From 6341318f781fb421f2c254244093ab2ddfc4a6c2 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Mon, 2 Jun 2025 11:50:58 +0000 Subject: [PATCH] Please consider the following formatting changes --- .../Tasks/photonChargedTriggerCorrelation.cxx | 783 ++++++++---------- 1 file changed, 367 insertions(+), 416 deletions(-) diff --git a/PWGJE/Tasks/photonChargedTriggerCorrelation.cxx b/PWGJE/Tasks/photonChargedTriggerCorrelation.cxx index 4a0861ab089..0dee3522bda 100644 --- a/PWGJE/Tasks/photonChargedTriggerCorrelation.cxx +++ b/PWGJE/Tasks/photonChargedTriggerCorrelation.cxx @@ -9,7 +9,6 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. - /// \file photonChargedTriggerCorrelation.cxx /// \author Julius Kinner /// \brief photon-jet correlation analysis @@ -19,12 +18,9 @@ /// Also contains checks and monte-carlo (efficiency, purity, mc-true correlation,...) /// End goal of studying correlations between direct photons and jets - - #define ETA_MAX_DEFAULT 0.8 #define DPHI_SCALE constants::math::TwoPI - constants::math::PIHalf -#define DETA_SCALE 4*ETA_MAX_DEFAULT - 2*ETA_MAX_DEFAULT - +#define DETA_SCALE 4 * ETA_MAX_DEFAULT - 2 * ETA_MAX_DEFAULT #include #include @@ -56,12 +52,8 @@ #include "PWGJE/DataModel/Jet.h" - - - - // derived data for correlations (on-the-fly) - // should be more efficient due to usage in correlations and event mixing +// should be more efficient due to usage in correlations and event mixing namespace o2::aod { @@ -70,7 +62,7 @@ namespace o2::aod namespace corr_particle { DECLARE_SOA_INDEX_COLUMN_FULL(JetCollision, jetCollision, int, JCollisions, ""); -DECLARE_SOA_INDEX_COLUMN_FULL(JetMcCollision, jetMcCollision, int , JMcCollisions, ""); +DECLARE_SOA_INDEX_COLUMN_FULL(JetMcCollision, jetMcCollision, int, JMcCollisions, ""); DECLARE_SOA_COLUMN(Pt, pt, float); DECLARE_SOA_COLUMN(Phi, phi, float); DECLARE_SOA_COLUMN(Eta, eta, float); @@ -147,8 +139,6 @@ DECLARE_SOA_TABLE(PhotonPCMPairs, "AOD", "PHOTONPCMPAIRS", corr_particle::Pt, corr_particle::Phi, corr_particle::Eta, photon_pcm_pair::Mgg); using PhotonPCMPair = PhotonPCMPairs::iterator; - - // mc // mcCollision extension @@ -170,15 +160,9 @@ DECLARE_SOA_TABLE(TriggerParticles, "AOD", "TRIGGERPARTICLES", using TriggerParticle = TriggerParticles::iterator; } // namespace o2::aod - - - - using namespace o2; using namespace o2::framework; - - using CorrCollisions = soa::Join; using CorrCollision = CorrCollisions::iterator; using CorrMcDCollisions = soa::Join; @@ -188,14 +172,9 @@ using CorrMcCollision = CorrMcCollisions::iterator; using BinningZPvMult = ColumnBinningPolicy; - - - - // correlation derived data =================================================================================================================================================================== -struct CorrelationTableProducer -{ +struct CorrelationTableProducer { // reco Produces collisionExtraCorrTable; Produces triggerTable; @@ -207,8 +186,6 @@ struct CorrelationTableProducer Produces mcCollisionExtraCorrTable; Produces triggerParticleTable; - - Configurable zPvMax{"zPvMax", 7, "maximum absZ primary-vertex cut"}; Configurable occupancyMin{"occupancyMin", 0, "minimum occupancy cut"}; Configurable occupancyMax{"occupancyMax", 2000, "maximum occupancy cut"}; @@ -233,13 +210,9 @@ struct CorrelationTableProducer int trackSelection = -1; std::vector triggerMaskBits; - - // for mc Service pdg; - - // partitions++ SliceCache cache; Partition partitionTriggerTracks = aod::jtrack::pt > ptTrigMin; @@ -250,32 +223,40 @@ struct CorrelationTableProducer Preslice perColV0Photons = aod::v0photonkf::collisionId; - - // functions ================================================================================================================================================================================ // selections /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // event selection - template bool checkEventSelection(T_collision const& collision) { - if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) return false; - if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) return false; - if (std::abs(collision.posZ()) > zPvMax) return false; - if (collision.trackOccupancyInTimeRange() < occupancyMin || collision.trackOccupancyInTimeRange() > occupancyMax) return false; + template + bool checkEventSelection(T_collision const& collision) + { + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) + return false; + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) + return false; + if (std::abs(collision.posZ()) > zPvMax) + return false; + if (collision.trackOccupancyInTimeRange() < occupancyMin || collision.trackOccupancyInTimeRange() > occupancyMax) + return false; return true; } - - // checks global track cuts - template bool checkGlobalTrackEta(T_track const& track) { - if (!jetderiveddatautilities::selectTrack(track, trackSelection)) return false; - if (std::abs(track.eta()) > etaMax) return false; + template + bool checkGlobalTrackEta(T_track const& track) + { + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) + return false; + if (std::abs(track.eta()) > etaMax) + return false; return true; } // checks pipm selection (just PID (no additional track cuts)) - template bool checkPipmTPCTOF(T_track const& track) { + template + bool checkPipmTPCTOF(T_track const& track) + { // too low for tof if (track.pt() < piPIDLowPt) { if (track.tpcNSigmaPi() > nSigmaPiTpcLowPt.value[0] && track.tpcNSigmaPi() < nSigmaPiTpcLowPt.value[1]) { @@ -301,7 +282,9 @@ struct CorrelationTableProducer } // checks pipm selection (just PID (no additional track cuts)) - template bool checkPipmTPC(T_track const& track) { + template + bool checkPipmTPC(T_track const& track) + { // Bethe-Bloch rel rise if (track.pt() > piPIDHighPt) { if (track.tpcNSigmaPi() > nSigmaPiRelRise.value[0] && track.tpcNSigmaPi() < nSigmaPiRelRise.value[1]) { @@ -311,18 +294,15 @@ struct CorrelationTableProducer return false; } - - // analysis ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void init(InitContext const&) { + void init(InitContext const&) + { eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); } - - void processRecoCollisionTrigger(aod::JetCollision const& collision, aod::JetTracks const&) { // event selection @@ -330,16 +310,15 @@ struct CorrelationTableProducer // trigger event check bool isTriggerEvent = false; - if (isSelectedEvent) { // group collision auto const triggers = partitionTriggerTracks->sliceByCached(aod::jtrack::collisionId, collision.globalIndex(), cache); - // trigger loop for (auto const& trigger : triggers) { // track selection - if (!checkGlobalTrackEta(trigger)) continue; + if (!checkGlobalTrackEta(trigger)) + continue; // detect trigger event isTriggerEvent = true; @@ -354,25 +333,25 @@ struct CorrelationTableProducer } PROCESS_SWITCH(CorrelationTableProducer, processRecoCollisionTrigger, "process correlation collision_extra and trigger table (reconstructed)", false); - - void processRecoPipmTPCTOF(aod::JetCollision const& collision, soa::Join const& tracks) { // event selection - if (!checkEventSelection(collision)) return; - + if (!checkEventSelection(collision)) + return; // hadron/pipm for (auto const& track : tracks) { // track selection - if (!checkGlobalTrackEta(track)) continue; + if (!checkGlobalTrackEta(track)) + continue; // hadron hadronTable(track.collisionId(), track.globalIndex(), track.pt(), track.phi(), track.eta()); // pipm selection - if (!checkPipmTPCTOF(track)) continue; + if (!checkPipmTPCTOF(track)) + continue; // pipm pipmTable(track.collisionId(), track.globalIndex(), track.pt(), track.phi(), track.eta()); @@ -384,19 +363,21 @@ struct CorrelationTableProducer soa::Join const& tracks) { // event selection - if (!checkEventSelection(collision)) return; - + if (!checkEventSelection(collision)) + return; // hadron/pipm for (auto const& track : tracks) { // track selection - if (!checkGlobalTrackEta(track)) continue; + if (!checkGlobalTrackEta(track)) + continue; // hadron hadronTable(track.collisionId(), track.globalIndex(), track.pt(), track.phi(), track.eta()); // pipm selection - if (!checkPipmTPC(track)) continue; + if (!checkPipmTPC(track)) + continue; // pipm pipmTable(track.collisionId(), track.globalIndex(), track.pt(), track.phi(), track.eta()); @@ -404,22 +385,21 @@ struct CorrelationTableProducer } PROCESS_SWITCH(CorrelationTableProducer, processRecoPipmTPC, "process pipm (TPC) table (reconstructed)", false); - - void processRecoPhotonPCM(soa::Join::iterator const& collision, aod::Collisions const&, aod::V0PhotonsKF const& v0Photons, aod::V0Legs const&) { // event selection - if (!checkEventSelection(collision)) return; + if (!checkEventSelection(collision)) + return; // photonsPCM (for some reason collsionId not an index column (?)) auto const v0PhotonsThisEvent = v0Photons.sliceBy(perColV0Photons, collision.collision().globalIndex()); - // photonPCM for (auto const& v0Photon : v0PhotonsThisEvent) { // photon selection - if (std::abs(v0Photon.eta()) > etaMax) continue; + if (std::abs(v0Photon.eta()) > etaMax) + continue; // photon PCM photonPCMTable(v0Photon.collisionId(), v0Photon.globalIndex(), @@ -434,7 +414,8 @@ struct CorrelationTableProducer ROOT::Math::PtEtaPhiMVector const p4V0PCMPair = p4V0PCM1 + p4V0PCM2; // pi0 selection - if (std::abs(p4V0PCMPair.Eta()) > etaMax) continue; + if (std::abs(p4V0PCMPair.Eta()) > etaMax) + continue; // save info photonPCMPairTable(v0Photon1.collisionId(), v0Photon1.globalIndex(), v0Photon2.globalIndex(), @@ -444,8 +425,6 @@ struct CorrelationTableProducer } PROCESS_SWITCH(CorrelationTableProducer, processRecoPhotonPCM, "process photonPCM table (reconstructed)", false); - - void processMcCorrTables(aod::JetMcCollision const& mcCollision, aod::JetParticles const&) { // group collision @@ -453,14 +432,16 @@ struct CorrelationTableProducer // trigger event check bool isTriggerEvent = false; - // trigger loop for (auto const& trigger : triggers) { // track selection auto const pdgParticle = pdg->GetParticle(trigger.pdgCode()); - if (!pdgParticle || pdgParticle->Charge() == 0) continue; - if (!trigger.isPhysicalPrimary()) continue; - if (std::abs(trigger.eta()) > etaMax) continue; + if (!pdgParticle || pdgParticle->Charge() == 0) + continue; + if (!trigger.isPhysicalPrimary()) + continue; + if (std::abs(trigger.eta()) > etaMax) + continue; // detect trigger event isTriggerEvent = true; @@ -475,22 +456,17 @@ struct CorrelationTableProducer PROCESS_SWITCH(CorrelationTableProducer, processMcCorrTables, "process table production (mc)", false); }; - - - - // correlation analysis ======================================================================================================================================================================= -struct PhotonChargedTriggerCorrelation -{ +struct PhotonChargedTriggerCorrelation { // configurables // general (kenobi) Configurable pathCcdbEff{"pathCcdbEff", "Users/j/jkinner/efficiency/set_in_config", "base path to the ccdb efficiencies"}; Configurable urlCcdb{"urlCcdb", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable noLaterThanCcdb{"noLaterThanCcdb", - std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), - "latest acceptable timestamp of creation for the object"}; + std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), + "latest acceptable timestamp of creation for the object"}; // analysis Configurable doEffCorrectionTrigger{"doEffCorrectionTrigger", false, "whether to do on-the-fly mixing correction for triggers"}; @@ -524,39 +500,40 @@ struct PhotonChargedTriggerCorrelation Configurable> binsPtTrig{"binsPtTrig", {5, 10, 25, 50}, "correlation ptTrig bins"}; Configurable> binsPtAssoc{"binsPtAssoc", - {0.2, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 7.0, 8.0, 9.0, 10, 12.5, 15, 17.5, 20, 30, 40}, "correlation ptAssoc bins"}; + {0.2, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 7.0, 8.0, 9.0, 10, 12.5, 15, 17.5, 20, 30, 40}, + "correlation ptAssoc bins"}; Configurable> binsDPhi{"binsDPhi", - {0.00*DPHI_SCALE, - 0.04*DPHI_SCALE, 0.08*DPHI_SCALE, 0.11*DPHI_SCALE, 0.14*DPHI_SCALE, - 0.16*DPHI_SCALE, 0.18*DPHI_SCALE, 0.20*DPHI_SCALE, 0.22*DPHI_SCALE, - 0.23*DPHI_SCALE, 0.24*DPHI_SCALE, 0.25*DPHI_SCALE, 0.26*DPHI_SCALE, 0.27*DPHI_SCALE, 0.28*DPHI_SCALE, - 0.30*DPHI_SCALE, 0.32*DPHI_SCALE, 0.34*DPHI_SCALE, 0.36*DPHI_SCALE, - 0.39*DPHI_SCALE, 0.42*DPHI_SCALE, 0.46*DPHI_SCALE, 0.50*DPHI_SCALE, - 0.54*DPHI_SCALE, 0.58*DPHI_SCALE, 0.61*DPHI_SCALE, 0.64*DPHI_SCALE, - 0.66*DPHI_SCALE, 0.68*DPHI_SCALE, 0.70*DPHI_SCALE, 0.72*DPHI_SCALE, - 0.74*DPHI_SCALE, 0.76*DPHI_SCALE, 0.78*DPHI_SCALE, - 0.80*DPHI_SCALE, 0.82*DPHI_SCALE, 0.84*DPHI_SCALE, 0.86*DPHI_SCALE, - 0.89*DPHI_SCALE, 0.92*DPHI_SCALE, 0.96*DPHI_SCALE, 1.00*DPHI_SCALE}, - "correlation bins DeltaPhi"}; + {0.00 * DPHI_SCALE, + 0.04 * DPHI_SCALE, 0.08 * DPHI_SCALE, 0.11 * DPHI_SCALE, 0.14 * DPHI_SCALE, + 0.16 * DPHI_SCALE, 0.18 * DPHI_SCALE, 0.20 * DPHI_SCALE, 0.22 * DPHI_SCALE, + 0.23 * DPHI_SCALE, 0.24 * DPHI_SCALE, 0.25 * DPHI_SCALE, 0.26 * DPHI_SCALE, 0.27 * DPHI_SCALE, 0.28 * DPHI_SCALE, + 0.30 * DPHI_SCALE, 0.32 * DPHI_SCALE, 0.34 * DPHI_SCALE, 0.36 * DPHI_SCALE, + 0.39 * DPHI_SCALE, 0.42 * DPHI_SCALE, 0.46 * DPHI_SCALE, 0.50 * DPHI_SCALE, + 0.54 * DPHI_SCALE, 0.58 * DPHI_SCALE, 0.61 * DPHI_SCALE, 0.64 * DPHI_SCALE, + 0.66 * DPHI_SCALE, 0.68 * DPHI_SCALE, 0.70 * DPHI_SCALE, 0.72 * DPHI_SCALE, + 0.74 * DPHI_SCALE, 0.76 * DPHI_SCALE, 0.78 * DPHI_SCALE, + 0.80 * DPHI_SCALE, 0.82 * DPHI_SCALE, 0.84 * DPHI_SCALE, 0.86 * DPHI_SCALE, + 0.89 * DPHI_SCALE, 0.92 * DPHI_SCALE, 0.96 * DPHI_SCALE, 1.00 * DPHI_SCALE}, + "correlation bins DeltaPhi"}; Configurable> binsDEta{"binsDEta", - { 0/32.*DETA_SCALE, - 1/32.*DETA_SCALE, 2/32.*DETA_SCALE, 3/32.*DETA_SCALE, 4/32.*DETA_SCALE, 5/32.*DETA_SCALE, 6/32.*DETA_SCALE, 7/32.*DETA_SCALE, 8/32.*DETA_SCALE, - 9/32.*DETA_SCALE, 10/32.*DETA_SCALE, 11/32.*DETA_SCALE, 12/32.*DETA_SCALE, 13/32.*DETA_SCALE, 14/32.*DETA_SCALE, - 59/128.*DETA_SCALE, 62/128.*DETA_SCALE, 64/128.*DETA_SCALE, 66/128.*DETA_SCALE, 69/128.*DETA_SCALE, 18/32.*DETA_SCALE, - 19/32.*DETA_SCALE, 20/32.*DETA_SCALE, 21/32.*DETA_SCALE, 22/32.*DETA_SCALE, 23/32.*DETA_SCALE, 24/32.*DETA_SCALE, - 25/32.*DETA_SCALE, 26/32.*DETA_SCALE, 27/32.*DETA_SCALE, 28/32.*DETA_SCALE, 29/32.*DETA_SCALE, 30/32.*DETA_SCALE, 31/32.*DETA_SCALE, 32/32.*DETA_SCALE}, - "correlation bins DeltaEta"}; + {0 / 32. * DETA_SCALE, + 1 / 32. * DETA_SCALE, 2 / 32. * DETA_SCALE, 3 / 32. * DETA_SCALE, 4 / 32. * DETA_SCALE, 5 / 32. * DETA_SCALE, 6 / 32. * DETA_SCALE, 7 / 32. * DETA_SCALE, 8 / 32. * DETA_SCALE, + 9 / 32. * DETA_SCALE, 10 / 32. * DETA_SCALE, 11 / 32. * DETA_SCALE, 12 / 32. * DETA_SCALE, 13 / 32. * DETA_SCALE, 14 / 32. * DETA_SCALE, + 59 / 128. * DETA_SCALE, 62 / 128. * DETA_SCALE, 64 / 128. * DETA_SCALE, 66 / 128. * DETA_SCALE, 69 / 128. * DETA_SCALE, 18 / 32. * DETA_SCALE, + 19 / 32. * DETA_SCALE, 20 / 32. * DETA_SCALE, 21 / 32. * DETA_SCALE, 22 / 32. * DETA_SCALE, 23 / 32. * DETA_SCALE, 24 / 32. * DETA_SCALE, + 25 / 32. * DETA_SCALE, 26 / 32. * DETA_SCALE, 27 / 32. * DETA_SCALE, 28 / 32. * DETA_SCALE, 29 / 32. * DETA_SCALE, 30 / 32. * DETA_SCALE, 31 / 32. * DETA_SCALE, 32 / 32. * DETA_SCALE}, + "correlation bins DeltaEta"}; Configurable> binsZPv{"binsZPv", - {-7, -5, -3, -1, 1, 3, 5, 7}, "zPv mixing bins"}; + {-7, -5, -3, -1, 1, 3, 5, 7}, + "zPv mixing bins"}; Configurable> binsMult{"binsMult", - {-0.5, 9.5, 14.5, 19.5, 25.5, 32}, "multiplicity mixing bins"}; + {-0.5, 9.5, 14.5, 19.5, 25.5, 32}, + "multiplicity mixing bins"}; // configurables from other tasks double etaMax; - - // objects to hold histograms HistogramRegistry histos{"histogramRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; @@ -569,8 +546,6 @@ struct PhotonChargedTriggerCorrelation static constexpr unsigned int SeedRandomEngine = 12345; std::mt19937 randomEngine{SeedRandomEngine}; - - // partitions SliceCache cache; @@ -586,15 +561,13 @@ struct PhotonChargedTriggerCorrelation // combinations binning // cumbersome, but still better than having extra configurable or figuring out how to init binningZPvMult later while declaring it here std::function(std::vector const&, double)> prependValueToVector = - [](std::vector const& vec, double const value) { - std::vector resultVec = {value}; - resultVec.insert(resultVec.end(), vec.begin(), vec.end()); - return resultVec; - }; + [](std::vector const& vec, double const value) { + std::vector resultVec = {value}; + resultVec.insert(resultVec.end(), vec.begin(), vec.end()); + return resultVec; + }; BinningZPvMult binningZPvMult{{prependValueToVector(binsZPv.value, VARIABLE_WIDTH), prependValueToVector(binsMult.value, VARIABLE_WIDTH)}, true}; - - // declare analysis variables // efficiency histograms @@ -608,24 +581,21 @@ struct PhotonChargedTriggerCorrelation // organised as zPv- and mult-bin matrix of deques to save trigger info beyond single dataframe // extra bin for mult overflow // with ajusted zVtx (see triggerBinValuesZPv in init) and mult overflow -> all events accounted for - // (possibly replace by some advanced derived data method and O2 event mixing in future?) + // (possibly replace by some advanced derived data method and O2 event mixing in future?) std::vector triggerBinValuesZPv; std::vector triggerBinValuesMult; std::vector>> savedTriggersZPvMultPt; std::vector>> savedTriggersZPvMultPhi; std::vector>> savedTriggersZPvMultEta; - - - - // functions ================================================================================================================================================================================ // general (kenobi) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // get histograms from ccdb // save efficiencies from ccdb in histogram registry - void initCcdbHistograms() { + void initCcdbHistograms() + { // trigger h1PtInvEffTrigger = nullptr; if (doEffCorrectionTrigger) { @@ -680,10 +650,9 @@ struct PhotonChargedTriggerCorrelation } } - - // create histograms - void initHistograms() { + void initHistograms() + { // define axes const AxisSpec axisN{1, 0., 1., "#it{N}_{something}"}; const AxisSpec axisCategories{16, 0., 16., "categories"}; @@ -705,8 +674,6 @@ struct PhotonChargedTriggerCorrelation const AxisSpec axisZPvBinning{binsZPv, "#it{z}_{pv} correlation binning"}; const AxisSpec axisMultBinning{binsMult, "multiplicity correlation binning"}; - - // reco info histos.add("reco/info/h1_nEvents", "h1_nEvents", kTH1D, {axisCategories}); histos.get(HIST("reco/info/h1_nEvents"))->GetXaxis()->SetBinLabel(1, "#it{N}_{ev}^{sel}"); @@ -762,7 +729,6 @@ struct PhotonChargedTriggerCorrelation histos.add("reco/plain/h3_ptPhiEta_pi0PCMMix", "h3_ptPhiEta_pi0PCMMix", kTHnSparseF, {axisPtAssoc, axisPhi, axisEta}, true); histos.add("reco/plain/h4_ptMggZPvMult_pi0PCMMix", "h4_ptMggZPvMult_pi0PCMMix", kTHnSparseF, {axisPtAssoc, axisMgg, axisZPvBinning, axisMultBinning}, true); - // mc info histos.add("mc/info/h1_nEvents_mcTrue", "h1_nEvents_mcTrue", kTH1D, {axisN}); histos.add("mc/info/h1_nTriggerEvents_mcTrue", "h1_nTriggerEvents_mcTrue", kTH1D, {axisN}); @@ -797,12 +763,12 @@ struct PhotonChargedTriggerCorrelation // mc efficiency/purity std::function add_effHists = - [&](std::string name_id) { - histos.add(std::format("mc/eff/h3_ptPhiEta_{}", name_id).data(), "h3_ptPhiEta_mcReco_hadron", - kTHnSparseF, {axisPtAssoc, axisPhi, axisEta}, true); - histos.add(std::format("mc/eff/h3_ptZPvMult_{}", name_id).data(), "h3_ptZPvMult_mcReco_hadron", - kTHnSparseF, {axisPtAssoc, axisZPvSmol, axisMultSmol}, true); - }; + [&](std::string name_id) { + histos.add(std::format("mc/eff/h3_ptPhiEta_{}", name_id).data(), "h3_ptPhiEta_mcReco_hadron", + kTHnSparseF, {axisPtAssoc, axisPhi, axisEta}, true); + histos.add(std::format("mc/eff/h3_ptZPvMult_{}", name_id).data(), "h3_ptZPvMult_mcReco_hadron", + kTHnSparseF, {axisPtAssoc, axisZPvSmol, axisMultSmol}, true); + }; // mc tracks add_effHists("mcReco_hadron"); add_effHists("mcReco_hasCorrectMc_hadron"); @@ -830,54 +796,74 @@ struct PhotonChargedTriggerCorrelation histos.add("test/h2_globalTracks_zPvMultDep", "h2_globalTracks_zPvMultDep", kTH2D, {axisZPv, axisMult}, true); } - - // selections /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // checks if mcParticle is charged - template bool checkChargedMc(T_mcParticle const& mcParticle) { + template + bool checkChargedMc(T_mcParticle const& mcParticle) + { auto const pdgParticle = pdg->GetParticle(mcParticle.pdgCode()); - if (!pdgParticle || pdgParticle->Charge() == 0) return false; + if (!pdgParticle || pdgParticle->Charge() == 0) + return false; return true; } // checks if mcParticle should be detected (physicalPrimary, |eta|) - template bool checkPrimaryEtaMc(T_mcParticle const& mcParticle) { - if (!mcParticle.isPhysicalPrimary()) return false; - if (std::abs(mcParticle.eta()) > etaMax) return false; + template + bool checkPrimaryEtaMc(T_mcParticle const& mcParticle) + { + if (!mcParticle.isPhysicalPrimary()) + return false; + if (std::abs(mcParticle.eta()) > etaMax) + return false; return true; } // checks if mcParticle should be detected as primary track (physicalPrimary, charge, |eta|) - template bool checkPrimaryTrackMc(T_mcParticle const& mcParticle) { - if (!checkPrimaryEtaMc(mcParticle)) return false; - if (!checkChargedMc(mcParticle)) return false; + template + bool checkPrimaryTrackMc(T_mcParticle const& mcParticle) + { + if (!checkPrimaryEtaMc(mcParticle)) + return false; + if (!checkChargedMc(mcParticle)) + return false; return true; } // checks if mcParticle should be detected as 'primary' pi0->gg (|eta| not checked) - template bool checkPi0ToGG(T_mcParticle const& mcParticle) { - if (mcParticle.pdgCode() != PDG_t::kPi0) return false; + template + bool checkPi0ToGG(T_mcParticle const& mcParticle) + { + if (mcParticle.pdgCode() != PDG_t::kPi0) + return false; // identify primary pi0 (account for 0 daughters for some reason) - if (mcParticle.template daughters_as().size() == 0) return false; + if (mcParticle.template daughters_as().size() == 0) + return false; for (auto const& pi0_daughter : mcParticle.template daughters_as()) { - if (!pi0_daughter.isPhysicalPrimary()) return false; + if (!pi0_daughter.isPhysicalPrimary()) + return false; } // select pi0 -> gg constexpr int NDaughtersPi0ToGG = 2; - if (mcParticle.template daughters_as().size() != NDaughtersPi0ToGG) return false; + if (mcParticle.template daughters_as().size() != NDaughtersPi0ToGG) + return false; return true; } - - // analysis helpers ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template double getH1ValueAt(T_h1 const*const h1, double const value) { + template + double getH1ValueAt(T_h1 const* const h1, double const value) + { return h1->GetBinContent(h1->FindFixBin(value)); } // efficiency helpers // define enum class for particle type - enum class ParticleType {Trigger, Hadron, Pipm, PhotonPCM}; + enum class ParticleType { Trigger, + Hadron, + Pipm, + PhotonPCM }; // efficiency function - template double getInvEff(double const value) { + template + double getInvEff(double const value) + { if constexpr (T == ParticleType::Trigger) { return doEffCorrectionTrigger ? getH1ValueAt(h1PtInvEffTrigger, value) : 1; } else if constexpr (T == ParticleType::Hadron) { @@ -891,33 +877,37 @@ struct PhotonChargedTriggerCorrelation } } - - // performs 'phi1 - phi2' and pushes it into the interval [-pi/2, 3pi/2] - inline double getDeltaPhi(double const phi1, double const phi2) { - return RecoDecay::constrainAngle(phi1 - phi2, -1*constants::math::PIHalf); + inline double getDeltaPhi(double const phi1, double const phi2) + { + return RecoDecay::constrainAngle(phi1 - phi2, -1 * constants::math::PIHalf); } // finds bin that value belongs to (assumes ordered bins) (starts at 0; includes underflow (return -1) and overlflow (return bins.size() - 1)) - // should be faster than some std binary search due to small number of bins (zPv, mult) - int findIntervalBin(double value, const std::vector& bins) { + // should be faster than some std binary search due to small number of bins (zPv, mult) + int findIntervalBin(double value, const std::vector& bins) + { const int n = bins.size() - 1; - if (value < bins[0]) return -1; // underflow + if (value < bins[0]) + return -1; // underflow for (int i_bin = 0; i_bin < n; i_bin++) - if (value < bins[i_bin + 1]) return i_bin; + if (value < bins[i_bin + 1]) + return i_bin; return n; // overflow } // checks that two values belong to the same category (assumes ordered bins) - // returns -1 for negative result (also for under/overflow values) and bin number (starting at 0) otherwise - int checkSameBin(double const value1, double const value2, std::vector const& bins) { + // returns -1 for negative result (also for under/overflow values) and bin number (starting at 0) otherwise + int checkSameBin(double const value1, double const value2, std::vector const& bins) + { // reject underflow - if (value1 < bins[0]) return -1; + if (value1 < bins[0]) + return -1; // loop over bins const int n = bins.size() - 1; for (int i_bin = 0; i_bin < n; i_bin++) { - if (value1 < bins[i_bin+1]) { - if (value2 < bins[i_bin+1] && value2 >= bins[i_bin]) { + if (value1 < bins[i_bin + 1]) { + if (value2 < bins[i_bin + 1] && value2 >= bins[i_bin]) { return i_bin; } return -1; @@ -927,20 +917,17 @@ struct PhotonChargedTriggerCorrelation return -1; } - - - - // analysis ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // generalised correlation functions - // per collision + // per collision // plain info template void corrProcessPlain(T_collision const& collision, T_associatedThisEvent const& associatedThisEvent, - T_funcPlain&& funcPlain) { + T_funcPlain&& funcPlain) + { // normal spectra (per event - not per trigger) for (auto const& associated : associatedThisEvent) { funcPlain(collision, associated); @@ -951,7 +938,8 @@ struct PhotonChargedTriggerCorrelation template void corrProcessCorrelation(T_collision const& collision, T_triggersThisEvent const& triggersThisEvent, T_associatedThisEvent const& associatedThisEvent, - T_funcCorrelation&& funcCorrelation) { + T_funcCorrelation&& funcCorrelation) + { // correlation combinations for (auto const& [trigger, associated] : soa::combinations(soa::CombinationsFullIndexPolicy(triggersThisEvent, associatedThisEvent))) { funcCorrelation(collision, trigger, associated); @@ -963,9 +951,11 @@ struct PhotonChargedTriggerCorrelation typename T_funcMixing> void corrProcessMixing(T_collision const& collision, T_associatedThisEvent const& associatedThisEvent, T_funcMixing&& funcMixing, - size_t const nTriggerMixing) { + size_t const nTriggerMixing) + { // skip if event does not contain valid trigger - if (doTrigEvMixing && !collision.trigEv()) return; + if (doTrigEvMixing && !collision.trigEv()) + return; // mixing loops (more efficient than O2 mixing (for now)) // prepare zPv-mult binned saved triggers @@ -976,7 +966,7 @@ struct PhotonChargedTriggerCorrelation auto const& savedTriggersEta = savedTriggersZPvMultEta[iBinCorrZPv][iBinCorrMult]; // number of triggers const int mixUpToTriggerN = std::min(savedTriggersPt.size(), nTriggerMixing + nTriggersThisDataFrame); - const float perTriggerWeight = 1./(mixUpToTriggerN - nTriggersThisDataFrame); // mixUpToTriggerN <= nTriggersThisDataFrame not problematic since no loop then + const float perTriggerWeight = 1. / (mixUpToTriggerN - nTriggersThisDataFrame); // mixUpToTriggerN <= nTriggersThisDataFrame not problematic since no loop then // mixing loops for (int i_mixingTrigger = nTriggersThisDataFrame; i_mixingTrigger < mixUpToTriggerN; i_mixingTrigger++) { for (auto const& associated : associatedThisEvent) { @@ -985,11 +975,7 @@ struct PhotonChargedTriggerCorrelation } } - - - - - void init(InitContext & initContext) + void init(InitContext& initContext) { // analysis info ccdb->setURL(urlCcdb.value); @@ -999,8 +985,6 @@ struct PhotonChargedTriggerCorrelation // not later than now, will be replaced by the value of train creation (avoids replacing objects while a train is running) ccdb->setCreatedNotAfter(noLaterThanCcdb.value); - - // init analysis variables // get variabels from other tasks @@ -1029,10 +1013,6 @@ struct PhotonChargedTriggerCorrelation initHistograms(); } - - - - // reconstructed //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void processInfo(CorrCollision const& collision) @@ -1044,7 +1024,8 @@ struct PhotonChargedTriggerCorrelation // event selection histos.fill(HIST("reco/info/h1_nEvents"), 1.5); - if (!collision.selEv()) return; + if (!collision.selEv()) + return; histos.fill(HIST("reco/info/h1_nEvents"), 0.5); // QA @@ -1054,23 +1035,18 @@ struct PhotonChargedTriggerCorrelation } PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processInfo, "process general info on collisions and tracks for analysis and qa", false); - - - - void processCorrFirst(CorrCollisions const& collisions, aod::Triggers const& triggers) { // do at beginning of each data frame (before other correlation process functions) - // (PROCESS_SWITCH of this process has to be declared first) + // (PROCESS_SWITCH of this process has to be declared first) // set trigger counter nTriggersThisDataFrame = triggers.size(); - - for (auto const& collision : collisions) { // event selection - if (!collision.selEv()) continue; + if (!collision.selEv()) + continue; // group collision auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); @@ -1079,7 +1055,7 @@ struct PhotonChargedTriggerCorrelation for (auto const& trigger : triggersThisEvent) { // trigger info histos.fill(HIST("reco/corr/h3_ptPhiEta_trig"), trigger.pt(), trigger.phi(), trigger.eta(), - getInvEff(trigger.pt())); + getInvEff(trigger.pt())); // save triggers for mixing const int iBinCorrZPv = findIntervalBin(collision.posZ(), triggerBinValuesZPv); @@ -1105,184 +1081,164 @@ struct PhotonChargedTriggerCorrelation } PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processCorrFirst, "process to gather info before correlation processes", false); - - - - void processCorrHadron(CorrCollision const& collision, aod::Triggers const& triggers, aod::Hadrons const& hadrons) { // event selection - if (!collision.selEv()) return; - + if (!collision.selEv()) + return; corrProcessPlain(collision, hadrons, - [this]([[maybe_unused]] auto const& collision, auto const& associated) { - histos.fill(HIST("reco/plain/h3_ptPhiEta_hadron"), - associated.pt(), associated.phi(), associated.eta(), - getInvEff(associated.pt())); - }); + [this]([[maybe_unused]] auto const& collision, auto const& associated) { + histos.fill(HIST("reco/plain/h3_ptPhiEta_hadron"), + associated.pt(), associated.phi(), associated.eta(), + getInvEff(associated.pt())); + }); corrProcessCorrelation(collision, triggers, hadrons, - [this](auto const& collision, auto const& trigger, auto const& associated) { - // exclude self correlation - if (trigger.jetTrackId() == associated.jetTrackId()) return; - - histos.fill(HIST("reco/corr/h3_ptPhiEta_assoc_hadron"), - associated.pt(), associated.phi(), associated.eta(), - getInvEff(trigger.pt())*getInvEff(associated.pt())); - histos.fill(HIST("reco/corr/h6_corr_hadron"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.multNTracksGlobal(), - getInvEff(trigger.pt())*getInvEff(associated.pt())); - }); - - corrProcessMixing(collision, hadrons, - [this](auto const& collision, - float const mixingTriggerPt, float const mixingTriggerPhi, float const mixingTriggerEta, auto const& associated, auto const perTriggerWeight) { - histos.fill(HIST("reco/corr/h6_mix_hadron"), - getDeltaPhi(mixingTriggerPhi, associated.phi()), - mixingTriggerEta - associated.eta(), - mixingTriggerPt, associated.pt(), collision.posZ(), collision.multNTracksGlobal(), - perTriggerWeight*getInvEff(mixingTriggerPt)*getInvEff(associated.pt())); - }, nTriggerMixingHadron); + [this](auto const& collision, auto const& trigger, auto const& associated) { + // exclude self correlation + if (trigger.jetTrackId() == associated.jetTrackId()) + return; + + histos.fill(HIST("reco/corr/h3_ptPhiEta_assoc_hadron"), + associated.pt(), associated.phi(), associated.eta(), + getInvEff(trigger.pt()) * getInvEff(associated.pt())); + histos.fill(HIST("reco/corr/h6_corr_hadron"), + getDeltaPhi(trigger.phi(), associated.phi()), + trigger.eta() - associated.eta(), + trigger.pt(), associated.pt(), collision.posZ(), collision.multNTracksGlobal(), + getInvEff(trigger.pt()) * getInvEff(associated.pt())); + }); + + corrProcessMixing(collision, hadrons, [this](auto const& collision, float const mixingTriggerPt, float const mixingTriggerPhi, float const mixingTriggerEta, auto const& associated, auto const perTriggerWeight) { histos.fill(HIST("reco/corr/h6_mix_hadron"), + getDeltaPhi(mixingTriggerPhi, associated.phi()), + mixingTriggerEta - associated.eta(), + mixingTriggerPt, associated.pt(), collision.posZ(), collision.multNTracksGlobal(), + perTriggerWeight * getInvEff(mixingTriggerPt) * getInvEff(associated.pt())); }, nTriggerMixingHadron); } PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processCorrHadron, "process standard correlation for associated hardons", false); - - void processCorrPipm(CorrCollision const& collision, aod::Triggers const& triggers, aod::Pipms const& pipms) { // event selection - if (!collision.selEv()) return; - + if (!collision.selEv()) + return; corrProcessPlain(collision, pipms, - [this]([[maybe_unused]] auto const& collision, auto const& associated) { - histos.fill(HIST("reco/plain/h3_ptPhiEta_pipm"), - associated.pt(), associated.phi(), associated.eta(), - getInvEff(associated.pt())); - }); + [this]([[maybe_unused]] auto const& collision, auto const& associated) { + histos.fill(HIST("reco/plain/h3_ptPhiEta_pipm"), + associated.pt(), associated.phi(), associated.eta(), + getInvEff(associated.pt())); + }); corrProcessCorrelation(collision, triggers, pipms, - [this](auto const& collision, auto const& trigger, auto const& associated) { - // exclude self correlation - if (trigger.jetTrackId() == associated.jetTrackId()) return; - - histos.fill(HIST("reco/corr/h3_ptPhiEta_assoc_pipm"), - associated.pt(), associated.phi(), associated.eta(), - getInvEff(trigger.pt())*getInvEff(associated.pt())); - histos.fill(HIST("reco/corr/h6_corr_pipm"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.multNTracksGlobal(), - getInvEff(trigger.pt())*getInvEff(associated.pt())); - }); - - corrProcessMixing(collision, pipms, - [this](auto const& collision, - float const mixingTriggerPt, float const mixingTriggerPhi, float const mixingTriggerEta, auto const& associated, auto const perTriggerWeight) { - histos.fill(HIST("reco/corr/h6_mix_pipm"), - getDeltaPhi(mixingTriggerPhi, associated.phi()), - mixingTriggerEta - associated.eta(), - mixingTriggerPt, associated.pt(), collision.posZ(), collision.multNTracksGlobal(), - perTriggerWeight*getInvEff(mixingTriggerPt)*getInvEff(associated.pt())); - }, nTriggerMixingPipm); + [this](auto const& collision, auto const& trigger, auto const& associated) { + // exclude self correlation + if (trigger.jetTrackId() == associated.jetTrackId()) + return; + + histos.fill(HIST("reco/corr/h3_ptPhiEta_assoc_pipm"), + associated.pt(), associated.phi(), associated.eta(), + getInvEff(trigger.pt()) * getInvEff(associated.pt())); + histos.fill(HIST("reco/corr/h6_corr_pipm"), + getDeltaPhi(trigger.phi(), associated.phi()), + trigger.eta() - associated.eta(), + trigger.pt(), associated.pt(), collision.posZ(), collision.multNTracksGlobal(), + getInvEff(trigger.pt()) * getInvEff(associated.pt())); + }); + + corrProcessMixing(collision, pipms, [this](auto const& collision, float const mixingTriggerPt, float const mixingTriggerPhi, float const mixingTriggerEta, auto const& associated, auto const perTriggerWeight) { histos.fill(HIST("reco/corr/h6_mix_pipm"), + getDeltaPhi(mixingTriggerPhi, associated.phi()), + mixingTriggerEta - associated.eta(), + mixingTriggerPt, associated.pt(), collision.posZ(), collision.multNTracksGlobal(), + perTriggerWeight * getInvEff(mixingTriggerPt) * getInvEff(associated.pt())); }, nTriggerMixingPipm); } PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processCorrPipm, "process standard correlation for associated pipm", false); - - void processCorrPhotonPCM(CorrCollision const& collision, aod::Triggers const& triggers, aod::PhotonPCMs const& photonPCMs) { // event selection - if (!collision.selEv()) return; - + if (!collision.selEv()) + return; corrProcessPlain(collision, photonPCMs, - [this]([[maybe_unused]] auto const& collision, auto const& associated) { - histos.fill(HIST("reco/plain/h3_ptPhiEta_photonPCM"), - associated.pt(), associated.phi(), associated.eta(), - getInvEff(associated.pt())); - }); + [this]([[maybe_unused]] auto const& collision, auto const& associated) { + histos.fill(HIST("reco/plain/h3_ptPhiEta_photonPCM"), + associated.pt(), associated.phi(), associated.eta(), + getInvEff(associated.pt())); + }); corrProcessCorrelation(collision, triggers, photonPCMs, - [this](auto const& collision, auto const& trigger, auto const& associated) { - // exclude self correlation - if (trigger.jetTrackId() == associated.posTrackId() || trigger.jetTrackId() == associated.negTrackId()) return; - - histos.fill(HIST("reco/corr/h3_ptPhiEta_assoc_photonPCM"), - associated.pt(), associated.phi(), associated.eta(), - getInvEff(trigger.pt())*getInvEff(associated.pt())); - histos.fill(HIST("reco/corr/h6_corr_photonPCM"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.multNTracksGlobal(), - getInvEff(trigger.pt())*getInvEff(associated.pt())); - }); - - corrProcessMixing(collision, photonPCMs, - [this](auto const& collision, - float const mixingTriggerPt, float const mixingTriggerPhi, float const mixingTriggerEta, auto const& associated, auto const perTriggerWeight) { - histos.fill(HIST("reco/corr/h6_mix_photonPCM"), - getDeltaPhi(mixingTriggerPhi, associated.phi()), - mixingTriggerEta - associated.eta(), - mixingTriggerPt, associated.pt(), collision.posZ(), collision.multNTracksGlobal(), - perTriggerWeight*getInvEff(mixingTriggerPt)*getInvEff(associated.pt())); - }, nTriggerMixingPhotonPCM); + [this](auto const& collision, auto const& trigger, auto const& associated) { + // exclude self correlation + if (trigger.jetTrackId() == associated.posTrackId() || trigger.jetTrackId() == associated.negTrackId()) + return; + + histos.fill(HIST("reco/corr/h3_ptPhiEta_assoc_photonPCM"), + associated.pt(), associated.phi(), associated.eta(), + getInvEff(trigger.pt()) * getInvEff(associated.pt())); + histos.fill(HIST("reco/corr/h6_corr_photonPCM"), + getDeltaPhi(trigger.phi(), associated.phi()), + trigger.eta() - associated.eta(), + trigger.pt(), associated.pt(), collision.posZ(), collision.multNTracksGlobal(), + getInvEff(trigger.pt()) * getInvEff(associated.pt())); + }); + + corrProcessMixing(collision, photonPCMs, [this](auto const& collision, float const mixingTriggerPt, float const mixingTriggerPhi, float const mixingTriggerEta, auto const& associated, auto const perTriggerWeight) { histos.fill(HIST("reco/corr/h6_mix_photonPCM"), + getDeltaPhi(mixingTriggerPhi, associated.phi()), + mixingTriggerEta - associated.eta(), + mixingTriggerPt, associated.pt(), collision.posZ(), collision.multNTracksGlobal(), + perTriggerWeight * getInvEff(mixingTriggerPt) * getInvEff(associated.pt())); }, nTriggerMixingPhotonPCM); } PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processCorrPhotonPCM, "process standard correlation for associated photonPCM", false); - - void processCorrPi0PCM(CorrCollision const& collision, aod::Triggers const& triggers, aod::PhotonPCMPairs const& photonPCMPairs) { // event selection - if (!collision.selEv()) return; - + if (!collision.selEv()) + return; corrProcessPlain(collision, photonPCMPairs, - [this](auto const& collision, auto const& associated) { - histos.fill(HIST("reco/plain/h4_ptMggZPvMult_pi0PCM"), associated.pt(), associated.mgg(), collision.posZ(), collision.multNTracksGlobal()); - // pi0 mass range - if (associated.mgg() > pi0PCMMassRange.value[0] && associated.mgg() < pi0PCMMassRange.value[1]) { - histos.fill(HIST("reco/plain/h3_ptPhiEta_pi0PCM"), associated.pt(), associated.phi(), associated.eta()); - } - }); + [this](auto const& collision, auto const& associated) { + histos.fill(HIST("reco/plain/h4_ptMggZPvMult_pi0PCM"), associated.pt(), associated.mgg(), collision.posZ(), collision.multNTracksGlobal()); + // pi0 mass range + if (associated.mgg() > pi0PCMMassRange.value[0] && associated.mgg() < pi0PCMMassRange.value[1]) { + histos.fill(HIST("reco/plain/h3_ptPhiEta_pi0PCM"), associated.pt(), associated.phi(), associated.eta()); + } + }); corrProcessCorrelation(collision, triggers, photonPCMPairs, - [this](auto const& collision, auto const& trigger, auto const& associated) { - // exclude self correlation - if (trigger.jetTrackId() == associated.posTrack1Id() || trigger.jetTrackId() == associated.negTrack1Id() || - trigger.jetTrackId() == associated.negTrack2Id() || trigger.jetTrackId() == associated.posTrack2Id()) return; - - histos.fill(HIST("reco/corr/h4_ptMggZPvMult_assoc_pi0PCM"), - associated.pt(), associated.mgg(), collision.posZ(), collision.multNTracksGlobal(), - getInvEff(trigger.pt())); - - if (associated.mgg() > pi0PCMMassRange.value[0] && associated.mgg() < pi0PCMMassRange.value[1]) { - // pi0 mass range - histos.fill(HIST("reco/corr/h3_ptPhiEta_assoc_pi0PCM"), - associated.pt(), associated.phi(), associated.eta(), - getInvEff(trigger.pt())); - histos.fill(HIST("reco/corr/h6_corr_pi0PCM"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.multNTracksGlobal(), - getInvEff(trigger.pt())); - } else if (associated.mgg() > pi0PCMSideMassRange.value[0] && associated.mgg() < pi0PCMSideMassRange.value[1]) { - // pi0 mass side range - histos.fill(HIST("reco/corr/h6_corr_pi0PCMSide"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.multNTracksGlobal(), - getInvEff(trigger.pt())); - } - }); - - corrProcessMixing(collision, photonPCMPairs, - [this](auto const& collision, - float const mixingTriggerPt, float const mixingTriggerPhi, float const mixingTriggerEta, auto const& associated, auto const perTriggerWeight) { + [this](auto const& collision, auto const& trigger, auto const& associated) { + // exclude self correlation + if (trigger.jetTrackId() == associated.posTrack1Id() || trigger.jetTrackId() == associated.negTrack1Id() || + trigger.jetTrackId() == associated.negTrack2Id() || trigger.jetTrackId() == associated.posTrack2Id()) + return; + + histos.fill(HIST("reco/corr/h4_ptMggZPvMult_assoc_pi0PCM"), + associated.pt(), associated.mgg(), collision.posZ(), collision.multNTracksGlobal(), + getInvEff(trigger.pt())); + + if (associated.mgg() > pi0PCMMassRange.value[0] && associated.mgg() < pi0PCMMassRange.value[1]) { + // pi0 mass range + histos.fill(HIST("reco/corr/h3_ptPhiEta_assoc_pi0PCM"), + associated.pt(), associated.phi(), associated.eta(), + getInvEff(trigger.pt())); + histos.fill(HIST("reco/corr/h6_corr_pi0PCM"), + getDeltaPhi(trigger.phi(), associated.phi()), + trigger.eta() - associated.eta(), + trigger.pt(), associated.pt(), collision.posZ(), collision.multNTracksGlobal(), + getInvEff(trigger.pt())); + } else if (associated.mgg() > pi0PCMSideMassRange.value[0] && associated.mgg() < pi0PCMSideMassRange.value[1]) { + // pi0 mass side range + histos.fill(HIST("reco/corr/h6_corr_pi0PCMSide"), + getDeltaPhi(trigger.phi(), associated.phi()), + trigger.eta() - associated.eta(), + trigger.pt(), associated.pt(), collision.posZ(), collision.multNTracksGlobal(), + getInvEff(trigger.pt())); + } + }); + + corrProcessMixing(collision, photonPCMPairs, [this](auto const& collision, float const mixingTriggerPt, float const mixingTriggerPhi, float const mixingTriggerEta, auto const& associated, auto const perTriggerWeight) { if (associated.mgg() > pi0PCMMassRange.value[0] && associated.mgg() < pi0PCMMassRange.value[1]) { // pi0 mass range histos.fill(HIST("reco/corr/h6_mix_pi0PCM"), @@ -1297,19 +1253,15 @@ struct PhotonChargedTriggerCorrelation mixingTriggerEta - associated.eta(), mixingTriggerPt, associated.pt(), collision.posZ(), collision.multNTracksGlobal(), perTriggerWeight*getInvEff(mixingTriggerPt)); - } - }, nTriggerMixingPi0PCM); + } }, nTriggerMixingPi0PCM); } PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processCorrPi0PCM, "process standard correlation for associated pi0PCM", false); - - void processCorrPi0PCMMix(CorrCollisions const& collisions, aod::PhotonPCMs const& photonPCMs) { auto photonPCMsTuple = std::make_tuple(photonPCMs); SameKindPair pairs{binningZPvMult, nNeighboursMixingPi0PCMPair, -1, collisions, photonPCMsTuple, &cache}; - // mixed events for (auto pair = pairs.begin(); pair != pairs.end(); pair++) { auto const& [collision1, photonPCMs1, collision2, photonPCMs2] = *pair; @@ -1323,8 +1275,10 @@ struct PhotonChargedTriggerCorrelation // } // event selection - if (!collision1.selEv()) continue; - if (!collision2.selEv()) continue; + if (!collision1.selEv()) + continue; + if (!collision2.selEv()) + continue; // mixing loop for (auto const& [photonPCM1, photonPCM2] : soa::combinations(soa::CombinationsFullIndexPolicy(photonPCMs1, photonPCMs2))) { @@ -1332,7 +1286,6 @@ struct PhotonChargedTriggerCorrelation ROOT::Math::PtEtaPhiMVector const p4photonPCM2(photonPCM2.pt(), photonPCM2.eta(), photonPCM2.phi(), 0.); ROOT::Math::PtEtaPhiMVector const p4photonPCMPair = p4photonPCM1 + p4photonPCM2; - // plain histos.fill(HIST("reco/plain/h3_ptPhiEta_pi0PCMMix"), p4photonPCMPair.pt(), p4photonPCMPair.phi() + constants::math::PI, p4photonPCMPair.eta()); histos.fill(HIST("reco/plain/h4_ptMggZPvMult_pi0PCMMix"), p4photonPCMPair.pt(), p4photonPCMPair.M(), collision1.posZ(), collision1.multNTracksGlobal()); @@ -1341,10 +1294,6 @@ struct PhotonChargedTriggerCorrelation } PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processCorrPi0PCMMix, "process gamma-gamma mixing for photonPCM", false); - - - - // mc /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void processMcInfo(CorrMcCollision const& mcCollision) @@ -1362,10 +1311,6 @@ struct PhotonChargedTriggerCorrelation } PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcInfo, "process general info on mc collisions and tracks for analysis and qa", false); - - - - void processMcTrueCorr(CorrMcCollision const&, aod::TriggerParticles const& triggerParticles, aod::JetParticles const& mcParticles) { // trigger pairing loop @@ -1373,11 +1318,11 @@ struct PhotonChargedTriggerCorrelation // trigger info histos.fill(HIST("mc/true/corr/h3_ptPhiEta_trig"), trigger.pt(), trigger.phi(), trigger.eta()); - // hadrons (tracks) and pipm for (auto const& associated : mcParticles) { // exclude self correlation - if (trigger.jetMcParticleId() == associated.globalIndex()) continue; + if (trigger.jetMcParticleId() == associated.globalIndex()) + continue; // standard particles (marked physical primary) if (checkPrimaryEtaMc(associated)) { @@ -1425,28 +1370,26 @@ struct PhotonChargedTriggerCorrelation } PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcTrueCorr, "process mc-true (all collisions) correlation for multiple associated particles", false); - - void processMcTrueRecoColCorr(CorrMcDCollision const& collision, aod::JetMcCollisions const&, aod::TriggerParticles const& triggerParticles, aod::JetParticles const& mcParticles) { // event selection - if (!collision.selEv()) return; + if (!collision.selEv()) + return; // group collision auto const triggerParticlesThisEvent = triggerParticles.sliceBy(perColTriggerParticles, collision.mcCollision().globalIndex()); auto const mcParticlesThisEvent = mcParticles.sliceBy(perColMcParticles, collision.mcCollision().globalIndex()); - // trigger pairing loop for (auto const& trigger : triggerParticlesThisEvent) { // trigger info histos.fill(HIST("mc/true_reco/corr/h3_ptPhiEta_trig"), trigger.pt(), trigger.phi(), trigger.eta()); - // hadrons (tracks) and pipm for (auto const& associated : mcParticlesThisEvent) { // exclude self correlation - if (trigger.jetMcParticleId() == associated.globalIndex()) continue; + if (trigger.jetMcParticleId() == associated.globalIndex()) + continue; // standard particles (marked physical primary) if (checkPrimaryEtaMc(associated)) { @@ -1494,14 +1437,11 @@ struct PhotonChargedTriggerCorrelation } PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcTrueRecoColCorr, "process mc-true (reco collisions) correlation for multiple associated particles", false); - - - - void processMcTrueEff(CorrMcCollision const& mcCollision, aod::JetParticles const& mcParticles) { // event selection - if (doTrigEvEff && !mcCollision.trigEv()) return; + if (doTrigEvEff && !mcCollision.trigEv()) + return; for (auto const& mcParticle : mcParticles) { // standard particles (marked physical primary) @@ -1535,8 +1475,6 @@ struct PhotonChargedTriggerCorrelation } PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcTrueEff, "process MC-true data (all collisions) to calculate efficiencies", false); - - void processMcRecoColEff(CorrMcDCollision const& collision, aod::JetMcCollisions const&, aod::JetTracksMCD const& tracks, aod::Triggers const& triggers, aod::Hadrons const& hadrons, aod::Pipms const& pipms, aod::PhotonPCMs const& photonPCMs, aod::PhotonPCMPairs const& photonPCMPairs, @@ -1545,14 +1483,14 @@ struct PhotonChargedTriggerCorrelation int excludeTriggerTrackId = -1; int excludeTriggerParticleId = -1; - // event selection - if (!collision.selEv()) return; - if (doTrigEvEff && !collision.trigEv()) return; + if (!collision.selEv()) + return; + if (doTrigEvEff && !collision.trigEv()) + return; auto const mcParticlesThisEvent = mcParticles.sliceBy(perColMcParticles, collision.mcCollision().globalIndex()); - // random trigger if (doTrigEvEff) { std::uniform_int_distribution intDistribution(0, static_cast(triggers.size()) - 1); @@ -1563,17 +1501,20 @@ struct PhotonChargedTriggerCorrelation } } - // hadrons for (auto const& hadron : hadrons) { - if (doTrigEvEff && hadron.jetTrackId() == excludeTriggerTrackId) continue; + if (doTrigEvEff && hadron.jetTrackId() == excludeTriggerTrackId) + continue; histos.fill(HIST("mc/eff/h3_ptPhiEta_mcReco_hadron"), hadron.pt(), hadron.phi(), hadron.eta()); histos.fill(HIST("mc/eff/h3_ptZPvMult_mcReco_hadron"), hadron.pt(), collision.posZ(), collision.multNTracksGlobal()); // purity - if (!hadron.jetTrack_as().has_mcParticle()) continue; + if (!hadron.jetTrack_as().has_mcParticle()) + continue; auto const hadronParticle = hadron.jetTrack_as().mcParticle(); - if (!checkPrimaryTrackMc(hadronParticle)) continue; - if (requireSingleCollisionPurity && hadronParticle.mcCollisionId() != collision.mcCollision().globalIndex()) continue; + if (!checkPrimaryTrackMc(hadronParticle)) + continue; + if (requireSingleCollisionPurity && hadronParticle.mcCollisionId() != collision.mcCollision().globalIndex()) + continue; histos.fill(HIST("mc/eff/h3_ptPhiEta_mcReco_hasCorrectMc_hadron"), hadron.pt(), hadron.phi(), hadron.eta()); histos.fill(HIST("mc/eff/h3_ptZPvMult_mcReco_hasCorrectMc_hadron"), hadron.pt(), collision.posZ(), collision.multNTracksGlobal()); @@ -1581,14 +1522,18 @@ struct PhotonChargedTriggerCorrelation // pipm for (auto const& pipm : pipms) { - if (doTrigEvEff && pipm.jetTrackId() == excludeTriggerTrackId) continue; + if (doTrigEvEff && pipm.jetTrackId() == excludeTriggerTrackId) + continue; histos.fill(HIST("mc/eff/h3_ptPhiEta_mcReco_pipm"), pipm.pt(), pipm.phi(), pipm.eta()); histos.fill(HIST("mc/eff/h3_ptZPvMult_mcReco_pipm"), pipm.pt(), collision.posZ(), collision.multNTracksGlobal()); // purity - if (!pipm.jetTrack_as().has_mcParticle()) continue; + if (!pipm.jetTrack_as().has_mcParticle()) + continue; auto const pipmParticle = pipm.jetTrack_as().mcParticle(); - if (std::abs(pipmParticle.pdgCode()) != PDG_t::kPiPlus || !checkPrimaryEtaMc(pipmParticle)) continue; - if (requireSingleCollisionPurity && pipmParticle.mcCollisionId() != collision.mcCollision().globalIndex()) continue; + if (std::abs(pipmParticle.pdgCode()) != PDG_t::kPiPlus || !checkPrimaryEtaMc(pipmParticle)) + continue; + if (requireSingleCollisionPurity && pipmParticle.mcCollisionId() != collision.mcCollision().globalIndex()) + continue; histos.fill(HIST("mc/eff/h3_ptPhiEta_mcReco_hasCorrectMc_pipm"), pipm.pt(), pipm.phi(), pipm.eta()); histos.fill(HIST("mc/eff/h3_ptZPvMult_mcReco_hasCorrectMc_pipm"), pipm.pt(), collision.posZ(), collision.multNTracksGlobal()); @@ -1600,23 +1545,30 @@ struct PhotonChargedTriggerCorrelation // check same mother auto const& posMothers = posTrack.mcParticle().template mothers_as(); auto const& negMothers = negTrack.mcParticle().template mothers_as(); - if (posMothers.size() != 1 || negMothers.size() != 1) return false; - if (posMothers.begin()->globalIndex() != negMothers.begin()->globalIndex()) return false; + if (posMothers.size() != 1 || negMothers.size() != 1) + return false; + if (posMothers.begin()->globalIndex() != negMothers.begin()->globalIndex()) + return false; // check photon - if (posMothers.begin()->pdgCode() != PDG_t::kGamma) return false; + if (posMothers.begin()->pdgCode() != PDG_t::kGamma) + return false; return true; }; auto isGGFromPi0 = [&](auto const& posTrack1, auto const& negTrack1, auto const& posTrack2, auto const& negTrack2) { - if (!isConversionPhoton(posTrack1, negTrack1) || !isConversionPhoton(posTrack2, negTrack2)) return false; + if (!isConversionPhoton(posTrack1, negTrack1) || !isConversionPhoton(posTrack2, negTrack2)) + return false; // check same mother auto const& mothers1 = (*(posTrack1.mcParticle().template mothers_as().begin())).template mothers_as(); auto const& mothers2 = (*(posTrack2.mcParticle().template mothers_as().begin())).template mothers_as(); constexpr int NMothersPhotonFromPi0 = 2; // for some reason two mothers (same particle) for pi0 decays (contradicts PYTHIA documentation, but whatever) - if (mothers1.size() != NMothersPhotonFromPi0 || mothers2.size() != NMothersPhotonFromPi0) return false; - if (mothers1.begin()->globalIndex() != mothers2.begin()->globalIndex()) return false; + if (mothers1.size() != NMothersPhotonFromPi0 || mothers2.size() != NMothersPhotonFromPi0) + return false; + if (mothers1.begin()->globalIndex() != mothers2.begin()->globalIndex()) + return false; // check pi0 - if (mothers1.begin()->pdgCode() != PDG_t::kPi0) return false; + if (mothers1.begin()->pdgCode() != PDG_t::kPi0) + return false; return true; }; @@ -1630,9 +1582,12 @@ struct PhotonChargedTriggerCorrelation // (V0Legs does not have the tracks reference as index column (just int)??) auto const& posTrack = tracks.rawIteratorAt(photonPCM.posTrackId() - tracks.offset()); auto const& negTrack = tracks.rawIteratorAt(photonPCM.negTrackId() - tracks.offset()); - if (!posTrack.has_mcParticle() || !negTrack.has_mcParticle()) continue; - if (!isConversionPhoton(posTrack, negTrack) || !checkPrimaryEtaMc(*(posTrack.mcParticle().mothers_as().begin()))) continue; - if (requireSingleCollisionPurity && posTrack.mcParticle().mcCollisionId() != collision.mcCollision().globalIndex()) continue; + if (!posTrack.has_mcParticle() || !negTrack.has_mcParticle()) + continue; + if (!isConversionPhoton(posTrack, negTrack) || !checkPrimaryEtaMc(*(posTrack.mcParticle().mothers_as().begin()))) + continue; + if (requireSingleCollisionPurity && posTrack.mcParticle().mcCollisionId() != collision.mcCollision().globalIndex()) + continue; histos.fill(HIST("mc/eff/h3_ptPhiEta_mcReco_hasCorrectMc_photonPCM"), photonPCM.pt(), photonPCM.phi(), photonPCM.eta()); histos.fill(HIST("mc/eff/h3_ptZPvMult_mcReco_hasCorrectMc_photonPCM"), photonPCM.pt(), collision.posZ(), collision.multNTracksGlobal()); @@ -1640,7 +1595,8 @@ struct PhotonChargedTriggerCorrelation // pi0PCM for (auto const& photonPCMPair : photonPCMPairs) { - if (photonPCMPair.mgg() < pi0PCMMassRange.value[0] || photonPCMPair.mgg() > pi0PCMMassRange.value[1]) continue; + if (photonPCMPair.mgg() < pi0PCMMassRange.value[0] || photonPCMPair.mgg() > pi0PCMMassRange.value[1]) + continue; histos.fill(HIST("mc/eff/h3_ptPhiEta_mcReco_pi0PCM"), photonPCMPair.pt(), photonPCMPair.phi(), photonPCMPair.eta()); histos.fill(HIST("mc/eff/h3_ptZPvMult_mcReco_pi0PCM"), photonPCMPair.pt(), collision.posZ(), collision.multNTracksGlobal()); @@ -1650,18 +1606,19 @@ struct PhotonChargedTriggerCorrelation auto const& negTrack1 = tracks.rawIteratorAt(photonPCMPair.negTrack1Id() - tracks.offset()); auto const& posTrack2 = tracks.rawIteratorAt(photonPCMPair.posTrack2Id() - tracks.offset()); auto const& negTrack2 = tracks.rawIteratorAt(photonPCMPair.negTrack2Id() - tracks.offset()); - if (!posTrack1.has_mcParticle() || !negTrack1.has_mcParticle() || !posTrack2.has_mcParticle() || !negTrack2.has_mcParticle()) continue; + if (!posTrack1.has_mcParticle() || !negTrack1.has_mcParticle() || !posTrack2.has_mcParticle() || !negTrack2.has_mcParticle()) + continue; if (!isGGFromPi0(posTrack1, negTrack1, posTrack2, negTrack2) || - std::abs((*(posTrack1.mcParticle().mothers_as().begin())).mothers_as().begin()->eta()) > etaMax) continue; + std::abs((*(posTrack1.mcParticle().mothers_as().begin())).mothers_as().begin()->eta()) > etaMax) + continue; if (requireSingleCollisionPurity && - (posTrack1.mcParticle().mcCollisionId() != collision.mcCollision().globalIndex() || posTrack2.mcParticle().mcCollisionId() != collision.mcCollision().globalIndex())) continue; + (posTrack1.mcParticle().mcCollisionId() != collision.mcCollision().globalIndex() || posTrack2.mcParticle().mcCollisionId() != collision.mcCollision().globalIndex())) + continue; histos.fill(HIST("mc/eff/h3_ptPhiEta_mcReco_hasCorrectMc_pi0PCM"), photonPCMPair.pt(), photonPCMPair.phi(), photonPCMPair.eta()); histos.fill(HIST("mc/eff/h3_ptZPvMult_mcReco_hasCorrectMc_pi0PCM"), photonPCMPair.pt(), collision.posZ(), collision.multNTracksGlobal()); } - - // mcParticle loop for (auto const& mcParticle : mcParticlesThisEvent) { // standard particles (marked physical primary) @@ -1695,10 +1652,6 @@ struct PhotonChargedTriggerCorrelation } PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcRecoColEff, "process MC data to calculate efficiencies and purities", false); - - - - // test ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void processTest(CorrCollision const& collision, @@ -1706,8 +1659,8 @@ struct PhotonChargedTriggerCorrelation aod::Hadrons const& hadrons) { // event selection - if (!collision.selEv()) return; - + if (!collision.selEv()) + return; histos.fill(HIST("test/h2_mult_comp"), collision.multNTracksGlobal(), hadrons.size()); @@ -1720,13 +1673,17 @@ struct PhotonChargedTriggerCorrelation constexpr float MaxR = 83.1; constexpr float MinPtTrackiu = 0.1; - if (!fullTrack.hasITS() && !fullTrack.hasTPC()) continue; - if (fullTrack.x()*fullTrack.x() + fullTrack.y()*fullTrack.y() > MaxR*MaxR || fullTrack.pt() < MinPtTrackiu) continue; + if (!fullTrack.hasITS() && !fullTrack.hasTPC()) + continue; + if (fullTrack.x() * fullTrack.x() + fullTrack.y() * fullTrack.y() > MaxR * MaxR || fullTrack.pt() < MinPtTrackiu) + continue; if (fullTrack.hasTPC()) { - if (fullTrack.tpcNClsCrossedRows() < Mincrossedrows || fullTrack.tpcChi2NCl() > Maxchi2tpc) continue; + if (fullTrack.tpcNClsCrossedRows() < Mincrossedrows || fullTrack.tpcChi2NCl() > Maxchi2tpc) + continue; } if (fullTrack.hasITS()) { - if (fullTrack.itsChi2NCl() > Maxchi2its) continue; + if (fullTrack.itsChi2NCl() > Maxchi2its) + continue; } histos.fill(HIST("test/h2_tracks_zPvMultDep"), collision.posZ(), collision.multNTracksGlobal()); @@ -1737,15 +1694,9 @@ struct PhotonChargedTriggerCorrelation PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processTest, "process just to test things", false); }; - - - - WorkflowSpec defineDataProcessing(ConfigContext const& configContext) { return WorkflowSpec{ adaptAnalysisTask(configContext), - adaptAnalysisTask(configContext) - }; + adaptAnalysisTask(configContext)}; } -