diff --git a/PWGUD/Tasks/flowCorrelationsUpc.cxx b/PWGUD/Tasks/flowCorrelationsUpc.cxx index baf24af6f94..81235ce9c6f 100644 --- a/PWGUD/Tasks/flowCorrelationsUpc.cxx +++ b/PWGUD/Tasks/flowCorrelationsUpc.cxx @@ -69,7 +69,7 @@ struct CalcNchUpc { using UdTracks = soa::Join; using UdTracksFull = soa::Join; - using UDCollisionsFull = soa::Join; + using UDCollisionsFull = soa::Join; Produces multiplicityNch; @@ -103,6 +103,9 @@ struct FlowCorrelationsUpc { O2_DEFINE_CONFIGURABLE(cfgSampleSize, double, 10, "Sample size for mixed event") O2_DEFINE_CONFIGURABLE(cfgUsePtOrder, bool, true, "enable trigger pT < associated pT cut") O2_DEFINE_CONFIGURABLE(cfgUsePtOrderInMixEvent, bool, true, "enable trigger pT < associated pT cut in mixed event") + O2_DEFINE_CONFIGURABLE(cfgCutMerging, float, 0.0, "Merging cut on track merge") + O2_DEFINE_CONFIGURABLE(cfgRadiusLow, float, 0.8, "Low radius for merging cut") + O2_DEFINE_CONFIGURABLE(cfgRadiusHigh, float, 2.5, "High radius for merging cut") ConfigurableAxis axisVertex{"axisVertex", {10, -10, 10}, "vertex axis for histograms"}; ConfigurableAxis axisEta{"axisEta", {40, -1., 1.}, "eta axis for histograms"}; @@ -135,7 +138,7 @@ struct FlowCorrelationsUpc { using UdTracks = soa::Join; using UdTracksFull = soa::Join; - using UDCollisionsFull = soa::Join; + using UDCollisionsFull = soa::Join; // Define the outputs OutputObj same{Form("sameEvent_%i_%i", static_cast(cfgMinMult), static_cast(cfgMaxMult))}; @@ -180,6 +183,63 @@ struct FlowCorrelationsUpc { MixedEvent = 3 }; + template + float getDPhiStar(TTrack const& track1, TTrack const& track2, float radius, int runnum, float phi1, float phi2) + { + float charge1 = track1.sign(); + float charge2 = track2.sign(); + + float pt1 = track1.pt(); + float pt2 = track2.pt(); + + int fbSign = 1; + + int zzo = 544868; + if (runnum >= zzo) { + fbSign = -1; + } + + float dPhiStar = phi1 - phi2 - charge1 * fbSign * std::asin(0.075 * radius / pt1) + charge2 * fbSign * std::asin(0.075 * radius / pt2); + + if (dPhiStar > constants::math::PI) + dPhiStar = constants::math::TwoPI - dPhiStar; + if (dPhiStar < -constants::math::PI) + dPhiStar = -constants::math::TwoPI - dPhiStar; + + return dPhiStar; + } + + template + bool trackSelected(TTrack track) + { + // UPC selection + if (!track.isPVContributor()) { + return false; + } + constexpr float kDcazCut = 2.0; + if (!(std::fabs(track.dcaZ()) < kDcazCut)) { + return false; + } + double dcaLimit = 0.0105 + 0.035 / std::pow(track.pt(), 1.1); + if (!(std::fabs(track.dcaXY()) < dcaLimit)) { + return false; + } + constexpr int kMinTPCClusters = 70; + constexpr int kMinITSClusters = 5; + constexpr int kMaxTPCChi2NCl = 4; + + if (track.tpcNClsFindableMinusCrossedRows() <= kMinTPCClusters) { + return false; + } + if (track.itsClusterSizes() <= kMinITSClusters) { + return false; + } + if (track.tpcChi2NCl() >= kMaxTPCChi2NCl) { + return false; + } + return true; + } + // fill multiple histograms template void fillYield(TCollision collision, TTracks tracks) // function to fill the yield and etaphi histograms. @@ -196,7 +256,7 @@ struct FlowCorrelationsUpc { } template - void fillCorrelations(TTracks tracks1, TTracks tracks2, float posZ, int system) // function to fill the Output functions (sparse) and the delta eta and delta phi histograms + void fillCorrelations(TTracks tracks1, TTracks tracks2, float posZ, int system, int runnum) // function to fill the Output functions (sparse) and the delta eta and delta phi histograms { int fSampleIndex = gRandom->Uniform(0, cfgSampleSize); @@ -209,6 +269,8 @@ struct FlowCorrelationsUpc { } for (auto const& track2 : tracks2) { + if (!trackSelected(track2)) + continue; if (track1.globalIndex() == track2.globalIndex()) continue; // For pt-differential correlations, skip if the trigger and associate are the same track @@ -217,11 +279,37 @@ struct FlowCorrelationsUpc { auto momentum1 = std::array{track1.px(), track1.py(), track1.pz()}; auto momentum2 = std::array{track2.px(), track2.py(), track2.pz()}; + double pt2 = RecoDecay::pt(momentum2); double phi1 = RecoDecay::phi(momentum1); double phi2 = RecoDecay::phi(momentum2); float deltaPhi = RecoDecay::constrainAngle(phi1 - phi2, -PIHalf); float deltaEta = RecoDecay::eta(momentum1) - RecoDecay::eta(momentum2); + if (pt2 < cfgPtCutMin || pt2 > cfgPtCutMax) + continue; + + if (std::abs(deltaEta) < cfgCutMerging) { + + double dPhiStarHigh = getDPhiStar(track1, track2, cfgRadiusHigh, runnum, phi1, phi2); + double dPhiStarLow = getDPhiStar(track1, track2, cfgRadiusLow, runnum, phi1, phi2); + + const double kLimit = 3.0 * cfgCutMerging; + + bool bIsBelow = false; + + if (std::abs(dPhiStarLow) < kLimit || std::abs(dPhiStarHigh) < kLimit || dPhiStarLow * dPhiStarHigh < 0) { + for (double rad(cfgRadiusLow); rad < cfgRadiusHigh; rad += 0.01) { + double dPhiStar = getDPhiStar(track1, track2, rad, runnum, phi1, phi2); + if (std::abs(dPhiStar) < kLimit) { + bIsBelow = true; + break; + } + } + if (bIsBelow) + continue; + } + } + // fill the right sparse and histograms if (system == SameEvent) { same->getPairHist()->Fill(step, fSampleIndex, posZ, track1.pt(), track2.pt(), deltaPhi, deltaEta); @@ -236,17 +324,17 @@ struct FlowCorrelationsUpc { void processSame(UDCollisionsFull::iterator const& collision, UdTracksFull const& tracks) { - if (std::abs(collision.posZ()) > cfgZVtxCut) { + if (tracks.size() < cfgMinMult || tracks.size() > cfgMaxMult) { return; } - if (tracks.size() < cfgMinMult || tracks.size() > cfgMaxMult) { + if (collision.trs() == 0) { return; } int gapSide = collision.gapSide(); const int minGapSide = 0; const int maxGapSide = 2; - if (gapSide < minGapSide || gapSide > maxGapSide) { + if (gapSide > minGapSide && gapSide < maxGapSide) { return; } @@ -256,9 +344,11 @@ struct FlowCorrelationsUpc { return; } + int runIndex = collision.runNumber(); + registry.fill(HIST("eventcount"), SameEvent); // because its same event i put it in the 1 bin fillYield(collision, tracks); - fillCorrelations(tracks, tracks, collision.posZ(), SameEvent); // fill the SE histogram and Sparse + fillCorrelations(tracks, tracks, collision.posZ(), SameEvent, runIndex); // fill the SE histogram and Sparse } PROCESS_SWITCH(FlowCorrelationsUpc, processSame, "Process same event", true); @@ -275,8 +365,8 @@ struct FlowCorrelationsUpc { SameKindPair pairs{binningOnVtxAndMult, cfgMinMixEventNum, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip for (auto const& [collision1, tracks1, collision2, tracks2] : pairs) { - registry.fill(HIST("eventcount"), MixedEvent); // fill the mixed event in the 3 bin - fillCorrelations(tracks1, tracks2, collision1.posZ(), MixedEvent); + registry.fill(HIST("eventcount"), MixedEvent); // fill the mixed event in the 3 bin + fillCorrelations(tracks1, tracks2, collision1.posZ(), MixedEvent, collision1.runNumber()); // fill the ME histogram and Sparse } } PROCESS_SWITCH(FlowCorrelationsUpc, processMixed, "Process mixed events", true); diff --git a/PWGUD/Tasks/flowCumulantsUpc.cxx b/PWGUD/Tasks/flowCumulantsUpc.cxx index b97b8e26edc..12332abbd6a 100644 --- a/PWGUD/Tasks/flowCumulantsUpc.cxx +++ b/PWGUD/Tasks/flowCumulantsUpc.cxx @@ -21,7 +21,6 @@ #include "GFWWeights.h" #include "PWGUD/Core/SGSelector.h" -#include "PWGUD/Core/UPCHelpers.h" #include "PWGUD/DataModel/UDTables.h" #include "Common/CCDB/ctpRateFetcher.h" @@ -40,10 +39,7 @@ #include "Framework/runDataProcessing.h" #include -#include "Math/LorentzVector.h" -#include "Math/PxPyPzM4D.h" #include "TList.h" -#include "TMath.h" #include "TVector3.h" #include #include @@ -65,11 +61,6 @@ using namespace o2::framework::expressions; struct FlowCumulantsUpc { - // resort - // Preslice perCollision = aod::track::collisionId; - PresliceUnsorted perMcCollision = o2::aod::udmcparticle::udMcCollisionId; - // Preslice perCol = aod::track::collisionId; - O2_DEFINE_CONFIGURABLE(cfgCutVertex, float, 10.0f, "Accepted z-vertex range") O2_DEFINE_CONFIGURABLE(cfgCentEstimator, int, 0, "0:FT0C; 1:FT0CVariant1; 2:FT0M; 3:FT0A") O2_DEFINE_CONFIGURABLE(cfgCentFT0CMin, float, 0.0f, "Minimum centrality (FT0C) to cut events in filter") @@ -175,10 +166,9 @@ struct FlowCumulantsUpc { TH2* gCurrentHadronicRate; // - // using MCparticles = aod::UDMcParticles::iterator; using UdTracks = soa::Join; using UdTracksFull = soa::Join; - // using UDCollisionsFull = soa::Join; + using UDCollisionsFull = soa::Join; // Track selection TrackSelection myTrackSel; @@ -241,10 +231,6 @@ struct FlowCumulantsUpc { registry.add("hVtxZ", "Vexter Z distribution", {HistType::kTH1D, {axisVertex}}); registry.add("hMult", "Multiplicity distribution", {HistType::kTH1D, {{3000, 0.5, 3000.5}}}); std::string hCentTitle = "Centrality distribution, Estimator " + std::to_string(cfgCentEstimator); - registry.add("hCentMC", hCentTitle.c_str(), {HistType::kTH1D, {{90, 0, 90}}}); - registry.add("hVtxZMC", "Vexter Z distribution", {HistType::kTH1D, {axisVertex}}); - registry.add("hMultMC", "Multiplicity distribution", {HistType::kTH1D, {{3000, 0.5, 3000.5}}}); - registry.add("numberOfTracksMC", "Number of tracks per event", {HistType::kTH1D, {{1000, 0, 1000}}}); registry.add("hCent", hCentTitle.c_str(), {HistType::kTH1D, {{90, 0, 90}}}); if (!cfgUseSmallMemory) { registry.add("BeforeSel8_globalTracks_centT0C", "before sel8;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); @@ -281,10 +267,6 @@ struct FlowCumulantsUpc { registry.add("hDCAxy", "DCAxy after cuts; DCAxy (cm); Pt", {HistType::kTH2D, {{200, -0.5, 0.5}, {200, 0, 5}}}); registry.add("hTrackCorrection2d", "Correlation table for number of tracks table; uncorrected track; corrected track", {HistType::kTH2D, {axisNch, axisNch}}); - registry.add("hPxMc", "Px distribution of MC truth particles", {HistType::kTH1D, {{100, -10, 10}}}); - registry.add("hPyMc", "Px distribution of MC truth particles", {HistType::kTH1D, {{100, -10, 10}}}); - registry.add("hPzMc", "Px distribution of MC truth particles", {HistType::kTH1D, {{100, -10, 10}}}); - registry.add("hweightMc", "weight distribution of MC truth particles", {HistType::kTH1D, {{100, 0, 1}}}); registry.add("hPhiMC", "#phi distribution", {HistType::kTH1D, {axisPhi}}); registry.add("hPhiWeightedMC", "corrected #phi distribution", {HistType::kTH1D, {axisPhi}}); registry.add("hEtaMC", "#eta distribution", {HistType::kTH1D, {axisEta}}); @@ -297,7 +279,6 @@ struct FlowCumulantsUpc { registry.add("hnTPCCrossedRowMC", "Number of crossed TPC Rows", {HistType::kTH1D, {{100, 40, 180}}}); registry.add("hDCAzMC", "DCAz after cuts; DCAz (cm); Pt", {HistType::kTH2D, {{200, -0.5, 0.5}, {200, 0, 5}}}); registry.add("hDCAxyMC", "DCAxy after cuts; DCAxy (cm); Pt", {HistType::kTH2D, {{200, -0.5, 0.5}, {200, 0, 5}}}); - registry.add("eventCounterMC", "Number of MC Event;; Count", {HistType::kTH1D, {{5, 0, 5}}}); registry.add("hTrackCorrection2dMC", "Correlation table for number of tracks table; uncorrected track; corrected track", {HistType::kTH2D, {axisNch, axisNch}}); o2::framework::AxisSpec axis = axisPt; @@ -524,11 +505,9 @@ struct FlowCumulantsUpc { } LOGF(info, "%d: %s %s", i, userDefineGFWCorr.at(i).c_str(), userDefineGFWName.at(i).c_str()); corrconfigs.push_back(fGFW->GetCorrelatorConfig(userDefineGFWCorr.at(i).c_str(), userDefineGFWName.at(i).c_str(), kFALSE)); - corrconfigsmc.push_back(fGFWMC->GetCorrelatorConfig(userDefineGFWCorr.at(i).c_str(), userDefineGFWName.at(i).c_str(), kFALSE)); } } fGFW->CreateRegions(); - fGFWMC->CreateRegions(); if (cfgUseAdditionalEventCut) { fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); @@ -644,8 +623,6 @@ struct FlowCumulantsUpc { return; } - // ... 其余代码保持不变 ... - void loadCorrections(uint64_t timestamp, int runNumber) { if (correctionsLoaded) { @@ -815,10 +792,10 @@ struct FlowCumulantsUpc { if (!((multNTracksPV < fMultPVCutLow->Eval(centrality)) || (multNTracksPV > fMultPVCutHigh->Eval(centrality)) || (multTrk < fMultCutLow->Eval(centrality)) || (multTrk > fMultCutHigh->Eval(centrality)))) { registry.fill(HIST("hEventCountTentative"), 8.5); } - constexpr int kSigmaCut = 5; - if (!(std::fabs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > kSigmaCut * fT0AV0ASigma->Eval(collision.multFT0A()))) { - registry.fill(HIST("hEventCountTentative"), 9.5); - } + // constexpr int kSigmaCut = 5; + // if (!(std::fabs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > kSigmaCut * fT0AV0ASigma->Eval(collision.multFT0A()))) { + // registry.fill(HIST("hEventCountTentative"), 9.5); + // } } template @@ -836,6 +813,19 @@ struct FlowCumulantsUpc { if (!(std::fabs(track.dcaXY()) < dcaLimit)) { return false; } + constexpr int kMinTPCClusters = 70; + constexpr int kMinITSClusters = 5; + constexpr int kMaxTPCChi2NCl = 4; + + if (track.tpcNClsFindableMinusCrossedRows() <= kMinTPCClusters) { + return false; + } + if (track.itsClusterSizes() <= kMinITSClusters) { + return false; + } + if (track.tpcChi2NCl() >= kMaxTPCChi2NCl) { + return false; + } return true; } @@ -856,200 +846,207 @@ struct FlowCumulantsUpc { gCurrentHadronicRate = gHadronicRate[mRunNumber]; } - // void process(UDCollisionsFull::iterator const& collision, UdTracksFull const& tracks) - // { - // std::cout << "Processing collision============================================== " << std::endl; - - // registry.fill(HIST("hEventCount"), 0.5); - // int gapSide = collision.gapSide(); - // constexpr int kGapSideSelection = 0; - // constexpr int kGapSideOppositeSelection = 2; - // if (gapSide < kGapSideSelection || gapSide > kGapSideOppositeSelection) { - // return; - // } - - // int trueGapSide = sgSelector.trueGap(collision, cfgCutFV0, cfgCutFT0A, cfgCutFT0C, cfgCutZDC); - // gapSide = trueGapSide; - // if (gapSide == cfgGapSideSelection) { - // return; - // } - // registry.fill(HIST("hEventCount"), 1.5); - // float cent = 100; - // float lRandom = fRndm->Rndm(); - // float vtxz = collision.posZ(); - // registry.fill(HIST("hVtxZ"), vtxz); - // registry.fill(HIST("hMult"), tracks.size()); - // registry.fill(HIST("hCent"), cent); - // fGFW->Clear(); - - // // // track weights - // float weff = 1, wacc = 1; - // double nTracksCorrected = 0; - // float independent = cent; - // if (cfgUseNch) { - // independent = static_cast(tracks.size()); - // } - - // for (const auto& track : tracks) { - // if (!trackSelected(track)) - // continue; - // auto momentum = std::array{track.px(), track.py(), track.pz()}; - // double pt = RecoDecay::pt(momentum); - // double phi = RecoDecay::phi(momentum); - // double eta = RecoDecay::eta(momentum); - // bool withinPtPOI = (cfgCutPtPOIMin < pt) && (pt < cfgCutPtPOIMax); // within POI pT range - // bool withinPtRef = (cfgCutPtRefMin < pt) && (pt < cfgCutPtRefMax); // within RF pT range - // if (cfgOutputNUAWeights) { - // if (cfgOutputNUAWeightsRefPt) { - // if (withinPtRef) { - // fWeights->fill(phi, eta, vtxz, pt, cent, 0); - // } - // } else { - // fWeights->fill(phi, eta, vtxz, pt, cent, 0); - // } - // } - // if (!setCurrentParticleWeights(weff, wacc, phi, eta, pt, vtxz)) { - // continue; - // } - // registry.fill(HIST("hPt"), track.pt()); - // if (withinPtRef) { - // registry.fill(HIST("hPhi"), phi); - // registry.fill(HIST("hPhiWeighted"), phi, wacc); - // registry.fill(HIST("hEta"), eta); - // registry.fill(HIST("hPtRef"), pt); - // registry.fill(HIST("hDCAz"), track.dcaZ(), track.pt()); - // registry.fill(HIST("hDCAxy"), track.dcaXY(), track.pt()); - // nTracksCorrected += weff; - // } - // if (withinPtRef) { - // fGFW->Fill(eta, fPtAxis->FindBin(pt) - 1, phi, wacc * weff, 1); - // } - // if (withinPtPOI) { - // fGFW->Fill(eta, fPtAxis->FindBin(pt) - 1, phi, wacc * weff, 2); - // } - // if (withinPtPOI && withinPtRef) { - // fGFW->Fill(eta, fPtAxis->FindBin(pt) - 1, phi, wacc * weff, 4); - // } - // } - // registry.fill(HIST("hTrackCorrection2d"), tracks.size(), nTracksCorrected); - - // // Filling Flow Container - // for (uint l_ind = 0; l_ind < corrconfigs.size(); l_ind++) { - // fillFC(corrconfigs.at(l_ind), independent, lRandom); - // } - // } - // PROCESS_SWITCH(FlowCumulantsUpc, process, "process", false); - - //----------------------------------------------------------------------------------------------------------------------- - void processSim(aod::UDMcCollisions const& mcCollisions, aod::UDMcParticles const& mcParticles) + template + float getDPhiStar(TTrack const& track1, TTrack const& track2, float radius, int runnum) { - LOG(info) << "Processing MC collision======================== " << std::endl; - - // std::cout << mcParicles::IndexudmcCollisions.is_sorted(); + float charge1 = track1.sign(); + float charge2 = track2.sign(); - for (const auto& mcCollision : mcCollisions) { - auto groupedUDMcParticles = mcParticles.sliceBy(perMcCollision, mcCollision.globalIndex()); - registry.fill(HIST("eventCounterMC"), 0.5); + float phi1 = track1.phi(); + float phi2 = track2.phi(); - // registry.fill(HIST("hEventCount"), 1.5); - float cent = 50; - float vtxz = 0; + float pt1 = track1.pt(); + float pt2 = track2.pt(); - vtxz = mcCollision.posZ(); - registry.fill(HIST("hVtxZMC"), vtxz); - registry.fill(HIST("eventCounterMC"), mcCollision.size()); - registry.fill(HIST("hMultMC"), groupedUDMcParticles.size()); - registry.fill(HIST("hCentMC"), cent); + int fbSign = 1; - auto massPion = o2::constants::physics::MassPionCharged; - registry.fill(HIST("numberOfTracksMC"), groupedUDMcParticles.size()); - // LOGF(info, "New event! mcParticles.size() = %d", mcParticles.size()); + int zzo = 544868; + if (runnum >= zzo) { + fbSign = -1; + } - float lRandomMc = fRndmMc->Rndm(); - fGFWMC->Clear(); + float dPhiStar = phi1 - phi2 - charge1 * fbSign * std::asin(0.075 * radius / pt1) + charge2 * fbSign * std::asin(0.075 * radius / pt2); - // // track weights - float weff = 1, wacc = 1; - double nTracksCorrected = 0; - float independent = cent; - if (cfgUseNch) { - independent = static_cast(groupedUDMcParticles.size()); - } + if (dPhiStar > constants::math::PI) + dPhiStar = constants::math::TwoPI - dPhiStar; + if (dPhiStar < -constants::math::PI) + dPhiStar = -constants::math::TwoPI - dPhiStar; - // LOG(info) << "mcParticles.size() = " << groupedUDMcParticles.size() << std::endl; + return dPhiStar; + } - for (const auto& mcParticle : groupedUDMcParticles) { + void process(UDCollisionsFull::iterator const& collision, UdTracksFull const& tracks) + { + registry.fill(HIST("hEventCount"), 0.5); + // if(!eventSelected(collision, tracks.size(), 100.0f)) { + // eventCounterQA(collision, tracks.size(), 100.0f); + // return; + // } + int gapSide = collision.gapSide(); + constexpr int kGapSideSelection = 0; + constexpr int kGapSideOppositeSelection = 2; + if (gapSide > kGapSideSelection && gapSide < kGapSideOppositeSelection) { + return; + } + if (collision.trs() == 0) { + return; + } + int trueGapSide = sgSelector.trueGap(collision, cfgCutFV0, cfgCutFT0A, cfgCutFT0C, cfgCutZDC); + gapSide = trueGapSide; + if (gapSide == cfgGapSideSelection) { + return; + } + registry.fill(HIST("hEventCount"), 1.5); + float cent = 100; + float lRandom = fRndm->Rndm(); + float vtxz = collision.posZ(); + registry.fill(HIST("hVtxZ"), vtxz); + registry.fill(HIST("hMult"), tracks.size()); + registry.fill(HIST("hCent"), cent); + fGFW->Clear(); + + // // track weights + float weff = 1, wacc = 1; + double nTracksCorrected = 0; + float independent = cent; + if (cfgUseNch) { + independent = static_cast(tracks.size()); + } - // LOG(info) << "filling mc particle px: " << mcParticle.px() << ", py: " << mcParticle.py() << ", pz: " << mcParticle.pz() << std::endl; + for (const auto& track : tracks) { + registry.fill(HIST("hChi2prTPCcls"), track.tpcChi2NCl()); + if (!trackSelected(track)) + continue; + auto momentum = std::array{track.px(), track.py(), track.pz()}; + double pt = RecoDecay::pt(momentum); + double phi = RecoDecay::phi(momentum); + double eta = RecoDecay::eta(momentum); + bool withinPtPOI = (cfgCutPtPOIMin < pt) && (pt < cfgCutPtPOIMax); // within POI pT range + bool withinPtRef = (cfgCutPtRefMin < pt) && (pt < cfgCutPtRefMax); // within RF pT range + if (cfgOutputNUAWeights) { + if (cfgOutputNUAWeightsRefPt) { + if (withinPtRef) { + fWeights->fill(phi, eta, vtxz, pt, cent, 0); + } + } else { + fWeights->fill(phi, eta, vtxz, pt, cent, 0); + } + } + if (!setCurrentParticleWeights(weff, wacc, phi, eta, pt, vtxz)) { + continue; + } + registry.fill(HIST("hPt"), track.pt()); + if (withinPtRef) { + registry.fill(HIST("hPhi"), phi); + registry.fill(HIST("hPhiWeighted"), phi, wacc); + registry.fill(HIST("hEta"), eta); + registry.fill(HIST("hPtRef"), pt); + registry.fill(HIST("hDCAz"), track.dcaZ(), track.pt()); + registry.fill(HIST("hDCAxy"), track.dcaXY(), track.pt()); + nTracksCorrected += weff; + } + if (withinPtRef) { + fGFW->Fill(eta, fPtAxis->FindBin(pt) - 1, phi, wacc * weff, 1); + } + if (withinPtPOI) { + fGFW->Fill(eta, fPtAxis->FindBin(pt) - 1, phi, wacc * weff, 2); + } + if (withinPtPOI && withinPtRef) { + fGFW->Fill(eta, fPtAxis->FindBin(pt) - 1, phi, wacc * weff, 4); + } + } + registry.fill(HIST("hTrackCorrection2d"), tracks.size(), nTracksCorrected); - // output information from mcparticles - registry.fill(HIST("hPxMc"), mcParticle.px()); - registry.fill(HIST("hPyMc"), mcParticle.py()); - registry.fill(HIST("hPzMc"), mcParticle.pz()); - registry.fill(HIST("hweightMc"), mcParticle.weight()); + // Filling Flow Container + for (uint l_ind = 0; l_ind < corrconfigs.size(); l_ind++) { + fillFC(corrconfigs.at(l_ind), independent, lRandom); + } + } + PROCESS_SWITCH(FlowCumulantsUpc, process, "process", true); - if (!mcParticle.isPhysicalPrimary()) { - // LOG(info) << "mcParticle.isPhysicalPrimary() = " << mcParticle.isPhysicalPrimary() << std::endl; - continue; - } + //----------------------------------------------------------------------------------------------------------------------- + void processSim(aod::UDMcCollision const& mcCollision, aod::UDMcParticles const& mcParticles) + { + registry.fill(HIST("eventCounterMC"), 0.5); + + registry.fill(HIST("hEventCount"), 1.5); + float cent = 100; + float vtxz = mcCollision.posZ(); + registry.fill(HIST("hVtxZMC"), vtxz); + registry.fill(HIST("hMultMC"), mcParticles.size()); + registry.fill(HIST("hCentMC"), cent); + + auto massPion = o2::constants::physics::MassPionCharged; + registry.fill(HIST("numberOfTracksMC"), mcParticles.size()); + // LOGF(info, "New event! mcParticles.size() = %d", mcParticles.size()); + + float lRandomMc = fRndmMc->Rndm(); + fGFWMC->Clear(); + + // // track weights + float weff = 1, wacc = 1; + double nTracksCorrected = 0; + float independent = cent; + if (cfgUseNch) { + independent = static_cast(mcParticles.size()); + } - std::array momentum = {mcParticle.px(), mcParticle.py(), mcParticle.pz()}; - double energy = std::sqrt(momentum[0] * momentum[0] + momentum[1] * momentum[1] + momentum[2] * momentum[2] + massPion * massPion); - ROOT::Math::LorentzVector> protoMC(momentum[0], momentum[1], momentum[2], energy); - constexpr double kEtaCut = 0.8; - constexpr double kPtCut = 0.1; - if (!(std::fabs(protoMC.Eta()) < kEtaCut && protoMC.Pt() > kPtCut)) { - // LOG(info) << "protoMC.Eta() = " << protoMC.Eta() << ", protoMC.Pt() = " << protoMC.Pt() << std::endl; - continue; - } - // auto momentum = std::array{mcParticle.px(), mcParticle.py(), mcParticle.pz()}; - double pt = RecoDecay::pt(momentum); - double phi = RecoDecay::phi(momentum); - double eta = RecoDecay::eta(momentum); - bool withinPtPOI = (cfgCutPtPOIMin < pt) && (pt < cfgCutPtPOIMax); // within POI pT range - bool withinPtRef = (cfgCutPtRefMin < pt) && (pt < cfgCutPtRefMax); // within RF pT range - if (cfgOutputNUAWeights) { - if (cfgOutputNUAWeightsRefPt) { - if (withinPtRef) { - fWeightsMc->fill(phi, eta, vtxz, pt, cent, 0); - } - } else { + for (const auto& mcParticle : mcParticles) { + if (!mcParticle.isPhysicalPrimary()) + continue; + std::array momentum = {mcParticle.px(), mcParticle.py(), mcParticle.pz()}; + double energy = std::sqrt(momentum[0] * momentum[0] + momentum[1] * momentum[1] + momentum[2] * momentum[2] + massPion * massPion); + ROOT::Math::LorentzVector> protoMC(momentum[0], momentum[1], momentum[2], energy); + constexpr double kEtaCut = 0.8; + constexpr double kPtCut = 0.1; + if (!(std::fabs(protoMC.Eta()) < kEtaCut && protoMC.Pt() > kPtCut)) { + continue; + } + // auto momentum = std::array{mcParticle.px(), mcParticle.py(), mcParticle.pz()}; + double pt = RecoDecay::pt(momentum); + double phi = RecoDecay::phi(momentum); + double eta = RecoDecay::eta(momentum); + bool withinPtPOI = (cfgCutPtPOIMin < pt) && (pt < cfgCutPtPOIMax); // within POI pT range + bool withinPtRef = (cfgCutPtRefMin < pt) && (pt < cfgCutPtRefMax); // within RF pT range + if (cfgOutputNUAWeights) { + if (cfgOutputNUAWeightsRefPt) { + if (withinPtRef) { fWeightsMc->fill(phi, eta, vtxz, pt, cent, 0); } + } else { + fWeightsMc->fill(phi, eta, vtxz, pt, cent, 0); } - if (!setCurrentParticleWeights(weff, wacc, phi, eta, pt, vtxz)) { - continue; - } - - if (withinPtRef) { - registry.fill(HIST("hPhiMC"), phi); - registry.fill(HIST("hPhiWeightedMC"), phi, wacc); - registry.fill(HIST("hEtaMC"), eta); - registry.fill(HIST("hPtRefMC"), pt); - // registry.fill(HIST("hDCAzMC"), track.dcaZ(), track.pt()); - // registry.fill(HIST("hDCAxyMC"), track.dcaXY(), track.pt()); - nTracksCorrected += weff; - } - if (withinPtRef) { - fGFWMC->Fill(eta, fPtAxis->FindBin(pt) - 1, phi, wacc * weff, 1); - } - if (withinPtPOI) { - fGFWMC->Fill(eta, fPtAxis->FindBin(pt) - 1, phi, wacc * weff, 2); - } - if (withinPtPOI && withinPtRef) { - fGFWMC->Fill(eta, fPtAxis->FindBin(pt) - 1, phi, wacc * weff, 4); - } - // LOG(info) << "successfully filled" << std::endl; } - registry.fill(HIST("hTrackCorrection2dMC"), mcParticles.size(), nTracksCorrected); - // Filling Flow Container - for (uint l_ind = 0; l_ind < corrconfigsmc.size(); l_ind++) { - // LOG(info) << "filling flow container for MC" << std::endl; - fillFCMC(corrconfigsmc.at(l_ind), independent, lRandomMc); + if (!setCurrentParticleWeights(weff, wacc, phi, eta, pt, vtxz)) { + continue; + } + if (withinPtRef) { + registry.fill(HIST("hPhiMC"), phi); + registry.fill(HIST("hPhiWeightedMC"), phi, wacc); + registry.fill(HIST("hEtaMC"), eta); + registry.fill(HIST("hPtRefMC"), pt); + // registry.fill(HIST("hDCAzMC"), track.dcaZ(), track.pt()); + // registry.fill(HIST("hDCAxyMC"), track.dcaXY(), track.pt()); + nTracksCorrected += weff; + } + if (withinPtRef) { + fGFWMC->Fill(eta, fPtAxis->FindBin(pt) - 1, phi, wacc * weff, 1); + } + if (withinPtPOI) { + fGFWMC->Fill(eta, fPtAxis->FindBin(pt) - 1, phi, wacc * weff, 2); } + if (withinPtPOI && withinPtRef) { + fGFWMC->Fill(eta, fPtAxis->FindBin(pt) - 1, phi, wacc * weff, 4); + } + } + registry.fill(HIST("hTrackCorrection2dMC"), mcParticles.size(), nTracksCorrected); + + // Filling Flow Container + for (uint l_ind = 0; l_ind < corrconfigs.size(); l_ind++) { + fillFCMC(corrconfigs.at(l_ind), independent, lRandomMc); } + PROCESS_SWITCH(FlowCumulantsUpc, processSim, "processSim", false); } - PROCESS_SWITCH(FlowCumulantsUpc, processSim, "processSim", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)