Skip to content

Commit 78991e2

Browse files
authored
add on-the-fly process
1 parent 93aaf9e commit 78991e2

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

PWGCF/TwoParticleCorrelations/Tasks/diHadronCor.cxx

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,13 @@ struct DiHadronCor {
245245
registry.add("Trig_hist", "", {HistType::kTHnSparseF, {{axisSample, axisVertex, axisPtTrigger}}});
246246

247247
registry.add("eventcount", "bin", {HistType::kTH1F, {{4, 0, 4, "bin"}}}); // histogram to see how many events are in the same and mixed event
248-
if (doprocessMCSame) {
248+
if (doprocessMCSame && doprocessOntheflySame) {
249+
LOGF(fatal, "Full simulation and on-the-fly processing of same event not supported");
250+
}
251+
if (doprocessMCMixed && doprocessOntheflyMixed) {
252+
LOGF(fatal, "Full simulation and on-the-fly processing of mixed event not supported");
253+
}
254+
if (doprocessMCSame || doprocessOntheflySame) {
249255
registry.add("MCTrue/MCeventcount", "MCeventcount", {HistType::kTH1F, {{4, 0, 4, "bin"}}}); // histogram to see how many events are in the same and mixed event
250256
registry.add("MCTrue/MCCentrality", hCentTitle.c_str(), {HistType::kTH1D, {axisCentrality}});
251257
registry.add("MCTrue/MCNch", "N_{ch}", {HistType::kTH1D, {axisMultiplicity}});
@@ -806,6 +812,66 @@ struct DiHadronCor {
806812
}
807813
}
808814
PROCESS_SWITCH(DiHadronCor, processMCMixed, "Process MC mixed events", false);
815+
816+
void processOntheflySame(FilteredMcCollisions::iterator const& mcCollision, FilteredMcParticles const& mcParticles)
817+
{
818+
if (cfgVerbosity) {
819+
LOGF(info, "processOntheflySame. MC collision: %d, particles: %d", mcCollision.globalIndex(), mcParticles.size());
820+
}
821+
822+
if (cfgSelCollByNch && (mcParticles.size() < cfgCutMultMin || mcParticles.size() >= cfgCutMultMax)) {
823+
return;
824+
}
825+
826+
registry.fill(HIST("MCTrue/MCeventcount"), SameEvent); // because its same event i put it in the 1 bin
827+
registry.fill(HIST("MCTrue/MCNch"), mcParticles.size());
828+
registry.fill(HIST("MCTrue/MCzVtx"), mcCollision.posZ());
829+
for (const auto& mcParticle : mcParticles) {
830+
if (mcParticle.isPhysicalPrimary()) {
831+
registry.fill(HIST("MCTrue/MCPhi"), mcParticle.phi());
832+
registry.fill(HIST("MCTrue/MCEta"), mcParticle.eta());
833+
registry.fill(HIST("MCTrue/MCpT"), mcParticle.pt());
834+
}
835+
}
836+
837+
same->fillEvent(mcParticles.size(), CorrelationContainer::kCFStepAll);
838+
fillMCCorrelations<CorrelationContainer::kCFStepAll>(mcParticles, mcParticles, mcCollision.posZ(), SameEvent);
839+
840+
same->fillEvent(mcParticles.size(), CorrelationContainer::kCFStepTrackedOnlyPrim);
841+
fillMCCorrelations<CorrelationContainer::kCFStepTrackedOnlyPrim>(mcParticles, mcParticles, mcCollision.posZ(), SameEvent);
842+
}
843+
PROCESS_SWITCH(DiHadronCor, processOntheflySame, "Process on-the-fly same event", false);
844+
845+
void processOntheflyMixed(FilteredMcCollisions const& mcCollisions, FilteredMcParticles const& mcParticles)
846+
{
847+
auto getTracksSize = [&mcParticles, this](FilteredMcCollisions::iterator const& mcCollision) {
848+
auto associatedTracks = mcParticles.sliceByCached(o2::aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), this->cache);
849+
auto mult = associatedTracks.size();
850+
return mult;
851+
};
852+
853+
using MixedBinning = FlexibleBinningPolicy<std::tuple<decltype(getTracksSize)>, o2::aod::mccollision::PosZ, decltype(getTracksSize)>;
854+
855+
MixedBinning binningOnVtxAndMult{{getTracksSize}, {axisVtxMix, axisMultMix}, true};
856+
857+
auto tracksTuple = std::make_tuple(mcParticles, mcParticles);
858+
Pair<FilteredMcCollisions, FilteredMcParticles, FilteredMcParticles, MixedBinning> pair{binningOnVtxAndMult, cfgMixEventNumMin, -1, mcCollisions, tracksTuple, &cache}; // -1 is the number of the bin to skip
859+
for (auto const& [collision1, tracks1, collision2, tracks2] : pair) {
860+
861+
if (cfgSelCollByNch && (tracks1.size() < cfgCutMultMin || tracks1.size() >= cfgCutMultMax))
862+
continue;
863+
864+
if (cfgSelCollByNch && (tracks2.size() < cfgCutMultMin || tracks2.size() >= cfgCutMultMax))
865+
continue;
866+
867+
registry.fill(HIST("MCTrue/MCeventcount"), MixedEvent); // fill the mixed event in the 3 bin
868+
869+
fillMCCorrelations<CorrelationContainer::kCFStepAll>(tracks1, tracks2, collision1.posZ(), MixedEvent);
870+
871+
fillMCCorrelations<CorrelationContainer::kCFStepTrackedOnlyPrim>(tracks1, tracks2, collision1.posZ(), MixedEvent);
872+
}
873+
}
874+
PROCESS_SWITCH(DiHadronCor, processOntheflyMixed, "Process on-the-fly mixed events", false);
809875
};
810876

811877
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

0 commit comments

Comments
 (0)