Skip to content

Commit 12de1de

Browse files
committed
Merge remote-tracking branch 'upstream/master' into souravspincor
2 parents 13c0404 + d2c66ee commit 12de1de

File tree

6 files changed

+1039
-22
lines changed

6 files changed

+1039
-22
lines changed

PWGHF/Tasks/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ o2physics_add_dpl_workflow(task-pid-studies
4949
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::EventFilteringUtils O2Physics::AnalysisCCDB
5050
COMPONENT_NAME Analysis)
5151

52+
o2physics_add_dpl_workflow(task-mc-injection
53+
SOURCES taskMcInjection.cxx
54+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
55+
COMPONENT_NAME Analysis)
56+
5257
# o2physics_add_dpl_workflow(task-sel-optimisation
5358
# SOURCES taskSelOptimisation.cxx
5459
# PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore

PWGHF/Tasks/taskMcInjection.cxx

Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \file taskMcInjection.cxx
13+
/// \brief Task for checking injected events in Pb-Pb MC productions
14+
///
15+
/// \author Fabrizio Chinu <fabrizio.chinu@cern.ch>, Università and INFN Torino
16+
17+
#include "Common/DataModel/Centrality.h"
18+
19+
#include <Framework/ASoA.h>
20+
#include <Framework/AnalysisDataModel.h>
21+
#include <Framework/AnalysisHelpers.h>
22+
#include <Framework/AnalysisTask.h>
23+
#include <Framework/Configurable.h>
24+
#include <Framework/HistogramRegistry.h>
25+
#include <Framework/HistogramSpec.h>
26+
#include <Framework/InitContext.h>
27+
#include <Framework/runDataProcessing.h>
28+
29+
#include <TH1.h>
30+
#include <TPDGCode.h>
31+
32+
#include <cstdlib>
33+
#include <memory>
34+
#include <unordered_set>
35+
#include <vector>
36+
37+
using namespace o2;
38+
using namespace o2::framework;
39+
using namespace o2::framework::expressions;
40+
41+
namespace o2::aod
42+
{
43+
namespace check_mc_pv_contr
44+
{
45+
// Collisions
46+
DECLARE_SOA_COLUMN(IdCollGen, idCollGen, int); //! Generated collision index
47+
DECLARE_SOA_COLUMN(ImpParGen, impParGen, float); //! Generated impact parameter
48+
DECLARE_SOA_COLUMN(XCollGen, xCollGen, float); //! Generated x coordinate of the collision
49+
DECLARE_SOA_COLUMN(YCollGen, yCollGen, float); //! Generated y coordinate of the collision
50+
DECLARE_SOA_COLUMN(ZCollGen, zCollGen, float); //! Generated z coordinate of the collision
51+
DECLARE_SOA_COLUMN(TimeGen, timeGen, float); //! Generated collision time
52+
DECLARE_SOA_COLUMN(TimeRec, timeRec, float); //! Reconstructed collision time
53+
DECLARE_SOA_COLUMN(NCharm, nCharm, int); //! Number of charm quarks in the collision
54+
DECLARE_SOA_COLUMN(NCharmFromInj, nCharmFromInj, int); //! Number of charm quarks from injected events
55+
DECLARE_SOA_COLUMN(NPVContributors, nPVContributors, int); //! Number of contributors to the PV
56+
DECLARE_SOA_COLUMN(Centrality, centrality, int); //! Centrality FT0C
57+
DECLARE_SOA_COLUMN(XCollRec, xCollRec, float); //! Reconstructed x coordinate of the collision
58+
DECLARE_SOA_COLUMN(YCollRec, yCollRec, float); //! Reconstructed y coordinate of the collision
59+
DECLARE_SOA_COLUMN(ZCollRec, zCollRec, float); //! Reconstructed z coordinate of the collision
60+
DECLARE_SOA_COLUMN(Bc, bc, int); //! Bunch crossing
61+
// Tracks
62+
DECLARE_SOA_COLUMN(Vx, vx, float); // x coordinate of the track production vertex
63+
DECLARE_SOA_COLUMN(Vy, vy, float); // y coordinate of the track production vertex
64+
DECLARE_SOA_COLUMN(Vz, vz, float); // z coordinate of the track production vertex
65+
DECLARE_SOA_COLUMN(IsFromSignal, isFromSignal, bool); // Whether the track is from the signal event
66+
} // namespace check_mc_pv_contr
67+
68+
DECLARE_SOA_TABLE(CheckInj, "AOD", "CHECKINJ", //! Table with PID information
69+
check_mc_pv_contr::IdCollGen,
70+
check_mc_pv_contr::ImpParGen,
71+
check_mc_pv_contr::XCollGen,
72+
check_mc_pv_contr::YCollGen,
73+
check_mc_pv_contr::ZCollGen,
74+
check_mc_pv_contr::TimeGen,
75+
check_mc_pv_contr::XCollRec,
76+
check_mc_pv_contr::YCollRec,
77+
check_mc_pv_contr::ZCollRec,
78+
check_mc_pv_contr::TimeRec,
79+
check_mc_pv_contr::NCharm,
80+
check_mc_pv_contr::NCharmFromInj,
81+
check_mc_pv_contr::NPVContributors,
82+
check_mc_pv_contr::Centrality,
83+
check_mc_pv_contr::Bc);
84+
85+
DECLARE_SOA_TABLE(TracksInjection, "AOD", "TRKINJ", //! Table with MC labels for tracks
86+
check_mc_pv_contr::IdCollGen,
87+
check_mc_pv_contr::Vx,
88+
check_mc_pv_contr::Vy,
89+
check_mc_pv_contr::Vz,
90+
check_mc_pv_contr::IsFromSignal);
91+
} // namespace o2::aod
92+
93+
struct HfTaskMcInjection {
94+
95+
Produces<o2::aod::CheckInj> checkInj;
96+
Produces<o2::aod::TracksInjection> tracksInj;
97+
98+
Configurable<double> centMaxForCollDelta{"centMaxForCollDelta", 20., "max. cent. for gen-rec collision position histograms"};
99+
Configurable<int> nPvContribMaxForCollDelta{"nPvContribMaxForCollDelta", 2000, "max. PV contrib. for gen-rec collision position histograms"};
100+
101+
std::shared_ptr<TH1> hCharmPerCollImpPar, hCollisions;
102+
103+
using TrackWLabels = soa::Join<aod::Tracks, aod::McTrackLabels>;
104+
using CollisionWLabels = soa::Join<aod::Collisions, aod::McCollisionLabels, aod::CentFT0Cs, aod::CentNTPVs>;
105+
106+
Preslice<TrackWLabels> tracksPerCollision = aod::track::collisionId;
107+
Preslice<aod::McParticles> perMcCollision = aod::mcparticle::mcCollisionId;
108+
PresliceUnsorted<CollisionWLabels> colPerMcCollision = aod::mccollisionlabel::mcCollisionId;
109+
110+
HistogramRegistry registry{"registry", {}};
111+
112+
void init(InitContext&)
113+
{
114+
AxisSpec impParBins = {200, 0, 20};
115+
AxisSpec deltaXYbins = {200, -0.05, 0.05};
116+
AxisSpec deltaZbins = {200, -10, 10};
117+
118+
registry.add("hCharmImpPar", ";Impact parameter (fm);Charm counts", {HistType::kTH1F, {impParBins}});
119+
registry.add("hCollImpPar", ";Impact parameter (fm);Counts", {HistType::kTH1F, {impParBins}});
120+
hCharmPerCollImpPar = registry.add<TH1>("hCharmPerCollImpPar", ";Impact parameter (fm);Charm counts per collision", {HistType::kTH1F, {impParBins}});
121+
122+
registry.add("hDeltaX", ";#DeltaX (cm);Counts", {HistType::kTH1F, {{deltaXYbins}}});
123+
registry.add("hDeltaY", ";#DeltaY (cm);Counts", {HistType::kTH1F, {{deltaXYbins}}});
124+
registry.add("hDeltaZ", ";#DeltaZ (cm);Counts", {HistType::kTH1F, {{deltaZbins}}});
125+
126+
registry.add("hDeltaX_NPV_lt", ";#DeltaX (cm);Counts", {HistType::kTH1F, {{deltaXYbins}}});
127+
registry.add("hDeltaY_NPV_lt", ";#DeltaY (cm);Counts", {HistType::kTH1F, {{deltaXYbins}}});
128+
registry.add("hDeltaZ_NPV_lt", ";#DeltaZ (cm);Counts", {HistType::kTH1F, {{deltaZbins}}});
129+
130+
registry.add("hDeltaX_NPV_gt", ";#DeltaX (cm);Counts", {HistType::kTH1F, {{deltaXYbins}}});
131+
registry.add("hDeltaY_NPV_gt", ";#DeltaY (cm);Counts", {HistType::kTH1F, {{deltaXYbins}}});
132+
registry.add("hDeltaZ_NPV_gt", ";#DeltaZ (cm);Counts", {HistType::kTH1F, {{deltaZbins}}});
133+
134+
registry.add("hDeltaXSngBkg", ";#DeltaX (signal/bkg) (cm);Counts", {HistType::kTH1F, {{200, -10, 10}}});
135+
registry.add("hDeltaYSngBkg", ";#DeltaY (signal/bkg) (cm);Counts", {HistType::kTH1F, {{200, -10, 10}}});
136+
registry.add("hDeltaZSngBkg", ";#DeltaZ (signal/bkg) (cm);Counts", {HistType::kTH1F, {{200, -20, 20}}});
137+
138+
hCollisions = registry.add<TH1>("hCollisions", ";;Counts", {HistType::kTH1F, {{2, 0.5, 2.5}}});
139+
hCollisions->GetXaxis()->SetBinLabel(1, "Generated");
140+
hCollisions->GetXaxis()->SetBinLabel(2, "Reconstructed");
141+
}
142+
143+
bool isCharm(int pdg)
144+
{
145+
if (std::abs(pdg) / 1000 == PDG_t::kCharm) // o2-linter: disable=magic-number (get thousands digit)
146+
return true;
147+
if (std::abs(pdg) / 100 == PDG_t::kCharm) // o2-linter: disable=magic-number (get hundreds digit)
148+
return true;
149+
return false;
150+
}
151+
152+
bool isBeauty(int pdg) // if needed in the future
153+
{
154+
if (std::abs(pdg) / 1000 == PDG_t::kBottom) // o2-linter: disable=magic-number (get thousands digit)
155+
return true;
156+
if (std::abs(pdg) / 100 == PDG_t::kBottom) // o2-linter: disable=magic-number (get hundreds digit)
157+
return true;
158+
return false;
159+
}
160+
161+
void process(CollisionWLabels const& collisions,
162+
TrackWLabels const& tracks,
163+
aod::McParticles const& mcParticles,
164+
aod::McCollisions const& mcCollisions)
165+
{
166+
for (const auto& mcColl : mcCollisions) {
167+
registry.fill(HIST("hCollImpPar"), mcColl.impactParameter());
168+
const auto mcPartColl = mcParticles.sliceBy(perMcCollision, mcColl.globalIndex());
169+
double xAvgSgn{0.}, yAvgSgn{0.}, zAvgSgn{0.};
170+
double xAvgBkg{0.}, yAvgBkg{0.}, zAvgBkg{0.};
171+
int nSgn{0}, nBkg{0};
172+
for (const auto& mcPart : mcPartColl) {
173+
if (isCharm(mcPart.pdgCode())) { // charm hadron
174+
registry.fill(HIST("hCharmImpPar"), mcColl.impactParameter());
175+
}
176+
if (mcPart.fromBackgroundEvent()) {
177+
xAvgBkg += mcPart.vx();
178+
yAvgBkg += mcPart.vy();
179+
zAvgBkg += mcPart.vz();
180+
nBkg++;
181+
tracksInj(mcPart.mcCollisionId(), mcPart.vx(), mcPart.vy(), mcPart.vz(), false);
182+
} else {
183+
xAvgSgn += mcPart.vx();
184+
yAvgSgn += mcPart.vy();
185+
zAvgSgn += mcPart.vz();
186+
nSgn++;
187+
tracksInj(mcPart.mcCollisionId(), mcPart.vx(), mcPart.vy(), mcPart.vz(), true);
188+
}
189+
}
190+
registry.fill(HIST("hDeltaXSngBkg"), xAvgSgn / nSgn - xAvgBkg / nBkg);
191+
registry.fill(HIST("hDeltaYSngBkg"), yAvgSgn / nSgn - yAvgBkg / nBkg);
192+
registry.fill(HIST("hDeltaZSngBkg"), zAvgSgn / nSgn - zAvgBkg / nBkg);
193+
194+
const auto collSlice = collisions.sliceBy(colPerMcCollision, mcColl.globalIndex());
195+
196+
// Then we fill the histogram with the distances of the collisions
197+
for (const auto& collision : collSlice) {
198+
const auto collTracks = tracks.sliceBy(tracksPerCollision, collision.globalIndex());
199+
int fromSignalEv{0};
200+
if (collision.centFT0C() < centMaxForCollDelta) {
201+
registry.fill(HIST("hDeltaX"), collision.posX() - collision.mcCollision().posX());
202+
registry.fill(HIST("hDeltaY"), collision.posY() - collision.mcCollision().posY());
203+
registry.fill(HIST("hDeltaZ"), collision.posZ() - collision.mcCollision().posZ());
204+
205+
if (collision.numContrib() > nPvContribMaxForCollDelta) {
206+
registry.fill(HIST("hDeltaX_NPV_gt"), collision.posX() - collision.mcCollision().posX());
207+
registry.fill(HIST("hDeltaY_NPV_gt"), collision.posY() - collision.mcCollision().posY());
208+
registry.fill(HIST("hDeltaZ_NPV_gt"), collision.posZ() - collision.mcCollision().posZ());
209+
} else {
210+
registry.fill(HIST("hDeltaX_NPV_lt"), collision.posX() - collision.mcCollision().posX());
211+
registry.fill(HIST("hDeltaY_NPV_lt"), collision.posY() - collision.mcCollision().posY());
212+
registry.fill(HIST("hDeltaZ_NPV_lt"), collision.posZ() - collision.mcCollision().posZ());
213+
}
214+
}
215+
std::unordered_set<int> charmIds{};
216+
for (const auto& track : collTracks) {
217+
if (track.has_mcParticle()) {
218+
auto mcPart = track.mcParticle_as<aod::McParticles>();
219+
for (const auto& mother : mcPart.mothers_as<aod::McParticles>()) {
220+
if (isCharm(mother.pdgCode())) { // charm hadron
221+
if (!charmIds.contains(mother.globalIndex())) {
222+
charmIds.emplace(mother.globalIndex());
223+
fromSignalEv += static_cast<int>(!mother.fromBackgroundEvent());
224+
}
225+
break;
226+
}
227+
}
228+
}
229+
}
230+
checkInj(
231+
mcColl.globalIndex(), mcColl.impactParameter(),
232+
mcColl.posX(), mcColl.posY(), mcColl.posZ(), mcColl.t(),
233+
collision.posX(), collision.posY(), collision.posZ(), collision.collisionTime(),
234+
charmIds.size(), fromSignalEv, collision.numContrib(), collision.centFT0C(), collision.bcId());
235+
}
236+
}
237+
238+
hCharmPerCollImpPar->Divide(registry.get<TH1>(HIST("hCharmImpPar")).get(), registry.get<TH1>(HIST("hCollImpPar")).get(), 1, 1);
239+
hCollisions->Fill(1, mcCollisions.size());
240+
hCollisions->Fill(2, collisions.size());
241+
}
242+
};
243+
244+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
245+
{
246+
return WorkflowSpec{adaptAnalysisTask<HfTaskMcInjection>(cfgc)};
247+
}

PWGJE/Tasks/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ if(FastJet_FOUND)
160160
SOURCES jetFinderQA.cxx
161161
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore
162162
COMPONENT_NAME Analysis)
163+
o2physics_add_dpl_workflow(jet-outlier-qa
164+
SOURCES jetOutlierQA.cxx
165+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore
166+
COMPONENT_NAME Analysis)
163167
o2physics_add_dpl_workflow(jet-charged-v2
164168
SOURCES jetChargedV2.cxx
165169
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore

0 commit comments

Comments
 (0)