Skip to content

Commit f3a7505

Browse files
committed
adding MC processes
1 parent a9a2fa8 commit f3a7505

File tree

1 file changed

+124
-2
lines changed

1 file changed

+124
-2
lines changed

PWGCF/JCorran/Tasks/jEPFlowAnalysis.cxx

Lines changed: 124 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "Common/DataModel/EventSelection.h"
2222
#include "Common/DataModel/Qvectors.h"
2323
#include "Common/DataModel/TrackSelectionTables.h"
24+
#include "Common/DataModel/Centrality.h"
2425

2526
#include "CCDB/BasicCCDBManager.h"
2627
#include "CCDB/CcdbApi.h"
@@ -32,13 +33,17 @@
3233
#include <string>
3334
#include <vector>
3435

36+
#include <TDatabasePDG.h>
37+
3538
using namespace o2;
3639
using namespace o2::framework;
3740
using namespace o2::framework::expressions;
3841
using namespace std;
3942

4043
using MyCollisions = soa::Join<aod::Collisions, aod::EvSels, aod::Qvectors>;
4144
using MyTracks = soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::TrackSelection>;
45+
using MyCollisionsMC = soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0Cs, aod::McCollisionLabels>;
46+
using MyTracksMC = soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::TrackSelection, aod::McTrackLabels>;
4247

4348
struct jEPFlowAnalysis {
4449

@@ -96,6 +101,12 @@ struct jEPFlowAnalysis {
96101
ConfigurableAxis cfgAxisCos{"cfgAxisCos", {102, -1.02, 1.02}, ""};
97102
ConfigurableAxis cfgAxisQvec{"cfgAxisQvec", {200, -5.0, 5.0}, ""};
98103

104+
ConfigurableAxis cfgAxisCentMC{"cfgAxisCentMC", {5, 0, 100}, ""};
105+
ConfigurableAxis cfgAxisVtxZMC{"cfgAxisVtxZMC", {20, -10, 10}, ""};
106+
ConfigurableAxis cfgAxisEtaMC{"cfgAxisEtaMC", {20, -1, 1}, ""};
107+
ConfigurableAxis cfgAxisPhiMC{"cfgAxisPhiMC", {36, 0, constants::math::PI * 2.0}, ""};
108+
ConfigurableAxis cfgAxisPtMC{"cfgAxisPtMC", {VARIABLE_WIDTH, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 10.0, 12.0, 15.0, 30.0, 50.0, 70.0, 100.0}, ""};
109+
99110
Filter trackFilter = (aod::track::pt > cfgTrackCuts.cfgPtMin) && (nabs(aod::track::eta) < cfgTrackCuts.cfgEtaMax);
100111

101112
int detId;
@@ -169,6 +180,7 @@ struct jEPFlowAnalysis {
169180
effVars[1] = eff->GetAxis(1)->FindBin(pt);
170181
effVars[2] = eff->GetAxis(2)->FindBin(multiplicity);
171182
effVars[3] = eff->GetAxis(3)->FindBin(posZ);
183+
172184
return eff->GetBinContent(effVars);
173185
}
174186

@@ -193,6 +205,12 @@ struct jEPFlowAnalysis {
193205
AxisSpec axisCos{cfgAxisCos, "cos"};
194206
AxisSpec axisQvec{cfgAxisQvec, "Qvec"};
195207

208+
AxisSpec axisCentMC{cfgAxisCentMC, "cent"};
209+
AxisSpec axisVtxZMC{cfgAxisVtxZMC, "vtxz"};
210+
AxisSpec axisEtaMC{cfgAxisEtaMC, "eta"};
211+
AxisSpec axisPhiMC{cfgAxisPhiMC, "phi"};
212+
AxisSpec axisPtMC{cfgAxisPtMC, "pt"};
213+
196214
epFlowHistograms.add("EpDet", "", {HistType::kTH3F, {axisMod, axisCent, axisEvtPl}});
197215
epFlowHistograms.add("EpRefA", "", {HistType::kTH3F, {axisMod, axisCent, axisEvtPl}});
198216
epFlowHistograms.add("EpRefB", "", {HistType::kTH3F, {axisMod, axisCent, axisEvtPl}});
@@ -216,6 +234,10 @@ struct jEPFlowAnalysis {
216234

217235
epFlowHistograms.add("hCentrality", "", {HistType::kTH1F, {axisCent}});
218236
epFlowHistograms.add("hVertex", "", {HistType::kTH1F, {axisVertex}});
237+
238+
epFlowHistograms.add("MC/hPartGen", "", {kTHnSparseF, {cfgAxisCentMC, cfgAxisVtxZMC, cfgAxisEtaMC, cfgAxisPhiMC, cfgAxisPtMC}});
239+
epFlowHistograms.add("MC/hPartRecPr", "", {kTHnSparseF, {cfgAxisCentMC, cfgAxisVtxZMC, cfgAxisEtaMC, cfgAxisPhiMC, cfgAxisPtMC}});
240+
epFlowHistograms.add("MC/hPartRec", "", {kTHnSparseF, {cfgAxisCentMC, cfgAxisVtxZMC, cfgAxisEtaMC, cfgAxisPhiMC, cfgAxisPtMC}});
219241
}
220242

221243
void processDefault(MyCollisions::iterator const& coll, soa::Filtered<MyTracks> const& tracks, aod::BCsWithTimestamps const&)
@@ -251,7 +273,11 @@ struct jEPFlowAnalysis {
251273

252274
if (cfgEffCor) {
253275
auto bc = coll.bc_as<aod::BCsWithTimestamps>();
254-
effMap = ccdb->getForTimeStamp<THnT<float>>(cfgEffCorDir, bc.timestamp());
276+
currentRunNumber = bc.runNumber();
277+
if (currentRunNumber != lastRunNumber) {
278+
effMap = ccdb->getForTimeStamp<THnT<float>>(cfgEffCorDir, bc.timestamp());
279+
lastRunNumber = currentRunNumber;
280+
}
255281
}
256282

257283
float cent = coll.cent();
@@ -350,7 +376,7 @@ struct jEPFlowAnalysis {
350376
continue;
351377

352378
if (cfgEffCor) {
353-
weight /= getEfficiencyCorrection(effMap, track.eta(), track.pt(), cent, coll.posZ());
379+
weight = getEfficiencyCorrection(effMap, track.eta(), track.pt(), cent, coll.posZ());
354380
}
355381

356382
float vn = std::cos((i + 2) * (track.phi() - eps[0]));
@@ -365,6 +391,102 @@ struct jEPFlowAnalysis {
365391
}
366392
}
367393
PROCESS_SWITCH(jEPFlowAnalysis, processDefault, "default process", true);
394+
395+
void processMCRec(MyCollisionsMC::iterator const& coll, MyTracksMC const& tracks, aod::McParticles const& /*mcParticles*/, aod::McCollisions const& /*mcCollisions*/)
396+
{
397+
if (!coll.has_mcCollision()) {
398+
return;
399+
}
400+
401+
if (cfgAddEvtSel) {
402+
if (std::abs(coll.posZ()) > cfgVertexZ)
403+
return;
404+
switch (cfgEvtSel) {
405+
case 0: // Sel8
406+
if (!coll.sel8())
407+
return;
408+
break;
409+
case 1: // PbPb standard
410+
if (!coll.sel8() || !coll.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !coll.selection_bit(aod::evsel::kNoSameBunchPileup))
411+
return;
412+
break;
413+
case 2: // PbPb with pileup
414+
if (!coll.sel8() || !coll.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard) ||
415+
!coll.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !coll.selection_bit(aod::evsel::kNoSameBunchPileup))
416+
return;
417+
break;
418+
case 3: // Small systems (OO, NeNe, pp)
419+
if (!coll.sel8() || !coll.selection_bit(aod::evsel::kNoSameBunchPileup))
420+
return;
421+
break;
422+
default:
423+
LOGF(warning, "Event selection flag was not found, continuing without basic event selections!\n");
424+
}
425+
// Check occupancy
426+
if (coll.trackOccupancyInTimeRange() > cfgMaxOccupancy || coll.trackOccupancyInTimeRange() < cfgMinOccupancy)
427+
return;
428+
}
429+
430+
float cent = coll.centFT0C();
431+
432+
if (cfgEffCor) {
433+
auto bc = coll.bc_as<aod::BCsWithTimestamps>();
434+
currentRunNumber = bc.runNumber();
435+
if (currentRunNumber != lastRunNumber) {
436+
effMap = ccdb->getForTimeStamp<THnT<float>>(cfgEffCorDir, bc.timestamp());
437+
lastRunNumber = currentRunNumber;
438+
}
439+
}
440+
441+
for (auto trk : tracks) {
442+
if (!trk.has_mcParticle()) {
443+
continue;
444+
}
445+
446+
if (trackSel(trk)) {
447+
continue;
448+
}
449+
450+
epFlowHistograms.fill(HIST("MC/hPartRec"), cent, coll.posZ(), trk.eta(), trk.phi(), trk.pt());
451+
auto mctrk = trk.mcParticle();
452+
if (mctrk.isPhysicalPrimary()) {
453+
epFlowHistograms.fill(HIST("MChPartRecPr"), cent, coll.posZ(), trk.eta(), trk.phi(), trk.pt());
454+
}
455+
}
456+
}
457+
PROCESS_SWITCH(jEPFlowAnalysis, processMCRec, "process for MC", false);
458+
459+
void processMCGen(MyCollisionsMC::iterator const& coll, aod::McParticles const& mcParticles, aod::McCollisions const&)
460+
{
461+
if (!coll.has_mcCollision()) return;
462+
const auto mcColl = coll.mcCollision();
463+
464+
if (cfgAddEvtSel) {
465+
if (std::abs(mcColl.posZ()) > cfgVertexZ) {
466+
return;
467+
}
468+
}
469+
470+
float cent = coll.centFT0C();
471+
472+
for (auto& mcParticle : mcParticles) {
473+
if (std::abs(mcParticle.eta()) > cfgTrackCuts.cfgEtaMax)
474+
continue;
475+
476+
auto* p = TDatabasePDG::Instance()->GetParticle(mcParticle.pdgCode());
477+
if (p) {
478+
if (std::abs(p->Charge()) < 1e-1) {
479+
continue;
480+
}
481+
}
482+
483+
if (!mcParticle.isPhysicalPrimary())
484+
continue;
485+
486+
epFlowHistograms.fill(HIST("MC/hPartGen"), cent, mcColl.posZ(), mcParticle.eta(), mcParticle.phi(), mcParticle.pt());
487+
}
488+
}
489+
PROCESS_SWITCH(jEPFlowAnalysis, processMCGen, "process for MC", false);
368490
};
369491

370492
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

0 commit comments

Comments
 (0)