From f1c595b95b923a5ae8323e88917e8d3f42c34abd Mon Sep 17 00:00:00 2001 From: jkinner2 Date: Mon, 2 Nov 2026 15:52:35 +0100 Subject: [PATCH 01/13] renameCorrelationFilesPeter --- PWGJE/Tasks/CMakeLists.txt | 4 +-- ...ion.cxx => hadronPhotonCorrelationSim.cxx} | 36 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) rename PWGJE/Tasks/{hadronPhotonCorrelation.cxx => hadronPhotonCorrelationSim.cxx} (96%) diff --git a/PWGJE/Tasks/CMakeLists.txt b/PWGJE/Tasks/CMakeLists.txt index 3a558ae55df..2c9af91e60e 100644 --- a/PWGJE/Tasks/CMakeLists.txt +++ b/PWGJE/Tasks/CMakeLists.txt @@ -110,8 +110,8 @@ o2physics_add_dpl_workflow(photon-charged-trigger-producer REUSE_FROM JetDataModelPCH PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(hadron-photon-correlation - SOURCES hadronPhotonCorrelation.cxx +o2physics_add_dpl_workflow(hadron-photon-correlation-sim + SOURCES hadronPhotonCorrelationSim.cxx REUSE_FROM JetDataModelPCH PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) diff --git a/PWGJE/Tasks/hadronPhotonCorrelation.cxx b/PWGJE/Tasks/hadronPhotonCorrelationSim.cxx similarity index 96% rename from PWGJE/Tasks/hadronPhotonCorrelation.cxx rename to PWGJE/Tasks/hadronPhotonCorrelationSim.cxx index 18e73087ff7..de4f8e5d32a 100644 --- a/PWGJE/Tasks/hadronPhotonCorrelation.cxx +++ b/PWGJE/Tasks/hadronPhotonCorrelationSim.cxx @@ -10,7 +10,7 @@ // or submit itself to any jurisdiction. /// -/// \file hadronPhotonCorrelation.cxx +/// \file hadronPhotonCorrelationSim.cxx /// \author Peter Stratmann /// \brief This code loops over JetTracks to extract pt and angular information /// for hadrons and photons to compute angular correlations @@ -57,7 +57,7 @@ using namespace o2::soa; using namespace o2::constants::physics; using namespace o2::constants::math; -struct HadronPhotonCorrelation { +struct HadronPhotonCorrelationSim { Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; @@ -514,7 +514,7 @@ struct HadronPhotonCorrelation { registry.fill(HIST("generated/events/hPtHat"), getCollisionPtHat(particles)); } - PROCESS_SWITCH(HadronPhotonCorrelation, processEventsMCGen, "event stats MC gen", true); + PROCESS_SWITCH(HadronPhotonCorrelationSim, processEventsMCGen, "event stats MC gen", true); void processEventsMCReco(JetCollisionMCD const& collision, JetMcCollisions const&, @@ -535,7 +535,7 @@ struct HadronPhotonCorrelation { registry.fill(HIST("reconstructed/events/hEventStats"), 3, collision.mcCollision().weight()); registry.fill(HIST("reconstructed/events/hEventStats"), 5, collision.mcCollision().xsectGen()); } - PROCESS_SWITCH(HadronPhotonCorrelation, processEventsMCReco, "event stats MC reco", true); + PROCESS_SWITCH(HadronPhotonCorrelationSim, processEventsMCReco, "event stats MC reco", true); /**************************************************************************************************** ************************************************ TRIGGER ******************************************** @@ -565,7 +565,7 @@ struct HadronPhotonCorrelation { } registry.fill(HIST("reconstructed/triggers/hTrigMultReco"), nTrigs); } - PROCESS_SWITCH(HadronPhotonCorrelation, processTrigsReco, "trigger particle properties", true); + PROCESS_SWITCH(HadronPhotonCorrelationSim, processTrigsReco, "trigger particle properties", true); /*********************************************** MC ************************************************/ @@ -595,7 +595,7 @@ struct HadronPhotonCorrelation { } registry.fill(HIST("reconstructed/triggers/hTrigMultReco"), nTrigs, collision.mcCollision().weight()); } - PROCESS_SWITCH(HadronPhotonCorrelation, processTrigsMCReco, "trigger particle mc properties", true); + PROCESS_SWITCH(HadronPhotonCorrelationSim, processTrigsMCReco, "trigger particle mc properties", true); void processTrigsMCGen(JetMcCollision const& collision, JetParticles const& particles) @@ -614,7 +614,7 @@ struct HadronPhotonCorrelation { } registry.fill(HIST("generated/triggers/hTrigMultGen"), nTrigs, collision.weight()); } - PROCESS_SWITCH(HadronPhotonCorrelation, processTrigsMCGen, "trigger particle mc properties", true); + PROCESS_SWITCH(HadronPhotonCorrelationSim, processTrigsMCGen, "trigger particle mc properties", true); /**************************************************************************************************** ********************************************** PHOTONS ********************************************** @@ -655,7 +655,7 @@ struct HadronPhotonCorrelation { } registry.fill(HIST("reconstructed/photons/hPhotonMultReco"), nPhotons); } - PROCESS_SWITCH(HadronPhotonCorrelation, processPhotonCorrelations, "hadron-photon correlation", true); + PROCESS_SWITCH(HadronPhotonCorrelationSim, processPhotonCorrelations, "hadron-photon correlation", true); /*********************************************** MC ************************************************/ @@ -698,7 +698,7 @@ struct HadronPhotonCorrelation { } registry.fill(HIST("reconstructed/photons/hPhotonMultReco"), nPhotons, collision_reco.mcCollision().weight()); } - PROCESS_SWITCH(HadronPhotonCorrelation, processPhotonCorrelationsMCReco, "hadron-photon correlation", true); + PROCESS_SWITCH(HadronPhotonCorrelationSim, processPhotonCorrelationsMCReco, "hadron-photon correlation", true); void processPhotonCorrelationsMCGen(JetMcCollision const& collision, JetParticles const& tracks_true) @@ -766,7 +766,7 @@ struct HadronPhotonCorrelation { registry.fill(HIST("generated/photons/hPhotonMultGen"), nPhotons, collision.weight()); } - PROCESS_SWITCH(HadronPhotonCorrelation, processPhotonCorrelationsMCGen, "mc hadron-photon correlation", true); + PROCESS_SWITCH(HadronPhotonCorrelationSim, processPhotonCorrelationsMCGen, "mc hadron-photon correlation", true); /**************************************************************************************************** ***************************************** HADRONS *************************************************** @@ -808,7 +808,7 @@ struct HadronPhotonCorrelation { } registry.fill(HIST("reconstructed/hadrons/hHadronMultReco"), nHadrons); } - PROCESS_SWITCH(HadronPhotonCorrelation, processHadronCorrelations, "hadron-hadron correlation", true); + PROCESS_SWITCH(HadronPhotonCorrelationSim, processHadronCorrelations, "hadron-hadron correlation", true); /*********************************************** MC ************************************************/ @@ -849,7 +849,7 @@ struct HadronPhotonCorrelation { } registry.fill(HIST("generated/hadrons/hHadronMultGen"), nHadrons, collision.weight()); } - PROCESS_SWITCH(HadronPhotonCorrelation, processHadronCorrelationsMCGen, "mc hadron-hadron correlation", true); + PROCESS_SWITCH(HadronPhotonCorrelationSim, processHadronCorrelationsMCGen, "mc hadron-hadron correlation", true); void processHadronCorrelationsMCReco(JetCollisionMCD const& collision_reco, JetMcCollisions const&, @@ -907,7 +907,7 @@ struct HadronPhotonCorrelation { } registry.fill(HIST("reconstructed/hadrons/hHadronMultReco"), nHadrons, collision_reco.mcCollision().weight()); } - PROCESS_SWITCH(HadronPhotonCorrelation, processHadronCorrelationsMCReco, "mc hadron-hadron correlation", true); + PROCESS_SWITCH(HadronPhotonCorrelationSim, processHadronCorrelationsMCReco, "mc hadron-hadron correlation", true); /**************************************************************************************************** *************************************** CHARGED PIONS *********************************************** @@ -952,7 +952,7 @@ struct HadronPhotonCorrelation { } registry.fill(HIST("reconstructed/charged/hPionMultReco"), nPions); } - PROCESS_SWITCH(HadronPhotonCorrelation, processPionCorrelations, "hadron-pion correlation", true); + PROCESS_SWITCH(HadronPhotonCorrelationSim, processPionCorrelations, "hadron-pion correlation", true); /*********************************************** MC ************************************************/ @@ -1027,7 +1027,7 @@ struct HadronPhotonCorrelation { } registry.fill(HIST("generated/charged/hPionMultGen"), nPions, collision.weight()); } - PROCESS_SWITCH(HadronPhotonCorrelation, processPionCorrelationsMCGen, "mc hadron-pion correlation", true); + PROCESS_SWITCH(HadronPhotonCorrelationSim, processPionCorrelationsMCGen, "mc hadron-pion correlation", true); void processPionCorrelationsMCReco(JetCollisionMCD const& collision_reco, JetMcCollisions const&, @@ -1074,7 +1074,7 @@ struct HadronPhotonCorrelation { } registry.fill(HIST("reconstructed/charged/hPionMultReco"), nPions, collision_reco.mcCollision().weight()); } - PROCESS_SWITCH(HadronPhotonCorrelation, processPionCorrelationsMCReco, "mc hadron-pion correlation", true); + PROCESS_SWITCH(HadronPhotonCorrelationSim, processPionCorrelationsMCReco, "mc hadron-pion correlation", true); /**************************************************************************************************** ****************************************** NEUTRALS ************************************************* @@ -1169,10 +1169,10 @@ struct HadronPhotonCorrelation { } registry.fill(HIST("generated/neutral/hNeutralMultGen"), nNeutrals, collision.weight()); } - PROCESS_SWITCH(HadronPhotonCorrelation, processNeutralCorrelationsMCGen, "mc hadron-pion correlation", true); + PROCESS_SWITCH(HadronPhotonCorrelationSim, processNeutralCorrelationsMCGen, "mc hadron-pion correlation", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc)}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; }; From 90f687a82fb2d69e7a55faa657ce2ae54677c277 Mon Sep 17 00:00:00 2001 From: jkinner2 Date: Mon, 2 Nov 2026 15:55:28 +0100 Subject: [PATCH 02/13] renameCorrelationFilesJulius --- ...orrelation.h => HadronPhotonCorrelation.h} | 10 ++--- PWGJE/Tasks/CMakeLists.txt | 8 ++-- ...lation.cxx => hadronPhotonCorrelation.cxx} | 44 +++++++++---------- ...rProducer.cxx => hadronPhotonProducer.cxx} | 20 ++++----- 4 files changed, 41 insertions(+), 41 deletions(-) rename PWGJE/DataModel/{PhotonChargedTriggerCorrelation.h => HadronPhotonCorrelation.h} (95%) rename PWGJE/Tasks/{photonChargedTriggerCorrelation.cxx => hadronPhotonCorrelation.cxx} (97%) rename PWGJE/Tasks/{photonChargedTriggerProducer.cxx => hadronPhotonProducer.cxx} (95%) diff --git a/PWGJE/DataModel/PhotonChargedTriggerCorrelation.h b/PWGJE/DataModel/HadronPhotonCorrelation.h similarity index 95% rename from PWGJE/DataModel/PhotonChargedTriggerCorrelation.h rename to PWGJE/DataModel/HadronPhotonCorrelation.h index 637a7f18c35..c43346a4c68 100644 --- a/PWGJE/DataModel/PhotonChargedTriggerCorrelation.h +++ b/PWGJE/DataModel/HadronPhotonCorrelation.h @@ -10,13 +10,13 @@ // or submit itself to any jurisdiction. /// -/// \brief table definitions for photon-hadron correlation analyses +/// \brief table definitions for hadron-photon correlation analyses /// /// \author Julius Kinner -/// \file PhotonChargedTriggerCorrelation.h +/// \file HadronPhotonCorrelation.h -#ifndef PWGJE_DATAMODEL_PHOTONCHARGEDTRIGGERCORRELATION_H_ -#define PWGJE_DATAMODEL_PHOTONCHARGEDTRIGGERCORRELATION_H_ +#ifndef PWGJE_DATAMODEL_HADRONPHOTONCORRELATION_H_ +#define PWGJE_DATAMODEL_HADRONPHOTONCORRELATION_H_ #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" #include "PWGJE/DataModel/Jet.h" @@ -135,4 +135,4 @@ DECLARE_SOA_TABLE(TriggerParticles, "AOD", "TRIGGERPARTICLES", using TriggerParticle = TriggerParticles::iterator; } // namespace o2::aod -#endif // PWGJE_DATAMODEL_PHOTONCHARGEDTRIGGERCORRELATION_H_ +#endif // PWGJE_DATAMODEL_HADRONPHOTONCORRELATION_H_ diff --git a/PWGJE/Tasks/CMakeLists.txt b/PWGJE/Tasks/CMakeLists.txt index 2c9af91e60e..dee5133267e 100644 --- a/PWGJE/Tasks/CMakeLists.txt +++ b/PWGJE/Tasks/CMakeLists.txt @@ -96,8 +96,8 @@ o2physics_add_dpl_workflow(photon-isolation-qa SOURCES photonIsolationQA.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::AnalysisCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(photon-charged-trigger-correlation - SOURCES photonChargedTriggerCorrelation.cxx +o2physics_add_dpl_workflow(hadron-photon-correlation + SOURCES hadronPhotonCorrelation.cxx REUSE_FROM JetDataModelPCH PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) @@ -105,8 +105,8 @@ o2physics_add_dpl_workflow(task-emc-extensive-mc-qa SOURCES taskEmcExtensiveMcQa.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2Physics::AnalysisCore O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(photon-charged-trigger-producer - SOURCES photonChargedTriggerProducer.cxx +o2physics_add_dpl_workflow(hadron-photon-producer + SOURCES hadronPhotonProducer.cxx REUSE_FROM JetDataModelPCH PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) diff --git a/PWGJE/Tasks/photonChargedTriggerCorrelation.cxx b/PWGJE/Tasks/hadronPhotonCorrelation.cxx similarity index 97% rename from PWGJE/Tasks/photonChargedTriggerCorrelation.cxx rename to PWGJE/Tasks/hadronPhotonCorrelation.cxx index 943bc742517..728cf0abfdc 100644 --- a/PWGJE/Tasks/photonChargedTriggerCorrelation.cxx +++ b/PWGJE/Tasks/hadronPhotonCorrelation.cxx @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file photonChargedTriggerCorrelation.cxx +/// \file hadronPhotonCorrelation.cxx /// \author Julius Kinner /// \brief photon-jet angular correlation analysis /// @@ -18,7 +18,7 @@ /// Also contains checks and monte-carlo (efficiency, purity, mc-true correlation,...) /// End goal of studying correlations between direct photons and jets -#include "PWGJE/DataModel/PhotonChargedTriggerCorrelation.h" +#include "PWGJE/DataModel/HadronPhotonCorrelation.h" #include "PWGJE/DataModel/Jet.h" #include "PWGJE/DataModel/JetReducedData.h" @@ -85,7 +85,7 @@ using BinningZPvMult = ColumnBinningPolicy(collision, hadronsThisEvent, funcMixing, nMixingAt0Hadron); } } - PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processCorrHadron, "process standard correlation for associated hardons", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processCorrHadron, "process standard correlation for associated hardons", false); void processCorrPipm(CorrCollisions const& collisions, aod::Triggers const& triggers, aod::Pipms const& pipms) { @@ -1023,7 +1023,7 @@ struct PhotonChargedTriggerCorrelation { corrProcessMixing(collision, pipmsThisEvent, funcMixing, nMixingAt0Pipm); } } - PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processCorrPipm, "process standard correlation for associated pipm", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processCorrPipm, "process standard correlation for associated pipm", false); void processCorrPhotonPCM(CorrCollisions const& collisions, aod::Triggers const& triggers, aod::PhotonPCMs const& photonPCMs) { @@ -1075,7 +1075,7 @@ struct PhotonChargedTriggerCorrelation { corrProcessMixing(collision, photonPCMsThisEvent, funcMixing, nMixingAt0PhotonPCM); } } - PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processCorrPhotonPCM, "process standard correlation for associated photonPCM", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processCorrPhotonPCM, "process standard correlation for associated photonPCM", false); void processCorrPhotonPCMPair(CorrCollisions const& collisions, aod::Triggers const& triggers, aod::PhotonPCMPairs const& photonPCMPairs) { @@ -1198,7 +1198,7 @@ struct PhotonChargedTriggerCorrelation { corrProcessMixing(collision, photonPCMPairsThisEvent, funcMixing, nMixingAt0H0PCM); } } - PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processCorrPhotonPCMPair, "process standard correlation for associated pi0PCM", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processCorrPhotonPCMPair, "process standard correlation for associated pi0PCM", false); void processCorrPhotonPCMPairMix(CorrCollisions const& collisions, aod::PhotonPCMs const& photonPCMs) { @@ -1233,7 +1233,7 @@ struct PhotonChargedTriggerCorrelation { } } } - PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processCorrPhotonPCMPairMix, "process gamma-gamma mixing for photonPCM", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processCorrPhotonPCMPairMix, "process gamma-gamma mixing for photonPCM", false); void processPCMDCAz(CorrCollision const& collision, aod::PhotonPCMs const& photonPCMs, aod::V0PhotonsKF const&) { @@ -1247,7 +1247,7 @@ struct PhotonChargedTriggerCorrelation { collision.ptMax(), photonPCM.pt(), photonPCM.v0PhotonKF().dcaZtopv(), collision.posZ(), collision.nGlobalTracks()); } } - PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processPCMDCAz, "process to test DCAz distribution of photons in trigger collisions", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processPCMDCAz, "process to test DCAz distribution of photons in trigger collisions", false); // MC /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ========================================================================================================================================================================================== @@ -1520,7 +1520,7 @@ struct PhotonChargedTriggerCorrelation { corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, nMixingAt0McTrue); } } - PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcTrueCorr, "process mc-true (all collisions) correlation for multiple associated particles", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueCorr, "process mc-true (all collisions) correlation for multiple associated particles", false); void processMcTrueAssocEvCorr(CorrMcDCollisions const& collisions, CorrMcCollisions const&, aod::TriggerParticles const& triggerParticles, aod::JetParticles const& mcParticles) { @@ -1552,7 +1552,7 @@ struct PhotonChargedTriggerCorrelation { corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, nMixingAt0McTrue); } } - PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcTrueAssocEvCorr, "process mc-true (reco collisions) correlation for multiple associated particles", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueAssocEvCorr, "process mc-true (reco collisions) correlation for multiple associated particles", false); void processMcTrueAssocEvRecoPtTrigCorr(CorrMcDCollisions const& collisions, aod::Triggers const& triggers, aod::JetTracksMCD const&, CorrMcCollisions const&, aod::JetParticles const& mcParticles) { @@ -1584,7 +1584,7 @@ struct PhotonChargedTriggerCorrelation { corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, nMixingAt0McTrue); } } - PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcTrueAssocEvRecoPtTrigCorr, "process mc-true (reco collisions with reco ptTrig) correlation for multiple associated particles", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueAssocEvRecoPtTrigCorr, "process mc-true (reco collisions with reco ptTrig) correlation for multiple associated particles", false); void processMcRecoCorrHadron(CorrMcDCollisions const& collisions, aod::Triggers const& triggers, aod::Hadrons const& hadrons, aod::JetTracksMCD const&, aod::JetParticles const&) @@ -1676,7 +1676,7 @@ struct PhotonChargedTriggerCorrelation { corrProcessMixing(collision, hadronsThisEvent, funcMixing, nMixingAt0Hadron); } } - PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcRecoCorrHadron, "process correlation for associated hardons with additional mc information", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoCorrHadron, "process correlation for associated hardons with additional mc information", false); void processMcRecoCorrPipm(CorrMcDCollisions const& collisions, aod::Triggers const& triggers, aod::Pipms const& pipms, aod::JetTracksMCD const&, aod::JetParticles const&) @@ -1768,7 +1768,7 @@ struct PhotonChargedTriggerCorrelation { corrProcessMixing(collision, pipmsThisEvent, funcMixing, nMixingAt0Pipm); } } - PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcRecoCorrPipm, "process correlation for associated pipms with additional mc information", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoCorrPipm, "process correlation for associated pipms with additional mc information", false); void processMcRecoCorrPhotonPCM(CorrMcDCollisions const& collisions, aod::Triggers const& triggers, aod::PhotonPCMs const& photonPCMs, aod::JetTracksMCD const&, aod::JetParticles const&) @@ -1864,7 +1864,7 @@ struct PhotonChargedTriggerCorrelation { corrProcessMixing(collision, photonPCMsThisEvent, funcMixing, nMixingAt0PhotonPCM); } } - PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcRecoCorrPhotonPCM, "process correlation for associated photonPCMs with additional mc information", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoCorrPhotonPCM, "process correlation for associated photonPCMs with additional mc information", false); void processMcRecoCorrPi0PCM(CorrMcDCollisions const& collisions, aod::Triggers const& triggers, aod::PhotonPCMPairs const& photonPCMPairs, aod::JetTracksMCD const&, aod::JetParticles const&) @@ -1985,7 +1985,7 @@ struct PhotonChargedTriggerCorrelation { corrProcessMixing(collision, photonPCMPairsThisEvent, funcMixing, nMixingAt0PhotonPCM); } } - PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcRecoCorrPi0PCM, "process correlation for associated pi0PCMs with additional mc information", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoCorrPi0PCM, "process correlation for associated pi0PCMs with additional mc information", false); // other //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -2320,7 +2320,7 @@ struct PhotonChargedTriggerCorrelation { } } } - PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcRecoCorrection, "process mc reconstruction to calculate corrections", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoCorrection, "process mc reconstruction to calculate corrections", false); void processMcTrueCorrection(CorrMcCollision const& mcCollision, aod::JetParticles const& mcParticles) { @@ -2371,7 +2371,7 @@ struct PhotonChargedTriggerCorrelation { } } } - PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcTrueCorrection, "process mc true data to calculate corrections", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueCorrection, "process mc true data to calculate corrections", false); void processPCMDCAzTrue(CorrMcDCollision const& collision, aod::PhotonPCMs const& photonPCMs, aod::V0PhotonsKF const&, aod::JetTracksMCD const&, CorrMcCollisions const&, aod::JetParticles const&) @@ -2397,7 +2397,7 @@ struct PhotonChargedTriggerCorrelation { collision.ptMax(), photonPCM.pt(), photonPCM.v0PhotonKF().dcaZtopv(), collision.posZ(), collision.nGlobalTracks()); } } - PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processPCMDCAzTrue, "process to test true DCAz distribution of photons in trigger collisions", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processPCMDCAzTrue, "process to test true DCAz distribution of photons in trigger collisions", false); // last ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -2440,7 +2440,7 @@ struct PhotonChargedTriggerCorrelation { } } } - PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processRecoLast, "process general info for reconstructed collisions and later correlations last", true); + PROCESS_SWITCH(HadronPhotonCorrelation, processRecoLast, "process general info for reconstructed collisions and later correlations last", true); void processMcLast(CorrMcDCollisions const& collisions, aod::Triggers const& triggers, aod::JetTracksMCD const&, CorrMcCollisions const& mcCollisions, aod::TriggerParticles const& triggerParticles, aod::JetParticles const&) @@ -2503,10 +2503,10 @@ struct PhotonChargedTriggerCorrelation { } } } - PROCESS_SWITCH(PhotonChargedTriggerCorrelation, processMcLast, "process general MC info for collisions and later correlations last", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processMcLast, "process general MC info for collisions and later correlations last", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& configContext) { - return WorkflowSpec{adaptAnalysisTask(configContext)}; + return WorkflowSpec{adaptAnalysisTask(configContext)}; } diff --git a/PWGJE/Tasks/photonChargedTriggerProducer.cxx b/PWGJE/Tasks/hadronPhotonProducer.cxx similarity index 95% rename from PWGJE/Tasks/photonChargedTriggerProducer.cxx rename to PWGJE/Tasks/hadronPhotonProducer.cxx index 9e16a69e1cc..dcbe82f5b11 100644 --- a/PWGJE/Tasks/photonChargedTriggerProducer.cxx +++ b/PWGJE/Tasks/hadronPhotonProducer.cxx @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file photonChargedTriggerProducer.cxx +/// \file hadronPhotonProducer.cxx /// \author Julius Kinner /// \brief photon-jet angular correlation table producer /// @@ -18,7 +18,7 @@ #include "PWGJE/Core/JetDerivedDataUtilities.h" #include "PWGJE/DataModel/Jet.h" #include "PWGJE/DataModel/JetReducedData.h" -#include "PWGJE/DataModel/PhotonChargedTriggerCorrelation.h" +#include "PWGJE/DataModel/HadronPhotonCorrelation.h" // #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" @@ -60,7 +60,7 @@ concept IsJetCollisionMCD = std::same_as, aod::JetCollisi template concept HasTrueCollision = IsJetMcCollision || IsJetCollisionMCD; -struct PhotonChargedTriggerProducer { +struct HadronPhotonProducer { struct : ProducesGroup { // reco Produces collisionExtraCorr; @@ -297,13 +297,13 @@ struct PhotonChargedTriggerProducer { { fillRecoCollisionTrigger(collision, tracks); } - PROCESS_SWITCH(PhotonChargedTriggerProducer, processRecoCollisionTrigger, "process correlation collision_extra and trigger table (reconstructed)", false); + PROCESS_SWITCH(HadronPhotonProducer, processRecoCollisionTrigger, "process correlation collision_extra and trigger table (reconstructed)", false); void processMcRecoCollisionTrigger(aod::JetCollisionMCD const& collision, aod::JetTracks const& tracks, aod::JetMcCollisions const&) { fillRecoCollisionTrigger(collision, tracks); } - PROCESS_SWITCH(PhotonChargedTriggerProducer, processMcRecoCollisionTrigger, "process correlation collision_extra and trigger table (reconstructed MC)", false); + PROCESS_SWITCH(HadronPhotonProducer, processMcRecoCollisionTrigger, "process correlation collision_extra and trigger table (reconstructed MC)", false); void processRecoPipmTPCTOF(aod::JetCollision const& collision, soa::Join const& tracks, soa::Join const&) @@ -335,7 +335,7 @@ struct PhotonChargedTriggerProducer { tableProduction.pipm(track.collisionId(), track.globalIndex(), track.pt(), track.phi(), track.eta()); } } - PROCESS_SWITCH(PhotonChargedTriggerProducer, processRecoPipmTPCTOF, "process pipm (TPC-TOF) table (reconstructed)", false); + PROCESS_SWITCH(HadronPhotonProducer, processRecoPipmTPCTOF, "process pipm (TPC-TOF) table (reconstructed)", false); void processRecoPipmTPC(aod::JetCollision const& collision, soa::Join const& tracks, soa::Join const&) @@ -367,7 +367,7 @@ struct PhotonChargedTriggerProducer { tableProduction.pipm(track.collisionId(), track.globalIndex(), track.pt(), track.phi(), track.eta()); } } - PROCESS_SWITCH(PhotonChargedTriggerProducer, processRecoPipmTPC, "process pipm (TPC) table (reconstructed)", false); + PROCESS_SWITCH(HadronPhotonProducer, processRecoPipmTPC, "process pipm (TPC) table (reconstructed)", false); void processRecoPhotonPCM(soa::Join::iterator const& collision, aod::V0PhotonsKF const& v0Photons, aod::V0Legs const&) @@ -415,7 +415,7 @@ struct PhotonChargedTriggerProducer { p4V0PCMPair.Pt(), RecoDecay::constrainAngle(p4V0PCMPair.Phi(), 0), p4V0PCMPair.Eta(), p4V0PCMPair.M()); } } - PROCESS_SWITCH(PhotonChargedTriggerProducer, processRecoPhotonPCM, "process photonPCM table (reconstructed)", false); + PROCESS_SWITCH(HadronPhotonProducer, processRecoPhotonPCM, "process photonPCM table (reconstructed)", false); void processMcCorrTables(aod::JetMcCollision const& mcCollision, aod::JetParticles const& mcParticles) { @@ -475,10 +475,10 @@ struct PhotonChargedTriggerProducer { histos.fill(HIST("true/h2_zPvMult"), mcCollision.posZ(), nCharged); tableProduction.mcCollisionExtraCorr(thirdDecimalTruePosZ, isTriggerEvent, maxChargedPt, nCharged); } - PROCESS_SWITCH(PhotonChargedTriggerProducer, processMcCorrTables, "process table production (mc)", false); + PROCESS_SWITCH(HadronPhotonProducer, processMcCorrTables, "process table production (mc)", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& configContext) { - return WorkflowSpec{adaptAnalysisTask(configContext)}; + return WorkflowSpec{adaptAnalysisTask(configContext)}; } From 04056f6bc476130e7dfca14b0fbffc6015bdb103 Mon Sep 17 00:00:00 2001 From: jkinner2 Date: Mon, 2 Nov 2026 16:56:21 +0100 Subject: [PATCH 03/13] overhaulTask --- PWGJE/DataModel/HadronPhotonCorrelation.h | 165 +- PWGJE/Tasks/CMakeLists.txt | 2 +- PWGJE/Tasks/hadronPhotonCorrelation.cxx | 3218 +++++++++++---------- PWGJE/Tasks/hadronPhotonProducer.cxx | 840 ++++-- 4 files changed, 2322 insertions(+), 1903 deletions(-) diff --git a/PWGJE/DataModel/HadronPhotonCorrelation.h b/PWGJE/DataModel/HadronPhotonCorrelation.h index c43346a4c68..b838ef33d16 100644 --- a/PWGJE/DataModel/HadronPhotonCorrelation.h +++ b/PWGJE/DataModel/HadronPhotonCorrelation.h @@ -24,77 +24,154 @@ #include +enum class AssocType { + Hadron, + Pipm, + PhotonPcm, + PhotonDecay, + PhotonDirect, + PhotonPcmPair, + Pi0Pcm, + Pi0PcmPeak, + Pi0PcmSide, + PhotonPi0, + EtaPcm, + EtaPcmPeak, + EtaPcmSide, + PhotonEta, + Omega, + PhotonOmega, + EtaPrime, + PhotonEtaPrime, + PhotonOtherMother +}; + +enum class TruthLevel : int { + None = -1, + Reco = 0, + RecoMcMatched = 1, + RecoAssocEv = 2, + RecoPure = 3, + RecoPureTruePtAssoc = 4, + PseudoReco = 5, + PseudoRecoAssocEv = 6, + PseudoRecoPure = 7, + PseudoRecoPureTruePtAssoc = 8, + TrueGeoAcc = 9, + TrueMeasDecay = 10, + TrueAssocEvRecoPtTrig = 11, + TrueAssocEv = 12, + True = 13, + TrueDecaySelfTrig = 14 +}; + +template +bool constexpr AlwaysFalseType = false; +template +bool constexpr AlwaysFalseValue = false; + namespace o2::aod { -// basic correlation particle columns -namespace corr_particle +// common correlation columns +namespace corr_common { -DECLARE_SOA_INDEX_COLUMN_FULL(JetCollision, jetCollision, int, JCollisions, ""); DECLARE_SOA_INDEX_COLUMN_FULL(JetMcCollision, jetMcCollision, int, JMcCollisions, ""); DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(PtTrue, ptTrue, float); DECLARE_SOA_COLUMN(Phi, phi, float); DECLARE_SOA_COLUMN(Eta, eta, float); -} // namespace corr_particle +} // namespace corr_common // reco -// collision extension -namespace collision_extra_corr +// correlation collision +namespace corr_collision { +// plain jet collision column for derived data +DECLARE_SOA_COLUMN(JetCollisionId, jetCollisionId, int); DECLARE_SOA_COLUMN(SelEv, selEv, bool); DECLARE_SOA_COLUMN(ThirdDecimalTruePosZ, thirdDecimalTruePosZ, int); DECLARE_SOA_COLUMN(TrigEv, trigEv, bool); DECLARE_SOA_COLUMN(PtMax, ptMax, float); +DECLARE_SOA_COLUMN(PosZ, posZ, float); DECLARE_SOA_COLUMN(NGlobalTracks, nGlobalTracks, int); -} // namespace collision_extra_corr -DECLARE_SOA_TABLE(CollisionsExtraCorr, "AOD", "COLLISIONSEXTRACORR", - collision_extra_corr::SelEv, collision_extra_corr::ThirdDecimalTruePosZ, collision_extra_corr::TrigEv, collision_extra_corr::PtMax, collision_extra_corr::NGlobalTracks); +} // namespace corr_collision +DECLARE_SOA_TABLE(CorrCollisions, "AOD", "CORRCOLLISION", + o2::soa::Index<>, + corr_collision::SelEv, corr_collision::ThirdDecimalTruePosZ, corr_collision::TrigEv, corr_collision::PtMax, corr_collision::PosZ, corr_collision::NGlobalTracks); +DECLARE_SOA_TABLE(CorrCollisionIds, "AOD", "CORRCOLLISIONID", + corr_collision::JetCollisionId); +DECLARE_SOA_TABLE(CorrCollisionMcIds, "AOD", "CORRCOLLISIONMCID", + corr_common::JetMcCollisionId); + +// add to common columns +namespace corr_common +{ +DECLARE_SOA_INDEX_COLUMN_FULL(CorrCollision, corrCollision, int, CorrCollisions, ""); +} // namespace corr_common // trigger namespace trigger { DECLARE_SOA_INDEX_COLUMN_FULL(JetTrack, jetTrack, int, JetTracks, ""); } // namespace trigger -DECLARE_SOA_TABLE(Triggers, "AOD", "TRIGGERS", - o2::soa::Index<>, corr_particle::JetCollisionId, trigger::JetTrackId, - corr_particle::Pt, corr_particle::Phi, corr_particle::Eta); -using Trigger = Triggers::iterator; +DECLARE_SOA_TABLE(Triggers, "AOD", "TRIGGER", + o2::soa::Index<>, corr_common::CorrCollisionId, + corr_common::Pt, corr_common::Phi, corr_common::Eta); +DECLARE_SOA_TABLE(TriggerTrackIds, "AOD", "TRIGGERTRACKID", + trigger::JetTrackId); + +// add to common columns +namespace corr_common +{ +DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(IntersectTrigger, intersectTrigger, int, Triggers, ""); +} // namespace corr_common // hadrons (global tracks) namespace hadron { DECLARE_SOA_INDEX_COLUMN_FULL(JetTrack, jetTrack, int, JetTracks, ""); +DECLARE_SOA_COLUMN(TruthLevelRecoHadron, truthLevelRecoHadron, int); } // namespace hadron -DECLARE_SOA_TABLE(Hadrons, "AOD", "HADRONS", - o2::soa::Index<>, corr_particle::JetCollisionId, hadron::JetTrackId, - corr_particle::Pt, corr_particle::Phi, corr_particle::Eta); -using Hadron = Hadrons::iterator; +DECLARE_SOA_TABLE(Hadrons, "AOD", "HADRON", + o2::soa::Index<>, corr_common::CorrCollisionId, corr_common::IntersectTriggerIds, + corr_common::Pt, corr_common::Phi, corr_common::Eta, + hadron::TruthLevelRecoHadron, corr_common::PtTrue); +DECLARE_SOA_TABLE(HadronTrackIds, "AOD", "HADRONTRACKID", + hadron::JetTrackId); // pipm namespace pipm { DECLARE_SOA_INDEX_COLUMN_FULL(JetTrack, jetTrack, int, JetTracks, ""); +DECLARE_SOA_COLUMN(TruthLevelRecoPipm, truthLevelRecoPipm, int); } // namespace pipm -DECLARE_SOA_TABLE(Pipms, "AOD", "PIPMS", - o2::soa::Index<>, corr_particle::JetCollisionId, pipm::JetTrackId, - corr_particle::Pt, corr_particle::Phi, corr_particle::Eta); -using Pipm = Pipms::iterator; - -// photonPCM +DECLARE_SOA_TABLE(Pipms, "AOD", "PIPM", + o2::soa::Index<>, corr_common::CorrCollisionId, corr_common::IntersectTriggerIds, + corr_common::Pt, corr_common::Phi, corr_common::Eta, + pipm::TruthLevelRecoPipm, corr_common::PtTrue); +DECLARE_SOA_TABLE(PipmTrackIds, "AOD", "PIPMTRACKID", + pipm::JetTrackId); + +// photonPcm namespace photon_pcm { DECLARE_SOA_INDEX_COLUMN_FULL(V0PhotonKF, v0PhotonKF, int, V0PhotonsKF, ""); DECLARE_SOA_INDEX_COLUMN_FULL(PosJetTrack, posJetTrack, int, JetTracks, "_pos"); DECLARE_SOA_INDEX_COLUMN_FULL(NegJetTrack, negJetTrack, int, JetTracks, "_neg"); +DECLARE_SOA_COLUMN(TruthLevelRecoPhotonPcm, truthLevelRecoPhotonPcm, int); } // namespace photon_pcm -DECLARE_SOA_TABLE(PhotonPCMs, "AOD", "PHOTONPCMS", - o2::soa::Index<>, corr_particle::JetCollisionId, photon_pcm::V0PhotonKFId, - photon_pcm::PosJetTrackId, photon_pcm::NegJetTrackId, - corr_particle::Pt, corr_particle::Phi, corr_particle::Eta); -using PhotonPCM = PhotonPCMs::iterator; - -// photonPCM pairs (pi0) +DECLARE_SOA_TABLE(PhotonPcms, "AOD", "PHOTONPCM", + o2::soa::Index<>, corr_common::CorrCollisionId, corr_common::IntersectTriggerIds, + corr_common::Pt, corr_common::Phi, corr_common::Eta, + photon_pcm::TruthLevelRecoPhotonPcm, corr_common::PtTrue); +DECLARE_SOA_TABLE(PhotonPcmTrackIds, "AOD", "PHOTONPCMTRACKID", + photon_pcm::PosJetTrackId, photon_pcm::NegJetTrackId); +DECLARE_SOA_TABLE(PhotonPcmV0PhotonIds, "AOD", "PHOTONPCMV0PHOTONID", + photon_pcm::V0PhotonKFId); + +// photonPcm pairs namespace photon_pcm_pair { DECLARE_SOA_INDEX_COLUMN_FULL(V0PhotonKF1, v0PhotonKF1, int, V0PhotonsKF, "_1"); @@ -104,12 +181,17 @@ DECLARE_SOA_INDEX_COLUMN_FULL(NegJetTrack1, negJetTrack1, int, JetTracks, "_neg1 DECLARE_SOA_INDEX_COLUMN_FULL(PosJetTrack2, posJetTrack2, int, JetTracks, "_pos2"); DECLARE_SOA_INDEX_COLUMN_FULL(NegJetTrack2, negJetTrack2, int, JetTracks, "_neg2"); DECLARE_SOA_COLUMN(Mgg, mgg, float); +DECLARE_SOA_COLUMN(TruthLevelRecoPi0Pcm, truthLevelRecoPi0Pcm, int); +DECLARE_SOA_COLUMN(TruthLevelRecoEtaPcm, truthLevelRecoEtaPcm, int); } // namespace photon_pcm_pair -DECLARE_SOA_TABLE(PhotonPCMPairs, "AOD", "PHOTONPCMPAIRS", - o2::soa::Index<>, corr_particle::JetCollisionId, photon_pcm_pair::V0PhotonKF1Id, photon_pcm_pair::V0PhotonKF2Id, - photon_pcm_pair::PosJetTrack1Id, photon_pcm_pair::NegJetTrack1Id, photon_pcm_pair::PosJetTrack2Id, photon_pcm_pair::NegJetTrack2Id, - corr_particle::Pt, corr_particle::Phi, corr_particle::Eta, photon_pcm_pair::Mgg); -using PhotonPCMPair = PhotonPCMPairs::iterator; +DECLARE_SOA_TABLE(PhotonPcmPairs, "AOD", "PHOTONPCMPAIR", + o2::soa::Index<>, corr_common::CorrCollisionId, corr_common::IntersectTriggerIds, + corr_common::Pt, corr_common::Phi, corr_common::Eta, photon_pcm_pair::Mgg, + photon_pcm_pair::TruthLevelRecoPi0Pcm, photon_pcm_pair::TruthLevelRecoEtaPcm, corr_common::PtTrue); +DECLARE_SOA_TABLE(PhotonPcmPairTrackIds, "AOD", "PHOTONPCMPAIRTRACKID", + photon_pcm_pair::PosJetTrack1Id, photon_pcm_pair::NegJetTrack1Id, photon_pcm_pair::PosJetTrack2Id, photon_pcm_pair::NegJetTrack2Id); +DECLARE_SOA_TABLE(PhotonPcmPairV0PhotonIds, "AOD", "PHOTONPCMPAIRV0PHOTONID", + photon_pcm_pair::V0PhotonKF1Id, photon_pcm_pair::V0PhotonKF2Id); // mc @@ -121,18 +203,17 @@ DECLARE_SOA_COLUMN(TrigEv, trigEv, bool); DECLARE_SOA_COLUMN(PtMax, ptMax, float); DECLARE_SOA_COLUMN(NChargedInEtaRange, nChargedInEtaRange, int); } // namespace mc_collision_extra_corr -DECLARE_SOA_TABLE(McCollisionsExtraCorr, "AOD", "MCCOLLISIONSEXTRACORR", +DECLARE_SOA_TABLE(McCollisionsExtraCorr, "AOD", "MCCOLLISIONEXTRACORR", mc_collision_extra_corr::ThirdDecimalTruePosZ, mc_collision_extra_corr::TrigEv, mc_collision_extra_corr::PtMax, mc_collision_extra_corr::NChargedInEtaRange); // trigger -namespace trigger_particle +namespace true_trigger { DECLARE_SOA_INDEX_COLUMN_FULL(JetMcParticle, jetMcParticle, int, JetParticles, ""); -} // namespace trigger_particle -DECLARE_SOA_TABLE(TriggerParticles, "AOD", "TRIGGERPARTICLES", - o2::soa::Index<>, corr_particle::JetMcCollisionId, trigger_particle::JetMcParticleId, - corr_particle::Pt, corr_particle::Phi, corr_particle::Eta); -using TriggerParticle = TriggerParticles::iterator; +} // namespace true_trigger +DECLARE_SOA_TABLE(TrueTriggers, "AOD", "TRUETRIGGER", + o2::soa::Index<>, corr_common::JetMcCollisionId, true_trigger::JetMcParticleId, + corr_common::Pt, corr_common::Phi, corr_common::Eta); } // namespace o2::aod #endif // PWGJE_DATAMODEL_HADRONPHOTONCORRELATION_H_ diff --git a/PWGJE/Tasks/CMakeLists.txt b/PWGJE/Tasks/CMakeLists.txt index dee5133267e..68eabc58ee1 100644 --- a/PWGJE/Tasks/CMakeLists.txt +++ b/PWGJE/Tasks/CMakeLists.txt @@ -99,7 +99,7 @@ o2physics_add_dpl_workflow(photon-isolation-qa o2physics_add_dpl_workflow(hadron-photon-correlation SOURCES hadronPhotonCorrelation.cxx REUSE_FROM JetDataModelPCH - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(task-emc-extensive-mc-qa SOURCES taskEmcExtensiveMcQa.cxx diff --git a/PWGJE/Tasks/hadronPhotonCorrelation.cxx b/PWGJE/Tasks/hadronPhotonCorrelation.cxx index 728cf0abfdc..432722b5a84 100644 --- a/PWGJE/Tasks/hadronPhotonCorrelation.cxx +++ b/PWGJE/Tasks/hadronPhotonCorrelation.cxx @@ -11,10 +11,10 @@ /// \file hadronPhotonCorrelation.cxx /// \author Julius Kinner -/// \brief photon-jet angular correlation analysis +/// \brief hadron-photon angular correlation analysis /// /// Analysis for angular correlations between jets and photons via two-particle correlations with charged high-pt triggers -/// Associated hadrons (tracks), pipm, photons (PCM), pi0 (PCM) +/// Associated hadrons (tracks), pipm, photons (pcm), pi0 (pcm) /// Also contains checks and monte-carlo (efficiency, purity, mc-true correlation,...) /// End goal of studying correlations between direct photons and jets @@ -23,6 +23,7 @@ #include "PWGJE/DataModel/Jet.h" #include "PWGJE/DataModel/JetReducedData.h" // +#include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" #include "Common/Core/RecoDecay.h" @@ -60,25 +61,28 @@ #include #include #include +#include #include #include #include #include +#include #include +#include #include #include using namespace o2; using namespace o2::framework; -using CorrCollisions = soa::Join; -using CorrCollision = CorrCollisions::iterator; -using CorrMcDCollisions = soa::Join; -using CorrMcDCollision = CorrMcDCollisions::iterator; +using CorrCollisions = aod::CorrCollisions; +using CorrCollisionsMcD = soa::Join; using CorrMcCollisions = soa::Join; -using CorrMcCollision = CorrMcCollisions::iterator; -using BinningZPvMult = ColumnBinningPolicy; +using PhotonPcmsWithV0 = soa::Join; +using PhotonPcmPairsWithV0 = soa::Join; + +using BinningZPvMult = ColumnBinningPolicy; // correlation analysis /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // =/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/ @@ -92,97 +96,184 @@ struct HadronPhotonCorrelation { Configurable pathCcdbCorrection{"pathCcdbCorrection", "Users/j/jkinner/correction/set_in_config", "base path to the ccdb corrections"}; Configurable urlCcdb{"urlCcdb", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable noLaterThanCcdbConfig{"noLaterThanCcdbConfig", -1, "latest acceptable timestamp of creation for the object (-1 for task start time)"}; - Configurable splitMcEvN{"splitMcEvN", 1, "number of equal event fractions for selection in MC (max 10) | (select 1 for data)"}; + + // shared across analysis tasks + Configurable absEtaMax{"absEtaMax", 0.8, "maximum absEta cut"}; + Configurable ptTrigMin{"ptTrigMin", 5, "minimum pT of triggers"}; + + // analysis settings + Configurable splitMcEvN{"splitMcEvN", 1, "number of event fractions for selection in MC (max 10) | (select 1 for data)"}; Configurable splitMcEvSelect{"splitMcEvSelect", 1, "selected event fraction number in MC (starts at 1) | (select 1 for data)"}; - // analysis Configurable applyCTotTrigger{"applyCTotTrigger", false, "whether to apply on-the-fly total correction factor for triggers"}; Configurable doTrigEvMixing{"doTrigEvMixing", false, "whether to use trigger events for trigger mixing"}; Configurable nTriggerSavedForMixing{"nTriggerSavedForMixing", 8192, "number of triggers that are saved for mixing with other events"}; - Configurable nTriggerBinMinThreshold{"nTriggerBinMinThreshold", 128, "threshold minimum number of triggers in mixing bin required"}; + Configurable nTriggerBinMinThreshold{"nTriggerBinMinThreshold", 4, "threshold minimum number of triggers in mixing bin required"}; Configurable iTriggerStartFraction{"iTriggerStartFraction", 0.5, "ratio of bin size for randomised iTrigger start"}; - Configurable nTriggerScaleCoefficient{"nTriggerScaleCoefficient", 2, "coeffcient a in mixing-number pt power scaling"}; + Configurable nTriggerScaleCoefficient{"nTriggerScaleCoefficient", 1, "coeffcient a in mixing-number pt power scaling"}; Configurable nTriggerScaleExponent{"nTriggerScaleExponent", 2, "exponent a in mixing-number pt power scaling"}; - Configurable nMixingAt0McTrue{"nMixingAt0McTrue", 4, "number of triggers that are used for mc true mixing"}; + Configurable nMixingAt0McTrue{"nMixingAt0McTrue", 1, "number of triggers that are used for mc true mixing"}; Configurable nMixingAt0Hadron{"nMixingAt0Hadron", 16, "number of triggers that are used for hadron mixing"}; Configurable nMixingAt0Pipm{"nMixingAt0Pipm", 16, "number of triggers that are used for pipm mixing"}; - Configurable nMixingAt0PhotonPCM{"nMixingAt0PhotonPCM", 256, "number of triggers that are saved for photonPCM mixing"}; - Configurable nMixingAt0H0PCM{"nMixingAt0H0PCM", 1024, "number of triggers that are saved for h0PCM (pi0, eta) mixing"}; - - Configurable nNeighboursMixingPhotonPCMPair{"nNeighboursMixingPhotonPCMPair", 32, "number neighbours used for for photonPCM pair mixing"}; - Configurable> pi0PCMPeakMassRange{"pi0PCMPeakMassRange", {0.10, 0.15}, "photon-pair mass integration range for pi0PCM"}; - Configurable> pi0PCMSideMassRange{"pi0PCMSideMassRange", {0.16, 0.22}, "photon-pair mass integration range outside pi0PCM region"}; - Configurable> etaPCMPeakMassRange{"etaPCMPeakMassRange", {0.51, 0.56}, "photon-pair mass integration range for etaPCM"}; - Configurable> etaPCMLowSideMassRange{"etaPCMLowSideMassRange", {0.44, 0.48}, "photon-pair mass integration range below etaPCM region"}; - Configurable> etaPCMHighSideMassRange{"etaPCMHighSideMassRange", {0.58, 0.62}, "photon-pair mass integration range above etaPCM region"}; - - // for histograms - Configurable nBinsZPv{"nBinsZPv", 28, "number zPv bins in histos"}; - Configurable nBinsMult{"nBinsMult", 64, "number multiplicity bins in histos"}; - Configurable nBinsOccupancy{"nBinsOccupancy", 2000, "number occupancy bins in histos for QA"}; - - Configurable nBinsPhi{"nBinsPhi", 72, "number phi bins"}; - Configurable nBinsEta{"nBinsEta", 32, "number eta bins"}; - Configurable nBinsDCAz{"nBinsDCAz", 100, "number DCAz bins"}; - Configurable nBinsMgg{"nBinsMgg", 240, "number mass-photon-pair bins"}; - - Configurable> binsPtTrig{"binsPtTrig", {0, 5, 10, 25, 50, 100}, "correlation ptTrig bins"}; - Configurable> binsPtAssoc{"binsPtAssoc", - {0, 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, 25, 35, 50, 100}, - "correlation ptAssoc bins"}; - Configurable> binsDPhi{"binsDPhi", - {0.00 * constants::math::TwoPI - constants::math::PIHalf, - 0.05 * constants::math::TwoPI - constants::math::PIHalf, 0.10 * constants::math::TwoPI - constants::math::PIHalf, - 0.14 * constants::math::TwoPI - constants::math::PIHalf, 0.17 * constants::math::TwoPI - constants::math::PIHalf, - 0.20 * constants::math::TwoPI - constants::math::PIHalf, - 0.22 * constants::math::TwoPI - constants::math::PIHalf, 0.24 * constants::math::TwoPI - constants::math::PIHalf, - 0.26 * constants::math::TwoPI - constants::math::PIHalf, 0.28 * constants::math::TwoPI - constants::math::PIHalf, - 0.30 * constants::math::TwoPI - constants::math::PIHalf, - 0.33 * constants::math::TwoPI - constants::math::PIHalf, 0.36 * constants::math::TwoPI - constants::math::PIHalf, - 0.40 * constants::math::TwoPI - constants::math::PIHalf, 0.45 * constants::math::TwoPI - constants::math::PIHalf, - 0.50 * constants::math::TwoPI - constants::math::PIHalf, - 0.55 * constants::math::TwoPI - constants::math::PIHalf, 0.60 * constants::math::TwoPI - constants::math::PIHalf, - 0.64 * constants::math::TwoPI - constants::math::PIHalf, 0.68 * constants::math::TwoPI - constants::math::PIHalf, - 0.71 * constants::math::TwoPI - constants::math::PIHalf, - 0.74 * constants::math::TwoPI - constants::math::PIHalf, 0.76 * constants::math::TwoPI - constants::math::PIHalf, - 0.79 * constants::math::TwoPI - constants::math::PIHalf, - 0.82 * constants::math::TwoPI - constants::math::PIHalf, 0.86 * constants::math::TwoPI - constants::math::PIHalf, - 0.90 * constants::math::TwoPI - constants::math::PIHalf, 0.95 * constants::math::TwoPI - constants::math::PIHalf, - 1.00 * constants::math::TwoPI - constants::math::PIHalf}, - "correlation bins DeltaPhi"}; - Configurable> binsDEta{"binsDEta", - {0 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, - 2 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, 4 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, - 6 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, 8 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, - 9.5 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, 11 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, - 12.5 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, 14 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, - 15.5 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, 16.5 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, - 18 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, - 19.5 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, 21 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, - 22.5 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, 24 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, - 26 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, 28 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, - 30 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault, 32 / 32. * 4 * absEtaMaxDefault - 2 * absEtaMaxDefault}, - "correlation bins DeltaEta"}; - Configurable> binsZPvBinning{"binsZPvBinning", - {-7, -5, -3, -1, 1, 3, 5, 7}, - "zPv mixing bins"}; - Configurable> binsMultBinning{"binsMultBinning", - {-0.5, 10.5, 15.5, 20.5, 27.5, 42.5}, - "multiplicity mixing bins"}; - Configurable> binsZPvBinningMcTrue{"binsZPvBinningMcTrue", - {-10000, 10000}, - "zPv mixing bins for mc true"}; - Configurable> binsMultBinningMcTrue{"binsMultBinningMcTrue", - {-0.5, 16.5, 24.5, 31.5, 39.5, 64.5}, - "multiplicity mixing bins for mc true"}; - - // configurables from other tasks - - double absEtaMax = -1; - - // further variables + Configurable nMixingAt0PhotonPcm{"nMixingAt0PhotonPcm", 256, "number of triggers that are saved for photonPcm mixing"}; + Configurable nMixingAt0PhotonPcmPair{"nMixingAt0PhotonPcmPair", 1024, "number of triggers that are saved for photonPcmPair (pi0, eta) mixing"}; + + Configurable nNeighboursMixingPhotonPcmPair{"nNeighboursMixingPhotonPcmPair", 32, "number neighbours used for for photonPcm pair mixing"}; + + Configurable> pi0PcmPeakMassRange{"pi0PcmPeakMassRange", {0.10, 0.15}, "photon-pair mass integration range for pi0Pcm"}; + Configurable> pi0PcmSideMassRange{"pi0PcmSideMassRange", {0.16, 0.22}, "photon-pair mass integration range outside pi0Pcm region"}; + Configurable> etaPcmPeakMassRange{"etaPcmPeakMassRange", {0.51, 0.56}, "photon-pair mass integration range for etaPcm"}; + Configurable> etaPcmLowSideMassRange{"etaPcmLowSideMassRange", {0.44, 0.48}, "photon-pair mass integration range below etaPcm region"}; + Configurable> etaPcmHighSideMassRange{"etaPcmHighSideMassRange", {0.58, 0.62}, "photon-pair mass integration range above etaPcm region"}; + + Configurable energyAsymmPhotonPairMax{"energyAsymmPhotonPairMax", 1.0, "maximum energy asymmetry ((E1 - E2) / (E1 + E2)) of photon pairs"}; + + // pcm cuts + struct : o2::framework::ConfigurableGroup { + std::string prefix = "pcmcut_group"; + o2::framework::Configurable cfg_require_v0_with_itstpc{"cfg_require_v0_with_itstpc", false, "flag to select V0s with ITS-TPC matched tracks"}; + o2::framework::Configurable cfg_require_v0_with_itsonly{"cfg_require_v0_with_itsonly", false, "flag to select V0s with ITSonly tracks"}; + o2::framework::Configurable cfg_require_v0_with_tpconly{"cfg_require_v0_with_tpconly", false, "flag to select V0s with TPConly tracks"}; + o2::framework::Configurable cfg_min_pt_v0{"cfg_min_pt_v0", 0.1, "min pT for v0 photons at PV"}; + o2::framework::Configurable cfg_max_pt_v0{"cfg_max_pt_v0", 1e+10, "max pT for v0 photons at PV"}; + o2::framework::Configurable cfg_min_eta_v0{"cfg_min_eta_v0", -0.8, "min eta for v0 photons at PV"}; + o2::framework::Configurable cfg_max_eta_v0{"cfg_max_eta_v0", 0.8, "max eta for v0 photons at PV"}; + o2::framework::Configurable cfg_min_v0radius{"cfg_min_v0radius", 4.0, "min v0 radius"}; + o2::framework::Configurable cfg_max_v0radius{"cfg_max_v0radius", 90.0, "max v0 radius"}; + o2::framework::Configurable cfg_midL_v0radius{"cfg_midL_v0radius", -1.0, "middle low v0 radius for rejection if >0"}; + o2::framework::Configurable cfg_midH_v0radius{"cfg_midH_v0radius", -1.0, "middle high v0 radius for rejection if >0"}; + o2::framework::Configurable cfg_max_alpha_ap{"cfg_max_alpha_ap", 0.95, "max alpha for AP cut"}; + o2::framework::Configurable cfg_max_qt_ap{"cfg_max_qt_ap", 0.01, "max qT for AP cut"}; + o2::framework::Configurable cfg_min_cospa{"cfg_min_cospa", 0.999, "min V0 CosPA"}; + o2::framework::Configurable cfg_max_pca{"cfg_max_pca", 1.5, "max distance btween 2 legs"}; + o2::framework::Configurable cfg_max_chi2kf{"cfg_max_chi2kf", 1e+10, "max chi2/ndf with KF"}; + o2::framework::Configurable cfg_reject_v0_on_itsib{"cfg_reject_v0_on_itsib", true, "flag to reject V0s on ITSib"}; + o2::framework::Configurable cfg_apply_cuts_from_prefilter_derived{"cfg_apply_cuts_from_prefilter_derived", false, "flag to apply prefilter to V0"}; + + o2::framework::Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; + o2::framework::Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 40, "min ncrossed rows"}; + o2::framework::Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; + o2::framework::Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; + o2::framework::Configurable cfg_max_chi2its{"cfg_max_chi2its", 36.0, "max chi2/NclsITS"}; + o2::framework::Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -3.0, "min. TPC n sigma for electron"}; + o2::framework::Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron"}; + o2::framework::Configurable cfg_disable_itsonly_track{"cfg_disable_itsonly_track", false, "flag to disable ITSonly tracks"}; + o2::framework::Configurable cfg_disable_tpconly_track{"cfg_disable_tpconly_track", false, "flag to disable TPConly tracks"}; + } configPcmCuts; + + // histogram config + struct : ConfigurableGroup { + Configurable nBinsZPvPlain{"nBinsZPvPlain", 28, "number zPv bins in histos"}; + Configurable nBinsMultPlain{"nBinsMultPlain", 64, "number multiplicity bins in histos"}; + + Configurable nBinsPhi{"nBinsPhi", 72, "number phi bins"}; + Configurable nBinsEta{"nBinsEta", 32, "number eta bins"}; + Configurable nBinsDcaZ{"nBinsDcaZ", 100, "number dcaZ bins"}; + Configurable nBinsMgg{"nBinsMgg", 240, "number mass-photon-pair bins"}; + + Configurable> binsPtTrig{"binsPtTrig", {5, 10, 25, 100}, "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, 25, 35, 50, 100}, + "correlation ptAssoc bins"}; + Configurable> binsDPhi{"binsDPhi", + {(0.00 - 1. / 4) * constants::math::TwoPI, + (0.05 - 1. / 4) * constants::math::TwoPI, (0.10 - 1. / 4) * constants::math::TwoPI, + (0.14 - 1. / 4) * constants::math::TwoPI, (0.17 - 1. / 4) * constants::math::TwoPI, + (0.20 - 1. / 4) * constants::math::TwoPI, + (0.22 - 1. / 4) * constants::math::TwoPI, (0.24 - 1. / 4) * constants::math::TwoPI, + (0.26 - 1. / 4) * constants::math::TwoPI, (0.28 - 1. / 4) * constants::math::TwoPI, + (0.30 - 1. / 4) * constants::math::TwoPI, + (0.33 - 1. / 4) * constants::math::TwoPI, (0.36 - 1. / 4) * constants::math::TwoPI, + (0.40 - 1. / 4) * constants::math::TwoPI, (0.45 - 1. / 4) * constants::math::TwoPI, + (0.50 - 1. / 4) * constants::math::TwoPI, + (0.55 - 1. / 4) * constants::math::TwoPI, (0.60 - 1. / 4) * constants::math::TwoPI, + (0.64 - 1. / 4) * constants::math::TwoPI, (0.68 - 1. / 4) * constants::math::TwoPI, + (0.71 - 1. / 4) * constants::math::TwoPI, + (0.74 - 1. / 4) * constants::math::TwoPI, (0.76 - 1. / 4) * constants::math::TwoPI, + (0.79 - 1. / 4) * constants::math::TwoPI, + (0.82 - 1. / 4) * constants::math::TwoPI, (0.86 - 1. / 4) * constants::math::TwoPI, + (0.90 - 1. / 4) * constants::math::TwoPI, (0.95 - 1. / 4) * constants::math::TwoPI, + (1.00 - 1. / 4) * constants::math::TwoPI}, + "correlation bins DeltaPhi"}; + Configurable> binsDEta{"binsDEta", + {(0 / 32. * 4 - 2) * absEtaMaxDefault, + (2 / 32. * 4 - 2) * absEtaMaxDefault, (4 / 32. * 4 - 2) * absEtaMaxDefault, + (6 / 32. * 4 - 2) * absEtaMaxDefault, (8 / 32. * 4 - 2) * absEtaMaxDefault, + (9.5 / 32. * 4 - 2) * absEtaMaxDefault, (11 / 32. * 4 - 2) * absEtaMaxDefault, + (12.5 / 32. * 4 - 2) * absEtaMaxDefault, (14 / 32. * 4 - 2) * absEtaMaxDefault, + (15.5 / 32. * 4 - 2) * absEtaMaxDefault, (16.5 / 32. * 4 - 2) * absEtaMaxDefault, + (18 / 32. * 4 - 2) * absEtaMaxDefault, + (19.5 / 32. * 4 - 2) * absEtaMaxDefault, (21 / 32. * 4 - 2) * absEtaMaxDefault, + (22.5 / 32. * 4 - 2) * absEtaMaxDefault, (24 / 32. * 4 - 2) * absEtaMaxDefault, + (26 / 32. * 4 - 2) * absEtaMaxDefault, (28 / 32. * 4 - 2) * absEtaMaxDefault, + (30 / 32. * 4 - 2) * absEtaMaxDefault, (32 / 32. * 4 - 2) * absEtaMaxDefault}, + "correlation bins DeltaEta"}; + Configurable> binsZPvBinning{"binsZPvBinning", + {-7, -5, -3, -1, 1, 3, 5, 7}, + "zPv mixing bins"}; + Configurable> binsMultBinning{"binsMultBinning", + {-0.5, 10.5, 15.5, 20.5, 27.5, 42.5}, + "multiplicity mixing bins"}; + Configurable> binsZPvBinningMcTrue{"binsZPvBinningMcTrue", + {-10000, 10000}, + "zPv mixing bins for mc true"}; + Configurable> binsMultBinningMcTrue{"binsMultBinningMcTrue", + {-0.5, 16.5, 24.5, 31.5, 39.5, 64.5}, + "multiplicity mixing bins for mc true"}; + } configHist; + + // further variables ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + + enum class HistFillMode { + PlainPt, + PlainPhiEta, + PlainZPvMult, + Plain, + Correlation, + Mixing + }; + + enum class PhotonImpurity { + WrongEv, + Misid, + K0Short, + K0Long, + Lambda0, + Other + }; + static constexpr double binValuePi0Impurities(PhotonImpurity const impurity) + { + return static_cast(impurity) + 0.5; + } + + enum class TriggerMemoryMode { + Reco, + True, + TrueAssocEv, + TrueAssocEvRecoPtTrig + }; + + struct HistPathEntry { + HistFillMode fillMode; + TruthLevel truthLevel; + AssocType assocType; + char const* path; + }; + + struct HistFillInfoPlainPt { + double ptMax, ptAssoc; + double weight = 1; + }; + struct HistFillInfoPlainPhiEtaZPvMult { + double ptMax, ptAssoc, phi, eta, zPv, mult; + double weight = 1; + }; + struct HistFillInfoCorr { + double dPhi, dEta, ptTrig, ptAssoc, zPv, mult; + double weight = 1; + }; std::mt19937 randomMt{3141u}; int randomIntInInterval(int const lowEdgeInclusive, int const upEdgeInclusive) @@ -195,8 +286,6 @@ struct HadronPhotonCorrelation { HistogramRegistry histos{"histogramRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; // ccdb calls - int64_t noLaterThanCcdb = - noLaterThanCcdbConfig == -1 ? std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count() : noLaterThanCcdbConfig; Service ccdb{}; // for mc Service pdg{}; @@ -206,23 +295,13 @@ struct HadronPhotonCorrelation { // prepare for per collision slicing Preslice perColTracks = aod::jtrack::collisionId; - Preslice perColTriggers = aod::corr_particle::jetCollisionId; - Preslice perColHadrons = aod::corr_particle::jetCollisionId; - Preslice perColPipms = aod::corr_particle::jetCollisionId; - Preslice perColPhotonPCMs = aod::corr_particle::jetCollisionId; - Preslice perColPhotonPCMPairs = aod::corr_particle::jetCollisionId; + Preslice perColTriggers = aod::corr_common::corrCollisionId; + Preslice perColHadrons = aod::corr_common::corrCollisionId; + Preslice perColPipms = aod::corr_common::corrCollisionId; + Preslice perColPhotonPcms = aod::corr_common::corrCollisionId; + Preslice perColPhotonPcmPairs = aod::corr_common::corrCollisionId; Preslice perColMcParticles = aod::jmcparticle::mcCollisionId; - Preslice perColTriggerParticles = aod::corr_particle::jetMcCollisionId; - - // 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 const)> prependValueToVector = - [](std::vector const& vec, double const value) { - std::vector resultVec = {value}; - resultVec.insert(resultVec.end(), vec.begin(), vec.end()); - return resultVec; - }; - BinningZPvMult binningZPvMult{{prependValueToVector(binsZPvBinning.value, VARIABLE_WIDTH), prependValueToVector(binsMultBinning.value, VARIABLE_WIDTH)}}; + Preslice perColTrueTriggers = aod::corr_common::jetMcCollisionId; // declare analysis variables @@ -239,7 +318,7 @@ struct HadronPhotonCorrelation { [[nodiscard]] float eta() const { return fEta; } }; // class to handle trigger info from previous collisions (beyond single dataframe) - // organised as zPv- and mult-bin matrix of deque (pt, phi, eta) to save trigger info beyond single dataframe + // organised as zPv- and mult-bin matrix of deque (pt, phi, eta) to save triggers in buffer // last mult bin open to account for overflow and adjusted zVtx limits to account for rounding errors -> all events accounted for // (possibly replace by some advanced derived data method and O2 event mixing in future?) class MixingTriggerMemory @@ -355,25 +434,30 @@ struct HadronPhotonCorrelation { }; // different buffers for mixing modes - enum class TriggerMemoryMode { Reco, - True, - TrueAssocEv, - TrueAssocEvRecoPtTrig }; - std::unique_ptr triggerMemoryReco; std::unique_ptr triggerMemoryTrue; std::unique_ptr triggerMemoryTrueAssocEv; std::unique_ptr triggerMemoryTrueAssocEvRecoPtTrig; + // pcm cut class + V0PhotonCut fV0PhotonCut; + // functions //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ========================================================================================================================================================================================== // general (kenobi) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + static std::vector prependVariableWidth(std::vector const& vec) + { + std::vector result{VARIABLE_WIDTH}; + result.insert(result.end(), vec.begin(), vec.end()); + return result; + } + // get histograms from ccdb // save corrections from ccdb in histogram registry - void initCcdbHistograms() + void initCcdbHistograms(int64_t const noLaterThanCcdb) { // trigger h1PtCorrectionTrigger = nullptr; @@ -397,204 +481,175 @@ struct HadronPhotonCorrelation { const AxisSpec axisN{1, 0., 1., "#it{N}_{something}"}; const AxisSpec axisCategories{16, 0., 16., "categories"}; - const AxisSpec axisZPv{nBinsZPv, -7, 7, "#it{z}_{pv}"}; - const AxisSpec axisMult{nBinsMult + 1, -0.5, nBinsMult + 0.5, "multiplicity"}; - const AxisSpec axisOccupancy{nBinsOccupancy + 1, -0.5, nBinsOccupancy + 0.5, "occupancy"}; - - const AxisSpec axisPhi{nBinsPhi, 0, constants::math::TwoPI, "#it{#varphi}"}; - const AxisSpec axisEta{nBinsEta, -absEtaMax, absEtaMax, "#it{#eta}"}; - const AxisSpec axisDCAz{nBinsDCAz, -5, 5, "DCA_{z}"}; - const AxisSpec axisMgg{nBinsMgg, 0, 0.8, "#it{m}_{#gamma#gamma}"}; - - const AxisSpec axisPtTrig{binsPtTrig, "#it{p}_{T}^{trig}"}; - const AxisSpec axisPtAssoc{binsPtAssoc, "#it{p}_{T}^{assoc}"}; - const AxisSpec axisDPhi{binsDPhi, "#Delta#it{#varphi}"}; - const AxisSpec axisDEta{binsDEta, "#Delta#it{#eta}"}; - const AxisSpec axisZPvBinning{binsZPvBinning, "#it{z}_{pv} correlation binning"}; - const AxisSpec axisMultBinning{binsMultBinning, "multiplicity correlation binning"}; - const AxisSpec axisZPvBinningMcTrue{binsZPvBinningMcTrue, "#it{z}_{pv} correlation binning for mc true"}; - const AxisSpec axisMultBinningMcTrue{binsMultBinningMcTrue, "multiplicity correlation binning for mc true"}; + const AxisSpec axisZPv{configHist.nBinsZPvPlain, -7, 7, "#it{z}_{pv}"}; + const AxisSpec axisMult{configHist.nBinsMultPlain + 1, -0.5, configHist.nBinsMultPlain + 0.5, "multiplicity"}; + + const AxisSpec axisPhi{configHist.nBinsPhi, 0, constants::math::TwoPI, "#it{#varphi}"}; + const AxisSpec axisEta{configHist.nBinsEta, -absEtaMax, absEtaMax, "#it{#eta}"}; + const AxisSpec axisDcaZ{configHist.nBinsDcaZ, -5, 5, "DCA_{z}"}; + const AxisSpec axisMgg{configHist.nBinsMgg, 0, 0.8, "#it{m}_{#gamma#gamma}"}; + + const AxisSpec axisPtTrig{configHist.binsPtTrig, "#it{p}_{T}^{trig}"}; + const AxisSpec axisPtAssoc{configHist.binsPtAssoc, "#it{p}_{T}^{assoc}"}; + const AxisSpec axisDPhi{configHist.binsDPhi, "#Delta#it{#varphi}"}; + const AxisSpec axisDEta{configHist.binsDEta, "#Delta#it{#eta}"}; + const AxisSpec axisZPvBinning{configHist.binsZPvBinning, "#it{z}_{pv} correlation binning"}; + const AxisSpec axisMultBinning{configHist.binsMultBinning, "multiplicity correlation binning"}; + const AxisSpec axisZPvBinningMcTrue{configHist.binsZPvBinningMcTrue, "#it{z}_{pv} correlation binning for mc true"}; + const AxisSpec axisMultBinningMcTrue{configHist.binsMultBinningMcTrue, "multiplicity correlation binning for mc true"}; + + // main info for assocType (spectra and correlation) + auto const addMainAssocHists = + [&](std::string const& recoOrMc, std::string const& nameTruthLevel, std::string const& nameAssoc, bool const resolvedInfo) { + if (resolvedInfo) { + histos.add(std::format("{}/plain/h4_ptTrigPtAssocPhiEta_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h4_ptTrigPtAssocPhiEta_{}_{}", nameTruthLevel, nameAssoc).data(), + kTHnSparseD, {axisPtTrig, axisPtAssoc, axisPhi, axisEta}, true); + histos.add(std::format("{}/plain/h4_ptTrigPtAssocZPvMult_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h4_ptTrigPtAssocZPvMult_{}_{}", nameTruthLevel, nameAssoc).data(), + kTHnSparseD, {axisPtTrig, axisPtAssoc, axisZPv, axisMult}, true); + } else { + histos.add(std::format("{}/plain/h2_ptTrigPtAssoc_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h2_ptTrigPtAssoc_{}_{}", nameTruthLevel, nameAssoc).data(), + kTHnSparseD, {axisPtTrig, axisPtAssoc}, true); + } + histos.add(std::format("{}/corr/h6_corr_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h6_corr_{}_{}", nameTruthLevel, nameAssoc).data(), + kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); + histos.add(std::format("{}/corr/h6_mix_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h6_mix_{}_{}", nameTruthLevel, nameAssoc).data(), + kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); + }; // reco info histos.add("reco/info/h1_nEvents", "h1_nEvents", kTH1D, {axisCategories}, true); - histos.add("reco/info/h3_ptTrigZPvMult", "h3_ptTrigZPvMult", kTHnSparseD, {axisPtTrig, axisZPv, axisMult}, true); - histos.add("reco/info/h2_ptTrigOccupancy", "h2_ptTrigOccupancy", kTHnSparseD, {axisPtTrig, axisOccupancy}, true); + histos.add("reco/info/h3_nEv_ptTrigZPvMult_reco", "h3_nEv_ptTrigZPvMult_reco", kTHnSparseD, {axisPtTrig, axisZPv, axisMult}, true); // reco (correlation) analysis histos.add("reco/corr/h3_ptPhiEta_trig", "h3_ptPhiEta_trig", kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); + for (std::string const& nameAssoc : std::initializer_list{"hadron", "pipm", "photonPcm"}) { + addMainAssocHists("reco", "reco", nameAssoc, true); + } + for (std::string const& nameAssoc : std::initializer_list{"pi0PcmPeak", "pi0PcmSide", "etaPcmPeak", "etaPcmSide"}) { + addMainAssocHists("reco", "reco", nameAssoc, false); + } - auto const add_corrHists = - [&](std::string const& name_id) { - histos.add(std::format("reco/corr/h4_ptTrigPtAssocPhiEta_assoc_{}", name_id).data(), std::format("h4_ptTrigPtAssocPhiEta_assoc_{}", name_id).data(), - kTHnSparseD, {axisPtTrig, axisPtAssoc, axisPhi, axisEta}, true); - histos.add(std::format("reco/corr/h6_corr_{}", name_id).data(), std::format("h6_corr_{}", name_id).data(), - kTHnSparseF, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); - histos.add(std::format("reco/corr/h6_mix_{}", name_id).data(), std::format("h6_mix_{}", name_id).data(), - kTHnSparseF, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); - }; - // hadron - histos.add("reco/plain/h3_ptPhiEta_hadron", "h3_ptPhiEta_hadron", kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); - add_corrHists("hadron"); - // pipm - histos.add("reco/plain/h3_ptPhiEta_pipm", "h3_ptPhiEta_pipm", kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); - add_corrHists("pipm"); - // photonPCM - histos.add("reco/plain/h3_ptPhiEta_photonPCM", "h3_ptPhiEta_photonPCM", kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); - add_corrHists("photonPCM"); - // photonPCM pairs - histos.add("reco/plain/h5_ptTrigPtAssocMggZPvMult_photonPCMPair", "h5_ptTrigPtAssocMggZPvMult_photonPCMPair", + // photonPcm pairs + // mgg + histos.add("reco/plain/h5_ptTrigPtAssocMggZPvMult_reco_photonPcmPair", "h5_ptTrigPtAssocMggZPvMult_reco_photonPcmPair", kTHnSparseD, {axisPtTrig, axisPtAssoc, axisMgg, axisZPvBinning, axisMultBinning}, true); - histos.add("reco/corr/h5_ptTrigPtAssocMggZPvMult_assoc_photonPCMPair", "h5_ptTrigPtAssocMggZPvMult_assoc_photonPCMPair", + histos.add("reco/corr/h5_ptTrigPtAssocMggZPvMult_reco_photonPcmPair", "h5_ptTrigPtAssocMggZPvMult_reco_photonPcmPair", kTHnSparseD, {axisPtTrig, axisPtAssoc, axisMgg, axisZPvBinning, axisMultBinning}, true); - // pi0PCM - add_corrHists("pi0PCMPeak"); - add_corrHists("pi0PCMSide"); - // etaPCM - add_corrHists("etaPCMPeak"); - add_corrHists("etaPCMSide"); - // event mixing for photon pairs - histos.add("reco/plain/h2_zPvMult_photonPCMPair_evMix", "h2_zPvMult_photonPCMPair_evMix", kTHnSparseD, {axisZPv, axisMult}, true); - histos.add("reco/plain/h4_ptMggZPvMult_photonPCMPair_evMix", "h4_ptMggZPvMult_photonPCMPair_evMix", kTHnSparseD, {axisPtAssoc, axisMgg, axisZPvBinning, axisMultBinning}, true); + histos.add("reco/plain/h4_ptMggZPvMult_photonPcmPair_evMix", "h4_ptMggZPvMult_photonPcmPair_evMix", kTHnSparseD, {axisPtAssoc, axisMgg, axisZPvBinning, axisMultBinning}, true); + // pseudo mgg + // pi0Pcm + histos.add("mc/plain/h5_ptTrigPtAssocMggZPvMult_pseudoReco_pi0Pcm", "h5_ptTrigPtAssocMggZPvMult_pseudoReco_pi0Pcm", + kTHnSparseD, {axisPtTrig, axisPtAssoc, axisMgg, axisZPvBinning, axisMultBinning}, true); + histos.add("mc/corr/h5_ptTrigPtAssocMggZPvMult_pseudoReco_pi0Pcm", "h5_ptTrigPtAssocMggZPvMult_pseudoReco_pi0Pcm", + kTHnSparseD, {axisPtTrig, axisPtAssoc, axisMgg, axisZPvBinning, axisMultBinning}, true); + histos.add("mc/plain/h5_ptTrigPtAssocMggZPvMult_pseudoReco_etaPcm", "h5_ptTrigPtAssocMggZPvMult_pseudoReco_etaPcm", + kTHnSparseD, {axisPtTrig, axisPtAssoc, axisMgg, axisZPvBinning, axisMultBinning}, true); + histos.add("mc/corr/h5_ptTrigPtAssocMggZPvMult_pseudoReco_etaPcm", "h5_ptTrigPtAssocMggZPvMult_pseudoReco_etaPcm", + kTHnSparseD, {axisPtTrig, axisPtAssoc, axisMgg, axisZPvBinning, axisMultBinning}, true); // mc info - histos.add("mc/info/h3_ptTrigZPvMult_true", "h3_ptTrigZPvMult_true", kTHnSparseD, {axisPtTrig, axisZPv, axisMult}, true); - histos.add("mc/info/h3_ptTrigZPvMult_trueAssocEv", "h3_ptTrigZPvMult_trueAssocEv", kTHnSparseD, {axisPtTrig, axisZPv, axisMult}, true); - histos.add("mc/info/h3_ptTrigZPvMult_trueAssocEvRecoPtTrig", "h3_ptTrigZPvMult_trueAssocEvRecoPtTrig", kTHnSparseD, {axisPtTrig, axisZPv, axisMult}, true); - - // reco and true collision correlations - const std::vector assocMcCorrNamesMcAll = {"hadron", "pipm", "photon", "pi0", "eta"}; - for (auto const& correlationType : {"true", "trueAssocEv", "trueAssocEvRecoPtTrig"}) { - histos.add(std::format("mc/corr/h3_ptPhiEta_trig_{}", correlationType).data(), std::format("h3_ptPhiEta_trig_{}", correlationType).data(), + histos.add("mc/info/h3_nEv_ptTrigZPvMult_true", "h3_nEv_ptTrigZPvMult_true", kTHnSparseD, {axisPtTrig, axisZPv, axisMult}, true); + histos.add("mc/info/h3_nEv_ptTrigZPvMult_trueAssocEv", "h3_nEv_ptTrigZPvMult_trueAssocEv", kTHnSparseD, {axisPtTrig, axisZPv, axisMult}, true); + histos.add("mc/info/h3_nEv_ptTrigZPvMult_trueAssocEvRecoPtTrig", "h3_nEv_ptTrigZPvMult_trueAssocEvRecoPtTrig", kTHnSparseD, {axisPtTrig, axisZPv, axisMult}, true); + + // true++ (event selection) + for (std::string const& nameTruthLevel : std::initializer_list{"true", "trueAssocEv", "trueAssocEvRecoPtTrig"}) { + histos.add(std::format("mc/corr/h3_ptPhiEta_trig_{}", nameTruthLevel).data(), std::format("h3_ptPhiEta_trig_{}", nameTruthLevel).data(), kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); - for (auto const& assocName : assocMcCorrNamesMcAll) { - histos.add(std::format("mc/corr/h6_corr_{}_{}", correlationType, assocName).data(), std::format("h6_corr_{}_{}", correlationType, assocName).data(), - kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinningMcTrue, axisMultBinningMcTrue}, true); - histos.add(std::format("mc/corr/h6_mix_{}_{}", correlationType, assocName).data(), std::format("h6_mix_{}_{}", correlationType, assocName).data(), - kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinningMcTrue, axisMultBinningMcTrue}, true); + for (std::string const& nameAssoc : std::initializer_list{"hadron", "pipm", "photon"}) { + addMainAssocHists("mc", nameTruthLevel, nameAssoc, true); + } + for (std::string const& nameAssoc : std::initializer_list{"pi0", "eta"}) { + addMainAssocHists("mc", nameTruthLevel, nameAssoc, false); } } - - // decay correlation extra info (just true level) - const std::vector assocMcCorrNamesMcDecayAddition = {"photonDecay", "photonDirect", "photonPi0", "photonEta", - "omega", "photonOmega", "etaPrime", "photonEtaPrime", "photonOtherMother"}; - for (auto const& assocName : assocMcCorrNamesMcDecayAddition) { - histos.add(std::format("mc/corr/h6_corr_true_{}", assocName).data(), std::format("h6_corr_true_{}", assocName).data(), - kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinningMcTrue, axisMultBinningMcTrue}, true); - histos.add(std::format("mc/corr/h6_mix_true_{}", assocName).data(), std::format("h6_mix_true_{}", assocName).data(), - kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinningMcTrue, axisMultBinningMcTrue}, true); + // extra truthLevels for photonPcmPair + for (std::string const& nameTruthLevel : std::initializer_list{"trueDecaySelfTrig", "trueMeasDecay", "trueGeoAcc"}) { + for (std::string const& nameAssoc : std::initializer_list{"pi0", "eta"}) { + addMainAssocHists("mc", nameTruthLevel, nameAssoc, false); + } + } + // assocTypes just on true level + for (std::string const& nameAssoc : std::initializer_list{"photonDecay", "photonDirect", "photonPi0", "photonEta", + "omega", "photonOmega", "etaPrime", "photonEtaPrime", "photonOtherMother"}) { + addMainAssocHists("mc", "true", nameAssoc, false); } - // extra reco correlations with MC info - auto const addMcRecoCorrHists = - [&](std::string const& correlationType, std::string const& assocName) { - histos.add(std::format("mc/corr/h6_corr_{}_{}", correlationType, assocName).data(), std::format("h6_corr_{}_{}", correlationType, assocName).data(), - kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); - histos.add(std::format("mc/corr/h6_mix_{}_{}", correlationType, assocName).data(), std::format("h6_mix_{}_{}", correlationType, assocName).data(), - kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); - }; - // matchable associated particles - const std::vector assocCorrNamesMcExtra = {"hadron", "pipm", "photonPCM"}; - for (auto const& correlationType : {"recoAssocEv", "recoPure", "recoPureTruePtAssoc"}) { - for (auto const& assocName : assocCorrNamesMcExtra) { - addMcRecoCorrHists(correlationType, assocName); - } - } - // invariant mass associated particles - // mc pseudo yield - addMcRecoCorrHists("pseudoReco", "pi0PCM"); - addMcRecoCorrHists("pseudoRecoAssocEv", "pi0PCM"); - addMcRecoCorrHists("pseudoRecoPure", "pi0PCM"); - addMcRecoCorrHists("pseudoRecoPureTruePtAssoc", "pi0PCM"); - // efficiency advanced info - addMcRecoCorrHists("trueGeoAcc", "pi0"); - addMcRecoCorrHists("trueMeasDecay", "pi0"); - - // mc correction - auto const addCorrectionHistsResolved = - [&](std::string const& nameId) { - histos.add(std::format("mc/correction/resol/h4_ptTrigPtAssocPhiEta_{}", nameId).data(), std::format("h4_ptTrigPtAssocPhiEta_{}", nameId).data(), - kTHnSparseD, {axisPtTrig, axisPtAssoc, axisPhi, axisEta}, true); - histos.add(std::format("mc/correction/resol/h4_ptTrigPtAssocZPvMult_{}", nameId).data(), std::format("h4_ptTrigPtAssocZPvMult_{}", nameId).data(), - kTHnSparseD, {axisPtTrig, axisPtAssoc, axisZPv, axisMult}, true); - }; - auto const addCorrectionHistsResolvedBasicTypes = - [&](std::string const& nameReco, std::string const& nameTrue) { - std::vector const recoTypes = {"reco", "recoAssocEv", "recoPure"}; - std::vector const trueTypes = {"true", "trueAssocEv", "trueAssocEvRecoPtTrig"}; - for (std::string const& recoType : recoTypes) { - addCorrectionHistsResolved(std::format("{}_{}", recoType, nameReco)); - } - for (std::string const& trueType : trueTypes) { - addCorrectionHistsResolved(std::format("{}_{}", trueType, nameTrue)); - } - }; - - auto const addCorrectionHistPt = - [&](std::string const& nameId) { - histos.add(std::format("mc/correction/h2_ptTrigPtAssoc_{}", nameId).data(), std::format("h2_ptTrigPtAssoc_{}", nameId).data(), - kTHnSparseD, {axisPtTrig, axisPtAssoc}, true); - }; - auto const addCorrectionHistPtCategories = - [&](std::string const& nameId) { - histos.add(std::format("mc/correction/h3_ptTrigPtAssocCategory_{}", nameId).data(), std::format("h3_ptTrigPtAssocCategory_{}", nameId).data(), - kTHnSparseD, {axisPtTrig, axisPtAssoc, axisCategories}, true); - }; - auto const addCorrectionHistsV0 = - [&](std::string const& nameReco, std::string const& nameTrue) { - addCorrectionHistPt(std::format("true_{}", nameTrue)); - addCorrectionHistPt(std::format("trueAssocEv_{}", nameTrue)); - addCorrectionHistPt(std::format("trueAssocEvRecoPtTrig_{}", nameTrue)); - // mc pseudo yield - addCorrectionHistPt(std::format("pseudoReco_{}", nameReco)); - addCorrectionHistPt(std::format("pseudoRecoAssocEv_{}", nameReco)); - addCorrectionHistPt(std::format("pseudoRecoPure_{}", nameReco)); - // efficiency advanced info - addCorrectionHistPt(std::format("trueGeoAcc_{}", nameTrue)); - addCorrectionHistPt(std::format("trueMeasDecay_{}", nameTrue)); - }; + // reco++ (MC info) + // std assoc + for (std::string const& nameTruthLevel : std::initializer_list{"recoAssocEv", "recoPure", "recoPureTruePtAssoc"}) { + for (std::string const& nameAssoc : std::initializer_list{"hadron", "pipm", "photonPcm"}) { + addMainAssocHists("mc", nameTruthLevel, nameAssoc, true); + } + } + // photonPcmPair assoc + for (std::string const& nameTruthLevel : std::initializer_list{"pseudoReco", "pseudoRecoAssocEv", "pseudoRecoPure", "pseudoRecoPureTruePtAssoc"}) { + for (std::string const& nameAssoc : std::initializer_list{"pi0Pcm", "etaPcm"}) { + addMainAssocHists("mc", nameTruthLevel, nameAssoc, false); + } + } + // impurity details + histos.add("mc/plain/h3_ptTrigPtAssocCategory_recoImpurities_photonPcm", "h3_ptTrigPtAssocCategory_recoImpurities_photonPcm", + kTHnSparseD, {axisPtTrig, axisPtAssoc, axisCategories}, true); + histos.add("mc/plain/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0Pcm", "h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0Pcm", + kTHnSparseD, {axisPtTrig, axisPtAssoc, axisCategories}, true); - // matchables - // tracks - addCorrectionHistsResolvedBasicTypes("hadron", "hadron"); - // pipm PID - addCorrectionHistsResolvedBasicTypes("pipm", "pipm"); - // photonPCM - addCorrectionHistsResolvedBasicTypes("photonPCM", "photon"); - // impurities - addCorrectionHistPtCategories("recoImpurities_photonPCM"); - - // invariant mass reconstruction - // pi0 - addCorrectionHistsV0("pi0PCM", "pi0"); - // impurities - addCorrectionHistPtCategories("pseudoRecoImpurities_pi0PCM"); - // eta - addCorrectionHistsV0("etaPCM", "eta"); + // check reco-mc matching + histos.add("mc/info/h1_pt_noMatch_event", "h1_pt_noMatch_event", kTH1D, {axisN}, true); + histos.add("mc/info/h1_pt_noMatch_trigger", "h1_pt_noMatch_trigger", kTH1D, {axisPtTrig}, true); - // tests + // pcm dcaZ + histos.add("reco/plain/h5_ptTrigPtAssocDcaZZPvMult_photonPcm", "h5_ptTrigPtAssocDcaZZPvMult_photonPcm", + kTHnSparseD, {axisPtTrig, axisPtAssoc, axisDcaZ, axisZPvBinning, axisMultBinning}, true); + histos.add("mc/plain/h5_ptTrigPtAssocDcaZZPvMult_photonPcm", "h5_ptTrigPtAssocDcaZZPvMult_photonPcm", + kTHnSparseD, {axisPtTrig, axisPtAssoc, axisDcaZ, axisZPvBinning, axisMultBinning}, true); + } - // DCAz - histos.add("reco/plain/h5_ptTrigPtAssocDCAzZPvMult_photonPCM", "h5_ptTrigPtAssocDCAzZPvMult_photonPCM", - kTHnSparseD, {axisPtTrig, axisPtAssoc, axisDCAz, axisZPvBinning, axisMultBinning}, true); - histos.add("mc/plain/h5_ptTrigPtAssocDCAzZPvMult_photonPCM", "h5_ptTrigPtAssocDCAzZPvMult_photonPCM", - kTHnSparseD, {axisPtTrig, axisPtAssoc, axisDCAz, axisZPvBinning, axisMultBinning}, true); + // init pcm cut class + void initV0PhotonCut() + { + fV0PhotonCut = V0PhotonCut("fV0PhotonCut", "fV0PhotonCut"); + + // for v0 + fV0PhotonCut.SetV0PtRange(configPcmCuts.cfg_min_pt_v0, configPcmCuts.cfg_max_pt_v0); + fV0PhotonCut.SetV0EtaRange(configPcmCuts.cfg_min_eta_v0, configPcmCuts.cfg_max_eta_v0); + fV0PhotonCut.SetMinCosPA(configPcmCuts.cfg_min_cospa); + fV0PhotonCut.SetMaxPCA(configPcmCuts.cfg_max_pca); + fV0PhotonCut.SetMaxChi2KF(configPcmCuts.cfg_max_chi2kf); + fV0PhotonCut.SetRxyRange(configPcmCuts.cfg_min_v0radius, configPcmCuts.cfg_max_v0radius, configPcmCuts.cfg_midL_v0radius, configPcmCuts.cfg_midH_v0radius); + fV0PhotonCut.SetAPRange(configPcmCuts.cfg_max_alpha_ap, configPcmCuts.cfg_max_qt_ap); + fV0PhotonCut.RejectITSib(configPcmCuts.cfg_reject_v0_on_itsib); + + // for track + fV0PhotonCut.SetMinNClustersTPC(configPcmCuts.cfg_min_ncluster_tpc); + fV0PhotonCut.SetMinNCrossedRowsTPC(configPcmCuts.cfg_min_ncrossedrows); + fV0PhotonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + fV0PhotonCut.SetMaxFracSharedClustersTPC(configPcmCuts.cfg_max_frac_shared_clusters_tpc); + fV0PhotonCut.SetChi2PerClusterTPC(0.0, configPcmCuts.cfg_max_chi2tpc); + fV0PhotonCut.SetTPCNsigmaElRange(configPcmCuts.cfg_min_TPCNsigmaEl, configPcmCuts.cfg_max_TPCNsigmaEl); + fV0PhotonCut.SetChi2PerClusterITS(-1e+10, configPcmCuts.cfg_max_chi2its); + fV0PhotonCut.SetNClustersITS(0, 7); + fV0PhotonCut.SetMeanClusterSizeITSob(0.0, 16.0); + fV0PhotonCut.SetDisableITSonly(configPcmCuts.cfg_disable_itsonly_track); + fV0PhotonCut.SetDisableTPConly(configPcmCuts.cfg_disable_tpconly_track); + fV0PhotonCut.SetRequireITSTPC(configPcmCuts.cfg_require_v0_with_itstpc); + fV0PhotonCut.SetRequireITSonly(configPcmCuts.cfg_require_v0_with_itsonly); + fV0PhotonCut.SetRequireTPConly(configPcmCuts.cfg_require_v0_with_tpconly); } // selections /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ // mc split event selection based in the thrid decimal of mc-true posZ - template - bool checkSplitMcEventSelection(T_collision const& collision) + bool checkSplitMcEventSelection(auto const& collision) { // select based on configurables return collision.thirdDecimalTruePosZ() % splitMcEvN == splitMcEvSelect - 1; } // total event selection (basic selections from producer and analysis level selections) - template - bool totalEvSel(T_collision const& collision) + bool totalEvSel(auto const& collision) { bool isSelEv = true; @@ -605,22 +660,20 @@ struct HadronPhotonCorrelation { } // checks if mcParticle is charged - template - bool checkChargedMc(T_mcParticle const& mcParticle) + bool isCharged(auto const& mcParticle) { auto const pdgParticle = pdg->GetParticle(mcParticle.pdgCode()); return pdgParticle && pdgParticle->Charge() != 0; } // checks if fast decaying mcParticle is 'primary' - template - bool checkDecayPrimary(T_mcParticle const& mcParticle) + bool isDecayPrimary(auto const& mcParticle) { // identify decaying primary return mcParticle.producedByGenerator(); } + // checks if mcParticle daughters are two photons - template - bool checkToGG(T_mcParticle const& mcParticle) + bool isDecayToGG(auto const& mcParticle) { auto const& daughters = mcParticle.template daughters_as(); constexpr int NDaughtersToGG = 2; @@ -638,8 +691,7 @@ struct HadronPhotonCorrelation { return true; } // check if particle has mother in parent tree - template - bool checkForMother(T_mcParticle const& mcParticle, int const pdgCode, bool const checkAntiParticle) + bool checkForMother(auto const& mcParticle, int const pdgCode, bool const checkAntiParticle) { if (!mcParticle.has_mothers()) { return false; @@ -664,22 +716,129 @@ struct HadronPhotonCorrelation { } return false; } + // check if particle has associated mother in parent tree + // includes associated particle checks + bool checkForAssocDecay(auto const& mcParticle, AssocType const assocType) + { + int const pdgCode = [&]() { + if (assocType == AssocType::Pi0Pcm) { + return static_cast(PDG_t::kPi0); + } else if (assocType == AssocType::EtaPcm) { + return static_cast(constants::physics::Pdg::kEta); + } else { + throw std::runtime_error("invalid assocType for mother search"); + } + }(); - // checks if daughters are in acceptance + if (!mcParticle.has_mothers()) { + return false; + } + auto const mothers = mcParticle.template mothers_as(); + auto mother = mothers.begin(); + auto motherEnd = mothers.end(); + while (mother != motherEnd) { + // exclude pre-hadonisation + if (std::abs((*mother).getGenStatusCode()) < 80) { + return false; + } + // check valid associated particle + if ((*mother).pdgCode() == pdgCode || (*mother).pdgCode() == -pdgCode) { + if (std::abs((*mother).eta()) < absEtaMax && isDecayPrimary(*mother)) { + return true; + } + } + if (checkForAssocDecay(*mother, assocType)) { + return true; + } + mother++; + } + return false; + } + // get plain self trigger associated map for event + template + std::map getDecaySelfTrigPlainMap(auto const& triggersThisEvent) + { + std::map decaySelfTrigPlainMap; + + for (AssocType const assocType : {AssocType::Pi0Pcm, AssocType::EtaPcm}) { + decaySelfTrigPlainMap[assocType] = [&]() { + auto trigger = triggersThisEvent.begin(); + auto triggerEnd = triggersThisEvent.end(); + // false for no triggers + if (trigger == triggerEnd) { + return false; + } + // check every trigger for self trigger and return false if unrelated (event triggers independently) + while (trigger != triggerEnd) { + if constexpr (TruthLevelV == TruthLevel::TrueAssocEvRecoPtTrig) { + if (!isMcMatchedTrigger(*trigger)) { + histos.fill(HIST("mc/info/h1_pt_noMatch_trigger"), (*trigger).pt()); + return false; + } + if (!checkForAssocDecay((*trigger).template jetTrack_as().mcParticle(), assocType)) { + return false; + } + } else if constexpr (TruthLevelV == TruthLevel::TrueAssocEv || TruthLevelV == TruthLevel::True) { + if (!checkForAssocDecay((*trigger).jetMcParticle(), assocType)) { + return false; + } + } else { + static_assert(AlwaysFalseValue, "truthLevel not found"); + } + trigger++; + } + return true; + }(); + } + + return decaySelfTrigPlainMap; + } + // recursive helper to exclude loopDeLoops template - bool checkDaughtersInAcceptance(T_mcParticle const& mcParticle, std::pair const etaRange, std::pair const phiRange = {0, constants::math::TwoPI}) + bool isDecayToTrigger(T_mcParticle const& mcParticle, T_mcParticle const& triggerParticle, std::unordered_set& visited) { - auto const& daughterPhotons = mcParticle.template daughters_as(); - auto daughterPhoton = daughterPhotons.begin(); - auto daughterPhotonEnd = daughterPhotons.end(); - while (daughterPhoton != daughterPhotonEnd) { - if ((*daughterPhoton).eta() < etaRange.first || (*daughterPhoton).eta() > etaRange.second) { + if (!visited.insert(mcParticle.globalIndex()).second) { + return false; + } + if (!mcParticle.has_daughters()) { + return false; + } + auto const daughters = mcParticle.template daughters_as(); + auto daughter = daughters.begin(); + auto daughterEnd = daughters.end(); + while (daughter != daughterEnd) { + if ((*daughter).globalIndex() == triggerParticle.globalIndex()) { + return true; + } + if (isDecayToTrigger(*daughter, triggerParticle, visited)) { + return true; + } + daughter++; + } + return false; + } + // check if particle has trigger in daughter tree + template + bool isDecayToTrigger(T_mcParticle const& mcParticle, T_mcParticle const& triggerParticle) + { + std::unordered_set visited; + return isDecayToTrigger(mcParticle, triggerParticle, visited); + } + + // checks if daughters are in acceptance + bool checkDaughtersInAcceptance(auto const& mcParticle, std::pair const etaRange, std::pair const phiRange = {0, constants::math::TwoPI}) + { + auto const& daughters = mcParticle.template daughters_as(); + auto daughter = daughters.begin(); + auto daughterEnd = daughters.end(); + while (daughter != daughterEnd) { + if ((*daughter).eta() < etaRange.first || (*daughter).eta() > etaRange.second) { return false; } - if ((*daughterPhoton).phi() < phiRange.first || (*daughterPhoton).phi() > phiRange.second) { + if ((*daughter).phi() < phiRange.first || (*daughter).phi() > phiRange.second) { return false; } - daughterPhoton++; + daughter++; } return true; } @@ -691,9 +850,9 @@ struct HadronPhotonCorrelation { // 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.size() != 1 || negMothers.size() != 1) { + // return false; + // } if (posMothers.begin()->globalIndex() != negMothers.begin()->globalIndex()) { return false; } @@ -704,103 +863,224 @@ struct HadronPhotonCorrelation { return true; }; - // checks if tracks come from double conversion - template - bool isGGFromDoubleConversion(T_track const& posTrack1, T_track const& negTrack1, T_track const& posTrack2, T_track const& negTrack2, int const pdgCode) - { - if (!isConversionPhoton(posTrack1, negTrack1) || !isConversionPhoton(posTrack2, negTrack2)) { - return false; + + // assocType dependent checks --------------------------------------------------------------------------------------------------------------------------------------------------------------- + + // check trivial self correlation for reconstruction + bool isRecoSelfTrigger(auto const& trigger, auto const& associated) { + for (auto const& intersectTriggerId : associated.intersectTriggerIds()) { + if (intersectTriggerId == trigger.globalIndex()) { + return true; + } } - // 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 NMothersPhotonFromH0 = 2; // for some reason two mothers (same particle) for h0 decays (contradicts PYTHIA documentation, but whatever) - if (mothers1.size() != NMothersPhotonFromH0 || mothers2.size() != NMothersPhotonFromH0) { - return false; + return false; + }; + + // check reco-mc match + bool isMcMatchedCollision(auto const& collision) { + return collision.has_jetMcCollision(); + }; + bool isMcMatchedTrigger(auto const& trigger) { + return trigger.template jetTrack_as().has_mcParticle(); + }; + + // check reco truthLevel reached + template + bool checkTruthLevelReco(auto const& associated) { + // std + static constexpr std::array truthLevelsRecoStdRanked{ + TruthLevel::Reco, + TruthLevel::RecoMcMatched, + TruthLevel::RecoAssocEv, + TruthLevel::RecoPure, + TruthLevel::RecoPureTruePtAssoc + }; + // diPhoton + static constexpr std::array truthLevelsRecoDiPhotonRanked{ + TruthLevel::Reco, + TruthLevel::RecoMcMatched, + TruthLevel::PseudoReco, + TruthLevel::PseudoRecoAssocEv, + TruthLevel::PseudoRecoPure, + TruthLevel::PseudoRecoPureTruePtAssoc + }; + // position of truthLevel in chain, -1 if not in ranked truthLevels + auto constexpr getRank = [](TruthLevel const truthLevel, auto const& truthLevelsRanked) constexpr -> int { + for (size_t iRank = 0; iRank < truthLevelsRanked.size(); iRank++) { + if (truthLevelsRanked[iRank] == truthLevel) { + return static_cast(iRank); + } + } + return -1; + }; + // TruthLevelV compared to the stored maximum level + auto const isReached = [&getRank](TruthLevel const truthLevelRecoMax, auto const& truthLevelsRanked) { + int const rankRecoToCheck = getRank(TruthLevelV, truthLevelsRanked); + int const rankRecoMax = getRank(truthLevelRecoMax, truthLevelsRanked); + if (rankRecoMax < 0) { + throw std::runtime_error("rankRecoMax not found"); + } + return rankRecoToCheck <= rankRecoMax; + }; + // assocType cases + if constexpr (AssocTypeV == AssocType::Hadron) { + static_assert(getRank(TruthLevelV, truthLevelsRecoStdRanked) >= 0, "truthLevel not in std reco chain"); + TruthLevel const truthLevelRecoMax = static_cast(associated.truthLevelRecoHadron()); + return isReached(truthLevelRecoMax, truthLevelsRecoStdRanked); + } else if constexpr (AssocTypeV == AssocType::Pipm) { + static_assert(getRank(TruthLevelV, truthLevelsRecoStdRanked) >= 0, "truthLevel not in std reco chain"); + TruthLevel const truthLevelRecoMax = static_cast(associated.truthLevelRecoPipm()); + return isReached(truthLevelRecoMax, truthLevelsRecoStdRanked); + } else if constexpr (AssocTypeV == AssocType::PhotonPcm) { + static_assert(getRank(TruthLevelV, truthLevelsRecoStdRanked) >= 0, "truthLevel not in std reco chain"); + TruthLevel const truthLevelRecoMax = static_cast(associated.truthLevelRecoPhotonPcm()); + return isReached(truthLevelRecoMax, truthLevelsRecoStdRanked); + } else if constexpr (AssocTypeV == AssocType::Pi0Pcm) { + static_assert(getRank(TruthLevelV, truthLevelsRecoDiPhotonRanked) >= 0, "truthLevel not in diPhoton reco chain"); + TruthLevel const truthLevelRecoMax = static_cast(associated.truthLevelRecoPi0Pcm()); + return isReached(truthLevelRecoMax, truthLevelsRecoDiPhotonRanked); + } else if constexpr (AssocTypeV == AssocType::EtaPcm) { + static_assert(getRank(TruthLevelV, truthLevelsRecoDiPhotonRanked) >= 0, "truthLevel not in diPhoton reco chain"); + TruthLevel const truthLevelRecoMax = static_cast(associated.truthLevelRecoEtaPcm()); + return isReached(truthLevelRecoMax, truthLevelsRecoDiPhotonRanked); + } else { + static_assert(AlwaysFalseValue, "assocType not found"); } - if (mothers1.begin()->globalIndex() != mothers2.begin()->globalIndex()) { + } + + // reco/systematic cuts --------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + // energy asymmetry for photon pair + bool checkEnergyAsymDiPhoton(auto const& v0Photon1, auto const& v0Photon2) + { + double const e1 = v0Photon1.pt() * std::cosh(v0Photon1.eta()); + double const e2 = v0Photon2.pt() * std::cosh(v0Photon2.eta()); + double const energyAsym = std::abs((e1 - e2) / (e1 + e2)); + return energyAsym < energyAsymmPhotonPairMax; + } + + // add pmeventId() due to unguarded call in V0PhotonCut.h qa; selection unaffected + template + struct V0PhotonNoEvent : V0PhotonType { + explicit V0PhotonNoEvent(V0PhotonType const& v0PhotonType) : V0PhotonType(v0PhotonType) {} + [[nodiscard]] int pmeventId() const { return -1; } + }; + bool isSelectedV0Photon(auto const& v0Photon) + { + using V0PhotonType = std::decay_t; + return fV0PhotonCut.template IsSelected, aod::V0Legs>(V0PhotonNoEvent{v0Photon}); + } + + bool isSelectedPhotonPcm(auto const& photonPcm) + { + return isSelectedV0Photon(photonPcm.v0PhotonKF()); + } + bool isSelectedPhotonPcmPair(auto const& photonPcmPair) + { + if (!isSelectedV0Photon(photonPcmPair.v0PhotonKF1()) || !isSelectedV0Photon(photonPcmPair.v0PhotonKF2())) { return false; } - // check particle type - if (mothers1.begin()->pdgCode() != pdgCode) { + if (!checkEnergyAsymDiPhoton(photonPcmPair.v0PhotonKF1(), photonPcmPair.v0PhotonKF2())) { return false; } - return true; - }; + } + + template + bool isSelectedAssoc(auto const& associated) { + if constexpr (AssocTypeV == AssocType::Hadron) { + return true; + } else if constexpr (AssocTypeV == AssocType::Pipm) { + return true; + } else if constexpr (AssocTypeV == AssocType::PhotonPcm) { + return isSelectedPhotonPcm(associated); + } else if constexpr (AssocTypeV == AssocType::PhotonPcmPair || + AssocTypeV == AssocType::Pi0PcmPeak || AssocTypeV == AssocType::Pi0PcmSide || + AssocTypeV == AssocType::EtaPcmPeak || AssocTypeV == AssocType::EtaPcmSide) { + return isSelectedPhotonPcmPair(associated); + } else { + static_assert(AlwaysFalseValue, "assocType not found"); + } + } // analysis helpers ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - template - double getH1ValueAt(T_h1 const* const h1, double const value) - { - return h1->GetBinContent(h1->FindFixBin(value)); + // select standard/main histogram compile-time path from array + static consteval char const* getHistPathMain(auto const& histPaths, HistFillMode const fillMode, TruthLevel const truthLevel, AssocType const assocType) { + for (auto const& entry : histPaths) { + if (entry.fillMode == fillMode && entry.truthLevel == truthLevel && entry.assocType == assocType) { + return entry.path; + } + } + throw "path not found"; } - // correction helpers - enum class CorrectionParticleType { Trigger, - Hadron, - Pipm, - PhotonPCM }; - - template - double getPtCorrection(double const value) - { - if constexpr (T_correctionParticleType == CorrectionParticleType::Trigger) { - return applyCTotTrigger ? getH1ValueAt(h1PtCorrectionTrigger, value) : 1; + + // fill main histogram + template + void fillHistMain(auto const& histFillInfo) { + if constexpr (HistFillModeV == HistFillMode::Plain) { + if constexpr (AssocTypeV == AssocType::Hadron || AssocTypeV == AssocType::Pipm || AssocTypeV == AssocType::PhotonPcm) { + histos.fill(HIST(getHistPathMain(HistPaths, HistFillMode::PlainPhiEta, TruthLevelV, AssocTypeV)), + histFillInfo.ptMax, histFillInfo.ptAssoc, histFillInfo.phi, histFillInfo.eta, + histFillInfo.weight); + histos.fill(HIST(getHistPathMain(HistPaths, HistFillMode::PlainZPvMult, TruthLevelV, AssocTypeV)), + histFillInfo.ptMax, histFillInfo.ptAssoc, histFillInfo.zPv, histFillInfo.mult, + histFillInfo.weight); + } else { + histos.fill(HIST(getHistPathMain(HistPaths, HistFillMode::PlainPt, TruthLevelV, AssocTypeV)), + histFillInfo.ptMax, histFillInfo.ptAssoc, + histFillInfo.weight); + } + } else if constexpr (HistFillModeV == HistFillMode::Correlation) { + histos.fill(HIST(getHistPathMain(HistPaths, HistFillMode::Correlation, TruthLevelV, AssocTypeV)), + histFillInfo.dPhi, histFillInfo.dEta, histFillInfo.ptTrig, histFillInfo.ptAssoc, histFillInfo.zPv, histFillInfo.mult, + histFillInfo.weight); + } else if constexpr (HistFillModeV == HistFillMode::Mixing) { + histos.fill(HIST(getHistPathMain(HistPaths, HistFillMode::Mixing, TruthLevelV, AssocTypeV)), + histFillInfo.dPhi, histFillInfo.dEta, histFillInfo.ptTrig, histFillInfo.ptAssoc, histFillInfo.zPv, histFillInfo.mult, + histFillInfo.weight); } else { - return 1; + static_assert(AlwaysFalseValue, "fillMode not valid"); } } - // performs 'phi1 - phi2' and pushes it into the interval [-pi/2, 3pi/2] - inline double getDeltaPhi(double const phi1, double const phi2) + // get histogram y-quantity at x-value + double getH1ValueAt(auto const*const h1, double const value) { - return RecoDecay::constrainAngle(phi1 - phi2, -1 * constants::math::PIHalf); + return h1->GetBinContent(h1->FindFixBin(value)); + } + // correction trigger as function of pt + double triggerPtCorrection(double const value) + { + return applyCTotTrigger ? getH1ValueAt(h1PtCorrectionTrigger, value) : 1; } - // 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) + // rescale of pt spectra for mc + // add stuff next + + // performs 'phi1 - phi2' and pushes it into the interval [-pi/2, 3pi/2] + double getDeltaPhi(double const phi1, double const phi2) { - // reject underflow - 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]) { - return i_bin; - } - return -1; - } - } - // reject overflow - return -1; + return RecoDecay::constrainAngle(phi1 - phi2, -1 * constants::math::PIHalf); } // check if invariant mass range - enum class MassRange { Pi0PCMPeak, - Pi0PCMSide, - EtaPCMPeak, - EtaPCMSide }; - - template - bool checkMassRange(double const mgg) + template + bool isInMassRange(double const mgg) { - if constexpr (range == MassRange::Pi0PCMPeak) { - return mgg > pi0PCMPeakMassRange.value[0] && mgg < pi0PCMPeakMassRange.value[1]; - } else if constexpr (range == MassRange::Pi0PCMSide) { - return mgg > pi0PCMSideMassRange.value[0] && mgg < pi0PCMSideMassRange.value[1]; - } else if constexpr (range == MassRange::EtaPCMPeak) { - return mgg > etaPCMPeakMassRange.value[0] && mgg < etaPCMPeakMassRange.value[1]; - } else if constexpr (range == MassRange::EtaPCMSide) { - return (mgg > etaPCMLowSideMassRange.value[0] && mgg < etaPCMLowSideMassRange.value[1]) || - (mgg > etaPCMHighSideMassRange.value[0] && mgg < etaPCMHighSideMassRange.value[1]); + if constexpr (AssocTypeV == AssocType::Pi0PcmPeak) { + return mgg > pi0PcmPeakMassRange.value[0] && mgg < pi0PcmPeakMassRange.value[1]; + } else if constexpr (AssocTypeV == AssocType::Pi0PcmSide) { + return mgg > pi0PcmSideMassRange.value[0] && mgg < pi0PcmSideMassRange.value[1]; + } else if constexpr (AssocTypeV == AssocType::EtaPcmPeak) { + return mgg > etaPcmPeakMassRange.value[0] && mgg < etaPcmPeakMassRange.value[1]; + } else if constexpr (AssocTypeV == AssocType::EtaPcmSide) { + return (mgg > etaPcmLowSideMassRange.value[0] && mgg < etaPcmLowSideMassRange.value[1]) || + (mgg > etaPcmHighSideMassRange.value[0] && mgg < etaPcmHighSideMassRange.value[1]); + } else { + static_assert(AlwaysFalseValue, "assocType not found"); } - return false; } // analysis ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -810,10 +1090,8 @@ struct HadronPhotonCorrelation { // per collision // plain info - template - void corrProcessPlain(T_collision const& collision, T_associatedThisEvent const& associatedThisEvent, - T_funcPlain const& funcPlain) + void corrProcessPlain(auto const& collision, auto const& associatedThisEvent, + auto const& funcPlain) { // normal spectra (per event - not per trigger) for (auto const& associated : associatedThisEvent) { @@ -822,10 +1100,8 @@ struct HadronPhotonCorrelation { } // correlation - template - void corrProcessCorrelation(T_collision const& collision, T_triggersThisEvent const& triggersThisEvent, T_associatedThisEvent const& associatedThisEvent, - T_funcCorrelation const& funcCorrelation) + void corrProcessCorrelation(auto const& collision, auto const& triggersThisEvent, auto const& associatedThisEvent, + auto const& funcCorrelation) { // correlation combinations for (auto const& [trigger, associated] : soa::combinations(soa::CombinationsFullIndexPolicy(triggersThisEvent, associatedThisEvent))) { @@ -834,18 +1110,16 @@ struct HadronPhotonCorrelation { } // mixing-number pt scaling with power law - size_t nMixingPtPowerScaling(double const pt, size_t const n0) + size_t nMixingPtPowerScaling(size_t const n0, double const pt) { - double const rawScale = 1 + nTriggerScaleCoefficient * std::pow(pt, nTriggerScaleExponent); - return n0 * static_cast(rawScale); + double const scale = 1 + nTriggerScaleCoefficient * std::pow(pt, nTriggerScaleExponent); + return n0 * scale; } // mixing - template - void corrProcessMixing(T_collision const& collision, T_associatedThisEvent const& associatedThisEvent, - T_funcMixing const& funcMixing, + template + void corrProcessMixing(auto const& collision, auto const& associatedThisEvent, + auto const& funcMixing, size_t const nTriggerMixingAt0) { size_t triggerMemoryBinSizeMin = 0; @@ -853,18 +1127,20 @@ struct HadronPhotonCorrelation { // mixing loops (more dynamic than O2 mixing) std::deque const& savedTriggers = [&]() -> std::deque const& { - if constexpr (triggerMemoryMode == TriggerMemoryMode::Reco) { + if constexpr (TriggerMemoryModeV == TriggerMemoryMode::Reco) { triggerMemoryBinSizeMin = triggerMemoryReco->getBinSizeMin(); return triggerMemoryReco->getTriggers(collision.posZ(), collision.nGlobalTracks()); - } else if constexpr (triggerMemoryMode == TriggerMemoryMode::True) { + } else if constexpr (TriggerMemoryModeV == TriggerMemoryMode::True) { triggerMemoryBinSizeMin = triggerMemoryTrue->getBinSizeMin(); return triggerMemoryTrue->getTriggers(collision.posZ(), collision.nChargedInEtaRange()); - } else if constexpr (triggerMemoryMode == TriggerMemoryMode::TrueAssocEv) { + } else if constexpr (TriggerMemoryModeV == TriggerMemoryMode::TrueAssocEv) { triggerMemoryBinSizeMin = triggerMemoryTrueAssocEv->getBinSizeMin(); return triggerMemoryTrueAssocEv->getTriggers(collision.posZ(), collision.nChargedInEtaRange()); - } else if constexpr (triggerMemoryMode == TriggerMemoryMode::TrueAssocEvRecoPtTrig) { + } else if constexpr (TriggerMemoryModeV == TriggerMemoryMode::TrueAssocEvRecoPtTrig) { triggerMemoryBinSizeMin = triggerMemoryTrueAssocEvRecoPtTrig->getBinSizeMin(); return triggerMemoryTrueAssocEvRecoPtTrig->getTriggers(collision.posZ(), collision.nChargedInEtaRange()); + } else { + static_assert(AlwaysFalseValue, "triggerMemoryMode not found"); } }(); // require enough mixing statistics @@ -872,15 +1148,15 @@ struct HadronPhotonCorrelation { return; } const size_t nSavedTriggers = savedTriggers.size(); - const size_t iStartTriggerParticle = randomIntInInterval(0, iTriggerStartFraction * nSavedTriggers); + const size_t iStartTrigger = randomIntInInterval(0, iTriggerStartFraction * nSavedTriggers); // associated loop for (auto const& associated : associatedThisEvent) { // trigger numbers - const size_t nTriggerMixing = nMixingPtPowerScaling(associated.pt(), nTriggerMixingAt0); - const size_t mixUpToTriggerN = std::min(nSavedTriggers, iStartTriggerParticle + nTriggerMixing); - const float perTriggerWeight = 1. / (mixUpToTriggerN - iStartTriggerParticle); // mixUpToTriggerN <= iStartTriggerParticle caught by break statement of loop + const size_t nTriggerMixing = nMixingPtPowerScaling(nTriggerMixingAt0, associated.pt()); + const size_t mixUpToTriggerN = std::min(nSavedTriggers, iStartTrigger + nTriggerMixing); + const float perTriggerWeight = 1. / (mixUpToTriggerN - iStartTrigger); // mixUpToTriggerN <= iStartTrigger caught by break statement of loop // trigger loop - for (size_t i_mixingTrigger = iStartTriggerParticle; i_mixingTrigger < mixUpToTriggerN; i_mixingTrigger++) { + for (size_t i_mixingTrigger = iStartTrigger; i_mixingTrigger < mixUpToTriggerN; i_mixingTrigger++) { MixingTrigger const& mixingTrigger = savedTriggers[i_mixingTrigger]; funcMixing(collision, mixingTrigger, associated, perTriggerWeight); } @@ -890,9 +1166,11 @@ struct HadronPhotonCorrelation { // analysis tasks /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // =/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/ - void init(InitContext& initContext) + void init(InitContext const&) { // analysis info + int64_t const noLaterThanCcdb = + noLaterThanCcdbConfig == -1 ? std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count() : noLaterThanCcdbConfig; ccdb->setURL(urlCcdb); // enabling object caching (otherwise each call goes to CCDB server) ccdb->setCaching(true); @@ -902,26 +1180,58 @@ struct HadronPhotonCorrelation { // init analysis variables - // get variables from other tasks - o2::common::core::getTaskOptionValue(initContext, "photon-charged-trigger-producer", "absEtaMax", absEtaMax, false); + // check coherent config + double const doublePrecisionDeltaCheck = 1e-5; + if (std::abs(ptTrigMin - configHist.binsPtTrig.value[0]) > doublePrecisionDeltaCheck) { + throw std::runtime_error("ptTrigMin does not match trigger axis"); + } // histograms from ccdb - initCcdbHistograms(); + initCcdbHistograms(noLaterThanCcdb); // create analysis histograms initHistograms(); // mixing trigger memory - triggerMemoryReco = std::make_unique(binsZPvBinning, binsMultBinning, nTriggerSavedForMixing); - triggerMemoryTrue = std::make_unique(binsZPvBinningMcTrue, binsMultBinningMcTrue, nTriggerSavedForMixing); - triggerMemoryTrueAssocEv = std::make_unique(binsZPvBinningMcTrue, binsMultBinningMcTrue, nTriggerSavedForMixing); - triggerMemoryTrueAssocEvRecoPtTrig = std::make_unique(binsZPvBinningMcTrue, binsMultBinningMcTrue, nTriggerSavedForMixing); + triggerMemoryReco = std::make_unique(configHist.binsZPvBinning, configHist.binsMultBinning, nTriggerSavedForMixing); + triggerMemoryTrue = std::make_unique(configHist.binsZPvBinningMcTrue, configHist.binsMultBinningMcTrue, nTriggerSavedForMixing); + triggerMemoryTrueAssocEv = std::make_unique(configHist.binsZPvBinningMcTrue, configHist.binsMultBinningMcTrue, nTriggerSavedForMixing); + triggerMemoryTrueAssocEvRecoPtTrig = std::make_unique(configHist.binsZPvBinningMcTrue, configHist.binsMultBinningMcTrue, nTriggerSavedForMixing); + + // init EM pcm cut class + initV0PhotonCut(); } // reconstructed //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ========================================================================================================================================================================================== - void processCorrHadron(CorrCollisions const& collisions, aod::Triggers const& triggers, aod::Hadrons const& hadrons) + // correlations ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + + // standard reco histogram compile-time paths + static constexpr auto HistPathsRecoStd = []() { + using enum HistFillMode; + using enum TruthLevel; + using enum AssocType; + + return std::to_array({ + {PlainPhiEta, Reco, Hadron, "reco/plain/h4_ptTrigPtAssocPhiEta_reco_hadron"}, + {PlainZPvMult, Reco, Hadron, "reco/plain/h4_ptTrigPtAssocZPvMult_reco_hadron"}, + {Correlation, Reco, Hadron, "reco/corr/h6_corr_reco_hadron"}, + {Mixing, Reco, Hadron, "reco/corr/h6_mix_reco_hadron"}, + {PlainPhiEta, Reco, Pipm, "reco/plain/h4_ptTrigPtAssocPhiEta_reco_pipm"}, + {PlainZPvMult, Reco, Pipm, "reco/plain/h4_ptTrigPtAssocZPvMult_reco_pipm"}, + {Correlation, Reco, Pipm, "reco/corr/h6_corr_reco_pipm"}, + {Mixing, Reco, Pipm, "reco/corr/h6_mix_reco_pipm"}, + {PlainPhiEta, Reco, PhotonPcm, "reco/plain/h4_ptTrigPtAssocPhiEta_reco_photonPcm"}, + {PlainZPvMult, Reco, PhotonPcm, "reco/plain/h4_ptTrigPtAssocZPvMult_reco_photonPcm"}, + {Correlation, Reco, PhotonPcm, "reco/corr/h6_corr_reco_photonPcm"}, + {Mixing, Reco, PhotonPcm, "reco/corr/h6_mix_reco_photonPcm"} + }); + }(); + + template + void fillProcessRecoStd(auto const& collisions, auto const& triggers, auto const& assocs) { for (auto const& collision : collisions) { // event selection @@ -929,103 +1239,133 @@ struct HadronPhotonCorrelation { continue; } - // group collision + // group collision ++ auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); - auto const hadronsThisEvent = hadrons.sliceBy(perColHadrons, collision.globalIndex()); + auto const [assocsThisEvent, nMixingAt0] = [&]() { + if constexpr (AssocTypeV == AssocType::Hadron) { + return std::tuple{assocs.sliceBy(perColHadrons, collision.globalIndex()), nMixingAt0Hadron.value}; + } else if constexpr (AssocTypeV == AssocType::Pipm) { + return std::tuple{assocs.sliceBy(perColPipms, collision.globalIndex()), nMixingAt0Pipm.value}; + } else if constexpr (AssocTypeV == AssocType::PhotonPcm) { + return std::tuple{assocs.sliceBy(perColPhotonPcms, collision.globalIndex()), nMixingAt0PhotonPcm.value}; + } else { + static_assert(AlwaysFalseValue, "assocType not supported"); + } + }(); + + auto const funcPlain = [this](auto const& collision, auto const& associated) { + // reco assoc selection + if (!isSelectedAssoc(associated)) { + return; + } - auto const funcPlain = [this]([[maybe_unused]] auto const& collision, auto const& associated) { - histos.fill(HIST("reco/plain/h3_ptPhiEta_hadron"), - associated.pt(), associated.phi(), associated.eta()); + HistFillInfoPlainPhiEtaZPvMult histFillInfo = {collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), collision.posZ(), static_cast(collision.nGlobalTracks())}; + fillHistMain(histFillInfo); }; - corrProcessPlain(collision, hadronsThisEvent, funcPlain); + corrProcessPlain(collision, assocsThisEvent, funcPlain); auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { + // reco assoc selection + if (!isSelectedAssoc(associated)) { + return; + } // exclude self correlation - if (trigger.jetTrackId() == associated.jetTrackId()) { + if (isRecoSelfTrigger(trigger, associated)) { return; } - histos.fill(HIST("reco/corr/h4_ptTrigPtAssocPhiEta_assoc_hadron"), - collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), - getPtCorrection(trigger.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.nGlobalTracks(), - getPtCorrection(trigger.pt())); + HistFillInfoCorr histFillInfo = {getDeltaPhi(trigger.phi(), associated.phi()), trigger.eta() - associated.eta(), + trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; + histFillInfo.weight = triggerPtCorrection(trigger.pt()); + fillHistMain(histFillInfo); }; - corrProcessCorrelation(collision, triggersThisEvent, hadronsThisEvent, funcCorrelation); + corrProcessCorrelation(collision, triggersThisEvent, assocsThisEvent, funcCorrelation); // select mixing events if (doTrigEvMixing && !collision.trigEv()) { continue; } - auto const funcMixing = [this](auto const& collision, auto const& trigger, auto const& associated, auto const perTriggerWeight) { - histos.fill(HIST("reco/corr/h6_mix_hadron"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); + auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { + // reco assoc selection + if (!isSelectedAssoc(associated)) { + return; + } + + HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), + mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; + histFillInfo.weight = perTriggerWeight * triggerPtCorrection(mixingTrigger.pt()); + fillHistMain(histFillInfo); }; - corrProcessMixing(collision, hadronsThisEvent, funcMixing, nMixingAt0Hadron); + corrProcessMixing(collision, assocsThisEvent, funcMixing, nMixingAt0); } } - PROCESS_SWITCH(HadronPhotonCorrelation, processCorrHadron, "process standard correlation for associated hardons", false); - void processCorrPipm(CorrCollisions const& collisions, aod::Triggers const& triggers, aod::Pipms const& pipms) + void processRecoHadron(CorrCollisions const& collisions, aod::Triggers const& triggers, aod::Hadrons const& hadrons) { - for (auto const& collision : collisions) { - // event selection - if (!totalEvSel(collision)) { - continue; - } - - // group collision - auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); - auto const pipmsThisEvent = pipms.sliceBy(perColPipms, collision.globalIndex()); - - auto const funcPlain = [this]([[maybe_unused]] auto const& collision, auto const& associated) { - histos.fill(HIST("reco/plain/h3_ptPhiEta_pipm"), - associated.pt(), associated.phi(), associated.eta()); - }; - corrProcessPlain(collision, pipmsThisEvent, funcPlain); - - auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { - // exclude self correlation - if (trigger.jetTrackId() == associated.jetTrackId()) { - return; - } - - histos.fill(HIST("reco/corr/h4_ptTrigPtAssocPhiEta_assoc_pipm"), - collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), - getPtCorrection(trigger.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.nGlobalTracks(), - getPtCorrection(trigger.pt())); - }; - corrProcessCorrelation(collision, triggersThisEvent, pipmsThisEvent, funcCorrelation); + fillProcessRecoStd(collisions, triggers, hadrons); + } + PROCESS_SWITCH(HadronPhotonCorrelation, processRecoHadron, "process standard for associated hardon", false); - // select mixing events - if (doTrigEvMixing && !collision.trigEv()) { - continue; - } + void processRecoPipm(CorrCollisions const& collisions, aod::Triggers const& triggers, aod::Pipms const& pipms) + { + fillProcessRecoStd(collisions, triggers, pipms); + } + PROCESS_SWITCH(HadronPhotonCorrelation, processRecoPipm, "process standard for associated pipm", false); - auto const funcMixing = [this](auto const& collision, auto const& trigger, auto const& associated, auto const perTriggerWeight) { - histos.fill(HIST("reco/corr/h6_mix_pipm"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); - }; - corrProcessMixing(collision, pipmsThisEvent, funcMixing, nMixingAt0Pipm); + void processRecoPhotonPcm(CorrCollisions const& collisions, aod::Triggers const& triggers, PhotonPcmsWithV0 const& photonPcms, + aod::V0PhotonsKF const&, aod::V0Legs const&) + { + fillProcessRecoStd(collisions, triggers, photonPcms); + } + PROCESS_SWITCH(HadronPhotonCorrelation, processRecoPhotonPcm, "process standard for associated photonPcm", false); + + // photonPcmPair reco histogram compile-time paths + static constexpr auto HistPathsRecoPhotonPcmPair = []() { + using enum HistFillMode; + using enum TruthLevel; + using enum AssocType; + + return std::to_array({ + {PlainPt, Reco, Pi0PcmPeak, "reco/plain/h2_ptTrigPtAssoc_reco_pi0PcmPeak"}, + {Correlation, Reco, Pi0PcmPeak, "reco/corr/h6_corr_reco_pi0PcmPeak"}, + {Mixing, Reco, Pi0PcmPeak, "reco/corr/h6_mix_reco_pi0PcmPeak"}, + {PlainPt, Reco, Pi0PcmSide, "reco/plain/h2_ptTrigPtAssoc_reco_pi0PcmSide"}, + {Correlation, Reco, Pi0PcmSide, "reco/corr/h6_corr_reco_pi0PcmSide"}, + {Mixing, Reco, Pi0PcmSide, "reco/corr/h6_mix_reco_pi0PcmSide"}, + {PlainPt, Reco, EtaPcmPeak, "reco/plain/h2_ptTrigPtAssoc_reco_etaPcmPeak"}, + {Correlation, Reco, EtaPcmPeak, "reco/corr/h6_corr_reco_etaPcmPeak"}, + {Mixing, Reco, EtaPcmPeak, "reco/corr/h6_mix_reco_etaPcmPeak"}, + {PlainPt, Reco, EtaPcmSide, "reco/plain/h2_ptTrigPtAssoc_reco_etaPcmSide"}, + {Correlation, Reco, EtaPcmSide, "reco/corr/h6_corr_reco_etaPcmSide"}, + {Mixing, Reco, EtaPcmSide, "reco/corr/h6_mix_reco_etaPcmSide"} + }); + }(); + + template + void fillAssocsRecoPhotonPcmPair(auto const& histFillInfo, double const mgg) { + // pi0 + if (isInMassRange(mgg)) { + fillHistMain(histFillInfo); + return; + } + if (isInMassRange(mgg)) { + fillHistMain(histFillInfo); + return; + } + // eta + if (isInMassRange(mgg)) { + fillHistMain(histFillInfo); + return; + } + if (isInMassRange(mgg)) { + fillHistMain(histFillInfo); + return; } } - PROCESS_SWITCH(HadronPhotonCorrelation, processCorrPipm, "process standard correlation for associated pipm", false); - void processCorrPhotonPCM(CorrCollisions const& collisions, aod::Triggers const& triggers, aod::PhotonPCMs const& photonPCMs) + void processRecoPhotonPcmPair(CorrCollisions const& collisions, aod::Triggers const& triggers, PhotonPcmPairsWithV0 const& photonPcmPairs, + aod::V0PhotonsKF const&, aod::V0Legs const&) { for (auto const& collision : collisions) { // event selection @@ -1035,219 +1375,128 @@ struct HadronPhotonCorrelation { // group collision auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); - auto const photonPCMsThisEvent = photonPCMs.sliceBy(perColPhotonPCMs, collision.globalIndex()); + auto const photonPcmPairsThisEvent = photonPcmPairs.sliceBy(perColPhotonPcmPairs, collision.globalIndex()); + + auto const funcPlain = [this](auto const& collision, auto const& associated) { + // reco assoc selection + if (!isSelectedAssoc(associated)) { + return; + } + + // mgg distribution + histos.fill(HIST("reco/plain/h5_ptTrigPtAssocMggZPvMult_reco_photonPcmPair"), + collision.ptMax(), associated.pt(), associated.mgg(), collision.posZ(), collision.nGlobalTracks()); - auto const funcPlain = [this]([[maybe_unused]] auto const& collision, auto const& associated) { - histos.fill(HIST("reco/plain/h3_ptPhiEta_photonPCM"), - associated.pt(), associated.phi(), associated.eta()); + HistFillInfoPlainPt const histFillInfo = {collision.ptMax(), associated.pt()}; + fillAssocsRecoPhotonPcmPair(histFillInfo, associated.mgg()); }; - corrProcessPlain(collision, photonPCMsThisEvent, funcPlain); + corrProcessPlain(collision, photonPcmPairsThisEvent, funcPlain); auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { + // reco assoc selection + if (!isSelectedAssoc(associated)) { + return; + } // exclude self correlation - if (trigger.jetTrackId() == associated.posJetTrackId() || trigger.jetTrackId() == associated.negJetTrackId()) { + if (isRecoSelfTrigger(trigger, associated)) { return; } - histos.fill(HIST("reco/corr/h4_ptTrigPtAssocPhiEta_assoc_photonPCM"), - collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), - getPtCorrection(trigger.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.nGlobalTracks(), - getPtCorrection(trigger.pt())); + double const weight = triggerPtCorrection(trigger.pt()); + + // mgg distribution + histos.fill(HIST("reco/corr/h5_ptTrigPtAssocMggZPvMult_reco_photonPcmPair"), + trigger.pt(), associated.pt(), associated.mgg(), collision.posZ(), collision.nGlobalTracks(), + weight); + + HistFillInfoCorr histFillInfo = {getDeltaPhi(trigger.phi(), associated.phi()), trigger.eta() - associated.eta(), + trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks()), + triggerPtCorrection(trigger.pt())}; + histFillInfo.weight = weight; + fillAssocsRecoPhotonPcmPair(histFillInfo, associated.mgg()); }; - corrProcessCorrelation(collision, triggersThisEvent, photonPCMsThisEvent, funcCorrelation); + corrProcessCorrelation(collision, triggersThisEvent, photonPcmPairsThisEvent, funcCorrelation); // select mixing events if (doTrigEvMixing && !collision.trigEv()) { continue; } - auto const funcMixing = [this](auto const& collision, auto const& trigger, auto const& associated, auto const perTriggerWeight) { - histos.fill(HIST("reco/corr/h6_mix_photonPCM"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); + auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { + // reco assoc selection + if (!isSelectedAssoc(associated)) { + return; + } + + HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), + mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; + histFillInfo.weight = perTriggerWeight * triggerPtCorrection(mixingTrigger.pt()); + fillAssocsRecoPhotonPcmPair(histFillInfo, associated.mgg()); }; - corrProcessMixing(collision, photonPCMsThisEvent, funcMixing, nMixingAt0PhotonPCM); + corrProcessMixing(collision, photonPcmPairsThisEvent, funcMixing, nMixingAt0PhotonPcmPair); } } - PROCESS_SWITCH(HadronPhotonCorrelation, processCorrPhotonPCM, "process standard correlation for associated photonPCM", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processRecoPhotonPcmPair, "process standard for associated photonPcmPair", false); - void processCorrPhotonPCMPair(CorrCollisions const& collisions, aod::Triggers const& triggers, aod::PhotonPCMPairs const& photonPCMPairs) + void processPhotonPcmPairMix(CorrCollisions const& collisions, PhotonPcmsWithV0 const& photonPcms, + aod::V0PhotonsKF const&, aod::V0Legs const&) { - for (auto const& collision : collisions) { - // event selection - if (!totalEvSel(collision)) { - continue; - } - - // group collision - auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); - auto const photonPCMPairsThisEvent = photonPCMPairs.sliceBy(perColPhotonPCMPairs, collision.globalIndex()); - - auto const funcPlain = [this](auto const& collision, auto const& associated) { - histos.fill(HIST("reco/plain/h5_ptTrigPtAssocMggZPvMult_photonPCMPair"), collision.ptMax(), associated.pt(), associated.mgg(), collision.posZ(), collision.nGlobalTracks()); - }; - corrProcessPlain(collision, photonPCMPairsThisEvent, funcPlain); - - auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { - // exclude self correlation - if (trigger.jetTrackId() == associated.posJetTrack1Id() || trigger.jetTrackId() == associated.negJetTrack1Id() || - trigger.jetTrackId() == associated.negJetTrack2Id() || trigger.jetTrackId() == associated.posJetTrack2Id()) { - return; - } - - histos.fill(HIST("reco/corr/h5_ptTrigPtAssocMggZPvMult_assoc_photonPCMPair"), - trigger.pt(), associated.pt(), associated.mgg(), collision.posZ(), collision.nGlobalTracks(), - getPtCorrection(trigger.pt())); - - // pi0 - if (checkMassRange(associated.mgg())) { - histos.fill(HIST("reco/corr/h4_ptTrigPtAssocPhiEta_assoc_pi0PCMPeak"), - collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), - getPtCorrection(trigger.pt())); - histos.fill(HIST("reco/corr/h6_corr_pi0PCMPeak"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - getPtCorrection(trigger.pt())); - return; - } - if (checkMassRange(associated.mgg())) { - histos.fill(HIST("reco/corr/h4_ptTrigPtAssocPhiEta_assoc_pi0PCMSide"), - collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), - getPtCorrection(trigger.pt())); - histos.fill(HIST("reco/corr/h6_corr_pi0PCMSide"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - getPtCorrection(trigger.pt())); - return; - } - // eta - if (checkMassRange(associated.mgg())) { - histos.fill(HIST("reco/corr/h4_ptTrigPtAssocPhiEta_assoc_etaPCMPeak"), - collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), - getPtCorrection(trigger.pt())); - histos.fill(HIST("reco/corr/h6_corr_etaPCMPeak"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - getPtCorrection(trigger.pt())); - return; - } - if (checkMassRange(associated.mgg())) { - histos.fill(HIST("reco/corr/h4_ptTrigPtAssocPhiEta_assoc_etaPCMSide"), - collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), - getPtCorrection(trigger.pt())); - histos.fill(HIST("reco/corr/h6_corr_etaPCMSide"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - getPtCorrection(trigger.pt())); - return; - } - }; - corrProcessCorrelation(collision, triggersThisEvent, photonPCMPairsThisEvent, funcCorrelation); - - // select mixing events - if (doTrigEvMixing && !collision.trigEv()) { - continue; - } - - auto const funcMixing = [this](auto const& collision, auto const& trigger, auto const& associated, auto const perTriggerWeight) { - // pi0 - if (checkMassRange(associated.mgg())) { - histos.fill(HIST("reco/corr/h6_mix_pi0PCMPeak"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); - return; - } - if (checkMassRange(associated.mgg())) { - histos.fill(HIST("reco/corr/h6_mix_pi0PCMSide"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); - return; - } - // eta - if (checkMassRange(associated.mgg())) { - histos.fill(HIST("reco/corr/h6_mix_etaPCMPeak"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); - return; - } - if (checkMassRange(associated.mgg())) { - histos.fill(HIST("reco/corr/h6_mix_etaPCMSide"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); - return; - } - }; - corrProcessMixing(collision, photonPCMPairsThisEvent, funcMixing, nMixingAt0H0PCM); - } - } - PROCESS_SWITCH(HadronPhotonCorrelation, processCorrPhotonPCMPair, "process standard correlation for associated pi0PCM", false); - - void processCorrPhotonPCMPairMix(CorrCollisions const& collisions, aod::PhotonPCMs const& photonPCMs) - { - auto photonPCMsTuple = std::make_tuple(photonPCMs); - SameKindPair pairs{binningZPvMult, nNeighboursMixingPhotonPCMPair, -1, collisions, photonPCMsTuple, &cache}; + BinningZPvMult const binningZPvMult{{prependVariableWidth(configHist.binsZPvBinning.value), prependVariableWidth(configHist.binsMultBinning.value)}, true}; + auto photonPcmsTuple = std::make_tuple(photonPcms); + SameKindPair pairs{binningZPvMult, nNeighboursMixingPhotonPcmPair, -1, collisions, photonPcmsTuple, &cache}; // mixed events for (auto pair = pairs.begin(); pair != pairs.end(); pair++) { - auto const& [collision1, photonPCMs1, collision2, photonPCMs2] = *pair; - - // // check that current und mixing-trigger event are from the same zPv/mult bins - // if (checkSameBin(collision1.posZ(), collision2.posZ(), binsZPvBinning) == -1) { - // std::printf("ERROR: zPv bins do not match\n"); continue; - // } - // if (checkSameBin(collision1.nGlobalTracks(), collision2.nGlobalTracks(), binsMultBinning) == -1) { - // std::printf("ERROR: multiplicity bins do not match\n"); continue; - // } - + auto const& [collision1, photonPcms1, collision2, photonPcms2] = *pair; // event selection if (!totalEvSel(collision1) || !totalEvSel(collision2)) { continue; } - // event info - histos.fill(HIST("reco/plain/h2_zPvMult_photonPCMPair_evMix"), collision1.posZ(), collision1.nGlobalTracks()); // mixing loop - for (auto const& [photonPCM1, photonPCM2] : soa::combinations(soa::CombinationsFullIndexPolicy(photonPCMs1, photonPCMs2))) { - ROOT::Math::PtEtaPhiMVector const p4photonPCM1(photonPCM1.pt(), photonPCM1.eta(), photonPCM1.phi(), 0.); - ROOT::Math::PtEtaPhiMVector const p4photonPCM2(photonPCM2.pt(), photonPCM2.eta(), photonPCM2.phi(), 0.); - ROOT::Math::PtEtaPhiMVector const p4photonPCMPair = p4photonPCM1 + p4photonPCM2; + for (auto const& [photonPcm1, photonPcm2] : soa::combinations(soa::CombinationsFullIndexPolicy(photonPcms1, photonPcms2))) { + ROOT::Math::PtEtaPhiMVector const p4photonPcm1(photonPcm1.pt(), photonPcm1.eta(), photonPcm1.phi(), 0.); + ROOT::Math::PtEtaPhiMVector const p4photonPcm2(photonPcm2.pt(), photonPcm2.eta(), photonPcm2.phi(), 0.); + ROOT::Math::PtEtaPhiMVector const p4photonPcmPair = p4photonPcm1 + p4photonPcm2; + + if (std::abs(p4photonPcmPair.eta()) > absEtaMax) { + continue; + } + // reco assoc selection + if (!isSelectedAssoc(photonPcm1) || !isSelectedAssoc(photonPcm2)) { + continue; + } + if (!checkEnergyAsymDiPhoton(photonPcm1.v0PhotonKF(), photonPcm2.v0PhotonKF())) { + continue; + } - histos.fill(HIST("reco/plain/h4_ptMggZPvMult_photonPCMPair_evMix"), p4photonPCMPair.pt(), p4photonPCMPair.M(), collision1.posZ(), collision1.nGlobalTracks()); + histos.fill(HIST("reco/plain/h4_ptMggZPvMult_photonPcmPair_evMix"), p4photonPcmPair.pt(), p4photonPcmPair.M(), collision1.posZ(), collision1.nGlobalTracks()); } } } - PROCESS_SWITCH(HadronPhotonCorrelation, processCorrPhotonPCMPairMix, "process gamma-gamma mixing for photonPCM", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processPhotonPcmPairMix, "process gamma-gamma mixing for photonPcm", false); + + // other //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - void processPCMDCAz(CorrCollision const& collision, aod::PhotonPCMs const& photonPCMs, aod::V0PhotonsKF const&) + void processPcmDcaZ(CorrCollisions::iterator const& collision, PhotonPcmsWithV0 const& photonPcms, + aod::V0PhotonsKF const&, aod::V0Legs const&) { // event selection if (!totalEvSel(collision)) { return; } - for (auto const& photonPCM : photonPCMs) { - histos.fill(HIST("reco/plain/h5_ptTrigPtAssocDCAzZPvMult_photonPCM"), - collision.ptMax(), photonPCM.pt(), photonPCM.v0PhotonKF().dcaZtopv(), collision.posZ(), collision.nGlobalTracks()); + for (auto const& photonPcm : photonPcms) { + // reco assoc selection + if (!isSelectedAssoc(photonPcm)) { + continue; + } + + histos.fill(HIST("reco/plain/h5_ptTrigPtAssocDcaZZPvMult_photonPcm"), + collision.ptMax(), photonPcm.pt(), photonPcm.v0PhotonKF().dcaZtopv(), collision.posZ(), collision.nGlobalTracks()); } } - PROCESS_SWITCH(HadronPhotonCorrelation, processPCMDCAz, "process to test DCAz distribution of photons in trigger collisions", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processPcmDcaZ, "process to test dcaZ distribution of photons", false); // MC /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ========================================================================================================================================================================================== @@ -1255,187 +1504,176 @@ struct HadronPhotonCorrelation { // correlations ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - // (sad) attempt at reducing code duplication - enum class McCorrTruthLevel : int { True = 0, - TrueAssocEv = 1, - TrueAssocEvRecoPtTrig = 2, - TrueMeasDecay = 3, - TrueGeoAcc = 4 }; - enum class McCorrCorrelationType : int { Correlation = 0, - Mixing = 1 }; - enum class McCorrAssocType : int { Hadron = 0, - Pipm = 1, - Photon = 2, - PhotonDecay = 3, - PhotonDirect = 4, - Pi0 = 5, - PhotonPi0 = 6, - Eta = 7, - PhotonEta = 8, - Omega = 9, - PhotonOmega = 10, - EtaPrime = 11, - PhotonEtaPrime = 12, - PhotonOtherMother = 13 }; - static constexpr std::array, 2>, 5> McTrueCorrHistPaths = {{{{{"mc/corr/h6_corr_true_hadron", "mc/corr/h6_corr_true_pipm", - "mc/corr/h6_corr_true_photon", "mc/corr/h6_corr_true_photonDecay", "mc/corr/h6_corr_true_photonDirect", - "mc/corr/h6_corr_true_pi0", "mc/corr/h6_corr_true_photonPi0", "mc/corr/h6_corr_true_eta", "mc/corr/h6_corr_true_photonEta", - "mc/corr/h6_corr_true_omega", "mc/corr/h6_corr_true_photonOmega", "mc/corr/h6_corr_true_etaPrime", "mc/corr/h6_corr_true_photonEtaPrime", "mc/corr/h6_corr_true_photonOtherMother"}, - {"mc/corr/h6_mix_true_hadron", "mc/corr/h6_mix_true_pipm", - "mc/corr/h6_mix_true_photon", "mc/corr/h6_mix_true_photonDecay", "mc/corr/h6_mix_true_photonDirect", - "mc/corr/h6_mix_true_pi0", "mc/corr/h6_mix_true_photonPi0", "mc/corr/h6_mix_true_eta", "mc/corr/h6_mix_true_photonEta", - "mc/corr/h6_mix_true_omega", "mc/corr/h6_mix_true_photonOmega", "mc/corr/h6_mix_true_etaPrime", "mc/corr/h6_mix_true_photonEtaPrime", "mc/corr/h6_mix_true_photonOtherMother"}}}, - {{{"mc/corr/h6_corr_trueAssocEv_hadron", "mc/corr/h6_corr_trueAssocEv_pipm", - "mc/corr/h6_corr_trueAssocEv_photon", "", "", - "mc/corr/h6_corr_trueAssocEv_pi0", "", "mc/corr/h6_corr_trueAssocEv_eta", "", - "", "", "", "", ""}, - {"mc/corr/h6_mix_trueAssocEv_hadron", "mc/corr/h6_mix_trueAssocEv_pipm", - "mc/corr/h6_mix_trueAssocEv_photon", "", "", - "mc/corr/h6_mix_trueAssocEv_pi0", "", "mc/corr/h6_mix_trueAssocEv_eta", "", - "", "", "", "", ""}}}, - {{{"mc/corr/h6_corr_trueAssocEvRecoPtTrig_hadron", "mc/corr/h6_corr_trueAssocEvRecoPtTrig_pipm", - "mc/corr/h6_corr_trueAssocEvRecoPtTrig_photon", "", "", - "mc/corr/h6_corr_trueAssocEvRecoPtTrig_pi0", "", "mc/corr/h6_corr_trueAssocEvRecoPtTrig_eta", "", - "", "", "", "", ""}, - {"mc/corr/h6_mix_trueAssocEvRecoPtTrig_hadron", "mc/corr/h6_mix_trueAssocEvRecoPtTrig_pipm", - "mc/corr/h6_mix_trueAssocEvRecoPtTrig_photon", "", "", - "mc/corr/h6_mix_trueAssocEvRecoPtTrig_pi0", "", "mc/corr/h6_mix_trueAssocEvRecoPtTrig_eta", "", - "", "", "", "", ""}}}, - {{{"", "", - "", "", "", - "mc/corr/h6_corr_trueMeasDecay_pi0", "", "", "", - "", "", "", "", ""}, - {"", "", - "", "", "", - "mc/corr/h6_mix_trueMeasDecay_pi0", "", "", "", - "", "", "", "", ""}}}, - {{{"", "", - "", "", "", - "mc/corr/h6_corr_trueGeoAcc_pi0", "", "", "", - "", "", "", "", ""}, - {"", "", - "", "", "", - "mc/corr/h6_mix_trueGeoAcc_pi0", "", "", "", - "", "", "", "", ""}}}}}; - static constexpr const char* getMcTrueCorrHistPath(McCorrTruthLevel truthLevel, McCorrCorrelationType correlationType, McCorrAssocType assocType) - { - return McTrueCorrHistPaths[static_cast(truthLevel)][static_cast(correlationType)][static_cast(assocType)]; - } - - // fill mc correlation histograms based on given associated mc particle - template - void fillMcCorrHists(auto const& mcCollision, auto const& triggerIn, auto const& associated, double const weight) - { - // check mc - if constexpr (requires { triggerIn.template jetTrack_as(); }) { - if (!triggerIn.template jetTrack_as().has_mcParticle()) { - return; - } - } - // trigger info separation - auto const triggerParticle = [&]() { - if constexpr (correlationType == McCorrCorrelationType::Correlation) { - if constexpr (truthLevel == McCorrTruthLevel::TrueAssocEvRecoPtTrig) { - static_assert(requires { triggerIn.template jetTrack_as(); }, "triggerIn must be reco level for TrueAssocEvRecoPtTrig"); - return triggerIn.template jetTrack_as().mcParticle(); - } else if constexpr (truthLevel == McCorrTruthLevel::TrueAssocEv || truthLevel == McCorrTruthLevel::True) { - static_assert(requires { triggerIn.template jetMcParticle_as(); }, "triggerIn must be true level for TrueAssocEv and True"); - return triggerIn; - } - } else if constexpr (correlationType == McCorrCorrelationType::Mixing) { - static_assert(std::same_as, MixingTrigger>, "triggerIn must be MixingTrigger for mixing"); - return triggerIn; - } - }(); - auto const& triggerForPt = triggerIn; - - // exclude self correlation - if constexpr (correlationType == McCorrCorrelationType::Correlation) { - if constexpr (truthLevel == McCorrTruthLevel::TrueAssocEvRecoPtTrig) { - if (triggerParticle.globalIndex() == associated.globalIndex()) { - return; - } - } else if constexpr (truthLevel == McCorrTruthLevel::TrueAssocEv || truthLevel == McCorrTruthLevel::True) { - if (triggerParticle.jetMcParticleId() == associated.globalIndex()) { - return; - } - } - } - - double const dPhi = getDeltaPhi(triggerParticle.phi(), associated.phi()); - double const dEta = triggerParticle.eta() - associated.eta(); - double const ptTrig = triggerForPt.pt(); - double const ptAssoc = associated.pt(); - double const posZ = mcCollision.posZ(); - double const mult = mcCollision.nChargedInEtaRange(); - - if (std::abs(associated.eta()) > absEtaMax) { + // mc true++ histogram compile-time paths + static constexpr auto HistPathsMcTrue = []() { + using enum HistFillMode; + using enum TruthLevel; + using enum AssocType; + + return std::to_array({ + {PlainPhiEta, True, Hadron, "mc/plain/h4_ptTrigPtAssocPhiEta_true_hadron"}, + {PlainZPvMult, True, Hadron, "mc/plain/h4_ptTrigPtAssocZPvMult_true_hadron"}, + {Correlation, True, Hadron, "mc/corr/h6_corr_true_hadron"}, + {Mixing, True, Hadron, "mc/corr/h6_mix_true_hadron"}, + {PlainPhiEta, True, Pipm, "mc/plain/h4_ptTrigPtAssocPhiEta_true_pipm"}, + {PlainZPvMult, True, Pipm, "mc/plain/h4_ptTrigPtAssocZPvMult_true_pipm"}, + {Correlation, True, Pipm, "mc/corr/h6_corr_true_pipm"}, + {Mixing, True, Pipm, "mc/corr/h6_mix_true_pipm"}, + {PlainPhiEta, True, PhotonPcm, "mc/plain/h4_ptTrigPtAssocPhiEta_true_photon"}, + {PlainZPvMult, True, PhotonPcm, "mc/plain/h4_ptTrigPtAssocZPvMult_true_photon"}, + {Correlation, True, PhotonPcm, "mc/corr/h6_corr_true_photon"}, + {Mixing, True, PhotonPcm, "mc/corr/h6_mix_true_photon"}, + {PlainPt, True, PhotonDecay, "mc/plain/h2_ptTrigPtAssoc_true_photonDecay"}, + {Correlation, True, PhotonDecay, "mc/corr/h6_corr_true_photonDecay"}, + {Mixing, True, PhotonDecay, "mc/corr/h6_mix_true_photonDecay"}, + {PlainPt, True, PhotonDirect, "mc/plain/h2_ptTrigPtAssoc_true_photonDirect"}, + {Correlation, True, PhotonDirect, "mc/corr/h6_corr_true_photonDirect"}, + {Mixing, True, PhotonDirect, "mc/corr/h6_mix_true_photonDirect"}, + {PlainPt, True, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_true_pi0"}, + {Correlation, True, Pi0Pcm, "mc/corr/h6_corr_true_pi0"}, + {Mixing, True, Pi0Pcm, "mc/corr/h6_mix_true_pi0"}, + {PlainPt, True, PhotonPi0, "mc/plain/h2_ptTrigPtAssoc_true_photonPi0"}, + {Correlation, True, PhotonPi0, "mc/corr/h6_corr_true_photonPi0"}, + {Mixing, True, PhotonPi0, "mc/corr/h6_mix_true_photonPi0"}, + {PlainPt, True, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_true_eta"}, + {Correlation, True, EtaPcm, "mc/corr/h6_corr_true_eta"}, + {Mixing, True, EtaPcm, "mc/corr/h6_mix_true_eta"}, + {PlainPt, True, PhotonEta, "mc/plain/h2_ptTrigPtAssoc_true_photonEta"}, + {Correlation, True, PhotonEta, "mc/corr/h6_corr_true_photonEta"}, + {Mixing, True, PhotonEta, "mc/corr/h6_mix_true_photonEta"}, + {PlainPt, True, Omega, "mc/plain/h2_ptTrigPtAssoc_true_omega"}, + {Correlation, True, Omega, "mc/corr/h6_corr_true_omega"}, + {Mixing, True, Omega, "mc/corr/h6_mix_true_omega"}, + {PlainPt, True, PhotonOmega, "mc/plain/h2_ptTrigPtAssoc_true_photonOmega"}, + {Correlation, True, PhotonOmega, "mc/corr/h6_corr_true_photonOmega"}, + {Mixing, True, PhotonOmega, "mc/corr/h6_mix_true_photonOmega"}, + {PlainPt, True, EtaPrime, "mc/plain/h2_ptTrigPtAssoc_true_etaPrime"}, + {Correlation, True, EtaPrime, "mc/corr/h6_corr_true_etaPrime"}, + {Mixing, True, EtaPrime, "mc/corr/h6_mix_true_etaPrime"}, + {PlainPt, True, PhotonEtaPrime, "mc/plain/h2_ptTrigPtAssoc_true_photonEtaPrime"}, + {Correlation, True, PhotonEtaPrime, "mc/corr/h6_corr_true_photonEtaPrime"}, + {Mixing, True, PhotonEtaPrime, "mc/corr/h6_mix_true_photonEtaPrime"}, + {PlainPt, True, PhotonOtherMother, "mc/plain/h2_ptTrigPtAssoc_true_photonOtherMother"}, + {Correlation, True, PhotonOtherMother, "mc/corr/h6_corr_true_photonOtherMother"}, + {Mixing, True, PhotonOtherMother, "mc/corr/h6_mix_true_photonOtherMother"}, + + {PlainPhiEta, TrueAssocEv, Hadron, "mc/plain/h4_ptTrigPtAssocPhiEta_trueAssocEv_hadron"}, + {PlainZPvMult, TrueAssocEv, Hadron, "mc/plain/h4_ptTrigPtAssocZPvMult_trueAssocEv_hadron"}, + {Correlation, TrueAssocEv, Hadron, "mc/corr/h6_corr_trueAssocEv_hadron"}, + {Mixing, TrueAssocEv, Hadron, "mc/corr/h6_mix_trueAssocEv_hadron"}, + {PlainPhiEta, TrueAssocEv, Pipm, "mc/plain/h4_ptTrigPtAssocPhiEta_trueAssocEv_pipm"}, + {PlainZPvMult, TrueAssocEv, Pipm, "mc/plain/h4_ptTrigPtAssocZPvMult_trueAssocEv_pipm"}, + {Correlation, TrueAssocEv, Pipm, "mc/corr/h6_corr_trueAssocEv_pipm"}, + {Mixing, TrueAssocEv, Pipm, "mc/corr/h6_mix_trueAssocEv_pipm"}, + {PlainPhiEta, TrueAssocEv, PhotonPcm, "mc/plain/h4_ptTrigPtAssocPhiEta_trueAssocEv_photon"}, + {PlainZPvMult, TrueAssocEv, PhotonPcm, "mc/plain/h4_ptTrigPtAssocZPvMult_trueAssocEv_photon"}, + {Correlation, TrueAssocEv, PhotonPcm, "mc/corr/h6_corr_trueAssocEv_photon"}, + {Mixing, TrueAssocEv, PhotonPcm, "mc/corr/h6_mix_trueAssocEv_photon"}, + {PlainPt, TrueAssocEv, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_trueAssocEv_pi0"}, + {Correlation, TrueAssocEv, Pi0Pcm, "mc/corr/h6_corr_trueAssocEv_pi0"}, + {Mixing, TrueAssocEv, Pi0Pcm, "mc/corr/h6_mix_trueAssocEv_pi0"}, + {PlainPt, TrueAssocEv, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_trueAssocEv_eta"}, + {Correlation, TrueAssocEv, EtaPcm, "mc/corr/h6_corr_trueAssocEv_eta"}, + {Mixing, TrueAssocEv, EtaPcm, "mc/corr/h6_mix_trueAssocEv_eta"}, + + {PlainPhiEta, TrueAssocEvRecoPtTrig, Hadron, "mc/plain/h4_ptTrigPtAssocPhiEta_trueAssocEvRecoPtTrig_hadron"}, + {PlainZPvMult, TrueAssocEvRecoPtTrig, Hadron, "mc/plain/h4_ptTrigPtAssocZPvMult_trueAssocEvRecoPtTrig_hadron"}, + {Correlation, TrueAssocEvRecoPtTrig, Hadron, "mc/corr/h6_corr_trueAssocEvRecoPtTrig_hadron"}, + {Mixing, TrueAssocEvRecoPtTrig, Hadron, "mc/corr/h6_mix_trueAssocEvRecoPtTrig_hadron"}, + {PlainPhiEta, TrueAssocEvRecoPtTrig, Pipm, "mc/plain/h4_ptTrigPtAssocPhiEta_trueAssocEvRecoPtTrig_pipm"}, + {PlainZPvMult, TrueAssocEvRecoPtTrig, Pipm, "mc/plain/h4_ptTrigPtAssocZPvMult_trueAssocEvRecoPtTrig_pipm"}, + {Correlation, TrueAssocEvRecoPtTrig, Pipm, "mc/corr/h6_corr_trueAssocEvRecoPtTrig_pipm"}, + {Mixing, TrueAssocEvRecoPtTrig, Pipm, "mc/corr/h6_mix_trueAssocEvRecoPtTrig_pipm"}, + {PlainPhiEta, TrueAssocEvRecoPtTrig, PhotonPcm, "mc/plain/h4_ptTrigPtAssocPhiEta_trueAssocEvRecoPtTrig_photon"}, + {PlainZPvMult, TrueAssocEvRecoPtTrig, PhotonPcm, "mc/plain/h4_ptTrigPtAssocZPvMult_trueAssocEvRecoPtTrig_photon"}, + {Correlation, TrueAssocEvRecoPtTrig, PhotonPcm, "mc/corr/h6_corr_trueAssocEvRecoPtTrig_photon"}, + {Mixing, TrueAssocEvRecoPtTrig, PhotonPcm, "mc/corr/h6_mix_trueAssocEvRecoPtTrig_photon"}, + {PlainPt, TrueAssocEvRecoPtTrig, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_trueAssocEvRecoPtTrig_pi0"}, + {Correlation, TrueAssocEvRecoPtTrig, Pi0Pcm, "mc/corr/h6_corr_trueAssocEvRecoPtTrig_pi0"}, + {Mixing, TrueAssocEvRecoPtTrig, Pi0Pcm, "mc/corr/h6_mix_trueAssocEvRecoPtTrig_pi0"}, + {PlainPt, TrueAssocEvRecoPtTrig, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_trueAssocEvRecoPtTrig_eta"}, + {Correlation, TrueAssocEvRecoPtTrig, EtaPcm, "mc/corr/h6_corr_trueAssocEvRecoPtTrig_eta"}, + {Mixing, TrueAssocEvRecoPtTrig, EtaPcm, "mc/corr/h6_mix_trueAssocEvRecoPtTrig_eta"}, + + {PlainPt, TrueDecaySelfTrig, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_trueDecaySelfTrig_pi0"}, + {Correlation, TrueDecaySelfTrig, Pi0Pcm, "mc/corr/h6_corr_trueDecaySelfTrig_pi0"}, + {Mixing, TrueDecaySelfTrig, Pi0Pcm, "mc/corr/h6_mix_trueDecaySelfTrig_pi0"}, + {PlainPt, TrueDecaySelfTrig, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_trueDecaySelfTrig_eta"}, + {Correlation, TrueDecaySelfTrig, EtaPcm, "mc/corr/h6_corr_trueDecaySelfTrig_eta"}, + {Mixing, TrueDecaySelfTrig, EtaPcm, "mc/corr/h6_mix_trueDecaySelfTrig_eta"}, + + {PlainPt, TrueMeasDecay, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_trueMeasDecay_pi0"}, + {Correlation, TrueMeasDecay, Pi0Pcm, "mc/corr/h6_corr_trueMeasDecay_pi0"}, + {Mixing, TrueMeasDecay, Pi0Pcm, "mc/corr/h6_mix_trueMeasDecay_pi0"}, + {PlainPt, TrueMeasDecay, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_trueMeasDecay_eta"}, + {Correlation, TrueMeasDecay, EtaPcm, "mc/corr/h6_corr_trueMeasDecay_eta"}, + {Mixing, TrueMeasDecay, EtaPcm, "mc/corr/h6_mix_trueMeasDecay_eta"}, + + {PlainPt, TrueGeoAcc, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_trueGeoAcc_pi0"}, + {Correlation, TrueGeoAcc, Pi0Pcm, "mc/corr/h6_corr_trueGeoAcc_pi0"}, + {Mixing, TrueGeoAcc, Pi0Pcm, "mc/corr/h6_mix_trueGeoAcc_pi0"}, + {PlainPt, TrueGeoAcc, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_trueGeoAcc_eta"}, + {Correlation, TrueGeoAcc, EtaPcm, "mc/corr/h6_corr_trueGeoAcc_eta"}, + {Mixing, TrueGeoAcc, EtaPcm, "mc/corr/h6_mix_trueGeoAcc_eta"} + }); + }(); + + template + void fillAssocsMcTrue(auto const& histFillInfo, auto const& assocParticle, T_DecaySelfTrigFunc const& isDecaySelfTrig = T_DecaySelfTrigFunc{}) { + // main eta cut + if (std::abs(assocParticle.eta()) > absEtaMax) { return; } // standard particles (marked physical primary) - if (associated.isPhysicalPrimary()) { - // charged primary ('hadron') - if (checkChargedMc(associated)) { - histos.fill(HIST(getMcTrueCorrHistPath(truthLevel, correlationType, McCorrAssocType::Hadron)), - dPhi, dEta, ptTrig, ptAssoc, posZ, mult, weight); + if (assocParticle.isPhysicalPrimary()) { + // hadron (charged primary) + if (isCharged(assocParticle)) { + fillHistMain(histFillInfo); } // pipm - if (std::abs(associated.pdgCode()) == PDG_t::kPiPlus) { - histos.fill(HIST(getMcTrueCorrHistPath(truthLevel, correlationType, McCorrAssocType::Pipm)), - dPhi, dEta, ptTrig, ptAssoc, posZ, mult, weight); + if (std::abs(assocParticle.pdgCode()) == PDG_t::kPiPlus) { + fillHistMain(histFillInfo); return; } // photon - if (associated.pdgCode() == PDG_t::kGamma) { - histos.fill(HIST(getMcTrueCorrHistPath(truthLevel, correlationType, McCorrAssocType::Photon)), - dPhi, dEta, ptTrig, ptAssoc, posZ, mult, weight); + if (assocParticle.pdgCode() == PDG_t::kGamma) { + fillHistMain(histFillInfo); // extra info for decay correlation only for total true level - if constexpr (truthLevel != McCorrTruthLevel::True) { - return; - } - - // decay and direct - int const statusDecayLow = 91; - int const statusDecayUp = 99; - int const statusDirect = 62; - - if (associated.getGenStatusCode() >= statusDecayLow && associated.getGenStatusCode() <= statusDecayUp) { - histos.fill(HIST(getMcTrueCorrHistPath(truthLevel, correlationType, McCorrAssocType::PhotonDecay)), - dPhi, dEta, ptTrig, ptAssoc, posZ, mult, - weight); - // decays from different mothers - int const pdgMother = associated.template mothers_as().begin()->pdgCode(); - switch (pdgMother) { - case PDG_t::kPi0: - histos.fill(HIST(getMcTrueCorrHistPath(truthLevel, correlationType, McCorrAssocType::PhotonPi0)), - dPhi, dEta, ptTrig, ptAssoc, posZ, mult, weight); - break; - case constants::physics::Pdg::kEta: - histos.fill(HIST(getMcTrueCorrHistPath(truthLevel, correlationType, McCorrAssocType::PhotonEta)), - dPhi, dEta, ptTrig, ptAssoc, posZ, mult, weight); - break; - case constants::physics::Pdg::kOmega: - histos.fill(HIST(getMcTrueCorrHistPath(truthLevel, correlationType, McCorrAssocType::PhotonOmega)), - dPhi, dEta, ptTrig, ptAssoc, posZ, mult, weight); - break; - case constants::physics::Pdg::kEtaPrime: - histos.fill(HIST(getMcTrueCorrHistPath(truthLevel, correlationType, McCorrAssocType::PhotonEtaPrime)), - dPhi, dEta, ptTrig, ptAssoc, posZ, mult, weight); - break; - default: - histos.fill(HIST(getMcTrueCorrHistPath(truthLevel, correlationType, McCorrAssocType::PhotonOtherMother)), - dPhi, dEta, ptTrig, ptAssoc, posZ, mult, weight); - break; - } - } else { - histos.fill(HIST(getMcTrueCorrHistPath(truthLevel, correlationType, McCorrAssocType::PhotonDirect)), - dPhi, dEta, ptTrig, ptAssoc, posZ, mult, - weight); - - if (associated.getGenStatusCode() != statusDirect) { - LOGF(info, "filled primary photon with status: %i", associated.getGenStatusCode()); + if constexpr (TruthLevelV == TruthLevel::True) { + // decay and direct + int const statusDecayLow = 91; + int const statusDecayUp = 99; + int const statusDirect = 62; + + if (std::abs(assocParticle.getGenStatusCode()) >= statusDecayLow && std::abs(assocParticle.getGenStatusCode()) <= statusDecayUp) { + fillHistMain(histFillInfo); + // decays from different mothers + int const pdgMother = assocParticle.template mothers_as().begin()->pdgCode(); + switch (pdgMother) { + case PDG_t::kPi0: + fillHistMain(histFillInfo); + break; + case constants::physics::Pdg::kEta: + fillHistMain(histFillInfo); + break; + case constants::physics::Pdg::kOmega: + fillHistMain(histFillInfo); + break; + case constants::physics::Pdg::kEtaPrime: + fillHistMain(histFillInfo); + break; + default: + fillHistMain(histFillInfo); + break; + } + } else { + fillHistMain(histFillInfo); + // log unexpected status + if (assocParticle.getGenStatusCode() != statusDirect) { + LOGF(info, "filled direct photon with status: %i", assocParticle.getGenStatusCode()); + } } } return; @@ -1443,56 +1681,94 @@ struct HadronPhotonCorrelation { return; } // decaying particles (not marked physical primary) - if (!checkDecayPrimary(associated)) { + if (!isDecayPrimary(assocParticle)) { return; } // pi0 - if (associated.pdgCode() == PDG_t::kPi0) { - histos.fill(HIST(getMcTrueCorrHistPath(truthLevel, correlationType, McCorrAssocType::Pi0)), - dPhi, dEta, ptTrig, ptAssoc, posZ, mult, weight); - // efficincy extra info - if constexpr (truthLevel != McCorrTruthLevel::TrueAssocEvRecoPtTrig) { - return; + if (assocParticle.pdgCode() == PDG_t::kPi0) { + if constexpr (TruthLevelV == TruthLevel::True) { + fillHistMain(histFillInfo); } - // chosen decay - if (!checkToGG(associated)) { - return; + // self trigger + if constexpr (HistFillModeV == HistFillMode::Plain) { + if (isDecaySelfTrig(AssocType::Pi0Pcm)) { + return; + } + } else if constexpr (HistFillModeV == HistFillMode::Correlation) { + if (isDecaySelfTrig()) { + return; + } + } else if constexpr (HistFillModeV == HistFillMode::Mixing) { + } else { + static_assert(AlwaysFalseValue, "histFillMode not found"); } - histos.fill(HIST(getMcTrueCorrHistPath(McCorrTruthLevel::TrueMeasDecay, correlationType, McCorrAssocType::Pi0)), - dPhi, dEta, ptTrig, ptAssoc, posZ, mult, weight); - // daughters in acceptance - if (!checkDaughtersInAcceptance(associated, {-absEtaMax, absEtaMax})) { - return; + fillHistMain(histFillInfo); + // decaying particles extra info + if constexpr (TruthLevelV == TruthLevel::TrueAssocEvRecoPtTrig) { + // chosen decay + if (!isDecayToGG(assocParticle)) { + return; + } + fillHistMain(histFillInfo); + // daughters in acceptance + if (!checkDaughtersInAcceptance(assocParticle, {-absEtaMax, absEtaMax})) { + return; + } + fillHistMain(histFillInfo); } - histos.fill(HIST(getMcTrueCorrHistPath(McCorrTruthLevel::TrueGeoAcc, correlationType, McCorrAssocType::Pi0)), - dPhi, dEta, ptTrig, ptAssoc, posZ, mult, weight); return; } // eta - if (associated.pdgCode() == constants::physics::Pdg::kEta) { - histos.fill(HIST(getMcTrueCorrHistPath(truthLevel, correlationType, McCorrAssocType::Eta)), - dPhi, dEta, ptTrig, ptAssoc, posZ, mult, weight); + if (assocParticle.pdgCode() == constants::physics::Pdg::kEta) { + if constexpr (TruthLevelV == TruthLevel::True) { + fillHistMain(histFillInfo); + } + // self trigger + if constexpr (HistFillModeV == HistFillMode::Plain) { + if (isDecaySelfTrig(AssocType::EtaPcm)) { + return; + } + } else if constexpr (HistFillModeV == HistFillMode::Correlation) { + if (isDecaySelfTrig()) { + return; + } + } else if constexpr (HistFillModeV == HistFillMode::Mixing) { + } else { + static_assert(AlwaysFalseValue, "histFillMode not found"); + } + fillHistMain(histFillInfo); + // decaying particles extra info + if constexpr (TruthLevelV == TruthLevel::TrueAssocEvRecoPtTrig) { + // chosen decay + if (!isDecayToGG(assocParticle)) { + return; + } + fillHistMain(histFillInfo); + // daughters in acceptance + if (!checkDaughtersInAcceptance(assocParticle, {-absEtaMax, absEtaMax})) { + return; + } + fillHistMain(histFillInfo); + } return; } + // extra info for decay correlation only for total true level - if constexpr (truthLevel != McCorrTruthLevel::True) { - return; - } - // omega - if (associated.pdgCode() == constants::physics::Pdg::kOmega) { - histos.fill(HIST(getMcTrueCorrHistPath(truthLevel, correlationType, McCorrAssocType::Omega)), - dPhi, dEta, ptTrig, ptAssoc, posZ, mult, weight); - return; - } - // etaPrime - if (associated.pdgCode() == constants::physics::Pdg::kEtaPrime) { - histos.fill(HIST(getMcTrueCorrHistPath(truthLevel, correlationType, McCorrAssocType::EtaPrime)), - dPhi, dEta, ptTrig, ptAssoc, posZ, mult, weight); - return; + if constexpr (TruthLevelV == TruthLevel::True) { + // omega + if (assocParticle.pdgCode() == constants::physics::Pdg::kOmega) { + fillHistMain(histFillInfo); + return; + } + // etaPrime + if (assocParticle.pdgCode() == constants::physics::Pdg::kEtaPrime) { + fillHistMain(histFillInfo); + return; + } } } - void processMcTrueCorr(CorrMcCollisions const& mcCollisions, aod::TriggerParticles const& triggerParticles, aod::JetParticles const& mcParticles) + void processMcTrue(CorrMcCollisions const& mcCollisions, aod::TrueTriggers const& trueTriggers, aod::JetParticles const& mcParticles) { for (auto const& mcCollision : mcCollisions) { // event selection @@ -1501,60 +1777,56 @@ struct HadronPhotonCorrelation { } // group collision - auto const triggerParticlesThisEvent = triggerParticles.sliceBy(perColTriggerParticles, mcCollision.globalIndex()); + auto const trueTriggersThisEvent = trueTriggers.sliceBy(perColTrueTriggers, mcCollision.globalIndex()); auto const mcParticlesThisEvent = mcParticles.sliceBy(perColMcParticles, mcCollision.globalIndex()); - auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { - fillMcCorrHists(collision, trigger, associated, 1); - }; - corrProcessCorrelation(mcCollision, triggerParticlesThisEvent, mcParticlesThisEvent, funcCorrelation); - - // select mixing events - if (doTrigEvMixing && !mcCollision.trigEv()) { - continue; - } + // self correlation of events (plain) + std::map const decaySelfTrigPlainMap = getDecaySelfTrigPlainMap(trueTriggersThisEvent); - auto const funcMixing = [this](auto const& collision, auto const& trigger, auto const& associated, auto const perTriggerWeight) { - fillMcCorrHists(collision, trigger, associated, perTriggerWeight); + auto const funcPlain = [this, &decaySelfTrigPlainMap](auto const& mcCollision, auto const& assocParticle) { + // self trigger info for decaying particles + auto const isDecaySelfTrig = [&decaySelfTrigPlainMap](AssocType const assocType) { + return decaySelfTrigPlainMap.at(assocType); + }; + HistFillInfoPlainPhiEtaZPvMult histFillInfo = {mcCollision.ptMax(), assocParticle.pt(), assocParticle.phi(), assocParticle.eta(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; + fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); }; - corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, nMixingAt0McTrue); - } - } - PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueCorr, "process mc-true (all collisions) correlation for multiple associated particles", false); - - void processMcTrueAssocEvCorr(CorrMcDCollisions const& collisions, CorrMcCollisions const&, aod::TriggerParticles const& triggerParticles, aod::JetParticles const& mcParticles) - { - for (auto const& collision : collisions) { - // event selection - if (!totalEvSel(collision)) { - continue; - } - - auto const& mcCollision = collision.mcCollision_as(); - - // group collision - auto const triggerParticlesThisEvent = triggerParticles.sliceBy(perColTriggerParticles, collision.mcCollisionId()); - auto const mcParticlesThisEvent = mcParticles.sliceBy(perColMcParticles, collision.mcCollisionId()); + corrProcessPlain(mcCollision, mcParticlesThisEvent, funcPlain); + + auto const funcCorrelation = [this](auto const& mcCollision, auto const& trueTrigger, auto const& assocParticle) { + auto const& triggerParticle = trueTrigger.jetMcParticle(); + // self trigger info for decaying particles + auto const isDecaySelfTrig = [this, &assocParticle, &triggerParticle]() { + return isDecayToTrigger(assocParticle, triggerParticle); + }; + // exclude self correlation + if (trueTrigger.jetMcParticleId() == assocParticle.globalIndex()) { + return; + } - auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { - fillMcCorrHists(collision, trigger, associated, 1); + HistFillInfoCorr histFillInfo = {getDeltaPhi(trueTrigger.phi(), assocParticle.phi()), trueTrigger.eta() - assocParticle.eta(), + trueTrigger.pt(), assocParticle.pt(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; + fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); }; - corrProcessCorrelation(mcCollision, triggerParticlesThisEvent, mcParticlesThisEvent, funcCorrelation); + corrProcessCorrelation(mcCollision, trueTriggersThisEvent, mcParticlesThisEvent, funcCorrelation); // select mixing events if (doTrigEvMixing && !mcCollision.trigEv()) { continue; } - auto const funcMixing = [this](auto const& collision, auto const& trigger, auto const& associated, auto const perTriggerWeight) { - fillMcCorrHists(collision, trigger, associated, perTriggerWeight); + auto const funcMixing = [this](auto const& mcCollision, auto const& mixingTrigger, auto const& assocParticle, auto const perTriggerWeight) { + HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), assocParticle.phi()), mixingTrigger.eta() - assocParticle.eta(), + mixingTrigger.pt(), assocParticle.pt(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; + histFillInfo.weight = perTriggerWeight; + fillAssocsMcTrue(histFillInfo, assocParticle); }; - corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, nMixingAt0McTrue); + corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, nMixingAt0McTrue); } } - PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueAssocEvCorr, "process mc-true (reco collisions) correlation for multiple associated particles", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrue, "process mc-true (all collisions) for multiple associated particles", false); - void processMcTrueAssocEvRecoPtTrigCorr(CorrMcDCollisions const& collisions, aod::Triggers const& triggers, aod::JetTracksMCD const&, CorrMcCollisions const&, aod::JetParticles const& mcParticles) + void processMcTrueAssocEv(CorrCollisionsMcD const& collisions, CorrMcCollisions const&, aod::TrueTriggers const& trueTriggers, aod::JetParticles const& mcParticles) { for (auto const& collision : collisions) { // event selection @@ -1562,124 +1834,65 @@ struct HadronPhotonCorrelation { continue; } - auto const& mcCollision = collision.mcCollision_as(); - - // group collision - auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); - auto const mcParticlesThisEvent = mcParticles.sliceBy(perColMcParticles, collision.mcCollisionId()); - - auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { - fillMcCorrHists(collision, trigger, associated, 1); - }; - corrProcessCorrelation(mcCollision, triggersThisEvent, mcParticlesThisEvent, funcCorrelation); - - // select mixing events - if (doTrigEvMixing && !mcCollision.trigEv()) { + if (!isMcMatchedCollision(collision)) { + histos.fill(HIST("mc/info/h1_pt_noMatch_event"), 0.5); continue; } - auto const funcMixing = [this](auto const& collision, auto const& trigger, auto const& associated, auto const perTriggerWeight) { - fillMcCorrHists(collision, trigger, associated, perTriggerWeight); - }; - corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, nMixingAt0McTrue); - } - } - PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueAssocEvRecoPtTrigCorr, "process mc-true (reco collisions with reco ptTrig) correlation for multiple associated particles", false); - - void processMcRecoCorrHadron(CorrMcDCollisions const& collisions, aod::Triggers const& triggers, aod::Hadrons const& hadrons, - aod::JetTracksMCD const&, aod::JetParticles const&) - { - for (auto const& collision : collisions) { - // event selection - if (!totalEvSel(collision)) { - continue; - } + auto const& mcCollision = collision.jetMcCollision_as(); // group collision - auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); - auto const hadronsThisEvent = hadrons.sliceBy(perColHadrons, collision.globalIndex()); - - auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { + auto const trueTriggersThisEvent = trueTriggers.sliceBy(perColTrueTriggers, collision.jetMcCollisionId()); + auto const mcParticlesThisEvent = mcParticles.sliceBy(perColMcParticles, collision.jetMcCollisionId()); + + // self correlation of events (plain) + std::map const decaySelfTrigPlainMap = getDecaySelfTrigPlainMap(trueTriggersThisEvent); + + auto const funcPlain = [this, &decaySelfTrigPlainMap](auto const& mcCollision, auto const& assocParticle) { + // self trigger info for decaying particles + auto const isDecaySelfTrig = [&decaySelfTrigPlainMap](AssocType const assocType) { + return decaySelfTrigPlainMap.at(assocType); + }; + HistFillInfoPlainPhiEtaZPvMult histFillInfo = {mcCollision.ptMax(), assocParticle.pt(), assocParticle.phi(), assocParticle.eta(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; + fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); + }; + corrProcessPlain(mcCollision, mcParticlesThisEvent, funcPlain); + + auto const funcCorrelation = [this](auto const& mcCollision, auto const& trueTrigger, auto const& assocParticle) { + auto const& triggerParticle = trueTrigger.jetMcParticle(); + // self trigger info for decaying particles + auto const isDecaySelfTrig = [this, &assocParticle, &triggerParticle]() { + return isDecayToTrigger(assocParticle, triggerParticle); + }; // exclude self correlation - if (trigger.jetTrackId() == associated.jetTrackId()) { + if (trueTrigger.jetMcParticleId() == assocParticle.globalIndex()) { return; } - // check mc - if (!associated.template jetTrack_as().has_mcParticle()) { - return; - } - auto const& associatedMcParticle = associated.template jetTrack_as().mcParticle(); - // collision association - if (associatedMcParticle.mcCollisionId() != collision.mcCollisionId()) { - return; - } - histos.fill(HIST("mc/corr/h6_corr_recoAssocEv_hadron"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - getPtCorrection(trigger.pt())); - // purity - if (!checkChargedMc(associatedMcParticle) || !associatedMcParticle.isPhysicalPrimary()) { - return; - } - histos.fill(HIST("mc/corr/h6_corr_recoPure_hadron"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - getPtCorrection(trigger.pt())); - // true pt - histos.fill(HIST("mc/corr/h6_corr_recoPureTruePtAssoc_hadron"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associatedMcParticle.pt(), collision.posZ(), collision.nGlobalTracks(), - getPtCorrection(trigger.pt())); + HistFillInfoCorr histFillInfo = {getDeltaPhi(trueTrigger.phi(), assocParticle.phi()), trueTrigger.eta() - assocParticle.eta(), + trueTrigger.pt(), assocParticle.pt(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; + fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); }; - corrProcessCorrelation(collision, triggersThisEvent, hadronsThisEvent, funcCorrelation); + corrProcessCorrelation(mcCollision, trueTriggersThisEvent, mcParticlesThisEvent, funcCorrelation); // select mixing events if (doTrigEvMixing && !collision.trigEv()) { continue; } - auto const funcMixing = [this](auto const& collision, auto const& trigger, auto const& associated, auto const perTriggerWeight) { - // check mc - if (!associated.template jetTrack_as().has_mcParticle()) { - return; - } - auto const& associatedMcParticle = associated.template jetTrack_as().mcParticle(); - // collision association - if (associatedMcParticle.mcCollisionId() != collision.mcCollisionId()) { - return; - } - histos.fill(HIST("mc/corr/h6_mix_recoAssocEv_hadron"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); - // purity - if (!checkChargedMc(associatedMcParticle) || !associatedMcParticle.isPhysicalPrimary()) { - return; - } - histos.fill(HIST("mc/corr/h6_mix_recoPure_hadron"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); - // true pt - histos.fill(HIST("mc/corr/h6_mix_recoPureTruePtAssoc_hadron"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associatedMcParticle.pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); + auto const funcMixing = [this](auto const& mcCollision, auto const& mixingTrigger, auto const& assocParticle, auto const perTriggerWeight) { + HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), assocParticle.phi()), mixingTrigger.eta() - assocParticle.eta(), + mixingTrigger.pt(), assocParticle.pt(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; + histFillInfo.weight = perTriggerWeight; + fillAssocsMcTrue(histFillInfo, assocParticle); }; - corrProcessMixing(collision, hadronsThisEvent, funcMixing, nMixingAt0Hadron); + corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, nMixingAt0McTrue); } } - PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoCorrHadron, "process correlation for associated hardons with additional mc information", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueAssocEv, "process mc-true (reco collisions) correlation for multiple associated particles", false); - void processMcRecoCorrPipm(CorrMcDCollisions const& collisions, aod::Triggers const& triggers, aod::Pipms const& pipms, - aod::JetTracksMCD const&, aod::JetParticles const&) + void processMcTrueAssocEvRecoPtTrig(CorrCollisionsMcD const& collisions, soa::Join const& triggers, aod::JetTracksMCD const&, + CorrMcCollisions const&, aod::JetParticles const& mcParticles) { for (auto const& collision : collisions) { // event selection @@ -1687,187 +1900,168 @@ struct HadronPhotonCorrelation { continue; } + if (!isMcMatchedCollision(collision)) { + histos.fill(HIST("mc/info/h1_pt_noMatch_event"), 0.5); + continue; + } + + auto const& mcCollision = collision.jetMcCollision_as(); + // group collision auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); - auto const pipmsThisEvent = pipms.sliceBy(perColPipms, collision.globalIndex()); - - auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { + auto const mcParticlesThisEvent = mcParticles.sliceBy(perColMcParticles, collision.jetMcCollisionId()); + + // self correlation of events (plain) + std::map const decaySelfTrigPlainMap = getDecaySelfTrigPlainMap(triggersThisEvent); + + auto const funcPlain = [this, &decaySelfTrigPlainMap](auto const& collision, auto const& assocParticle) { + auto const& mcCollision = collision.template jetMcCollision_as(); + // self trigger info for decaying particles + auto const isDecaySelfTrig = [&decaySelfTrigPlainMap](AssocType const assocType) { + return decaySelfTrigPlainMap.at(assocType); + }; + HistFillInfoPlainPhiEtaZPvMult histFillInfo = {collision.ptMax(), assocParticle.pt(), assocParticle.phi(), assocParticle.eta(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; + fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); + }; + corrProcessPlain(collision, mcParticlesThisEvent, funcPlain); + + auto const funcCorrelation = [this](auto const& mcCollision, auto const& trigger, auto const& assocParticle) { + if (!isMcMatchedTrigger(trigger)) { + histos.fill(HIST("mc/info/h1_pt_noMatch_trigger"), trigger.pt()); + return; + } + auto const& triggerParticle = trigger.template jetTrack_as().mcParticle(); + // self trigger info for decaying particles + auto const isDecaySelfTrig = [this, &assocParticle, &triggerParticle]() { + return isDecayToTrigger(assocParticle, triggerParticle); + }; // exclude self correlation - if (trigger.jetTrackId() == associated.jetTrackId()) { + if (triggerParticle.globalIndex() == assocParticle.globalIndex()) { return; } - // check mc - if (!associated.template jetTrack_as().has_mcParticle()) { - return; - } - auto const& associatedMcParticle = associated.template jetTrack_as().mcParticle(); - // collision association - if (associatedMcParticle.mcCollisionId() != collision.mcCollisionId()) { - return; - } - histos.fill(HIST("mc/corr/h6_corr_recoAssocEv_pipm"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - getPtCorrection(trigger.pt())); - // purity - if (std::abs(associatedMcParticle.pdgCode()) != PDG_t::kPiPlus || !associatedMcParticle.isPhysicalPrimary()) { - return; - } - histos.fill(HIST("mc/corr/h6_corr_recoPure_pipm"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - getPtCorrection(trigger.pt())); - // true pt - histos.fill(HIST("mc/corr/h6_corr_recoPureTruePtAssoc_pipm"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associatedMcParticle.pt(), collision.posZ(), collision.nGlobalTracks(), - getPtCorrection(trigger.pt())); + HistFillInfoCorr histFillInfo = {getDeltaPhi(triggerParticle.phi(), assocParticle.phi()), triggerParticle.eta() - assocParticle.eta(), + trigger.pt(), assocParticle.pt(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; + fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); }; - corrProcessCorrelation(collision, triggersThisEvent, pipmsThisEvent, funcCorrelation); + corrProcessCorrelation(mcCollision, triggersThisEvent, mcParticlesThisEvent, funcCorrelation); // select mixing events if (doTrigEvMixing && !collision.trigEv()) { continue; } - auto const funcMixing = [this](auto const& collision, auto const& trigger, auto const& associated, auto const perTriggerWeight) { - // check mc - if (!associated.template jetTrack_as().has_mcParticle()) { - return; - } - auto const& associatedMcParticle = associated.template jetTrack_as().mcParticle(); - // collision association - if (associatedMcParticle.mcCollisionId() != collision.mcCollisionId()) { - return; - } - histos.fill(HIST("mc/corr/h6_mix_recoAssocEv_pipm"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); - // purity - if (std::abs(associatedMcParticle.pdgCode()) != PDG_t::kPiPlus || !associatedMcParticle.isPhysicalPrimary()) { - return; - } - histos.fill(HIST("mc/corr/h6_mix_recoPure_pipm"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); - // true pt - histos.fill(HIST("mc/corr/h6_mix_recoPureTruePtAssoc_pipm"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associatedMcParticle.pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); + auto const funcMixing = [this](auto const& mcCollision, auto const& mixingTrigger, auto const& assocParticle, auto const perTriggerWeight) { + HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), assocParticle.phi()), mixingTrigger.eta() - assocParticle.eta(), + mixingTrigger.pt(), assocParticle.pt(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; + histFillInfo.weight = perTriggerWeight; + fillAssocsMcTrue(histFillInfo, assocParticle, [](){ return false; }); }; - corrProcessMixing(collision, pipmsThisEvent, funcMixing, nMixingAt0Pipm); + corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, nMixingAt0McTrue); } } - PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoCorrPipm, "process correlation for associated pipms with additional mc information", false); - - void processMcRecoCorrPhotonPCM(CorrMcDCollisions const& collisions, aod::Triggers const& triggers, aod::PhotonPCMs const& photonPCMs, - aod::JetTracksMCD const&, aod::JetParticles const&) - { - for (auto const& collision : collisions) { - // event selection - if (!totalEvSel(collision)) { - continue; + PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueAssocEvRecoPtTrig, "process mc-true (reco collisions with reco ptTrig) correlation for multiple associated particles", false); + + // standard mc reco++ histogram compile-time paths + static constexpr auto HistPathsMcRecoStd = []() { + using enum HistFillMode; + using enum TruthLevel; + using enum AssocType; + + return std::to_array({ + {PlainPhiEta, RecoAssocEv, Hadron, "mc/plain/h4_ptTrigPtAssocPhiEta_recoAssocEv_hadron"}, + {PlainZPvMult, RecoAssocEv, Hadron, "mc/plain/h4_ptTrigPtAssocZPvMult_recoAssocEv_hadron"}, + {Correlation, RecoAssocEv, Hadron, "mc/corr/h6_corr_recoAssocEv_hadron"}, + {Mixing, RecoAssocEv, Hadron, "mc/corr/h6_mix_recoAssocEv_hadron"}, + {PlainPhiEta, RecoAssocEv, Pipm, "mc/plain/h4_ptTrigPtAssocPhiEta_recoAssocEv_pipm"}, + {PlainZPvMult, RecoAssocEv, Pipm, "mc/plain/h4_ptTrigPtAssocZPvMult_recoAssocEv_pipm"}, + {Correlation, RecoAssocEv, Pipm, "mc/corr/h6_corr_recoAssocEv_pipm"}, + {Mixing, RecoAssocEv, Pipm, "mc/corr/h6_mix_recoAssocEv_pipm"}, + {PlainPhiEta, RecoAssocEv, PhotonPcm, "mc/plain/h4_ptTrigPtAssocPhiEta_recoAssocEv_photonPcm"}, + {PlainZPvMult, RecoAssocEv, PhotonPcm, "mc/plain/h4_ptTrigPtAssocZPvMult_recoAssocEv_photonPcm"}, + {Correlation, RecoAssocEv, PhotonPcm, "mc/corr/h6_corr_recoAssocEv_photonPcm"}, + {Mixing, RecoAssocEv, PhotonPcm, "mc/corr/h6_mix_recoAssocEv_photonPcm"}, + + {PlainPhiEta, RecoPure, Hadron, "mc/plain/h4_ptTrigPtAssocPhiEta_recoPure_hadron"}, + {PlainZPvMult, RecoPure, Hadron, "mc/plain/h4_ptTrigPtAssocZPvMult_recoPure_hadron"}, + {Correlation, RecoPure, Hadron, "mc/corr/h6_corr_recoPure_hadron"}, + {Mixing, RecoPure, Hadron, "mc/corr/h6_mix_recoPure_hadron"}, + {PlainPhiEta, RecoPure, Pipm, "mc/plain/h4_ptTrigPtAssocPhiEta_recoPure_pipm"}, + {PlainZPvMult, RecoPure, Pipm, "mc/plain/h4_ptTrigPtAssocZPvMult_recoPure_pipm"}, + {Correlation, RecoPure, Pipm, "mc/corr/h6_corr_recoPure_pipm"}, + {Mixing, RecoPure, Pipm, "mc/corr/h6_mix_recoPure_pipm"}, + {PlainPhiEta, RecoPure, PhotonPcm, "mc/plain/h4_ptTrigPtAssocPhiEta_recoPure_photonPcm"}, + {PlainZPvMult, RecoPure, PhotonPcm, "mc/plain/h4_ptTrigPtAssocZPvMult_recoPure_photonPcm"}, + {Correlation, RecoPure, PhotonPcm, "mc/corr/h6_corr_recoPure_photonPcm"}, + {Mixing, RecoPure, PhotonPcm, "mc/corr/h6_mix_recoPure_photonPcm"}, + + {PlainPhiEta, RecoPureTruePtAssoc, Hadron, "mc/plain/h4_ptTrigPtAssocPhiEta_recoPureTruePtAssoc_hadron"}, + {PlainZPvMult, RecoPureTruePtAssoc, Hadron, "mc/plain/h4_ptTrigPtAssocZPvMult_recoPureTruePtAssoc_hadron"}, + {Correlation, RecoPureTruePtAssoc, Hadron, "mc/corr/h6_corr_recoPureTruePtAssoc_hadron"}, + {Mixing, RecoPureTruePtAssoc, Hadron, "mc/corr/h6_mix_recoPureTruePtAssoc_hadron"}, + {PlainPhiEta, RecoPureTruePtAssoc, Pipm, "mc/plain/h4_ptTrigPtAssocPhiEta_recoPureTruePtAssoc_pipm"}, + {PlainZPvMult, RecoPureTruePtAssoc, Pipm, "mc/plain/h4_ptTrigPtAssocZPvMult_recoPureTruePtAssoc_pipm"}, + {Correlation, RecoPureTruePtAssoc, Pipm, "mc/corr/h6_corr_recoPureTruePtAssoc_pipm"}, + {Mixing, RecoPureTruePtAssoc, Pipm, "mc/corr/h6_mix_recoPureTruePtAssoc_pipm"}, + {PlainPhiEta, RecoPureTruePtAssoc, PhotonPcm, "mc/plain/h4_ptTrigPtAssocPhiEta_recoPureTruePtAssoc_photonPcm"}, + {PlainZPvMult, RecoPureTruePtAssoc, PhotonPcm, "mc/plain/h4_ptTrigPtAssocZPvMult_recoPureTruePtAssoc_photonPcm"}, + {Correlation, RecoPureTruePtAssoc, PhotonPcm, "mc/corr/h6_corr_recoPureTruePtAssoc_photonPcm"}, + {Mixing, RecoPureTruePtAssoc, PhotonPcm, "mc/corr/h6_mix_recoPureTruePtAssoc_photonPcm"} + }); + }(); + + template + void fillTruthLevelsMcRecoStd(auto& histFillInfo, auto const& collision, auto const& associated) { + // collision association + if (!checkTruthLevelReco(associated)) { + if constexpr (AssocTypeV == AssocType::PhotonPcm) { + histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_recoImpurities_photonPcm"), + collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::WrongEv)); } - - // group collision - auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); - auto const photonPCMsThisEvent = photonPCMs.sliceBy(perColPhotonPCMs, collision.globalIndex()); - - auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { - // exclude self correlation - if (trigger.jetTrackId() == associated.posJetTrackId() || trigger.jetTrackId() == associated.negJetTrackId()) { - return; - } - - // check mc + return; + } + fillHistMain(histFillInfo); + // purity + if (!checkTruthLevelReco(associated)) { + if constexpr (AssocTypeV == AssocType::PhotonPcm && requires { associated.posJetTrack(); }) { auto const& posTrack = associated.template posJetTrack_as(); auto const& negTrack = associated.template negJetTrack_as(); - if (!posTrack.has_mcParticle() || !negTrack.has_mcParticle()) { - return; - } - // collision association - if (posTrack.mcParticle().mcCollisionId() != collision.mcCollisionId() || negTrack.mcParticle().mcCollisionId() != collision.mcCollisionId()) { + if (!isConversionPhoton(posTrack, negTrack)) { + histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_recoImpurities_photonPcm"), + collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::Misid)); return; } - histos.fill(HIST("mc/corr/h6_corr_recoAssocEv_photonPCM"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - getPtCorrection(trigger.pt())); - // purity auto const& photons = posTrack.mcParticle().template mothers_as(); - if (!isConversionPhoton(posTrack, negTrack) || !photons.begin()->isPhysicalPrimary()) { - return; + if (!photons.begin()->isPhysicalPrimary()) { + if (checkForMother(*(photons.begin()), PDG_t::kK0Short, true)) { + histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_recoImpurities_photonPcm"), + collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::K0Short)); + return; + } + if (checkForMother(*(photons.begin()), PDG_t::kK0Long, true)) { + histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_recoImpurities_photonPcm"), + collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::K0Long)); + return; + } + if (checkForMother(*(photons.begin()), PDG_t::kLambda0, true)) { + histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_recoImpurities_photonPcm"), + collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::Lambda0)); + return; + } + histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_recoImpurities_photonPcm"), + collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::Other)); } - histos.fill(HIST("mc/corr/h6_corr_recoPure_photonPCM"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - getPtCorrection(trigger.pt())); - // true pt - histos.fill(HIST("mc/corr/h6_corr_recoPureTruePtAssoc_photonPCM"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), photons.begin()->pt(), collision.posZ(), collision.nGlobalTracks(), - getPtCorrection(trigger.pt())); - }; - corrProcessCorrelation(collision, triggersThisEvent, photonPCMsThisEvent, funcCorrelation); - - // select mixing events - if (doTrigEvMixing && !collision.trigEv()) { - continue; } - - auto const funcMixing = [this](auto const& collision, auto const& trigger, auto const& associated, auto const perTriggerWeight) { - // check mc - auto const& posTrack = associated.template posJetTrack_as(); - auto const& negTrack = associated.template negJetTrack_as(); - if (!posTrack.has_mcParticle() || !negTrack.has_mcParticle()) { - return; - } - // collision association - if (posTrack.mcParticle().mcCollisionId() != collision.mcCollisionId() || negTrack.mcParticle().mcCollisionId() != collision.mcCollisionId()) { - return; - } - histos.fill(HIST("mc/corr/h6_mix_recoAssocEv_photonPCM"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); - // purity - auto const& photons = posTrack.mcParticle().template mothers_as(); - if (!isConversionPhoton(posTrack, negTrack) || !photons.begin()->isPhysicalPrimary()) { - return; - } - histos.fill(HIST("mc/corr/h6_mix_recoPure_photonPCM"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); - // true pt - histos.fill(HIST("mc/corr/h6_mix_recoPureTruePtAssoc_photonPCM"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), photons.begin()->pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); - }; - corrProcessMixing(collision, photonPCMsThisEvent, funcMixing, nMixingAt0PhotonPCM); + return; } + fillHistMain(histFillInfo); + // true ptAssoc + histFillInfo.ptAssoc = associated.ptTrue(); + fillHistMain(histFillInfo); } - PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoCorrPhotonPCM, "process correlation for associated photonPCMs with additional mc information", false); - void processMcRecoCorrPi0PCM(CorrMcDCollisions const& collisions, aod::Triggers const& triggers, aod::PhotonPCMPairs const& photonPCMPairs, - aod::JetTracksMCD const&, aod::JetParticles const&) + template + void fillProcessMcRecoStd(auto const& collisions, auto const& triggers, auto const& assocs) { for (auto const& collision : collisions) { // event selection @@ -1875,529 +2069,331 @@ struct HadronPhotonCorrelation { continue; } - // group collision + // group collision ++ auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); - auto const photonPCMPairsThisEvent = photonPCMPairs.sliceBy(perColPhotonPCMPairs, collision.globalIndex()); - - auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { - // exclude self correlation - if (trigger.jetTrackId() == associated.posJetTrack1Id() || trigger.jetTrackId() == associated.negJetTrack1Id() || - trigger.jetTrackId() == associated.posJetTrack2Id() || trigger.jetTrackId() == associated.negJetTrack2Id()) { - return; + auto const [assocsThisEvent, nMixingAt0] = [&]() { + if constexpr (AssocTypeV == AssocType::Hadron) { + return std::tuple{assocs.sliceBy(perColHadrons, collision.globalIndex()), nMixingAt0Hadron.value}; + } else if constexpr (AssocTypeV == AssocType::Pipm) { + return std::tuple{assocs.sliceBy(perColPipms, collision.globalIndex()), nMixingAt0Pipm.value}; + } else if constexpr (AssocTypeV == AssocType::PhotonPcm) { + return std::tuple{assocs.sliceBy(perColPhotonPcms, collision.globalIndex()), nMixingAt0PhotonPcm.value}; + } else { + static_assert(AlwaysFalseValue, "assocType not supported"); } + }(); - // check mc - auto const& posTrack1 = associated.template posJetTrack1_as(); - auto const& negTrack1 = associated.template negJetTrack1_as(); - auto const& posTrack2 = associated.template posJetTrack2_as(); - auto const& negTrack2 = associated.template negJetTrack2_as(); - if (!posTrack1.has_mcParticle() || !negTrack1.has_mcParticle() || !posTrack2.has_mcParticle() || !negTrack2.has_mcParticle()) { - return; - } - // pseudo yield - if (!isGGFromDoubleConversion(posTrack1, negTrack1, posTrack2, negTrack2, PDG_t::kPi0)) { + auto const funcPlain = [this](auto const& collision, auto const& associated) { + // reco assoc selection + if (!isSelectedAssoc(associated)) { return; } - histos.fill(HIST("mc/corr/h6_corr_pseudoReco_pi0PCM"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - getPtCorrection(trigger.pt())); - // collision association - if (posTrack1.mcParticle().mcCollisionId() != collision.mcCollisionId()) { + + HistFillInfoPlainPhiEtaZPvMult histFillInfo = {collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), collision.posZ(), static_cast(collision.nGlobalTracks())}; + fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); + }; + corrProcessPlain(collision, assocsThisEvent, funcPlain); + + auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { + // reco assoc selection + if (!isSelectedAssoc(associated)) { return; } - histos.fill(HIST("mc/corr/h6_corr_pseudoRecoAssocEv_pi0PCM"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - getPtCorrection(trigger.pt())); - // purity (just secondaries) - auto const& photons1 = posTrack1.mcParticle().template mothers_as(); - auto const& mothersOfPhoton = photons1.begin()->template mothers_as(); - if (!checkDecayPrimary(*(mothersOfPhoton.begin()))) { + // exclude self correlation + if (isRecoSelfTrigger(trigger, associated)) { return; } - histos.fill(HIST("mc/corr/h6_corr_pseudoRecoPure_pi0PCM"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - getPtCorrection(trigger.pt())); - // true pt - histos.fill(HIST("mc/corr/h6_corr_pseudoRecoPureTruePtAssoc_pi0PCM"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), mothersOfPhoton.begin()->pt(), collision.posZ(), collision.nGlobalTracks(), - getPtCorrection(trigger.pt())); + + HistFillInfoCorr histFillInfo = {getDeltaPhi(trigger.phi(), associated.phi()), trigger.eta() - associated.eta(), + trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; + histFillInfo.weight = triggerPtCorrection(trigger.pt()); + fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); }; - corrProcessCorrelation(collision, triggersThisEvent, photonPCMPairsThisEvent, funcCorrelation); + corrProcessCorrelation(collision, triggersThisEvent, assocsThisEvent, funcCorrelation); // select mixing events if (doTrigEvMixing && !collision.trigEv()) { continue; } - auto const funcMixing = [this](auto const& collision, auto const& trigger, auto const& associated, auto const perTriggerWeight) { - // check mc - auto const& posTrack1 = associated.template posJetTrack1_as(); - auto const& negTrack1 = associated.template negJetTrack1_as(); - auto const& posTrack2 = associated.template posJetTrack2_as(); - auto const& negTrack2 = associated.template negJetTrack2_as(); - if (!posTrack1.has_mcParticle() || !negTrack1.has_mcParticle() || !posTrack2.has_mcParticle() || !negTrack2.has_mcParticle()) { - return; - } - // pseudo yield - if (!isGGFromDoubleConversion(posTrack1, negTrack1, posTrack2, negTrack2, PDG_t::kPi0)) { - return; - } - histos.fill(HIST("mc/corr/h6_mix_pseudoReco_pi0PCM"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); - // collision association - if (posTrack1.mcParticle().mcCollisionId() != collision.mcCollisionId()) { + auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { + // reco assoc selection + if (!isSelectedAssoc(associated)) { return; } - histos.fill(HIST("mc/corr/h6_mix_pseudoRecoAssocEv_pi0PCM"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); - // purity (just secondaries) - auto const& photons1 = posTrack1.mcParticle().template mothers_as(); - auto const& mothersOfPhoton = photons1.begin()->template mothers_as(); - if (!checkDecayPrimary(*(mothersOfPhoton.begin()))) { - return; - } - histos.fill(HIST("mc/corr/h6_mix_pseudoRecoPure_pi0PCM"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); - // true pt - histos.fill(HIST("mc/corr/h6_mix_pseudoRecoPureTruePtAssoc_pi0PCM"), - getDeltaPhi(trigger.phi(), associated.phi()), - trigger.eta() - associated.eta(), - trigger.pt(), mothersOfPhoton.begin()->pt(), collision.posZ(), collision.nGlobalTracks(), - perTriggerWeight * getPtCorrection(trigger.pt())); + + HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), + mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; + histFillInfo.weight = perTriggerWeight * triggerPtCorrection(mixingTrigger.pt()); + fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); }; - corrProcessMixing(collision, photonPCMPairsThisEvent, funcMixing, nMixingAt0PhotonPCM); + corrProcessMixing(collision, assocsThisEvent, funcMixing, nMixingAt0); } } - PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoCorrPi0PCM, "process correlation for associated pi0PCMs with additional mc information", false); - - // other //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - enum class McCorrectionObservable : int { PhiEta = 0, - ZPvMult = 1 }; - enum class McResolvedTruthLevel : int { Reco = 0, - RecoAssocEv = 1, - RecoPure = 2, - TrueAssocEvRecoPtTrig = 3, - TrueAssocEv = 4, - True = 5 }; - enum class CorrAssocType : int { Hadron = 0, - Pipm = 1, - PhotonPCM = 2 }; - static constexpr std::array, 6>, 2> McResolvedCorrectionHistPaths = { - {{{{"mc/correction/resol/h4_ptTrigPtAssocPhiEta_reco_hadron", - "mc/correction/resol/h4_ptTrigPtAssocPhiEta_reco_pipm", - "mc/correction/resol/h4_ptTrigPtAssocPhiEta_reco_photonPCM"}, - {"mc/correction/resol/h4_ptTrigPtAssocPhiEta_recoAssocEv_hadron", - "mc/correction/resol/h4_ptTrigPtAssocPhiEta_recoAssocEv_pipm", - "mc/correction/resol/h4_ptTrigPtAssocPhiEta_recoAssocEv_photonPCM"}, - {"mc/correction/resol/h4_ptTrigPtAssocPhiEta_recoPure_hadron", - "mc/correction/resol/h4_ptTrigPtAssocPhiEta_recoPure_pipm", - "mc/correction/resol/h4_ptTrigPtAssocPhiEta_recoPure_photonPCM"}, - {"mc/correction/resol/h4_ptTrigPtAssocPhiEta_trueAssocEvRecoPtTrig_hadron", - "mc/correction/resol/h4_ptTrigPtAssocPhiEta_trueAssocEvRecoPtTrig_pipm", - "mc/correction/resol/h4_ptTrigPtAssocPhiEta_trueAssocEvRecoPtTrig_photon"}, - {"mc/correction/resol/h4_ptTrigPtAssocPhiEta_trueAssocEv_hadron", - "mc/correction/resol/h4_ptTrigPtAssocPhiEta_trueAssocEv_pipm", - "mc/correction/resol/h4_ptTrigPtAssocPhiEta_trueAssocEv_photon"}, - {"mc/correction/resol/h4_ptTrigPtAssocPhiEta_true_hadron", - "mc/correction/resol/h4_ptTrigPtAssocPhiEta_true_pipm", - "mc/correction/resol/h4_ptTrigPtAssocPhiEta_true_photon"}}}, - {{{"mc/correction/resol/h4_ptTrigPtAssocZPvMult_reco_hadron", - "mc/correction/resol/h4_ptTrigPtAssocZPvMult_reco_pipm", - "mc/correction/resol/h4_ptTrigPtAssocZPvMult_reco_photonPCM"}, - {"mc/correction/resol/h4_ptTrigPtAssocZPvMult_recoAssocEv_hadron", - "mc/correction/resol/h4_ptTrigPtAssocZPvMult_recoAssocEv_pipm", - "mc/correction/resol/h4_ptTrigPtAssocZPvMult_recoAssocEv_photonPCM"}, - {"mc/correction/resol/h4_ptTrigPtAssocZPvMult_recoPure_hadron", - "mc/correction/resol/h4_ptTrigPtAssocZPvMult_recoPure_pipm", - "mc/correction/resol/h4_ptTrigPtAssocZPvMult_recoPure_photonPCM"}, - {"mc/correction/resol/h4_ptTrigPtAssocZPvMult_trueAssocEvRecoPtTrig_hadron", - "mc/correction/resol/h4_ptTrigPtAssocZPvMult_trueAssocEvRecoPtTrig_pipm", - "mc/correction/resol/h4_ptTrigPtAssocZPvMult_trueAssocEvRecoPtTrig_photon"}, - {"mc/correction/resol/h4_ptTrigPtAssocZPvMult_trueAssocEv_hadron", - "mc/correction/resol/h4_ptTrigPtAssocZPvMult_trueAssocEv_pipm", - "mc/correction/resol/h4_ptTrigPtAssocZPvMult_trueAssocEv_photon"}, - {"mc/correction/resol/h4_ptTrigPtAssocZPvMult_true_hadron", - "mc/correction/resol/h4_ptTrigPtAssocZPvMult_true_pipm", - "mc/correction/resol/h4_ptTrigPtAssocZPvMult_true_photon"}}}}}; - static constexpr char const* getMcResolvedCorrectionHistPath(McCorrectionObservable observable, McResolvedTruthLevel truthLevel, CorrAssocType assocType) + void processMcRecoHadron(CorrCollisions const& collisions, aod::Triggers const& triggers, aod::Hadrons const& hadrons) { - return McResolvedCorrectionHistPaths[static_cast(observable)][static_cast(truthLevel)][static_cast(assocType)]; + fillProcessMcRecoStd(collisions, triggers, hadrons); } - template - void fillResolvedCorrectionHists(auto const& collision, auto const& associated) + PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoHadron, "process standard for associated hardon with additional mc information", false); + + void processMcRecoPipm(CorrCollisions const& collisions, aod::Triggers const& triggers, aod::Pipms const& pipms) { - if constexpr (truthLevel == McResolvedTruthLevel::Reco || truthLevel == McResolvedTruthLevel::RecoAssocEv || truthLevel == McResolvedTruthLevel::RecoPure) { - histos.fill(HIST(getMcResolvedCorrectionHistPath(McCorrectionObservable::PhiEta, truthLevel, assocType)), - collision.ptMax(), associated.pt(), associated.phi(), associated.eta()); - histos.fill(HIST(getMcResolvedCorrectionHistPath(McCorrectionObservable::ZPvMult, truthLevel, assocType)), - collision.ptMax(), associated.pt(), collision.posZ(), collision.nGlobalTracks()); - } - if constexpr (truthLevel == McResolvedTruthLevel::TrueAssocEvRecoPtTrig) { - histos.fill(HIST(getMcResolvedCorrectionHistPath(McCorrectionObservable::PhiEta, truthLevel, assocType)), - collision.ptMax(), associated.pt(), associated.phi(), associated.eta()); - histos.fill(HIST(getMcResolvedCorrectionHistPath(McCorrectionObservable::ZPvMult, truthLevel, assocType)), - collision.ptMax(), associated.pt(), collision.template mcCollision_as().posZ(), collision.template mcCollision_as().nChargedInEtaRange()); - } - if constexpr (truthLevel == McResolvedTruthLevel::True || truthLevel == McResolvedTruthLevel::TrueAssocEv) { - histos.fill(HIST(getMcResolvedCorrectionHistPath(McCorrectionObservable::PhiEta, truthLevel, assocType)), - collision.ptMax(), associated.pt(), associated.phi(), associated.eta()); - histos.fill(HIST(getMcResolvedCorrectionHistPath(McCorrectionObservable::ZPvMult, truthLevel, assocType)), - collision.ptMax(), associated.pt(), collision.posZ(), collision.nChargedInEtaRange()); - } + fillProcessMcRecoStd(collisions, triggers, pipms); } + PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoPipm, "process standard for associated pipm with additional mc information", false); - enum class PhotonImpurity { WrongEv, - Misid, - K0Short, - K0Long, - Lambda0, - Other }; - static constexpr double binValuePi0Impurities(PhotonImpurity const impurity) + void processMcRecoPhotonPcm(CorrCollisions const& collisions, aod::Triggers const& triggers, PhotonPcmsWithV0 const& photonPcms, + aod::V0PhotonsKF const&, aod::V0Legs const&) { - return static_cast(impurity) + 0.5; + fillProcessMcRecoStd(collisions, triggers, photonPcms); } + PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoPhotonPcm, "process standard for associated photonPcm with additional mc information", false); - void processMcRecoCorrection(CorrMcDCollision const& collision, aod::JetTracksMCD const&, - aod::Hadrons const& hadrons, aod::Pipms const& pipms, aod::PhotonPCMs const& photonPCMs, aod::PhotonPCMPairs const& photonPCMPairs, - CorrMcCollisions const&, aod::JetParticles const& mcParticles) + void processMcRecoPhotonPcmParentAccess(CorrCollisions const& collisions, aod::Triggers const& triggers, + soa::Join const& photonPcms, + aod::V0PhotonsKF const&, aod::V0Legs const&, + aod::JetTracksMCD const&, aod::JetParticles const&) { - // event selection - if (!totalEvSel(collision)) { - return; - } - - auto const& mcCollision = collision.mcCollision_as(); - - // group collision - auto const mcParticlesThisEvent = mcParticles.sliceBy(perColMcParticles, collision.mcCollisionId()); - - // hadrons - for (auto const& hadron : hadrons) { - // reconstructed - fillResolvedCorrectionHists(collision, hadron); - // check mc - if (!hadron.jetTrack_as().has_mcParticle()) { - continue; - } - auto const& hadronParticle = hadron.jetTrack_as().mcParticle(); - // collision association - if (hadronParticle.mcCollisionId() != collision.mcCollisionId()) { - continue; - } - fillResolvedCorrectionHists(collision, hadron); - // purity - if (!checkChargedMc(hadronParticle) || !hadronParticle.isPhysicalPrimary()) { - continue; - } - fillResolvedCorrectionHists(collision, hadron); - } - - // pipm - for (auto const& pipm : pipms) { - // reconstructed - fillResolvedCorrectionHists(collision, pipm); - // check mc - if (!pipm.jetTrack_as().has_mcParticle()) { - continue; - } - auto const& pipmParticle = pipm.jetTrack_as().mcParticle(); - // collision association - if (pipmParticle.mcCollisionId() != collision.mcCollisionId()) { - continue; - } - fillResolvedCorrectionHists(collision, pipm); - // purity - if (std::abs(pipmParticle.pdgCode()) != PDG_t::kPiPlus || !pipmParticle.isPhysicalPrimary()) { - continue; - } - fillResolvedCorrectionHists(collision, pipm); - } - - // photonPCM - for (auto const& photonPCM : photonPCMs) { - // reconstructed - fillResolvedCorrectionHists(collision, photonPCM); - // check mc - auto const& posTrack = photonPCM.posJetTrack_as(); - auto const& negTrack = photonPCM.negJetTrack_as(); - if (!posTrack.has_mcParticle() || !negTrack.has_mcParticle()) { - continue; - } - // collision association - if (posTrack.mcParticle().mcCollisionId() != collision.mcCollisionId() || negTrack.mcParticle().mcCollisionId() != collision.mcCollisionId()) { - histos.fill(HIST("mc/correction/h3_ptTrigPtAssocCategory_recoImpurities_photonPCM"), - collision.ptMax(), photonPCM.pt(), binValuePi0Impurities(PhotonImpurity::WrongEv)); - continue; - } - fillResolvedCorrectionHists(collision, photonPCM); - // purity - if (!isConversionPhoton(posTrack, negTrack)) { - histos.fill(HIST("mc/correction/h3_ptTrigPtAssocCategory_recoImpurities_photonPCM"), - collision.ptMax(), photonPCM.pt(), binValuePi0Impurities(PhotonImpurity::Misid)); - continue; - } - auto const& photons = posTrack.mcParticle().mothers_as(); - if (!photons.begin()->isPhysicalPrimary()) { - if (checkForMother(*(photons.begin()), PDG_t::kK0Short, true)) { - histos.fill(HIST("mc/correction/h3_ptTrigPtAssocCategory_recoImpurities_photonPCM"), - collision.ptMax(), photonPCM.pt(), binValuePi0Impurities(PhotonImpurity::K0Short)); - continue; - } - if (checkForMother(*(photons.begin()), PDG_t::kK0Long, true)) { - histos.fill(HIST("mc/correction/h3_ptTrigPtAssocCategory_recoImpurities_photonPCM"), - collision.ptMax(), photonPCM.pt(), binValuePi0Impurities(PhotonImpurity::K0Long)); - continue; - } - if (checkForMother(*(photons.begin()), PDG_t::kLambda0, true)) { - histos.fill(HIST("mc/correction/h3_ptTrigPtAssocCategory_recoImpurities_photonPCM"), - collision.ptMax(), photonPCM.pt(), binValuePi0Impurities(PhotonImpurity::Lambda0)); - continue; - } - histos.fill(HIST("mc/correction/h3_ptTrigPtAssocCategory_recoImpurities_photonPCM"), - collision.ptMax(), photonPCM.pt(), binValuePi0Impurities(PhotonImpurity::Other)); - continue; + fillProcessMcRecoStd(collisions, triggers, photonPcms); + } + PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoPhotonPcmParentAccess, "process standard for associated photonPcm with additional mc information and parent access", false); + + // photonPcmPair mc reco++ histogram compile-time paths + static constexpr auto HistPathsMcRecoPhotonPcmPair = []() { + using enum HistFillMode; + using enum TruthLevel; + using enum AssocType; + + return std::to_array({ + {PlainPt, PseudoReco, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_pseudoReco_pi0Pcm"}, + {Correlation, PseudoReco, Pi0Pcm, "mc/corr/h6_corr_pseudoReco_pi0Pcm"}, + {Mixing, PseudoReco, Pi0Pcm, "mc/corr/h6_mix_pseudoReco_pi0Pcm"}, + {PlainPt, PseudoReco, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_pseudoReco_etaPcm"}, + {Correlation, PseudoReco, EtaPcm, "mc/corr/h6_corr_pseudoReco_etaPcm"}, + {Mixing, PseudoReco, EtaPcm, "mc/corr/h6_mix_pseudoReco_etaPcm"}, + + {PlainPt, PseudoRecoAssocEv, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_pseudoRecoAssocEv_pi0Pcm"}, + {Correlation, PseudoRecoAssocEv, Pi0Pcm, "mc/corr/h6_corr_pseudoRecoAssocEv_pi0Pcm"}, + {Mixing, PseudoRecoAssocEv, Pi0Pcm, "mc/corr/h6_mix_pseudoRecoAssocEv_pi0Pcm"}, + {PlainPt, PseudoRecoAssocEv, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_pseudoRecoAssocEv_etaPcm"}, + {Correlation, PseudoRecoAssocEv, EtaPcm, "mc/corr/h6_corr_pseudoRecoAssocEv_etaPcm"}, + {Mixing, PseudoRecoAssocEv, EtaPcm, "mc/corr/h6_mix_pseudoRecoAssocEv_etaPcm"}, + + {PlainPt, PseudoRecoPure, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_pseudoRecoPure_pi0Pcm"}, + {Correlation, PseudoRecoPure, Pi0Pcm, "mc/corr/h6_corr_pseudoRecoPure_pi0Pcm"}, + {Mixing, PseudoRecoPure, Pi0Pcm, "mc/corr/h6_mix_pseudoRecoPure_pi0Pcm"}, + {PlainPt, PseudoRecoPure, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_pseudoRecoPure_etaPcm"}, + {Correlation, PseudoRecoPure, EtaPcm, "mc/corr/h6_corr_pseudoRecoPure_etaPcm"}, + {Mixing, PseudoRecoPure, EtaPcm, "mc/corr/h6_mix_pseudoRecoPure_etaPcm"}, + + {PlainPt, PseudoRecoPureTruePtAssoc, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_pseudoRecoPureTruePtAssoc_pi0Pcm"}, + {Correlation, PseudoRecoPureTruePtAssoc, Pi0Pcm, "mc/corr/h6_corr_pseudoRecoPureTruePtAssoc_pi0Pcm"}, + {Mixing, PseudoRecoPureTruePtAssoc, Pi0Pcm, "mc/corr/h6_mix_pseudoRecoPureTruePtAssoc_pi0Pcm"}, + {PlainPt, PseudoRecoPureTruePtAssoc, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_pseudoRecoPureTruePtAssoc_etaPcm"}, + {Correlation, PseudoRecoPureTruePtAssoc, EtaPcm, "mc/corr/h6_corr_pseudoRecoPureTruePtAssoc_etaPcm"}, + {Mixing, PseudoRecoPureTruePtAssoc, EtaPcm, "mc/corr/h6_mix_pseudoRecoPureTruePtAssoc_etaPcm"} + }); + }(); + + template + void fillTruthLevelsMcRecoPhotonPcmPair(auto& histFillInfo, auto const& collision, auto const& associated) { + // collision association + if (!checkTruthLevelReco(associated)) { + if constexpr (AssocTypeV == AssocType::Pi0Pcm) { + histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0Pcm"), + collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::WrongEv)); } - fillResolvedCorrectionHists(collision, photonPCM); + return; } - - // h0 PCM - for (auto const& photonPCMPair : photonPCMPairs) { - // check mc - auto const& posTrack1 = photonPCMPair.posJetTrack1_as(); - auto const& negTrack1 = photonPCMPair.negJetTrack1_as(); - auto const& posTrack2 = photonPCMPair.posJetTrack2_as(); - auto const& negTrack2 = photonPCMPair.negJetTrack2_as(); - if (!posTrack1.has_mcParticle() || !negTrack1.has_mcParticle() || !posTrack2.has_mcParticle() || !negTrack2.has_mcParticle()) { - continue; - } - - // pi0PCM - if (isGGFromDoubleConversion(posTrack1, negTrack1, posTrack2, negTrack2, PDG_t::kPi0)) { - // pseudo reconstructed - histos.fill(HIST("mc/correction/h2_ptTrigPtAssoc_pseudoReco_pi0PCM"), collision.ptMax(), photonPCMPair.pt()); - // collision association - if (posTrack1.mcParticle().mcCollisionId() != collision.mcCollisionId()) { - histos.fill(HIST("mc/correction/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0PCM"), - collision.ptMax(), photonPCMPair.pt(), binValuePi0Impurities(PhotonImpurity::WrongEv)); - continue; - } - histos.fill(HIST("mc/correction/h2_ptTrigPtAssoc_pseudoRecoAssocEv_pi0PCM"), collision.ptMax(), photonPCMPair.pt()); - // purity + fillHistMain(histFillInfo); + // purity + if (!checkTruthLevelReco(associated)) { + if constexpr (AssocTypeV == AssocType::Pi0Pcm && requires { associated.posJetTrack1(); }) { // note: do not dereference 'mothers' and store element in 'const&' (leads to seg fault) - auto const& photons1 = posTrack1.mcParticle().mothers_as(); - auto const& mothersOfPhoton = photons1.begin()->mothers_as(); - auto const& grandmothersOfPhoton = mothersOfPhoton.begin()->mothers_as(); - if (!checkDecayPrimary(*(mothersOfPhoton.begin()))) { + auto const& posTrack1 = associated.template posJetTrack1_as(); + auto const& photons1 = posTrack1.mcParticle().template mothers_as(); + auto const& mothersOfPhoton = photons1.begin()->template mothers_as(); + auto const& grandmothersOfPhoton = mothersOfPhoton.begin()->template mothers_as(); + if (!isDecayPrimary(*(mothersOfPhoton.begin()))) { if (std::abs(grandmothersOfPhoton.begin()->pdgCode()) == PDG_t::kK0Short) { - histos.fill(HIST("mc/correction/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0PCM"), - collision.ptMax(), photonPCMPair.pt(), binValuePi0Impurities(PhotonImpurity::K0Short)); - continue; + histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0Pcm"), + collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::K0Short)); + return; } if (std::abs(grandmothersOfPhoton.begin()->pdgCode()) == PDG_t::kK0Long) { - histos.fill(HIST("mc/correction/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0PCM"), - collision.ptMax(), photonPCMPair.pt(), binValuePi0Impurities(PhotonImpurity::K0Long)); - continue; + histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0Pcm"), + collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::K0Long)); + return; } if (std::abs(grandmothersOfPhoton.begin()->pdgCode()) == PDG_t::kLambda0) { - histos.fill(HIST("mc/correction/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0PCM"), - collision.ptMax(), photonPCMPair.pt(), binValuePi0Impurities(PhotonImpurity::Lambda0)); - continue; + histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0Pcm"), + collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::Lambda0)); + return; } - histos.fill(HIST("mc/correction/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0PCM"), - collision.ptMax(), photonPCMPair.pt(), binValuePi0Impurities(PhotonImpurity::Other)); - continue; + histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0Pcm"), + collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::Other)); } - histos.fill(HIST("mc/correction/h2_ptTrigPtAssoc_pseudoRecoPure_pi0PCM"), - collision.ptMax(), photonPCMPair.pt()); - continue; - } - // etaPCM - if (isGGFromDoubleConversion(posTrack1, negTrack1, posTrack2, negTrack2, constants::physics::Pdg::kEta)) { - // pseudo reconstructed - histos.fill(HIST("mc/correction/h2_ptTrigPtAssoc_pseudoReco_etaPCM"), collision.ptMax(), photonPCMPair.pt()); - // collision association - if (posTrack1.mcParticle().mcCollisionId() != collision.mcCollisionId()) { - continue; - } - histos.fill(HIST("mc/correction/h2_ptTrigPtAssoc_pseudoRecoAssocEv_etaPCM"), collision.ptMax(), photonPCMPair.pt()); - // purity - auto const& photons1 = posTrack1.mcParticle().mothers_as(); - auto const& mothersOfPhoton = photons1.begin()->mothers_as(); - if (!checkDecayPrimary(*(mothersOfPhoton.begin()))) { - continue; - } - histos.fill(HIST("mc/correction/h2_ptTrigPtAssoc_pseudoRecoPure_etaPCM"), collision.ptMax(), photonPCMPair.pt()); - continue; } + return; } + fillHistMain(histFillInfo); + // true ptAssoc + histFillInfo.ptAssoc = associated.ptTrue(); + fillHistMain(histFillInfo); + } - // mcParticle loop - for (auto const& mcParticle : mcParticlesThisEvent) { - if (std::abs(mcParticle.eta()) > absEtaMax) { - continue; - } + template + void fillAssocsMcRecoPhotonPcmPair(auto& histFillInfo, auto const& collision, auto const& associated) { + // pi0Pcm + if (checkTruthLevelReco(associated)) { + // pseudo yield - // standard particles (marked physical primary) - if (mcParticle.isPhysicalPrimary()) { - // charged - // hadrons - if (checkChargedMc(mcParticle)) { - fillResolvedCorrectionHists(collision, mcParticle); - fillResolvedCorrectionHists(mcCollision, mcParticle); - } - // pipm - if (std::abs(mcParticle.pdgCode()) == PDG_t::kPiPlus) { - fillResolvedCorrectionHists(collision, mcParticle); - fillResolvedCorrectionHists(mcCollision, mcParticle); - continue; - } - // non charged - // photons - if (mcParticle.pdgCode() == PDG_t::kGamma) { - fillResolvedCorrectionHists(collision, mcParticle); - fillResolvedCorrectionHists(mcCollision, mcParticle); - continue; - } - continue; + // mgg distribution + if constexpr (HistFillModeV == HistFillMode::PlainPt) { + histos.fill(HIST("mc/plain/h5_ptTrigPtAssocMggZPvMult_pseudoReco_pi0Pcm"), + histFillInfo.ptMax, histFillInfo.ptAssoc, associated.mgg(), collision.posZ(), collision.nGlobalTracks()); + } else if constexpr (HistFillModeV == HistFillMode::Correlation) { + histos.fill(HIST("mc/corr/h5_ptTrigPtAssocMggZPvMult_pseudoReco_pi0Pcm"), + histFillInfo.ptTrig, histFillInfo.ptAssoc, associated.mgg(), collision.posZ(), collision.nGlobalTracks(), + histFillInfo.weight); } - // decaying particles (not marked physical primary) - if (!checkDecayPrimary(mcParticle)) { - continue; - } - // pi0 - if (mcParticle.pdgCode() == PDG_t::kPi0) { - // true - histos.fill(HIST("mc/correction/h2_ptTrigPtAssoc_trueAssocEv_pi0"), mcCollision.ptMax(), mcParticle.pt()); - histos.fill(HIST("mc/correction/h2_ptTrigPtAssoc_trueAssocEvRecoPtTrig_pi0"), collision.ptMax(), mcParticle.pt()); - // chosen decay - if (!checkToGG(mcParticle)) { - continue; - } - histos.fill(HIST("mc/correction/h2_ptTrigPtAssoc_trueMeasDecay_pi0"), collision.ptMax(), mcParticle.pt()); - // daughters in acceptance - if (!checkDaughtersInAcceptance(mcParticle, {-absEtaMax, absEtaMax})) { - continue; - } - histos.fill(HIST("mc/correction/h2_ptTrigPtAssoc_trueGeoAcc_pi0"), collision.ptMax(), mcParticle.pt()); - continue; - } - // eta - if (mcParticle.pdgCode() == constants::physics::Pdg::kEta) { - // true - histos.fill(HIST("mc/correction/h2_ptTrigPtAssoc_trueAssocEv_eta"), mcCollision.ptMax(), mcParticle.pt()); - histos.fill(HIST("mc/correction/h2_ptTrigPtAssoc_trueAssocEvRecoPtTrig_eta"), collision.ptMax(), mcParticle.pt()); - // chosen decay - if (!checkToGG(mcParticle)) { - continue; - } - histos.fill(HIST("mc/correction/h2_ptTrigPtAssoc_trueMeasDecay_eta"), collision.ptMax(), mcParticle.pt()); - // daughters in acceptance - if (!checkDaughtersInAcceptance(mcParticle, {-absEtaMax, absEtaMax})) { - continue; - } - histos.fill(HIST("mc/correction/h2_ptTrigPtAssoc_trueGeoAcc_eta"), collision.ptMax(), mcParticle.pt()); - continue; - } + // mgg distribution + + fillHistMain(histFillInfo); + + fillTruthLevelsMcRecoPhotonPcmPair(histFillInfo, collision, associated); + return; } - } - PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoCorrection, "process mc reconstruction to calculate corrections", false); + // etaPcm + if (checkTruthLevelReco(associated)) { + // pseudo yield - void processMcTrueCorrection(CorrMcCollision const& mcCollision, aod::JetParticles const& mcParticles) - { - // event selection - if (!totalEvSel(mcCollision)) { + // mgg distribution + if constexpr (HistFillModeV == HistFillMode::PlainPt) { + histos.fill(HIST("mc/plain/h5_ptTrigPtAssocMggZPvMult_pseudoReco_etaPcm"), + histFillInfo.ptMax, histFillInfo.ptAssoc, associated.mgg(), collision.posZ(), collision.nGlobalTracks()); + } else if constexpr (HistFillModeV == HistFillMode::Correlation) { + histos.fill(HIST("mc/corr/h5_ptTrigPtAssocMggZPvMult_pseudoReco_etaPcm"), + histFillInfo.ptTrig, histFillInfo.ptAssoc, associated.mgg(), collision.posZ(), collision.nGlobalTracks(), + histFillInfo.weight); + } + + fillHistMain(histFillInfo); + + fillTruthLevelsMcRecoPhotonPcmPair(histFillInfo, collision, associated); return; } + } - for (auto const& mcParticle : mcParticles) { - if (std::abs(mcParticle.eta()) > absEtaMax) { + void fillProcesMcRecoPhotonPcmPair(auto const& collisions, auto const& triggers, auto const& photonPcmPairs) { + for (auto const& collision : collisions) { + // event selection + if (!totalEvSel(collision)) { continue; } - // standard particles (marked physical primary) - if (mcParticle.isPhysicalPrimary()) { - // charged - // hadrons - if (checkChargedMc(mcParticle)) { - fillResolvedCorrectionHists(mcCollision, mcParticle); + // group collision + auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); + auto const photonPcmPairsThisEvent = photonPcmPairs.sliceBy(perColPhotonPcmPairs, collision.globalIndex()); + + auto const funcPlain = [this](auto const& collision, auto const& associated) { + // reco assoc selection + if (!isSelectedAssoc(associated)) { + return; } - // pipm - if (std::abs(mcParticle.pdgCode()) == PDG_t::kPiPlus) { - fillResolvedCorrectionHists(mcCollision, mcParticle); - continue; + + HistFillInfoPlainPt histFillInfo = {collision.ptMax(), associated.pt()}; + fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); + }; + corrProcessPlain(collision, photonPcmPairsThisEvent, funcPlain); + + auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { + // reco assoc selection + if (!isSelectedAssoc(associated)) { + return; } - // non charged - // photons - if (mcParticle.pdgCode() == PDG_t::kGamma) { - fillResolvedCorrectionHists(mcCollision, mcParticle); - continue; + // exclude self correlation + if (isRecoSelfTrigger(trigger, associated)) { + return; } - continue; - } - // decaying particles (not marked physical primary) - if (!checkDecayPrimary(mcParticle)) { - continue; - } - // pi0 - if (mcParticle.pdgCode() == PDG_t::kPi0) { - histos.fill(HIST("mc/correction/h2_ptTrigPtAssoc_true_pi0"), mcCollision.ptMax(), mcParticle.pt()); - continue; - } - // eta - if (mcParticle.pdgCode() == constants::physics::Pdg::kEta) { - histos.fill(HIST("mc/correction/h2_ptTrigPtAssoc_true_eta"), mcCollision.ptMax(), mcParticle.pt()); + HistFillInfoCorr histFillInfo = {getDeltaPhi(trigger.phi(), associated.phi()), trigger.eta() - associated.eta(), + trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; + histFillInfo.weight = triggerPtCorrection(trigger.pt()); + fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); + }; + corrProcessCorrelation(collision, triggersThisEvent, photonPcmPairsThisEvent, funcCorrelation); + + // select mixing events + if (doTrigEvMixing && !collision.trigEv()) { continue; } + + auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { + // reco assoc selection + if (!isSelectedAssoc(associated)) { + return; + } + + HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), + mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; + histFillInfo.weight = perTriggerWeight * triggerPtCorrection(mixingTrigger.pt()); + fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); + }; + corrProcessMixing(collision, photonPcmPairsThisEvent, funcMixing, nMixingAt0PhotonPcmPair); } } - PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueCorrection, "process mc true data to calculate corrections", false); - void processPCMDCAzTrue(CorrMcDCollision const& collision, aod::PhotonPCMs const& photonPCMs, aod::V0PhotonsKF const&, aod::JetTracksMCD const&, - CorrMcCollisions const&, aod::JetParticles const&) + void processMcRecoPhotonPcmPair(CorrCollisions const& collisions, aod::Triggers const& triggers, PhotonPcmPairsWithV0 const& photonPcmPairs, + aod::V0PhotonsKF const&, aod::V0Legs const&) + { + fillProcesMcRecoPhotonPcmPair(collisions, triggers, photonPcmPairs); + } + PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoPhotonPcmPair, "process correlation for associated photonPcmPair with additional mc information", false); + + void processMcRecoPhotonPcmPairParentAccess(CorrCollisions const& collisions, aod::Triggers const& triggers, + soa::Join const& photonPcmPairs, + aod::V0PhotonsKF const&, aod::V0Legs const&, + aod::JetTracksMCD const&, aod::JetParticles const&) + { + fillProcesMcRecoPhotonPcmPair(collisions, triggers, photonPcmPairs); + } + PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoPhotonPcmPairParentAccess, "process correlation for associated photonPcmPair with additional mc information and parent access", false); + + // other //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + + void processPcmDcaZTrue(CorrCollisionsMcD::iterator const& collision, soa::Join const& photonPcms, + aod::V0PhotonsKF const&, aod::V0Legs const&, aod::JetTracksMCD const&, CorrMcCollisions const&, aod::JetParticles const&) { // event selection if (!totalEvSel(collision)) { return; } - for (auto const& photonPCM : photonPCMs) { - // check mc - auto const& posTrack = photonPCM.posJetTrack_as(); - auto const& negTrack = photonPCM.negJetTrack_as(); - if (!posTrack.has_mcParticle() || !negTrack.has_mcParticle()) { + for (auto const& photonPcm : photonPcms) { + // reco assoc selection + if (!isSelectedAssoc(photonPcm)) { + continue; + } + if (!checkTruthLevelReco(photonPcm)) { continue; } + // check mc + auto const& posTrack = photonPcm.posJetTrack_as(); + auto const& negTrack = photonPcm.negJetTrack_as(); // collision association - if (posTrack.mcParticle().mcCollisionId() != collision.mcCollisionId() || negTrack.mcParticle().mcCollisionId() != collision.mcCollisionId()) { + if (posTrack.mcParticle().mcCollisionId() != collision.jetMcCollisionId() || negTrack.mcParticle().mcCollisionId() != collision.jetMcCollisionId()) { continue; } - histos.fill(HIST("mc/plain/h5_ptTrigPtAssocDCAzZPvMult_photonPCM"), - collision.ptMax(), photonPCM.pt(), photonPCM.v0PhotonKF().dcaZtopv(), collision.posZ(), collision.nGlobalTracks()); + histos.fill(HIST("mc/plain/h5_ptTrigPtAssocDcaZZPvMult_photonPcm"), + collision.ptMax(), photonPcm.pt(), photonPcm.v0PhotonKF().dcaZtopv(), collision.posZ(), collision.nGlobalTracks()); } } - PROCESS_SWITCH(HadronPhotonCorrelation, processPCMDCAzTrue, "process to test true DCAz distribution of photons in trigger collisions", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processPcmDcaZTrue, "process to test true dcaZ distribution of photons in trigger collisions", false); // last ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -2423,8 +2419,7 @@ struct HadronPhotonCorrelation { } histos.fill(HIST("reco/info/h1_nEvents"), 2.5); - histos.fill(HIST("reco/info/h3_ptTrigZPvMult"), collision.ptMax(), collision.posZ(), collision.nGlobalTracks()); - histos.fill(HIST("reco/info/h2_ptTrigOccupancy"), collision.ptMax(), collision.trackOccupancyInTimeRange()); + histos.fill(HIST("reco/info/h3_nEv_ptTrigZPvMult_reco"), collision.ptMax(), collision.posZ(), collision.nGlobalTracks()); // group collision auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); @@ -2433,7 +2428,7 @@ struct HadronPhotonCorrelation { for (auto const& trigger : triggersThisEvent) { // trigger info histos.fill(HIST("reco/corr/h3_ptPhiEta_trig"), trigger.pt(), trigger.phi(), trigger.eta(), - getPtCorrection(trigger.pt())); + triggerPtCorrection(trigger.pt())); // save trigger for mixing triggerMemoryReco->saveTrigger(trigger.pt(), trigger.phi(), trigger.eta(), collision.posZ(), collision.nGlobalTracks()); @@ -2442,9 +2437,12 @@ struct HadronPhotonCorrelation { } PROCESS_SWITCH(HadronPhotonCorrelation, processRecoLast, "process general info for reconstructed collisions and later correlations last", true); - void processMcLast(CorrMcDCollisions const& collisions, aod::Triggers const& triggers, aod::JetTracksMCD const&, - CorrMcCollisions const& mcCollisions, aod::TriggerParticles const& triggerParticles, aod::JetParticles const&) + void processMcLast(CorrCollisionsMcD const& collisions, soa::Join const& triggers, aod::JetTracksMCD const&, + CorrMcCollisions const& mcCollisions, aod::TrueTriggers const& trueTriggers, aod::JetParticles const&) { + // do at end of each data frame (after other mc correlation process functions) + // (PROCESS_SWITCH of this process has to be declared last) + for (auto const& mcCollision : mcCollisions) { // event selection if (!totalEvSel(mcCollision)) { @@ -2452,17 +2450,17 @@ struct HadronPhotonCorrelation { } // group collision - auto const triggerParticlesThisEvent = triggerParticles.sliceBy(perColTriggerParticles, mcCollision.globalIndex()); + auto const trueTriggersThisEvent = trueTriggers.sliceBy(perColTrueTriggers, mcCollision.globalIndex()); - histos.fill(HIST("mc/info/h3_ptTrigZPvMult_true"), mcCollision.ptMax(), mcCollision.posZ(), mcCollision.nChargedInEtaRange()); + histos.fill(HIST("mc/info/h3_nEv_ptTrigZPvMult_true"), mcCollision.ptMax(), mcCollision.posZ(), mcCollision.nChargedInEtaRange()); // trigger loop - for (auto const& trigger : triggerParticlesThisEvent) { + for (auto const& trueTrigger : trueTriggersThisEvent) { // trigger info - histos.fill(HIST("mc/corr/h3_ptPhiEta_trig_true"), trigger.pt(), trigger.phi(), trigger.eta()); + histos.fill(HIST("mc/corr/h3_ptPhiEta_trig_true"), trueTrigger.pt(), trueTrigger.phi(), trueTrigger.eta()); // save trigger for mixing - triggerMemoryTrue->saveTrigger(trigger.pt(), trigger.phi(), trigger.eta(), mcCollision.posZ(), mcCollision.nChargedInEtaRange()); + triggerMemoryTrue->saveTrigger(trueTrigger.pt(), trueTrigger.phi(), trueTrigger.eta(), mcCollision.posZ(), mcCollision.nChargedInEtaRange()); } } for (auto const& collision : collisions) { @@ -2471,25 +2469,31 @@ struct HadronPhotonCorrelation { continue; } - auto const& mcCollision = collision.mcCollision_as(); + if (!isMcMatchedCollision(collision)) { + histos.fill(HIST("mc/info/h1_pt_noMatch_event"), 0.5); + continue; + } + + auto const& mcCollision = collision.jetMcCollision_as(); // group collision - auto const triggerParticlesThisEvent = triggerParticles.sliceBy(perColTriggerParticles, mcCollision.globalIndex()); + auto const trueTriggersThisEvent = trueTriggers.sliceBy(perColTrueTriggers, mcCollision.globalIndex()); auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); - histos.fill(HIST("mc/info/h3_ptTrigZPvMult_trueAssocEv"), mcCollision.ptMax(), mcCollision.posZ(), mcCollision.nChargedInEtaRange()); - histos.fill(HIST("mc/info/h3_ptTrigZPvMult_trueAssocEvRecoPtTrig"), collision.ptMax(), mcCollision.posZ(), mcCollision.nChargedInEtaRange()); + histos.fill(HIST("mc/info/h3_nEv_ptTrigZPvMult_trueAssocEv"), mcCollision.ptMax(), mcCollision.posZ(), mcCollision.nChargedInEtaRange()); + histos.fill(HIST("mc/info/h3_nEv_ptTrigZPvMult_trueAssocEvRecoPtTrig"), collision.ptMax(), mcCollision.posZ(), mcCollision.nChargedInEtaRange()); // trigger loops - for (auto const& triggerParticle : triggerParticlesThisEvent) { + for (auto const& trueTrigger : trueTriggersThisEvent) { // trigger info - histos.fill(HIST("mc/corr/h3_ptPhiEta_trig_trueAssocEv"), triggerParticle.pt(), triggerParticle.phi(), triggerParticle.eta()); + histos.fill(HIST("mc/corr/h3_ptPhiEta_trig_trueAssocEv"), trueTrigger.pt(), trueTrigger.phi(), trueTrigger.eta()); // save trigger for mixing - triggerMemoryTrueAssocEv->saveTrigger(triggerParticle.pt(), triggerParticle.phi(), triggerParticle.eta(), mcCollision.posZ(), mcCollision.nChargedInEtaRange()); + triggerMemoryTrueAssocEv->saveTrigger(trueTrigger.pt(), trueTrigger.phi(), trueTrigger.eta(), mcCollision.posZ(), mcCollision.nChargedInEtaRange()); } for (auto const& trigger : triggersThisEvent) { - if (!trigger.jetTrack_as().has_mcParticle()) { + if (!isMcMatchedTrigger(trigger)) { + histos.fill(HIST("mc/info/h1_pt_noMatch_trigger"), trigger.pt()); continue; } diff --git a/PWGJE/Tasks/hadronPhotonProducer.cxx b/PWGJE/Tasks/hadronPhotonProducer.cxx index dcbe82f5b11..17605d09aab 100644 --- a/PWGJE/Tasks/hadronPhotonProducer.cxx +++ b/PWGJE/Tasks/hadronPhotonProducer.cxx @@ -11,9 +11,9 @@ /// \file hadronPhotonProducer.cxx /// \author Julius Kinner -/// \brief photon-jet angular correlation table producer +/// \brief hadron-photon angular correlation table producer /// -/// Table producer for photon-jet angular correlation analysis (see photonChargedTriggerCorrelation.cxx) +/// Table producer for hadron-photon angular correlation analysis #include "PWGJE/Core/JetDerivedDataUtilities.h" #include "PWGJE/DataModel/Jet.h" @@ -23,6 +23,7 @@ #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" #include "Common/Core/RecoDecay.h" +#include "Common/Core/TableHelper.h" #include "Common/DataModel/PIDResponseTOF.h" #include "Common/DataModel/PIDResponseTPC.h" @@ -41,10 +42,15 @@ #include // IWYU pragma: keep (do not replace with Math/Vector4Dfwd.h) #include +#include +#include #include #include +#include +#include #include +#include #include #include @@ -54,56 +60,71 @@ using namespace o2::framework; // correlation derived data =================================================================================================================================================================== template -concept IsJetMcCollision = std::same_as, aod::JetMcCollision>; +concept IsCollisionMCD = requires(T& collision) { collision.mcCollision(); }; template -concept IsJetCollisionMCD = std::same_as, aod::JetCollisionMCD>; -template -concept HasTrueCollision = IsJetMcCollision || IsJetCollisionMCD; +concept IsMcCollision = requires(T& collision) { collision.getGeneratorId(); }; struct HadronPhotonProducer { struct : ProducesGroup { // reco - Produces collisionExtraCorr; + Produces corrCollision; + Produces corrCollisionId; + Produces corrCollisionMcId; Produces trigger; + Produces triggerTrackId; Produces hadron; + Produces hadronTrackId; Produces pipm; - Produces photonPCM; - Produces photonPCMPair; - // mc + Produces pipmTrackId; + Produces photonPcm; + Produces photonPcmTrackId; + Produces photonPcmV0PhotonId; + Produces photonPcmPair; + Produces photonPcmPairTrackId; + Produces photonPcmPairV0PhotonId; + // true Produces mcCollisionExtraCorr; - Produces triggerParticle; + Produces trueTrigger; } tableProduction; Configurable zPvMax{"zPvMax", 7, "maximum absZ primary-vertex cut"}; Configurable occupancyMin{"occupancyMin", 0, "minimum occupancy cut"}; Configurable occupancyMax{"occupancyMax", 2000, "maximum occupancy cut"}; - Configurable absEtaMax{"absEtaMax", 0.8, "maximum absEta cut"}; Configurable eventSelections{"eventSelections", "sel8", "JE framework - event selection"}; Configurable skipMBGapEvents{"skipMBGapEvents", true, "skip MB gap events"}; Configurable applyRctSelection{"applyRctSelection", true, "apply RCT selection"}; - Configurable rctLabel{"rctLabel", "CBT_hadronPID", "RCT selection label"}; + Configurable rctLabel{"rctLabel", "CBT_hadronPid", "RCT selection label"}; Configurable trackSelections{"trackSelections", "globalTracks", "JE framework - track selections"}; Configurable triggerMasks{"triggerMasks", "", "JE framework - skimmed data trigger masks (relevent for correlation: fTrackLowPt,fTrackHighPt)"}; - Configurable piPIDLowPt{"piPIDLowPt", 0.5, "max pt value for pipm PID without tof"}; - Configurable piPIDHighPt{"piPIDHighPt", 2.5, "min pt value for pipm PID without tof in relativistic rise of Bethe-Bloch"}; + Configurable ptMinHadron{"ptMinHadron", 0.1, "min pt value for hadrons"}; + + Configurable piPidLowPt{"piPidLowPt", 0.5, "max pt value for pipm pid without tof"}; + Configurable piPidHighPt{"piPidHighPt", 2.5, "min pt value for pipm pid without tof in relativistic rise of Bethe-Bloch"}; Configurable> nSigmaPiTpcLowPt{"nSigmaPiTpcLowPt", {-2, 2}, "minimum-maximum nSigma for pipm in tpc at low pt"}; Configurable> nSigmaPiTpcMidPt{"nSigmaPiTpcMidPt", {-1, 1}, "minimum-maximum nSigma for pipm in tpc at mid pt"}; Configurable> nSigmaPiTof{"nSigmaPiTof", {-1, 2}, "minimum-maximum nSigma for pipm in tof"}; Configurable> nSigmaPiRelRise{"nSigmaPiRelRise", {0, 2}, "minimum-maximum nSigma pipm tpc at high pt"}; - Configurable> pcmAbsDcaZLim{"pcmAbsDcaZLim", {0, 5}, "absolute values of DCAz limits for PCM"}; + Configurable> pcmAbsDcaZLim{"pcmAbsDcaZLim", {0, 5}, "absolute values of dcaZ limits for pcm"}; - Configurable ptTrigMin{"ptTrigMin", 5, "minimum pT of triggers"}; Configurable oneTriggerPerEvent{"oneTriggerPerEvent", false, "use only one trigger (of highest pt) in an event"}; + // configurables from other tasks + + double absEtaMax = -1; + double ptTrigMin = -1; + // derivatives of configurables std::vector eventSelectionBits; int trackSelection = -1; std::vector triggerMaskBits; + // map jetTracks to produced triggers + std::map trackToTriggerMap; + HistogramRegistry histos{"histogramRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; // for mc @@ -119,11 +140,23 @@ struct HadronPhotonProducer { // functions ================================================================================================================================================================================ + // get v0 leg tracks {posTrack, negTrack} as jet tracks via JTrackPI. throws in case of problems + auto getV0LegJetTracks(auto const& v0Photon, auto const& tracks) { + auto const posTrack = tracks.rawIteratorAt(v0Photon.posTrack().trackId() - tracks.offset()); + auto const negTrack = tracks.rawIteratorAt(v0Photon.negTrack().trackId() - tracks.offset()); + // check index match + if (posTrack.trackId() != v0Photon.posTrack().trackId() || negTrack.trackId() != v0Photon.negTrack().trackId()) { + throw std::runtime_error("v0Photon legs not correctly matched to jetTracks"); + } + return std::tuple(posTrack, negTrack); + } + // selections /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // reco only -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + // event selection - template - bool checkEventSelection(T_collision const& collision) + bool checkEventSelection(auto const& collision) { if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { return false; @@ -140,44 +173,27 @@ struct HadronPhotonProducer { return true; } - // mc split event selection based in the thrid decimal of mc-true posZ - template - int getThirdDecimalTruePosZ(T_collision const& collision) - { - // get third decimal - double absPosZ = -1; - if constexpr (IsJetCollisionMCD) { - absPosZ = std::abs(collision.template mcCollision_as().posZ()); - } else { - absPosZ = std::abs(collision.posZ()); - } - int const thirdDecimalPosZ = static_cast(1000 * absPosZ) % 10; - return thirdDecimalPosZ; - } - - // checks global track cuts - template - bool checkGlobalTrackEta(T_track const& track) + // checks track cuts (wow, such explanation) + bool checkTrackCuts(auto const& track) { if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { return false; } - if (!jetderiveddatautilities::applyTrackKinematics(track, 0.1, 1000, -1 * absEtaMax, absEtaMax)) { + if (!jetderiveddatautilities::applyTrackKinematics(track, ptMinHadron, 1000, -1 * absEtaMax, absEtaMax)) { return false; } return true; } - // checks pipm selection (just PID (no additional track cuts)) - template - bool checkPipmTPCTOF(T_track const& track) + // checks pipm selection (just pid (no additional track cuts) + bool checkPipmTPCTOF(auto const& track) { // too low for tof - if (track.pt() < piPIDLowPt) { + if (track.pt() < piPidLowPt) { return (track.tpcNSigmaPi() > nSigmaPiTpcLowPt.value[0] && track.tpcNSigmaPi() < nSigmaPiTpcLowPt.value[1]); } // Bethe-Bloch overlap (-> tpc + tof) - if (track.pt() < piPIDHighPt) { + if (track.pt() < piPidHighPt) { if (track.hasTOF()) { // has to stay inside pt-if due to return-layout of function if (track.tpcNSigmaPi() > nSigmaPiTpcMidPt.value[0] && track.tpcNSigmaPi() < nSigmaPiTpcMidPt.value[1] && track.tofNSigmaPi() > nSigmaPiTof.value[0] && track.tofNSigmaPi() < nSigmaPiTof.value[1]) { @@ -190,12 +206,11 @@ struct HadronPhotonProducer { return (track.tpcNSigmaPi() > nSigmaPiRelRise.value[0] && track.tpcNSigmaPi() < nSigmaPiRelRise.value[1]); } - // checks pipm selection (just PID (no additional track cuts)) - template - bool checkPipmTPC(T_track const& track) + // checks pipm selection (just pid (no additional track cuts)) + bool checkPipmTPC(auto const& track) { // Bethe-Bloch rel rise - if (track.pt() > piPIDHighPt) { + if (track.pt() > piPidHighPt) { if (track.tpcNSigmaPi() > nSigmaPiRelRise.value[0] && track.tpcNSigmaPi() < nSigmaPiRelRise.value[1]) { return true; } @@ -203,277 +218,596 @@ struct HadronPhotonProducer { return false; } + // reco MC ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + // checks if mcParticle is charged + bool isCharged(auto const& mcParticle) + { + auto const pdgParticle = pdg->GetParticle(mcParticle.pdgCode()); + return pdgParticle && pdgParticle->Charge() != 0; + } + // checks if fast decaying mcParticle is 'primary' + bool isDecayPrimary(auto const& mcParticle) + { + // identify decaying primary + return mcParticle.producedByGenerator(); + } + + // checks if tracks come from photon conversion + template + bool isConversionPhoton(T_track const& posTrack, T_track const& negTrack) + { + auto const& posParticle = posTrack.mcParticle(); + auto const& negParticle = negTrack.mcParticle(); + if (!posParticle.has_mothers() || !negParticle.has_mothers()) { + return false; + } + // check same mother + auto const& posMothers = posParticle.template mothers_as(); + auto const& negMothers = negParticle.template mothers_as(); + if (posMothers.begin()->globalIndex() != negMothers.begin()->globalIndex()) { + return false; + } + // check photon + if (posMothers.begin()->pdgCode() != PDG_t::kGamma) { + return false; + } + + return true; + }; + // checks if tracks come from double conversion + template + bool isGGFromDoubleConversion(T_track const& posTrack1, T_track const& negTrack1, T_track const& posTrack2, T_track const& negTrack2, int const pdgCode) + { + // check conversion + if (!isConversionPhoton(posTrack1, negTrack1) || !isConversionPhoton(posTrack2, negTrack2)) { + return false; + } + auto const& photons1 = posTrack1.mcParticle().template mothers_as(); + auto const& photons2 = posTrack2.mcParticle().template mothers_as(); + if (!photons1.begin()->has_mothers() || !photons2.begin()->has_mothers()) { + return false; + } + auto const& mothers1 = photons1.begin()->template mothers_as(); + auto const& mothers2 = photons2.begin()->template mothers_as(); + // check same mother of photons + if (mothers1.begin()->globalIndex() != mothers2.begin()->globalIndex()) { + return false; + } + // check particle type + if (mothers1.begin()->pdgCode() != pdgCode) { + return false; + } + + return true; + }; + + // get highest reco truthLevel particle canidate + + template + std::tuple getTruthLevelRecoHadronPipm(auto const& collision, auto const& track) { + if (!track.has_mcParticle()) { + return {TruthLevel::Reco, -1}; + } + auto const& mcParticle = track.mcParticle(); + double const ptTrue = mcParticle.pt(); + if (mcParticle.mcCollisionId() != collision.mcCollisionId()) { + return {TruthLevel::RecoMcMatched, ptTrue}; + } + if constexpr (AssocTypeV == AssocType::Hadron) { + if (!isCharged(mcParticle) || !mcParticle.isPhysicalPrimary()) { + return {TruthLevel::RecoAssocEv, ptTrue}; + } + } else if constexpr (AssocTypeV == AssocType::Pipm) { + if (std::abs(mcParticle.pdgCode()) != PDG_t::kPiPlus || !mcParticle.isPhysicalPrimary()) { + return {TruthLevel::RecoAssocEv, ptTrue}; + } + } else { + static_assert(AlwaysFalseValue, "assocType not found"); + } + return {TruthLevel::RecoPure, ptTrue}; + } + std::tuple getTruthLevelRecoPhoton(auto const& collision, auto const& v0Photon, auto const& tracks) { + auto const [posTrack, negTrack] = getV0LegJetTracks(v0Photon, tracks); + if (!posTrack.has_mcParticle() || !negTrack.has_mcParticle()) { + return {TruthLevel::Reco, -1}; + } + if (posTrack.mcParticle().mcCollisionId() != collision.mcCollisionId() || negTrack.mcParticle().mcCollisionId() != collision.mcCollisionId()) { + return {TruthLevel::RecoMcMatched, -1}; + } + auto const& photons = posTrack.mcParticle().template mothers_as(); + if (!isConversionPhoton(posTrack, negTrack) || !photons.begin()->isPhysicalPrimary()) { + return {TruthLevel::RecoAssocEv, -1}; + } + double const ptTrue = photons.begin()->pt(); + return {TruthLevel::RecoPure, ptTrue}; + } + template + std::tuple getTruthLevelRecoDiPhoton(auto const& collision, auto const& v0Photon1, auto const& v0Photon2, auto const& tracks) { + int constexpr PdgCode = []() { + if constexpr (AssocTypeV == AssocType::Pi0Pcm) { + return PDG_t::kPi0; + } else if constexpr (AssocTypeV == AssocType::EtaPcm) { + return constants::physics::Pdg::kEta; + } else { + static_assert(AlwaysFalseValue, "assocType not found"); + } + }(); + auto const [posTrack1, negTrack1] = getV0LegJetTracks(v0Photon1, tracks); + auto const [posTrack2, negTrack2] = getV0LegJetTracks(v0Photon2, tracks); + if (!posTrack1.has_mcParticle() || !negTrack1.has_mcParticle() || !posTrack2.has_mcParticle() || !negTrack2.has_mcParticle()) { + return {TruthLevel::Reco, -1}; + } + if (!isGGFromDoubleConversion(posTrack1, negTrack1, posTrack2, negTrack2, PdgCode)) { + return {TruthLevel::RecoMcMatched, -1}; + } + if (posTrack1.mcParticle().mcCollisionId() != collision.mcCollisionId()) { + return {TruthLevel::PseudoReco, -1}; + } + auto const& photons1 = posTrack1.mcParticle().template mothers_as(); + auto const& mothersOfPhoton = photons1.begin()->template mothers_as(); + if (!isDecayPrimary(*(mothersOfPhoton.begin()))) { + return {TruthLevel::PseudoRecoAssocEv, -1}; + } + double const ptTrue = mothersOfPhoton.begin()->pt(); + return {TruthLevel::PseudoRecoPure, ptTrue}; + } + + // other ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + + // mc split event selection based in the thrid decimal of mc-true posZ + int getThirdDecimalTruePosZ(auto const& collision) + { + double absPosZ; + + // get third decimal + if constexpr (IsCollisionMCD) { + if (!collision.has_mcCollision()) { + return -1; + } + absPosZ = std::abs(collision.template mcCollision_as().posZ()); + } else if constexpr (IsMcCollision) { + absPosZ = std::abs(collision.posZ()); + } else { + static_assert(AlwaysFalseType, "collision type not allowed"); + } + int const thirdDecimalPosZ = static_cast(1000 * absPosZ) % 10; + + return thirdDecimalPosZ; + } + // analysis ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void init(InitContext const&) + void init(InitContext& initContext) { - eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(eventSelections); - trackSelection = jetderiveddatautilities::initialiseTrackSelection(trackSelections); + // selection JE utilities + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); + trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); + // get variables from other tasks + if (!common::core::getTaskOptionValue(initContext, "hadron-photon-correlation", "absEtaMax", absEtaMax, false)) { + throw std::runtime_error("absEtaMax not set"); + }; + if (!common::core::getTaskOptionValue(initContext, "hadron-photon-correlation", "ptTrigMin", ptTrigMin, false)) { + throw std::runtime_error("ptTrigMin not set"); + } + // histograms - AxisSpec const axisZPv{28, -7, 7, "#it{z}_{pv}"}; - AxisSpec const axisMult{65, -0.5, 64.5, "multiplicity"}; + AxisSpec const axisZPv{40, -10, 10, "#it{z}_{pv}"}; + AxisSpec const axisMult{101, -0.5, 100.5, "multiplicity"}; AxisSpec const axisHadronicRate{1001, -0.5, 1000.5, "hadronicRate"}; - AxisSpec const axisPt{50, 0, 25, "#it{p}_{T}"}; + AxisSpec const axisPt{200, 0, 100, "#it{p}_{T}"}; AxisSpec const axisPhi{72, 0, constants::math::TwoPI, "#varphi"}; - AxisSpec const axisEta{32, -absEtaMax, absEtaMax, "#eta"}; + AxisSpec const axisEta{64, -absEtaMax, absEtaMax, "#eta"}; + AxisSpec const axisMgg{240, 0, 0.8, "#it{m}_{#gamma#gamma}"}; // reco - histos.add("reco/h2_zPvMult", "h2_zPvMult", kTHnSparseD, {axisZPv, axisMult}, true); + histos.add("reco/h2_zPvMult", "h2_zPvMult", kTH2D, {axisZPv, axisMult}, true); histos.add("reco/h1_hadronicRate", "h1_hadronicRate", kTH1D, {axisHadronicRate}, true); - histos.add("reco/h3_ptPhiEta_trigger", "h3_ptPhiEta_trigger", kTHnSparseD, {axisPt, axisPhi, axisEta}, true); - histos.add("reco/h3_ptPhiEta_hadron", "h3_ptPhiEta_hadron", kTHnSparseD, {axisPt, axisPhi, axisEta}, true); - histos.add("reco/h3_ptPhiEta_pipm", "h3_ptPhiEta_pipm", kTHnSparseD, {axisPt, axisPhi, axisEta}, true); - histos.add("reco/h3_ptPhiEta_photonPCM", "h3_ptPhiEta_photonPCM", kTHnSparseD, {axisPt, axisPhi, axisEta}, true); - histos.add("reco/h3_ptPhiEta_photonPCMPair", "h3_ptPhiEta_photonPCMPair", kTHnSparseD, {axisPt, axisPhi, axisEta}, true); + histos.add("reco/h3_ptPhiEta_trigger", "h3_ptPhiEta_trigger", kTH3D, {axisPt, axisPhi, axisEta}, true); + histos.add("reco/h3_ptPhiEta_hadron", "h3_ptPhiEta_hadron", kTH3D, {axisPt, axisPhi, axisEta}, true); + histos.add("reco/h3_ptPhiEta_pipm", "h3_ptPhiEta_pipm", kTH3D, {axisPt, axisPhi, axisEta}, true); + histos.add("reco/h3_ptPhiEta_photonPcm", "h3_ptPhiEta_photonPcm", kTH3D, {axisPt, axisPhi, axisEta}, true); + histos.add("reco/h3_ptPhiEta_photonPcmPair", "h3_ptPhiEta_photonPcmPair", kTH3D, {axisPt, axisPhi, axisEta}, true); // true - histos.add("true/h2_zPvMult", "h2_zPvMult", kTHnSparseD, {axisZPv, axisMult}, true); - histos.add("true/h3_ptPhiEta_trigger", "h3_ptPhiEta_trigger", kTHnSparseD, {axisPt, axisPhi, axisEta}, true); + histos.add("true/h2_zPvMult", "h2_zPvMult", kTH2D, {axisZPv, axisMult}, true); + histos.add("true/h3_ptPhiEta_trigger", "h3_ptPhiEta_trigger", kTH3D, {axisPt, axisPhi, axisEta}, true); } - template - void fillRecoCollisionTrigger(T_collision const& collision, T_tracks const& tracks) + void fillProcessRecoCollisionTrigger(auto const& collisions, auto const& tracks) { - // event selection - bool isSelectedEvent = checkEventSelection(collision); - // mc split event selection - // default -1 for data reconstruction - int thirdDecimalTruePosZ = -1; - if constexpr (IsJetCollisionMCD) { - thirdDecimalTruePosZ = getThirdDecimalTruePosZ(collision); - } - // maximum track pt - float maxTrackPt = -1; - int maxTriggerCollisionId = -1; - int maxTriggerGlobalIndex = -1; - float maxTriggerPhi = 0; - float maxTriggerEta = 0; - // number global tracks - int nGlobalTracks = 0; - - // count global tracks (for independence of multiplicity task (uses only JE derieved data)) - for (auto const& track : tracks) { - // track selection - if (!checkGlobalTrackEta(track)) { - continue; - } + // clear mapping at start of dataframe (in first process) + trackToTriggerMap.clear(); - nGlobalTracks++; - if (track.pt() > maxTrackPt) { - maxTrackPt = track.pt(); - maxTriggerCollisionId = track.collisionId(); - maxTriggerGlobalIndex = track.globalIndex(); - maxTriggerPhi = track.phi(); - maxTriggerEta = track.eta(); - } + for (auto const& collision : collisions) { + // event selection + bool isSelectedEvent = checkEventSelection(collision); - if (!isSelectedEvent) { - continue; + // group collision + auto const tracksThisEvent = tracks.sliceBy(perColTracks, collision.globalIndex()); + + // mc split event selection + // default -1 for data reconstruction + int thirdDecimalTruePosZ = -1; + if constexpr (IsCollisionMCD) { + thirdDecimalTruePosZ = getThirdDecimalTruePosZ(collision); } - if (track.pt() < ptTrigMin) { - continue; + // maximum track pt + float maxTrackPt = -1; + int maxTriggerCollisionId = -1; + int maxTriggerGlobalIndex = -1; + float maxTriggerPhi = 0; + float maxTriggerEta = 0; + // number global tracks + int nGlobalTracks = 0; + + // count global tracks (for independence of multiplicity task (uses only JE derieved data)) + for (auto const& track : tracksThisEvent) { + // track selection + if (!checkTrackCuts(track)) { + continue; + } + + nGlobalTracks++; + if (track.pt() > maxTrackPt) { + maxTrackPt = track.pt(); + maxTriggerCollisionId = track.collisionId(); + maxTriggerGlobalIndex = track.globalIndex(); + maxTriggerPhi = track.phi(); + maxTriggerEta = track.eta(); + } + + if (!isSelectedEvent) { + continue; + } + if (track.pt() < ptTrigMin) { + continue; + } + if (oneTriggerPerEvent) { + continue; + } + + // trigger info + histos.fill(HIST("reco/h3_ptPhiEta_trigger"), track.pt(), track.phi(), track.eta()); + tableProduction.trigger(track.collisionId(), + track.pt(), track.phi(), track.eta()); + tableProduction.triggerTrackId(track.globalIndex()); + trackToTriggerMap[track.globalIndex()] = tableProduction.trigger.lastIndex(); } - if (oneTriggerPerEvent) { - continue; + bool const isTriggerEvent = maxTrackPt > ptTrigMin; + if (oneTriggerPerEvent && isSelectedEvent && isTriggerEvent) { + histos.fill(HIST("reco/h3_ptPhiEta_trigger"), maxTrackPt, maxTriggerPhi, maxTriggerEta); + tableProduction.trigger(maxTriggerCollisionId, + maxTrackPt, maxTriggerPhi, maxTriggerEta); + tableProduction.triggerTrackId(maxTriggerGlobalIndex); + trackToTriggerMap[maxTriggerGlobalIndex] = tableProduction.trigger.lastIndex(); } - // trigger info - histos.fill(HIST("reco/h3_ptPhiEta_trigger"), track.pt(), track.phi(), track.eta()); - tableProduction.trigger(track.collisionId(), track.globalIndex(), track.pt(), track.phi(), track.eta()); - } - bool const isTriggerEvent = maxTrackPt > ptTrigMin; - if (oneTriggerPerEvent && isSelectedEvent && isTriggerEvent) { - histos.fill(HIST("reco/h3_ptPhiEta_trigger"), maxTrackPt, maxTriggerPhi, maxTriggerEta); - tableProduction.trigger(maxTriggerCollisionId, maxTriggerGlobalIndex, maxTrackPt, maxTriggerPhi, maxTriggerEta); + // collision info + histos.fill(HIST("reco/h2_zPvMult"), collision.posZ(), nGlobalTracks); + histos.fill(HIST("reco/h1_hadronicRate"), collision.hadronicRate()); + tableProduction.corrCollision(isSelectedEvent, thirdDecimalTruePosZ, isTriggerEvent, maxTrackPt, collision.posZ(), nGlobalTracks); + tableProduction.corrCollisionId(collision.globalIndex()); + // mc true collsion label + if constexpr (IsCollisionMCD) { + tableProduction.corrCollisionMcId(collision.mcCollisionId()); + } } - - // collision info - histos.fill(HIST("reco/h2_zPvMult"), collision.posZ(), nGlobalTracks); - histos.fill(HIST("reco/h1_hadronicRate"), collision.hadronicRate()); - tableProduction.collisionExtraCorr(isSelectedEvent, thirdDecimalTruePosZ, isTriggerEvent, maxTrackPt, nGlobalTracks); } - void processRecoCollisionTrigger(aod::JetCollision const& collision, aod::JetTracks const& tracks) + void processRecoCollisionTrigger(soa::Join const& collisions, aod::JetTracks const& tracks) { - fillRecoCollisionTrigger(collision, tracks); + fillProcessRecoCollisionTrigger(collisions, tracks); } PROCESS_SWITCH(HadronPhotonProducer, processRecoCollisionTrigger, "process correlation collision_extra and trigger table (reconstructed)", false); - void processMcRecoCollisionTrigger(aod::JetCollisionMCD const& collision, aod::JetTracks const& tracks, aod::JetMcCollisions const&) + void processMcRecoCollisionTrigger(soa::Join const& collisions, aod::JetTracks const& tracks, aod::JetMcCollisions const&) { - fillRecoCollisionTrigger(collision, tracks); + fillProcessRecoCollisionTrigger(collisions, tracks); } PROCESS_SWITCH(HadronPhotonProducer, processMcRecoCollisionTrigger, "process correlation collision_extra and trigger table (reconstructed MC)", false); - void processRecoPipmTPCTOF(aod::JetCollision const& collision, - soa::Join const& tracks, soa::Join const&) + template + void fillProcessRecoHadronPipm(auto const& collisions, auto const& tracks) { - // event selection - if (!checkEventSelection(collision)) { - return; - } - - // hadron/pipm - for (auto const& track : tracks) { - // track selection - if (!checkGlobalTrackEta(track)) { + for (auto const& collision : collisions) { + // event selection + if (!checkEventSelection(collision)) { continue; } - // hadron - histos.fill(HIST("reco/h3_ptPhiEta_hadron"), track.pt(), track.phi(), track.eta()); - tableProduction.hadron(track.collisionId(), track.globalIndex(), track.pt(), track.phi(), track.eta()); + // group collision + auto const tracksThisEvent = tracks.sliceBy(perColTracks, collision.globalIndex()); - // pipm selection - auto const& trackPID = track.track_as>(); - if (!checkPipmTPCTOF(trackPID)) { - continue; - } + // hadron/pipm + for (auto const& track : tracksThisEvent) { + std::vector intersectTriggerIds; - // pipm - histos.fill(HIST("reco/h3_ptPhiEta_pipm"), track.pt(), track.phi(), track.eta()); - tableProduction.pipm(track.collisionId(), track.globalIndex(), track.pt(), track.phi(), track.eta()); + // track selection + if (!checkTrackCuts(track)) { + continue; + } + + // get possible overlap with triggers + auto const triggerTrackIt = trackToTriggerMap.find(track.globalIndex()); + if (triggerTrackIt != trackToTriggerMap.end()) { + intersectTriggerIds.push_back(triggerTrackIt->second); + } + + // truthLevel and ptTrue + auto const [truthLevelHadron, truePtHadron] = [&] { + if constexpr (IsCollisionMCD) { + return getTruthLevelRecoHadronPipm(collision, track); + } else { + return std::tuple{TruthLevel::None, -1}; + } + }(); + + // hadron info + histos.fill(HIST("reco/h3_ptPhiEta_hadron"), track.pt(), track.phi(), track.eta()); + tableProduction.hadron(track.collisionId(), intersectTriggerIds, + track.pt(), track.phi(), track.eta(), + static_cast(truthLevelHadron), truePtHadron); + tableProduction.hadronTrackId(track.globalIndex()); + + // pipm selection + auto const& trackPid = track.template track_as(); + if constexpr (requires { trackPid.tofNSigmaPi(); }) { + if (!checkPipmTPCTOF(trackPid)) { + continue; + } + } else { + if (!checkPipmTPC(trackPid)) { + continue; + } + } + + // truthLevel and ptTrue + auto const [truthLevelPipm, ptTruePipm] = [&] { + if constexpr (IsCollisionMCD) { + return getTruthLevelRecoHadronPipm(collision, track); + } else { + return std::tuple{TruthLevel::None, -1}; + } + }(); + + // pipm info + histos.fill(HIST("reco/h3_ptPhiEta_pipm"), track.pt(), track.phi(), track.eta()); + tableProduction.pipm(track.collisionId(), intersectTriggerIds, + track.pt(), track.phi(), track.eta(), + static_cast(truthLevelPipm), ptTruePipm); + tableProduction.pipmTrackId(track.globalIndex()); + } } } - PROCESS_SWITCH(HadronPhotonProducer, processRecoPipmTPCTOF, "process pipm (TPC-TOF) table (reconstructed)", false); - void processRecoPipmTPC(aod::JetCollision const& collision, - soa::Join const& tracks, soa::Join const&) + void processRecoHadronPipmTPCTOF(aod::JetCollisions const& collisions, + soa::Join const& tracks, soa::Join const&) { - // event selection - if (!checkEventSelection(collision)) { - return; - } + fillProcessRecoHadronPipm>(collisions, tracks); + } + PROCESS_SWITCH(HadronPhotonProducer, processRecoHadronPipmTPCTOF, "process hadron and pipm (TPC-TOF) table (reconstructed)", false); - // hadron/pipm - for (auto const& track : tracks) { - // track selection - if (!checkGlobalTrackEta(track)) { - continue; - } + void processMcRecoHadronPipmTPCTOF(aod::JetCollisionsMCD const& collisions, + soa::Join const& tracks, soa::Join const&, + aod::JetParticles const&) + { + fillProcessRecoHadronPipm>(collisions, tracks); + } + PROCESS_SWITCH(HadronPhotonProducer, processMcRecoHadronPipmTPCTOF, "process hadron and pipm (TPC-TOF) table (reconstructed MC)", false); + + void processRecoHadronPipmTPC(aod::JetCollisions const& collisions, + soa::Join const& tracks, soa::Join const&) + { + fillProcessRecoHadronPipm>(collisions, tracks); + } + PROCESS_SWITCH(HadronPhotonProducer, processRecoHadronPipmTPC, "process hadron and pipm (TPC) table (reconstructed)", false); - // hadron - histos.fill(HIST("reco/h3_ptPhiEta_hadron"), track.pt(), track.phi(), track.eta()); - tableProduction.hadron(track.collisionId(), track.globalIndex(), track.pt(), track.phi(), track.eta()); + void processMcRecoHadronPipmTPC(aod::JetCollisionsMCD const& collisions, + soa::Join const& tracks, soa::Join const&, + aod::JetParticles const&) + { + fillProcessRecoHadronPipm>(collisions, tracks); + } + PROCESS_SWITCH(HadronPhotonProducer, processMcRecoHadronPipmTPC, "process hadron and pipm (TPC) table (reconstructed MC)", false); - // pipm selection - auto const& trackPID = track.track_as>(); - if (!checkPipmTPC(trackPID)) { + void fillProcessRecoPhotonPcm(auto const& collisions, auto const& v0Photons, auto const& tracks) + { + for (auto const& collision : collisions) { + // event selection + if (!checkEventSelection(collision)) { continue; } - // pipm - histos.fill(HIST("reco/h3_ptPhiEta_pipm"), track.pt(), track.phi(), track.eta()); - tableProduction.pipm(track.collisionId(), track.globalIndex(), track.pt(), track.phi(), track.eta()); - } - } - PROCESS_SWITCH(HadronPhotonProducer, processRecoPipmTPC, "process pipm (TPC) table (reconstructed)", false); + // photonsPcm (for some reason collisionId not an index column (?)) + auto const v0PhotonsThisEvent = v0Photons.sliceBy(perColV0Photons, collision.collisionId()); - void processRecoPhotonPCM(soa::Join::iterator const& collision, - aod::V0PhotonsKF const& v0Photons, aod::V0Legs const&) - { - // event selection - if (!checkEventSelection(collision)) { - return; - } + // photonPcm + for (auto const& v0Photon : v0PhotonsThisEvent) { + std::vector intersectTriggerIds; - // photonsPCM (for some reason collsionId not an index column (?)) - auto const v0PhotonsThisEvent = v0Photons.sliceBy(perColV0Photons, collision.collisionId()); + // photon selection + if (std::abs(v0Photon.eta()) > absEtaMax) { + continue; + } + if (std::abs(v0Photon.dcaZtopv()) < pcmAbsDcaZLim.value[0] || std::abs(v0Photon.dcaZtopv()) > pcmAbsDcaZLim.value[1]) { + continue; + } - // photonPCM - for (auto const& v0Photon : v0PhotonsThisEvent) { - // photon selection - if (std::abs(v0Photon.eta()) > absEtaMax) { - continue; - } - if (std::abs(v0Photon.dcaZtopv()) < pcmAbsDcaZLim.value[0] || std::abs(v0Photon.dcaZtopv()) > pcmAbsDcaZLim.value[1]) { - continue; + // get legs and check v0Leg-jetTrack match + auto const [posTrack, negTrack] = getV0LegJetTracks(v0Photon, tracks); + + // get possible overlap with triggers + auto const triggerPosTrackIt = trackToTriggerMap.find(posTrack.globalIndex()); + if (triggerPosTrackIt != trackToTriggerMap.end()) { + intersectTriggerIds.push_back(triggerPosTrackIt->second); + } + auto const triggerNegTrackIt = trackToTriggerMap.find(negTrack.globalIndex()); + if (triggerNegTrackIt != trackToTriggerMap.end()) { + intersectTriggerIds.push_back(triggerNegTrackIt->second); + } + + // truthLevel and ptTrue + auto const [truthLevelPhotonPcm, ptTruePhotonPcm] = [&] { + if constexpr (IsCollisionMCD) { + return getTruthLevelRecoPhoton(collision, v0Photon, tracks); + } else { + return std::tuple{TruthLevel::None, -1}; + } + }(); + + // photonPcm info + histos.fill(HIST("reco/h3_ptPhiEta_photonPcm"), v0Photon.pt(), v0Photon.phi(), v0Photon.eta()); + tableProduction.photonPcm(v0Photon.collisionId(), intersectTriggerIds, + v0Photon.pt(), v0Photon.phi(), v0Photon.eta(), + static_cast(truthLevelPhotonPcm), ptTruePhotonPcm); + tableProduction.photonPcmTrackId(v0Photon.posTrack().trackId(), v0Photon.negTrack().trackId()); + tableProduction.photonPcmV0PhotonId(v0Photon.globalIndex()); } - // photon PCM - histos.fill(HIST("reco/h3_ptPhiEta_photonPCM"), v0Photon.pt(), v0Photon.phi(), v0Photon.eta()); - tableProduction.photonPCM(v0Photon.collisionId(), v0Photon.globalIndex(), - v0Photon.posTrack().trackId(), v0Photon.negTrack().trackId(), v0Photon.pt(), v0Photon.phi(), v0Photon.eta()); - } + // photonPcmPair + for (auto const& [v0Photon1, v0Photon2] : soa::combinations(soa::CombinationsStrictlyUpperIndexPolicy(v0PhotonsThisEvent, v0PhotonsThisEvent))) { + std::vector intersectTriggerIds; - // photonPCm pairs - for (auto const& [v0Photon1, v0Photon2] : soa::combinations(soa::CombinationsStrictlyUpperIndexPolicy(v0PhotonsThisEvent, v0PhotonsThisEvent))) { - // get kinematics - ROOT::Math::PtEtaPhiMVector const p4V0PCM1(v0Photon1.pt(), v0Photon1.eta(), v0Photon1.phi(), 0.); - ROOT::Math::PtEtaPhiMVector const p4V0PCM2(v0Photon2.pt(), v0Photon2.eta(), v0Photon2.phi(), 0.); - ROOT::Math::PtEtaPhiMVector const p4V0PCMPair = p4V0PCM1 + p4V0PCM2; + // get kinematics + ROOT::Math::PtEtaPhiMVector const p4V0Pcm1(v0Photon1.pt(), v0Photon1.eta(), v0Photon1.phi(), 0.); + ROOT::Math::PtEtaPhiMVector const p4V0Pcm2(v0Photon2.pt(), v0Photon2.eta(), v0Photon2.phi(), 0.); + ROOT::Math::PtEtaPhiMVector const p4V0PcmPair = p4V0Pcm1 + p4V0Pcm2; - // pi0 selection - if (std::abs(p4V0PCMPair.Eta()) > absEtaMax) { - continue; - } + // pair selection + if (std::abs(p4V0PcmPair.Eta()) > absEtaMax) { + continue; + } + + // get legs and check v0Leg-jetTrack match + auto const [posTrack1, negTrack1] = getV0LegJetTracks(v0Photon1, tracks); + auto const [posTrack2, negTrack2] = getV0LegJetTracks(v0Photon2, tracks); - // save info - histos.fill(HIST("reco/h3_ptPhiEta_photonPCMPair"), p4V0PCMPair.Pt(), RecoDecay::constrainAngle(p4V0PCMPair.Phi(), 0), p4V0PCMPair.Eta()); - tableProduction.photonPCMPair(v0Photon1.collisionId(), v0Photon1.globalIndex(), v0Photon2.globalIndex(), - v0Photon1.posTrack().trackId(), v0Photon1.negTrack().trackId(), v0Photon2.posTrack().trackId(), v0Photon2.negTrack().trackId(), - p4V0PCMPair.Pt(), RecoDecay::constrainAngle(p4V0PCMPair.Phi(), 0), p4V0PCMPair.Eta(), p4V0PCMPair.M()); + // get possible overlap with triggers + auto const triggerPosTrack1It = trackToTriggerMap.find(posTrack1.globalIndex()); + if (triggerPosTrack1It != trackToTriggerMap.end()) { + intersectTriggerIds.push_back(triggerPosTrack1It->second); + } + auto const triggerNegTrack1It = trackToTriggerMap.find(negTrack1.globalIndex()); + if (triggerNegTrack1It != trackToTriggerMap.end()) { + intersectTriggerIds.push_back(triggerNegTrack1It->second); + } + auto const triggerPosTrack2It = trackToTriggerMap.find(posTrack2.globalIndex()); + if (triggerPosTrack2It != trackToTriggerMap.end()) { + intersectTriggerIds.push_back(triggerPosTrack2It->second); + } + auto const triggerNegTrack2It = trackToTriggerMap.find(negTrack2.globalIndex()); + if (triggerNegTrack2It != trackToTriggerMap.end()) { + intersectTriggerIds.push_back(triggerNegTrack2It->second); + } + + // truthLevel and ptTrue + auto const [truthLevelPi0Pcm, ptTruePi0Pcm] = [&] { + if constexpr (IsCollisionMCD) { + return getTruthLevelRecoDiPhoton(collision, v0Photon1, v0Photon2, tracks); + } else { + return std::tuple{TruthLevel::None, -1}; + } + }(); + auto const [truthLevelEtaPcm, ptTrueEtaPcm] = [&] { + if constexpr (IsCollisionMCD) { + return getTruthLevelRecoDiPhoton(collision, v0Photon1, v0Photon2, tracks); + } else { + return std::tuple{TruthLevel::None, -1}; + } + }(); + double const ptTruePhotonPcmPair = std::max(ptTruePi0Pcm, ptTrueEtaPcm); + + // photonPcmPair info + histos.fill(HIST("reco/h3_ptPhiEta_photonPcmPair"), p4V0PcmPair.Pt(), RecoDecay::constrainAngle(p4V0PcmPair.Phi(), 0), p4V0PcmPair.Eta()); + tableProduction.photonPcmPair(v0Photon1.collisionId(), intersectTriggerIds, + p4V0PcmPair.Pt(), RecoDecay::constrainAngle(p4V0PcmPair.Phi(), 0), p4V0PcmPair.Eta(), p4V0PcmPair.M(), + static_cast(truthLevelPi0Pcm), static_cast(truthLevelEtaPcm), ptTruePhotonPcmPair); + tableProduction.photonPcmPairTrackId(v0Photon1.posTrack().trackId(), v0Photon1.negTrack().trackId(), v0Photon2.posTrack().trackId(), v0Photon2.negTrack().trackId()); + tableProduction.photonPcmPairV0PhotonId(v0Photon1.globalIndex(), v0Photon2.globalIndex()); + } } } - PROCESS_SWITCH(HadronPhotonProducer, processRecoPhotonPCM, "process photonPCM table (reconstructed)", false); - void processMcCorrTables(aod::JetMcCollision const& mcCollision, aod::JetParticles const& mcParticles) + void processRecoPhotonPcm(soa::Join const& collisions, + aod::V0PhotonsKF const& v0Photons, aod::V0Legs const&, soa::Join const& tracks) { - // mc split event selection - int const thirdDecimalTruePosZ = getThirdDecimalTruePosZ(mcCollision); - // maximum charged particle pt - float maxChargedPt = -1; - int maxTriggerCollisionId = -1; - int maxTriggerGlobalIndex = -1; - float maxTriggerPhi = 0; - float maxTriggerEta = 0; - // number charged particles in eta range - int nCharged = 0; - - // particle loop - for (auto const& mcParticle : mcParticles) { - // track selection - auto const pdgParticle = pdg->GetParticle(mcParticle.pdgCode()); - if (!pdgParticle || pdgParticle->Charge() == 0) { - continue; - } - if (!mcParticle.isPhysicalPrimary()) { - continue; - } - if (std::abs(mcParticle.eta()) > absEtaMax) { - continue; - } + fillProcessRecoPhotonPcm(collisions, v0Photons, tracks); + } + PROCESS_SWITCH(HadronPhotonProducer, processRecoPhotonPcm, "process photonPcm table (reconstructed)", false); - nCharged++; - if (mcParticle.pt() > maxChargedPt) { - maxChargedPt = mcParticle.pt(); - maxTriggerCollisionId = mcParticle.mcCollisionId(); - maxTriggerGlobalIndex = mcParticle.globalIndex(); - maxTriggerPhi = mcParticle.phi(); - maxTriggerEta = mcParticle.eta(); - } + void processMcRecoPhotonPcm(soa::Join const& collisions, + aod::V0PhotonsKF const& v0Photons, aod::V0Legs const&, soa::Join const& tracks, + aod::JetParticles const&) + { + fillProcessRecoPhotonPcm(collisions, v0Photons, tracks); + } + PROCESS_SWITCH(HadronPhotonProducer, processMcRecoPhotonPcm, "process photonPcm table (reconstructed MC)", false); - // trigger selection - if (mcParticle.pt() < ptTrigMin) { - continue; + void processMcCorrTables(aod::JetMcCollisions const& mcCollisions, aod::JetParticles const& mcParticles) + { + for (auto const& mcCollision : mcCollisions) { + // group collision + auto const mcParticlesThisEvent = mcParticles.sliceBy(perColMcParticles, mcCollision.globalIndex()); + + // mc split event selection + int const thirdDecimalTruePosZ = getThirdDecimalTruePosZ(mcCollision); + // maximum charged particle pt + float maxChargedPt = -1; + int maxTriggerCollisionId = -1; + int maxTriggerGlobalIndex = -1; + float maxTriggerPhi = 0; + float maxTriggerEta = 0; + // number charged particles in eta range + int nCharged = 0; + + // particle loop + for (auto const& mcParticle : mcParticlesThisEvent) { + // track selection + auto const pdgParticle = pdg->GetParticle(mcParticle.pdgCode()); + if (!pdgParticle || pdgParticle->Charge() == 0) { + continue; + } + if (!mcParticle.isPhysicalPrimary()) { + continue; + } + if (std::abs(mcParticle.eta()) > absEtaMax || mcParticle.pt() < ptMinHadron) { + continue; + } + + nCharged++; + if (mcParticle.pt() > maxChargedPt) { + maxChargedPt = mcParticle.pt(); + maxTriggerCollisionId = mcParticle.mcCollisionId(); + maxTriggerGlobalIndex = mcParticle.globalIndex(); + maxTriggerPhi = mcParticle.phi(); + maxTriggerEta = mcParticle.eta(); + } + + // trigger selection + if (mcParticle.pt() < ptTrigMin) { + continue; + } + if (oneTriggerPerEvent) { + continue; + } + + // trigger info + histos.fill(HIST("true/h3_ptPhiEta_trigger"), mcParticle.pt(), mcParticle.phi(), mcParticle.eta()); + tableProduction.trueTrigger(mcParticle.mcCollisionId(), mcParticle.globalIndex(), + mcParticle.pt(), mcParticle.phi(), mcParticle.eta()); } - if (oneTriggerPerEvent) { - continue; + bool const isTriggerEvent = maxChargedPt > ptTrigMin; + if (oneTriggerPerEvent && isTriggerEvent) { + histos.fill(HIST("true/h3_ptPhiEta_trigger"), maxChargedPt, maxTriggerPhi, maxTriggerEta); + tableProduction.trueTrigger(maxTriggerCollisionId, maxTriggerGlobalIndex, + maxChargedPt, maxTriggerPhi, maxTriggerEta); } - // trigger info - histos.fill(HIST("true/h3_ptPhiEta_trigger"), mcParticle.pt(), mcParticle.phi(), mcParticle.eta()); - tableProduction.triggerParticle(mcParticle.mcCollisionId(), mcParticle.globalIndex(), mcParticle.pt(), mcParticle.phi(), mcParticle.eta()); + // collision info + histos.fill(HIST("true/h2_zPvMult"), mcCollision.posZ(), nCharged); + tableProduction.mcCollisionExtraCorr(thirdDecimalTruePosZ, isTriggerEvent, maxChargedPt, nCharged); } - bool const isTriggerEvent = maxChargedPt > ptTrigMin; - if (oneTriggerPerEvent && isTriggerEvent) { - histos.fill(HIST("true/h3_ptPhiEta_trigger"), maxChargedPt, maxTriggerPhi, maxTriggerEta); - tableProduction.triggerParticle(maxTriggerCollisionId, maxTriggerGlobalIndex, maxChargedPt, maxTriggerPhi, maxTriggerEta); - } - - // collision info - histos.fill(HIST("true/h2_zPvMult"), mcCollision.posZ(), nCharged); - tableProduction.mcCollisionExtraCorr(thirdDecimalTruePosZ, isTriggerEvent, maxChargedPt, nCharged); } PROCESS_SWITCH(HadronPhotonProducer, processMcCorrTables, "process table production (mc)", false); }; From d32590b9d90e8b637d63decf550888b70cecf144 Mon Sep 17 00:00:00 2001 From: jkinner2 Date: Wed, 4 Nov 2026 11:17:33 +0100 Subject: [PATCH 04/13] reorderMcRecoInfo --- PWGJE/DataModel/HadronPhotonCorrelation.h | 38 ++- PWGJE/Tasks/hadronPhotonCorrelation.cxx | 314 +++++++++------------- PWGJE/Tasks/hadronPhotonProducer.cxx | 200 ++++++++++---- 3 files changed, 299 insertions(+), 253 deletions(-) diff --git a/PWGJE/DataModel/HadronPhotonCorrelation.h b/PWGJE/DataModel/HadronPhotonCorrelation.h index b838ef33d16..979f776bd66 100644 --- a/PWGJE/DataModel/HadronPhotonCorrelation.h +++ b/PWGJE/DataModel/HadronPhotonCorrelation.h @@ -47,7 +47,7 @@ enum class AssocType { }; enum class TruthLevel : int { - None = -1, + Unknown = -1, Reco = 0, RecoMcMatched = 1, RecoAssocEv = 2, @@ -65,6 +65,21 @@ enum class TruthLevel : int { TrueDecaySelfTrig = 14 }; +enum class PhotonImpurity : int { + Unknown = -1, + Pure = 0, + WrongEv = 1, + MisId = 2, + K0Short = 3, + K0Long = 4, + Lambda0 = 5, + Other = 6 +}; +constexpr double binValuePhotonImpurity(PhotonImpurity const impurity) +{ + return static_cast(impurity) + 0.5; +} + template bool constexpr AlwaysFalseType = false; template @@ -77,8 +92,10 @@ namespace o2::aod namespace corr_common { DECLARE_SOA_INDEX_COLUMN_FULL(JetMcCollision, jetMcCollision, int, JMcCollisions, ""); +DECLARE_SOA_COLUMN(SelEv, selEv, bool); DECLARE_SOA_COLUMN(Pt, pt, float); -DECLARE_SOA_COLUMN(PtTrue, ptTrue, float); +DECLARE_SOA_COLUMN(PtTruePure, ptTruePure, float); +DECLARE_SOA_COLUMN(PtTrueOrigin, ptTrueOrigin, float); // and the blind forest DECLARE_SOA_COLUMN(Phi, phi, float); DECLARE_SOA_COLUMN(Eta, eta, float); } // namespace corr_common @@ -90,7 +107,6 @@ namespace corr_collision { // plain jet collision column for derived data DECLARE_SOA_COLUMN(JetCollisionId, jetCollisionId, int); -DECLARE_SOA_COLUMN(SelEv, selEv, bool); DECLARE_SOA_COLUMN(ThirdDecimalTruePosZ, thirdDecimalTruePosZ, int); DECLARE_SOA_COLUMN(TrigEv, trigEv, bool); DECLARE_SOA_COLUMN(PtMax, ptMax, float); @@ -99,7 +115,7 @@ DECLARE_SOA_COLUMN(NGlobalTracks, nGlobalTracks, int); } // namespace corr_collision DECLARE_SOA_TABLE(CorrCollisions, "AOD", "CORRCOLLISION", o2::soa::Index<>, - corr_collision::SelEv, corr_collision::ThirdDecimalTruePosZ, corr_collision::TrigEv, corr_collision::PtMax, corr_collision::PosZ, corr_collision::NGlobalTracks); + corr_common::SelEv, corr_collision::ThirdDecimalTruePosZ, corr_collision::TrigEv, corr_collision::PtMax, corr_collision::PosZ, corr_collision::NGlobalTracks); DECLARE_SOA_TABLE(CorrCollisionIds, "AOD", "CORRCOLLISIONID", corr_collision::JetCollisionId); DECLARE_SOA_TABLE(CorrCollisionMcIds, "AOD", "CORRCOLLISIONMCID", @@ -137,7 +153,7 @@ DECLARE_SOA_COLUMN(TruthLevelRecoHadron, truthLevelRecoHadron, int); DECLARE_SOA_TABLE(Hadrons, "AOD", "HADRON", o2::soa::Index<>, corr_common::CorrCollisionId, corr_common::IntersectTriggerIds, corr_common::Pt, corr_common::Phi, corr_common::Eta, - hadron::TruthLevelRecoHadron, corr_common::PtTrue); + hadron::TruthLevelRecoHadron, corr_common::PtTruePure); DECLARE_SOA_TABLE(HadronTrackIds, "AOD", "HADRONTRACKID", hadron::JetTrackId); @@ -150,7 +166,7 @@ DECLARE_SOA_COLUMN(TruthLevelRecoPipm, truthLevelRecoPipm, int); DECLARE_SOA_TABLE(Pipms, "AOD", "PIPM", o2::soa::Index<>, corr_common::CorrCollisionId, corr_common::IntersectTriggerIds, corr_common::Pt, corr_common::Phi, corr_common::Eta, - pipm::TruthLevelRecoPipm, corr_common::PtTrue); + pipm::TruthLevelRecoPipm, corr_common::PtTruePure); DECLARE_SOA_TABLE(PipmTrackIds, "AOD", "PIPMTRACKID", pipm::JetTrackId); @@ -161,11 +177,13 @@ DECLARE_SOA_INDEX_COLUMN_FULL(V0PhotonKF, v0PhotonKF, int, V0PhotonsKF, ""); DECLARE_SOA_INDEX_COLUMN_FULL(PosJetTrack, posJetTrack, int, JetTracks, "_pos"); DECLARE_SOA_INDEX_COLUMN_FULL(NegJetTrack, negJetTrack, int, JetTracks, "_neg"); DECLARE_SOA_COLUMN(TruthLevelRecoPhotonPcm, truthLevelRecoPhotonPcm, int); +DECLARE_SOA_COLUMN(ImpurityPhotonPcm, impurityPhotonPcm, int); } // namespace photon_pcm DECLARE_SOA_TABLE(PhotonPcms, "AOD", "PHOTONPCM", o2::soa::Index<>, corr_common::CorrCollisionId, corr_common::IntersectTriggerIds, corr_common::Pt, corr_common::Phi, corr_common::Eta, - photon_pcm::TruthLevelRecoPhotonPcm, corr_common::PtTrue); + photon_pcm::TruthLevelRecoPhotonPcm, corr_common::PtTruePure, + photon_pcm::ImpurityPhotonPcm, corr_common::PtTrueOrigin); DECLARE_SOA_TABLE(PhotonPcmTrackIds, "AOD", "PHOTONPCMTRACKID", photon_pcm::PosJetTrackId, photon_pcm::NegJetTrackId); DECLARE_SOA_TABLE(PhotonPcmV0PhotonIds, "AOD", "PHOTONPCMV0PHOTONID", @@ -183,11 +201,13 @@ DECLARE_SOA_INDEX_COLUMN_FULL(NegJetTrack2, negJetTrack2, int, JetTracks, "_neg2 DECLARE_SOA_COLUMN(Mgg, mgg, float); DECLARE_SOA_COLUMN(TruthLevelRecoPi0Pcm, truthLevelRecoPi0Pcm, int); DECLARE_SOA_COLUMN(TruthLevelRecoEtaPcm, truthLevelRecoEtaPcm, int); +DECLARE_SOA_COLUMN(ImpurityPi0Pcm, impurityPi0Pcm, int); } // namespace photon_pcm_pair DECLARE_SOA_TABLE(PhotonPcmPairs, "AOD", "PHOTONPCMPAIR", o2::soa::Index<>, corr_common::CorrCollisionId, corr_common::IntersectTriggerIds, corr_common::Pt, corr_common::Phi, corr_common::Eta, photon_pcm_pair::Mgg, - photon_pcm_pair::TruthLevelRecoPi0Pcm, photon_pcm_pair::TruthLevelRecoEtaPcm, corr_common::PtTrue); + photon_pcm_pair::TruthLevelRecoPi0Pcm, photon_pcm_pair::TruthLevelRecoEtaPcm, corr_common::PtTruePure, + photon_pcm_pair::ImpurityPi0Pcm, corr_common::PtTrueOrigin); DECLARE_SOA_TABLE(PhotonPcmPairTrackIds, "AOD", "PHOTONPCMPAIRTRACKID", photon_pcm_pair::PosJetTrack1Id, photon_pcm_pair::NegJetTrack1Id, photon_pcm_pair::PosJetTrack2Id, photon_pcm_pair::NegJetTrack2Id); DECLARE_SOA_TABLE(PhotonPcmPairV0PhotonIds, "AOD", "PHOTONPCMPAIRV0PHOTONID", @@ -204,7 +224,7 @@ DECLARE_SOA_COLUMN(PtMax, ptMax, float); DECLARE_SOA_COLUMN(NChargedInEtaRange, nChargedInEtaRange, int); } // namespace mc_collision_extra_corr DECLARE_SOA_TABLE(McCollisionsExtraCorr, "AOD", "MCCOLLISIONEXTRACORR", - mc_collision_extra_corr::ThirdDecimalTruePosZ, mc_collision_extra_corr::TrigEv, mc_collision_extra_corr::PtMax, mc_collision_extra_corr::NChargedInEtaRange); + corr_common::SelEv, mc_collision_extra_corr::ThirdDecimalTruePosZ, mc_collision_extra_corr::TrigEv, mc_collision_extra_corr::PtMax, mc_collision_extra_corr::NChargedInEtaRange); // trigger namespace true_trigger diff --git a/PWGJE/Tasks/hadronPhotonCorrelation.cxx b/PWGJE/Tasks/hadronPhotonCorrelation.cxx index 432722b5a84..aab61c7967a 100644 --- a/PWGJE/Tasks/hadronPhotonCorrelation.cxx +++ b/PWGJE/Tasks/hadronPhotonCorrelation.cxx @@ -105,7 +105,12 @@ struct HadronPhotonCorrelation { Configurable splitMcEvN{"splitMcEvN", 1, "number of event fractions for selection in MC (max 10) | (select 1 for data)"}; Configurable splitMcEvSelect{"splitMcEvSelect", 1, "selected event fraction number in MC (starts at 1) | (select 1 for data)"}; - Configurable applyCTotTrigger{"applyCTotTrigger", false, "whether to apply on-the-fly total correction factor for triggers"}; + Configurable applyPhotonPtScaling{"applyPhotonPtScaling", false, "apply photon mc scaling factor"}; + Configurable applyPi0PtScaling{"applyPi0PtScaling", false, "apply pi0 mc scaling factor"}; + Configurable applyEtaPtScaling{"applyEtaPtScaling", false, "apply eta mc scaling factor"}; + Configurable applyK0sPtScaling{"applyK0sPtScaling", false, "apply K0s mc scaling factor"}; + + Configurable applyTriggerPtCorrection{"applyTriggerPtCorrection", false, "whether to apply on-the-fly total correction factor for triggers"}; Configurable doTrigEvMixing{"doTrigEvMixing", false, "whether to use trigger events for trigger mixing"}; Configurable nTriggerSavedForMixing{"nTriggerSavedForMixing", 8192, "number of triggers that are saved for mixing with other events"}; @@ -235,19 +240,6 @@ struct HadronPhotonCorrelation { Mixing }; - enum class PhotonImpurity { - WrongEv, - Misid, - K0Short, - K0Long, - Lambda0, - Other - }; - static constexpr double binValuePi0Impurities(PhotonImpurity const impurity) - { - return static_cast(impurity) + 0.5; - } - enum class TriggerMemoryMode { Reco, True, @@ -461,7 +453,7 @@ struct HadronPhotonCorrelation { { // trigger h1PtCorrectionTrigger = nullptr; - if (applyCTotTrigger) { + if (applyTriggerPtCorrection) { h1PtCorrectionTrigger = ccdb->getForTimeStamp(pathCcdbCorrection.value + "/trigger", noLaterThanCcdb); const double* correctionBinsTrigger = h1PtCorrectionTrigger->GetXaxis()->GetXbins()->GetArray(); @@ -479,7 +471,7 @@ struct HadronPhotonCorrelation { { // define axes const AxisSpec axisN{1, 0., 1., "#it{N}_{something}"}; - const AxisSpec axisCategories{16, 0., 16., "categories"}; + const AxisSpec axisCategories{32, 0., 32., "categories"}; const AxisSpec axisZPv{configHist.nBinsZPvPlain, -7, 7, "#it{z}_{pv}"}; const AxisSpec axisMult{configHist.nBinsMultPlain + 1, -0.5, configHist.nBinsMultPlain + 0.5, "multiplicity"}; @@ -500,7 +492,7 @@ struct HadronPhotonCorrelation { // main info for assocType (spectra and correlation) auto const addMainAssocHists = - [&](std::string const& recoOrMc, std::string const& nameTruthLevel, std::string const& nameAssoc, bool const resolvedInfo) { + [&](std::string const& recoOrMc, std::string const& nameTruthLevel, std::string const& nameAssoc, bool const resolvedInfo, bool const trueColInfo) { if (resolvedInfo) { histos.add(std::format("{}/plain/h4_ptTrigPtAssocPhiEta_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h4_ptTrigPtAssocPhiEta_{}_{}", nameTruthLevel, nameAssoc).data(), kTHnSparseD, {axisPtTrig, axisPtAssoc, axisPhi, axisEta}, true); @@ -510,10 +502,17 @@ struct HadronPhotonCorrelation { histos.add(std::format("{}/plain/h2_ptTrigPtAssoc_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h2_ptTrigPtAssoc_{}_{}", nameTruthLevel, nameAssoc).data(), kTHnSparseD, {axisPtTrig, axisPtAssoc}, true); } - histos.add(std::format("{}/corr/h6_corr_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h6_corr_{}_{}", nameTruthLevel, nameAssoc).data(), - kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); - histos.add(std::format("{}/corr/h6_mix_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h6_mix_{}_{}", nameTruthLevel, nameAssoc).data(), - kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); + if (!trueColInfo) { + histos.add(std::format("{}/corr/h6_corr_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h6_corr_{}_{}", nameTruthLevel, nameAssoc).data(), + kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); + histos.add(std::format("{}/corr/h6_mix_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h6_mix_{}_{}", nameTruthLevel, nameAssoc).data(), + kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); + } else { + histos.add(std::format("{}/corr/h6_corr_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h6_corr_{}_{}", nameTruthLevel, nameAssoc).data(), + kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinningMcTrue, axisMultBinningMcTrue}, true); + histos.add(std::format("{}/corr/h6_mix_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h6_mix_{}_{}", nameTruthLevel, nameAssoc).data(), + kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinningMcTrue, axisMultBinningMcTrue}, true); + } }; // reco info @@ -523,10 +522,10 @@ struct HadronPhotonCorrelation { // reco (correlation) analysis histos.add("reco/corr/h3_ptPhiEta_trig", "h3_ptPhiEta_trig", kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); for (std::string const& nameAssoc : std::initializer_list{"hadron", "pipm", "photonPcm"}) { - addMainAssocHists("reco", "reco", nameAssoc, true); + addMainAssocHists("reco", "reco", nameAssoc, true, false); } for (std::string const& nameAssoc : std::initializer_list{"pi0PcmPeak", "pi0PcmSide", "etaPcmPeak", "etaPcmSide"}) { - addMainAssocHists("reco", "reco", nameAssoc, false); + addMainAssocHists("reco", "reco", nameAssoc, false, false); } // photonPcm pairs @@ -558,35 +557,35 @@ struct HadronPhotonCorrelation { histos.add(std::format("mc/corr/h3_ptPhiEta_trig_{}", nameTruthLevel).data(), std::format("h3_ptPhiEta_trig_{}", nameTruthLevel).data(), kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); for (std::string const& nameAssoc : std::initializer_list{"hadron", "pipm", "photon"}) { - addMainAssocHists("mc", nameTruthLevel, nameAssoc, true); + addMainAssocHists("mc", nameTruthLevel, nameAssoc, true, true); } for (std::string const& nameAssoc : std::initializer_list{"pi0", "eta"}) { - addMainAssocHists("mc", nameTruthLevel, nameAssoc, false); + addMainAssocHists("mc", nameTruthLevel, nameAssoc, false, true); } } // extra truthLevels for photonPcmPair for (std::string const& nameTruthLevel : std::initializer_list{"trueDecaySelfTrig", "trueMeasDecay", "trueGeoAcc"}) { for (std::string const& nameAssoc : std::initializer_list{"pi0", "eta"}) { - addMainAssocHists("mc", nameTruthLevel, nameAssoc, false); + addMainAssocHists("mc", nameTruthLevel, nameAssoc, false, true); } } // assocTypes just on true level for (std::string const& nameAssoc : std::initializer_list{"photonDecay", "photonDirect", "photonPi0", "photonEta", "omega", "photonOmega", "etaPrime", "photonEtaPrime", "photonOtherMother"}) { - addMainAssocHists("mc", "true", nameAssoc, false); + addMainAssocHists("mc", "true", nameAssoc, false, true); } // reco++ (MC info) // std assoc for (std::string const& nameTruthLevel : std::initializer_list{"recoAssocEv", "recoPure", "recoPureTruePtAssoc"}) { for (std::string const& nameAssoc : std::initializer_list{"hadron", "pipm", "photonPcm"}) { - addMainAssocHists("mc", nameTruthLevel, nameAssoc, true); + addMainAssocHists("mc", nameTruthLevel, nameAssoc, true, false); } } // photonPcmPair assoc for (std::string const& nameTruthLevel : std::initializer_list{"pseudoReco", "pseudoRecoAssocEv", "pseudoRecoPure", "pseudoRecoPureTruePtAssoc"}) { for (std::string const& nameAssoc : std::initializer_list{"pi0Pcm", "etaPcm"}) { - addMainAssocHists("mc", nameTruthLevel, nameAssoc, false); + addMainAssocHists("mc", nameTruthLevel, nameAssoc, false, false); } } // impurity details @@ -651,12 +650,7 @@ struct HadronPhotonCorrelation { // total event selection (basic selections from producer and analysis level selections) bool totalEvSel(auto const& collision) { - bool isSelEv = true; - - if constexpr (requires { collision.selEv(); }) { - isSelEv = collision.selEv(); - } - return isSelEv && checkSplitMcEventSelection(collision); + return collision.selEv() && checkSplitMcEventSelection(collision); } // checks if mcParticle is charged @@ -690,32 +684,6 @@ struct HadronPhotonCorrelation { } return true; } - // check if particle has mother in parent tree - bool checkForMother(auto const& mcParticle, int const pdgCode, bool const checkAntiParticle) - { - if (!mcParticle.has_mothers()) { - return false; - } - auto const mothers = mcParticle.template mothers_as(); - auto mother = mothers.begin(); - auto motherEnd = mothers.end(); - while (mother != motherEnd) { - - // LOGF(info, "searchPdgCode: %i, current[ pdgCode: %i, status: %i, primary: %i ], mother[ pdgCode: %i, status: %i, primary: %i ]", - // pdgCode, - // mcParticle.pdgCode(), mcParticle.getGenStatusCode(), mcParticle.isPhysicalPrimary(), - // (*mother).pdgCode(), (*mother).getGenStatusCode(), (*mother).isPhysicalPrimary()); - - if ((*mother).pdgCode() == pdgCode || (checkAntiParticle && (*mother).pdgCode() == -pdgCode)) { - return true; - } - if (checkForMother(*mother, pdgCode, checkAntiParticle)) { - return true; - } - mother++; - } - return false; - } // check if particle has associated mother in parent tree // includes associated particle checks bool checkForAssocDecay(auto const& mcParticle, AssocType const assocType) @@ -738,7 +706,7 @@ struct HadronPhotonCorrelation { auto motherEnd = mothers.end(); while (mother != motherEnd) { // exclude pre-hadonisation - if (std::abs((*mother).getGenStatusCode()) < 80) { + if ((*mother).producedByGenerator() && std::abs((*mother).getGenStatusCode()) < 80) { return false; } // check valid associated particle @@ -772,7 +740,6 @@ struct HadronPhotonCorrelation { while (trigger != triggerEnd) { if constexpr (TruthLevelV == TruthLevel::TrueAssocEvRecoPtTrig) { if (!isMcMatchedTrigger(*trigger)) { - histos.fill(HIST("mc/info/h1_pt_noMatch_trigger"), (*trigger).pt()); return false; } if (!checkForAssocDecay((*trigger).template jetTrack_as().mcParticle(), assocType)) { @@ -795,7 +762,7 @@ struct HadronPhotonCorrelation { } // recursive helper to exclude loopDeLoops template - bool isDecayToTrigger(T_mcParticle const& mcParticle, T_mcParticle const& triggerParticle, std::unordered_set& visited) + bool producesTrigger(T_mcParticle const& mcParticle, T_mcParticle const& triggerParticle, std::unordered_set& visited) { if (!visited.insert(mcParticle.globalIndex()).second) { return false; @@ -810,7 +777,7 @@ struct HadronPhotonCorrelation { if ((*daughter).globalIndex() == triggerParticle.globalIndex()) { return true; } - if (isDecayToTrigger(*daughter, triggerParticle, visited)) { + if (producesTrigger(*daughter, triggerParticle, visited)) { return true; } daughter++; @@ -819,10 +786,10 @@ struct HadronPhotonCorrelation { } // check if particle has trigger in daughter tree template - bool isDecayToTrigger(T_mcParticle const& mcParticle, T_mcParticle const& triggerParticle) + bool producesTrigger(T_mcParticle const& mcParticle, T_mcParticle const& triggerParticle) { std::unordered_set visited; - return isDecayToTrigger(mcParticle, triggerParticle, visited); + return producesTrigger(mcParticle, triggerParticle, visited); } // checks if daughters are in acceptance @@ -843,27 +810,6 @@ struct HadronPhotonCorrelation { return true; } - // checks if tracks come from photon conversion - template - bool isConversionPhoton(T_track const& posTrack, T_track const& negTrack) - { - // 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; - } - // check photon - if (posMothers.begin()->pdgCode() != PDG_t::kGamma) { - return false; - } - - return true; - }; - // assocType dependent checks --------------------------------------------------------------------------------------------------------------------------------------------------------------- // check trivial self correlation for reconstruction @@ -1051,13 +997,61 @@ struct HadronPhotonCorrelation { return h1->GetBinContent(h1->FindFixBin(value)); } // correction trigger as function of pt - double triggerPtCorrection(double const value) + double getTriggerPtCorrection(double const pt) { - return applyCTotTrigger ? getH1ValueAt(h1PtCorrectionTrigger, value) : 1; + return applyTriggerPtCorrection ? getH1ValueAt(h1PtCorrectionTrigger, pt) : 1; } // rescale of pt spectra for mc - // add stuff next + + template + double getMcAssocPtScaling (double const ptTrue) { + if constexpr (AssocTypeV == AssocType::PhotonPcm) { + if (applyPhotonPtScaling) { + return 64; + } else { + return 1; + } + } else if constexpr (AssocTypeV == AssocType::Pi0Pcm) { + if (applyPi0PtScaling) { + return 67; + } else { + return 1; + } + } else if constexpr (AssocTypeV == AssocType::EtaPcm) { + if (applyEtaPtScaling) { + return 68; + } else { + return 1; + } + } else { + static_assert(AlwaysFalseValue, "assocType not found"); + } + } + template + double getMcAssocPtScaling(auto const& associated) { + if constexpr (AssocTypeV == AssocType::Hadron) { + return 1; + } else if constexpr (AssocTypeV == AssocType::Pipm) { + return 1; + } else if constexpr (AssocTypeV == AssocType::PhotonPcm) { + return 63; + } else if constexpr (AssocTypeV == AssocType::PhotonPcmPair || + AssocTypeV == AssocType::Pi0PcmPeak || AssocTypeV == AssocType::Pi0PcmSide || AssocTypeV == AssocType::Pi0Pcm || + AssocTypeV == AssocType::EtaPcmPeak || AssocTypeV == AssocType::EtaPcmSide || AssocTypeV == AssocType::EtaPcm) { + return 69; + } else { + static_assert(AlwaysFalseValue, "assocType not found"); + } + } + + double getMcK0sPtScaling (double const ptTrue) { + return 66; // work in progress + } + double getMcK0sPtScaling (auto const& associated) { + return 66; // work in progress + } + // performs 'phi1 - phi2' and pushes it into the interval [-pi/2, 3pi/2] double getDeltaPhi(double const phi1, double const phi2) @@ -1276,7 +1270,7 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(trigger.phi(), associated.phi()), trigger.eta() - associated.eta(), trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = triggerPtCorrection(trigger.pt()); + histFillInfo.weight = getTriggerPtCorrection(trigger.pt()); fillHistMain(histFillInfo); }; corrProcessCorrelation(collision, triggersThisEvent, assocsThisEvent, funcCorrelation); @@ -1294,7 +1288,7 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = perTriggerWeight * triggerPtCorrection(mixingTrigger.pt()); + histFillInfo.weight = perTriggerWeight * getTriggerPtCorrection(mixingTrigger.pt()); fillHistMain(histFillInfo); }; corrProcessMixing(collision, assocsThisEvent, funcMixing, nMixingAt0); @@ -1402,7 +1396,7 @@ struct HadronPhotonCorrelation { return; } - double const weight = triggerPtCorrection(trigger.pt()); + double const weight = getTriggerPtCorrection(trigger.pt()); // mgg distribution histos.fill(HIST("reco/corr/h5_ptTrigPtAssocMggZPvMult_reco_photonPcmPair"), @@ -1410,8 +1404,7 @@ struct HadronPhotonCorrelation { weight); HistFillInfoCorr histFillInfo = {getDeltaPhi(trigger.phi(), associated.phi()), trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks()), - triggerPtCorrection(trigger.pt())}; + trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; histFillInfo.weight = weight; fillAssocsRecoPhotonPcmPair(histFillInfo, associated.mgg()); }; @@ -1430,7 +1423,7 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = perTriggerWeight * triggerPtCorrection(mixingTrigger.pt()); + histFillInfo.weight = perTriggerWeight * getTriggerPtCorrection(mixingTrigger.pt()); fillAssocsRecoPhotonPcmPair(histFillInfo, associated.mgg()); }; corrProcessMixing(collision, photonPcmPairsThisEvent, funcMixing, nMixingAt0PhotonPcmPair); @@ -1797,7 +1790,7 @@ struct HadronPhotonCorrelation { auto const& triggerParticle = trueTrigger.jetMcParticle(); // self trigger info for decaying particles auto const isDecaySelfTrig = [this, &assocParticle, &triggerParticle]() { - return isDecayToTrigger(assocParticle, triggerParticle); + return producesTrigger(assocParticle, triggerParticle); }; // exclude self correlation if (trueTrigger.jetMcParticleId() == assocParticle.globalIndex()) { @@ -1835,7 +1828,6 @@ struct HadronPhotonCorrelation { } if (!isMcMatchedCollision(collision)) { - histos.fill(HIST("mc/info/h1_pt_noMatch_event"), 0.5); continue; } @@ -1862,7 +1854,7 @@ struct HadronPhotonCorrelation { auto const& triggerParticle = trueTrigger.jetMcParticle(); // self trigger info for decaying particles auto const isDecaySelfTrig = [this, &assocParticle, &triggerParticle]() { - return isDecayToTrigger(assocParticle, triggerParticle); + return producesTrigger(assocParticle, triggerParticle); }; // exclude self correlation if (trueTrigger.jetMcParticleId() == assocParticle.globalIndex()) { @@ -1901,7 +1893,6 @@ struct HadronPhotonCorrelation { } if (!isMcMatchedCollision(collision)) { - histos.fill(HIST("mc/info/h1_pt_noMatch_event"), 0.5); continue; } @@ -1927,18 +1918,24 @@ struct HadronPhotonCorrelation { auto const funcCorrelation = [this](auto const& mcCollision, auto const& trigger, auto const& assocParticle) { if (!isMcMatchedTrigger(trigger)) { - histos.fill(HIST("mc/info/h1_pt_noMatch_trigger"), trigger.pt()); return; } auto const& triggerParticle = trigger.template jetTrack_as().mcParticle(); // self trigger info for decaying particles auto const isDecaySelfTrig = [this, &assocParticle, &triggerParticle]() { - return isDecayToTrigger(assocParticle, triggerParticle); + return producesTrigger(assocParticle, triggerParticle); }; // exclude self correlation if (triggerParticle.globalIndex() == assocParticle.globalIndex()) { return; } + // match reco self-correlation exclusions + // trigger from conversion leg of the photon (pi0,eta legs handled implicily in isDecaySelfTrig) + if (assocParticle.pdgCode() == PDG_t::kGamma && + triggerParticle.has_mothers() && triggerParticle.mothersIds().front() == assocParticle.globalIndex() && + triggerParticle.getProcess() == TMCProcess::kPPair) { + return; + } HistFillInfoCorr histFillInfo = {getDeltaPhi(triggerParticle.phi(), assocParticle.phi()), triggerParticle.eta() - assocParticle.eta(), trigger.pt(), assocParticle.pt(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; @@ -2012,51 +2009,24 @@ struct HadronPhotonCorrelation { template void fillTruthLevelsMcRecoStd(auto& histFillInfo, auto const& collision, auto const& associated) { + // photon impurity + if constexpr (HistFillModeV == HistFillMode::Plain && AssocTypeV == AssocType::PhotonPcm) { + PhotonImpurity const impurity = static_cast(associated.impurityPhotonPcm()); + histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_recoImpurities_photonPcm"), + collision.ptMax(), associated.pt(), binValuePhotonImpurity(impurity)); + } // collision association if (!checkTruthLevelReco(associated)) { - if constexpr (AssocTypeV == AssocType::PhotonPcm) { - histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_recoImpurities_photonPcm"), - collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::WrongEv)); - } return; } fillHistMain(histFillInfo); // purity if (!checkTruthLevelReco(associated)) { - if constexpr (AssocTypeV == AssocType::PhotonPcm && requires { associated.posJetTrack(); }) { - auto const& posTrack = associated.template posJetTrack_as(); - auto const& negTrack = associated.template negJetTrack_as(); - if (!isConversionPhoton(posTrack, negTrack)) { - histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_recoImpurities_photonPcm"), - collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::Misid)); - return; - } - auto const& photons = posTrack.mcParticle().template mothers_as(); - if (!photons.begin()->isPhysicalPrimary()) { - if (checkForMother(*(photons.begin()), PDG_t::kK0Short, true)) { - histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_recoImpurities_photonPcm"), - collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::K0Short)); - return; - } - if (checkForMother(*(photons.begin()), PDG_t::kK0Long, true)) { - histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_recoImpurities_photonPcm"), - collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::K0Long)); - return; - } - if (checkForMother(*(photons.begin()), PDG_t::kLambda0, true)) { - histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_recoImpurities_photonPcm"), - collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::Lambda0)); - return; - } - histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_recoImpurities_photonPcm"), - collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::Other)); - } - } return; } fillHistMain(histFillInfo); // true ptAssoc - histFillInfo.ptAssoc = associated.ptTrue(); + histFillInfo.ptAssoc = associated.ptTruePure(); fillHistMain(histFillInfo); } @@ -2106,7 +2076,7 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(trigger.phi(), associated.phi()), trigger.eta() - associated.eta(), trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = triggerPtCorrection(trigger.pt()); + histFillInfo.weight = getTriggerPtCorrection(trigger.pt()); fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); }; corrProcessCorrelation(collision, triggersThisEvent, assocsThisEvent, funcCorrelation); @@ -2124,7 +2094,7 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = perTriggerWeight * triggerPtCorrection(mixingTrigger.pt()); + histFillInfo.weight = perTriggerWeight * getTriggerPtCorrection(mixingTrigger.pt()); fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); }; corrProcessMixing(collision, assocsThisEvent, funcMixing, nMixingAt0); @@ -2150,15 +2120,6 @@ struct HadronPhotonCorrelation { } PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoPhotonPcm, "process standard for associated photonPcm with additional mc information", false); - void processMcRecoPhotonPcmParentAccess(CorrCollisions const& collisions, aod::Triggers const& triggers, - soa::Join const& photonPcms, - aod::V0PhotonsKF const&, aod::V0Legs const&, - aod::JetTracksMCD const&, aod::JetParticles const&) - { - fillProcessMcRecoStd(collisions, triggers, photonPcms); - } - PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoPhotonPcmParentAccess, "process standard for associated photonPcm with additional mc information and parent access", false); - // photonPcmPair mc reco++ histogram compile-time paths static constexpr auto HistPathsMcRecoPhotonPcmPair = []() { using enum HistFillMode; @@ -2198,48 +2159,24 @@ struct HadronPhotonCorrelation { template void fillTruthLevelsMcRecoPhotonPcmPair(auto& histFillInfo, auto const& collision, auto const& associated) { + // pi0 impurity + if constexpr (HistFillModeV == HistFillMode::Plain && AssocTypeV == AssocType::Pi0Pcm) { + PhotonImpurity const impurity = static_cast(associated.impurityPi0Pcm()); + histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0Pcm"), + collision.ptMax(), associated.pt(), binValuePhotonImpurity(impurity)); + } // collision association if (!checkTruthLevelReco(associated)) { - if constexpr (AssocTypeV == AssocType::Pi0Pcm) { - histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0Pcm"), - collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::WrongEv)); - } return; } fillHistMain(histFillInfo); // purity if (!checkTruthLevelReco(associated)) { - if constexpr (AssocTypeV == AssocType::Pi0Pcm && requires { associated.posJetTrack1(); }) { - // note: do not dereference 'mothers' and store element in 'const&' (leads to seg fault) - auto const& posTrack1 = associated.template posJetTrack1_as(); - auto const& photons1 = posTrack1.mcParticle().template mothers_as(); - auto const& mothersOfPhoton = photons1.begin()->template mothers_as(); - auto const& grandmothersOfPhoton = mothersOfPhoton.begin()->template mothers_as(); - if (!isDecayPrimary(*(mothersOfPhoton.begin()))) { - if (std::abs(grandmothersOfPhoton.begin()->pdgCode()) == PDG_t::kK0Short) { - histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0Pcm"), - collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::K0Short)); - return; - } - if (std::abs(grandmothersOfPhoton.begin()->pdgCode()) == PDG_t::kK0Long) { - histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0Pcm"), - collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::K0Long)); - return; - } - if (std::abs(grandmothersOfPhoton.begin()->pdgCode()) == PDG_t::kLambda0) { - histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0Pcm"), - collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::Lambda0)); - return; - } - histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0Pcm"), - collision.ptMax(), associated.pt(), binValuePi0Impurities(PhotonImpurity::Other)); - } - } return; } fillHistMain(histFillInfo); // true ptAssoc - histFillInfo.ptAssoc = associated.ptTrue(); + histFillInfo.ptAssoc = associated.ptTruePure(); fillHistMain(histFillInfo); } @@ -2250,7 +2187,7 @@ struct HadronPhotonCorrelation { // pseudo yield // mgg distribution - if constexpr (HistFillModeV == HistFillMode::PlainPt) { + if constexpr (HistFillModeV == HistFillMode::Plain) { histos.fill(HIST("mc/plain/h5_ptTrigPtAssocMggZPvMult_pseudoReco_pi0Pcm"), histFillInfo.ptMax, histFillInfo.ptAssoc, associated.mgg(), collision.posZ(), collision.nGlobalTracks()); } else if constexpr (HistFillModeV == HistFillMode::Correlation) { @@ -2271,7 +2208,7 @@ struct HadronPhotonCorrelation { // pseudo yield // mgg distribution - if constexpr (HistFillModeV == HistFillMode::PlainPt) { + if constexpr (HistFillModeV == HistFillMode::Plain) { histos.fill(HIST("mc/plain/h5_ptTrigPtAssocMggZPvMult_pseudoReco_etaPcm"), histFillInfo.ptMax, histFillInfo.ptAssoc, associated.mgg(), collision.posZ(), collision.nGlobalTracks()); } else if constexpr (HistFillModeV == HistFillMode::Correlation) { @@ -2321,7 +2258,7 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(trigger.phi(), associated.phi()), trigger.eta() - associated.eta(), trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = triggerPtCorrection(trigger.pt()); + histFillInfo.weight = getTriggerPtCorrection(trigger.pt()); fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); }; corrProcessCorrelation(collision, triggersThisEvent, photonPcmPairsThisEvent, funcCorrelation); @@ -2339,7 +2276,7 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = perTriggerWeight * triggerPtCorrection(mixingTrigger.pt()); + histFillInfo.weight = perTriggerWeight * getTriggerPtCorrection(mixingTrigger.pt()); fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); }; corrProcessMixing(collision, photonPcmPairsThisEvent, funcMixing, nMixingAt0PhotonPcmPair); @@ -2353,15 +2290,6 @@ struct HadronPhotonCorrelation { } PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoPhotonPcmPair, "process correlation for associated photonPcmPair with additional mc information", false); - void processMcRecoPhotonPcmPairParentAccess(CorrCollisions const& collisions, aod::Triggers const& triggers, - soa::Join const& photonPcmPairs, - aod::V0PhotonsKF const&, aod::V0Legs const&, - aod::JetTracksMCD const&, aod::JetParticles const&) - { - fillProcesMcRecoPhotonPcmPair(collisions, triggers, photonPcmPairs); - } - PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoPhotonPcmPairParentAccess, "process correlation for associated photonPcmPair with additional mc information and parent access", false); - // other //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -2428,7 +2356,7 @@ struct HadronPhotonCorrelation { for (auto const& trigger : triggersThisEvent) { // trigger info histos.fill(HIST("reco/corr/h3_ptPhiEta_trig"), trigger.pt(), trigger.phi(), trigger.eta(), - triggerPtCorrection(trigger.pt())); + getTriggerPtCorrection(trigger.pt())); // save trigger for mixing triggerMemoryReco->saveTrigger(trigger.pt(), trigger.phi(), trigger.eta(), collision.posZ(), collision.nGlobalTracks()); diff --git a/PWGJE/Tasks/hadronPhotonProducer.cxx b/PWGJE/Tasks/hadronPhotonProducer.cxx index 17605d09aab..1eebee9f73e 100644 --- a/PWGJE/Tasks/hadronPhotonProducer.cxx +++ b/PWGJE/Tasks/hadronPhotonProducer.cxx @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -94,7 +95,7 @@ struct HadronPhotonProducer { Configurable eventSelections{"eventSelections", "sel8", "JE framework - event selection"}; Configurable skipMBGapEvents{"skipMBGapEvents", true, "skip MB gap events"}; Configurable applyRctSelection{"applyRctSelection", true, "apply RCT selection"}; - Configurable rctLabel{"rctLabel", "CBT_hadronPid", "RCT selection label"}; + Configurable rctLabel{"rctLabel", "CBT_hadronPID", "RCT selection label"}; Configurable trackSelections{"trackSelections", "globalTracks", "JE framework - track selections"}; Configurable triggerMasks{"triggerMasks", "", "JE framework - skimmed data trigger masks (relevent for correlation: fTrackLowPt,fTrackHighPt)"}; @@ -122,6 +123,15 @@ struct HadronPhotonProducer { int trackSelection = -1; std::vector triggerMaskBits; + struct TruthLevelInfo { + TruthLevel truthLevel = TruthLevel::Unknown; + double ptTruePure = -1; + }; + struct PhotonImpurityInfo { + PhotonImpurity impurity = PhotonImpurity::Unknown; + double ptTrueOrigin = -1; + }; + // map jetTracks to produced triggers std::map trackToTriggerMap; @@ -233,6 +243,32 @@ struct HadronPhotonProducer { return mcParticle.producedByGenerator(); } + // check if particle has mother in parent tree + // returns optional pt of mother + std::optional checkForMother(auto const& mcParticle, int const pdgCode, bool const checkAntiParticle, bool const includePreHadronisation = true) + { + if (!mcParticle.has_mothers()) { + return std::nullopt; + } + auto const mothers = mcParticle.template mothers_as(); + auto mother = mothers.begin(); + auto motherEnd = mothers.end(); + while (mother != motherEnd) { + // optional exclude pre-hadonisation + if (!includePreHadronisation && (*mother).producedByGenerator() && std::abs((*mother).getGenStatusCode()) < 80) { + return std::nullopt; + } + if ((*mother).pdgCode() == pdgCode || (checkAntiParticle && (*mother).pdgCode() == -pdgCode)) { + return (*mother).pt(); + } + if (auto const ptMother = checkForMother(*mother, pdgCode, checkAntiParticle, includePreHadronisation)) { + return ptMother; + } + mother++; + } + return std::nullopt; + } + // checks if tracks come from photon conversion template bool isConversionPhoton(T_track const& posTrack, T_track const& negTrack) @@ -285,45 +321,74 @@ struct HadronPhotonProducer { // get highest reco truthLevel particle canidate template - std::tuple getTruthLevelRecoHadronPipm(auto const& collision, auto const& track) { + TruthLevelInfo getMcRecoInfoHadronPipm(auto const& collision, auto const& track) { if (!track.has_mcParticle()) { return {TruthLevel::Reco, -1}; } auto const& mcParticle = track.mcParticle(); - double const ptTrue = mcParticle.pt(); if (mcParticle.mcCollisionId() != collision.mcCollisionId()) { - return {TruthLevel::RecoMcMatched, ptTrue}; + return {TruthLevel::RecoMcMatched, -1}; } if constexpr (AssocTypeV == AssocType::Hadron) { if (!isCharged(mcParticle) || !mcParticle.isPhysicalPrimary()) { - return {TruthLevel::RecoAssocEv, ptTrue}; + return {TruthLevel::RecoAssocEv, -1}; } } else if constexpr (AssocTypeV == AssocType::Pipm) { if (std::abs(mcParticle.pdgCode()) != PDG_t::kPiPlus || !mcParticle.isPhysicalPrimary()) { - return {TruthLevel::RecoAssocEv, ptTrue}; + return {TruthLevel::RecoAssocEv, -1}; } } else { static_assert(AlwaysFalseValue, "assocType not found"); } - return {TruthLevel::RecoPure, ptTrue}; + double const ptTruePure = mcParticle.pt(); + return {TruthLevel::RecoPure, ptTruePure}; } - std::tuple getTruthLevelRecoPhoton(auto const& collision, auto const& v0Photon, auto const& tracks) { + std::tuple getMcRecoInfoPhoton(auto const& collision, auto const& v0Photon, auto const& tracks) { + TruthLevelInfo truthLevelInfo; + PhotonImpurityInfo impurityInfo; + auto const [posTrack, negTrack] = getV0LegJetTracks(v0Photon, tracks); if (!posTrack.has_mcParticle() || !negTrack.has_mcParticle()) { - return {TruthLevel::Reco, -1}; + truthLevelInfo.truthLevel = TruthLevel::Reco; + return {truthLevelInfo, impurityInfo}; } if (posTrack.mcParticle().mcCollisionId() != collision.mcCollisionId() || negTrack.mcParticle().mcCollisionId() != collision.mcCollisionId()) { - return {TruthLevel::RecoMcMatched, -1}; + truthLevelInfo.truthLevel = TruthLevel::RecoMcMatched; + impurityInfo.impurity = PhotonImpurity::WrongEv; + return {truthLevelInfo, impurityInfo}; } auto const& photons = posTrack.mcParticle().template mothers_as(); - if (!isConversionPhoton(posTrack, negTrack) || !photons.begin()->isPhysicalPrimary()) { - return {TruthLevel::RecoAssocEv, -1}; + bool const isPhoton = isConversionPhoton(posTrack, negTrack); + if (!isPhoton || !photons.begin()->isPhysicalPrimary()) { + truthLevelInfo.truthLevel = TruthLevel::RecoAssocEv; + if (!isPhoton) { + impurityInfo.impurity = PhotonImpurity::MisId; + } else { + if (auto const ptMother = checkForMother(*(photons.begin()), PDG_t::kK0Short, true, false)) { + impurityInfo.impurity = PhotonImpurity::K0Short; + impurityInfo.ptTrueOrigin = *ptMother; + } else if (auto const ptMother = checkForMother(*(photons.begin()), PDG_t::kK0Long, true, false)) { + impurityInfo.impurity = PhotonImpurity::K0Long; + impurityInfo.ptTrueOrigin = *ptMother; + } else if (auto const ptMother = checkForMother(*(photons.begin()), PDG_t::kLambda0, true, false)) { + impurityInfo.impurity = PhotonImpurity::Lambda0; + impurityInfo.ptTrueOrigin = *ptMother; + } else { + impurityInfo.impurity = PhotonImpurity::Other; + } + } + return {truthLevelInfo, impurityInfo}; } - double const ptTrue = photons.begin()->pt(); - return {TruthLevel::RecoPure, ptTrue}; + truthLevelInfo.truthLevel = TruthLevel::RecoPure; + truthLevelInfo.ptTruePure = photons.begin()->pt(); + impurityInfo.impurity = PhotonImpurity::Pure; + return {truthLevelInfo, impurityInfo}; } template - std::tuple getTruthLevelRecoDiPhoton(auto const& collision, auto const& v0Photon1, auto const& v0Photon2, auto const& tracks) { + std::tuple getMcRecoInfoDiPhoton(auto const& collision, auto const& v0Photon1, auto const& v0Photon2, auto const& tracks) { + TruthLevelInfo truthLevelInfo; + PhotonImpurityInfo impurityInfo; + int constexpr PdgCode = []() { if constexpr (AssocTypeV == AssocType::Pi0Pcm) { return PDG_t::kPi0; @@ -336,26 +401,53 @@ struct HadronPhotonProducer { auto const [posTrack1, negTrack1] = getV0LegJetTracks(v0Photon1, tracks); auto const [posTrack2, negTrack2] = getV0LegJetTracks(v0Photon2, tracks); if (!posTrack1.has_mcParticle() || !negTrack1.has_mcParticle() || !posTrack2.has_mcParticle() || !negTrack2.has_mcParticle()) { - return {TruthLevel::Reco, -1}; + truthLevelInfo.truthLevel = TruthLevel::Reco; + return {truthLevelInfo, impurityInfo}; } if (!isGGFromDoubleConversion(posTrack1, negTrack1, posTrack2, negTrack2, PdgCode)) { - return {TruthLevel::RecoMcMatched, -1}; + truthLevelInfo.truthLevel = TruthLevel::RecoMcMatched; + return {truthLevelInfo, impurityInfo}; } if (posTrack1.mcParticle().mcCollisionId() != collision.mcCollisionId()) { - return {TruthLevel::PseudoReco, -1}; + truthLevelInfo.truthLevel = TruthLevel::PseudoReco; + if constexpr (AssocTypeV == AssocType::Pi0Pcm) { + impurityInfo.impurity = PhotonImpurity::WrongEv; + } + return {truthLevelInfo, impurityInfo}; } + // note: do not dereference 'mothers' and store element in 'const&' (leads to seg fault) auto const& photons1 = posTrack1.mcParticle().template mothers_as(); auto const& mothersOfPhoton = photons1.begin()->template mothers_as(); if (!isDecayPrimary(*(mothersOfPhoton.begin()))) { - return {TruthLevel::PseudoRecoAssocEv, -1}; + truthLevelInfo.truthLevel = TruthLevel::PseudoRecoAssocEv; + if constexpr (AssocTypeV == AssocType::Pi0Pcm) { + if (auto const ptMother = checkForMother(*(photons1.begin()), PDG_t::kK0Short, true, false)) { + impurityInfo.impurity = PhotonImpurity::K0Short; + impurityInfo.ptTrueOrigin = *ptMother; + } else if (auto const ptMother = checkForMother(*(photons1.begin()), PDG_t::kK0Long, true, false)) { + impurityInfo.impurity = PhotonImpurity::K0Long; + impurityInfo.ptTrueOrigin = *ptMother; + } else if (auto const ptMother = checkForMother(*(photons1.begin()), PDG_t::kLambda0, true, false)) { + impurityInfo.impurity = PhotonImpurity::Lambda0; + impurityInfo.ptTrueOrigin = *ptMother; + } else { + impurityInfo.impurity = PhotonImpurity::Other; + } + } + return {truthLevelInfo, impurityInfo}; } - double const ptTrue = mothersOfPhoton.begin()->pt(); - return {TruthLevel::PseudoRecoPure, ptTrue}; + truthLevelInfo.truthLevel = TruthLevel::PseudoRecoPure; + truthLevelInfo.ptTruePure = mothersOfPhoton.begin()->pt(); + if constexpr (AssocTypeV == AssocType::Pi0Pcm) { + impurityInfo.impurity = PhotonImpurity::Pure; + } + return {truthLevelInfo, impurityInfo}; } // other ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ // mc split event selection based in the thrid decimal of mc-true posZ + // returns reco value in case of no mc match int getThirdDecimalTruePosZ(auto const& collision) { double absPosZ; @@ -363,9 +455,10 @@ struct HadronPhotonProducer { // get third decimal if constexpr (IsCollisionMCD) { if (!collision.has_mcCollision()) { - return -1; + absPosZ = std::abs(collision.posZ()); + } else { + absPosZ = std::abs(collision.template mcCollision_as().posZ()); } - absPosZ = std::abs(collision.template mcCollision_as().posZ()); } else if constexpr (IsMcCollision) { absPosZ = std::abs(collision.posZ()); } else { @@ -421,7 +514,7 @@ struct HadronPhotonProducer { for (auto const& collision : collisions) { // event selection - bool isSelectedEvent = checkEventSelection(collision); + bool const isSelectedEvent = checkEventSelection(collision); // group collision auto const tracksThisEvent = tracks.sliceBy(perColTracks, collision.globalIndex()); @@ -534,12 +627,12 @@ struct HadronPhotonProducer { intersectTriggerIds.push_back(triggerTrackIt->second); } - // truthLevel and ptTrue - auto const [truthLevelHadron, truePtHadron] = [&] { + // mc reco info + TruthLevelInfo const truthLevelInfoHadron = [&] { if constexpr (IsCollisionMCD) { - return getTruthLevelRecoHadronPipm(collision, track); + return getMcRecoInfoHadronPipm(collision, track); } else { - return std::tuple{TruthLevel::None, -1}; + return TruthLevelInfo{}; } }(); @@ -547,7 +640,7 @@ struct HadronPhotonProducer { histos.fill(HIST("reco/h3_ptPhiEta_hadron"), track.pt(), track.phi(), track.eta()); tableProduction.hadron(track.collisionId(), intersectTriggerIds, track.pt(), track.phi(), track.eta(), - static_cast(truthLevelHadron), truePtHadron); + static_cast(truthLevelInfoHadron.truthLevel), truthLevelInfoHadron.ptTruePure); tableProduction.hadronTrackId(track.globalIndex()); // pipm selection @@ -562,12 +655,12 @@ struct HadronPhotonProducer { } } - // truthLevel and ptTrue - auto const [truthLevelPipm, ptTruePipm] = [&] { + // mc reco info + TruthLevelInfo const truthLevelInfoPipm = [&] { if constexpr (IsCollisionMCD) { - return getTruthLevelRecoHadronPipm(collision, track); + return getMcRecoInfoHadronPipm(collision, track); } else { - return std::tuple{TruthLevel::None, -1}; + return TruthLevelInfo{}; } }(); @@ -575,7 +668,7 @@ struct HadronPhotonProducer { histos.fill(HIST("reco/h3_ptPhiEta_pipm"), track.pt(), track.phi(), track.eta()); tableProduction.pipm(track.collisionId(), intersectTriggerIds, track.pt(), track.phi(), track.eta(), - static_cast(truthLevelPipm), ptTruePipm); + static_cast(truthLevelInfoPipm.truthLevel), truthLevelInfoPipm.ptTruePure); tableProduction.pipmTrackId(track.globalIndex()); } } @@ -647,20 +740,21 @@ struct HadronPhotonProducer { intersectTriggerIds.push_back(triggerNegTrackIt->second); } - // truthLevel and ptTrue - auto const [truthLevelPhotonPcm, ptTruePhotonPcm] = [&] { + // mc reco info + auto const [truthLevelInfoPhotonPcm, impurityInfoPhotonPcm] = [&] { if constexpr (IsCollisionMCD) { - return getTruthLevelRecoPhoton(collision, v0Photon, tracks); + return getMcRecoInfoPhoton(collision, v0Photon, tracks); } else { - return std::tuple{TruthLevel::None, -1}; + return std::tuple{TruthLevelInfo{}, PhotonImpurityInfo{}}; } }(); // photonPcm info histos.fill(HIST("reco/h3_ptPhiEta_photonPcm"), v0Photon.pt(), v0Photon.phi(), v0Photon.eta()); - tableProduction.photonPcm(v0Photon.collisionId(), intersectTriggerIds, + tableProduction.photonPcm(collision.globalIndex(), intersectTriggerIds, v0Photon.pt(), v0Photon.phi(), v0Photon.eta(), - static_cast(truthLevelPhotonPcm), ptTruePhotonPcm); + static_cast(truthLevelInfoPhotonPcm.truthLevel), truthLevelInfoPhotonPcm.ptTruePure, + static_cast(impurityInfoPhotonPcm.impurity), impurityInfoPhotonPcm.ptTrueOrigin); tableProduction.photonPcmTrackId(v0Photon.posTrack().trackId(), v0Photon.negTrack().trackId()); tableProduction.photonPcmV0PhotonId(v0Photon.globalIndex()); } @@ -701,28 +795,29 @@ struct HadronPhotonProducer { intersectTriggerIds.push_back(triggerNegTrack2It->second); } - // truthLevel and ptTrue - auto const [truthLevelPi0Pcm, ptTruePi0Pcm] = [&] { + // mc reco info + auto const [truthLevelInfoPi0Pcm, photonImpurityInfoPi0Pcm] = [&] { if constexpr (IsCollisionMCD) { - return getTruthLevelRecoDiPhoton(collision, v0Photon1, v0Photon2, tracks); + return getMcRecoInfoDiPhoton(collision, v0Photon1, v0Photon2, tracks); } else { - return std::tuple{TruthLevel::None, -1}; + return std::tuple{TruthLevelInfo{}, PhotonImpurityInfo{}}; } }(); - auto const [truthLevelEtaPcm, ptTrueEtaPcm] = [&] { + TruthLevelInfo const truthLevelInfoEtaPcm = [&] { if constexpr (IsCollisionMCD) { - return getTruthLevelRecoDiPhoton(collision, v0Photon1, v0Photon2, tracks); + return std::get<0>(getMcRecoInfoDiPhoton(collision, v0Photon1, v0Photon2, tracks)); } else { - return std::tuple{TruthLevel::None, -1}; + return TruthLevelInfo{}; } }(); - double const ptTruePhotonPcmPair = std::max(ptTruePi0Pcm, ptTrueEtaPcm); + double const ptTruePurePhotonPcmPair = std::max(truthLevelInfoPi0Pcm.ptTruePure, truthLevelInfoEtaPcm.ptTruePure); // photonPcmPair info histos.fill(HIST("reco/h3_ptPhiEta_photonPcmPair"), p4V0PcmPair.Pt(), RecoDecay::constrainAngle(p4V0PcmPair.Phi(), 0), p4V0PcmPair.Eta()); - tableProduction.photonPcmPair(v0Photon1.collisionId(), intersectTriggerIds, + tableProduction.photonPcmPair(collision.globalIndex(), intersectTriggerIds, p4V0PcmPair.Pt(), RecoDecay::constrainAngle(p4V0PcmPair.Phi(), 0), p4V0PcmPair.Eta(), p4V0PcmPair.M(), - static_cast(truthLevelPi0Pcm), static_cast(truthLevelEtaPcm), ptTruePhotonPcmPair); + static_cast(truthLevelInfoPi0Pcm.truthLevel), static_cast(truthLevelInfoEtaPcm.truthLevel), ptTruePurePhotonPcmPair, + static_cast(photonImpurityInfoPi0Pcm.impurity), photonImpurityInfoPi0Pcm.ptTrueOrigin); tableProduction.photonPcmPairTrackId(v0Photon1.posTrack().trackId(), v0Photon1.negTrack().trackId(), v0Photon2.posTrack().trackId(), v0Photon2.negTrack().trackId()); tableProduction.photonPcmPairV0PhotonId(v0Photon1.globalIndex(), v0Photon2.globalIndex()); } @@ -747,6 +842,9 @@ struct HadronPhotonProducer { void processMcCorrTables(aod::JetMcCollisions const& mcCollisions, aod::JetParticles const& mcParticles) { for (auto const& mcCollision : mcCollisions) { + // event selection true + bool const isSelectedEvent = !skipMBGapEvents || mcCollision.getSubGeneratorId() != jetderiveddatautilities::JCollisionSubGeneratorId::mbGap; + // group collision auto const mcParticlesThisEvent = mcParticles.sliceBy(perColMcParticles, mcCollision.globalIndex()); @@ -806,7 +904,7 @@ struct HadronPhotonProducer { // collision info histos.fill(HIST("true/h2_zPvMult"), mcCollision.posZ(), nCharged); - tableProduction.mcCollisionExtraCorr(thirdDecimalTruePosZ, isTriggerEvent, maxChargedPt, nCharged); + tableProduction.mcCollisionExtraCorr(isSelectedEvent, thirdDecimalTruePosZ, isTriggerEvent, maxChargedPt, nCharged); } } PROCESS_SWITCH(HadronPhotonProducer, processMcCorrTables, "process table production (mc)", false); From 9601e116fa360ff4ea97a9f0aaf8e61c5c1cc076 Mon Sep 17 00:00:00 2001 From: jkinner2 Date: Fri, 6 Nov 2026 09:35:12 +0100 Subject: [PATCH 05/13] addMcScaling --- PWGJE/Tasks/hadronPhotonCorrelation.cxx | 484 +++++++++++++++--------- PWGJE/Tasks/hadronPhotonProducer.cxx | 4 +- 2 files changed, 301 insertions(+), 187 deletions(-) diff --git a/PWGJE/Tasks/hadronPhotonCorrelation.cxx b/PWGJE/Tasks/hadronPhotonCorrelation.cxx index aab61c7967a..6b32994f9f3 100644 --- a/PWGJE/Tasks/hadronPhotonCorrelation.cxx +++ b/PWGJE/Tasks/hadronPhotonCorrelation.cxx @@ -49,6 +49,7 @@ #include // IWYU pragma: keep (do not replace with Math/Vector4Dfwd.h) #include #include +#include #include #include @@ -92,47 +93,62 @@ const double absEtaMaxDefault = 0.8; struct HadronPhotonCorrelation { // configurables - // general (kenobi) - Configurable pathCcdbCorrection{"pathCcdbCorrection", "Users/j/jkinner/correction/set_in_config", "base path to the ccdb corrections"}; - Configurable urlCcdb{"urlCcdb", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable noLaterThanCcdbConfig{"noLaterThanCcdbConfig", -1, "latest acceptable timestamp of creation for the object (-1 for task start time)"}; - - // shared across analysis tasks - Configurable absEtaMax{"absEtaMax", 0.8, "maximum absEta cut"}; - Configurable ptTrigMin{"ptTrigMin", 5, "minimum pT of triggers"}; - - // analysis settings - Configurable splitMcEvN{"splitMcEvN", 1, "number of event fractions for selection in MC (max 10) | (select 1 for data)"}; - Configurable splitMcEvSelect{"splitMcEvSelect", 1, "selected event fraction number in MC (starts at 1) | (select 1 for data)"}; - - Configurable applyPhotonPtScaling{"applyPhotonPtScaling", false, "apply photon mc scaling factor"}; - Configurable applyPi0PtScaling{"applyPi0PtScaling", false, "apply pi0 mc scaling factor"}; - Configurable applyEtaPtScaling{"applyEtaPtScaling", false, "apply eta mc scaling factor"}; - Configurable applyK0sPtScaling{"applyK0sPtScaling", false, "apply K0s mc scaling factor"}; - - Configurable applyTriggerPtCorrection{"applyTriggerPtCorrection", false, "whether to apply on-the-fly total correction factor for triggers"}; - Configurable doTrigEvMixing{"doTrigEvMixing", false, "whether to use trigger events for trigger mixing"}; - - Configurable nTriggerSavedForMixing{"nTriggerSavedForMixing", 8192, "number of triggers that are saved for mixing with other events"}; - Configurable nTriggerBinMinThreshold{"nTriggerBinMinThreshold", 4, "threshold minimum number of triggers in mixing bin required"}; - Configurable iTriggerStartFraction{"iTriggerStartFraction", 0.5, "ratio of bin size for randomised iTrigger start"}; - Configurable nTriggerScaleCoefficient{"nTriggerScaleCoefficient", 1, "coeffcient a in mixing-number pt power scaling"}; - Configurable nTriggerScaleExponent{"nTriggerScaleExponent", 2, "exponent a in mixing-number pt power scaling"}; - Configurable nMixingAt0McTrue{"nMixingAt0McTrue", 1, "number of triggers that are used for mc true mixing"}; - Configurable nMixingAt0Hadron{"nMixingAt0Hadron", 16, "number of triggers that are used for hadron mixing"}; - Configurable nMixingAt0Pipm{"nMixingAt0Pipm", 16, "number of triggers that are used for pipm mixing"}; - Configurable nMixingAt0PhotonPcm{"nMixingAt0PhotonPcm", 256, "number of triggers that are saved for photonPcm mixing"}; - Configurable nMixingAt0PhotonPcmPair{"nMixingAt0PhotonPcmPair", 1024, "number of triggers that are saved for photonPcmPair (pi0, eta) mixing"}; - - Configurable nNeighboursMixingPhotonPcmPair{"nNeighboursMixingPhotonPcmPair", 32, "number neighbours used for for photonPcm pair mixing"}; - - Configurable> pi0PcmPeakMassRange{"pi0PcmPeakMassRange", {0.10, 0.15}, "photon-pair mass integration range for pi0Pcm"}; - Configurable> pi0PcmSideMassRange{"pi0PcmSideMassRange", {0.16, 0.22}, "photon-pair mass integration range outside pi0Pcm region"}; - Configurable> etaPcmPeakMassRange{"etaPcmPeakMassRange", {0.51, 0.56}, "photon-pair mass integration range for etaPcm"}; - Configurable> etaPcmLowSideMassRange{"etaPcmLowSideMassRange", {0.44, 0.48}, "photon-pair mass integration range below etaPcm region"}; - Configurable> etaPcmHighSideMassRange{"etaPcmHighSideMassRange", {0.58, 0.62}, "photon-pair mass integration range above etaPcm region"}; - - Configurable energyAsymmPhotonPairMax{"energyAsymmPhotonPairMax", 1.0, "maximum energy asymmetry ((E1 - E2) / (E1 + E2)) of photon pairs"}; + // main config + struct : o2::framework::ConfigurableGroup { + // general (kenobi) + Configurable pathCcdbAnalysis{"pathCcdbAnalysis", "Users/j/jkinner/analysis/set_in_config", "base path to the ccdb for analysis objects"}; + Configurable urlCcdb{"urlCcdb", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable noLaterThanCcdbConfig{"noLaterThanCcdbConfig", -1, "latest acceptable timestamp of creation for the object (-1 for task start time)"}; + + // shared across analysis tasks + Configurable absEtaMax{"absEtaMax", 0.8, "maximum absEta cut"}; + Configurable ptTrigMin{"ptTrigMin", 5, "minimum pT of triggers"}; + + // analysis settings + Configurable splitMcEvN{"splitMcEvN", 1, "number of event fractions for selection in MC (max 10) | (select 1 for data)"}; + Configurable splitMcEvSelect{"splitMcEvSelect", 1, "selected event fraction number in MC (starts at 1) | (select 1 for data)"}; + + // mc scaling to data + // caution: applied to true-level very broadly, full mc-true possibly inconsistent (e.g. gammaDir scaled as well), only use for correcting + Configurable applyScalingPhotonPt{"applyScalingPhotonPt", false, "apply photon mc scaling factor"}; + Configurable> ptRangeScalingPhoton{"ptRangeScalingPhoton", {0.5, 15}, "pt for photon mc scaling factor using tcm, switching to constant outside"}; + Configurable> parScalingPhotonPtData{"parScalingPhotonPtData", {}, "tcm params, corrected data, photonPcm"}; + Configurable> parScalingPhotonPtMc{"parScalingPhotonPtMc", {}, "tcm params, mc gen, photonPcm"}; + Configurable applyScalingPi0Pt{"applyScalingPi0Pt", false, "apply pi0 mc scaling factor"}; + Configurable> ptRangeScalingPi0{"ptRangeScalingPi0", {0.5, 10}, "pt for pi0 mc scaling factor using tcm, switching to constant outside"}; + Configurable> parScalingPi0PtData{"parScalingPi0PtData", {}, "tcm params, corrected data, pi0Pcm"}; + Configurable> parScalingPi0PtMc{"parScalingPi0PtMc", {}, "tcm params, mc gen, pi0Pcm"}; + Configurable applyScalingEtaPt{"applyScalingEtaPt", false, "apply eta mc scaling factor"}; + Configurable> ptRangeScalingEta{"ptRangeScalingEta", {1.0, 10}, "pt for eta mc scaling factor using tcm, switching to constant outside"}; + Configurable> parScalingEtaPtData{"parScalingEtaPtData", {}, "tcm params, corrected data, etaPcm"}; + Configurable> parScalingEtaPtMc{"parScalingEtaPtMc", {}, "tcm params, mc gen, etaPcm"}; + // scalings and corrections applied to reco + Configurable applyScalingK0ShortPt{"applyScalingK0ShortPt", false, "apply K0Short mc scaling factor"}; + Configurable applyTriggerPtCorrection{"applyTriggerPtCorrection", false, "whether to apply on-the-fly total correction factor for triggers"}; + + Configurable doTrigEvMixing{"doTrigEvMixing", false, "whether to use trigger events for trigger mixing"}; + + Configurable nTriggerSavedForMixing{"nTriggerSavedForMixing", 8192, "number of triggers that are saved for mixing with other events"}; + Configurable nTriggerBinMinThreshold{"nTriggerBinMinThreshold", 4, "threshold minimum number of triggers in mixing bin required"}; + Configurable iTriggerStartFraction{"iTriggerStartFraction", 0.5, "ratio of bin size for randomised iTrigger start"}; + Configurable nTriggerScaleCoefficient{"nTriggerScaleCoefficient", 1, "coeffcient a in mixing-number pt power scaling"}; + Configurable nTriggerScaleExponent{"nTriggerScaleExponent", 2, "exponent a in mixing-number pt power scaling"}; + Configurable nMixingAt0McTrue{"nMixingAt0McTrue", 1, "number of triggers that are used for mc true mixing"}; + Configurable nMixingAt0Hadron{"nMixingAt0Hadron", 16, "number of triggers that are used for hadron mixing"}; + Configurable nMixingAt0Pipm{"nMixingAt0Pipm", 16, "number of triggers that are used for pipm mixing"}; + Configurable nMixingAt0PhotonPcm{"nMixingAt0PhotonPcm", 256, "number of triggers that are saved for photonPcm mixing"}; + Configurable nMixingAt0PhotonPcmPair{"nMixingAt0PhotonPcmPair", 1024, "number of triggers that are saved for photonPcmPair (pi0, eta) mixing"}; + + Configurable nNeighboursMixingPhotonPcmPair{"nNeighboursMixingPhotonPcmPair", 32, "number neighbours used for for photonPcm pair mixing"}; + + Configurable> pi0PcmPeakMassRange{"pi0PcmPeakMassRange", {0.10, 0.15}, "photon-pair mass integration range for pi0Pcm"}; + Configurable> pi0PcmSideMassRange{"pi0PcmSideMassRange", {0.16, 0.22}, "photon-pair mass integration range outside pi0Pcm region"}; + Configurable> etaPcmPeakMassRange{"etaPcmPeakMassRange", {0.51, 0.56}, "photon-pair mass integration range for etaPcm"}; + Configurable> etaPcmLowSideMassRange{"etaPcmLowSideMassRange", {0.44, 0.48}, "photon-pair mass integration range below etaPcm region"}; + Configurable> etaPcmHighSideMassRange{"etaPcmHighSideMassRange", {0.58, 0.62}, "photon-pair mass integration range above etaPcm region"}; + + Configurable energyAsymmPhotonPairMax{"energyAsymmPhotonPairMax", 1.0, "maximum energy asymmetry ((E1 - E2) / (E1 + E2)) of photon pairs"}; + } config; // pcm cuts struct : o2::framework::ConfigurableGroup { @@ -299,6 +315,7 @@ struct HadronPhotonCorrelation { // correction histograms TH1D* h1PtCorrectionTrigger = nullptr; + TH1D* h1PtScalingK0Short = nullptr; // mixing trigger memory struct MixingTrigger { @@ -452,16 +469,27 @@ struct HadronPhotonCorrelation { void initCcdbHistograms(int64_t const noLaterThanCcdb) { // trigger - h1PtCorrectionTrigger = nullptr; - if (applyTriggerPtCorrection) { - h1PtCorrectionTrigger = ccdb->getForTimeStamp(pathCcdbCorrection.value + "/trigger", noLaterThanCcdb); + if (config.applyTriggerPtCorrection.value) { + h1PtCorrectionTrigger = ccdb->getForTimeStamp(config.pathCcdbAnalysis.value + "/correction/trigger", noLaterThanCcdb); - const double* correctionBinsTrigger = h1PtCorrectionTrigger->GetXaxis()->GetXbins()->GetArray(); - const AxisSpec axisPtCorrectionTrigger{std::vector(correctionBinsTrigger, correctionBinsTrigger + h1PtCorrectionTrigger->GetNbinsX() + 1), "#it{p}_{T}"}; - histos.add("usedCorrection/h1_pt_correction_trigger_ccdb", "h1_pt_correction_trigger_ccdb", kTH1D, {axisPtCorrectionTrigger}, true); - for (int iBin = 1; iBin <= h1PtCorrectionTrigger->GetNbinsX(); iBin++) { - histos.get(HIST("usedCorrection/h1_pt_correction_trigger_ccdb"))->SetBinContent(iBin, h1PtCorrectionTrigger->GetBinContent(iBin)); - histos.get(HIST("usedCorrection/h1_pt_correction_trigger_ccdb"))->SetBinError(iBin, h1PtCorrectionTrigger->GetBinError(iBin)); + const double* bins = h1PtCorrectionTrigger->GetXaxis()->GetXbins()->GetArray(); + const AxisSpec axis{std::vector(bins, bins + h1PtCorrectionTrigger->GetNbinsX() + 1), "#it{p}_{T}"}; + histos.add("usedObjectsCcdb/h1_pt_correction_trigger_ccdb", "h1_pt_correction_trigger_ccdb", kTH1D, {axis}, true); + for (int iBin = 0; iBin <= h1PtCorrectionTrigger->GetNbinsX() + 1; iBin++) { + histos.get(HIST("usedObjectsCcdb/h1_pt_correction_trigger_ccdb"))->SetBinContent(iBin, h1PtCorrectionTrigger->GetBinContent(iBin)); + histos.get(HIST("usedObjectsCcdb/h1_pt_correction_trigger_ccdb"))->SetBinError(iBin, h1PtCorrectionTrigger->GetBinError(iBin)); + } + } + // K0Short + if (config.applyScalingK0ShortPt.value) { + h1PtScalingK0Short = ccdb->getForTimeStamp(config.pathCcdbAnalysis.value + "/scaling/K0Short", noLaterThanCcdb); + + const double* bins = h1PtScalingK0Short->GetXaxis()->GetXbins()->GetArray(); + const AxisSpec axis{std::vector(bins, bins + h1PtScalingK0Short->GetNbinsX() + 1), "#it{p}_{T}"}; + histos.add("usedObjectsCcdb/h1_pt_scaling_K0Short_ccdb", "h1_pt_scaling_K0Short_ccdb", kTH1D, {axis}, true); + for (int iBin = 0; iBin <= h1PtScalingK0Short->GetNbinsX() + 1; iBin++) { + histos.get(HIST("usedObjectsCcdb/h1_pt_scaling_K0Short_ccdb"))->SetBinContent(iBin, h1PtScalingK0Short->GetBinContent(iBin)); + histos.get(HIST("usedObjectsCcdb/h1_pt_scaling_K0Short_ccdb"))->SetBinError(iBin, h1PtScalingK0Short->GetBinError(iBin)); } } } @@ -477,7 +505,7 @@ struct HadronPhotonCorrelation { const AxisSpec axisMult{configHist.nBinsMultPlain + 1, -0.5, configHist.nBinsMultPlain + 0.5, "multiplicity"}; const AxisSpec axisPhi{configHist.nBinsPhi, 0, constants::math::TwoPI, "#it{#varphi}"}; - const AxisSpec axisEta{configHist.nBinsEta, -absEtaMax, absEtaMax, "#it{#eta}"}; + const AxisSpec axisEta{configHist.nBinsEta, -config.absEtaMax.value, config.absEtaMax.value, "#it{#eta}"}; const AxisSpec axisDcaZ{configHist.nBinsDcaZ, -5, 5, "DCA_{z}"}; const AxisSpec axisMgg{configHist.nBinsMgg, 0, 0.8, "#it{m}_{#gamma#gamma}"}; @@ -644,7 +672,7 @@ struct HadronPhotonCorrelation { bool checkSplitMcEventSelection(auto const& collision) { // select based on configurables - return collision.thirdDecimalTruePosZ() % splitMcEvN == splitMcEvSelect - 1; + return collision.thirdDecimalTruePosZ() % config.splitMcEvN.value == config.splitMcEvSelect.value - 1; } // total event selection (basic selections from producer and analysis level selections) @@ -711,7 +739,7 @@ struct HadronPhotonCorrelation { } // check valid associated particle if ((*mother).pdgCode() == pdgCode || (*mother).pdgCode() == -pdgCode) { - if (std::abs((*mother).eta()) < absEtaMax && isDecayPrimary(*mother)) { + if (std::abs((*mother).eta()) < config.absEtaMax.value && isDecayPrimary(*mother)) { return true; } } @@ -838,8 +866,7 @@ struct HadronPhotonCorrelation { TruthLevel::Reco, TruthLevel::RecoMcMatched, TruthLevel::RecoAssocEv, - TruthLevel::RecoPure, - TruthLevel::RecoPureTruePtAssoc + TruthLevel::RecoPure }; // diPhoton static constexpr std::array truthLevelsRecoDiPhotonRanked{ @@ -847,8 +874,7 @@ struct HadronPhotonCorrelation { TruthLevel::RecoMcMatched, TruthLevel::PseudoReco, TruthLevel::PseudoRecoAssocEv, - TruthLevel::PseudoRecoPure, - TruthLevel::PseudoRecoPureTruePtAssoc + TruthLevel::PseudoRecoPure }; // position of truthLevel in chain, -1 if not in ranked truthLevels auto constexpr getRank = [](TruthLevel const truthLevel, auto const& truthLevelsRanked) constexpr -> int { @@ -902,13 +928,13 @@ struct HadronPhotonCorrelation { double const e1 = v0Photon1.pt() * std::cosh(v0Photon1.eta()); double const e2 = v0Photon2.pt() * std::cosh(v0Photon2.eta()); double const energyAsym = std::abs((e1 - e2) / (e1 + e2)); - return energyAsym < energyAsymmPhotonPairMax; + return energyAsym < config.energyAsymmPhotonPairMax.value; } // add pmeventId() due to unguarded call in V0PhotonCut.h qa; selection unaffected - template - struct V0PhotonNoEvent : V0PhotonType { - explicit V0PhotonNoEvent(V0PhotonType const& v0PhotonType) : V0PhotonType(v0PhotonType) {} + template + struct V0PhotonNoEvent : T_V0PhotonType { + explicit V0PhotonNoEvent(T_V0PhotonType const& v0PhotonType) : T_V0PhotonType(v0PhotonType) {} [[nodiscard]] int pmeventId() const { return -1; } }; bool isSelectedV0Photon(auto const& v0Photon) @@ -940,9 +966,7 @@ struct HadronPhotonCorrelation { return true; } else if constexpr (AssocTypeV == AssocType::PhotonPcm) { return isSelectedPhotonPcm(associated); - } else if constexpr (AssocTypeV == AssocType::PhotonPcmPair || - AssocTypeV == AssocType::Pi0PcmPeak || AssocTypeV == AssocType::Pi0PcmSide || - AssocTypeV == AssocType::EtaPcmPeak || AssocTypeV == AssocType::EtaPcmSide) { + } else if constexpr (AssocTypeV == AssocType::PhotonPcmPair) { return isSelectedPhotonPcmPair(associated); } else { static_assert(AlwaysFalseValue, "assocType not found"); @@ -963,7 +987,7 @@ struct HadronPhotonCorrelation { } // fill main histogram - template + template void fillHistMain(auto const& histFillInfo) { if constexpr (HistFillModeV == HistFillMode::Plain) { if constexpr (AssocTypeV == AssocType::Hadron || AssocTypeV == AssocType::Pipm || AssocTypeV == AssocType::PhotonPcm) { @@ -991,36 +1015,73 @@ struct HadronPhotonCorrelation { } } - // get histogram y-quantity at x-value - double getH1ValueAt(auto const*const h1, double const value) - { - return h1->GetBinContent(h1->FindFixBin(value)); + // tcm component: exponential for low pt + // parameter shape: [m0_h, A_e, T_e] + double tcmInvariantSoftExp(double const* pt, double const* par) { + double const ET_kin = std::sqrt(std::pow(pt[0], 2) + std::pow(par[0], 2)) - par[0]; + return std::abs(par[1]) * std::exp(-1 * ET_kin / par[2]); } - // correction trigger as function of pt - double getTriggerPtCorrection(double const pt) - { - return applyTriggerPtCorrection ? getH1ValueAt(h1PtCorrectionTrigger, pt) : 1; + // tcm component: power law for high pt + // parameter shape: [A_p, T_p, N_p] + double tcmInvariantHardPower(double const* pt, double const* par) { + return std::abs(par[0]) / std::pow(1 + std::pow(pt[0], 2) / (std::pow(par[1], 2) * par[2]), par[2]); + } + // fit function for invariant pT spectrum + // parameter shape: [m0_h, A_e, T_e, A_p, T_p, N_p] + double tcmInvariantFit(double const* pt, double const* par) { + int const nParSoftExp = 3; + return tcmInvariantSoftExp(pt, par) + tcmInvariantHardPower(pt, par + nParSoftExp); + } + // tcm function (non-invariant) + double tcmParam(double const pt, std::vector const& par) { + return pt * tcmInvariantFit(&pt, par.data()); + } + + // pt weight + double ptWeightTcms(double const pt, std::vector const& parNum, std::vector const& parDenom) { + return tcmParam(pt, parNum) / tcmParam(pt, parDenom); } // rescale of pt spectra for mc template - double getMcAssocPtScaling (double const ptTrue) { - if constexpr (AssocTypeV == AssocType::PhotonPcm) { - if (applyPhotonPtScaling) { - return 64; - } else { - return 1; + double getMcAssocPtScalingFromPt(double const ptTrue) { + auto const getWeight = [this](double const pt, std::vector const& ptRange, std::vector const& parNum, std::vector const& parDenom) { + if (pt < ptRange.at(0)) { + return ptWeightTcms(ptRange.at(0), parNum, parDenom); + } + if (pt > ptRange.at(1)) { + return ptWeightTcms(ptRange.at(1), parNum, parDenom); } + return ptWeightTcms(pt, parNum, parDenom); + }; + if constexpr (AssocTypeV == AssocType::PhotonPcm) { + return config.applyScalingPhotonPt.value ? getWeight(ptTrue, config.ptRangeScalingPhoton.value, config.parScalingPhotonPtData.value, config.parScalingPhotonPtMc.value) : 1; } else if constexpr (AssocTypeV == AssocType::Pi0Pcm) { - if (applyPi0PtScaling) { - return 67; + return config.applyScalingPi0Pt.value ? getWeight(ptTrue, config.ptRangeScalingPi0.value, config.parScalingPi0PtData.value, config.parScalingPi0PtMc.value) : 1; + } else if constexpr (AssocTypeV == AssocType::EtaPcm) { + return config.applyScalingEtaPt.value ? getWeight(ptTrue, config.ptRangeScalingEta.value, config.parScalingEtaPtData.value, config.parScalingEtaPtMc.value) : 1; + } else { + static_assert(AlwaysFalseValue, "assocType not found"); + } + } + template + double getMcAssocPtScaling(auto const& associated) { + if constexpr (AssocTypeV == AssocType::Hadron || AssocTypeV == AssocType::Pipm) { + return 1; + } else if constexpr (AssocTypeV == AssocType::PhotonPcm) { + if (!config.applyScalingPhotonPt.value) return 1; + if (checkTruthLevelReco(associated)) { + return getMcAssocPtScalingFromPt(associated.ptTruePure()); } else { return 1; } - } else if constexpr (AssocTypeV == AssocType::EtaPcm) { - if (applyEtaPtScaling) { - return 68; + } else if constexpr (AssocTypeV == AssocType::PhotonPcmPair) { + if (!config.applyScalingPi0Pt.value && !config.applyScalingEtaPt.value) return 1; + if (checkTruthLevelReco(associated)) { + return getMcAssocPtScalingFromPt(associated.ptTruePure()); + } else if (checkTruthLevelReco(associated)) { + return getMcAssocPtScalingFromPt(associated.ptTruePure()); } else { return 1; } @@ -1028,31 +1089,44 @@ struct HadronPhotonCorrelation { static_assert(AlwaysFalseValue, "assocType not found"); } } + + // get histogram y-quantity at x-value + double getH1ValueAt(auto const*const h1, double const value) + { + return h1->GetBinContent(h1->FindFixBin(value)); + } + + // K0Short mc scaling + double getMcK0ShortPtScalingFromPt(double const ptTrue) { + return config.applyScalingK0ShortPt.value ? getH1ValueAt(h1PtScalingK0Short, ptTrue) : 1; + } template - double getMcAssocPtScaling(auto const& associated) { - if constexpr (AssocTypeV == AssocType::Hadron) { - return 1; - } else if constexpr (AssocTypeV == AssocType::Pipm) { + double getMcK0ShortPtScaling (auto const& associated) { + if constexpr (AssocTypeV == AssocType::Hadron || AssocTypeV == AssocType::Pipm) { return 1; } else if constexpr (AssocTypeV == AssocType::PhotonPcm) { - return 63; - } else if constexpr (AssocTypeV == AssocType::PhotonPcmPair || - AssocTypeV == AssocType::Pi0PcmPeak || AssocTypeV == AssocType::Pi0PcmSide || AssocTypeV == AssocType::Pi0Pcm || - AssocTypeV == AssocType::EtaPcmPeak || AssocTypeV == AssocType::EtaPcmSide || AssocTypeV == AssocType::EtaPcm) { - return 69; + if (associated.impurityPhotonPcm() == static_cast(PhotonImpurity::K0Short)) { + return getMcK0ShortPtScalingFromPt(associated.ptTrueOrigin()); + } else { + return 1; + } + } else if constexpr (AssocTypeV == AssocType::PhotonPcmPair) { + if (associated.impurityPi0Pcm() == static_cast(PhotonImpurity::K0Short)) { + return getMcK0ShortPtScalingFromPt(associated.ptTrueOrigin()); + } else { + return 1; + } } else { static_assert(AlwaysFalseValue, "assocType not found"); } } - double getMcK0sPtScaling (double const ptTrue) { - return 66; // work in progress - } - double getMcK0sPtScaling (auto const& associated) { - return 66; // work in progress + // correction trigger as function of pt + double getTriggerPtCorrection(double const pt) + { + return config.applyTriggerPtCorrection.value ? getH1ValueAt(h1PtCorrectionTrigger, pt) : 1; } - // performs 'phi1 - phi2' and pushes it into the interval [-pi/2, 3pi/2] double getDeltaPhi(double const phi1, double const phi2) { @@ -1064,14 +1138,14 @@ struct HadronPhotonCorrelation { bool isInMassRange(double const mgg) { if constexpr (AssocTypeV == AssocType::Pi0PcmPeak) { - return mgg > pi0PcmPeakMassRange.value[0] && mgg < pi0PcmPeakMassRange.value[1]; + return mgg > config.pi0PcmPeakMassRange.value.at(0) && mgg < config.pi0PcmPeakMassRange.value.at(1); } else if constexpr (AssocTypeV == AssocType::Pi0PcmSide) { - return mgg > pi0PcmSideMassRange.value[0] && mgg < pi0PcmSideMassRange.value[1]; + return mgg > config.pi0PcmSideMassRange.value.at(0) && mgg < config.pi0PcmSideMassRange.value.at(1); } else if constexpr (AssocTypeV == AssocType::EtaPcmPeak) { - return mgg > etaPcmPeakMassRange.value[0] && mgg < etaPcmPeakMassRange.value[1]; + return mgg > config.etaPcmPeakMassRange.value.at(0) && mgg < config.etaPcmPeakMassRange.value.at(1); } else if constexpr (AssocTypeV == AssocType::EtaPcmSide) { - return (mgg > etaPcmLowSideMassRange.value[0] && mgg < etaPcmLowSideMassRange.value[1]) || - (mgg > etaPcmHighSideMassRange.value[0] && mgg < etaPcmHighSideMassRange.value[1]); + return (mgg > config.etaPcmLowSideMassRange.value.at(0) && mgg < config.etaPcmLowSideMassRange.value.at(1)) || + (mgg > config.etaPcmHighSideMassRange.value.at(0) && mgg < config.etaPcmHighSideMassRange.value.at(1)); } else { static_assert(AlwaysFalseValue, "assocType not found"); } @@ -1106,15 +1180,20 @@ struct HadronPhotonCorrelation { // mixing-number pt scaling with power law size_t nMixingPtPowerScaling(size_t const n0, double const pt) { - double const scale = 1 + nTriggerScaleCoefficient * std::pow(pt, nTriggerScaleExponent); + double const scale = 1 + config.nTriggerScaleCoefficient.value * std::pow(pt, config.nTriggerScaleExponent.value); return n0 * scale; } // mixing - template + struct ConditionMixAcceptAll { + constexpr bool operator()(auto const&) const + { + return true; + } + }; + template void corrProcessMixing(auto const& collision, auto const& associatedThisEvent, - auto const& funcMixing, - size_t const nTriggerMixingAt0) + auto const& funcMixing, size_t const nTriggerMixingAt0, T_AssocCondition const& funcConditionAssocOnly = {}) { size_t triggerMemoryBinSizeMin = 0; @@ -1138,14 +1217,17 @@ struct HadronPhotonCorrelation { } }(); // require enough mixing statistics - if (triggerMemoryBinSizeMin < static_cast(nTriggerBinMinThreshold)) { + if (triggerMemoryBinSizeMin < static_cast(config.nTriggerBinMinThreshold.value)) { return; } const size_t nSavedTriggers = savedTriggers.size(); - const size_t iStartTrigger = randomIntInInterval(0, iTriggerStartFraction * nSavedTriggers); + const size_t iStartTrigger = randomIntInInterval(0, config.iTriggerStartFraction.value * nSavedTriggers); // associated loop for (auto const& associated : associatedThisEvent) { - // trigger numbers + if (!funcConditionAssocOnly(associated)) { + continue; + } + // trigger settings const size_t nTriggerMixing = nMixingPtPowerScaling(nTriggerMixingAt0, associated.pt()); const size_t mixUpToTriggerN = std::min(nSavedTriggers, iStartTrigger + nTriggerMixing); const float perTriggerWeight = 1. / (mixUpToTriggerN - iStartTrigger); // mixUpToTriggerN <= iStartTrigger caught by break statement of loop @@ -1164,8 +1246,8 @@ struct HadronPhotonCorrelation { { // analysis info int64_t const noLaterThanCcdb = - noLaterThanCcdbConfig == -1 ? std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count() : noLaterThanCcdbConfig; - ccdb->setURL(urlCcdb); + config.noLaterThanCcdbConfig.value == -1 ? std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count() : config.noLaterThanCcdbConfig.value; + ccdb->setURL(config.urlCcdb.value); // enabling object caching (otherwise each call goes to CCDB server) ccdb->setCaching(true); // ccdb->setLocalObjectValidityChecking(); @@ -1176,9 +1258,18 @@ struct HadronPhotonCorrelation { // check coherent config double const doublePrecisionDeltaCheck = 1e-5; - if (std::abs(ptTrigMin - configHist.binsPtTrig.value[0]) > doublePrecisionDeltaCheck) { + if (std::abs(config.ptTrigMin.value - configHist.binsPtTrig.value.at(0)) > doublePrecisionDeltaCheck) { throw std::runtime_error("ptTrigMin does not match trigger axis"); } + if (config.applyScalingPhotonPt.value && (config.parScalingPhotonPtData.value.size() != 6 || config.parScalingPhotonPtMc.value.size() != 6)) { + throw std::runtime_error("wrong number of mc scaling params for photon"); + } + if (config.applyScalingPi0Pt.value && (config.parScalingPi0PtData.value.size() != 6 || config.parScalingPi0PtMc.value.size() != 6)) { + throw std::runtime_error("wrong number of mc scaling params for pi0"); + } + if (config.applyScalingEtaPt.value && (config.parScalingEtaPtData.value.size() != 6 || config.parScalingEtaPtMc.value.size() != 6)) { + throw std::runtime_error("wrong number of mc scaling params for eta"); + } // histograms from ccdb initCcdbHistograms(noLaterThanCcdb); @@ -1187,16 +1278,16 @@ struct HadronPhotonCorrelation { initHistograms(); // mixing trigger memory - triggerMemoryReco = std::make_unique(configHist.binsZPvBinning, configHist.binsMultBinning, nTriggerSavedForMixing); - triggerMemoryTrue = std::make_unique(configHist.binsZPvBinningMcTrue, configHist.binsMultBinningMcTrue, nTriggerSavedForMixing); - triggerMemoryTrueAssocEv = std::make_unique(configHist.binsZPvBinningMcTrue, configHist.binsMultBinningMcTrue, nTriggerSavedForMixing); - triggerMemoryTrueAssocEvRecoPtTrig = std::make_unique(configHist.binsZPvBinningMcTrue, configHist.binsMultBinningMcTrue, nTriggerSavedForMixing); + triggerMemoryReco = std::make_unique(configHist.binsZPvBinning.value, configHist.binsMultBinning.value, config.nTriggerSavedForMixing.value); + triggerMemoryTrue = std::make_unique(configHist.binsZPvBinningMcTrue.value, configHist.binsMultBinningMcTrue.value, config.nTriggerSavedForMixing.value); + triggerMemoryTrueAssocEv = std::make_unique(configHist.binsZPvBinningMcTrue.value, configHist.binsMultBinningMcTrue.value, config.nTriggerSavedForMixing.value); + triggerMemoryTrueAssocEvRecoPtTrig = std::make_unique(configHist.binsZPvBinningMcTrue.value, configHist.binsMultBinningMcTrue.value, config.nTriggerSavedForMixing.value); // init EM pcm cut class initV0PhotonCut(); } - // reconstructed //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // reco only //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ========================================================================================================================================================================================== // correlations ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1237,11 +1328,11 @@ struct HadronPhotonCorrelation { auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); auto const [assocsThisEvent, nMixingAt0] = [&]() { if constexpr (AssocTypeV == AssocType::Hadron) { - return std::tuple{assocs.sliceBy(perColHadrons, collision.globalIndex()), nMixingAt0Hadron.value}; + return std::tuple{assocs.sliceBy(perColHadrons, collision.globalIndex()), config.nMixingAt0Hadron.value}; } else if constexpr (AssocTypeV == AssocType::Pipm) { - return std::tuple{assocs.sliceBy(perColPipms, collision.globalIndex()), nMixingAt0Pipm.value}; + return std::tuple{assocs.sliceBy(perColPipms, collision.globalIndex()), config.nMixingAt0Pipm.value}; } else if constexpr (AssocTypeV == AssocType::PhotonPcm) { - return std::tuple{assocs.sliceBy(perColPhotonPcms, collision.globalIndex()), nMixingAt0PhotonPcm.value}; + return std::tuple{assocs.sliceBy(perColPhotonPcms, collision.globalIndex()), config.nMixingAt0PhotonPcm.value}; } else { static_assert(AlwaysFalseValue, "assocType not supported"); } @@ -1254,6 +1345,7 @@ struct HadronPhotonCorrelation { } HistFillInfoPlainPhiEtaZPvMult histFillInfo = {collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), collision.posZ(), static_cast(collision.nGlobalTracks())}; + histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated); fillHistMain(histFillInfo); }; corrProcessPlain(collision, assocsThisEvent, funcPlain); @@ -1270,28 +1362,27 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(trigger.phi(), associated.phi()), trigger.eta() - associated.eta(), trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = getTriggerPtCorrection(trigger.pt()); + histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(trigger.pt()); fillHistMain(histFillInfo); }; corrProcessCorrelation(collision, triggersThisEvent, assocsThisEvent, funcCorrelation); // select mixing events - if (doTrigEvMixing && !collision.trigEv()) { + if (config.doTrigEvMixing.value && !collision.trigEv()) { continue; } - auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { + auto const conditionMixAssocOnly = [this](auto const& associated) { // reco assoc selection - if (!isSelectedAssoc(associated)) { - return; - } - + return isSelectedAssoc(associated); + }; + auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = perTriggerWeight * getTriggerPtCorrection(mixingTrigger.pt()); + histFillInfo.weight = perTriggerWeight * getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(mixingTrigger.pt()); fillHistMain(histFillInfo); }; - corrProcessMixing(collision, assocsThisEvent, funcMixing, nMixingAt0); + corrProcessMixing(collision, assocsThisEvent, funcMixing, nMixingAt0, conditionMixAssocOnly); } } @@ -1377,11 +1468,15 @@ struct HadronPhotonCorrelation { return; } + double const weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated); + // mgg distribution histos.fill(HIST("reco/plain/h5_ptTrigPtAssocMggZPvMult_reco_photonPcmPair"), - collision.ptMax(), associated.pt(), associated.mgg(), collision.posZ(), collision.nGlobalTracks()); + collision.ptMax(), associated.pt(), associated.mgg(), collision.posZ(), collision.nGlobalTracks(), + weight); - HistFillInfoPlainPt const histFillInfo = {collision.ptMax(), associated.pt()}; + HistFillInfoPlainPt histFillInfo = {collision.ptMax(), associated.pt()}; + histFillInfo.weight = weight; fillAssocsRecoPhotonPcmPair(histFillInfo, associated.mgg()); }; corrProcessPlain(collision, photonPcmPairsThisEvent, funcPlain); @@ -1396,7 +1491,7 @@ struct HadronPhotonCorrelation { return; } - double const weight = getTriggerPtCorrection(trigger.pt()); + double const weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(trigger.pt()); // mgg distribution histos.fill(HIST("reco/corr/h5_ptTrigPtAssocMggZPvMult_reco_photonPcmPair"), @@ -1411,22 +1506,21 @@ struct HadronPhotonCorrelation { corrProcessCorrelation(collision, triggersThisEvent, photonPcmPairsThisEvent, funcCorrelation); // select mixing events - if (doTrigEvMixing && !collision.trigEv()) { + if (config.doTrigEvMixing.value && !collision.trigEv()) { continue; } - auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { + auto const conditionMixAssocOnly = [this](auto const& associated) { // reco assoc selection - if (!isSelectedAssoc(associated)) { - return; - } - + return isSelectedAssoc(associated); + }; + auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = perTriggerWeight * getTriggerPtCorrection(mixingTrigger.pt()); + histFillInfo.weight = perTriggerWeight * getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(mixingTrigger.pt()); fillAssocsRecoPhotonPcmPair(histFillInfo, associated.mgg()); }; - corrProcessMixing(collision, photonPcmPairsThisEvent, funcMixing, nMixingAt0PhotonPcmPair); + corrProcessMixing(collision, photonPcmPairsThisEvent, funcMixing, config.nMixingAt0PhotonPcmPair.value, conditionMixAssocOnly); } } PROCESS_SWITCH(HadronPhotonCorrelation, processRecoPhotonPcmPair, "process standard for associated photonPcmPair", false); @@ -1436,7 +1530,7 @@ struct HadronPhotonCorrelation { { BinningZPvMult const binningZPvMult{{prependVariableWidth(configHist.binsZPvBinning.value), prependVariableWidth(configHist.binsMultBinning.value)}, true}; auto photonPcmsTuple = std::make_tuple(photonPcms); - SameKindPair pairs{binningZPvMult, nNeighboursMixingPhotonPcmPair, -1, collisions, photonPcmsTuple, &cache}; + SameKindPair pairs{binningZPvMult, config.nNeighboursMixingPhotonPcmPair.value, -1, collisions, photonPcmsTuple, &cache}; // mixed events for (auto pair = pairs.begin(); pair != pairs.end(); pair++) { @@ -1451,7 +1545,7 @@ struct HadronPhotonCorrelation { ROOT::Math::PtEtaPhiMVector const p4photonPcm2(photonPcm2.pt(), photonPcm2.eta(), photonPcm2.phi(), 0.); ROOT::Math::PtEtaPhiMVector const p4photonPcmPair = p4photonPcm1 + p4photonPcm2; - if (std::abs(p4photonPcmPair.eta()) > absEtaMax) { + if (std::abs(p4photonPcmPair.eta()) > config.absEtaMax.value) { continue; } // reco assoc selection @@ -1462,7 +1556,8 @@ struct HadronPhotonCorrelation { continue; } - histos.fill(HIST("reco/plain/h4_ptMggZPvMult_photonPcmPair_evMix"), p4photonPcmPair.pt(), p4photonPcmPair.M(), collision1.posZ(), collision1.nGlobalTracks()); + histos.fill(HIST("reco/plain/h4_ptMggZPvMult_photonPcmPair_evMix"), + p4photonPcmPair.pt(), p4photonPcmPair.M(), collision1.posZ(), collision1.nGlobalTracks()); } } } @@ -1485,8 +1580,11 @@ struct HadronPhotonCorrelation { continue; } + double const weight = getMcAssocPtScaling(photonPcm) * getMcK0ShortPtScaling(photonPcm); + histos.fill(HIST("reco/plain/h5_ptTrigPtAssocDcaZZPvMult_photonPcm"), - collision.ptMax(), photonPcm.pt(), photonPcm.v0PhotonKF().dcaZtopv(), collision.posZ(), collision.nGlobalTracks()); + collision.ptMax(), photonPcm.pt(), photonPcm.v0PhotonKF().dcaZtopv(), collision.posZ(), collision.nGlobalTracks(), + weight); } } PROCESS_SWITCH(HadronPhotonCorrelation, processPcmDcaZ, "process to test dcaZ distribution of photons", false); @@ -1612,9 +1710,9 @@ struct HadronPhotonCorrelation { }(); template - void fillAssocsMcTrue(auto const& histFillInfo, auto const& assocParticle, T_DecaySelfTrigFunc const& isDecaySelfTrig = T_DecaySelfTrigFunc{}) { + void fillAssocsMcTrue(auto histFillInfo, auto const& assocParticle, T_DecaySelfTrigFunc const& isDecaySelfTrig = {}) { // main eta cut - if (std::abs(assocParticle.eta()) > absEtaMax) { + if (std::abs(assocParticle.eta()) > config.absEtaMax.value) { return; } @@ -1631,6 +1729,9 @@ struct HadronPhotonCorrelation { } // photon if (assocParticle.pdgCode() == PDG_t::kGamma) { + // mc-to-data scaling + histFillInfo.weight *= getMcAssocPtScalingFromPt(assocParticle.pt()); + fillHistMain(histFillInfo); // extra info for decay correlation only for total true level @@ -1679,6 +1780,9 @@ struct HadronPhotonCorrelation { } // pi0 if (assocParticle.pdgCode() == PDG_t::kPi0) { + // mc-to-data scaling + histFillInfo.weight *= getMcAssocPtScalingFromPt(assocParticle.pt()); + if constexpr (TruthLevelV == TruthLevel::True) { fillHistMain(histFillInfo); } @@ -1704,7 +1808,7 @@ struct HadronPhotonCorrelation { } fillHistMain(histFillInfo); // daughters in acceptance - if (!checkDaughtersInAcceptance(assocParticle, {-absEtaMax, absEtaMax})) { + if (!checkDaughtersInAcceptance(assocParticle, {-config.absEtaMax.value, config.absEtaMax.value})) { return; } fillHistMain(histFillInfo); @@ -1713,6 +1817,9 @@ struct HadronPhotonCorrelation { } // eta if (assocParticle.pdgCode() == constants::physics::Pdg::kEta) { + // mc-to-data scaling + histFillInfo.weight *= getMcAssocPtScalingFromPt(assocParticle.pt()); + if constexpr (TruthLevelV == TruthLevel::True) { fillHistMain(histFillInfo); } @@ -1738,7 +1845,7 @@ struct HadronPhotonCorrelation { } fillHistMain(histFillInfo); // daughters in acceptance - if (!checkDaughtersInAcceptance(assocParticle, {-absEtaMax, absEtaMax})) { + if (!checkDaughtersInAcceptance(assocParticle, {-config.absEtaMax.value, config.absEtaMax.value})) { return; } fillHistMain(histFillInfo); @@ -1804,7 +1911,7 @@ struct HadronPhotonCorrelation { corrProcessCorrelation(mcCollision, trueTriggersThisEvent, mcParticlesThisEvent, funcCorrelation); // select mixing events - if (doTrigEvMixing && !mcCollision.trigEv()) { + if (config.doTrigEvMixing.value && !mcCollision.trigEv()) { continue; } @@ -1814,7 +1921,7 @@ struct HadronPhotonCorrelation { histFillInfo.weight = perTriggerWeight; fillAssocsMcTrue(histFillInfo, assocParticle); }; - corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, nMixingAt0McTrue); + corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, config.nMixingAt0McTrue.value); } } PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrue, "process mc-true (all collisions) for multiple associated particles", false); @@ -1868,7 +1975,7 @@ struct HadronPhotonCorrelation { corrProcessCorrelation(mcCollision, trueTriggersThisEvent, mcParticlesThisEvent, funcCorrelation); // select mixing events - if (doTrigEvMixing && !collision.trigEv()) { + if (config.doTrigEvMixing.value && !collision.trigEv()) { continue; } @@ -1878,7 +1985,7 @@ struct HadronPhotonCorrelation { histFillInfo.weight = perTriggerWeight; fillAssocsMcTrue(histFillInfo, assocParticle); }; - corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, nMixingAt0McTrue); + corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, config.nMixingAt0McTrue.value); } } PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueAssocEv, "process mc-true (reco collisions) correlation for multiple associated particles", false); @@ -1944,7 +2051,7 @@ struct HadronPhotonCorrelation { corrProcessCorrelation(mcCollision, triggersThisEvent, mcParticlesThisEvent, funcCorrelation); // select mixing events - if (doTrigEvMixing && !collision.trigEv()) { + if (config.doTrigEvMixing.value && !collision.trigEv()) { continue; } @@ -1954,7 +2061,7 @@ struct HadronPhotonCorrelation { histFillInfo.weight = perTriggerWeight; fillAssocsMcTrue(histFillInfo, assocParticle, [](){ return false; }); }; - corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, nMixingAt0McTrue); + corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, config.nMixingAt0McTrue.value); } } PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueAssocEvRecoPtTrig, "process mc-true (reco collisions with reco ptTrig) correlation for multiple associated particles", false); @@ -2008,12 +2115,13 @@ struct HadronPhotonCorrelation { }(); template - void fillTruthLevelsMcRecoStd(auto& histFillInfo, auto const& collision, auto const& associated) { + void fillTruthLevelsMcRecoStd(auto histFillInfo, auto const& collision, auto const& associated) { // photon impurity if constexpr (HistFillModeV == HistFillMode::Plain && AssocTypeV == AssocType::PhotonPcm) { PhotonImpurity const impurity = static_cast(associated.impurityPhotonPcm()); histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_recoImpurities_photonPcm"), - collision.ptMax(), associated.pt(), binValuePhotonImpurity(impurity)); + collision.ptMax(), associated.pt(), binValuePhotonImpurity(impurity), + histFillInfo.weight); } // collision association if (!checkTruthLevelReco(associated)) { @@ -2043,11 +2151,11 @@ struct HadronPhotonCorrelation { auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); auto const [assocsThisEvent, nMixingAt0] = [&]() { if constexpr (AssocTypeV == AssocType::Hadron) { - return std::tuple{assocs.sliceBy(perColHadrons, collision.globalIndex()), nMixingAt0Hadron.value}; + return std::tuple{assocs.sliceBy(perColHadrons, collision.globalIndex()), config.nMixingAt0Hadron.value}; } else if constexpr (AssocTypeV == AssocType::Pipm) { - return std::tuple{assocs.sliceBy(perColPipms, collision.globalIndex()), nMixingAt0Pipm.value}; + return std::tuple{assocs.sliceBy(perColPipms, collision.globalIndex()), config.nMixingAt0Pipm.value}; } else if constexpr (AssocTypeV == AssocType::PhotonPcm) { - return std::tuple{assocs.sliceBy(perColPhotonPcms, collision.globalIndex()), nMixingAt0PhotonPcm.value}; + return std::tuple{assocs.sliceBy(perColPhotonPcms, collision.globalIndex()), config.nMixingAt0PhotonPcm.value}; } else { static_assert(AlwaysFalseValue, "assocType not supported"); } @@ -2060,6 +2168,7 @@ struct HadronPhotonCorrelation { } HistFillInfoPlainPhiEtaZPvMult histFillInfo = {collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), collision.posZ(), static_cast(collision.nGlobalTracks())}; + histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated); fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); }; corrProcessPlain(collision, assocsThisEvent, funcPlain); @@ -2076,28 +2185,27 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(trigger.phi(), associated.phi()), trigger.eta() - associated.eta(), trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = getTriggerPtCorrection(trigger.pt()); + histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(trigger.pt()); fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); }; corrProcessCorrelation(collision, triggersThisEvent, assocsThisEvent, funcCorrelation); // select mixing events - if (doTrigEvMixing && !collision.trigEv()) { + if (config.doTrigEvMixing.value && !collision.trigEv()) { continue; } - auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { + auto const conditionMixAssocOnly = [this](auto const& associated) { // reco assoc selection - if (!isSelectedAssoc(associated)) { - return; - } - + return isSelectedAssoc(associated); + }; + auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = perTriggerWeight * getTriggerPtCorrection(mixingTrigger.pt()); + histFillInfo.weight = perTriggerWeight * getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(mixingTrigger.pt()); fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); }; - corrProcessMixing(collision, assocsThisEvent, funcMixing, nMixingAt0); + corrProcessMixing(collision, assocsThisEvent, funcMixing, nMixingAt0, conditionMixAssocOnly); } } @@ -2158,12 +2266,13 @@ struct HadronPhotonCorrelation { }(); template - void fillTruthLevelsMcRecoPhotonPcmPair(auto& histFillInfo, auto const& collision, auto const& associated) { + void fillTruthLevelsMcRecoPhotonPcmPair(auto histFillInfo, auto const& collision, auto const& associated) { // pi0 impurity if constexpr (HistFillModeV == HistFillMode::Plain && AssocTypeV == AssocType::Pi0Pcm) { PhotonImpurity const impurity = static_cast(associated.impurityPi0Pcm()); histos.fill(HIST("mc/plain/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0Pcm"), - collision.ptMax(), associated.pt(), binValuePhotonImpurity(impurity)); + collision.ptMax(), associated.pt(), binValuePhotonImpurity(impurity), + histFillInfo.weight); } // collision association if (!checkTruthLevelReco(associated)) { @@ -2181,7 +2290,7 @@ struct HadronPhotonCorrelation { } template - void fillAssocsMcRecoPhotonPcmPair(auto& histFillInfo, auto const& collision, auto const& associated) { + void fillAssocsMcRecoPhotonPcmPair(auto histFillInfo, auto const& collision, auto const& associated) { // pi0Pcm if (checkTruthLevelReco(associated)) { // pseudo yield @@ -2189,7 +2298,8 @@ struct HadronPhotonCorrelation { // mgg distribution if constexpr (HistFillModeV == HistFillMode::Plain) { histos.fill(HIST("mc/plain/h5_ptTrigPtAssocMggZPvMult_pseudoReco_pi0Pcm"), - histFillInfo.ptMax, histFillInfo.ptAssoc, associated.mgg(), collision.posZ(), collision.nGlobalTracks()); + histFillInfo.ptMax, histFillInfo.ptAssoc, associated.mgg(), collision.posZ(), collision.nGlobalTracks(), + histFillInfo.weight); } else if constexpr (HistFillModeV == HistFillMode::Correlation) { histos.fill(HIST("mc/corr/h5_ptTrigPtAssocMggZPvMult_pseudoReco_pi0Pcm"), histFillInfo.ptTrig, histFillInfo.ptAssoc, associated.mgg(), collision.posZ(), collision.nGlobalTracks(), @@ -2210,7 +2320,8 @@ struct HadronPhotonCorrelation { // mgg distribution if constexpr (HistFillModeV == HistFillMode::Plain) { histos.fill(HIST("mc/plain/h5_ptTrigPtAssocMggZPvMult_pseudoReco_etaPcm"), - histFillInfo.ptMax, histFillInfo.ptAssoc, associated.mgg(), collision.posZ(), collision.nGlobalTracks()); + histFillInfo.ptMax, histFillInfo.ptAssoc, associated.mgg(), collision.posZ(), collision.nGlobalTracks(), + histFillInfo.weight); } else if constexpr (HistFillModeV == HistFillMode::Correlation) { histos.fill(HIST("mc/corr/h5_ptTrigPtAssocMggZPvMult_pseudoReco_etaPcm"), histFillInfo.ptTrig, histFillInfo.ptAssoc, associated.mgg(), collision.posZ(), collision.nGlobalTracks(), @@ -2242,6 +2353,7 @@ struct HadronPhotonCorrelation { } HistFillInfoPlainPt histFillInfo = {collision.ptMax(), associated.pt()}; + histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated); fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); }; corrProcessPlain(collision, photonPcmPairsThisEvent, funcPlain); @@ -2258,28 +2370,27 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(trigger.phi(), associated.phi()), trigger.eta() - associated.eta(), trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = getTriggerPtCorrection(trigger.pt()); + histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(trigger.pt()); fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); }; corrProcessCorrelation(collision, triggersThisEvent, photonPcmPairsThisEvent, funcCorrelation); // select mixing events - if (doTrigEvMixing && !collision.trigEv()) { + if (config.doTrigEvMixing.value && !collision.trigEv()) { continue; } - auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { + auto const conditionMixAssocOnly = [this](auto const& associated) { // reco assoc selection - if (!isSelectedAssoc(associated)) { - return; - } - + return isSelectedAssoc(associated); + }; + auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = perTriggerWeight * getTriggerPtCorrection(mixingTrigger.pt()); + histFillInfo.weight = perTriggerWeight * getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(mixingTrigger.pt()); fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); }; - corrProcessMixing(collision, photonPcmPairsThisEvent, funcMixing, nMixingAt0PhotonPcmPair); + corrProcessMixing(collision, photonPcmPairsThisEvent, funcMixing, config.nMixingAt0PhotonPcmPair.value, conditionMixAssocOnly); } } @@ -2317,8 +2428,11 @@ struct HadronPhotonCorrelation { continue; } + double const weight = getMcAssocPtScaling(photonPcm) * getMcK0ShortPtScaling(photonPcm); + histos.fill(HIST("mc/plain/h5_ptTrigPtAssocDcaZZPvMult_photonPcm"), - collision.ptMax(), photonPcm.pt(), photonPcm.v0PhotonKF().dcaZtopv(), collision.posZ(), collision.nGlobalTracks()); + collision.ptMax(), photonPcm.pt(), photonPcm.v0PhotonKF().dcaZtopv(), collision.posZ(), collision.nGlobalTracks(), + weight); } } PROCESS_SWITCH(HadronPhotonCorrelation, processPcmDcaZTrue, "process to test true dcaZ distribution of photons in trigger collisions", false); diff --git a/PWGJE/Tasks/hadronPhotonProducer.cxx b/PWGJE/Tasks/hadronPhotonProducer.cxx index 1eebee9f73e..8185e2171b9 100644 --- a/PWGJE/Tasks/hadronPhotonProducer.cxx +++ b/PWGJE/Tasks/hadronPhotonProducer.cxx @@ -600,7 +600,7 @@ struct HadronPhotonProducer { } PROCESS_SWITCH(HadronPhotonProducer, processMcRecoCollisionTrigger, "process correlation collision_extra and trigger table (reconstructed MC)", false); - template + template void fillProcessRecoHadronPipm(auto const& collisions, auto const& tracks) { for (auto const& collision : collisions) { @@ -644,7 +644,7 @@ struct HadronPhotonProducer { tableProduction.hadronTrackId(track.globalIndex()); // pipm selection - auto const& trackPid = track.template track_as(); + auto const& trackPid = track.template track_as(); if constexpr (requires { trackPid.tofNSigmaPi(); }) { if (!checkPipmTPCTOF(trackPid)) { continue; From 7ff2d0ba8dcf5a79bd3fa1b6aaf1bc9f6d3d4a12 Mon Sep 17 00:00:00 2001 From: jkinner2 Date: Fri, 6 Nov 2026 17:59:10 +0100 Subject: [PATCH 06/13] simplifyHistNamingStructure --- .../TableProducer/photonconversionbuilder.h | 4 +- PWGJE/DataModel/HadronPhotonCorrelation.h | 176 +-- PWGJE/Tasks/hadronPhotonCorrelation.cxx | 1032 ++++++++--------- PWGJE/Tasks/hadronPhotonProducer.cxx | 117 +- 4 files changed, 653 insertions(+), 676 deletions(-) diff --git a/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.h b/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.h index fff39a0df75..2fafaadaff0 100644 --- a/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.h +++ b/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.h @@ -2533,7 +2533,9 @@ struct PhotonConversionBuilder { } if (nGreedyFallback > 0) { - LOGF(warning, "group matching: %d conflict group(s) larger than dedupMaxGroupSize = %d were solved greedily", nGreedyFallback, maxEnum); + LOGF(warning, "group matching: %d conflict group(s) larger than dedupMaxGroupSize = %d of nGroups = %li were solved greedily", nGreedyFallback, maxEnum, groups.size()); + } else { + LOGF(warning, "group matching: groups = %li", groups.size()); } // the table expects candidates ordered by collision diff --git a/PWGJE/DataModel/HadronPhotonCorrelation.h b/PWGJE/DataModel/HadronPhotonCorrelation.h index 979f776bd66..21b7cda2945 100644 --- a/PWGJE/DataModel/HadronPhotonCorrelation.h +++ b/PWGJE/DataModel/HadronPhotonCorrelation.h @@ -24,6 +24,8 @@ #include +namespace hpc { + enum class AssocType { Hadron, Pipm, @@ -59,11 +61,36 @@ enum class TruthLevel : int { PseudoRecoPureTruePtAssoc = 8, TrueGeoAcc = 9, TrueMeasDecay = 10, - TrueAssocEvRecoPtTrig = 11, - TrueAssocEv = 12, + TrueRecoEvRecoPtTrig = 11, + TrueRecoEv = 12, True = 13, TrueDecaySelfTrig = 14 }; +// true level: associated particles taken from mc truth +constexpr bool isTrueLevel(TruthLevel const truthLevel) +{ + switch (truthLevel) { + case TruthLevel::Unknown: + case TruthLevel::Reco: + case TruthLevel::RecoMcMatched: + case TruthLevel::RecoAssocEv: + case TruthLevel::RecoPure: + case TruthLevel::RecoPureTruePtAssoc: + case TruthLevel::PseudoReco: + case TruthLevel::PseudoRecoAssocEv: + case TruthLevel::PseudoRecoPure: + case TruthLevel::PseudoRecoPureTruePtAssoc: + return false; + case TruthLevel::TrueGeoAcc: + case TruthLevel::TrueMeasDecay: + case TruthLevel::TrueRecoEvRecoPtTrig: + case TruthLevel::TrueRecoEv: + case TruthLevel::True: + case TruthLevel::TrueDecaySelfTrig: + return true; + } + return false; +} enum class PhotonImpurity : int { Unknown = -1, @@ -85,11 +112,13 @@ bool constexpr AlwaysFalseType = false; template bool constexpr AlwaysFalseValue = false; +} // namespace hpc + namespace o2::aod { // common correlation columns -namespace corr_common +namespace hpc_common { DECLARE_SOA_INDEX_COLUMN_FULL(JetMcCollision, jetMcCollision, int, JMcCollisions, ""); DECLARE_SOA_COLUMN(SelEv, selEv, bool); @@ -98,12 +127,12 @@ DECLARE_SOA_COLUMN(PtTruePure, ptTruePure, float); DECLARE_SOA_COLUMN(PtTrueOrigin, ptTrueOrigin, float); // and the blind forest DECLARE_SOA_COLUMN(Phi, phi, float); DECLARE_SOA_COLUMN(Eta, eta, float); -} // namespace corr_common +} // namespace hpc_common // reco // correlation collision -namespace corr_collision +namespace hpc_collision { // plain jet collision column for derived data DECLARE_SOA_COLUMN(JetCollisionId, jetCollisionId, int); @@ -112,85 +141,85 @@ DECLARE_SOA_COLUMN(TrigEv, trigEv, bool); DECLARE_SOA_COLUMN(PtMax, ptMax, float); DECLARE_SOA_COLUMN(PosZ, posZ, float); DECLARE_SOA_COLUMN(NGlobalTracks, nGlobalTracks, int); -} // namespace corr_collision -DECLARE_SOA_TABLE(CorrCollisions, "AOD", "CORRCOLLISION", +} // namespace hpc_collision +DECLARE_SOA_TABLE(HpcCollisions, "AOD", "HPCCOL", o2::soa::Index<>, - corr_common::SelEv, corr_collision::ThirdDecimalTruePosZ, corr_collision::TrigEv, corr_collision::PtMax, corr_collision::PosZ, corr_collision::NGlobalTracks); -DECLARE_SOA_TABLE(CorrCollisionIds, "AOD", "CORRCOLLISIONID", - corr_collision::JetCollisionId); -DECLARE_SOA_TABLE(CorrCollisionMcIds, "AOD", "CORRCOLLISIONMCID", - corr_common::JetMcCollisionId); + hpc_common::SelEv, hpc_collision::ThirdDecimalTruePosZ, hpc_collision::TrigEv, hpc_collision::PtMax, hpc_collision::PosZ, hpc_collision::NGlobalTracks); +DECLARE_SOA_TABLE(HpcCollisionIds, "AOD", "HPCCOLID", + hpc_collision::JetCollisionId); +DECLARE_SOA_TABLE(HpcCollisionMcIds, "AOD", "HPCCOLMCID", + hpc_common::JetMcCollisionId); // add to common columns -namespace corr_common +namespace hpc_common { -DECLARE_SOA_INDEX_COLUMN_FULL(CorrCollision, corrCollision, int, CorrCollisions, ""); -} // namespace corr_common +DECLARE_SOA_INDEX_COLUMN_FULL(CorrCollision, corrCollision, int, HpcCollisions, ""); +} // namespace hpc_common // trigger -namespace trigger +namespace hpc_trigger { DECLARE_SOA_INDEX_COLUMN_FULL(JetTrack, jetTrack, int, JetTracks, ""); -} // namespace trigger -DECLARE_SOA_TABLE(Triggers, "AOD", "TRIGGER", - o2::soa::Index<>, corr_common::CorrCollisionId, - corr_common::Pt, corr_common::Phi, corr_common::Eta); -DECLARE_SOA_TABLE(TriggerTrackIds, "AOD", "TRIGGERTRACKID", - trigger::JetTrackId); +} // namespace hpc_trigger +DECLARE_SOA_TABLE(HpcTriggers, "AOD", "HPCTRIG", + o2::soa::Index<>, hpc_common::CorrCollisionId, + hpc_common::Pt, hpc_common::Phi, hpc_common::Eta); +DECLARE_SOA_TABLE(HpcTriggerTrackIds, "AOD", "HPCTRIGTRID", + hpc_trigger::JetTrackId); // add to common columns -namespace corr_common +namespace hpc_common { -DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(IntersectTrigger, intersectTrigger, int, Triggers, ""); -} // namespace corr_common +DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(IntersectTrigger, intersectTrigger, int, HpcTriggers, ""); +} // namespace hpc_common -// hadrons (global tracks) -namespace hadron +// hadron (global tracks) +namespace hpc_hadron { DECLARE_SOA_INDEX_COLUMN_FULL(JetTrack, jetTrack, int, JetTracks, ""); DECLARE_SOA_COLUMN(TruthLevelRecoHadron, truthLevelRecoHadron, int); -} // namespace hadron -DECLARE_SOA_TABLE(Hadrons, "AOD", "HADRON", - o2::soa::Index<>, corr_common::CorrCollisionId, corr_common::IntersectTriggerIds, - corr_common::Pt, corr_common::Phi, corr_common::Eta, - hadron::TruthLevelRecoHadron, corr_common::PtTruePure); -DECLARE_SOA_TABLE(HadronTrackIds, "AOD", "HADRONTRACKID", - hadron::JetTrackId); +} // namespace hpc_hadron +DECLARE_SOA_TABLE(HpcHadrons, "AOD", "HPCHAD", + o2::soa::Index<>, hpc_common::CorrCollisionId, hpc_common::IntersectTriggerIds, + hpc_common::Pt, hpc_common::Phi, hpc_common::Eta, + hpc_hadron::TruthLevelRecoHadron, hpc_common::PtTruePure); +DECLARE_SOA_TABLE(HpcHadronTrackIds, "AOD", "HPCHADTRID", + hpc_hadron::JetTrackId); // pipm -namespace pipm +namespace hpc_pipm { DECLARE_SOA_INDEX_COLUMN_FULL(JetTrack, jetTrack, int, JetTracks, ""); DECLARE_SOA_COLUMN(TruthLevelRecoPipm, truthLevelRecoPipm, int); -} // namespace pipm -DECLARE_SOA_TABLE(Pipms, "AOD", "PIPM", - o2::soa::Index<>, corr_common::CorrCollisionId, corr_common::IntersectTriggerIds, - corr_common::Pt, corr_common::Phi, corr_common::Eta, - pipm::TruthLevelRecoPipm, corr_common::PtTruePure); -DECLARE_SOA_TABLE(PipmTrackIds, "AOD", "PIPMTRACKID", - pipm::JetTrackId); +} // namespace hpc_pipm +DECLARE_SOA_TABLE(HpcPipms, "AOD", "HPCPIPM", + o2::soa::Index<>, hpc_common::CorrCollisionId, hpc_common::IntersectTriggerIds, + hpc_common::Pt, hpc_common::Phi, hpc_common::Eta, + hpc_pipm::TruthLevelRecoPipm, hpc_common::PtTruePure); +DECLARE_SOA_TABLE(HpcPipmTrackIds, "AOD", "HPCPIPMTRID", + hpc_pipm::JetTrackId); // photonPcm -namespace photon_pcm +namespace hpc_photon_pcm { DECLARE_SOA_INDEX_COLUMN_FULL(V0PhotonKF, v0PhotonKF, int, V0PhotonsKF, ""); DECLARE_SOA_INDEX_COLUMN_FULL(PosJetTrack, posJetTrack, int, JetTracks, "_pos"); DECLARE_SOA_INDEX_COLUMN_FULL(NegJetTrack, negJetTrack, int, JetTracks, "_neg"); DECLARE_SOA_COLUMN(TruthLevelRecoPhotonPcm, truthLevelRecoPhotonPcm, int); DECLARE_SOA_COLUMN(ImpurityPhotonPcm, impurityPhotonPcm, int); -} // namespace photon_pcm -DECLARE_SOA_TABLE(PhotonPcms, "AOD", "PHOTONPCM", - o2::soa::Index<>, corr_common::CorrCollisionId, corr_common::IntersectTriggerIds, - corr_common::Pt, corr_common::Phi, corr_common::Eta, - photon_pcm::TruthLevelRecoPhotonPcm, corr_common::PtTruePure, - photon_pcm::ImpurityPhotonPcm, corr_common::PtTrueOrigin); -DECLARE_SOA_TABLE(PhotonPcmTrackIds, "AOD", "PHOTONPCMTRACKID", - photon_pcm::PosJetTrackId, photon_pcm::NegJetTrackId); -DECLARE_SOA_TABLE(PhotonPcmV0PhotonIds, "AOD", "PHOTONPCMV0PHOTONID", - photon_pcm::V0PhotonKFId); +} // namespace hpc_photon_pcm +DECLARE_SOA_TABLE(HpcPhotonPcms, "AOD", "HPCPHPCM", + o2::soa::Index<>, hpc_common::CorrCollisionId, hpc_common::IntersectTriggerIds, + hpc_common::Pt, hpc_common::Phi, hpc_common::Eta, + hpc_photon_pcm::TruthLevelRecoPhotonPcm, hpc_common::PtTruePure, + hpc_photon_pcm::ImpurityPhotonPcm, hpc_common::PtTrueOrigin); +DECLARE_SOA_TABLE(HpcPhotonPcmTrackIds, "AOD", "HPCPHPCMTRID", + hpc_photon_pcm::PosJetTrackId, hpc_photon_pcm::NegJetTrackId); +DECLARE_SOA_TABLE(HpcPhotonPcmV0PhotonIds, "AOD", "HPCPHPCMV0ID", + hpc_photon_pcm::V0PhotonKFId); // photonPcm pairs -namespace photon_pcm_pair +namespace hpc_photon_pcm_pair { DECLARE_SOA_INDEX_COLUMN_FULL(V0PhotonKF1, v0PhotonKF1, int, V0PhotonsKF, "_1"); DECLARE_SOA_INDEX_COLUMN_FULL(V0PhotonKF2, v0PhotonKF2, int, V0PhotonsKF, "_2"); @@ -202,38 +231,39 @@ DECLARE_SOA_COLUMN(Mgg, mgg, float); DECLARE_SOA_COLUMN(TruthLevelRecoPi0Pcm, truthLevelRecoPi0Pcm, int); DECLARE_SOA_COLUMN(TruthLevelRecoEtaPcm, truthLevelRecoEtaPcm, int); DECLARE_SOA_COLUMN(ImpurityPi0Pcm, impurityPi0Pcm, int); -} // namespace photon_pcm_pair -DECLARE_SOA_TABLE(PhotonPcmPairs, "AOD", "PHOTONPCMPAIR", - o2::soa::Index<>, corr_common::CorrCollisionId, corr_common::IntersectTriggerIds, - corr_common::Pt, corr_common::Phi, corr_common::Eta, photon_pcm_pair::Mgg, - photon_pcm_pair::TruthLevelRecoPi0Pcm, photon_pcm_pair::TruthLevelRecoEtaPcm, corr_common::PtTruePure, - photon_pcm_pair::ImpurityPi0Pcm, corr_common::PtTrueOrigin); -DECLARE_SOA_TABLE(PhotonPcmPairTrackIds, "AOD", "PHOTONPCMPAIRTRACKID", - photon_pcm_pair::PosJetTrack1Id, photon_pcm_pair::NegJetTrack1Id, photon_pcm_pair::PosJetTrack2Id, photon_pcm_pair::NegJetTrack2Id); -DECLARE_SOA_TABLE(PhotonPcmPairV0PhotonIds, "AOD", "PHOTONPCMPAIRV0PHOTONID", - photon_pcm_pair::V0PhotonKF1Id, photon_pcm_pair::V0PhotonKF2Id); +} // namespace hpc_photon_pcm_pair +DECLARE_SOA_TABLE(HpcPhotonPcmPairs, "AOD", "HPCPCMPAIR", + o2::soa::Index<>, hpc_common::CorrCollisionId, hpc_common::IntersectTriggerIds, + hpc_common::Pt, hpc_common::Phi, hpc_common::Eta, hpc_photon_pcm_pair::Mgg, + hpc_photon_pcm_pair::TruthLevelRecoPi0Pcm, hpc_photon_pcm_pair::TruthLevelRecoEtaPcm, hpc_common::PtTruePure, + hpc_photon_pcm_pair::ImpurityPi0Pcm, hpc_common::PtTrueOrigin); +DECLARE_SOA_TABLE(HpcPhotonPcmPairTrackIds, "AOD", "HPCPCMPAIRTRID", + hpc_photon_pcm_pair::PosJetTrack1Id, hpc_photon_pcm_pair::NegJetTrack1Id, hpc_photon_pcm_pair::PosJetTrack2Id, hpc_photon_pcm_pair::NegJetTrack2Id); +DECLARE_SOA_TABLE(HpcPhotonPcmPairV0PhotonIds, "AOD", "HPCPCMPAIRV0ID", + hpc_photon_pcm_pair::V0PhotonKF1Id, hpc_photon_pcm_pair::V0PhotonKF2Id); // mc // mcCollision extension -namespace mc_collision_extra_corr +namespace hpc_mc_collision_extra { DECLARE_SOA_COLUMN(ThirdDecimalTruePosZ, thirdDecimalTruePosZ, int); DECLARE_SOA_COLUMN(TrigEv, trigEv, bool); DECLARE_SOA_COLUMN(PtMax, ptMax, float); DECLARE_SOA_COLUMN(NChargedInEtaRange, nChargedInEtaRange, int); -} // namespace mc_collision_extra_corr -DECLARE_SOA_TABLE(McCollisionsExtraCorr, "AOD", "MCCOLLISIONEXTRACORR", - corr_common::SelEv, mc_collision_extra_corr::ThirdDecimalTruePosZ, mc_collision_extra_corr::TrigEv, mc_collision_extra_corr::PtMax, mc_collision_extra_corr::NChargedInEtaRange); +} // namespace hpc_mc_collision_extra +DECLARE_SOA_TABLE(HpcMcCollisionsExtra, "AOD", "HPCMCCOLEXTRA", + hpc_common::SelEv, hpc_mc_collision_extra::ThirdDecimalTruePosZ, hpc_mc_collision_extra::TrigEv, hpc_mc_collision_extra::PtMax, hpc_mc_collision_extra::NChargedInEtaRange); // trigger -namespace true_trigger +namespace hpc_true_trigger { DECLARE_SOA_INDEX_COLUMN_FULL(JetMcParticle, jetMcParticle, int, JetParticles, ""); -} // namespace true_trigger -DECLARE_SOA_TABLE(TrueTriggers, "AOD", "TRUETRIGGER", - o2::soa::Index<>, corr_common::JetMcCollisionId, true_trigger::JetMcParticleId, - corr_common::Pt, corr_common::Phi, corr_common::Eta); +} // namespace hpc_true_trigger +DECLARE_SOA_TABLE(HpcTrueTriggers, "AOD", "HPCTRUETRIG", + o2::soa::Index<>, hpc_common::JetMcCollisionId, hpc_true_trigger::JetMcParticleId, + hpc_common::Pt, hpc_common::Phi, hpc_common::Eta); + } // namespace o2::aod #endif // PWGJE_DATAMODEL_HADRONPHOTONCORRELATION_H_ diff --git a/PWGJE/Tasks/hadronPhotonCorrelation.cxx b/PWGJE/Tasks/hadronPhotonCorrelation.cxx index 6b32994f9f3..879bce0380c 100644 --- a/PWGJE/Tasks/hadronPhotonCorrelation.cxx +++ b/PWGJE/Tasks/hadronPhotonCorrelation.cxx @@ -63,10 +63,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -75,15 +77,16 @@ using namespace o2; using namespace o2::framework; +using namespace hpc; -using CorrCollisions = aod::CorrCollisions; -using CorrCollisionsMcD = soa::Join; -using CorrMcCollisions = soa::Join; +using HpcCollisions = aod::HpcCollisions; +using HpcCollisionsMcD = soa::Join; +using CorrMcCollisions = soa::Join; -using PhotonPcmsWithV0 = soa::Join; -using PhotonPcmPairsWithV0 = soa::Join; +using PhotonPcmsWithV0 = soa::Join; +using PhotonPcmPairsWithV0 = soa::Join; -using BinningZPvMult = ColumnBinningPolicy; +using BinningZPvMult = ColumnBinningPolicy; // correlation analysis /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // =/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/ @@ -100,9 +103,9 @@ struct HadronPhotonCorrelation { Configurable urlCcdb{"urlCcdb", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable noLaterThanCcdbConfig{"noLaterThanCcdbConfig", -1, "latest acceptable timestamp of creation for the object (-1 for task start time)"}; - // shared across analysis tasks + // central cuts Configurable absEtaMax{"absEtaMax", 0.8, "maximum absEta cut"}; - Configurable ptTrigMin{"ptTrigMin", 5, "minimum pT of triggers"}; + Configurable ptTrigMin{"ptTrigMin", 5, "minimum pt of triggers"}; // analysis settings Configurable splitMcEvN{"splitMcEvN", 1, "number of event fractions for selection in MC (max 10) | (select 1 for data)"}; @@ -153,34 +156,33 @@ struct HadronPhotonCorrelation { // pcm cuts struct : o2::framework::ConfigurableGroup { std::string prefix = "pcmcut_group"; - o2::framework::Configurable cfg_require_v0_with_itstpc{"cfg_require_v0_with_itstpc", false, "flag to select V0s with ITS-TPC matched tracks"}; - o2::framework::Configurable cfg_require_v0_with_itsonly{"cfg_require_v0_with_itsonly", false, "flag to select V0s with ITSonly tracks"}; - o2::framework::Configurable cfg_require_v0_with_tpconly{"cfg_require_v0_with_tpconly", false, "flag to select V0s with TPConly tracks"}; - o2::framework::Configurable cfg_min_pt_v0{"cfg_min_pt_v0", 0.1, "min pT for v0 photons at PV"}; - o2::framework::Configurable cfg_max_pt_v0{"cfg_max_pt_v0", 1e+10, "max pT for v0 photons at PV"}; - o2::framework::Configurable cfg_min_eta_v0{"cfg_min_eta_v0", -0.8, "min eta for v0 photons at PV"}; - o2::framework::Configurable cfg_max_eta_v0{"cfg_max_eta_v0", 0.8, "max eta for v0 photons at PV"}; - o2::framework::Configurable cfg_min_v0radius{"cfg_min_v0radius", 4.0, "min v0 radius"}; - o2::framework::Configurable cfg_max_v0radius{"cfg_max_v0radius", 90.0, "max v0 radius"}; - o2::framework::Configurable cfg_midL_v0radius{"cfg_midL_v0radius", -1.0, "middle low v0 radius for rejection if >0"}; - o2::framework::Configurable cfg_midH_v0radius{"cfg_midH_v0radius", -1.0, "middle high v0 radius for rejection if >0"}; - o2::framework::Configurable cfg_max_alpha_ap{"cfg_max_alpha_ap", 0.95, "max alpha for AP cut"}; - o2::framework::Configurable cfg_max_qt_ap{"cfg_max_qt_ap", 0.01, "max qT for AP cut"}; - o2::framework::Configurable cfg_min_cospa{"cfg_min_cospa", 0.999, "min V0 CosPA"}; - o2::framework::Configurable cfg_max_pca{"cfg_max_pca", 1.5, "max distance btween 2 legs"}; - o2::framework::Configurable cfg_max_chi2kf{"cfg_max_chi2kf", 1e+10, "max chi2/ndf with KF"}; - o2::framework::Configurable cfg_reject_v0_on_itsib{"cfg_reject_v0_on_itsib", true, "flag to reject V0s on ITSib"}; - o2::framework::Configurable cfg_apply_cuts_from_prefilter_derived{"cfg_apply_cuts_from_prefilter_derived", false, "flag to apply prefilter to V0"}; - - o2::framework::Configurable cfg_min_ncluster_tpc{"cfg_min_ncluster_tpc", 0, "min ncluster tpc"}; - o2::framework::Configurable cfg_min_ncrossedrows{"cfg_min_ncrossedrows", 40, "min ncrossed rows"}; - o2::framework::Configurable cfg_max_frac_shared_clusters_tpc{"cfg_max_frac_shared_clusters_tpc", 999.f, "max fraction of shared clusters in TPC"}; - o2::framework::Configurable cfg_max_chi2tpc{"cfg_max_chi2tpc", 4.0, "max chi2/NclsTPC"}; - o2::framework::Configurable cfg_max_chi2its{"cfg_max_chi2its", 36.0, "max chi2/NclsITS"}; - o2::framework::Configurable cfg_min_TPCNsigmaEl{"cfg_min_TPCNsigmaEl", -3.0, "min. TPC n sigma for electron"}; - o2::framework::Configurable cfg_max_TPCNsigmaEl{"cfg_max_TPCNsigmaEl", +3.0, "max. TPC n sigma for electron"}; - o2::framework::Configurable cfg_disable_itsonly_track{"cfg_disable_itsonly_track", false, "flag to disable ITSonly tracks"}; - o2::framework::Configurable cfg_disable_tpconly_track{"cfg_disable_tpconly_track", false, "flag to disable TPConly tracks"}; + o2::framework::Configurable cfgRequireV0WithItstpc{"cfgRequireV0WithItstpc", false, "flag to select V0s with ITS-TPC matched tracks"}; + o2::framework::Configurable cfgRequireV0WithItsonly{"cfgRequireV0WithItsonly", false, "flag to select V0s with ITSonly tracks"}; + o2::framework::Configurable cfgRequireV0WithTpconly{"cfgRequireV0WithTpconly", false, "flag to select V0s with TPConly tracks"}; + o2::framework::Configurable cfgMinPtV0{"cfgMinPtV0", 0.1, "min pt for v0 photons at PV"}; + o2::framework::Configurable cfgMaxPtV0{"cfgMaxPtV0", 1e+10, "max pt for v0 photons at PV"}; + o2::framework::Configurable cfgMinEtaV0{"cfgMinEtaV0", -1e+10, "min eta for v0 photons at PV"}; + o2::framework::Configurable cfgMaxEtaV0{"cfgMaxEtaV0", 1e+10, "max eta for v0 photons at PV"}; + o2::framework::Configurable cfgMinV0radius{"cfgMinV0radius", 4.0, "min v0 radius"}; + o2::framework::Configurable cfgMaxV0radius{"cfgMaxV0radius", 90.0, "max v0 radius"}; + o2::framework::Configurable cfgMidLV0radius{"cfgMidLV0radius", -1.0, "middle low v0 radius for rejection if >0"}; + o2::framework::Configurable cfgMidHV0radius{"cfgMidHV0radius", -1.0, "middle high v0 radius for rejection if >0"}; + o2::framework::Configurable cfgMaxAlphaAp{"cfgMaxAlphaAp", 0.95, "max alpha for AP cut"}; + o2::framework::Configurable cfgMaxQtAp{"cfgMaxQtAp", 0.01, "max qT for AP cut"}; + o2::framework::Configurable cfgMinCospa{"cfgMinCospa", 0.999, "min V0 CosPA"}; + o2::framework::Configurable cfgMaxPca{"cfgMaxPca", 1.5, "max distance btween 2 legs"}; + o2::framework::Configurable cfgMaxChi2kf{"cfgMaxChi2kf", 1e+10, "max chi2/ndf with KF"}; + o2::framework::Configurable cfgRejectV0OnItsib{"cfgRejectV0OnItsib", true, "flag to reject V0s on ITSib"}; + + o2::framework::Configurable cfgMinNclusterTpc{"cfgMinNclusterTpc", 0, "min ncluster tpc"}; + o2::framework::Configurable cfgMinNcrossedrows{"cfgMinNcrossedrows", 40, "min ncrossed rows"}; + o2::framework::Configurable cfgMaxFracSharedClustersTpc{"cfgMaxFracSharedClustersTpc", 999.f, "max fraction of shared clusters in TPC"}; + o2::framework::Configurable cfgMaxChi2tpc{"cfgMaxChi2tpc", 4.0, "max chi2/NclsTPC"}; + o2::framework::Configurable cfgMaxChi2its{"cfgMaxChi2its", 36.0, "max chi2/NclsITS"}; + o2::framework::Configurable cfgMinTPCNsigmaEl{"cfgMinTPCNsigmaEl", -3.0, "min. TPC n sigma for electron"}; + o2::framework::Configurable cfgMaxTPCNsigmaEl{"cfgMaxTPCNsigmaEl", +3.0, "max. TPC n sigma for electron"}; + o2::framework::Configurable cfgDisableItsonlyTrack{"cfgDisableItsonlyTrack", false, "flag to disable ITSonly tracks"}; + o2::framework::Configurable cfgDisableTpconlyTrack{"cfgDisableTpconlyTrack", false, "flag to disable TPConly tracks"}; } configPcmCuts; // histogram config @@ -196,7 +198,7 @@ struct HadronPhotonCorrelation { Configurable> binsPtTrig{"binsPtTrig", {5, 10, 25, 100}, "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, 25, 35, 50, 100}, + 12.5, 15, 17.5, 20, 25, 35, 50, 100}, "correlation ptAssoc bins"}; Configurable> binsDPhi{"binsDPhi", {(0.00 - 1. / 4) * constants::math::TwoPI, @@ -259,15 +261,8 @@ struct HadronPhotonCorrelation { enum class TriggerMemoryMode { Reco, True, - TrueAssocEv, - TrueAssocEvRecoPtTrig - }; - - struct HistPathEntry { - HistFillMode fillMode; - TruthLevel truthLevel; - AssocType assocType; - char const* path; + TrueRecoEv, + TrueRecoEvRecoPtTrig }; struct HistFillInfoPlainPt { @@ -303,13 +298,13 @@ struct HadronPhotonCorrelation { // prepare for per collision slicing Preslice perColTracks = aod::jtrack::collisionId; - Preslice perColTriggers = aod::corr_common::corrCollisionId; - Preslice perColHadrons = aod::corr_common::corrCollisionId; - Preslice perColPipms = aod::corr_common::corrCollisionId; - Preslice perColPhotonPcms = aod::corr_common::corrCollisionId; - Preslice perColPhotonPcmPairs = aod::corr_common::corrCollisionId; + Preslice perColTriggers = aod::hpc_common::corrCollisionId; + Preslice perColHadrons = aod::hpc_common::corrCollisionId; + Preslice perColPipms = aod::hpc_common::corrCollisionId; + Preslice perColPhotonPcms = aod::hpc_common::corrCollisionId; + Preslice perColPhotonPcmPairs = aod::hpc_common::corrCollisionId; Preslice perColMcParticles = aod::jmcparticle::mcCollisionId; - Preslice perColTrueTriggers = aod::corr_common::jetMcCollisionId; + Preslice perColTrueTriggers = aod::hpc_common::jetMcCollisionId; // declare analysis variables @@ -445,8 +440,8 @@ struct HadronPhotonCorrelation { // different buffers for mixing modes std::unique_ptr triggerMemoryReco; std::unique_ptr triggerMemoryTrue; - std::unique_ptr triggerMemoryTrueAssocEv; - std::unique_ptr triggerMemoryTrueAssocEvRecoPtTrig; + std::unique_ptr triggerMemoryTrueRecoEv; + std::unique_ptr triggerMemoryTrueRecoEvRecoPtTrig; // pcm cut class V0PhotonCut fV0PhotonCut; @@ -464,6 +459,16 @@ struct HadronPhotonCorrelation { return result; } + static std::vector getBinEdges(TH1 const* h1) + { + std::vector edges; + for (int iBin = 1; iBin <= h1->GetNbinsX(); iBin++) { + edges.push_back(h1->GetXaxis()->GetBinLowEdge(iBin)); + } + edges.push_back(h1->GetXaxis()->GetXmax()); + return edges; + } + // get histograms from ccdb // save corrections from ccdb in histogram registry void initCcdbHistograms(int64_t const noLaterThanCcdb) @@ -473,7 +478,7 @@ struct HadronPhotonCorrelation { h1PtCorrectionTrigger = ccdb->getForTimeStamp(config.pathCcdbAnalysis.value + "/correction/trigger", noLaterThanCcdb); const double* bins = h1PtCorrectionTrigger->GetXaxis()->GetXbins()->GetArray(); - const AxisSpec axis{std::vector(bins, bins + h1PtCorrectionTrigger->GetNbinsX() + 1), "#it{p}_{T}"}; + const AxisSpec axis{getBinEdges(h1PtCorrectionTrigger), "#it{p}_{T}"}; histos.add("usedObjectsCcdb/h1_pt_correction_trigger_ccdb", "h1_pt_correction_trigger_ccdb", kTH1D, {axis}, true); for (int iBin = 0; iBin <= h1PtCorrectionTrigger->GetNbinsX() + 1; iBin++) { histos.get(HIST("usedObjectsCcdb/h1_pt_correction_trigger_ccdb"))->SetBinContent(iBin, h1PtCorrectionTrigger->GetBinContent(iBin)); @@ -485,7 +490,7 @@ struct HadronPhotonCorrelation { h1PtScalingK0Short = ccdb->getForTimeStamp(config.pathCcdbAnalysis.value + "/scaling/K0Short", noLaterThanCcdb); const double* bins = h1PtScalingK0Short->GetXaxis()->GetXbins()->GetArray(); - const AxisSpec axis{std::vector(bins, bins + h1PtScalingK0Short->GetNbinsX() + 1), "#it{p}_{T}"}; + const AxisSpec axis{getBinEdges(h1PtScalingK0Short), "#it{p}_{T}"}; histos.add("usedObjectsCcdb/h1_pt_scaling_K0Short_ccdb", "h1_pt_scaling_K0Short_ccdb", kTH1D, {axis}, true); for (int iBin = 0; iBin <= h1PtScalingK0Short->GetNbinsX() + 1; iBin++) { histos.get(HIST("usedObjectsCcdb/h1_pt_scaling_K0Short_ccdb"))->SetBinContent(iBin, h1PtScalingK0Short->GetBinContent(iBin)); @@ -494,12 +499,122 @@ struct HadronPhotonCorrelation { } } + // histograms + + // main histogram naming (compile time 'string' required for O2 hist registry) + static constexpr std::string_view nameHistMainRecoOrMc(TruthLevel const truthLevel) + { + return truthLevel == TruthLevel::Reco ? "reco" : "mc"; + } + static constexpr std::string_view nameHistMainMode(HistFillMode const histFillMode) + { + switch (histFillMode) { + case HistFillMode::PlainPt: + return "plain/h2_ptTrigPtAssoc_"; + case HistFillMode::PlainPhiEta: + return "plain/h4_ptTrigPtAssocPhiEta_"; + case HistFillMode::PlainZPvMult: + return "plain/h4_ptTrigPtAssocZPvMult_"; + case HistFillMode::Correlation: + return "corr/h6_corr_"; + case HistFillMode::Mixing: + return "corr/h6_mix_"; + default: + throw std::runtime_error("histFillMode not found for hist name"); + } + } + static constexpr std::string_view nameHistMainTruth(TruthLevel const truthLevel) + { + switch (truthLevel) { + case TruthLevel::Reco: + return "reco"; + case TruthLevel::RecoAssocEv: + return "recoAssocEv"; + case TruthLevel::RecoPure: + return "recoPure"; + case TruthLevel::RecoPureTruePtAssoc: + return "recoPureTruePtAssoc"; + case TruthLevel::PseudoReco: + return "pseudoReco"; + case TruthLevel::PseudoRecoAssocEv: + return "pseudoRecoAssocEv"; + case TruthLevel::PseudoRecoPure: + return "pseudoRecoPure"; + case TruthLevel::PseudoRecoPureTruePtAssoc: + return "pseudoRecoPureTruePtAssoc"; + case TruthLevel::TrueGeoAcc: + return "trueGeoAcc"; + case TruthLevel::TrueMeasDecay: + return "trueMeasDecay"; + case TruthLevel::TrueRecoEvRecoPtTrig: + return "trueRecoEvRecoPtTrig"; + case TruthLevel::TrueRecoEv: + return "trueRecoEv"; + case TruthLevel::True: + return "true"; + case TruthLevel::TrueDecaySelfTrig: + return "trueDecaySelfTrig"; + default: + throw std::runtime_error("truthLevel not found for hist name"); + } + } + static constexpr std::string_view nameHistMainAssoc(AssocType const assocType, TruthLevel const truthLevel) + { + switch (assocType) { + case AssocType::Hadron: + return "hadron"; + case AssocType::Pipm: + return "pipm"; + case AssocType::PhotonPcm: + return isTrueLevel(truthLevel) ? "photon" : "photonPcm"; + case AssocType::PhotonDecay: + return "photonDecay"; + case AssocType::PhotonDirect: + return "photonDirect"; + case AssocType::Pi0Pcm: + return isTrueLevel(truthLevel) ? "pi0" : "pi0Pcm"; + case AssocType::Pi0PcmPeak: + return "pi0PcmPeak"; + case AssocType::Pi0PcmSide: + return "pi0PcmSide"; + case AssocType::PhotonPi0: + return "photonPi0"; + case AssocType::EtaPcm: + return isTrueLevel(truthLevel) ? "eta" : "etaPcm"; + case AssocType::EtaPcmPeak: + return "etaPcmPeak"; + case AssocType::EtaPcmSide: + return "etaPcmSide"; + case AssocType::PhotonEta: + return "photonEta"; + case AssocType::Omega: + return "omega"; + case AssocType::PhotonOmega: + return "photonOmega"; + case AssocType::EtaPrime: + return "etaPrime"; + case AssocType::PhotonEtaPrime: + return "photonEtaPrime"; + case AssocType::PhotonOtherMother: + return "photonOtherMother"; + default: + throw std::runtime_error("assocType not found for hist name"); + } + } + template + static constexpr auto histPath() + { + return HIST(nameHistMainRecoOrMc(TruthLevelV)) + HIST("/") + + HIST(nameHistMainMode(HistFillModeV)) + HIST(nameHistMainTruth(TruthLevelV)) + HIST("_") + HIST(nameHistMainAssoc(AssocTypeV, TruthLevelV)); + } + // create histograms void initHistograms() { // define axes const AxisSpec axisN{1, 0., 1., "#it{N}_{something}"}; const AxisSpec axisCategories{32, 0., 32., "categories"}; + const AxisSpec axisInts{2049, -1024.5, 1024.5, "ints"}; const AxisSpec axisZPv{configHist.nBinsZPvPlain, -7, 7, "#it{z}_{pv}"}; const AxisSpec axisMult{configHist.nBinsMultPlain + 1, -0.5, configHist.nBinsMultPlain + 0.5, "multiplicity"}; @@ -520,26 +635,25 @@ struct HadronPhotonCorrelation { // main info for assocType (spectra and correlation) auto const addMainAssocHists = - [&](std::string const& recoOrMc, std::string const& nameTruthLevel, std::string const& nameAssoc, bool const resolvedInfo, bool const trueColInfo) { + [&](TruthLevel const truthLevel, AssocType const assocType, bool const resolvedInfo, bool const trueColInfo) { + // runtime counterpart of histPath(), title is name without directories + auto const addMainHist = [&](HistFillMode const histFillMode, std::vector const& axes) { + std::string const name = std::format("{}/{}{}_{}", nameHistMainRecoOrMc(truthLevel), nameHistMainMode(histFillMode), + nameHistMainTruth(truthLevel), nameHistMainAssoc(assocType, truthLevel)); + histos.add(name, name.substr(name.rfind('/') + 1).data(), kTHnSparseD, axes, true); + }; if (resolvedInfo) { - histos.add(std::format("{}/plain/h4_ptTrigPtAssocPhiEta_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h4_ptTrigPtAssocPhiEta_{}_{}", nameTruthLevel, nameAssoc).data(), - kTHnSparseD, {axisPtTrig, axisPtAssoc, axisPhi, axisEta}, true); - histos.add(std::format("{}/plain/h4_ptTrigPtAssocZPvMult_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h4_ptTrigPtAssocZPvMult_{}_{}", nameTruthLevel, nameAssoc).data(), - kTHnSparseD, {axisPtTrig, axisPtAssoc, axisZPv, axisMult}, true); + addMainHist(HistFillMode::PlainPhiEta, {axisPtTrig, axisPtAssoc, axisPhi, axisEta}); + addMainHist(HistFillMode::PlainZPvMult, {axisPtTrig, axisPtAssoc, axisZPv, axisMult}); } else { - histos.add(std::format("{}/plain/h2_ptTrigPtAssoc_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h2_ptTrigPtAssoc_{}_{}", nameTruthLevel, nameAssoc).data(), - kTHnSparseD, {axisPtTrig, axisPtAssoc}, true); + addMainHist(HistFillMode::PlainPt, {axisPtTrig, axisPtAssoc}); } if (!trueColInfo) { - histos.add(std::format("{}/corr/h6_corr_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h6_corr_{}_{}", nameTruthLevel, nameAssoc).data(), - kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); - histos.add(std::format("{}/corr/h6_mix_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h6_mix_{}_{}", nameTruthLevel, nameAssoc).data(), - kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}, true); + addMainHist(HistFillMode::Correlation, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}); + addMainHist(HistFillMode::Mixing, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinning, axisMultBinning}); } else { - histos.add(std::format("{}/corr/h6_corr_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h6_corr_{}_{}", nameTruthLevel, nameAssoc).data(), - kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinningMcTrue, axisMultBinningMcTrue}, true); - histos.add(std::format("{}/corr/h6_mix_{}_{}", recoOrMc, nameTruthLevel, nameAssoc).data(), std::format("h6_mix_{}_{}", nameTruthLevel, nameAssoc).data(), - kTHnSparseD, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinningMcTrue, axisMultBinningMcTrue}, true); + addMainHist(HistFillMode::Correlation, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinningMcTrue, axisMultBinningMcTrue}); + addMainHist(HistFillMode::Mixing, {axisDPhi, axisDEta, axisPtTrig, axisPtAssoc, axisZPvBinningMcTrue, axisMultBinningMcTrue}); } }; @@ -548,12 +662,12 @@ struct HadronPhotonCorrelation { histos.add("reco/info/h3_nEv_ptTrigZPvMult_reco", "h3_nEv_ptTrigZPvMult_reco", kTHnSparseD, {axisPtTrig, axisZPv, axisMult}, true); // reco (correlation) analysis - histos.add("reco/corr/h3_ptPhiEta_trig", "h3_ptPhiEta_trig", kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); - for (std::string const& nameAssoc : std::initializer_list{"hadron", "pipm", "photonPcm"}) { - addMainAssocHists("reco", "reco", nameAssoc, true, false); + histos.add("reco/corr/h3_ptPhiEta_trig_reco", "h3_ptPhiEta_trig_reco", kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); + for (AssocType const& assocType : {AssocType::Hadron, AssocType::Pipm, AssocType::PhotonPcm}) { + addMainAssocHists(TruthLevel::Reco, assocType, true, false); } - for (std::string const& nameAssoc : std::initializer_list{"pi0PcmPeak", "pi0PcmSide", "etaPcmPeak", "etaPcmSide"}) { - addMainAssocHists("reco", "reco", nameAssoc, false, false); + for (AssocType const& assocType : {AssocType::Pi0PcmPeak, AssocType::Pi0PcmSide, AssocType::EtaPcmPeak, AssocType::EtaPcmSide}) { + addMainAssocHists(TruthLevel::Reco, assocType, false, false); } // photonPcm pairs @@ -563,7 +677,7 @@ struct HadronPhotonCorrelation { histos.add("reco/corr/h5_ptTrigPtAssocMggZPvMult_reco_photonPcmPair", "h5_ptTrigPtAssocMggZPvMult_reco_photonPcmPair", kTHnSparseD, {axisPtTrig, axisPtAssoc, axisMgg, axisZPvBinning, axisMultBinning}, true); // event mixing for photon pairs - histos.add("reco/plain/h4_ptMggZPvMult_photonPcmPair_evMix", "h4_ptMggZPvMult_photonPcmPair_evMix", kTHnSparseD, {axisPtAssoc, axisMgg, axisZPvBinning, axisMultBinning}, true); + histos.add("reco/plain/h4_ptMggZPvMult_reco_photonPcmPair_evMix", "h4_ptMggZPvMult_reco_photonPcmPair_evMix", kTHnSparseD, {axisPtAssoc, axisMgg, axisZPvBinning, axisMultBinning}, true); // pseudo mgg // pi0Pcm histos.add("mc/plain/h5_ptTrigPtAssocMggZPvMult_pseudoReco_pi0Pcm", "h5_ptTrigPtAssocMggZPvMult_pseudoReco_pi0Pcm", @@ -577,43 +691,43 @@ struct HadronPhotonCorrelation { // mc info histos.add("mc/info/h3_nEv_ptTrigZPvMult_true", "h3_nEv_ptTrigZPvMult_true", kTHnSparseD, {axisPtTrig, axisZPv, axisMult}, true); - histos.add("mc/info/h3_nEv_ptTrigZPvMult_trueAssocEv", "h3_nEv_ptTrigZPvMult_trueAssocEv", kTHnSparseD, {axisPtTrig, axisZPv, axisMult}, true); - histos.add("mc/info/h3_nEv_ptTrigZPvMult_trueAssocEvRecoPtTrig", "h3_nEv_ptTrigZPvMult_trueAssocEvRecoPtTrig", kTHnSparseD, {axisPtTrig, axisZPv, axisMult}, true); + histos.add("mc/info/h3_nEv_ptTrigZPvMult_trueRecoEv", "h3_nEv_ptTrigZPvMult_trueRecoEv", kTHnSparseD, {axisPtTrig, axisZPv, axisMult}, true); + histos.add("mc/info/h3_nEv_ptTrigZPvMult_trueRecoEvRecoPtTrig", "h3_nEv_ptTrigZPvMult_trueRecoEvRecoPtTrig", kTHnSparseD, {axisPtTrig, axisZPv, axisMult}, true); // true++ (event selection) - for (std::string const& nameTruthLevel : std::initializer_list{"true", "trueAssocEv", "trueAssocEvRecoPtTrig"}) { - histos.add(std::format("mc/corr/h3_ptPhiEta_trig_{}", nameTruthLevel).data(), std::format("h3_ptPhiEta_trig_{}", nameTruthLevel).data(), + for (TruthLevel const& truthLevel : {TruthLevel::True, TruthLevel::TrueRecoEv, TruthLevel::TrueRecoEvRecoPtTrig}) { + histos.add(std::format("mc/corr/h3_ptPhiEta_trig_{}", nameHistMainTruth(truthLevel)).data(), std::format("h3_ptPhiEta_trig_{}", nameHistMainTruth(truthLevel)).data(), kTHnSparseD, {axisPtAssoc, axisPhi, axisEta}, true); - for (std::string const& nameAssoc : std::initializer_list{"hadron", "pipm", "photon"}) { - addMainAssocHists("mc", nameTruthLevel, nameAssoc, true, true); + for (AssocType const& assocType : {AssocType::Hadron, AssocType::Pipm, AssocType::PhotonPcm}) { + addMainAssocHists(truthLevel, assocType, true, true); } - for (std::string const& nameAssoc : std::initializer_list{"pi0", "eta"}) { - addMainAssocHists("mc", nameTruthLevel, nameAssoc, false, true); + for (AssocType const& assocType : {AssocType::Pi0Pcm, AssocType::EtaPcm}) { + addMainAssocHists(truthLevel, assocType, false, true); } } // extra truthLevels for photonPcmPair - for (std::string const& nameTruthLevel : std::initializer_list{"trueDecaySelfTrig", "trueMeasDecay", "trueGeoAcc"}) { - for (std::string const& nameAssoc : std::initializer_list{"pi0", "eta"}) { - addMainAssocHists("mc", nameTruthLevel, nameAssoc, false, true); + for (TruthLevel const& truthLevel : {TruthLevel::TrueDecaySelfTrig, TruthLevel::TrueMeasDecay, TruthLevel::TrueGeoAcc}) { + for (AssocType const& assocType : {AssocType::Pi0Pcm, AssocType::EtaPcm}) { + addMainAssocHists(truthLevel, assocType, false, true); } } // assocTypes just on true level - for (std::string const& nameAssoc : std::initializer_list{"photonDecay", "photonDirect", "photonPi0", "photonEta", - "omega", "photonOmega", "etaPrime", "photonEtaPrime", "photonOtherMother"}) { - addMainAssocHists("mc", "true", nameAssoc, false, true); + for (AssocType const& assocType : {AssocType::PhotonDecay, AssocType::PhotonDirect, AssocType::PhotonPi0, AssocType::PhotonEta, + AssocType::Omega, AssocType::PhotonOmega, AssocType::EtaPrime, AssocType::PhotonEtaPrime, AssocType::PhotonOtherMother}) { + addMainAssocHists(TruthLevel::True, assocType, false, true); } // reco++ (MC info) // std assoc - for (std::string const& nameTruthLevel : std::initializer_list{"recoAssocEv", "recoPure", "recoPureTruePtAssoc"}) { - for (std::string const& nameAssoc : std::initializer_list{"hadron", "pipm", "photonPcm"}) { - addMainAssocHists("mc", nameTruthLevel, nameAssoc, true, false); + for (TruthLevel const& truthLevel : {TruthLevel::RecoAssocEv, TruthLevel::RecoPure, TruthLevel::RecoPureTruePtAssoc}) { + for (AssocType const& assocType : {AssocType::Hadron, AssocType::Pipm, AssocType::PhotonPcm}) { + addMainAssocHists(truthLevel, assocType, true, false); } } // photonPcmPair assoc - for (std::string const& nameTruthLevel : std::initializer_list{"pseudoReco", "pseudoRecoAssocEv", "pseudoRecoPure", "pseudoRecoPureTruePtAssoc"}) { - for (std::string const& nameAssoc : std::initializer_list{"pi0Pcm", "etaPcm"}) { - addMainAssocHists("mc", nameTruthLevel, nameAssoc, false, false); + for (TruthLevel const& truthLevel : {TruthLevel::PseudoReco, TruthLevel::PseudoRecoAssocEv, TruthLevel::PseudoRecoPure, TruthLevel::PseudoRecoPureTruePtAssoc}) { + for (AssocType const& assocType : {AssocType::Pi0Pcm, AssocType::EtaPcm}) { + addMainAssocHists(truthLevel, assocType, false, false); } } // impurity details @@ -622,9 +736,10 @@ struct HadronPhotonCorrelation { histos.add("mc/plain/h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0Pcm", "h3_ptTrigPtAssocCategory_pseudoRecoImpurities_pi0Pcm", kTHnSparseD, {axisPtTrig, axisPtAssoc, axisCategories}, true); - // check reco-mc matching + // check count histograms - should not be filled, unless something is off / changed histos.add("mc/info/h1_pt_noMatch_event", "h1_pt_noMatch_event", kTH1D, {axisN}, true); histos.add("mc/info/h1_pt_noMatch_trigger", "h1_pt_noMatch_trigger", kTH1D, {axisPtTrig}, true); + histos.add("mc/info/h1_unusualStatus_photonDirect", "h1_unusualStatus_photonDirect", kTH1D, {axisInts}, true); // pcm dcaZ histos.add("reco/plain/h5_ptTrigPtAssocDcaZZPvMult_photonPcm", "h5_ptTrigPtAssocDcaZZPvMult_photonPcm", @@ -639,30 +754,30 @@ struct HadronPhotonCorrelation { fV0PhotonCut = V0PhotonCut("fV0PhotonCut", "fV0PhotonCut"); // for v0 - fV0PhotonCut.SetV0PtRange(configPcmCuts.cfg_min_pt_v0, configPcmCuts.cfg_max_pt_v0); - fV0PhotonCut.SetV0EtaRange(configPcmCuts.cfg_min_eta_v0, configPcmCuts.cfg_max_eta_v0); - fV0PhotonCut.SetMinCosPA(configPcmCuts.cfg_min_cospa); - fV0PhotonCut.SetMaxPCA(configPcmCuts.cfg_max_pca); - fV0PhotonCut.SetMaxChi2KF(configPcmCuts.cfg_max_chi2kf); - fV0PhotonCut.SetRxyRange(configPcmCuts.cfg_min_v0radius, configPcmCuts.cfg_max_v0radius, configPcmCuts.cfg_midL_v0radius, configPcmCuts.cfg_midH_v0radius); - fV0PhotonCut.SetAPRange(configPcmCuts.cfg_max_alpha_ap, configPcmCuts.cfg_max_qt_ap); - fV0PhotonCut.RejectITSib(configPcmCuts.cfg_reject_v0_on_itsib); - - // for track - fV0PhotonCut.SetMinNClustersTPC(configPcmCuts.cfg_min_ncluster_tpc); - fV0PhotonCut.SetMinNCrossedRowsTPC(configPcmCuts.cfg_min_ncrossedrows); + fV0PhotonCut.SetV0PtRange(configPcmCuts.cfgMinPtV0, configPcmCuts.cfgMaxPtV0); + fV0PhotonCut.SetV0EtaRange(configPcmCuts.cfgMinEtaV0, configPcmCuts.cfgMaxEtaV0); + fV0PhotonCut.SetMinCosPA(configPcmCuts.cfgMinCospa); + fV0PhotonCut.SetMaxPCA(configPcmCuts.cfgMaxPca); + fV0PhotonCut.SetMaxChi2KF(configPcmCuts.cfgMaxChi2kf); + fV0PhotonCut.SetRxyRange(configPcmCuts.cfgMinV0radius, configPcmCuts.cfgMaxV0radius, configPcmCuts.cfgMidLV0radius, configPcmCuts.cfgMidHV0radius); + fV0PhotonCut.SetAPRange(configPcmCuts.cfgMaxAlphaAp, configPcmCuts.cfgMaxQtAp); + fV0PhotonCut.RejectITSib(configPcmCuts.cfgRejectV0OnItsib); + + // for leg + fV0PhotonCut.SetMinNClustersTPC(configPcmCuts.cfgMinNclusterTpc); + fV0PhotonCut.SetMinNCrossedRowsTPC(configPcmCuts.cfgMinNcrossedrows); fV0PhotonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); - fV0PhotonCut.SetMaxFracSharedClustersTPC(configPcmCuts.cfg_max_frac_shared_clusters_tpc); - fV0PhotonCut.SetChi2PerClusterTPC(0.0, configPcmCuts.cfg_max_chi2tpc); - fV0PhotonCut.SetTPCNsigmaElRange(configPcmCuts.cfg_min_TPCNsigmaEl, configPcmCuts.cfg_max_TPCNsigmaEl); - fV0PhotonCut.SetChi2PerClusterITS(-1e+10, configPcmCuts.cfg_max_chi2its); + fV0PhotonCut.SetMaxFracSharedClustersTPC(configPcmCuts.cfgMaxFracSharedClustersTpc); + fV0PhotonCut.SetChi2PerClusterTPC(0.0, configPcmCuts.cfgMaxChi2tpc); + fV0PhotonCut.SetTPCNsigmaElRange(configPcmCuts.cfgMinTPCNsigmaEl, configPcmCuts.cfgMaxTPCNsigmaEl); + fV0PhotonCut.SetChi2PerClusterITS(-1e+10, configPcmCuts.cfgMaxChi2its); fV0PhotonCut.SetNClustersITS(0, 7); fV0PhotonCut.SetMeanClusterSizeITSob(0.0, 16.0); - fV0PhotonCut.SetDisableITSonly(configPcmCuts.cfg_disable_itsonly_track); - fV0PhotonCut.SetDisableTPConly(configPcmCuts.cfg_disable_tpconly_track); - fV0PhotonCut.SetRequireITSTPC(configPcmCuts.cfg_require_v0_with_itstpc); - fV0PhotonCut.SetRequireITSonly(configPcmCuts.cfg_require_v0_with_itsonly); - fV0PhotonCut.SetRequireTPConly(configPcmCuts.cfg_require_v0_with_tpconly); + fV0PhotonCut.SetDisableITSonly(configPcmCuts.cfgDisableItsonlyTrack); + fV0PhotonCut.SetDisableTPConly(configPcmCuts.cfgDisableTpconlyTrack); + fV0PhotonCut.SetRequireITSTPC(configPcmCuts.cfgRequireV0WithItstpc); + fV0PhotonCut.SetRequireITSonly(configPcmCuts.cfgRequireV0WithItsonly); + fV0PhotonCut.SetRequireTPConly(configPcmCuts.cfgRequireV0WithTpconly); } // selections /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -734,7 +849,8 @@ struct HadronPhotonCorrelation { auto motherEnd = mothers.end(); while (mother != motherEnd) { // exclude pre-hadonisation - if ((*mother).producedByGenerator() && std::abs((*mother).getGenStatusCode()) < 80) { + int const statusPreHadronisationCut = 80; + if ((*mother).producedByGenerator() && std::abs((*mother).getGenStatusCode()) < statusPreHadronisationCut) { return false; } // check valid associated particle @@ -756,7 +872,7 @@ struct HadronPhotonCorrelation { { std::map decaySelfTrigPlainMap; - for (AssocType const assocType : {AssocType::Pi0Pcm, AssocType::EtaPcm}) { + for (AssocType const& assocType : {AssocType::Pi0Pcm, AssocType::EtaPcm}) { decaySelfTrigPlainMap[assocType] = [&]() { auto trigger = triggersThisEvent.begin(); auto triggerEnd = triggersThisEvent.end(); @@ -766,14 +882,14 @@ struct HadronPhotonCorrelation { } // check every trigger for self trigger and return false if unrelated (event triggers independently) while (trigger != triggerEnd) { - if constexpr (TruthLevelV == TruthLevel::TrueAssocEvRecoPtTrig) { + if constexpr (TruthLevelV == TruthLevel::TrueRecoEvRecoPtTrig) { if (!isMcMatchedTrigger(*trigger)) { return false; } if (!checkForAssocDecay((*trigger).template jetTrack_as().mcParticle(), assocType)) { return false; } - } else if constexpr (TruthLevelV == TruthLevel::TrueAssocEv || TruthLevelV == TruthLevel::True) { + } else if constexpr (TruthLevelV == TruthLevel::TrueRecoEv || TruthLevelV == TruthLevel::True) { if (!checkForAssocDecay((*trigger).jetMcParticle(), assocType)) { return false; } @@ -841,7 +957,8 @@ struct HadronPhotonCorrelation { // assocType dependent checks --------------------------------------------------------------------------------------------------------------------------------------------------------------- // check trivial self correlation for reconstruction - bool isRecoSelfTrigger(auto const& trigger, auto const& associated) { + bool isRecoSelfTrigger(auto const& trigger, auto const& associated) + { for (auto const& intersectTriggerId : associated.intersectTriggerIds()) { if (intersectTriggerId == trigger.globalIndex()) { return true; @@ -851,33 +968,34 @@ struct HadronPhotonCorrelation { }; // check reco-mc match - bool isMcMatchedCollision(auto const& collision) { + bool isMcMatchedCollision(auto const& collision) + { return collision.has_jetMcCollision(); }; - bool isMcMatchedTrigger(auto const& trigger) { + bool isMcMatchedTrigger(auto const& trigger) + { return trigger.template jetTrack_as().has_mcParticle(); }; // check reco truthLevel reached template - bool checkTruthLevelReco(auto const& associated) { + bool checkTruthLevelReco(auto const& associated) + { // std - static constexpr std::array truthLevelsRecoStdRanked{ + static constexpr std::array TruthLevelsRecoStdRanked{ TruthLevel::Reco, TruthLevel::RecoMcMatched, TruthLevel::RecoAssocEv, - TruthLevel::RecoPure - }; + TruthLevel::RecoPure}; // diPhoton - static constexpr std::array truthLevelsRecoDiPhotonRanked{ + static constexpr std::array TruthLevelsRecoDiPhotonRanked{ TruthLevel::Reco, TruthLevel::RecoMcMatched, TruthLevel::PseudoReco, TruthLevel::PseudoRecoAssocEv, - TruthLevel::PseudoRecoPure - }; + TruthLevel::PseudoRecoPure}; // position of truthLevel in chain, -1 if not in ranked truthLevels - auto constexpr getRank = [](TruthLevel const truthLevel, auto const& truthLevelsRanked) constexpr -> int { + auto constexpr GetRank = [](TruthLevel const truthLevel, auto const& truthLevelsRanked) constexpr -> int { for (size_t iRank = 0; iRank < truthLevelsRanked.size(); iRank++) { if (truthLevelsRanked[iRank] == truthLevel) { return static_cast(iRank); @@ -886,9 +1004,9 @@ struct HadronPhotonCorrelation { return -1; }; // TruthLevelV compared to the stored maximum level - auto const isReached = [&getRank](TruthLevel const truthLevelRecoMax, auto const& truthLevelsRanked) { - int const rankRecoToCheck = getRank(TruthLevelV, truthLevelsRanked); - int const rankRecoMax = getRank(truthLevelRecoMax, truthLevelsRanked); + auto const isReached = [&GetRank](TruthLevel const truthLevelRecoMax, auto const& truthLevelsRanked) { + int const rankRecoToCheck = GetRank(TruthLevelV, truthLevelsRanked); + int const rankRecoMax = GetRank(truthLevelRecoMax, truthLevelsRanked); if (rankRecoMax < 0) { throw std::runtime_error("rankRecoMax not found"); } @@ -896,25 +1014,25 @@ struct HadronPhotonCorrelation { }; // assocType cases if constexpr (AssocTypeV == AssocType::Hadron) { - static_assert(getRank(TruthLevelV, truthLevelsRecoStdRanked) >= 0, "truthLevel not in std reco chain"); + static_assert(GetRank(TruthLevelV, TruthLevelsRecoStdRanked) >= 0, "truthLevel not in std reco chain"); TruthLevel const truthLevelRecoMax = static_cast(associated.truthLevelRecoHadron()); - return isReached(truthLevelRecoMax, truthLevelsRecoStdRanked); + return isReached(truthLevelRecoMax, TruthLevelsRecoStdRanked); } else if constexpr (AssocTypeV == AssocType::Pipm) { - static_assert(getRank(TruthLevelV, truthLevelsRecoStdRanked) >= 0, "truthLevel not in std reco chain"); + static_assert(GetRank(TruthLevelV, TruthLevelsRecoStdRanked) >= 0, "truthLevel not in std reco chain"); TruthLevel const truthLevelRecoMax = static_cast(associated.truthLevelRecoPipm()); - return isReached(truthLevelRecoMax, truthLevelsRecoStdRanked); + return isReached(truthLevelRecoMax, TruthLevelsRecoStdRanked); } else if constexpr (AssocTypeV == AssocType::PhotonPcm) { - static_assert(getRank(TruthLevelV, truthLevelsRecoStdRanked) >= 0, "truthLevel not in std reco chain"); + static_assert(GetRank(TruthLevelV, TruthLevelsRecoStdRanked) >= 0, "truthLevel not in std reco chain"); TruthLevel const truthLevelRecoMax = static_cast(associated.truthLevelRecoPhotonPcm()); - return isReached(truthLevelRecoMax, truthLevelsRecoStdRanked); + return isReached(truthLevelRecoMax, TruthLevelsRecoStdRanked); } else if constexpr (AssocTypeV == AssocType::Pi0Pcm) { - static_assert(getRank(TruthLevelV, truthLevelsRecoDiPhotonRanked) >= 0, "truthLevel not in diPhoton reco chain"); + static_assert(GetRank(TruthLevelV, TruthLevelsRecoDiPhotonRanked) >= 0, "truthLevel not in diPhoton reco chain"); TruthLevel const truthLevelRecoMax = static_cast(associated.truthLevelRecoPi0Pcm()); - return isReached(truthLevelRecoMax, truthLevelsRecoDiPhotonRanked); + return isReached(truthLevelRecoMax, TruthLevelsRecoDiPhotonRanked); } else if constexpr (AssocTypeV == AssocType::EtaPcm) { - static_assert(getRank(TruthLevelV, truthLevelsRecoDiPhotonRanked) >= 0, "truthLevel not in diPhoton reco chain"); + static_assert(GetRank(TruthLevelV, TruthLevelsRecoDiPhotonRanked) >= 0, "truthLevel not in diPhoton reco chain"); TruthLevel const truthLevelRecoMax = static_cast(associated.truthLevelRecoEtaPcm()); - return isReached(truthLevelRecoMax, truthLevelsRecoDiPhotonRanked); + return isReached(truthLevelRecoMax, TruthLevelsRecoDiPhotonRanked); } else { static_assert(AlwaysFalseValue, "assocType not found"); } @@ -959,7 +1077,8 @@ struct HadronPhotonCorrelation { } template - bool isSelectedAssoc(auto const& associated) { + bool isSelectedAssoc(auto const& associated) + { if constexpr (AssocTypeV == AssocType::Hadron) { return true; } else if constexpr (AssocTypeV == AssocType::Pipm) { @@ -976,38 +1095,25 @@ struct HadronPhotonCorrelation { // analysis helpers ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - // select standard/main histogram compile-time path from array - static consteval char const* getHistPathMain(auto const& histPaths, HistFillMode const fillMode, TruthLevel const truthLevel, AssocType const assocType) { - for (auto const& entry : histPaths) { - if (entry.fillMode == fillMode && entry.truthLevel == truthLevel && entry.assocType == assocType) { - return entry.path; - } - } - throw "path not found"; - } - // fill main histogram - template - void fillHistMain(auto const& histFillInfo) { + template + void fillHistMain(auto const& histFillInfo) + { if constexpr (HistFillModeV == HistFillMode::Plain) { if constexpr (AssocTypeV == AssocType::Hadron || AssocTypeV == AssocType::Pipm || AssocTypeV == AssocType::PhotonPcm) { - histos.fill(HIST(getHistPathMain(HistPaths, HistFillMode::PlainPhiEta, TruthLevelV, AssocTypeV)), + histos.fill(histPath(), histFillInfo.ptMax, histFillInfo.ptAssoc, histFillInfo.phi, histFillInfo.eta, histFillInfo.weight); - histos.fill(HIST(getHistPathMain(HistPaths, HistFillMode::PlainZPvMult, TruthLevelV, AssocTypeV)), + histos.fill(histPath(), histFillInfo.ptMax, histFillInfo.ptAssoc, histFillInfo.zPv, histFillInfo.mult, histFillInfo.weight); } else { - histos.fill(HIST(getHistPathMain(HistPaths, HistFillMode::PlainPt, TruthLevelV, AssocTypeV)), + histos.fill(histPath(), histFillInfo.ptMax, histFillInfo.ptAssoc, histFillInfo.weight); } - } else if constexpr (HistFillModeV == HistFillMode::Correlation) { - histos.fill(HIST(getHistPathMain(HistPaths, HistFillMode::Correlation, TruthLevelV, AssocTypeV)), - histFillInfo.dPhi, histFillInfo.dEta, histFillInfo.ptTrig, histFillInfo.ptAssoc, histFillInfo.zPv, histFillInfo.mult, - histFillInfo.weight); - } else if constexpr (HistFillModeV == HistFillMode::Mixing) { - histos.fill(HIST(getHistPathMain(HistPaths, HistFillMode::Mixing, TruthLevelV, AssocTypeV)), + } else if constexpr (HistFillModeV == HistFillMode::Correlation || HistFillModeV == HistFillMode::Mixing) { + histos.fill(histPath(), histFillInfo.dPhi, histFillInfo.dEta, histFillInfo.ptTrig, histFillInfo.ptAssoc, histFillInfo.zPv, histFillInfo.mult, histFillInfo.weight); } else { @@ -1017,35 +1123,41 @@ struct HadronPhotonCorrelation { // tcm component: exponential for low pt // parameter shape: [m0_h, A_e, T_e] - double tcmInvariantSoftExp(double const* pt, double const* par) { - double const ET_kin = std::sqrt(std::pow(pt[0], 2) + std::pow(par[0], 2)) - par[0]; - return std::abs(par[1]) * std::exp(-1 * ET_kin / par[2]); + double tcmInvariantSoftExp(double const* pt, double const* par) + { + double const etKin = std::sqrt(std::pow(pt[0], 2) + std::pow(par[0], 2)) - par[0]; + return std::abs(par[1]) * std::exp(-etKin / par[2]); } // tcm component: power law for high pt // parameter shape: [A_p, T_p, N_p] - double tcmInvariantHardPower(double const* pt, double const* par) { + double tcmInvariantHardPower(double const* pt, double const* par) + { return std::abs(par[0]) / std::pow(1 + std::pow(pt[0], 2) / (std::pow(par[1], 2) * par[2]), par[2]); } - // fit function for invariant pT spectrum + // fit function for invariant pt spectrum // parameter shape: [m0_h, A_e, T_e, A_p, T_p, N_p] - double tcmInvariantFit(double const* pt, double const* par) { + double tcmInvariantFit(double const* pt, double const* par) + { int const nParSoftExp = 3; return tcmInvariantSoftExp(pt, par) + tcmInvariantHardPower(pt, par + nParSoftExp); } // tcm function (non-invariant) - double tcmParam(double const pt, std::vector const& par) { + double tcmParam(double const pt, std::vector const& par) + { return pt * tcmInvariantFit(&pt, par.data()); } // pt weight - double ptWeightTcms(double const pt, std::vector const& parNum, std::vector const& parDenom) { + double ptWeightTcms(double const pt, std::vector const& parNum, std::vector const& parDenom) + { return tcmParam(pt, parNum) / tcmParam(pt, parDenom); } // rescale of pt spectra for mc template - double getMcAssocPtScalingFromPt(double const ptTrue) { + double getMcAssocPtScalingFromPt(double const ptTrue) + { auto const getWeight = [this](double const pt, std::vector const& ptRange, std::vector const& parNum, std::vector const& parDenom) { if (pt < ptRange.at(0)) { return ptWeightTcms(ptRange.at(0), parNum, parDenom); @@ -1066,18 +1178,21 @@ struct HadronPhotonCorrelation { } } template - double getMcAssocPtScaling(auto const& associated) { + double getMcAssocPtScaling(auto const& associated) + { if constexpr (AssocTypeV == AssocType::Hadron || AssocTypeV == AssocType::Pipm) { return 1; } else if constexpr (AssocTypeV == AssocType::PhotonPcm) { - if (!config.applyScalingPhotonPt.value) return 1; + if (!config.applyScalingPhotonPt.value) + return 1; if (checkTruthLevelReco(associated)) { return getMcAssocPtScalingFromPt(associated.ptTruePure()); } else { return 1; } } else if constexpr (AssocTypeV == AssocType::PhotonPcmPair) { - if (!config.applyScalingPi0Pt.value && !config.applyScalingEtaPt.value) return 1; + if (!config.applyScalingPi0Pt.value && !config.applyScalingEtaPt.value) + return 1; if (checkTruthLevelReco(associated)) { return getMcAssocPtScalingFromPt(associated.ptTruePure()); } else if (checkTruthLevelReco(associated)) { @@ -1091,17 +1206,19 @@ struct HadronPhotonCorrelation { } // get histogram y-quantity at x-value - double getH1ValueAt(auto const*const h1, double const value) + double getH1ValueAt(auto const* const h1, double const value) { return h1->GetBinContent(h1->FindFixBin(value)); } // K0Short mc scaling - double getMcK0ShortPtScalingFromPt(double const ptTrue) { + double getMcK0ShortPtScalingFromPt(double const ptTrue) + { return config.applyScalingK0ShortPt.value ? getH1ValueAt(h1PtScalingK0Short, ptTrue) : 1; } template - double getMcK0ShortPtScaling (auto const& associated) { + double getMcK0ShortPtScaling(auto const& associated) + { if constexpr (AssocTypeV == AssocType::Hadron || AssocTypeV == AssocType::Pipm) { return 1; } else if constexpr (AssocTypeV == AssocType::PhotonPcm) { @@ -1130,7 +1247,7 @@ struct HadronPhotonCorrelation { // performs 'phi1 - phi2' and pushes it into the interval [-pi/2, 3pi/2] double getDeltaPhi(double const phi1, double const phi2) { - return RecoDecay::constrainAngle(phi1 - phi2, -1 * constants::math::PIHalf); + return RecoDecay::constrainAngle(phi1 - phi2, -constants::math::PIHalf); } // check if invariant mass range @@ -1155,7 +1272,13 @@ struct HadronPhotonCorrelation { // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ // generalised correlation functions - // per collision + + struct CorrConditionTrue { + constexpr bool operator()(auto const&) const + { + return true; + } + }; // plain info void corrProcessPlain(auto const& collision, auto const& associatedThisEvent, @@ -1185,13 +1308,7 @@ struct HadronPhotonCorrelation { } // mixing - struct ConditionMixAcceptAll { - constexpr bool operator()(auto const&) const - { - return true; - } - }; - template + template void corrProcessMixing(auto const& collision, auto const& associatedThisEvent, auto const& funcMixing, size_t const nTriggerMixingAt0, T_AssocCondition const& funcConditionAssocOnly = {}) { @@ -1206,12 +1323,12 @@ struct HadronPhotonCorrelation { } else if constexpr (TriggerMemoryModeV == TriggerMemoryMode::True) { triggerMemoryBinSizeMin = triggerMemoryTrue->getBinSizeMin(); return triggerMemoryTrue->getTriggers(collision.posZ(), collision.nChargedInEtaRange()); - } else if constexpr (TriggerMemoryModeV == TriggerMemoryMode::TrueAssocEv) { - triggerMemoryBinSizeMin = triggerMemoryTrueAssocEv->getBinSizeMin(); - return triggerMemoryTrueAssocEv->getTriggers(collision.posZ(), collision.nChargedInEtaRange()); - } else if constexpr (TriggerMemoryModeV == TriggerMemoryMode::TrueAssocEvRecoPtTrig) { - triggerMemoryBinSizeMin = triggerMemoryTrueAssocEvRecoPtTrig->getBinSizeMin(); - return triggerMemoryTrueAssocEvRecoPtTrig->getTriggers(collision.posZ(), collision.nChargedInEtaRange()); + } else if constexpr (TriggerMemoryModeV == TriggerMemoryMode::TrueRecoEv) { + triggerMemoryBinSizeMin = triggerMemoryTrueRecoEv->getBinSizeMin(); + return triggerMemoryTrueRecoEv->getTriggers(collision.posZ(), collision.nChargedInEtaRange()); + } else if constexpr (TriggerMemoryModeV == TriggerMemoryMode::TrueRecoEvRecoPtTrig) { + triggerMemoryBinSizeMin = triggerMemoryTrueRecoEvRecoPtTrig->getBinSizeMin(); + return triggerMemoryTrueRecoEvRecoPtTrig->getTriggers(collision.posZ(), collision.nChargedInEtaRange()); } else { static_assert(AlwaysFalseValue, "triggerMemoryMode not found"); } @@ -1242,8 +1359,12 @@ struct HadronPhotonCorrelation { // analysis tasks /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // =/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/ - void init(InitContext const&) + void init(InitContext& initContext) { + double const doublePrecisionDeltaCheck = 1e-5; + double absEtaMaxProducer; + double ptTrigMinProducer; + // analysis info int64_t const noLaterThanCcdb = config.noLaterThanCcdbConfig.value == -1 ? std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count() : config.noLaterThanCcdbConfig.value; @@ -1254,20 +1375,39 @@ struct HadronPhotonCorrelation { // not later than (avoids replacing objects while a train is running) ccdb->setCreatedNotAfter(noLaterThanCcdb); - // init analysis variables + // variables from other tasks + if (common::core::getTaskOptionValue(initContext, "hadron-photon-producer", "absEtaMax", absEtaMaxProducer, false)) { + if (std::abs(config.absEtaMax.value - absEtaMaxProducer) > doublePrecisionDeltaCheck) { + throw std::runtime_error("absEtaMax does not match producer"); + } + }; + if (common::core::getTaskOptionValue(initContext, "hadron-photon-producer", "ptTrigMin", ptTrigMinProducer, false)) { + if (std::abs(config.ptTrigMin.value - ptTrigMinProducer) > doublePrecisionDeltaCheck) { + throw std::runtime_error("ptTrigMin does not match producer"); + } + } // check coherent config - double const doublePrecisionDeltaCheck = 1e-5; if (std::abs(config.ptTrigMin.value - configHist.binsPtTrig.value.at(0)) > doublePrecisionDeltaCheck) { throw std::runtime_error("ptTrigMin does not match trigger axis"); } - if (config.applyScalingPhotonPt.value && (config.parScalingPhotonPtData.value.size() != 6 || config.parScalingPhotonPtMc.value.size() != 6)) { + if (std::abs(2 * config.absEtaMax.value + configHist.binsDEta.value.front()) > doublePrecisionDeltaCheck || + std::abs(2 * config.absEtaMax.value - configHist.binsDEta.value.back()) > doublePrecisionDeltaCheck) { + throw std::runtime_error("absEtaMax does not match binsDEta axis"); + } + + if (config.absEtaMax.value > std::abs(configPcmCuts.cfgMinEtaV0) || config.absEtaMax.value > std::abs(configPcmCuts.cfgMaxEtaV0)) { + throw std::runtime_error("absEtaMax does not constrain v0 cut"); + } + + int const nParTcm = 6; + if (config.applyScalingPhotonPt.value && (config.parScalingPhotonPtData.value.size() != nParTcm || config.parScalingPhotonPtMc.value.size() != nParTcm)) { throw std::runtime_error("wrong number of mc scaling params for photon"); } - if (config.applyScalingPi0Pt.value && (config.parScalingPi0PtData.value.size() != 6 || config.parScalingPi0PtMc.value.size() != 6)) { + if (config.applyScalingPi0Pt.value && (config.parScalingPi0PtData.value.size() != nParTcm || config.parScalingPi0PtMc.value.size() != nParTcm)) { throw std::runtime_error("wrong number of mc scaling params for pi0"); } - if (config.applyScalingEtaPt.value && (config.parScalingEtaPtData.value.size() != 6 || config.parScalingEtaPtMc.value.size() != 6)) { + if (config.applyScalingEtaPt.value && (config.parScalingEtaPtData.value.size() != nParTcm || config.parScalingEtaPtMc.value.size() != nParTcm)) { throw std::runtime_error("wrong number of mc scaling params for eta"); } @@ -1278,10 +1418,14 @@ struct HadronPhotonCorrelation { initHistograms(); // mixing trigger memory - triggerMemoryReco = std::make_unique(configHist.binsZPvBinning.value, configHist.binsMultBinning.value, config.nTriggerSavedForMixing.value); - triggerMemoryTrue = std::make_unique(configHist.binsZPvBinningMcTrue.value, configHist.binsMultBinningMcTrue.value, config.nTriggerSavedForMixing.value); - triggerMemoryTrueAssocEv = std::make_unique(configHist.binsZPvBinningMcTrue.value, configHist.binsMultBinningMcTrue.value, config.nTriggerSavedForMixing.value); - triggerMemoryTrueAssocEvRecoPtTrig = std::make_unique(configHist.binsZPvBinningMcTrue.value, configHist.binsMultBinningMcTrue.value, config.nTriggerSavedForMixing.value); + triggerMemoryReco = std::make_unique(configHist.binsZPvBinning.value, configHist.binsMultBinning.value, + config.nTriggerSavedForMixing.value); + triggerMemoryTrue = std::make_unique(configHist.binsZPvBinningMcTrue.value, configHist.binsMultBinningMcTrue.value, + config.nTriggerSavedForMixing.value); + triggerMemoryTrueRecoEv = std::make_unique(configHist.binsZPvBinningMcTrue.value, configHist.binsMultBinningMcTrue.value, + config.nTriggerSavedForMixing.value); + triggerMemoryTrueRecoEvRecoPtTrig = std::make_unique(configHist.binsZPvBinningMcTrue.value, configHist.binsMultBinningMcTrue.value, + config.nTriggerSavedForMixing.value); // init EM pcm cut class initV0PhotonCut(); @@ -1293,27 +1437,7 @@ struct HadronPhotonCorrelation { // correlations ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - // standard reco histogram compile-time paths - static constexpr auto HistPathsRecoStd = []() { - using enum HistFillMode; - using enum TruthLevel; - using enum AssocType; - - return std::to_array({ - {PlainPhiEta, Reco, Hadron, "reco/plain/h4_ptTrigPtAssocPhiEta_reco_hadron"}, - {PlainZPvMult, Reco, Hadron, "reco/plain/h4_ptTrigPtAssocZPvMult_reco_hadron"}, - {Correlation, Reco, Hadron, "reco/corr/h6_corr_reco_hadron"}, - {Mixing, Reco, Hadron, "reco/corr/h6_mix_reco_hadron"}, - {PlainPhiEta, Reco, Pipm, "reco/plain/h4_ptTrigPtAssocPhiEta_reco_pipm"}, - {PlainZPvMult, Reco, Pipm, "reco/plain/h4_ptTrigPtAssocZPvMult_reco_pipm"}, - {Correlation, Reco, Pipm, "reco/corr/h6_corr_reco_pipm"}, - {Mixing, Reco, Pipm, "reco/corr/h6_mix_reco_pipm"}, - {PlainPhiEta, Reco, PhotonPcm, "reco/plain/h4_ptTrigPtAssocPhiEta_reco_photonPcm"}, - {PlainZPvMult, Reco, PhotonPcm, "reco/plain/h4_ptTrigPtAssocZPvMult_reco_photonPcm"}, - {Correlation, Reco, PhotonPcm, "reco/corr/h6_corr_reco_photonPcm"}, - {Mixing, Reco, PhotonPcm, "reco/corr/h6_mix_reco_photonPcm"} - }); - }(); + // standard reco :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: template void fillProcessRecoStd(auto const& collisions, auto const& triggers, auto const& assocs) @@ -1344,9 +1468,10 @@ struct HadronPhotonCorrelation { return; } - HistFillInfoPlainPhiEtaZPvMult histFillInfo = {collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), collision.posZ(), static_cast(collision.nGlobalTracks())}; + HistFillInfoPlainPhiEtaZPvMult histFillInfo = {collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), + collision.posZ(), static_cast(collision.nGlobalTracks())}; histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated); - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); }; corrProcessPlain(collision, assocsThisEvent, funcPlain); @@ -1362,8 +1487,9 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(trigger.phi(), associated.phi()), trigger.eta() - associated.eta(), trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(trigger.pt()); - fillHistMain(histFillInfo); + histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * + getTriggerPtCorrection(trigger.pt()); + fillHistMain(histFillInfo); }; corrProcessCorrelation(collision, triggersThisEvent, assocsThisEvent, funcCorrelation); @@ -1379,77 +1505,60 @@ struct HadronPhotonCorrelation { auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = perTriggerWeight * getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(mixingTrigger.pt()); - fillHistMain(histFillInfo); + histFillInfo.weight = perTriggerWeight * + getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * + getTriggerPtCorrection(mixingTrigger.pt()); + fillHistMain(histFillInfo); }; corrProcessMixing(collision, assocsThisEvent, funcMixing, nMixingAt0, conditionMixAssocOnly); } } - void processRecoHadron(CorrCollisions const& collisions, aod::Triggers const& triggers, aod::Hadrons const& hadrons) + void processRecoHadron(HpcCollisions const& collisions, aod::HpcTriggers const& triggers, aod::HpcHadrons const& hadrons) { fillProcessRecoStd(collisions, triggers, hadrons); } PROCESS_SWITCH(HadronPhotonCorrelation, processRecoHadron, "process standard for associated hardon", false); - void processRecoPipm(CorrCollisions const& collisions, aod::Triggers const& triggers, aod::Pipms const& pipms) + void processRecoPipm(HpcCollisions const& collisions, aod::HpcTriggers const& triggers, aod::HpcPipms const& pipms) { fillProcessRecoStd(collisions, triggers, pipms); } PROCESS_SWITCH(HadronPhotonCorrelation, processRecoPipm, "process standard for associated pipm", false); - void processRecoPhotonPcm(CorrCollisions const& collisions, aod::Triggers const& triggers, PhotonPcmsWithV0 const& photonPcms, + void processRecoPhotonPcm(HpcCollisions const& collisions, aod::HpcTriggers const& triggers, PhotonPcmsWithV0 const& photonPcms, aod::V0PhotonsKF const&, aod::V0Legs const&) { fillProcessRecoStd(collisions, triggers, photonPcms); } PROCESS_SWITCH(HadronPhotonCorrelation, processRecoPhotonPcm, "process standard for associated photonPcm", false); - // photonPcmPair reco histogram compile-time paths - static constexpr auto HistPathsRecoPhotonPcmPair = []() { - using enum HistFillMode; - using enum TruthLevel; - using enum AssocType; - - return std::to_array({ - {PlainPt, Reco, Pi0PcmPeak, "reco/plain/h2_ptTrigPtAssoc_reco_pi0PcmPeak"}, - {Correlation, Reco, Pi0PcmPeak, "reco/corr/h6_corr_reco_pi0PcmPeak"}, - {Mixing, Reco, Pi0PcmPeak, "reco/corr/h6_mix_reco_pi0PcmPeak"}, - {PlainPt, Reco, Pi0PcmSide, "reco/plain/h2_ptTrigPtAssoc_reco_pi0PcmSide"}, - {Correlation, Reco, Pi0PcmSide, "reco/corr/h6_corr_reco_pi0PcmSide"}, - {Mixing, Reco, Pi0PcmSide, "reco/corr/h6_mix_reco_pi0PcmSide"}, - {PlainPt, Reco, EtaPcmPeak, "reco/plain/h2_ptTrigPtAssoc_reco_etaPcmPeak"}, - {Correlation, Reco, EtaPcmPeak, "reco/corr/h6_corr_reco_etaPcmPeak"}, - {Mixing, Reco, EtaPcmPeak, "reco/corr/h6_mix_reco_etaPcmPeak"}, - {PlainPt, Reco, EtaPcmSide, "reco/plain/h2_ptTrigPtAssoc_reco_etaPcmSide"}, - {Correlation, Reco, EtaPcmSide, "reco/corr/h6_corr_reco_etaPcmSide"}, - {Mixing, Reco, EtaPcmSide, "reco/corr/h6_mix_reco_etaPcmSide"} - }); - }(); + // photonPcmPair reco ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: template - void fillAssocsRecoPhotonPcmPair(auto const& histFillInfo, double const mgg) { + void fillAssocsRecoPhotonPcmPair(auto const& histFillInfo, double const mgg) + { // pi0 if (isInMassRange(mgg)) { - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); return; } if (isInMassRange(mgg)) { - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); return; } // eta if (isInMassRange(mgg)) { - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); return; } if (isInMassRange(mgg)) { - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); return; } } - void processRecoPhotonPcmPair(CorrCollisions const& collisions, aod::Triggers const& triggers, PhotonPcmPairsWithV0 const& photonPcmPairs, + void processRecoPhotonPcmPair(HpcCollisions const& collisions, aod::HpcTriggers const& triggers, PhotonPcmPairsWithV0 const& photonPcmPairs, aod::V0PhotonsKF const&, aod::V0Legs const&) { for (auto const& collision : collisions) { @@ -1491,7 +1600,8 @@ struct HadronPhotonCorrelation { return; } - double const weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(trigger.pt()); + double const weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * + getTriggerPtCorrection(trigger.pt()); // mgg distribution histos.fill(HIST("reco/corr/h5_ptTrigPtAssocMggZPvMult_reco_photonPcmPair"), @@ -1517,7 +1627,9 @@ struct HadronPhotonCorrelation { auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = perTriggerWeight * getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(mixingTrigger.pt()); + histFillInfo.weight = perTriggerWeight * + getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * + getTriggerPtCorrection(mixingTrigger.pt()); fillAssocsRecoPhotonPcmPair(histFillInfo, associated.mgg()); }; corrProcessMixing(collision, photonPcmPairsThisEvent, funcMixing, config.nMixingAt0PhotonPcmPair.value, conditionMixAssocOnly); @@ -1525,12 +1637,12 @@ struct HadronPhotonCorrelation { } PROCESS_SWITCH(HadronPhotonCorrelation, processRecoPhotonPcmPair, "process standard for associated photonPcmPair", false); - void processPhotonPcmPairMix(CorrCollisions const& collisions, PhotonPcmsWithV0 const& photonPcms, + void processPhotonPcmPairMix(HpcCollisions const& collisions, PhotonPcmsWithV0 const& photonPcms, aod::V0PhotonsKF const&, aod::V0Legs const&) { BinningZPvMult const binningZPvMult{{prependVariableWidth(configHist.binsZPvBinning.value), prependVariableWidth(configHist.binsMultBinning.value)}, true}; auto photonPcmsTuple = std::make_tuple(photonPcms); - SameKindPair pairs{binningZPvMult, config.nNeighboursMixingPhotonPcmPair.value, -1, collisions, photonPcmsTuple, &cache}; + SameKindPair pairs{binningZPvMult, config.nNeighboursMixingPhotonPcmPair.value, -1, collisions, photonPcmsTuple, &cache}; // mixed events for (auto pair = pairs.begin(); pair != pairs.end(); pair++) { @@ -1556,7 +1668,7 @@ struct HadronPhotonCorrelation { continue; } - histos.fill(HIST("reco/plain/h4_ptMggZPvMult_photonPcmPair_evMix"), + histos.fill(HIST("reco/plain/h4_ptMggZPvMult_reco_photonPcmPair_evMix"), p4photonPcmPair.pt(), p4photonPcmPair.M(), collision1.posZ(), collision1.nGlobalTracks()); } } @@ -1566,7 +1678,7 @@ struct HadronPhotonCorrelation { // other //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - void processPcmDcaZ(CorrCollisions::iterator const& collision, PhotonPcmsWithV0 const& photonPcms, + void processPcmDcaZ(HpcCollisions::iterator const& collision, PhotonPcmsWithV0 const& photonPcms, aod::V0PhotonsKF const&, aod::V0Legs const&) { // event selection @@ -1595,122 +1707,11 @@ struct HadronPhotonCorrelation { // correlations ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - // mc true++ histogram compile-time paths - static constexpr auto HistPathsMcTrue = []() { - using enum HistFillMode; - using enum TruthLevel; - using enum AssocType; - - return std::to_array({ - {PlainPhiEta, True, Hadron, "mc/plain/h4_ptTrigPtAssocPhiEta_true_hadron"}, - {PlainZPvMult, True, Hadron, "mc/plain/h4_ptTrigPtAssocZPvMult_true_hadron"}, - {Correlation, True, Hadron, "mc/corr/h6_corr_true_hadron"}, - {Mixing, True, Hadron, "mc/corr/h6_mix_true_hadron"}, - {PlainPhiEta, True, Pipm, "mc/plain/h4_ptTrigPtAssocPhiEta_true_pipm"}, - {PlainZPvMult, True, Pipm, "mc/plain/h4_ptTrigPtAssocZPvMult_true_pipm"}, - {Correlation, True, Pipm, "mc/corr/h6_corr_true_pipm"}, - {Mixing, True, Pipm, "mc/corr/h6_mix_true_pipm"}, - {PlainPhiEta, True, PhotonPcm, "mc/plain/h4_ptTrigPtAssocPhiEta_true_photon"}, - {PlainZPvMult, True, PhotonPcm, "mc/plain/h4_ptTrigPtAssocZPvMult_true_photon"}, - {Correlation, True, PhotonPcm, "mc/corr/h6_corr_true_photon"}, - {Mixing, True, PhotonPcm, "mc/corr/h6_mix_true_photon"}, - {PlainPt, True, PhotonDecay, "mc/plain/h2_ptTrigPtAssoc_true_photonDecay"}, - {Correlation, True, PhotonDecay, "mc/corr/h6_corr_true_photonDecay"}, - {Mixing, True, PhotonDecay, "mc/corr/h6_mix_true_photonDecay"}, - {PlainPt, True, PhotonDirect, "mc/plain/h2_ptTrigPtAssoc_true_photonDirect"}, - {Correlation, True, PhotonDirect, "mc/corr/h6_corr_true_photonDirect"}, - {Mixing, True, PhotonDirect, "mc/corr/h6_mix_true_photonDirect"}, - {PlainPt, True, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_true_pi0"}, - {Correlation, True, Pi0Pcm, "mc/corr/h6_corr_true_pi0"}, - {Mixing, True, Pi0Pcm, "mc/corr/h6_mix_true_pi0"}, - {PlainPt, True, PhotonPi0, "mc/plain/h2_ptTrigPtAssoc_true_photonPi0"}, - {Correlation, True, PhotonPi0, "mc/corr/h6_corr_true_photonPi0"}, - {Mixing, True, PhotonPi0, "mc/corr/h6_mix_true_photonPi0"}, - {PlainPt, True, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_true_eta"}, - {Correlation, True, EtaPcm, "mc/corr/h6_corr_true_eta"}, - {Mixing, True, EtaPcm, "mc/corr/h6_mix_true_eta"}, - {PlainPt, True, PhotonEta, "mc/plain/h2_ptTrigPtAssoc_true_photonEta"}, - {Correlation, True, PhotonEta, "mc/corr/h6_corr_true_photonEta"}, - {Mixing, True, PhotonEta, "mc/corr/h6_mix_true_photonEta"}, - {PlainPt, True, Omega, "mc/plain/h2_ptTrigPtAssoc_true_omega"}, - {Correlation, True, Omega, "mc/corr/h6_corr_true_omega"}, - {Mixing, True, Omega, "mc/corr/h6_mix_true_omega"}, - {PlainPt, True, PhotonOmega, "mc/plain/h2_ptTrigPtAssoc_true_photonOmega"}, - {Correlation, True, PhotonOmega, "mc/corr/h6_corr_true_photonOmega"}, - {Mixing, True, PhotonOmega, "mc/corr/h6_mix_true_photonOmega"}, - {PlainPt, True, EtaPrime, "mc/plain/h2_ptTrigPtAssoc_true_etaPrime"}, - {Correlation, True, EtaPrime, "mc/corr/h6_corr_true_etaPrime"}, - {Mixing, True, EtaPrime, "mc/corr/h6_mix_true_etaPrime"}, - {PlainPt, True, PhotonEtaPrime, "mc/plain/h2_ptTrigPtAssoc_true_photonEtaPrime"}, - {Correlation, True, PhotonEtaPrime, "mc/corr/h6_corr_true_photonEtaPrime"}, - {Mixing, True, PhotonEtaPrime, "mc/corr/h6_mix_true_photonEtaPrime"}, - {PlainPt, True, PhotonOtherMother, "mc/plain/h2_ptTrigPtAssoc_true_photonOtherMother"}, - {Correlation, True, PhotonOtherMother, "mc/corr/h6_corr_true_photonOtherMother"}, - {Mixing, True, PhotonOtherMother, "mc/corr/h6_mix_true_photonOtherMother"}, - - {PlainPhiEta, TrueAssocEv, Hadron, "mc/plain/h4_ptTrigPtAssocPhiEta_trueAssocEv_hadron"}, - {PlainZPvMult, TrueAssocEv, Hadron, "mc/plain/h4_ptTrigPtAssocZPvMult_trueAssocEv_hadron"}, - {Correlation, TrueAssocEv, Hadron, "mc/corr/h6_corr_trueAssocEv_hadron"}, - {Mixing, TrueAssocEv, Hadron, "mc/corr/h6_mix_trueAssocEv_hadron"}, - {PlainPhiEta, TrueAssocEv, Pipm, "mc/plain/h4_ptTrigPtAssocPhiEta_trueAssocEv_pipm"}, - {PlainZPvMult, TrueAssocEv, Pipm, "mc/plain/h4_ptTrigPtAssocZPvMult_trueAssocEv_pipm"}, - {Correlation, TrueAssocEv, Pipm, "mc/corr/h6_corr_trueAssocEv_pipm"}, - {Mixing, TrueAssocEv, Pipm, "mc/corr/h6_mix_trueAssocEv_pipm"}, - {PlainPhiEta, TrueAssocEv, PhotonPcm, "mc/plain/h4_ptTrigPtAssocPhiEta_trueAssocEv_photon"}, - {PlainZPvMult, TrueAssocEv, PhotonPcm, "mc/plain/h4_ptTrigPtAssocZPvMult_trueAssocEv_photon"}, - {Correlation, TrueAssocEv, PhotonPcm, "mc/corr/h6_corr_trueAssocEv_photon"}, - {Mixing, TrueAssocEv, PhotonPcm, "mc/corr/h6_mix_trueAssocEv_photon"}, - {PlainPt, TrueAssocEv, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_trueAssocEv_pi0"}, - {Correlation, TrueAssocEv, Pi0Pcm, "mc/corr/h6_corr_trueAssocEv_pi0"}, - {Mixing, TrueAssocEv, Pi0Pcm, "mc/corr/h6_mix_trueAssocEv_pi0"}, - {PlainPt, TrueAssocEv, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_trueAssocEv_eta"}, - {Correlation, TrueAssocEv, EtaPcm, "mc/corr/h6_corr_trueAssocEv_eta"}, - {Mixing, TrueAssocEv, EtaPcm, "mc/corr/h6_mix_trueAssocEv_eta"}, - - {PlainPhiEta, TrueAssocEvRecoPtTrig, Hadron, "mc/plain/h4_ptTrigPtAssocPhiEta_trueAssocEvRecoPtTrig_hadron"}, - {PlainZPvMult, TrueAssocEvRecoPtTrig, Hadron, "mc/plain/h4_ptTrigPtAssocZPvMult_trueAssocEvRecoPtTrig_hadron"}, - {Correlation, TrueAssocEvRecoPtTrig, Hadron, "mc/corr/h6_corr_trueAssocEvRecoPtTrig_hadron"}, - {Mixing, TrueAssocEvRecoPtTrig, Hadron, "mc/corr/h6_mix_trueAssocEvRecoPtTrig_hadron"}, - {PlainPhiEta, TrueAssocEvRecoPtTrig, Pipm, "mc/plain/h4_ptTrigPtAssocPhiEta_trueAssocEvRecoPtTrig_pipm"}, - {PlainZPvMult, TrueAssocEvRecoPtTrig, Pipm, "mc/plain/h4_ptTrigPtAssocZPvMult_trueAssocEvRecoPtTrig_pipm"}, - {Correlation, TrueAssocEvRecoPtTrig, Pipm, "mc/corr/h6_corr_trueAssocEvRecoPtTrig_pipm"}, - {Mixing, TrueAssocEvRecoPtTrig, Pipm, "mc/corr/h6_mix_trueAssocEvRecoPtTrig_pipm"}, - {PlainPhiEta, TrueAssocEvRecoPtTrig, PhotonPcm, "mc/plain/h4_ptTrigPtAssocPhiEta_trueAssocEvRecoPtTrig_photon"}, - {PlainZPvMult, TrueAssocEvRecoPtTrig, PhotonPcm, "mc/plain/h4_ptTrigPtAssocZPvMult_trueAssocEvRecoPtTrig_photon"}, - {Correlation, TrueAssocEvRecoPtTrig, PhotonPcm, "mc/corr/h6_corr_trueAssocEvRecoPtTrig_photon"}, - {Mixing, TrueAssocEvRecoPtTrig, PhotonPcm, "mc/corr/h6_mix_trueAssocEvRecoPtTrig_photon"}, - {PlainPt, TrueAssocEvRecoPtTrig, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_trueAssocEvRecoPtTrig_pi0"}, - {Correlation, TrueAssocEvRecoPtTrig, Pi0Pcm, "mc/corr/h6_corr_trueAssocEvRecoPtTrig_pi0"}, - {Mixing, TrueAssocEvRecoPtTrig, Pi0Pcm, "mc/corr/h6_mix_trueAssocEvRecoPtTrig_pi0"}, - {PlainPt, TrueAssocEvRecoPtTrig, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_trueAssocEvRecoPtTrig_eta"}, - {Correlation, TrueAssocEvRecoPtTrig, EtaPcm, "mc/corr/h6_corr_trueAssocEvRecoPtTrig_eta"}, - {Mixing, TrueAssocEvRecoPtTrig, EtaPcm, "mc/corr/h6_mix_trueAssocEvRecoPtTrig_eta"}, - - {PlainPt, TrueDecaySelfTrig, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_trueDecaySelfTrig_pi0"}, - {Correlation, TrueDecaySelfTrig, Pi0Pcm, "mc/corr/h6_corr_trueDecaySelfTrig_pi0"}, - {Mixing, TrueDecaySelfTrig, Pi0Pcm, "mc/corr/h6_mix_trueDecaySelfTrig_pi0"}, - {PlainPt, TrueDecaySelfTrig, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_trueDecaySelfTrig_eta"}, - {Correlation, TrueDecaySelfTrig, EtaPcm, "mc/corr/h6_corr_trueDecaySelfTrig_eta"}, - {Mixing, TrueDecaySelfTrig, EtaPcm, "mc/corr/h6_mix_trueDecaySelfTrig_eta"}, - - {PlainPt, TrueMeasDecay, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_trueMeasDecay_pi0"}, - {Correlation, TrueMeasDecay, Pi0Pcm, "mc/corr/h6_corr_trueMeasDecay_pi0"}, - {Mixing, TrueMeasDecay, Pi0Pcm, "mc/corr/h6_mix_trueMeasDecay_pi0"}, - {PlainPt, TrueMeasDecay, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_trueMeasDecay_eta"}, - {Correlation, TrueMeasDecay, EtaPcm, "mc/corr/h6_corr_trueMeasDecay_eta"}, - {Mixing, TrueMeasDecay, EtaPcm, "mc/corr/h6_mix_trueMeasDecay_eta"}, - - {PlainPt, TrueGeoAcc, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_trueGeoAcc_pi0"}, - {Correlation, TrueGeoAcc, Pi0Pcm, "mc/corr/h6_corr_trueGeoAcc_pi0"}, - {Mixing, TrueGeoAcc, Pi0Pcm, "mc/corr/h6_mix_trueGeoAcc_pi0"}, - {PlainPt, TrueGeoAcc, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_trueGeoAcc_eta"}, - {Correlation, TrueGeoAcc, EtaPcm, "mc/corr/h6_corr_trueGeoAcc_eta"}, - {Mixing, TrueGeoAcc, EtaPcm, "mc/corr/h6_mix_trueGeoAcc_eta"} - }); - }(); - - template - void fillAssocsMcTrue(auto histFillInfo, auto const& assocParticle, T_DecaySelfTrigFunc const& isDecaySelfTrig = {}) { + // mc true++ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + + template + void fillAssocsMcTrue(auto histFillInfo, auto const& assocParticle, T_DecaySelfTrigFunc const& isDecaySelfTrig = {}) + { // main eta cut if (std::abs(assocParticle.eta()) > config.absEtaMax.value) { return; @@ -1720,11 +1721,11 @@ struct HadronPhotonCorrelation { if (assocParticle.isPhysicalPrimary()) { // hadron (charged primary) if (isCharged(assocParticle)) { - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); } // pipm if (std::abs(assocParticle.pdgCode()) == PDG_t::kPiPlus) { - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); return; } // photon @@ -1732,7 +1733,7 @@ struct HadronPhotonCorrelation { // mc-to-data scaling histFillInfo.weight *= getMcAssocPtScalingFromPt(assocParticle.pt()); - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); // extra info for decay correlation only for total true level if constexpr (TruthLevelV == TruthLevel::True) { @@ -1742,31 +1743,31 @@ struct HadronPhotonCorrelation { int const statusDirect = 62; if (std::abs(assocParticle.getGenStatusCode()) >= statusDecayLow && std::abs(assocParticle.getGenStatusCode()) <= statusDecayUp) { - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); // decays from different mothers int const pdgMother = assocParticle.template mothers_as().begin()->pdgCode(); switch (pdgMother) { case PDG_t::kPi0: - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); break; case constants::physics::Pdg::kEta: - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); break; case constants::physics::Pdg::kOmega: - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); break; case constants::physics::Pdg::kEtaPrime: - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); break; default: - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); break; } } else { - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); // log unexpected status if (assocParticle.getGenStatusCode() != statusDirect) { - LOGF(info, "filled direct photon with status: %i", assocParticle.getGenStatusCode()); + histos.fill(HIST("mc/info/h1_unusualStatus_photonDirect"), assocParticle.getGenStatusCode()); } } } @@ -1784,7 +1785,7 @@ struct HadronPhotonCorrelation { histFillInfo.weight *= getMcAssocPtScalingFromPt(assocParticle.pt()); if constexpr (TruthLevelV == TruthLevel::True) { - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); } // self trigger if constexpr (HistFillModeV == HistFillMode::Plain) { @@ -1799,19 +1800,19 @@ struct HadronPhotonCorrelation { } else { static_assert(AlwaysFalseValue, "histFillMode not found"); } - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); // decaying particles extra info - if constexpr (TruthLevelV == TruthLevel::TrueAssocEvRecoPtTrig) { + if constexpr (TruthLevelV == TruthLevel::TrueRecoEvRecoPtTrig) { // chosen decay if (!isDecayToGG(assocParticle)) { return; } - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); // daughters in acceptance if (!checkDaughtersInAcceptance(assocParticle, {-config.absEtaMax.value, config.absEtaMax.value})) { return; } - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); } return; } @@ -1821,7 +1822,7 @@ struct HadronPhotonCorrelation { histFillInfo.weight *= getMcAssocPtScalingFromPt(assocParticle.pt()); if constexpr (TruthLevelV == TruthLevel::True) { - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); } // self trigger if constexpr (HistFillModeV == HistFillMode::Plain) { @@ -1836,19 +1837,19 @@ struct HadronPhotonCorrelation { } else { static_assert(AlwaysFalseValue, "histFillMode not found"); } - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); // decaying particles extra info - if constexpr (TruthLevelV == TruthLevel::TrueAssocEvRecoPtTrig) { + if constexpr (TruthLevelV == TruthLevel::TrueRecoEvRecoPtTrig) { // chosen decay if (!isDecayToGG(assocParticle)) { return; } - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); // daughters in acceptance if (!checkDaughtersInAcceptance(assocParticle, {-config.absEtaMax.value, config.absEtaMax.value})) { return; } - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); } return; } @@ -1857,18 +1858,18 @@ struct HadronPhotonCorrelation { if constexpr (TruthLevelV == TruthLevel::True) { // omega if (assocParticle.pdgCode() == constants::physics::Pdg::kOmega) { - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); return; } // etaPrime if (assocParticle.pdgCode() == constants::physics::Pdg::kEtaPrime) { - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); return; } } } - void processMcTrue(CorrMcCollisions const& mcCollisions, aod::TrueTriggers const& trueTriggers, aod::JetParticles const& mcParticles) + void processMcTrue(CorrMcCollisions const& mcCollisions, aod::HpcTrueTriggers const& trueTriggers, aod::JetParticles const& mcParticles) { for (auto const& mcCollision : mcCollisions) { // event selection @@ -1888,7 +1889,8 @@ struct HadronPhotonCorrelation { auto const isDecaySelfTrig = [&decaySelfTrigPlainMap](AssocType const assocType) { return decaySelfTrigPlainMap.at(assocType); }; - HistFillInfoPlainPhiEtaZPvMult histFillInfo = {mcCollision.ptMax(), assocParticle.pt(), assocParticle.phi(), assocParticle.eta(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; + HistFillInfoPlainPhiEtaZPvMult histFillInfo = {mcCollision.ptMax(), assocParticle.pt(), assocParticle.phi(), assocParticle.eta(), + mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); }; corrProcessPlain(mcCollision, mcParticlesThisEvent, funcPlain); @@ -1926,7 +1928,7 @@ struct HadronPhotonCorrelation { } PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrue, "process mc-true (all collisions) for multiple associated particles", false); - void processMcTrueAssocEv(CorrCollisionsMcD const& collisions, CorrMcCollisions const&, aod::TrueTriggers const& trueTriggers, aod::JetParticles const& mcParticles) + void processMcTrueRecoEv(HpcCollisionsMcD const& collisions, CorrMcCollisions const&, aod::HpcTrueTriggers const& trueTriggers, aod::JetParticles const& mcParticles) { for (auto const& collision : collisions) { // event selection @@ -1945,15 +1947,16 @@ struct HadronPhotonCorrelation { auto const mcParticlesThisEvent = mcParticles.sliceBy(perColMcParticles, collision.jetMcCollisionId()); // self correlation of events (plain) - std::map const decaySelfTrigPlainMap = getDecaySelfTrigPlainMap(trueTriggersThisEvent); + std::map const decaySelfTrigPlainMap = getDecaySelfTrigPlainMap(trueTriggersThisEvent); auto const funcPlain = [this, &decaySelfTrigPlainMap](auto const& mcCollision, auto const& assocParticle) { // self trigger info for decaying particles auto const isDecaySelfTrig = [&decaySelfTrigPlainMap](AssocType const assocType) { return decaySelfTrigPlainMap.at(assocType); }; - HistFillInfoPlainPhiEtaZPvMult histFillInfo = {mcCollision.ptMax(), assocParticle.pt(), assocParticle.phi(), assocParticle.eta(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; - fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); + HistFillInfoPlainPhiEtaZPvMult histFillInfo = {mcCollision.ptMax(), assocParticle.pt(), assocParticle.phi(), assocParticle.eta(), + mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; + fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); }; corrProcessPlain(mcCollision, mcParticlesThisEvent, funcPlain); @@ -1970,12 +1973,12 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(trueTrigger.phi(), assocParticle.phi()), trueTrigger.eta() - assocParticle.eta(), trueTrigger.pt(), assocParticle.pt(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; - fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); + fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); }; corrProcessCorrelation(mcCollision, trueTriggersThisEvent, mcParticlesThisEvent, funcCorrelation); // select mixing events - if (config.doTrigEvMixing.value && !collision.trigEv()) { + if (config.doTrigEvMixing.value && !mcCollision.trigEv()) { continue; } @@ -1983,14 +1986,14 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), assocParticle.phi()), mixingTrigger.eta() - assocParticle.eta(), mixingTrigger.pt(), assocParticle.pt(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; histFillInfo.weight = perTriggerWeight; - fillAssocsMcTrue(histFillInfo, assocParticle); + fillAssocsMcTrue(histFillInfo, assocParticle); }; - corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, config.nMixingAt0McTrue.value); + corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, config.nMixingAt0McTrue.value); } } - PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueAssocEv, "process mc-true (reco collisions) correlation for multiple associated particles", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueRecoEv, "process mc-true (reco collisions) correlation for multiple associated particles", false); - void processMcTrueAssocEvRecoPtTrig(CorrCollisionsMcD const& collisions, soa::Join const& triggers, aod::JetTracksMCD const&, + void processMcTrueRecoEvRecoPtTrig(HpcCollisionsMcD const& collisions, soa::Join const& triggers, aod::JetTracksMCD const&, CorrMcCollisions const&, aod::JetParticles const& mcParticles) { for (auto const& collision : collisions) { @@ -2010,7 +2013,7 @@ struct HadronPhotonCorrelation { auto const mcParticlesThisEvent = mcParticles.sliceBy(perColMcParticles, collision.jetMcCollisionId()); // self correlation of events (plain) - std::map const decaySelfTrigPlainMap = getDecaySelfTrigPlainMap(triggersThisEvent); + std::map const decaySelfTrigPlainMap = getDecaySelfTrigPlainMap(triggersThisEvent); auto const funcPlain = [this, &decaySelfTrigPlainMap](auto const& collision, auto const& assocParticle) { auto const& mcCollision = collision.template jetMcCollision_as(); @@ -2018,14 +2021,15 @@ struct HadronPhotonCorrelation { auto const isDecaySelfTrig = [&decaySelfTrigPlainMap](AssocType const assocType) { return decaySelfTrigPlainMap.at(assocType); }; - HistFillInfoPlainPhiEtaZPvMult histFillInfo = {collision.ptMax(), assocParticle.pt(), assocParticle.phi(), assocParticle.eta(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; - fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); + HistFillInfoPlainPhiEtaZPvMult histFillInfo = {collision.ptMax(), assocParticle.pt(), assocParticle.phi(), assocParticle.eta(), + mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; + fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); }; corrProcessPlain(collision, mcParticlesThisEvent, funcPlain); auto const funcCorrelation = [this](auto const& mcCollision, auto const& trigger, auto const& assocParticle) { if (!isMcMatchedTrigger(trigger)) { - return; + return; } auto const& triggerParticle = trigger.template jetTrack_as().mcParticle(); // self trigger info for decaying particles @@ -2046,7 +2050,7 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(triggerParticle.phi(), assocParticle.phi()), triggerParticle.eta() - assocParticle.eta(), trigger.pt(), assocParticle.pt(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; - fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); + fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); }; corrProcessCorrelation(mcCollision, triggersThisEvent, mcParticlesThisEvent, funcCorrelation); @@ -2059,63 +2063,18 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), assocParticle.phi()), mixingTrigger.eta() - assocParticle.eta(), mixingTrigger.pt(), assocParticle.pt(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; histFillInfo.weight = perTriggerWeight; - fillAssocsMcTrue(histFillInfo, assocParticle, [](){ return false; }); + fillAssocsMcTrue(histFillInfo, assocParticle, []() { return false; }); }; - corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, config.nMixingAt0McTrue.value); - } - } - PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueAssocEvRecoPtTrig, "process mc-true (reco collisions with reco ptTrig) correlation for multiple associated particles", false); - - // standard mc reco++ histogram compile-time paths - static constexpr auto HistPathsMcRecoStd = []() { - using enum HistFillMode; - using enum TruthLevel; - using enum AssocType; - - return std::to_array({ - {PlainPhiEta, RecoAssocEv, Hadron, "mc/plain/h4_ptTrigPtAssocPhiEta_recoAssocEv_hadron"}, - {PlainZPvMult, RecoAssocEv, Hadron, "mc/plain/h4_ptTrigPtAssocZPvMult_recoAssocEv_hadron"}, - {Correlation, RecoAssocEv, Hadron, "mc/corr/h6_corr_recoAssocEv_hadron"}, - {Mixing, RecoAssocEv, Hadron, "mc/corr/h6_mix_recoAssocEv_hadron"}, - {PlainPhiEta, RecoAssocEv, Pipm, "mc/plain/h4_ptTrigPtAssocPhiEta_recoAssocEv_pipm"}, - {PlainZPvMult, RecoAssocEv, Pipm, "mc/plain/h4_ptTrigPtAssocZPvMult_recoAssocEv_pipm"}, - {Correlation, RecoAssocEv, Pipm, "mc/corr/h6_corr_recoAssocEv_pipm"}, - {Mixing, RecoAssocEv, Pipm, "mc/corr/h6_mix_recoAssocEv_pipm"}, - {PlainPhiEta, RecoAssocEv, PhotonPcm, "mc/plain/h4_ptTrigPtAssocPhiEta_recoAssocEv_photonPcm"}, - {PlainZPvMult, RecoAssocEv, PhotonPcm, "mc/plain/h4_ptTrigPtAssocZPvMult_recoAssocEv_photonPcm"}, - {Correlation, RecoAssocEv, PhotonPcm, "mc/corr/h6_corr_recoAssocEv_photonPcm"}, - {Mixing, RecoAssocEv, PhotonPcm, "mc/corr/h6_mix_recoAssocEv_photonPcm"}, - - {PlainPhiEta, RecoPure, Hadron, "mc/plain/h4_ptTrigPtAssocPhiEta_recoPure_hadron"}, - {PlainZPvMult, RecoPure, Hadron, "mc/plain/h4_ptTrigPtAssocZPvMult_recoPure_hadron"}, - {Correlation, RecoPure, Hadron, "mc/corr/h6_corr_recoPure_hadron"}, - {Mixing, RecoPure, Hadron, "mc/corr/h6_mix_recoPure_hadron"}, - {PlainPhiEta, RecoPure, Pipm, "mc/plain/h4_ptTrigPtAssocPhiEta_recoPure_pipm"}, - {PlainZPvMult, RecoPure, Pipm, "mc/plain/h4_ptTrigPtAssocZPvMult_recoPure_pipm"}, - {Correlation, RecoPure, Pipm, "mc/corr/h6_corr_recoPure_pipm"}, - {Mixing, RecoPure, Pipm, "mc/corr/h6_mix_recoPure_pipm"}, - {PlainPhiEta, RecoPure, PhotonPcm, "mc/plain/h4_ptTrigPtAssocPhiEta_recoPure_photonPcm"}, - {PlainZPvMult, RecoPure, PhotonPcm, "mc/plain/h4_ptTrigPtAssocZPvMult_recoPure_photonPcm"}, - {Correlation, RecoPure, PhotonPcm, "mc/corr/h6_corr_recoPure_photonPcm"}, - {Mixing, RecoPure, PhotonPcm, "mc/corr/h6_mix_recoPure_photonPcm"}, - - {PlainPhiEta, RecoPureTruePtAssoc, Hadron, "mc/plain/h4_ptTrigPtAssocPhiEta_recoPureTruePtAssoc_hadron"}, - {PlainZPvMult, RecoPureTruePtAssoc, Hadron, "mc/plain/h4_ptTrigPtAssocZPvMult_recoPureTruePtAssoc_hadron"}, - {Correlation, RecoPureTruePtAssoc, Hadron, "mc/corr/h6_corr_recoPureTruePtAssoc_hadron"}, - {Mixing, RecoPureTruePtAssoc, Hadron, "mc/corr/h6_mix_recoPureTruePtAssoc_hadron"}, - {PlainPhiEta, RecoPureTruePtAssoc, Pipm, "mc/plain/h4_ptTrigPtAssocPhiEta_recoPureTruePtAssoc_pipm"}, - {PlainZPvMult, RecoPureTruePtAssoc, Pipm, "mc/plain/h4_ptTrigPtAssocZPvMult_recoPureTruePtAssoc_pipm"}, - {Correlation, RecoPureTruePtAssoc, Pipm, "mc/corr/h6_corr_recoPureTruePtAssoc_pipm"}, - {Mixing, RecoPureTruePtAssoc, Pipm, "mc/corr/h6_mix_recoPureTruePtAssoc_pipm"}, - {PlainPhiEta, RecoPureTruePtAssoc, PhotonPcm, "mc/plain/h4_ptTrigPtAssocPhiEta_recoPureTruePtAssoc_photonPcm"}, - {PlainZPvMult, RecoPureTruePtAssoc, PhotonPcm, "mc/plain/h4_ptTrigPtAssocZPvMult_recoPureTruePtAssoc_photonPcm"}, - {Correlation, RecoPureTruePtAssoc, PhotonPcm, "mc/corr/h6_corr_recoPureTruePtAssoc_photonPcm"}, - {Mixing, RecoPureTruePtAssoc, PhotonPcm, "mc/corr/h6_mix_recoPureTruePtAssoc_photonPcm"} - }); - }(); + corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, config.nMixingAt0McTrue.value); + } + } + PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueRecoEvRecoPtTrig, "process mc-true (reco collisions with reco ptTrig) correlation for multiple associated particles", false); + + // standard mc reco++ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: template - void fillTruthLevelsMcRecoStd(auto histFillInfo, auto const& collision, auto const& associated) { + void fillTruthLevelsMcRecoStd(auto histFillInfo, auto const& collision, auto const& associated) + { // photon impurity if constexpr (HistFillModeV == HistFillMode::Plain && AssocTypeV == AssocType::PhotonPcm) { PhotonImpurity const impurity = static_cast(associated.impurityPhotonPcm()); @@ -2127,15 +2086,15 @@ struct HadronPhotonCorrelation { if (!checkTruthLevelReco(associated)) { return; } - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); // purity if (!checkTruthLevelReco(associated)) { return; } - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); // true ptAssoc histFillInfo.ptAssoc = associated.ptTruePure(); - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); } template @@ -2167,7 +2126,8 @@ struct HadronPhotonCorrelation { return; } - HistFillInfoPlainPhiEtaZPvMult histFillInfo = {collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), collision.posZ(), static_cast(collision.nGlobalTracks())}; + HistFillInfoPlainPhiEtaZPvMult histFillInfo = {collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), + collision.posZ(), static_cast(collision.nGlobalTracks())}; histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated); fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); }; @@ -2185,7 +2145,8 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(trigger.phi(), associated.phi()), trigger.eta() - associated.eta(), trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(trigger.pt()); + histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * + getTriggerPtCorrection(trigger.pt()); fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); }; corrProcessCorrelation(collision, triggersThisEvent, assocsThisEvent, funcCorrelation); @@ -2202,71 +2163,39 @@ struct HadronPhotonCorrelation { auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = perTriggerWeight * getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(mixingTrigger.pt()); + histFillInfo.weight = perTriggerWeight * + getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * + getTriggerPtCorrection(mixingTrigger.pt()); fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); }; corrProcessMixing(collision, assocsThisEvent, funcMixing, nMixingAt0, conditionMixAssocOnly); } } - void processMcRecoHadron(CorrCollisions const& collisions, aod::Triggers const& triggers, aod::Hadrons const& hadrons) + void processMcRecoHadron(HpcCollisions const& collisions, aod::HpcTriggers const& triggers, aod::HpcHadrons const& hadrons) { fillProcessMcRecoStd(collisions, triggers, hadrons); } PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoHadron, "process standard for associated hardon with additional mc information", false); - void processMcRecoPipm(CorrCollisions const& collisions, aod::Triggers const& triggers, aod::Pipms const& pipms) + void processMcRecoPipm(HpcCollisions const& collisions, aod::HpcTriggers const& triggers, aod::HpcPipms const& pipms) { fillProcessMcRecoStd(collisions, triggers, pipms); } PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoPipm, "process standard for associated pipm with additional mc information", false); - void processMcRecoPhotonPcm(CorrCollisions const& collisions, aod::Triggers const& triggers, PhotonPcmsWithV0 const& photonPcms, + void processMcRecoPhotonPcm(HpcCollisions const& collisions, aod::HpcTriggers const& triggers, PhotonPcmsWithV0 const& photonPcms, aod::V0PhotonsKF const&, aod::V0Legs const&) { fillProcessMcRecoStd(collisions, triggers, photonPcms); } PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoPhotonPcm, "process standard for associated photonPcm with additional mc information", false); - // photonPcmPair mc reco++ histogram compile-time paths - static constexpr auto HistPathsMcRecoPhotonPcmPair = []() { - using enum HistFillMode; - using enum TruthLevel; - using enum AssocType; - - return std::to_array({ - {PlainPt, PseudoReco, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_pseudoReco_pi0Pcm"}, - {Correlation, PseudoReco, Pi0Pcm, "mc/corr/h6_corr_pseudoReco_pi0Pcm"}, - {Mixing, PseudoReco, Pi0Pcm, "mc/corr/h6_mix_pseudoReco_pi0Pcm"}, - {PlainPt, PseudoReco, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_pseudoReco_etaPcm"}, - {Correlation, PseudoReco, EtaPcm, "mc/corr/h6_corr_pseudoReco_etaPcm"}, - {Mixing, PseudoReco, EtaPcm, "mc/corr/h6_mix_pseudoReco_etaPcm"}, - - {PlainPt, PseudoRecoAssocEv, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_pseudoRecoAssocEv_pi0Pcm"}, - {Correlation, PseudoRecoAssocEv, Pi0Pcm, "mc/corr/h6_corr_pseudoRecoAssocEv_pi0Pcm"}, - {Mixing, PseudoRecoAssocEv, Pi0Pcm, "mc/corr/h6_mix_pseudoRecoAssocEv_pi0Pcm"}, - {PlainPt, PseudoRecoAssocEv, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_pseudoRecoAssocEv_etaPcm"}, - {Correlation, PseudoRecoAssocEv, EtaPcm, "mc/corr/h6_corr_pseudoRecoAssocEv_etaPcm"}, - {Mixing, PseudoRecoAssocEv, EtaPcm, "mc/corr/h6_mix_pseudoRecoAssocEv_etaPcm"}, - - {PlainPt, PseudoRecoPure, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_pseudoRecoPure_pi0Pcm"}, - {Correlation, PseudoRecoPure, Pi0Pcm, "mc/corr/h6_corr_pseudoRecoPure_pi0Pcm"}, - {Mixing, PseudoRecoPure, Pi0Pcm, "mc/corr/h6_mix_pseudoRecoPure_pi0Pcm"}, - {PlainPt, PseudoRecoPure, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_pseudoRecoPure_etaPcm"}, - {Correlation, PseudoRecoPure, EtaPcm, "mc/corr/h6_corr_pseudoRecoPure_etaPcm"}, - {Mixing, PseudoRecoPure, EtaPcm, "mc/corr/h6_mix_pseudoRecoPure_etaPcm"}, - - {PlainPt, PseudoRecoPureTruePtAssoc, Pi0Pcm, "mc/plain/h2_ptTrigPtAssoc_pseudoRecoPureTruePtAssoc_pi0Pcm"}, - {Correlation, PseudoRecoPureTruePtAssoc, Pi0Pcm, "mc/corr/h6_corr_pseudoRecoPureTruePtAssoc_pi0Pcm"}, - {Mixing, PseudoRecoPureTruePtAssoc, Pi0Pcm, "mc/corr/h6_mix_pseudoRecoPureTruePtAssoc_pi0Pcm"}, - {PlainPt, PseudoRecoPureTruePtAssoc, EtaPcm, "mc/plain/h2_ptTrigPtAssoc_pseudoRecoPureTruePtAssoc_etaPcm"}, - {Correlation, PseudoRecoPureTruePtAssoc, EtaPcm, "mc/corr/h6_corr_pseudoRecoPureTruePtAssoc_etaPcm"}, - {Mixing, PseudoRecoPureTruePtAssoc, EtaPcm, "mc/corr/h6_mix_pseudoRecoPureTruePtAssoc_etaPcm"} - }); - }(); + // photonPcmPair mc reco++ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: template - void fillTruthLevelsMcRecoPhotonPcmPair(auto histFillInfo, auto const& collision, auto const& associated) { + void fillTruthLevelsMcRecoPhotonPcmPair(auto histFillInfo, auto const& collision, auto const& associated) + { // pi0 impurity if constexpr (HistFillModeV == HistFillMode::Plain && AssocTypeV == AssocType::Pi0Pcm) { PhotonImpurity const impurity = static_cast(associated.impurityPi0Pcm()); @@ -2278,19 +2207,20 @@ struct HadronPhotonCorrelation { if (!checkTruthLevelReco(associated)) { return; } - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); // purity if (!checkTruthLevelReco(associated)) { return; } - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); // true ptAssoc histFillInfo.ptAssoc = associated.ptTruePure(); - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); } template - void fillAssocsMcRecoPhotonPcmPair(auto histFillInfo, auto const& collision, auto const& associated) { + void fillAssocsMcRecoPhotonPcmPair(auto histFillInfo, auto const& collision, auto const& associated) + { // pi0Pcm if (checkTruthLevelReco(associated)) { // pseudo yield @@ -2308,7 +2238,7 @@ struct HadronPhotonCorrelation { // mgg distribution - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); fillTruthLevelsMcRecoPhotonPcmPair(histFillInfo, collision, associated); return; @@ -2328,14 +2258,15 @@ struct HadronPhotonCorrelation { histFillInfo.weight); } - fillHistMain(histFillInfo); + fillHistMain(histFillInfo); fillTruthLevelsMcRecoPhotonPcmPair(histFillInfo, collision, associated); return; } } - void fillProcesMcRecoPhotonPcmPair(auto const& collisions, auto const& triggers, auto const& photonPcmPairs) { + void fillProcesMcRecoPhotonPcmPair(auto const& collisions, auto const& triggers, auto const& photonPcmPairs) + { for (auto const& collision : collisions) { // event selection if (!totalEvSel(collision)) { @@ -2370,7 +2301,8 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(trigger.phi(), associated.phi()), trigger.eta() - associated.eta(), trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(trigger.pt()); + histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * + getTriggerPtCorrection(trigger.pt()); fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); }; corrProcessCorrelation(collision, triggersThisEvent, photonPcmPairsThisEvent, funcCorrelation); @@ -2387,14 +2319,16 @@ struct HadronPhotonCorrelation { auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = perTriggerWeight * getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(mixingTrigger.pt()); + histFillInfo.weight = perTriggerWeight * + getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * + getTriggerPtCorrection(mixingTrigger.pt()); fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); }; corrProcessMixing(collision, photonPcmPairsThisEvent, funcMixing, config.nMixingAt0PhotonPcmPair.value, conditionMixAssocOnly); } } - void processMcRecoPhotonPcmPair(CorrCollisions const& collisions, aod::Triggers const& triggers, PhotonPcmPairsWithV0 const& photonPcmPairs, + void processMcRecoPhotonPcmPair(HpcCollisions const& collisions, aod::HpcTriggers const& triggers, PhotonPcmPairsWithV0 const& photonPcmPairs, aod::V0PhotonsKF const&, aod::V0Legs const&) { fillProcesMcRecoPhotonPcmPair(collisions, triggers, photonPcmPairs); @@ -2404,7 +2338,7 @@ struct HadronPhotonCorrelation { // other //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - void processPcmDcaZTrue(CorrCollisionsMcD::iterator const& collision, soa::Join const& photonPcms, + void processPcmDcaZTrue(HpcCollisionsMcD::iterator const& collision, soa::Join const& photonPcms, aod::V0PhotonsKF const&, aod::V0Legs const&, aod::JetTracksMCD const&, CorrMcCollisions const&, aod::JetParticles const&) { // event selection @@ -2440,7 +2374,7 @@ struct HadronPhotonCorrelation { // last ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - void processRecoLast(CorrCollisions const& collisions, aod::Triggers const& triggers) + void processRecoLast(HpcCollisions const& collisions, aod::HpcTriggers const& triggers) { // do at end of each data frame (after other reco correlation process functions) // (PROCESS_SWITCH of this process has to be declared last) @@ -2469,7 +2403,7 @@ struct HadronPhotonCorrelation { // trigger loop for (auto const& trigger : triggersThisEvent) { // trigger info - histos.fill(HIST("reco/corr/h3_ptPhiEta_trig"), trigger.pt(), trigger.phi(), trigger.eta(), + histos.fill(HIST("reco/corr/h3_ptPhiEta_trig_reco"), trigger.pt(), trigger.phi(), trigger.eta(), getTriggerPtCorrection(trigger.pt())); // save trigger for mixing @@ -2479,8 +2413,8 @@ struct HadronPhotonCorrelation { } PROCESS_SWITCH(HadronPhotonCorrelation, processRecoLast, "process general info for reconstructed collisions and later correlations last", true); - void processMcLast(CorrCollisionsMcD const& collisions, soa::Join const& triggers, aod::JetTracksMCD const&, - CorrMcCollisions const& mcCollisions, aod::TrueTriggers const& trueTriggers, aod::JetParticles const&) + void processMcLast(HpcCollisionsMcD const& collisions, soa::Join const& triggers, aod::JetTracksMCD const&, + CorrMcCollisions const& mcCollisions, aod::HpcTrueTriggers const& trueTriggers, aod::JetParticles const&) { // do at end of each data frame (after other mc correlation process functions) // (PROCESS_SWITCH of this process has to be declared last) @@ -2522,16 +2456,16 @@ struct HadronPhotonCorrelation { auto const trueTriggersThisEvent = trueTriggers.sliceBy(perColTrueTriggers, mcCollision.globalIndex()); auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); - histos.fill(HIST("mc/info/h3_nEv_ptTrigZPvMult_trueAssocEv"), mcCollision.ptMax(), mcCollision.posZ(), mcCollision.nChargedInEtaRange()); - histos.fill(HIST("mc/info/h3_nEv_ptTrigZPvMult_trueAssocEvRecoPtTrig"), collision.ptMax(), mcCollision.posZ(), mcCollision.nChargedInEtaRange()); + histos.fill(HIST("mc/info/h3_nEv_ptTrigZPvMult_trueRecoEv"), mcCollision.ptMax(), mcCollision.posZ(), mcCollision.nChargedInEtaRange()); + histos.fill(HIST("mc/info/h3_nEv_ptTrigZPvMult_trueRecoEvRecoPtTrig"), collision.ptMax(), mcCollision.posZ(), mcCollision.nChargedInEtaRange()); // trigger loops for (auto const& trueTrigger : trueTriggersThisEvent) { // trigger info - histos.fill(HIST("mc/corr/h3_ptPhiEta_trig_trueAssocEv"), trueTrigger.pt(), trueTrigger.phi(), trueTrigger.eta()); + histos.fill(HIST("mc/corr/h3_ptPhiEta_trig_trueRecoEv"), trueTrigger.pt(), trueTrigger.phi(), trueTrigger.eta()); // save trigger for mixing - triggerMemoryTrueAssocEv->saveTrigger(trueTrigger.pt(), trueTrigger.phi(), trueTrigger.eta(), mcCollision.posZ(), mcCollision.nChargedInEtaRange()); + triggerMemoryTrueRecoEv->saveTrigger(trueTrigger.pt(), trueTrigger.phi(), trueTrigger.eta(), mcCollision.posZ(), mcCollision.nChargedInEtaRange()); } for (auto const& trigger : triggersThisEvent) { if (!isMcMatchedTrigger(trigger)) { @@ -2542,10 +2476,10 @@ struct HadronPhotonCorrelation { auto const& triggerParticle = trigger.jetTrack_as().mcParticle(); // trigger info - histos.fill(HIST("mc/corr/h3_ptPhiEta_trig_trueAssocEvRecoPtTrig"), trigger.pt(), triggerParticle.phi(), triggerParticle.eta()); + histos.fill(HIST("mc/corr/h3_ptPhiEta_trig_trueRecoEvRecoPtTrig"), trigger.pt(), triggerParticle.phi(), triggerParticle.eta()); // save trigger for mixing - triggerMemoryTrueAssocEvRecoPtTrig->saveTrigger(trigger.pt(), triggerParticle.phi(), triggerParticle.eta(), mcCollision.posZ(), mcCollision.nChargedInEtaRange()); + triggerMemoryTrueRecoEvRecoPtTrig->saveTrigger(trigger.pt(), triggerParticle.phi(), triggerParticle.eta(), mcCollision.posZ(), mcCollision.nChargedInEtaRange()); } } } diff --git a/PWGJE/Tasks/hadronPhotonProducer.cxx b/PWGJE/Tasks/hadronPhotonProducer.cxx index 8185e2171b9..e304458fe82 100644 --- a/PWGJE/Tasks/hadronPhotonProducer.cxx +++ b/PWGJE/Tasks/hadronPhotonProducer.cxx @@ -16,14 +16,13 @@ /// Table producer for hadron-photon angular correlation analysis #include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/HadronPhotonCorrelation.h" #include "PWGJE/DataModel/Jet.h" #include "PWGJE/DataModel/JetReducedData.h" -#include "PWGJE/DataModel/HadronPhotonCorrelation.h" // #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" #include "Common/Core/RecoDecay.h" -#include "Common/Core/TableHelper.h" #include "Common/DataModel/PIDResponseTOF.h" #include "Common/DataModel/PIDResponseTPC.h" @@ -57,6 +56,7 @@ using namespace o2; using namespace o2::framework; +using namespace hpc; // correlation derived data =================================================================================================================================================================== @@ -68,24 +68,24 @@ concept IsMcCollision = requires(T& collision) { collision.getGeneratorId(); }; struct HadronPhotonProducer { struct : ProducesGroup { // reco - Produces corrCollision; - Produces corrCollisionId; - Produces corrCollisionMcId; - Produces trigger; - Produces triggerTrackId; - Produces hadron; - Produces hadronTrackId; - Produces pipm; - Produces pipmTrackId; - Produces photonPcm; - Produces photonPcmTrackId; - Produces photonPcmV0PhotonId; - Produces photonPcmPair; - Produces photonPcmPairTrackId; - Produces photonPcmPairV0PhotonId; + Produces collision; + Produces collisionId; + Produces collisionMcId; + Produces trigger; + Produces triggerTrackId; + Produces hadron; + Produces hadronTrackId; + Produces pipm; + Produces pipmTrackId; + Produces photonPcm; + Produces photonPcmTrackId; + Produces photonPcmV0PhotonId; + Produces photonPcmPair; + Produces photonPcmPairTrackId; + Produces photonPcmPairV0PhotonId; // true - Produces mcCollisionExtraCorr; - Produces trueTrigger; + Produces mcCollisionExtraCorr; + Produces trueTrigger; } tableProduction; Configurable zPvMax{"zPvMax", 7, "maximum absZ primary-vertex cut"}; @@ -99,24 +99,21 @@ struct HadronPhotonProducer { Configurable trackSelections{"trackSelections", "globalTracks", "JE framework - track selections"}; Configurable triggerMasks{"triggerMasks", "", "JE framework - skimmed data trigger masks (relevent for correlation: fTrackLowPt,fTrackHighPt)"}; - Configurable ptMinHadron{"ptMinHadron", 0.1, "min pt value for hadrons"}; - + Configurable absEtaMax{"absEtaMax", 0.8, "maximum absEta cut"}; + Configurable ptTrigMin{"ptTrigMin", 5, "minimum pt of triggers"}; + Configurable ptMinTrack{"ptMinTrack", 0.1, "min pt value for tracks (hadron, pipm, mult, trig,... (not v0 legs or other external))"}; + Configurable ptMinHadron{"ptMinHadron", 0.2, "min pt value for hadrons"}; Configurable piPidLowPt{"piPidLowPt", 0.5, "max pt value for pipm pid without tof"}; Configurable piPidHighPt{"piPidHighPt", 2.5, "min pt value for pipm pid without tof in relativistic rise of Bethe-Bloch"}; Configurable> nSigmaPiTpcLowPt{"nSigmaPiTpcLowPt", {-2, 2}, "minimum-maximum nSigma for pipm in tpc at low pt"}; Configurable> nSigmaPiTpcMidPt{"nSigmaPiTpcMidPt", {-1, 1}, "minimum-maximum nSigma for pipm in tpc at mid pt"}; - Configurable> nSigmaPiTof{"nSigmaPiTof", {-1, 2}, "minimum-maximum nSigma for pipm in tof"}; + Configurable> nSigmaPiTof{"nSigmaPiTof", {-2, 1}, "minimum-maximum nSigma for pipm in tof"}; Configurable> nSigmaPiRelRise{"nSigmaPiRelRise", {0, 2}, "minimum-maximum nSigma pipm tpc at high pt"}; Configurable> pcmAbsDcaZLim{"pcmAbsDcaZLim", {0, 5}, "absolute values of dcaZ limits for pcm"}; Configurable oneTriggerPerEvent{"oneTriggerPerEvent", false, "use only one trigger (of highest pt) in an event"}; - // configurables from other tasks - - double absEtaMax = -1; - double ptTrigMin = -1; - // derivatives of configurables std::vector eventSelectionBits; @@ -151,7 +148,8 @@ struct HadronPhotonProducer { // functions ================================================================================================================================================================================ // get v0 leg tracks {posTrack, negTrack} as jet tracks via JTrackPI. throws in case of problems - auto getV0LegJetTracks(auto const& v0Photon, auto const& tracks) { + auto getV0LegJetTracks(auto const& v0Photon, auto const& tracks) + { auto const posTrack = tracks.rawIteratorAt(v0Photon.posTrack().trackId() - tracks.offset()); auto const negTrack = tracks.rawIteratorAt(v0Photon.negTrack().trackId() - tracks.offset()); // check index match @@ -189,7 +187,7 @@ struct HadronPhotonProducer { if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { return false; } - if (!jetderiveddatautilities::applyTrackKinematics(track, ptMinHadron, 1000, -1 * absEtaMax, absEtaMax)) { + if (!jetderiveddatautilities::applyTrackKinematics(track, ptMinTrack, 1000, -absEtaMax, absEtaMax)) { return false; } return true; @@ -255,7 +253,8 @@ struct HadronPhotonProducer { auto motherEnd = mothers.end(); while (mother != motherEnd) { // optional exclude pre-hadonisation - if (!includePreHadronisation && (*mother).producedByGenerator() && std::abs((*mother).getGenStatusCode()) < 80) { + int const statusPreHadronisationCut = 80; + if (!includePreHadronisation && (*mother).producedByGenerator() && std::abs((*mother).getGenStatusCode()) < statusPreHadronisationCut) { return std::nullopt; } if ((*mother).pdgCode() == pdgCode || (checkAntiParticle && (*mother).pdgCode() == -pdgCode)) { @@ -321,7 +320,8 @@ struct HadronPhotonProducer { // get highest reco truthLevel particle canidate template - TruthLevelInfo getMcRecoInfoHadronPipm(auto const& collision, auto const& track) { + TruthLevelInfo getMcRecoInfoHadronPipm(auto const& collision, auto const& track) + { if (!track.has_mcParticle()) { return {TruthLevel::Reco, -1}; } @@ -343,7 +343,8 @@ struct HadronPhotonProducer { double const ptTruePure = mcParticle.pt(); return {TruthLevel::RecoPure, ptTruePure}; } - std::tuple getMcRecoInfoPhoton(auto const& collision, auto const& v0Photon, auto const& tracks) { + std::tuple getMcRecoInfoPhoton(auto const& collision, auto const& v0Photon, auto const& tracks) + { TruthLevelInfo truthLevelInfo; PhotonImpurityInfo impurityInfo; @@ -385,7 +386,8 @@ struct HadronPhotonProducer { return {truthLevelInfo, impurityInfo}; } template - std::tuple getMcRecoInfoDiPhoton(auto const& collision, auto const& v0Photon1, auto const& v0Photon2, auto const& tracks) { + std::tuple getMcRecoInfoDiPhoton(auto const& collision, auto const& v0Photon1, auto const& v0Photon2, auto const& tracks) + { TruthLevelInfo truthLevelInfo; PhotonImpurityInfo impurityInfo; @@ -471,19 +473,23 @@ struct HadronPhotonProducer { // analysis ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void init(InitContext& initContext) + void init(InitContext const&) { // selection JE utilities eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); - // get variables from other tasks - if (!common::core::getTaskOptionValue(initContext, "hadron-photon-correlation", "absEtaMax", absEtaMax, false)) { - throw std::runtime_error("absEtaMax not set"); - }; - if (!common::core::getTaskOptionValue(initContext, "hadron-photon-correlation", "ptTrigMin", ptTrigMin, false)) { - throw std::runtime_error("ptTrigMin not set"); + // check config + if (static_cast(doprocessRecoCollisionTrigger) + static_cast(doprocessMcRecoCollisionTrigger) > 1) { + throw std::runtime_error("invalid doprocess-collisionTrigger config"); + } + if (static_cast(doprocessRecoHadronPipmTPCTOF) + static_cast(doprocessMcRecoHadronPipmTPCTOF) + + static_cast(doprocessRecoHadronPipmTPC) + static_cast(doprocessMcRecoHadronPipmTPC) > 1) { + throw std::runtime_error("invalid doprocess-hadronPipm config"); + } + if (static_cast(doprocessRecoPhotonPcm) + static_cast(doprocessMcRecoPhotonPcm) > 1) { + throw std::runtime_error("invalid doprocess-photonPcm config"); } // histograms @@ -579,11 +585,11 @@ struct HadronPhotonProducer { // collision info histos.fill(HIST("reco/h2_zPvMult"), collision.posZ(), nGlobalTracks); histos.fill(HIST("reco/h1_hadronicRate"), collision.hadronicRate()); - tableProduction.corrCollision(isSelectedEvent, thirdDecimalTruePosZ, isTriggerEvent, maxTrackPt, collision.posZ(), nGlobalTracks); - tableProduction.corrCollisionId(collision.globalIndex()); + tableProduction.collision(isSelectedEvent, thirdDecimalTruePosZ, isTriggerEvent, maxTrackPt, collision.posZ(), nGlobalTracks); + tableProduction.collisionId(collision.globalIndex()); // mc true collsion label if constexpr (IsCollisionMCD) { - tableProduction.corrCollisionMcId(collision.mcCollisionId()); + tableProduction.collisionMcId(collision.mcCollisionId()); } } } @@ -637,11 +643,13 @@ struct HadronPhotonProducer { }(); // hadron info - histos.fill(HIST("reco/h3_ptPhiEta_hadron"), track.pt(), track.phi(), track.eta()); - tableProduction.hadron(track.collisionId(), intersectTriggerIds, - track.pt(), track.phi(), track.eta(), - static_cast(truthLevelInfoHadron.truthLevel), truthLevelInfoHadron.ptTruePure); - tableProduction.hadronTrackId(track.globalIndex()); + if (track.pt() > ptMinHadron) { + histos.fill(HIST("reco/h3_ptPhiEta_hadron"), track.pt(), track.phi(), track.eta()); + tableProduction.hadron(track.collisionId(), intersectTriggerIds, + track.pt(), track.phi(), track.eta(), + static_cast(truthLevelInfoHadron.truthLevel), truthLevelInfoHadron.ptTruePure); + tableProduction.hadronTrackId(track.globalIndex()); + } // pipm selection auto const& trackPid = track.template track_as(); @@ -667,8 +675,8 @@ struct HadronPhotonProducer { // pipm info histos.fill(HIST("reco/h3_ptPhiEta_pipm"), track.pt(), track.phi(), track.eta()); tableProduction.pipm(track.collisionId(), intersectTriggerIds, - track.pt(), track.phi(), track.eta(), - static_cast(truthLevelInfoPipm.truthLevel), truthLevelInfoPipm.ptTruePure); + track.pt(), track.phi(), track.eta(), + static_cast(truthLevelInfoPipm.truthLevel), truthLevelInfoPipm.ptTruePure); tableProduction.pipmTrackId(track.globalIndex()); } } @@ -755,7 +763,7 @@ struct HadronPhotonProducer { v0Photon.pt(), v0Photon.phi(), v0Photon.eta(), static_cast(truthLevelInfoPhotonPcm.truthLevel), truthLevelInfoPhotonPcm.ptTruePure, static_cast(impurityInfoPhotonPcm.impurity), impurityInfoPhotonPcm.ptTrueOrigin); - tableProduction.photonPcmTrackId(v0Photon.posTrack().trackId(), v0Photon.negTrack().trackId()); + tableProduction.photonPcmTrackId(posTrack.globalIndex(), negTrack.globalIndex()); tableProduction.photonPcmV0PhotonId(v0Photon.globalIndex()); } @@ -769,6 +777,9 @@ struct HadronPhotonProducer { ROOT::Math::PtEtaPhiMVector const p4V0PcmPair = p4V0Pcm1 + p4V0Pcm2; // pair selection + if (std::abs(v0Photon1.eta()) > absEtaMax || std::abs(v0Photon2.eta()) > absEtaMax) { + continue; + } if (std::abs(p4V0PcmPair.Eta()) > absEtaMax) { continue; } @@ -818,7 +829,7 @@ struct HadronPhotonProducer { p4V0PcmPair.Pt(), RecoDecay::constrainAngle(p4V0PcmPair.Phi(), 0), p4V0PcmPair.Eta(), p4V0PcmPair.M(), static_cast(truthLevelInfoPi0Pcm.truthLevel), static_cast(truthLevelInfoEtaPcm.truthLevel), ptTruePurePhotonPcmPair, static_cast(photonImpurityInfoPi0Pcm.impurity), photonImpurityInfoPi0Pcm.ptTrueOrigin); - tableProduction.photonPcmPairTrackId(v0Photon1.posTrack().trackId(), v0Photon1.negTrack().trackId(), v0Photon2.posTrack().trackId(), v0Photon2.negTrack().trackId()); + tableProduction.photonPcmPairTrackId(posTrack1.globalIndex(), negTrack1.globalIndex(), posTrack2.globalIndex(), negTrack2.globalIndex()); tableProduction.photonPcmPairV0PhotonId(v0Photon1.globalIndex(), v0Photon2.globalIndex()); } } @@ -869,7 +880,7 @@ struct HadronPhotonProducer { if (!mcParticle.isPhysicalPrimary()) { continue; } - if (std::abs(mcParticle.eta()) > absEtaMax || mcParticle.pt() < ptMinHadron) { + if (std::abs(mcParticle.eta()) > absEtaMax || mcParticle.pt() < ptMinTrack) { continue; } From 1704c7ddc5990fccd346ebb38475e187dda1e52c Mon Sep 17 00:00:00 2001 From: jkinner2 Date: Thu, 19 Nov 2026 13:25:49 +0100 Subject: [PATCH 07/13] addEventFilter --- PWGJE/DataModel/HadronPhotonCorrelation.h | 25 +- PWGJE/Tasks/hadronPhotonCorrelation.cxx | 509 +++++++++------------- PWGJE/Tasks/hadronPhotonProducer.cxx | 26 +- 3 files changed, 238 insertions(+), 322 deletions(-) diff --git a/PWGJE/DataModel/HadronPhotonCorrelation.h b/PWGJE/DataModel/HadronPhotonCorrelation.h index 21b7cda2945..b42cecae505 100644 --- a/PWGJE/DataModel/HadronPhotonCorrelation.h +++ b/PWGJE/DataModel/HadronPhotonCorrelation.h @@ -24,7 +24,8 @@ #include -namespace hpc { +namespace hpc +{ enum class AssocType { Hadron, @@ -122,6 +123,7 @@ namespace hpc_common { DECLARE_SOA_INDEX_COLUMN_FULL(JetMcCollision, jetMcCollision, int, JMcCollisions, ""); DECLARE_SOA_COLUMN(SelEv, selEv, bool); +DECLARE_SOA_COLUMN(NSelectSplitMcEv, nSelectSplitMcEv, int); DECLARE_SOA_COLUMN(Pt, pt, float); DECLARE_SOA_COLUMN(PtTruePure, ptTruePure, float); DECLARE_SOA_COLUMN(PtTrueOrigin, ptTrueOrigin, float); // and the blind forest @@ -136,7 +138,6 @@ namespace hpc_collision { // plain jet collision column for derived data DECLARE_SOA_COLUMN(JetCollisionId, jetCollisionId, int); -DECLARE_SOA_COLUMN(ThirdDecimalTruePosZ, thirdDecimalTruePosZ, int); DECLARE_SOA_COLUMN(TrigEv, trigEv, bool); DECLARE_SOA_COLUMN(PtMax, ptMax, float); DECLARE_SOA_COLUMN(PosZ, posZ, float); @@ -144,7 +145,7 @@ DECLARE_SOA_COLUMN(NGlobalTracks, nGlobalTracks, int); } // namespace hpc_collision DECLARE_SOA_TABLE(HpcCollisions, "AOD", "HPCCOL", o2::soa::Index<>, - hpc_common::SelEv, hpc_collision::ThirdDecimalTruePosZ, hpc_collision::TrigEv, hpc_collision::PtMax, hpc_collision::PosZ, hpc_collision::NGlobalTracks); + hpc_common::SelEv, hpc_common::NSelectSplitMcEv, hpc_collision::TrigEv, hpc_collision::PtMax, hpc_collision::PosZ, hpc_collision::NGlobalTracks); DECLARE_SOA_TABLE(HpcCollisionIds, "AOD", "HPCCOLID", hpc_collision::JetCollisionId); DECLARE_SOA_TABLE(HpcCollisionMcIds, "AOD", "HPCCOLMCID", @@ -242,18 +243,32 @@ DECLARE_SOA_TABLE(HpcPhotonPcmPairTrackIds, "AOD", "HPCPCMPAIRTRID", DECLARE_SOA_TABLE(HpcPhotonPcmPairV0PhotonIds, "AOD", "HPCPCMPAIRV0ID", hpc_photon_pcm_pair::V0PhotonKF1Id, hpc_photon_pcm_pair::V0PhotonKF2Id); +// photon selection +namespace hpc_photon_pcm +{ +DECLARE_SOA_COLUMN(SelPhotonPcm, selPhotonPcm, bool); +} // namespace hpc_photon_pcm +DECLARE_SOA_TABLE(HpcPhotonPcmSels, "AOD", "HPCPHPCMSEL", + hpc_photon_pcm::SelPhotonPcm); +namespace hpc_photon_pcm_pair +{ +DECLARE_SOA_COLUMN(SelPhotons, selPhotons, bool); +DECLARE_SOA_COLUMN(EnergyAsym, energyAsym, float); +} // namespace hpc_photon_pcm_pair +DECLARE_SOA_TABLE(HpcPhotonPcmPairSels, "AOD", "HPCPCMPAIRSEL", + hpc_photon_pcm_pair::SelPhotons, hpc_photon_pcm_pair::EnergyAsym); + // mc // mcCollision extension namespace hpc_mc_collision_extra { -DECLARE_SOA_COLUMN(ThirdDecimalTruePosZ, thirdDecimalTruePosZ, int); DECLARE_SOA_COLUMN(TrigEv, trigEv, bool); DECLARE_SOA_COLUMN(PtMax, ptMax, float); DECLARE_SOA_COLUMN(NChargedInEtaRange, nChargedInEtaRange, int); } // namespace hpc_mc_collision_extra DECLARE_SOA_TABLE(HpcMcCollisionsExtra, "AOD", "HPCMCCOLEXTRA", - hpc_common::SelEv, hpc_mc_collision_extra::ThirdDecimalTruePosZ, hpc_mc_collision_extra::TrigEv, hpc_mc_collision_extra::PtMax, hpc_mc_collision_extra::NChargedInEtaRange); + hpc_common::SelEv, hpc_common::NSelectSplitMcEv, hpc_mc_collision_extra::TrigEv, hpc_mc_collision_extra::PtMax, hpc_mc_collision_extra::NChargedInEtaRange); // trigger namespace hpc_true_trigger diff --git a/PWGJE/Tasks/hadronPhotonCorrelation.cxx b/PWGJE/Tasks/hadronPhotonCorrelation.cxx index 879bce0380c..b7c83dec2d2 100644 --- a/PWGJE/Tasks/hadronPhotonCorrelation.cxx +++ b/PWGJE/Tasks/hadronPhotonCorrelation.cxx @@ -68,8 +68,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -79,15 +79,123 @@ using namespace o2; using namespace o2::framework; using namespace hpc; -using HpcCollisions = aod::HpcCollisions; using HpcCollisionsMcD = soa::Join; -using CorrMcCollisions = soa::Join; +using HpcMcCollisions = soa::Join; -using PhotonPcmsWithV0 = soa::Join; -using PhotonPcmPairsWithV0 = soa::Join; +using PhotonPcmsWithV0 = soa::Join; +using PhotonPcmPairsWithV0 = soa::Join; using BinningZPvMult = ColumnBinningPolicy; +// photon cut selection /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// =/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/ + +struct HadronPhotonPcmSelection { + Produces photonPcmSel; + Produces photonPcmPairSel; + + // pcm cuts + struct : o2::framework::ConfigurableGroup { + std::string prefix = "pcmcut_group"; + o2::framework::Configurable cfgRequireV0WithItstpc{"cfgRequireV0WithItstpc", false, "flag to select V0s with ITS-TPC matched tracks"}; + o2::framework::Configurable cfgRequireV0WithItsonly{"cfgRequireV0WithItsonly", false, "flag to select V0s with ITSonly tracks"}; + o2::framework::Configurable cfgRequireV0WithTpconly{"cfgRequireV0WithTpconly", false, "flag to select V0s with TPConly tracks"}; + o2::framework::Configurable cfgMinPtV0{"cfgMinPtV0", 0.1, "min pt for v0 photons at PV"}; + o2::framework::Configurable cfgMaxPtV0{"cfgMaxPtV0", 1e+10, "max pt for v0 photons at PV"}; + o2::framework::Configurable cfgMinEtaV0{"cfgMinEtaV0", -1e+10, "min eta for v0 photons at PV"}; + o2::framework::Configurable cfgMaxEtaV0{"cfgMaxEtaV0", 1e+10, "max eta for v0 photons at PV"}; + o2::framework::Configurable cfgMinV0radius{"cfgMinV0radius", 4.0, "min v0 radius"}; + o2::framework::Configurable cfgMaxV0radius{"cfgMaxV0radius", 90.0, "max v0 radius"}; + o2::framework::Configurable cfgMidLV0radius{"cfgMidLV0radius", -1.0, "middle low v0 radius for rejection if >0"}; + o2::framework::Configurable cfgMidHV0radius{"cfgMidHV0radius", -1.0, "middle high v0 radius for rejection if >0"}; + o2::framework::Configurable cfgMaxAlphaAp{"cfgMaxAlphaAp", 0.95, "max alpha for AP cut"}; + o2::framework::Configurable cfgMaxQtAp{"cfgMaxQtAp", 0.01, "max qT for AP cut"}; + o2::framework::Configurable cfgMinCospa{"cfgMinCospa", 0.999, "min V0 CosPA"}; + o2::framework::Configurable cfgMaxPca{"cfgMaxPca", 1.5, "max distance btween 2 legs"}; + o2::framework::Configurable cfgMaxChi2kf{"cfgMaxChi2kf", 1e+10, "max chi2/ndf with KF"}; + o2::framework::Configurable cfgRejectV0OnItsib{"cfgRejectV0OnItsib", true, "flag to reject V0s on ITSib"}; + + o2::framework::Configurable cfgMinNclusterTpc{"cfgMinNclusterTpc", 0, "min ncluster tpc"}; + o2::framework::Configurable cfgMinNcrossedrows{"cfgMinNcrossedrows", 40, "min ncrossed rows"}; + o2::framework::Configurable cfgMaxFracSharedClustersTpc{"cfgMaxFracSharedClustersTpc", 999.f, "max fraction of shared clusters in TPC"}; + o2::framework::Configurable cfgMaxChi2tpc{"cfgMaxChi2tpc", 4.0, "max chi2/NclsTPC"}; + o2::framework::Configurable cfgMaxChi2its{"cfgMaxChi2its", 36.0, "max chi2/NclsITS"}; + o2::framework::Configurable cfgMinTPCNsigmaEl{"cfgMinTPCNsigmaEl", -3.0, "min. TPC n sigma for electron"}; + o2::framework::Configurable cfgMaxTPCNsigmaEl{"cfgMaxTPCNsigmaEl", +3.0, "max. TPC n sigma for electron"}; + o2::framework::Configurable cfgDisableItsonlyTrack{"cfgDisableItsonlyTrack", false, "flag to disable ITSonly tracks"}; + o2::framework::Configurable cfgDisableTpconlyTrack{"cfgDisableTpconlyTrack", false, "flag to disable TPConly tracks"}; + } configPcmCuts; + + // pcm cut class + V0PhotonCut fV0PhotonCut; + + void initV0PhotonCut() + { + fV0PhotonCut = V0PhotonCut("fV0PhotonCut", "fV0PhotonCut"); + + // for v0 + fV0PhotonCut.SetV0PtRange(configPcmCuts.cfgMinPtV0, configPcmCuts.cfgMaxPtV0); + fV0PhotonCut.SetV0EtaRange(configPcmCuts.cfgMinEtaV0, configPcmCuts.cfgMaxEtaV0); + fV0PhotonCut.SetMinCosPA(configPcmCuts.cfgMinCospa); + fV0PhotonCut.SetMaxPCA(configPcmCuts.cfgMaxPca); + fV0PhotonCut.SetMaxChi2KF(configPcmCuts.cfgMaxChi2kf); + fV0PhotonCut.SetRxyRange(configPcmCuts.cfgMinV0radius, configPcmCuts.cfgMaxV0radius, configPcmCuts.cfgMidLV0radius, configPcmCuts.cfgMidHV0radius); + fV0PhotonCut.SetAPRange(configPcmCuts.cfgMaxAlphaAp, configPcmCuts.cfgMaxQtAp); + fV0PhotonCut.RejectITSib(configPcmCuts.cfgRejectV0OnItsib); + + // for leg + fV0PhotonCut.SetMinNClustersTPC(configPcmCuts.cfgMinNclusterTpc); + fV0PhotonCut.SetMinNCrossedRowsTPC(configPcmCuts.cfgMinNcrossedrows); + fV0PhotonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + fV0PhotonCut.SetMaxFracSharedClustersTPC(configPcmCuts.cfgMaxFracSharedClustersTpc); + fV0PhotonCut.SetChi2PerClusterTPC(0.0, configPcmCuts.cfgMaxChi2tpc); + fV0PhotonCut.SetTPCNsigmaElRange(configPcmCuts.cfgMinTPCNsigmaEl, configPcmCuts.cfgMaxTPCNsigmaEl); + fV0PhotonCut.SetChi2PerClusterITS(-1e+10, configPcmCuts.cfgMaxChi2its); + fV0PhotonCut.SetNClustersITS(0, 7); + fV0PhotonCut.SetMeanClusterSizeITSob(0.0, 16.0); + fV0PhotonCut.SetDisableITSonly(configPcmCuts.cfgDisableItsonlyTrack); + fV0PhotonCut.SetDisableTPConly(configPcmCuts.cfgDisableTpconlyTrack); + fV0PhotonCut.SetRequireITSTPC(configPcmCuts.cfgRequireV0WithItstpc); + fV0PhotonCut.SetRequireITSonly(configPcmCuts.cfgRequireV0WithItsonly); + fV0PhotonCut.SetRequireTPConly(configPcmCuts.cfgRequireV0WithTpconly); + } + + // add pmeventId() due to unguarded call in V0PhotonCut.h qa; selection unaffected + template + struct V0PhotonNoEvent : T_V0PhotonType { + explicit V0PhotonNoEvent(T_V0PhotonType const& v0PhotonType) : T_V0PhotonType(v0PhotonType) {} + [[nodiscard]] int pmeventId() const { return -1; } + }; + bool isSelectedV0Photon(auto const& v0Photon) + { + using V0PhotonType = std::decay_t; + return fV0PhotonCut.template IsSelected, aod::V0Legs>(V0PhotonNoEvent{v0Photon}); + } + + void init(InitContext&) + { + initV0PhotonCut(); + } + + void processSelection(aod::HpcPhotonPcmV0PhotonIds const& photonPcms, aod::HpcPhotonPcmPairV0PhotonIds const& photonPcmPairs, + aod::V0PhotonsKF const&, aod::V0Legs const&) + { + // joinable tables + for (auto const& photonPcm : photonPcms) { + photonPcmSel(isSelectedV0Photon(photonPcm.v0PhotonKF())); + } + for (auto const& pair : photonPcmPairs) { + auto const v0Photon1 = pair.v0PhotonKF1(); + auto const v0Photon2 = pair.v0PhotonKF2(); + double const e1 = v0Photon1.pt() * std::cosh(v0Photon1.eta()); + double const e2 = v0Photon2.pt() * std::cosh(v0Photon2.eta()); + double const energyAsym = std::abs((e1 - e2) / (e1 + e2)); + photonPcmPairSel(isSelectedV0Photon(v0Photon1) && isSelectedV0Photon(v0Photon2), energyAsym); + } + } + PROCESS_SWITCH(HadronPhotonPcmSelection, processSelection, "process photonPcm selection", false); +}; + // correlation analysis /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // =/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/ @@ -108,8 +216,7 @@ struct HadronPhotonCorrelation { Configurable ptTrigMin{"ptTrigMin", 5, "minimum pt of triggers"}; // analysis settings - Configurable splitMcEvN{"splitMcEvN", 1, "number of event fractions for selection in MC (max 10) | (select 1 for data)"}; - Configurable splitMcEvSelect{"splitMcEvSelect", 1, "selected event fraction number in MC (starts at 1) | (select 1 for data)"}; + Configurable nSelectSplitMcEv{"nSelectSplitMcEv", 1, "selected event fraction number in MC (starts at 1) | (select 1 for data)"}; // mc scaling to data // caution: applied to true-level very broadly, full mc-true possibly inconsistent (e.g. gammaDir scaled as well), only use for correcting @@ -150,41 +257,9 @@ struct HadronPhotonCorrelation { Configurable> etaPcmLowSideMassRange{"etaPcmLowSideMassRange", {0.44, 0.48}, "photon-pair mass integration range below etaPcm region"}; Configurable> etaPcmHighSideMassRange{"etaPcmHighSideMassRange", {0.58, 0.62}, "photon-pair mass integration range above etaPcm region"}; - Configurable energyAsymmPhotonPairMax{"energyAsymmPhotonPairMax", 1.0, "maximum energy asymmetry ((E1 - E2) / (E1 + E2)) of photon pairs"}; + Configurable energyAsymmPhotonPairMax{"energyAsymmPhotonPairMax", 1.0, "maximum energy asymmetry ((E1 - E2) / (E1 + E2)) of photon pairs"}; } config; - // pcm cuts - struct : o2::framework::ConfigurableGroup { - std::string prefix = "pcmcut_group"; - o2::framework::Configurable cfgRequireV0WithItstpc{"cfgRequireV0WithItstpc", false, "flag to select V0s with ITS-TPC matched tracks"}; - o2::framework::Configurable cfgRequireV0WithItsonly{"cfgRequireV0WithItsonly", false, "flag to select V0s with ITSonly tracks"}; - o2::framework::Configurable cfgRequireV0WithTpconly{"cfgRequireV0WithTpconly", false, "flag to select V0s with TPConly tracks"}; - o2::framework::Configurable cfgMinPtV0{"cfgMinPtV0", 0.1, "min pt for v0 photons at PV"}; - o2::framework::Configurable cfgMaxPtV0{"cfgMaxPtV0", 1e+10, "max pt for v0 photons at PV"}; - o2::framework::Configurable cfgMinEtaV0{"cfgMinEtaV0", -1e+10, "min eta for v0 photons at PV"}; - o2::framework::Configurable cfgMaxEtaV0{"cfgMaxEtaV0", 1e+10, "max eta for v0 photons at PV"}; - o2::framework::Configurable cfgMinV0radius{"cfgMinV0radius", 4.0, "min v0 radius"}; - o2::framework::Configurable cfgMaxV0radius{"cfgMaxV0radius", 90.0, "max v0 radius"}; - o2::framework::Configurable cfgMidLV0radius{"cfgMidLV0radius", -1.0, "middle low v0 radius for rejection if >0"}; - o2::framework::Configurable cfgMidHV0radius{"cfgMidHV0radius", -1.0, "middle high v0 radius for rejection if >0"}; - o2::framework::Configurable cfgMaxAlphaAp{"cfgMaxAlphaAp", 0.95, "max alpha for AP cut"}; - o2::framework::Configurable cfgMaxQtAp{"cfgMaxQtAp", 0.01, "max qT for AP cut"}; - o2::framework::Configurable cfgMinCospa{"cfgMinCospa", 0.999, "min V0 CosPA"}; - o2::framework::Configurable cfgMaxPca{"cfgMaxPca", 1.5, "max distance btween 2 legs"}; - o2::framework::Configurable cfgMaxChi2kf{"cfgMaxChi2kf", 1e+10, "max chi2/ndf with KF"}; - o2::framework::Configurable cfgRejectV0OnItsib{"cfgRejectV0OnItsib", true, "flag to reject V0s on ITSib"}; - - o2::framework::Configurable cfgMinNclusterTpc{"cfgMinNclusterTpc", 0, "min ncluster tpc"}; - o2::framework::Configurable cfgMinNcrossedrows{"cfgMinNcrossedrows", 40, "min ncrossed rows"}; - o2::framework::Configurable cfgMaxFracSharedClustersTpc{"cfgMaxFracSharedClustersTpc", 999.f, "max fraction of shared clusters in TPC"}; - o2::framework::Configurable cfgMaxChi2tpc{"cfgMaxChi2tpc", 4.0, "max chi2/NclsTPC"}; - o2::framework::Configurable cfgMaxChi2its{"cfgMaxChi2its", 36.0, "max chi2/NclsITS"}; - o2::framework::Configurable cfgMinTPCNsigmaEl{"cfgMinTPCNsigmaEl", -3.0, "min. TPC n sigma for electron"}; - o2::framework::Configurable cfgMaxTPCNsigmaEl{"cfgMaxTPCNsigmaEl", +3.0, "max. TPC n sigma for electron"}; - o2::framework::Configurable cfgDisableItsonlyTrack{"cfgDisableItsonlyTrack", false, "flag to disable ITSonly tracks"}; - o2::framework::Configurable cfgDisableTpconlyTrack{"cfgDisableTpconlyTrack", false, "flag to disable TPConly tracks"}; - } configPcmCuts; - // histogram config struct : ConfigurableGroup { Configurable nBinsZPvPlain{"nBinsZPvPlain", 28, "number zPv bins in histos"}; @@ -285,13 +360,13 @@ struct HadronPhotonCorrelation { // return std::uniform_int_distribution(lowEdgeInclusive, upEdgeInclusive)(randomMt); } - // objects to hold histograms - HistogramRegistry histos{"histogramRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + // O2 varables ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - // ccdb calls - Service ccdb{}; - // for mc - Service pdg{}; + // filters + expressions::Filter filterEvTotal = aod::hpc_common::selEv == true && aod::hpc_common::nSelectSplitMcEv == config.nSelectSplitMcEv; + expressions::Filter filterPhotonPcm = aod::hpc_photon_pcm::selPhotonPcm == true; + expressions::Filter filterPhotonPcmPair = aod::hpc_photon_pcm_pair::selPhotons == true && + aod::hpc_photon_pcm_pair::energyAsym < expressions::as(config.energyAsymmPhotonPairMax); // partitions SliceCache cache; @@ -306,7 +381,15 @@ struct HadronPhotonCorrelation { Preslice perColMcParticles = aod::jmcparticle::mcCollisionId; Preslice perColTrueTriggers = aod::hpc_common::jetMcCollisionId; - // declare analysis variables + // ccdb calls + Service ccdb{}; + // for mc info + Service pdg{}; + + // objects to hold histograms + HistogramRegistry histos{"histogramRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + + // declare analysis variables --------------------------------------------------------------------------------------------------------------------------------------------------------------- // correction histograms TH1D* h1PtCorrectionTrigger = nullptr; @@ -443,9 +526,6 @@ struct HadronPhotonCorrelation { std::unique_ptr triggerMemoryTrueRecoEv; std::unique_ptr triggerMemoryTrueRecoEvRecoPtTrig; - // pcm cut class - V0PhotonCut fV0PhotonCut; - // functions //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ========================================================================================================================================================================================== @@ -477,7 +557,6 @@ struct HadronPhotonCorrelation { if (config.applyTriggerPtCorrection.value) { h1PtCorrectionTrigger = ccdb->getForTimeStamp(config.pathCcdbAnalysis.value + "/correction/trigger", noLaterThanCcdb); - const double* bins = h1PtCorrectionTrigger->GetXaxis()->GetXbins()->GetArray(); const AxisSpec axis{getBinEdges(h1PtCorrectionTrigger), "#it{p}_{T}"}; histos.add("usedObjectsCcdb/h1_pt_correction_trigger_ccdb", "h1_pt_correction_trigger_ccdb", kTH1D, {axis}, true); for (int iBin = 0; iBin <= h1PtCorrectionTrigger->GetNbinsX() + 1; iBin++) { @@ -489,7 +568,6 @@ struct HadronPhotonCorrelation { if (config.applyScalingK0ShortPt.value) { h1PtScalingK0Short = ccdb->getForTimeStamp(config.pathCcdbAnalysis.value + "/scaling/K0Short", noLaterThanCcdb); - const double* bins = h1PtScalingK0Short->GetXaxis()->GetXbins()->GetArray(); const AxisSpec axis{getBinEdges(h1PtScalingK0Short), "#it{p}_{T}"}; histos.add("usedObjectsCcdb/h1_pt_scaling_K0Short_ccdb", "h1_pt_scaling_K0Short_ccdb", kTH1D, {axis}, true); for (int iBin = 0; iBin <= h1PtScalingK0Short->GetNbinsX() + 1; iBin++) { @@ -748,54 +826,9 @@ struct HadronPhotonCorrelation { kTHnSparseD, {axisPtTrig, axisPtAssoc, axisDcaZ, axisZPvBinning, axisMultBinning}, true); } - // init pcm cut class - void initV0PhotonCut() - { - fV0PhotonCut = V0PhotonCut("fV0PhotonCut", "fV0PhotonCut"); - - // for v0 - fV0PhotonCut.SetV0PtRange(configPcmCuts.cfgMinPtV0, configPcmCuts.cfgMaxPtV0); - fV0PhotonCut.SetV0EtaRange(configPcmCuts.cfgMinEtaV0, configPcmCuts.cfgMaxEtaV0); - fV0PhotonCut.SetMinCosPA(configPcmCuts.cfgMinCospa); - fV0PhotonCut.SetMaxPCA(configPcmCuts.cfgMaxPca); - fV0PhotonCut.SetMaxChi2KF(configPcmCuts.cfgMaxChi2kf); - fV0PhotonCut.SetRxyRange(configPcmCuts.cfgMinV0radius, configPcmCuts.cfgMaxV0radius, configPcmCuts.cfgMidLV0radius, configPcmCuts.cfgMidHV0radius); - fV0PhotonCut.SetAPRange(configPcmCuts.cfgMaxAlphaAp, configPcmCuts.cfgMaxQtAp); - fV0PhotonCut.RejectITSib(configPcmCuts.cfgRejectV0OnItsib); - - // for leg - fV0PhotonCut.SetMinNClustersTPC(configPcmCuts.cfgMinNclusterTpc); - fV0PhotonCut.SetMinNCrossedRowsTPC(configPcmCuts.cfgMinNcrossedrows); - fV0PhotonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); - fV0PhotonCut.SetMaxFracSharedClustersTPC(configPcmCuts.cfgMaxFracSharedClustersTpc); - fV0PhotonCut.SetChi2PerClusterTPC(0.0, configPcmCuts.cfgMaxChi2tpc); - fV0PhotonCut.SetTPCNsigmaElRange(configPcmCuts.cfgMinTPCNsigmaEl, configPcmCuts.cfgMaxTPCNsigmaEl); - fV0PhotonCut.SetChi2PerClusterITS(-1e+10, configPcmCuts.cfgMaxChi2its); - fV0PhotonCut.SetNClustersITS(0, 7); - fV0PhotonCut.SetMeanClusterSizeITSob(0.0, 16.0); - fV0PhotonCut.SetDisableITSonly(configPcmCuts.cfgDisableItsonlyTrack); - fV0PhotonCut.SetDisableTPConly(configPcmCuts.cfgDisableTpconlyTrack); - fV0PhotonCut.SetRequireITSTPC(configPcmCuts.cfgRequireV0WithItstpc); - fV0PhotonCut.SetRequireITSonly(configPcmCuts.cfgRequireV0WithItsonly); - fV0PhotonCut.SetRequireTPConly(configPcmCuts.cfgRequireV0WithTpconly); - } - // selections /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - // mc split event selection based in the thrid decimal of mc-true posZ - bool checkSplitMcEventSelection(auto const& collision) - { - // select based on configurables - return collision.thirdDecimalTruePosZ() % config.splitMcEvN.value == config.splitMcEvSelect.value - 1; - } - - // total event selection (basic selections from producer and analysis level selections) - bool totalEvSel(auto const& collision) - { - return collision.selEv() && checkSplitMcEventSelection(collision); - } - // checks if mcParticle is charged bool isCharged(auto const& mcParticle) { @@ -1049,49 +1082,6 @@ struct HadronPhotonCorrelation { return energyAsym < config.energyAsymmPhotonPairMax.value; } - // add pmeventId() due to unguarded call in V0PhotonCut.h qa; selection unaffected - template - struct V0PhotonNoEvent : T_V0PhotonType { - explicit V0PhotonNoEvent(T_V0PhotonType const& v0PhotonType) : T_V0PhotonType(v0PhotonType) {} - [[nodiscard]] int pmeventId() const { return -1; } - }; - bool isSelectedV0Photon(auto const& v0Photon) - { - using V0PhotonType = std::decay_t; - return fV0PhotonCut.template IsSelected, aod::V0Legs>(V0PhotonNoEvent{v0Photon}); - } - - bool isSelectedPhotonPcm(auto const& photonPcm) - { - return isSelectedV0Photon(photonPcm.v0PhotonKF()); - } - bool isSelectedPhotonPcmPair(auto const& photonPcmPair) - { - if (!isSelectedV0Photon(photonPcmPair.v0PhotonKF1()) || !isSelectedV0Photon(photonPcmPair.v0PhotonKF2())) { - return false; - } - if (!checkEnergyAsymDiPhoton(photonPcmPair.v0PhotonKF1(), photonPcmPair.v0PhotonKF2())) { - return false; - } - return true; - } - - template - bool isSelectedAssoc(auto const& associated) - { - if constexpr (AssocTypeV == AssocType::Hadron) { - return true; - } else if constexpr (AssocTypeV == AssocType::Pipm) { - return true; - } else if constexpr (AssocTypeV == AssocType::PhotonPcm) { - return isSelectedPhotonPcm(associated); - } else if constexpr (AssocTypeV == AssocType::PhotonPcmPair) { - return isSelectedPhotonPcmPair(associated); - } else { - static_assert(AlwaysFalseValue, "assocType not found"); - } - } - // analysis helpers ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -1364,6 +1354,8 @@ struct HadronPhotonCorrelation { double const doublePrecisionDeltaCheck = 1e-5; double absEtaMaxProducer; double ptTrigMinProducer; + float cfgMinEtaV0Selection; + float cfgMaxEtaV0Selection; // analysis info int64_t const noLaterThanCcdb = @@ -1387,6 +1379,13 @@ struct HadronPhotonCorrelation { } } + if (common::core::getTaskOptionValue(initContext, "hadron-photon-pcm-selection", "pcmcut_group.cfgMinEtaV0", cfgMinEtaV0Selection, false) || + common::core::getTaskOptionValue(initContext, "hadron-photon-pcm-selection", "pcmcut_group.cfgMaxEtaV0", cfgMaxEtaV0Selection, false)) { + if (config.absEtaMax.value > std::abs(cfgMinEtaV0Selection) || config.absEtaMax.value > std::abs(cfgMaxEtaV0Selection)) { + throw std::runtime_error("absEtaMax does not constrain v0 cut"); + } + }; + // check coherent config if (std::abs(config.ptTrigMin.value - configHist.binsPtTrig.value.at(0)) > doublePrecisionDeltaCheck) { throw std::runtime_error("ptTrigMin does not match trigger axis"); @@ -1396,10 +1395,6 @@ struct HadronPhotonCorrelation { throw std::runtime_error("absEtaMax does not match binsDEta axis"); } - if (config.absEtaMax.value > std::abs(configPcmCuts.cfgMinEtaV0) || config.absEtaMax.value > std::abs(configPcmCuts.cfgMaxEtaV0)) { - throw std::runtime_error("absEtaMax does not constrain v0 cut"); - } - int const nParTcm = 6; if (config.applyScalingPhotonPt.value && (config.parScalingPhotonPtData.value.size() != nParTcm || config.parScalingPhotonPtMc.value.size() != nParTcm)) { throw std::runtime_error("wrong number of mc scaling params for photon"); @@ -1423,12 +1418,9 @@ struct HadronPhotonCorrelation { triggerMemoryTrue = std::make_unique(configHist.binsZPvBinningMcTrue.value, configHist.binsMultBinningMcTrue.value, config.nTriggerSavedForMixing.value); triggerMemoryTrueRecoEv = std::make_unique(configHist.binsZPvBinningMcTrue.value, configHist.binsMultBinningMcTrue.value, - config.nTriggerSavedForMixing.value); + config.nTriggerSavedForMixing.value); triggerMemoryTrueRecoEvRecoPtTrig = std::make_unique(configHist.binsZPvBinningMcTrue.value, configHist.binsMultBinningMcTrue.value, - config.nTriggerSavedForMixing.value); - - // init EM pcm cut class - initV0PhotonCut(); + config.nTriggerSavedForMixing.value); } // reco only //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1443,11 +1435,6 @@ struct HadronPhotonCorrelation { void fillProcessRecoStd(auto const& collisions, auto const& triggers, auto const& assocs) { for (auto const& collision : collisions) { - // event selection - if (!totalEvSel(collision)) { - continue; - } - // group collision ++ auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); auto const [assocsThisEvent, nMixingAt0] = [&]() { @@ -1463,11 +1450,6 @@ struct HadronPhotonCorrelation { }(); auto const funcPlain = [this](auto const& collision, auto const& associated) { - // reco assoc selection - if (!isSelectedAssoc(associated)) { - return; - } - HistFillInfoPlainPhiEtaZPvMult histFillInfo = {collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), collision.posZ(), static_cast(collision.nGlobalTracks())}; histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated); @@ -1476,10 +1458,6 @@ struct HadronPhotonCorrelation { corrProcessPlain(collision, assocsThisEvent, funcPlain); auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { - // reco assoc selection - if (!isSelectedAssoc(associated)) { - return; - } // exclude self correlation if (isRecoSelfTrigger(trigger, associated)) { return; @@ -1498,10 +1476,6 @@ struct HadronPhotonCorrelation { continue; } - auto const conditionMixAssocOnly = [this](auto const& associated) { - // reco assoc selection - return isSelectedAssoc(associated); - }; auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; @@ -1510,23 +1484,23 @@ struct HadronPhotonCorrelation { getTriggerPtCorrection(mixingTrigger.pt()); fillHistMain(histFillInfo); }; - corrProcessMixing(collision, assocsThisEvent, funcMixing, nMixingAt0, conditionMixAssocOnly); + corrProcessMixing(collision, assocsThisEvent, funcMixing, nMixingAt0); } } - void processRecoHadron(HpcCollisions const& collisions, aod::HpcTriggers const& triggers, aod::HpcHadrons const& hadrons) + void processRecoHadron(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, aod::HpcHadrons const& hadrons) { fillProcessRecoStd(collisions, triggers, hadrons); } PROCESS_SWITCH(HadronPhotonCorrelation, processRecoHadron, "process standard for associated hardon", false); - void processRecoPipm(HpcCollisions const& collisions, aod::HpcTriggers const& triggers, aod::HpcPipms const& pipms) + void processRecoPipm(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, aod::HpcPipms const& pipms) { fillProcessRecoStd(collisions, triggers, pipms); } PROCESS_SWITCH(HadronPhotonCorrelation, processRecoPipm, "process standard for associated pipm", false); - void processRecoPhotonPcm(HpcCollisions const& collisions, aod::HpcTriggers const& triggers, PhotonPcmsWithV0 const& photonPcms, + void processRecoPhotonPcm(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, soa::Filtered const& photonPcms, aod::V0PhotonsKF const&, aod::V0Legs const&) { fillProcessRecoStd(collisions, triggers, photonPcms); @@ -1558,25 +1532,15 @@ struct HadronPhotonCorrelation { } } - void processRecoPhotonPcmPair(HpcCollisions const& collisions, aod::HpcTriggers const& triggers, PhotonPcmPairsWithV0 const& photonPcmPairs, + void processRecoPhotonPcmPair(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, soa::Filtered const& photonPcmPairs, aod::V0PhotonsKF const&, aod::V0Legs const&) { for (auto const& collision : collisions) { - // event selection - if (!totalEvSel(collision)) { - continue; - } - // group collision auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); auto const photonPcmPairsThisEvent = photonPcmPairs.sliceBy(perColPhotonPcmPairs, collision.globalIndex()); auto const funcPlain = [this](auto const& collision, auto const& associated) { - // reco assoc selection - if (!isSelectedAssoc(associated)) { - return; - } - double const weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated); // mgg distribution @@ -1591,10 +1555,6 @@ struct HadronPhotonCorrelation { corrProcessPlain(collision, photonPcmPairsThisEvent, funcPlain); auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { - // reco assoc selection - if (!isSelectedAssoc(associated)) { - return; - } // exclude self correlation if (isRecoSelfTrigger(trigger, associated)) { return; @@ -1620,10 +1580,6 @@ struct HadronPhotonCorrelation { continue; } - auto const conditionMixAssocOnly = [this](auto const& associated) { - // reco assoc selection - return isSelectedAssoc(associated); - }; auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; @@ -1632,25 +1588,22 @@ struct HadronPhotonCorrelation { getTriggerPtCorrection(mixingTrigger.pt()); fillAssocsRecoPhotonPcmPair(histFillInfo, associated.mgg()); }; - corrProcessMixing(collision, photonPcmPairsThisEvent, funcMixing, config.nMixingAt0PhotonPcmPair.value, conditionMixAssocOnly); + corrProcessMixing(collision, photonPcmPairsThisEvent, funcMixing, config.nMixingAt0PhotonPcmPair.value); } } PROCESS_SWITCH(HadronPhotonCorrelation, processRecoPhotonPcmPair, "process standard for associated photonPcmPair", false); - void processPhotonPcmPairMix(HpcCollisions const& collisions, PhotonPcmsWithV0 const& photonPcms, + void processPhotonPcmPairMix(soa::Filtered const& collisions, soa::Filtered const& photonPcms, aod::V0PhotonsKF const&, aod::V0Legs const&) { BinningZPvMult const binningZPvMult{{prependVariableWidth(configHist.binsZPvBinning.value), prependVariableWidth(configHist.binsMultBinning.value)}, true}; auto photonPcmsTuple = std::make_tuple(photonPcms); - SameKindPair pairs{binningZPvMult, config.nNeighboursMixingPhotonPcmPair.value, -1, collisions, photonPcmsTuple, &cache}; + SameKindPair, soa::Filtered, BinningZPvMult> pairs{binningZPvMult, config.nNeighboursMixingPhotonPcmPair.value, -1, + collisions, photonPcmsTuple, &cache}; // mixed events for (auto pair = pairs.begin(); pair != pairs.end(); pair++) { auto const& [collision1, photonPcms1, collision2, photonPcms2] = *pair; - // event selection - if (!totalEvSel(collision1) || !totalEvSel(collision2)) { - continue; - } // mixing loop for (auto const& [photonPcm1, photonPcm2] : soa::combinations(soa::CombinationsFullIndexPolicy(photonPcms1, photonPcms2))) { ROOT::Math::PtEtaPhiMVector const p4photonPcm1(photonPcm1.pt(), photonPcm1.eta(), photonPcm1.phi(), 0.); @@ -1661,9 +1614,6 @@ struct HadronPhotonCorrelation { continue; } // reco assoc selection - if (!isSelectedAssoc(photonPcm1) || !isSelectedAssoc(photonPcm2)) { - continue; - } if (!checkEnergyAsymDiPhoton(photonPcm1.v0PhotonKF(), photonPcm2.v0PhotonKF())) { continue; } @@ -1678,20 +1628,10 @@ struct HadronPhotonCorrelation { // other //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - void processPcmDcaZ(HpcCollisions::iterator const& collision, PhotonPcmsWithV0 const& photonPcms, + void processPcmDcaZ(soa::Filtered::iterator const& collision, soa::Filtered const& photonPcms, aod::V0PhotonsKF const&, aod::V0Legs const&) { - // event selection - if (!totalEvSel(collision)) { - return; - } - for (auto const& photonPcm : photonPcms) { - // reco assoc selection - if (!isSelectedAssoc(photonPcm)) { - continue; - } - double const weight = getMcAssocPtScaling(photonPcm) * getMcK0ShortPtScaling(photonPcm); histos.fill(HIST("reco/plain/h5_ptTrigPtAssocDcaZZPvMult_photonPcm"), @@ -1709,6 +1649,31 @@ struct HadronPhotonCorrelation { // mc true++ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + bool fillMcTrueBasicCondition(auto const& assocParticle) + { + if (std::abs(assocParticle.eta()) > config.absEtaMax.value) { + return false; + } + if (assocParticle.isPhysicalPrimary()) { + return true; + } + if (isDecayPrimary(assocParticle)) { + switch (assocParticle.pdgCode()) { + case PDG_t::kPi0: + return true; + case constants::physics::Pdg::kEta: + return true; + case constants::physics::Pdg::kOmega: + return true; + case constants::physics::Pdg::kEtaPrime: + return true; + default: + return false; + } + } + return false; + } + template void fillAssocsMcTrue(auto histFillInfo, auto const& assocParticle, T_DecaySelfTrigFunc const& isDecaySelfTrig = {}) { @@ -1869,14 +1834,9 @@ struct HadronPhotonCorrelation { } } - void processMcTrue(CorrMcCollisions const& mcCollisions, aod::HpcTrueTriggers const& trueTriggers, aod::JetParticles const& mcParticles) + void processMcTrue(soa::Filtered const& mcCollisions, aod::HpcTrueTriggers const& trueTriggers, aod::JetParticles const& mcParticles) { for (auto const& mcCollision : mcCollisions) { - // event selection - if (!totalEvSel(mcCollision)) { - continue; - } - // group collision auto const trueTriggersThisEvent = trueTriggers.sliceBy(perColTrueTriggers, mcCollision.globalIndex()); auto const mcParticlesThisEvent = mcParticles.sliceBy(perColMcParticles, mcCollision.globalIndex()); @@ -1923,24 +1883,21 @@ struct HadronPhotonCorrelation { histFillInfo.weight = perTriggerWeight; fillAssocsMcTrue(histFillInfo, assocParticle); }; - corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, config.nMixingAt0McTrue.value); + corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, config.nMixingAt0McTrue.value, + [this](auto const& assocParticle) { return fillMcTrueBasicCondition(assocParticle); }); } } PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrue, "process mc-true (all collisions) for multiple associated particles", false); - void processMcTrueRecoEv(HpcCollisionsMcD const& collisions, CorrMcCollisions const&, aod::HpcTrueTriggers const& trueTriggers, aod::JetParticles const& mcParticles) + void processMcTrueRecoEv(soa::Filtered const& collisions, + soa::Filtered const&, aod::HpcTrueTriggers const& trueTriggers, aod::JetParticles const& mcParticles) { for (auto const& collision : collisions) { - // event selection - if (!totalEvSel(collision)) { - continue; - } - if (!isMcMatchedCollision(collision)) { continue; } - auto const& mcCollision = collision.jetMcCollision_as(); + auto const& mcCollision = collision.jetMcCollision_as>(); // group collision auto const trueTriggersThisEvent = trueTriggers.sliceBy(perColTrueTriggers, collision.jetMcCollisionId()); @@ -1988,25 +1945,21 @@ struct HadronPhotonCorrelation { histFillInfo.weight = perTriggerWeight; fillAssocsMcTrue(histFillInfo, assocParticle); }; - corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, config.nMixingAt0McTrue.value); + corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, config.nMixingAt0McTrue.value, + [this](auto const& assocParticle) { return fillMcTrueBasicCondition(assocParticle); }); } } PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueRecoEv, "process mc-true (reco collisions) correlation for multiple associated particles", false); - void processMcTrueRecoEvRecoPtTrig(HpcCollisionsMcD const& collisions, soa::Join const& triggers, aod::JetTracksMCD const&, - CorrMcCollisions const&, aod::JetParticles const& mcParticles) + void processMcTrueRecoEvRecoPtTrig(soa::Filtered const& collisions, soa::Join const& triggers, aod::JetTracksMCD const&, + soa::Filtered const&, aod::JetParticles const& mcParticles) { for (auto const& collision : collisions) { - // event selection - if (!totalEvSel(collision)) { - continue; - } - if (!isMcMatchedCollision(collision)) { continue; } - auto const& mcCollision = collision.jetMcCollision_as(); + auto const& mcCollision = collision.jetMcCollision_as>(); // group collision auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); @@ -2016,7 +1969,7 @@ struct HadronPhotonCorrelation { std::map const decaySelfTrigPlainMap = getDecaySelfTrigPlainMap(triggersThisEvent); auto const funcPlain = [this, &decaySelfTrigPlainMap](auto const& collision, auto const& assocParticle) { - auto const& mcCollision = collision.template jetMcCollision_as(); + auto const& mcCollision = collision.template jetMcCollision_as>(); // self trigger info for decaying particles auto const isDecaySelfTrig = [&decaySelfTrigPlainMap](AssocType const assocType) { return decaySelfTrigPlainMap.at(assocType); @@ -2065,7 +2018,8 @@ struct HadronPhotonCorrelation { histFillInfo.weight = perTriggerWeight; fillAssocsMcTrue(histFillInfo, assocParticle, []() { return false; }); }; - corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, config.nMixingAt0McTrue.value); + corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, config.nMixingAt0McTrue.value, + [this](auto const& assocParticle) { return fillMcTrueBasicCondition(assocParticle); }); } } PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueRecoEvRecoPtTrig, "process mc-true (reco collisions with reco ptTrig) correlation for multiple associated particles", false); @@ -2101,11 +2055,6 @@ struct HadronPhotonCorrelation { void fillProcessMcRecoStd(auto const& collisions, auto const& triggers, auto const& assocs) { for (auto const& collision : collisions) { - // event selection - if (!totalEvSel(collision)) { - continue; - } - // group collision ++ auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); auto const [assocsThisEvent, nMixingAt0] = [&]() { @@ -2121,11 +2070,6 @@ struct HadronPhotonCorrelation { }(); auto const funcPlain = [this](auto const& collision, auto const& associated) { - // reco assoc selection - if (!isSelectedAssoc(associated)) { - return; - } - HistFillInfoPlainPhiEtaZPvMult histFillInfo = {collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), collision.posZ(), static_cast(collision.nGlobalTracks())}; histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated); @@ -2134,10 +2078,6 @@ struct HadronPhotonCorrelation { corrProcessPlain(collision, assocsThisEvent, funcPlain); auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { - // reco assoc selection - if (!isSelectedAssoc(associated)) { - return; - } // exclude self correlation if (isRecoSelfTrigger(trigger, associated)) { return; @@ -2156,10 +2096,6 @@ struct HadronPhotonCorrelation { continue; } - auto const conditionMixAssocOnly = [this](auto const& associated) { - // reco assoc selection - return isSelectedAssoc(associated); - }; auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; @@ -2168,23 +2104,23 @@ struct HadronPhotonCorrelation { getTriggerPtCorrection(mixingTrigger.pt()); fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); }; - corrProcessMixing(collision, assocsThisEvent, funcMixing, nMixingAt0, conditionMixAssocOnly); + corrProcessMixing(collision, assocsThisEvent, funcMixing, nMixingAt0); } } - void processMcRecoHadron(HpcCollisions const& collisions, aod::HpcTriggers const& triggers, aod::HpcHadrons const& hadrons) + void processMcRecoHadron(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, aod::HpcHadrons const& hadrons) { fillProcessMcRecoStd(collisions, triggers, hadrons); } PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoHadron, "process standard for associated hardon with additional mc information", false); - void processMcRecoPipm(HpcCollisions const& collisions, aod::HpcTriggers const& triggers, aod::HpcPipms const& pipms) + void processMcRecoPipm(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, aod::HpcPipms const& pipms) { fillProcessMcRecoStd(collisions, triggers, pipms); } PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoPipm, "process standard for associated pipm with additional mc information", false); - void processMcRecoPhotonPcm(HpcCollisions const& collisions, aod::HpcTriggers const& triggers, PhotonPcmsWithV0 const& photonPcms, + void processMcRecoPhotonPcm(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, soa::Filtered const& photonPcms, aod::V0PhotonsKF const&, aod::V0Legs const&) { fillProcessMcRecoStd(collisions, triggers, photonPcms); @@ -2268,21 +2204,11 @@ struct HadronPhotonCorrelation { void fillProcesMcRecoPhotonPcmPair(auto const& collisions, auto const& triggers, auto const& photonPcmPairs) { for (auto const& collision : collisions) { - // event selection - if (!totalEvSel(collision)) { - continue; - } - // group collision auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); auto const photonPcmPairsThisEvent = photonPcmPairs.sliceBy(perColPhotonPcmPairs, collision.globalIndex()); auto const funcPlain = [this](auto const& collision, auto const& associated) { - // reco assoc selection - if (!isSelectedAssoc(associated)) { - return; - } - HistFillInfoPlainPt histFillInfo = {collision.ptMax(), associated.pt()}; histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated); fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); @@ -2290,10 +2216,6 @@ struct HadronPhotonCorrelation { corrProcessPlain(collision, photonPcmPairsThisEvent, funcPlain); auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { - // reco assoc selection - if (!isSelectedAssoc(associated)) { - return; - } // exclude self correlation if (isRecoSelfTrigger(trigger, associated)) { return; @@ -2312,10 +2234,6 @@ struct HadronPhotonCorrelation { continue; } - auto const conditionMixAssocOnly = [this](auto const& associated) { - // reco assoc selection - return isSelectedAssoc(associated); - }; auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; @@ -2324,11 +2242,11 @@ struct HadronPhotonCorrelation { getTriggerPtCorrection(mixingTrigger.pt()); fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); }; - corrProcessMixing(collision, photonPcmPairsThisEvent, funcMixing, config.nMixingAt0PhotonPcmPair.value, conditionMixAssocOnly); + corrProcessMixing(collision, photonPcmPairsThisEvent, funcMixing, config.nMixingAt0PhotonPcmPair.value); } } - void processMcRecoPhotonPcmPair(HpcCollisions const& collisions, aod::HpcTriggers const& triggers, PhotonPcmPairsWithV0 const& photonPcmPairs, + void processMcRecoPhotonPcmPair(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, soa::Filtered const& photonPcmPairs, aod::V0PhotonsKF const&, aod::V0Legs const&) { fillProcesMcRecoPhotonPcmPair(collisions, triggers, photonPcmPairs); @@ -2338,19 +2256,10 @@ struct HadronPhotonCorrelation { // other //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - void processPcmDcaZTrue(HpcCollisionsMcD::iterator const& collision, soa::Join const& photonPcms, - aod::V0PhotonsKF const&, aod::V0Legs const&, aod::JetTracksMCD const&, CorrMcCollisions const&, aod::JetParticles const&) + void processPcmDcaZTrue(soa::Filtered::iterator const& collision, soa::Filtered> const& photonPcms, + aod::V0PhotonsKF const&, aod::V0Legs const&, aod::JetTracksMCD const&, soa::Filtered const&, aod::JetParticles const&) { - // event selection - if (!totalEvSel(collision)) { - return; - } - for (auto const& photonPcm : photonPcms) { - // reco assoc selection - if (!isSelectedAssoc(photonPcm)) { - continue; - } if (!checkTruthLevelReco(photonPcm)) { continue; } @@ -2374,7 +2283,7 @@ struct HadronPhotonCorrelation { // last ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - void processRecoLast(HpcCollisions const& collisions, aod::HpcTriggers const& triggers) + void processRecoLast(aod::HpcCollisions const& collisions, aod::HpcTriggers const& triggers) { // do at end of each data frame (after other reco correlation process functions) // (PROCESS_SWITCH of this process has to be declared last) @@ -2384,7 +2293,7 @@ struct HadronPhotonCorrelation { histos.fill(HIST("reco/info/h1_nEvents"), 0.5); // mc split - if (!checkSplitMcEventSelection(collision)) { + if (collision.nSelectSplitMcEv() != config.nSelectSplitMcEv.value) { continue; } histos.fill(HIST("reco/info/h1_nEvents"), 1.5); @@ -2413,18 +2322,13 @@ struct HadronPhotonCorrelation { } PROCESS_SWITCH(HadronPhotonCorrelation, processRecoLast, "process general info for reconstructed collisions and later correlations last", true); - void processMcLast(HpcCollisionsMcD const& collisions, soa::Join const& triggers, aod::JetTracksMCD const&, - CorrMcCollisions const& mcCollisions, aod::HpcTrueTriggers const& trueTriggers, aod::JetParticles const&) + void processMcLast(soa::Filtered const& collisions, soa::Join const& triggers, aod::JetTracksMCD const&, + soa::Filtered const& mcCollisions, aod::HpcTrueTriggers const& trueTriggers, aod::JetParticles const&) { // do at end of each data frame (after other mc correlation process functions) // (PROCESS_SWITCH of this process has to be declared last) for (auto const& mcCollision : mcCollisions) { - // event selection - if (!totalEvSel(mcCollision)) { - continue; - } - // group collision auto const trueTriggersThisEvent = trueTriggers.sliceBy(perColTrueTriggers, mcCollision.globalIndex()); @@ -2440,17 +2344,12 @@ struct HadronPhotonCorrelation { } } for (auto const& collision : collisions) { - // event selection - if (!totalEvSel(collision)) { - continue; - } - if (!isMcMatchedCollision(collision)) { histos.fill(HIST("mc/info/h1_pt_noMatch_event"), 0.5); continue; } - auto const& mcCollision = collision.jetMcCollision_as(); + auto const& mcCollision = collision.jetMcCollision_as>(); // group collision auto const trueTriggersThisEvent = trueTriggers.sliceBy(perColTrueTriggers, mcCollision.globalIndex()); @@ -2488,5 +2387,5 @@ struct HadronPhotonCorrelation { WorkflowSpec defineDataProcessing(ConfigContext const& configContext) { - return WorkflowSpec{adaptAnalysisTask(configContext)}; + return WorkflowSpec{adaptAnalysisTask(configContext), adaptAnalysisTask(configContext)}; } diff --git a/PWGJE/Tasks/hadronPhotonProducer.cxx b/PWGJE/Tasks/hadronPhotonProducer.cxx index e304458fe82..8ff7fc52081 100644 --- a/PWGJE/Tasks/hadronPhotonProducer.cxx +++ b/PWGJE/Tasks/hadronPhotonProducer.cxx @@ -98,6 +98,7 @@ struct HadronPhotonProducer { Configurable rctLabel{"rctLabel", "CBT_hadronPID", "RCT selection label"}; Configurable trackSelections{"trackSelections", "globalTracks", "JE framework - track selections"}; Configurable triggerMasks{"triggerMasks", "", "JE framework - skimmed data trigger masks (relevent for correlation: fTrackLowPt,fTrackHighPt)"}; + Configurable nTimesSplitMcEv{"nTimesSplitMcEv", 1, "number of event fractions for selection in MC (as modulo from {0,1,...,99}) | (select 1 for data)"}; Configurable absEtaMax{"absEtaMax", 0.8, "maximum absEta cut"}; Configurable ptTrigMin{"ptTrigMin", 5, "minimum pt of triggers"}; @@ -448,9 +449,9 @@ struct HadronPhotonProducer { // other ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - // mc split event selection based in the thrid decimal of mc-true posZ + // mc split event selection based in the thrid and fourth decimal of mc-true posZ // returns reco value in case of no mc match - int getThirdDecimalTruePosZ(auto const& collision) + int getThirdFourthDecimalTruePosZ(auto const& collision) { double absPosZ; @@ -466,9 +467,9 @@ struct HadronPhotonProducer { } else { static_assert(AlwaysFalseType, "collision type not allowed"); } - int const thirdDecimalPosZ = static_cast(1000 * absPosZ) % 10; + int const thirdFourthDecimalPosZ = static_cast(10000 * absPosZ) % 100; - return thirdDecimalPosZ; + return thirdFourthDecimalPosZ; } // analysis ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -485,7 +486,8 @@ struct HadronPhotonProducer { throw std::runtime_error("invalid doprocess-collisionTrigger config"); } if (static_cast(doprocessRecoHadronPipmTPCTOF) + static_cast(doprocessMcRecoHadronPipmTPCTOF) + - static_cast(doprocessRecoHadronPipmTPC) + static_cast(doprocessMcRecoHadronPipmTPC) > 1) { + static_cast(doprocessRecoHadronPipmTPC) + static_cast(doprocessMcRecoHadronPipmTPC) > + 1) { throw std::runtime_error("invalid doprocess-hadronPipm config"); } if (static_cast(doprocessRecoPhotonPcm) + static_cast(doprocessMcRecoPhotonPcm) > 1) { @@ -525,11 +527,11 @@ struct HadronPhotonProducer { // group collision auto const tracksThisEvent = tracks.sliceBy(perColTracks, collision.globalIndex()); - // mc split event selection - // default -1 for data reconstruction - int thirdDecimalTruePosZ = -1; + // mc split event selection n + // default 1 for data reconstruction + int nSelectSplitMcEv = 1; if constexpr (IsCollisionMCD) { - thirdDecimalTruePosZ = getThirdDecimalTruePosZ(collision); + nSelectSplitMcEv = getThirdFourthDecimalTruePosZ(collision) % nTimesSplitMcEv.value + 1; } // maximum track pt float maxTrackPt = -1; @@ -585,7 +587,7 @@ struct HadronPhotonProducer { // collision info histos.fill(HIST("reco/h2_zPvMult"), collision.posZ(), nGlobalTracks); histos.fill(HIST("reco/h1_hadronicRate"), collision.hadronicRate()); - tableProduction.collision(isSelectedEvent, thirdDecimalTruePosZ, isTriggerEvent, maxTrackPt, collision.posZ(), nGlobalTracks); + tableProduction.collision(isSelectedEvent, nSelectSplitMcEv, isTriggerEvent, maxTrackPt, collision.posZ(), nGlobalTracks); tableProduction.collisionId(collision.globalIndex()); // mc true collsion label if constexpr (IsCollisionMCD) { @@ -860,7 +862,7 @@ struct HadronPhotonProducer { auto const mcParticlesThisEvent = mcParticles.sliceBy(perColMcParticles, mcCollision.globalIndex()); // mc split event selection - int const thirdDecimalTruePosZ = getThirdDecimalTruePosZ(mcCollision); + int const nSelectSplitMcEv = getThirdFourthDecimalTruePosZ(mcCollision) % nTimesSplitMcEv.value + 1; // maximum charged particle pt float maxChargedPt = -1; int maxTriggerCollisionId = -1; @@ -915,7 +917,7 @@ struct HadronPhotonProducer { // collision info histos.fill(HIST("true/h2_zPvMult"), mcCollision.posZ(), nCharged); - tableProduction.mcCollisionExtraCorr(isSelectedEvent, thirdDecimalTruePosZ, isTriggerEvent, maxChargedPt, nCharged); + tableProduction.mcCollisionExtraCorr(isSelectedEvent, nSelectSplitMcEv, isTriggerEvent, maxChargedPt, nCharged); } } PROCESS_SWITCH(HadronPhotonProducer, processMcCorrTables, "process table production (mc)", false); From 911f7bc748ef42d1fb5173239de5c445edd479cc Mon Sep 17 00:00:00 2001 From: jkinner2 Date: Thu, 19 Nov 2026 16:15:03 +0100 Subject: [PATCH 08/13] absorbFillMcReco --- PWGJE/Tasks/hadronPhotonCorrelation.cxx | 262 +++++++++--------------- PWGJE/Tasks/hadronPhotonProducer.cxx | 23 ++- 2 files changed, 109 insertions(+), 176 deletions(-) diff --git a/PWGJE/Tasks/hadronPhotonCorrelation.cxx b/PWGJE/Tasks/hadronPhotonCorrelation.cxx index b7c83dec2d2..65f295a0f70 100644 --- a/PWGJE/Tasks/hadronPhotonCorrelation.cxx +++ b/PWGJE/Tasks/hadronPhotonCorrelation.cxx @@ -172,6 +172,15 @@ struct HadronPhotonPcmSelection { return fV0PhotonCut.template IsSelected, aod::V0Legs>(V0PhotonNoEvent{v0Photon}); } + // energy asymmetry for photon pair + static double getEnergyAsymDiPhoton(auto const& v0Photon1, auto const& v0Photon2) + { + double const e1 = v0Photon1.pt() * std::cosh(v0Photon1.eta()); + double const e2 = v0Photon2.pt() * std::cosh(v0Photon2.eta()); + double const energyAsym = std::abs((e1 - e2) / (e1 + e2)); + return energyAsym; + } + void init(InitContext&) { initV0PhotonCut(); @@ -187,10 +196,7 @@ struct HadronPhotonPcmSelection { for (auto const& pair : photonPcmPairs) { auto const v0Photon1 = pair.v0PhotonKF1(); auto const v0Photon2 = pair.v0PhotonKF2(); - double const e1 = v0Photon1.pt() * std::cosh(v0Photon1.eta()); - double const e2 = v0Photon2.pt() * std::cosh(v0Photon2.eta()); - double const energyAsym = std::abs((e1 - e2) / (e1 + e2)); - photonPcmPairSel(isSelectedV0Photon(v0Photon1) && isSelectedV0Photon(v0Photon2), energyAsym); + photonPcmPairSel(isSelectedV0Photon(v0Photon1) && isSelectedV0Photon(v0Photon2), getEnergyAsymDiPhoton(v0Photon1, v0Photon2)); } } PROCESS_SWITCH(HadronPhotonPcmSelection, processSelection, "process photonPcm selection", false); @@ -372,7 +378,6 @@ struct HadronPhotonCorrelation { SliceCache cache; // prepare for per collision slicing - Preslice perColTracks = aod::jtrack::collisionId; Preslice perColTriggers = aod::hpc_common::corrCollisionId; Preslice perColHadrons = aod::hpc_common::corrCollisionId; Preslice perColPipms = aod::hpc_common::corrCollisionId; @@ -755,7 +760,8 @@ struct HadronPhotonCorrelation { histos.add("reco/corr/h5_ptTrigPtAssocMggZPvMult_reco_photonPcmPair", "h5_ptTrigPtAssocMggZPvMult_reco_photonPcmPair", kTHnSparseD, {axisPtTrig, axisPtAssoc, axisMgg, axisZPvBinning, axisMultBinning}, true); // event mixing for photon pairs - histos.add("reco/plain/h4_ptMggZPvMult_reco_photonPcmPair_evMix", "h4_ptMggZPvMult_reco_photonPcmPair_evMix", kTHnSparseD, {axisPtAssoc, axisMgg, axisZPvBinning, axisMultBinning}, true); + histos.add("reco/plain/h4_ptMggZPvMult_reco_photonPcmPair_evMix", "h4_ptMggZPvMult_reco_photonPcmPair_evMix", + kTHnSparseD, {axisPtAssoc, axisMgg, axisZPvBinning, axisMultBinning}, true); // pseudo mgg // pi0Pcm histos.add("mc/plain/h5_ptTrigPtAssocMggZPvMult_pseudoReco_pi0Pcm", "h5_ptTrigPtAssocMggZPvMult_pseudoReco_pi0Pcm", @@ -1071,17 +1077,6 @@ struct HadronPhotonCorrelation { } } - // reco/systematic cuts --------------------------------------------------------------------------------------------------------------------------------------------------------------------- - - // energy asymmetry for photon pair - bool checkEnergyAsymDiPhoton(auto const& v0Photon1, auto const& v0Photon2) - { - double const e1 = v0Photon1.pt() * std::cosh(v0Photon1.eta()); - double const e2 = v0Photon2.pt() * std::cosh(v0Photon2.eta()); - double const energyAsym = std::abs((e1 - e2) / (e1 + e2)); - return energyAsym < config.energyAsymmPhotonPairMax.value; - } - // analysis helpers ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -1359,7 +1354,8 @@ struct HadronPhotonCorrelation { // analysis info int64_t const noLaterThanCcdb = - config.noLaterThanCcdbConfig.value == -1 ? std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count() : config.noLaterThanCcdbConfig.value; + config.noLaterThanCcdbConfig.value == -1 ? std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count() : + config.noLaterThanCcdbConfig.value; ccdb->setURL(config.urlCcdb.value); // enabling object caching (otherwise each call goes to CCDB server) ccdb->setCaching(true); @@ -1372,21 +1368,23 @@ struct HadronPhotonCorrelation { if (std::abs(config.absEtaMax.value - absEtaMaxProducer) > doublePrecisionDeltaCheck) { throw std::runtime_error("absEtaMax does not match producer"); } - }; + } + if (common::core::getTaskOptionValue(initContext, "hadron-photon-producer", "ptTrigMin", ptTrigMinProducer, false)) { if (std::abs(config.ptTrigMin.value - ptTrigMinProducer) > doublePrecisionDeltaCheck) { throw std::runtime_error("ptTrigMin does not match producer"); } } - if (common::core::getTaskOptionValue(initContext, "hadron-photon-pcm-selection", "pcmcut_group.cfgMinEtaV0", cfgMinEtaV0Selection, false) || + if (common::core::getTaskOptionValue(initContext, "hadron-photon-pcm-selection", "pcmcut_group.cfgMinEtaV0", cfgMinEtaV0Selection, false) && common::core::getTaskOptionValue(initContext, "hadron-photon-pcm-selection", "pcmcut_group.cfgMaxEtaV0", cfgMaxEtaV0Selection, false)) { if (config.absEtaMax.value > std::abs(cfgMinEtaV0Selection) || config.absEtaMax.value > std::abs(cfgMaxEtaV0Selection)) { throw std::runtime_error("absEtaMax does not constrain v0 cut"); } - }; + } // check coherent config + if (std::abs(config.ptTrigMin.value - configHist.binsPtTrig.value.at(0)) > doublePrecisionDeltaCheck) { throw std::runtime_error("ptTrigMin does not match trigger axis"); } @@ -1406,6 +1404,21 @@ struct HadronPhotonCorrelation { throw std::runtime_error("wrong number of mc scaling params for eta"); } + // doprocess combinations + + if (static_cast(doprocessRecoHadron) + static_cast(doprocessMcRecoHadron) > 1) { + throw std::runtime_error("invalid doprocess-recoHadron config"); + } + if (static_cast(doprocessRecoPipm) + static_cast(doprocessMcRecoPipm) > 1) { + throw std::runtime_error("invalid doprocess-recoPipm config"); + } + if (static_cast(doprocessRecoPhotonPcm) + static_cast(doprocessMcRecoPhotonPcm) > 1) { + throw std::runtime_error("invalid doprocess-recoPhotonPcm config"); + } + if (static_cast(doprocessRecoPhotonPcmPair) + static_cast(doprocessMcRecoPhotonPcmPair) > 1) { + throw std::runtime_error("invalid doprocess-recoPhotonPcmPair config"); + } + // histograms from ccdb initCcdbHistograms(noLaterThanCcdb); @@ -1431,7 +1444,7 @@ struct HadronPhotonCorrelation { // standard reco :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - template + template void fillProcessRecoStd(auto const& collisions, auto const& triggers, auto const& assocs) { for (auto const& collision : collisions) { @@ -1454,6 +1467,9 @@ struct HadronPhotonCorrelation { collision.posZ(), static_cast(collision.nGlobalTracks())}; histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated); fillHistMain(histFillInfo); + if constexpr (FillMcRecoInfo) { + fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); + } }; corrProcessPlain(collision, assocsThisEvent, funcPlain); @@ -1468,6 +1484,9 @@ struct HadronPhotonCorrelation { histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(trigger.pt()); fillHistMain(histFillInfo); + if constexpr (FillMcRecoInfo) { + fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); + } }; corrProcessCorrelation(collision, triggersThisEvent, assocsThisEvent, funcCorrelation); @@ -1483,6 +1502,9 @@ struct HadronPhotonCorrelation { getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(mixingTrigger.pt()); fillHistMain(histFillInfo); + if constexpr (FillMcRecoInfo) { + fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); + } }; corrProcessMixing(collision, assocsThisEvent, funcMixing, nMixingAt0); } @@ -1490,50 +1512,61 @@ struct HadronPhotonCorrelation { void processRecoHadron(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, aod::HpcHadrons const& hadrons) { - fillProcessRecoStd(collisions, triggers, hadrons); + fillProcessRecoStd(collisions, triggers, hadrons); } PROCESS_SWITCH(HadronPhotonCorrelation, processRecoHadron, "process standard for associated hardon", false); void processRecoPipm(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, aod::HpcPipms const& pipms) { - fillProcessRecoStd(collisions, triggers, pipms); + fillProcessRecoStd(collisions, triggers, pipms); } PROCESS_SWITCH(HadronPhotonCorrelation, processRecoPipm, "process standard for associated pipm", false); void processRecoPhotonPcm(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, soa::Filtered const& photonPcms, aod::V0PhotonsKF const&, aod::V0Legs const&) { - fillProcessRecoStd(collisions, triggers, photonPcms); + fillProcessRecoStd(collisions, triggers, photonPcms); } PROCESS_SWITCH(HadronPhotonCorrelation, processRecoPhotonPcm, "process standard for associated photonPcm", false); // photonPcmPair reco ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: template - void fillAssocsRecoPhotonPcmPair(auto const& histFillInfo, double const mgg) + void fillAssocsRecoPhotonPcmPair(auto const& histFillInfo, auto const& collision, auto const& associated) { + // mgg distribution + if constexpr (HistFillModeV == HistFillMode::Plain) { + histos.fill(HIST("reco/plain/h5_ptTrigPtAssocMggZPvMult_reco_photonPcmPair"), + histFillInfo.ptMax, histFillInfo.ptAssoc, associated.mgg(), collision.posZ(), collision.nGlobalTracks(), + histFillInfo.weight); + } else if constexpr (HistFillModeV == HistFillMode::Correlation) { + histos.fill(HIST("reco/corr/h5_ptTrigPtAssocMggZPvMult_reco_photonPcmPair"), + histFillInfo.ptTrig, histFillInfo.ptAssoc, associated.mgg(), collision.posZ(), collision.nGlobalTracks(), + histFillInfo.weight); + } + // pi0 - if (isInMassRange(mgg)) { + if (isInMassRange(associated.mgg())) { fillHistMain(histFillInfo); return; } - if (isInMassRange(mgg)) { + if (isInMassRange(associated.mgg())) { fillHistMain(histFillInfo); return; } // eta - if (isInMassRange(mgg)) { + if (isInMassRange(associated.mgg())) { fillHistMain(histFillInfo); return; } - if (isInMassRange(mgg)) { + if (isInMassRange(associated.mgg())) { fillHistMain(histFillInfo); return; } } - void processRecoPhotonPcmPair(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, soa::Filtered const& photonPcmPairs, - aod::V0PhotonsKF const&, aod::V0Legs const&) + template + void fillProcesRecoPhotonPcmPair(auto const& collisions, auto const& triggers, auto const& photonPcmPairs) { for (auto const& collision : collisions) { // group collision @@ -1541,16 +1574,12 @@ struct HadronPhotonCorrelation { auto const photonPcmPairsThisEvent = photonPcmPairs.sliceBy(perColPhotonPcmPairs, collision.globalIndex()); auto const funcPlain = [this](auto const& collision, auto const& associated) { - double const weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated); - - // mgg distribution - histos.fill(HIST("reco/plain/h5_ptTrigPtAssocMggZPvMult_reco_photonPcmPair"), - collision.ptMax(), associated.pt(), associated.mgg(), collision.posZ(), collision.nGlobalTracks(), - weight); - HistFillInfoPlainPt histFillInfo = {collision.ptMax(), associated.pt()}; - histFillInfo.weight = weight; - fillAssocsRecoPhotonPcmPair(histFillInfo, associated.mgg()); + histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated); + fillAssocsRecoPhotonPcmPair(histFillInfo, collision, associated); + if constexpr (FillMcRecoInfo) { + fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); + } }; corrProcessPlain(collision, photonPcmPairsThisEvent, funcPlain); @@ -1560,18 +1589,14 @@ struct HadronPhotonCorrelation { return; } - double const weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * - getTriggerPtCorrection(trigger.pt()); - - // mgg distribution - histos.fill(HIST("reco/corr/h5_ptTrigPtAssocMggZPvMult_reco_photonPcmPair"), - trigger.pt(), associated.pt(), associated.mgg(), collision.posZ(), collision.nGlobalTracks(), - weight); - HistFillInfoCorr histFillInfo = {getDeltaPhi(trigger.phi(), associated.phi()), trigger.eta() - associated.eta(), trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = weight; - fillAssocsRecoPhotonPcmPair(histFillInfo, associated.mgg()); + histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * + getTriggerPtCorrection(trigger.pt()); + fillAssocsRecoPhotonPcmPair(histFillInfo, collision, associated); + if constexpr (FillMcRecoInfo) { + fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); + } }; corrProcessCorrelation(collision, triggersThisEvent, photonPcmPairsThisEvent, funcCorrelation); @@ -1586,11 +1611,20 @@ struct HadronPhotonCorrelation { histFillInfo.weight = perTriggerWeight * getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(mixingTrigger.pt()); - fillAssocsRecoPhotonPcmPair(histFillInfo, associated.mgg()); + fillAssocsRecoPhotonPcmPair(histFillInfo, collision, associated); + if constexpr (FillMcRecoInfo) { + fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); + } }; corrProcessMixing(collision, photonPcmPairsThisEvent, funcMixing, config.nMixingAt0PhotonPcmPair.value); } } + + void processRecoPhotonPcmPair(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, soa::Filtered const& photonPcmPairs, + aod::V0PhotonsKF const&, aod::V0Legs const&) + { + fillProcesRecoPhotonPcmPair(collisions, triggers, photonPcmPairs); + } PROCESS_SWITCH(HadronPhotonCorrelation, processRecoPhotonPcmPair, "process standard for associated photonPcmPair", false); void processPhotonPcmPairMix(soa::Filtered const& collisions, soa::Filtered const& photonPcms, @@ -1614,7 +1648,7 @@ struct HadronPhotonCorrelation { continue; } // reco assoc selection - if (!checkEnergyAsymDiPhoton(photonPcm1.v0PhotonKF(), photonPcm2.v0PhotonKF())) { + if (HadronPhotonPcmSelection::getEnergyAsymDiPhoton(photonPcm1.v0PhotonKF(), photonPcm2.v0PhotonKF()) > config.energyAsymmPhotonPairMax.value) { continue; } @@ -2051,79 +2085,22 @@ struct HadronPhotonCorrelation { fillHistMain(histFillInfo); } - template - void fillProcessMcRecoStd(auto const& collisions, auto const& triggers, auto const& assocs) - { - for (auto const& collision : collisions) { - // group collision ++ - auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); - auto const [assocsThisEvent, nMixingAt0] = [&]() { - if constexpr (AssocTypeV == AssocType::Hadron) { - return std::tuple{assocs.sliceBy(perColHadrons, collision.globalIndex()), config.nMixingAt0Hadron.value}; - } else if constexpr (AssocTypeV == AssocType::Pipm) { - return std::tuple{assocs.sliceBy(perColPipms, collision.globalIndex()), config.nMixingAt0Pipm.value}; - } else if constexpr (AssocTypeV == AssocType::PhotonPcm) { - return std::tuple{assocs.sliceBy(perColPhotonPcms, collision.globalIndex()), config.nMixingAt0PhotonPcm.value}; - } else { - static_assert(AlwaysFalseValue, "assocType not supported"); - } - }(); - - auto const funcPlain = [this](auto const& collision, auto const& associated) { - HistFillInfoPlainPhiEtaZPvMult histFillInfo = {collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), - collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated); - fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); - }; - corrProcessPlain(collision, assocsThisEvent, funcPlain); - - auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { - // exclude self correlation - if (isRecoSelfTrigger(trigger, associated)) { - return; - } - - HistFillInfoCorr histFillInfo = {getDeltaPhi(trigger.phi(), associated.phi()), trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * - getTriggerPtCorrection(trigger.pt()); - fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); - }; - corrProcessCorrelation(collision, triggersThisEvent, assocsThisEvent, funcCorrelation); - - // select mixing events - if (config.doTrigEvMixing.value && !collision.trigEv()) { - continue; - } - - auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { - HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), - mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = perTriggerWeight * - getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * - getTriggerPtCorrection(mixingTrigger.pt()); - fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); - }; - corrProcessMixing(collision, assocsThisEvent, funcMixing, nMixingAt0); - } - } - void processMcRecoHadron(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, aod::HpcHadrons const& hadrons) { - fillProcessMcRecoStd(collisions, triggers, hadrons); + fillProcessRecoStd(collisions, triggers, hadrons); } PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoHadron, "process standard for associated hardon with additional mc information", false); void processMcRecoPipm(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, aod::HpcPipms const& pipms) { - fillProcessMcRecoStd(collisions, triggers, pipms); + fillProcessRecoStd(collisions, triggers, pipms); } PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoPipm, "process standard for associated pipm with additional mc information", false); void processMcRecoPhotonPcm(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, soa::Filtered const& photonPcms, aod::V0PhotonsKF const&, aod::V0Legs const&) { - fillProcessMcRecoStd(collisions, triggers, photonPcms); + fillProcessRecoStd(collisions, triggers, photonPcms); } PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoPhotonPcm, "process standard for associated photonPcm with additional mc information", false); @@ -2157,10 +2134,8 @@ struct HadronPhotonCorrelation { template void fillAssocsMcRecoPhotonPcmPair(auto histFillInfo, auto const& collision, auto const& associated) { - // pi0Pcm + // pi0Pcm pseudo yield if (checkTruthLevelReco(associated)) { - // pseudo yield - // mgg distribution if constexpr (HistFillModeV == HistFillMode::Plain) { histos.fill(HIST("mc/plain/h5_ptTrigPtAssocMggZPvMult_pseudoReco_pi0Pcm"), @@ -2172,17 +2147,12 @@ struct HadronPhotonCorrelation { histFillInfo.weight); } - // mgg distribution - fillHistMain(histFillInfo); - fillTruthLevelsMcRecoPhotonPcmPair(histFillInfo, collision, associated); return; } - // etaPcm + // etaPcm pseudo yield if (checkTruthLevelReco(associated)) { - // pseudo yield - // mgg distribution if constexpr (HistFillModeV == HistFillMode::Plain) { histos.fill(HIST("mc/plain/h5_ptTrigPtAssocMggZPvMult_pseudoReco_etaPcm"), @@ -2195,61 +2165,15 @@ struct HadronPhotonCorrelation { } fillHistMain(histFillInfo); - fillTruthLevelsMcRecoPhotonPcmPair(histFillInfo, collision, associated); return; } } - void fillProcesMcRecoPhotonPcmPair(auto const& collisions, auto const& triggers, auto const& photonPcmPairs) - { - for (auto const& collision : collisions) { - // group collision - auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); - auto const photonPcmPairsThisEvent = photonPcmPairs.sliceBy(perColPhotonPcmPairs, collision.globalIndex()); - - auto const funcPlain = [this](auto const& collision, auto const& associated) { - HistFillInfoPlainPt histFillInfo = {collision.ptMax(), associated.pt()}; - histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated); - fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); - }; - corrProcessPlain(collision, photonPcmPairsThisEvent, funcPlain); - - auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { - // exclude self correlation - if (isRecoSelfTrigger(trigger, associated)) { - return; - } - - HistFillInfoCorr histFillInfo = {getDeltaPhi(trigger.phi(), associated.phi()), trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * - getTriggerPtCorrection(trigger.pt()); - fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); - }; - corrProcessCorrelation(collision, triggersThisEvent, photonPcmPairsThisEvent, funcCorrelation); - - // select mixing events - if (config.doTrigEvMixing.value && !collision.trigEv()) { - continue; - } - - auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { - HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), - mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = perTriggerWeight * - getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * - getTriggerPtCorrection(mixingTrigger.pt()); - fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); - }; - corrProcessMixing(collision, photonPcmPairsThisEvent, funcMixing, config.nMixingAt0PhotonPcmPair.value); - } - } - void processMcRecoPhotonPcmPair(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, soa::Filtered const& photonPcmPairs, aod::V0PhotonsKF const&, aod::V0Legs const&) { - fillProcesMcRecoPhotonPcmPair(collisions, triggers, photonPcmPairs); + fillProcesRecoPhotonPcmPair(collisions, triggers, photonPcmPairs); } PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoPhotonPcmPair, "process correlation for associated photonPcmPair with additional mc information", false); diff --git a/PWGJE/Tasks/hadronPhotonProducer.cxx b/PWGJE/Tasks/hadronPhotonProducer.cxx index 8ff7fc52081..73211cefeb6 100644 --- a/PWGJE/Tasks/hadronPhotonProducer.cxx +++ b/PWGJE/Tasks/hadronPhotonProducer.cxx @@ -482,12 +482,14 @@ struct HadronPhotonProducer { triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); // check config + + // doprocess combinations + if (static_cast(doprocessRecoCollisionTrigger) + static_cast(doprocessMcRecoCollisionTrigger) > 1) { throw std::runtime_error("invalid doprocess-collisionTrigger config"); } if (static_cast(doprocessRecoHadronPipmTPCTOF) + static_cast(doprocessMcRecoHadronPipmTPCTOF) + - static_cast(doprocessRecoHadronPipmTPC) + static_cast(doprocessMcRecoHadronPipmTPC) > - 1) { + static_cast(doprocessRecoHadronPipmTPC) + static_cast(doprocessMcRecoHadronPipmTPC) > 1) { throw std::runtime_error("invalid doprocess-hadronPipm config"); } if (static_cast(doprocessRecoPhotonPcm) + static_cast(doprocessMcRecoPhotonPcm) > 1) { @@ -725,15 +727,22 @@ struct HadronPhotonProducer { // photonsPcm (for some reason collisionId not an index column (?)) auto const v0PhotonsThisEvent = v0Photons.sliceBy(perColV0Photons, collision.collisionId()); + auto const checkPhotonEtaDcaZ = [this](auto const& v0Photon) { + if (std::abs(v0Photon.eta()) > absEtaMax) { + return false; + } + if (std::abs(v0Photon.dcaZtopv()) < pcmAbsDcaZLim.value[0] || std::abs(v0Photon.dcaZtopv()) > pcmAbsDcaZLim.value[1]) { + return false; + } + return true; + }; + // photonPcm for (auto const& v0Photon : v0PhotonsThisEvent) { std::vector intersectTriggerIds; // photon selection - if (std::abs(v0Photon.eta()) > absEtaMax) { - continue; - } - if (std::abs(v0Photon.dcaZtopv()) < pcmAbsDcaZLim.value[0] || std::abs(v0Photon.dcaZtopv()) > pcmAbsDcaZLim.value[1]) { + if (!checkPhotonEtaDcaZ(v0Photon)) { continue; } @@ -779,7 +788,7 @@ struct HadronPhotonProducer { ROOT::Math::PtEtaPhiMVector const p4V0PcmPair = p4V0Pcm1 + p4V0Pcm2; // pair selection - if (std::abs(v0Photon1.eta()) > absEtaMax || std::abs(v0Photon2.eta()) > absEtaMax) { + if (!checkPhotonEtaDcaZ(v0Photon1) || !checkPhotonEtaDcaZ(v0Photon2)) { continue; } if (std::abs(p4V0PcmPair.Eta()) > absEtaMax) { From 8aea0a573e69c45005fd68488964356ed1b9623e Mon Sep 17 00:00:00 2001 From: jkinner2 Date: Thu, 19 Nov 2026 18:15:26 +0100 Subject: [PATCH 09/13] shortenAndSimplifyCode --- PWGJE/Tasks/hadronPhotonCorrelation.cxx | 386 +++++++++--------------- PWGJE/Tasks/hadronPhotonProducer.cxx | 128 ++++---- 2 files changed, 210 insertions(+), 304 deletions(-) diff --git a/PWGJE/Tasks/hadronPhotonCorrelation.cxx b/PWGJE/Tasks/hadronPhotonCorrelation.cxx index 65f295a0f70..668b39fc22a 100644 --- a/PWGJE/Tasks/hadronPhotonCorrelation.cxx +++ b/PWGJE/Tasks/hadronPhotonCorrelation.cxx @@ -318,13 +318,13 @@ struct HadronPhotonCorrelation { {-7, -5, -3, -1, 1, 3, 5, 7}, "zPv mixing bins"}; Configurable> binsMultBinning{"binsMultBinning", - {-0.5, 10.5, 15.5, 20.5, 27.5, 42.5}, + {-0.5, 10.5, 15.5, 20.5, 27.5, 66.5}, "multiplicity mixing bins"}; Configurable> binsZPvBinningMcTrue{"binsZPvBinningMcTrue", {-10000, 10000}, "zPv mixing bins for mc true"}; Configurable> binsMultBinningMcTrue{"binsMultBinningMcTrue", - {-0.5, 16.5, 24.5, 31.5, 39.5, 64.5}, + {-0.5, 16.5, 24.5, 31.5, 39.5, 99.5}, "multiplicity mixing bins for mc true"}; } configHist; @@ -339,17 +339,6 @@ struct HadronPhotonCorrelation { Mixing }; - enum class TriggerMemoryMode { - Reco, - True, - TrueRecoEv, - TrueRecoEvRecoPtTrig - }; - - struct HistFillInfoPlainPt { - double ptMax, ptAssoc; - double weight = 1; - }; struct HistFillInfoPlainPhiEtaZPvMult { double ptMax, ptAssoc, phi, eta, zPv, mult; double weight = 1; @@ -821,7 +810,7 @@ struct HadronPhotonCorrelation { kTHnSparseD, {axisPtTrig, axisPtAssoc, axisCategories}, true); // check count histograms - should not be filled, unless something is off / changed - histos.add("mc/info/h1_pt_noMatch_event", "h1_pt_noMatch_event", kTH1D, {axisN}, true); + histos.add("mc/info/h1_noMatch_event", "h1_noMatch_event", kTH1D, {axisN}, true); histos.add("mc/info/h1_pt_noMatch_trigger", "h1_pt_noMatch_trigger", kTH1D, {axisPtTrig}, true); histos.add("mc/info/h1_unusualStatus_photonDirect", "h1_unusualStatus_photonDirect", kTH1D, {axisInts}, true); @@ -1293,7 +1282,7 @@ struct HadronPhotonCorrelation { } // mixing - template + template void corrProcessMixing(auto const& collision, auto const& associatedThisEvent, auto const& funcMixing, size_t const nTriggerMixingAt0, T_AssocCondition const& funcConditionAssocOnly = {}) { @@ -1302,20 +1291,20 @@ struct HadronPhotonCorrelation { // mixing loops (more dynamic than O2 mixing) std::deque const& savedTriggers = [&]() -> std::deque const& { - if constexpr (TriggerMemoryModeV == TriggerMemoryMode::Reco) { + if constexpr (TruthLevelV == TruthLevel::Reco) { triggerMemoryBinSizeMin = triggerMemoryReco->getBinSizeMin(); return triggerMemoryReco->getTriggers(collision.posZ(), collision.nGlobalTracks()); - } else if constexpr (TriggerMemoryModeV == TriggerMemoryMode::True) { + } else if constexpr (TruthLevelV == TruthLevel::True) { triggerMemoryBinSizeMin = triggerMemoryTrue->getBinSizeMin(); return triggerMemoryTrue->getTriggers(collision.posZ(), collision.nChargedInEtaRange()); - } else if constexpr (TriggerMemoryModeV == TriggerMemoryMode::TrueRecoEv) { + } else if constexpr (TruthLevelV == TruthLevel::TrueRecoEv) { triggerMemoryBinSizeMin = triggerMemoryTrueRecoEv->getBinSizeMin(); return triggerMemoryTrueRecoEv->getTriggers(collision.posZ(), collision.nChargedInEtaRange()); - } else if constexpr (TriggerMemoryModeV == TriggerMemoryMode::TrueRecoEvRecoPtTrig) { + } else if constexpr (TruthLevelV == TruthLevel::TrueRecoEvRecoPtTrig) { triggerMemoryBinSizeMin = triggerMemoryTrueRecoEvRecoPtTrig->getBinSizeMin(); return triggerMemoryTrueRecoEvRecoPtTrig->getTriggers(collision.posZ(), collision.nChargedInEtaRange()); } else { - static_assert(AlwaysFalseValue, "triggerMemoryMode not found"); + static_assert(AlwaysFalseValue, "TruthLevel not found"); } }(); // require enough mixing statistics @@ -1347,6 +1336,7 @@ struct HadronPhotonCorrelation { void init(InitContext& initContext) { double const doublePrecisionDeltaCheck = 1e-5; + double zPvMaxProducer; double absEtaMaxProducer; double ptTrigMinProducer; float cfgMinEtaV0Selection; @@ -1354,8 +1344,7 @@ struct HadronPhotonCorrelation { // analysis info int64_t const noLaterThanCcdb = - config.noLaterThanCcdbConfig.value == -1 ? std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count() : - config.noLaterThanCcdbConfig.value; + config.noLaterThanCcdbConfig.value == -1 ? std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count() : config.noLaterThanCcdbConfig.value; ccdb->setURL(config.urlCcdb.value); // enabling object caching (otherwise each call goes to CCDB server) ccdb->setCaching(true); @@ -1363,13 +1352,19 @@ struct HadronPhotonCorrelation { // not later than (avoids replacing objects while a train is running) ccdb->setCreatedNotAfter(noLaterThanCcdb); + // variables from other tasks + if (common::core::getTaskOptionValue(initContext, "hadron-photon-producer", "zPvMax", zPvMaxProducer, false)) { + if (std::abs(configHist.binsZPvBinning.value.front() + zPvMaxProducer) > doublePrecisionDeltaCheck || + std::abs(configHist.binsZPvBinning.value.back() - zPvMaxProducer) > doublePrecisionDeltaCheck) { + throw std::runtime_error("binsZPvBinning does not match producer"); + } + } // variables from other tasks if (common::core::getTaskOptionValue(initContext, "hadron-photon-producer", "absEtaMax", absEtaMaxProducer, false)) { if (std::abs(config.absEtaMax.value - absEtaMaxProducer) > doublePrecisionDeltaCheck) { throw std::runtime_error("absEtaMax does not match producer"); } } - if (common::core::getTaskOptionValue(initContext, "hadron-photon-producer", "ptTrigMin", ptTrigMinProducer, false)) { if (std::abs(config.ptTrigMin.value - ptTrigMinProducer) > doublePrecisionDeltaCheck) { throw std::runtime_error("ptTrigMin does not match producer"); @@ -1442,10 +1437,26 @@ struct HadronPhotonCorrelation { // correlations ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - // standard reco :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + template + void fillAssocsRecoMain(auto histFillInfo, auto const& collision, auto const& associated) + { + if constexpr (AssocTypeV == AssocType::Hadron || AssocTypeV == AssocType::Pipm || AssocTypeV == AssocType::PhotonPcm) { + fillHistMain(histFillInfo); + if constexpr (FillMcRecoInfo) { + fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); + } + } else if constexpr (AssocTypeV == AssocType::PhotonPcmPair) { + fillAssocsRecoPhotonPcmPair(histFillInfo, collision, associated); + if constexpr (FillMcRecoInfo) { + fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); + } + } else { + static_assert(AlwaysFalseValue, "assocType not found"); + } + } - template - void fillProcessRecoStd(auto const& collisions, auto const& triggers, auto const& assocs) + template + void fillProcessRecoMain(auto const& collisions, auto const& triggers, auto const& assocs, T_AssocConditionMix const& mixConditionAssocOnly = {}) { for (auto const& collision : collisions) { // group collision ++ @@ -1457,6 +1468,8 @@ struct HadronPhotonCorrelation { return std::tuple{assocs.sliceBy(perColPipms, collision.globalIndex()), config.nMixingAt0Pipm.value}; } else if constexpr (AssocTypeV == AssocType::PhotonPcm) { return std::tuple{assocs.sliceBy(perColPhotonPcms, collision.globalIndex()), config.nMixingAt0PhotonPcm.value}; + } else if constexpr (AssocTypeV == AssocType::PhotonPcmPair) { + return std::tuple{assocs.sliceBy(perColPhotonPcmPairs, collision.globalIndex()), config.nMixingAt0PhotonPcmPair.value}; } else { static_assert(AlwaysFalseValue, "assocType not supported"); } @@ -1466,10 +1479,7 @@ struct HadronPhotonCorrelation { HistFillInfoPlainPhiEtaZPvMult histFillInfo = {collision.ptMax(), associated.pt(), associated.phi(), associated.eta(), collision.posZ(), static_cast(collision.nGlobalTracks())}; histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated); - fillHistMain(histFillInfo); - if constexpr (FillMcRecoInfo) { - fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); - } + fillAssocsRecoMain(histFillInfo, collision, associated); }; corrProcessPlain(collision, assocsThisEvent, funcPlain); @@ -1483,10 +1493,7 @@ struct HadronPhotonCorrelation { trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(trigger.pt()); - fillHistMain(histFillInfo); - if constexpr (FillMcRecoInfo) { - fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); - } + fillAssocsRecoMain(histFillInfo, collision, associated); }; corrProcessCorrelation(collision, triggersThisEvent, assocsThisEvent, funcCorrelation); @@ -1501,36 +1508,48 @@ struct HadronPhotonCorrelation { histFillInfo.weight = perTriggerWeight * getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * getTriggerPtCorrection(mixingTrigger.pt()); - fillHistMain(histFillInfo); - if constexpr (FillMcRecoInfo) { - fillTruthLevelsMcRecoStd(histFillInfo, collision, associated); - } + fillAssocsRecoMain(histFillInfo, collision, associated); }; - corrProcessMixing(collision, assocsThisEvent, funcMixing, nMixingAt0); + corrProcessMixing(collision, assocsThisEvent, funcMixing, nMixingAt0, mixConditionAssocOnly); } } + // standard reco :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + void processRecoHadron(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, aod::HpcHadrons const& hadrons) { - fillProcessRecoStd(collisions, triggers, hadrons); + fillProcessRecoMain(collisions, triggers, hadrons); } - PROCESS_SWITCH(HadronPhotonCorrelation, processRecoHadron, "process standard for associated hardon", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processRecoHadron, "process standard for associated hadron", false); void processRecoPipm(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, aod::HpcPipms const& pipms) { - fillProcessRecoStd(collisions, triggers, pipms); + fillProcessRecoMain(collisions, triggers, pipms); } PROCESS_SWITCH(HadronPhotonCorrelation, processRecoPipm, "process standard for associated pipm", false); void processRecoPhotonPcm(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, soa::Filtered const& photonPcms, aod::V0PhotonsKF const&, aod::V0Legs const&) { - fillProcessRecoStd(collisions, triggers, photonPcms); + fillProcessRecoMain(collisions, triggers, photonPcms); } PROCESS_SWITCH(HadronPhotonCorrelation, processRecoPhotonPcm, "process standard for associated photonPcm", false); // photonPcmPair reco ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + bool fillConditionRecoPhotonPcmPairMix(auto const& associated) + { + // pi0 + if (isInMassRange(associated.mgg()) || isInMassRange(associated.mgg())) { + return true; + } + // eta + if (isInMassRange(associated.mgg()) || isInMassRange(associated.mgg())) { + return true; + } + return false; + } + template void fillAssocsRecoPhotonPcmPair(auto const& histFillInfo, auto const& collision, auto const& associated) { @@ -1565,70 +1584,15 @@ struct HadronPhotonCorrelation { } } - template - void fillProcesRecoPhotonPcmPair(auto const& collisions, auto const& triggers, auto const& photonPcmPairs) - { - for (auto const& collision : collisions) { - // group collision - auto const triggersThisEvent = triggers.sliceBy(perColTriggers, collision.globalIndex()); - auto const photonPcmPairsThisEvent = photonPcmPairs.sliceBy(perColPhotonPcmPairs, collision.globalIndex()); - - auto const funcPlain = [this](auto const& collision, auto const& associated) { - HistFillInfoPlainPt histFillInfo = {collision.ptMax(), associated.pt()}; - histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated); - fillAssocsRecoPhotonPcmPair(histFillInfo, collision, associated); - if constexpr (FillMcRecoInfo) { - fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); - } - }; - corrProcessPlain(collision, photonPcmPairsThisEvent, funcPlain); - - auto const funcCorrelation = [this](auto const& collision, auto const& trigger, auto const& associated) { - // exclude self correlation - if (isRecoSelfTrigger(trigger, associated)) { - return; - } - - HistFillInfoCorr histFillInfo = {getDeltaPhi(trigger.phi(), associated.phi()), trigger.eta() - associated.eta(), - trigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * - getTriggerPtCorrection(trigger.pt()); - fillAssocsRecoPhotonPcmPair(histFillInfo, collision, associated); - if constexpr (FillMcRecoInfo) { - fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); - } - }; - corrProcessCorrelation(collision, triggersThisEvent, photonPcmPairsThisEvent, funcCorrelation); - - // select mixing events - if (config.doTrigEvMixing.value && !collision.trigEv()) { - continue; - } - - auto const funcMixing = [this](auto const& collision, auto const& mixingTrigger, auto const& associated, auto const perTriggerWeight) { - HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), associated.phi()), mixingTrigger.eta() - associated.eta(), - mixingTrigger.pt(), associated.pt(), collision.posZ(), static_cast(collision.nGlobalTracks())}; - histFillInfo.weight = perTriggerWeight * - getMcAssocPtScaling(associated) * getMcK0ShortPtScaling(associated) * - getTriggerPtCorrection(mixingTrigger.pt()); - fillAssocsRecoPhotonPcmPair(histFillInfo, collision, associated); - if constexpr (FillMcRecoInfo) { - fillAssocsMcRecoPhotonPcmPair(histFillInfo, collision, associated); - } - }; - corrProcessMixing(collision, photonPcmPairsThisEvent, funcMixing, config.nMixingAt0PhotonPcmPair.value); - } - } - void processRecoPhotonPcmPair(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, soa::Filtered const& photonPcmPairs, aod::V0PhotonsKF const&, aod::V0Legs const&) { - fillProcesRecoPhotonPcmPair(collisions, triggers, photonPcmPairs); + fillProcessRecoMain(collisions, triggers, photonPcmPairs, + [this](auto const& associated) { return fillConditionRecoPhotonPcmPairMix(associated); }); } PROCESS_SWITCH(HadronPhotonCorrelation, processRecoPhotonPcmPair, "process standard for associated photonPcmPair", false); - void processPhotonPcmPairMix(soa::Filtered const& collisions, soa::Filtered const& photonPcms, - aod::V0PhotonsKF const&, aod::V0Legs const&) + void processPhotonPcmPairMix(soa::Filtered const& collisions, soa::Filtered const& photonPcms) { BinningZPvMult const binningZPvMult{{prependVariableWidth(configHist.binsZPvBinning.value), prependVariableWidth(configHist.binsMultBinning.value)}, true}; auto photonPcmsTuple = std::make_tuple(photonPcms); @@ -1648,7 +1612,7 @@ struct HadronPhotonCorrelation { continue; } // reco assoc selection - if (HadronPhotonPcmSelection::getEnergyAsymDiPhoton(photonPcm1.v0PhotonKF(), photonPcm2.v0PhotonKF()) > config.energyAsymmPhotonPairMax.value) { + if (HadronPhotonPcmSelection::getEnergyAsymDiPhoton(photonPcm1, photonPcm2) > config.energyAsymmPhotonPairMax.value) { continue; } @@ -1683,7 +1647,7 @@ struct HadronPhotonCorrelation { // mc true++ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - bool fillMcTrueBasicCondition(auto const& assocParticle) + bool fillConditionMcTrueBasic(auto const& assocParticle) { if (std::abs(assocParticle.eta()) > config.absEtaMax.value) { return false; @@ -1708,6 +1672,44 @@ struct HadronPhotonCorrelation { return false; } + template + void fillPi0EtaMcTrue(auto& histFillInfo, auto const& assocParticle, auto const& isDecaySelfTrig) + { + // mc-to-data scaling + histFillInfo.weight *= getMcAssocPtScalingFromPt(assocParticle.pt()); + + if constexpr (TruthLevelV == TruthLevel::True) { + fillHistMain(histFillInfo); + } + // self trigger + if constexpr (HistFillModeV == HistFillMode::Plain) { + if (isDecaySelfTrig(AssocTypeV)) { + return; + } + } else if constexpr (HistFillModeV == HistFillMode::Correlation) { + if (isDecaySelfTrig()) { + return; + } + } else if constexpr (HistFillModeV == HistFillMode::Mixing) { + } else { + static_assert(AlwaysFalseValue, "histFillMode not found"); + } + fillHistMain(histFillInfo); + // decaying particles extra info + if constexpr (TruthLevelV == TruthLevel::TrueRecoEvRecoPtTrig) { + // chosen decay + if (!isDecayToGG(assocParticle)) { + return; + } + fillHistMain(histFillInfo); + // daughters in acceptance + if (!checkDaughtersInAcceptance(assocParticle, {-config.absEtaMax.value, config.absEtaMax.value})) { + return; + } + fillHistMain(histFillInfo); + } + } + template void fillAssocsMcTrue(auto histFillInfo, auto const& assocParticle, T_DecaySelfTrigFunc const& isDecaySelfTrig = {}) { @@ -1780,76 +1782,12 @@ struct HadronPhotonCorrelation { } // pi0 if (assocParticle.pdgCode() == PDG_t::kPi0) { - // mc-to-data scaling - histFillInfo.weight *= getMcAssocPtScalingFromPt(assocParticle.pt()); - - if constexpr (TruthLevelV == TruthLevel::True) { - fillHistMain(histFillInfo); - } - // self trigger - if constexpr (HistFillModeV == HistFillMode::Plain) { - if (isDecaySelfTrig(AssocType::Pi0Pcm)) { - return; - } - } else if constexpr (HistFillModeV == HistFillMode::Correlation) { - if (isDecaySelfTrig()) { - return; - } - } else if constexpr (HistFillModeV == HistFillMode::Mixing) { - } else { - static_assert(AlwaysFalseValue, "histFillMode not found"); - } - fillHistMain(histFillInfo); - // decaying particles extra info - if constexpr (TruthLevelV == TruthLevel::TrueRecoEvRecoPtTrig) { - // chosen decay - if (!isDecayToGG(assocParticle)) { - return; - } - fillHistMain(histFillInfo); - // daughters in acceptance - if (!checkDaughtersInAcceptance(assocParticle, {-config.absEtaMax.value, config.absEtaMax.value})) { - return; - } - fillHistMain(histFillInfo); - } + fillPi0EtaMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); return; } // eta if (assocParticle.pdgCode() == constants::physics::Pdg::kEta) { - // mc-to-data scaling - histFillInfo.weight *= getMcAssocPtScalingFromPt(assocParticle.pt()); - - if constexpr (TruthLevelV == TruthLevel::True) { - fillHistMain(histFillInfo); - } - // self trigger - if constexpr (HistFillModeV == HistFillMode::Plain) { - if (isDecaySelfTrig(AssocType::EtaPcm)) { - return; - } - } else if constexpr (HistFillModeV == HistFillMode::Correlation) { - if (isDecaySelfTrig()) { - return; - } - } else if constexpr (HistFillModeV == HistFillMode::Mixing) { - } else { - static_assert(AlwaysFalseValue, "histFillMode not found"); - } - fillHistMain(histFillInfo); - // decaying particles extra info - if constexpr (TruthLevelV == TruthLevel::TrueRecoEvRecoPtTrig) { - // chosen decay - if (!isDecayToGG(assocParticle)) { - return; - } - fillHistMain(histFillInfo); - // daughters in acceptance - if (!checkDaughtersInAcceptance(assocParticle, {-config.absEtaMax.value, config.absEtaMax.value})) { - return; - } - fillHistMain(histFillInfo); - } + fillPi0EtaMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); return; } @@ -1868,15 +1806,31 @@ struct HadronPhotonCorrelation { } } - void processMcTrue(soa::Filtered const& mcCollisions, aod::HpcTrueTriggers const& trueTriggers, aod::JetParticles const& mcParticles) + template + void fillProcessMcTrueTrig(auto const& collisions, auto const& trueTriggers, auto const& mcParticles) { - for (auto const& mcCollision : mcCollisions) { + for (auto const& collision : collisions) { + if constexpr (TruthLevelV == TruthLevel::TrueRecoEv) { + if (!isMcMatchedCollision(collision)) { + continue; + } + } + auto const& mcCollision = [&]() { + if constexpr (TruthLevelV == TruthLevel::True) { + return collision; + } else if constexpr (TruthLevelV == TruthLevel::TrueRecoEv) { + return collision.template jetMcCollision_as>(); + } else { + static_assert(AlwaysFalseValue, "truthLevel not found"); + } + }(); + // group collision auto const trueTriggersThisEvent = trueTriggers.sliceBy(perColTrueTriggers, mcCollision.globalIndex()); auto const mcParticlesThisEvent = mcParticles.sliceBy(perColMcParticles, mcCollision.globalIndex()); // self correlation of events (plain) - std::map const decaySelfTrigPlainMap = getDecaySelfTrigPlainMap(trueTriggersThisEvent); + std::map const decaySelfTrigPlainMap = getDecaySelfTrigPlainMap(trueTriggersThisEvent); auto const funcPlain = [this, &decaySelfTrigPlainMap](auto const& mcCollision, auto const& assocParticle) { // self trigger info for decaying particles @@ -1885,7 +1839,7 @@ struct HadronPhotonCorrelation { }; HistFillInfoPlainPhiEtaZPvMult histFillInfo = {mcCollision.ptMax(), assocParticle.pt(), assocParticle.phi(), assocParticle.eta(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; - fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); + fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); }; corrProcessPlain(mcCollision, mcParticlesThisEvent, funcPlain); @@ -1902,7 +1856,7 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(trueTrigger.phi(), assocParticle.phi()), trueTrigger.eta() - assocParticle.eta(), trueTrigger.pt(), assocParticle.pt(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; - fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); + fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); }; corrProcessCorrelation(mcCollision, trueTriggersThisEvent, mcParticlesThisEvent, funcCorrelation); @@ -1915,73 +1869,23 @@ struct HadronPhotonCorrelation { HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), assocParticle.phi()), mixingTrigger.eta() - assocParticle.eta(), mixingTrigger.pt(), assocParticle.pt(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; histFillInfo.weight = perTriggerWeight; - fillAssocsMcTrue(histFillInfo, assocParticle); + fillAssocsMcTrue(histFillInfo, assocParticle); }; - corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, config.nMixingAt0McTrue.value, - [this](auto const& assocParticle) { return fillMcTrueBasicCondition(assocParticle); }); + corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, config.nMixingAt0McTrue.value, + [this](auto const& assocParticle) { return fillConditionMcTrueBasic(assocParticle); }); } } + + void processMcTrue(soa::Filtered const& mcCollisions, aod::HpcTrueTriggers const& trueTriggers, aod::JetParticles const& mcParticles) + { + fillProcessMcTrueTrig(mcCollisions, trueTriggers, mcParticles); + } PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrue, "process mc-true (all collisions) for multiple associated particles", false); void processMcTrueRecoEv(soa::Filtered const& collisions, soa::Filtered const&, aod::HpcTrueTriggers const& trueTriggers, aod::JetParticles const& mcParticles) { - for (auto const& collision : collisions) { - if (!isMcMatchedCollision(collision)) { - continue; - } - - auto const& mcCollision = collision.jetMcCollision_as>(); - - // group collision - auto const trueTriggersThisEvent = trueTriggers.sliceBy(perColTrueTriggers, collision.jetMcCollisionId()); - auto const mcParticlesThisEvent = mcParticles.sliceBy(perColMcParticles, collision.jetMcCollisionId()); - - // self correlation of events (plain) - std::map const decaySelfTrigPlainMap = getDecaySelfTrigPlainMap(trueTriggersThisEvent); - - auto const funcPlain = [this, &decaySelfTrigPlainMap](auto const& mcCollision, auto const& assocParticle) { - // self trigger info for decaying particles - auto const isDecaySelfTrig = [&decaySelfTrigPlainMap](AssocType const assocType) { - return decaySelfTrigPlainMap.at(assocType); - }; - HistFillInfoPlainPhiEtaZPvMult histFillInfo = {mcCollision.ptMax(), assocParticle.pt(), assocParticle.phi(), assocParticle.eta(), - mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; - fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); - }; - corrProcessPlain(mcCollision, mcParticlesThisEvent, funcPlain); - - auto const funcCorrelation = [this](auto const& mcCollision, auto const& trueTrigger, auto const& assocParticle) { - auto const& triggerParticle = trueTrigger.jetMcParticle(); - // self trigger info for decaying particles - auto const isDecaySelfTrig = [this, &assocParticle, &triggerParticle]() { - return producesTrigger(assocParticle, triggerParticle); - }; - // exclude self correlation - if (trueTrigger.jetMcParticleId() == assocParticle.globalIndex()) { - return; - } - - HistFillInfoCorr histFillInfo = {getDeltaPhi(trueTrigger.phi(), assocParticle.phi()), trueTrigger.eta() - assocParticle.eta(), - trueTrigger.pt(), assocParticle.pt(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; - fillAssocsMcTrue(histFillInfo, assocParticle, isDecaySelfTrig); - }; - corrProcessCorrelation(mcCollision, trueTriggersThisEvent, mcParticlesThisEvent, funcCorrelation); - - // select mixing events - if (config.doTrigEvMixing.value && !mcCollision.trigEv()) { - continue; - } - - auto const funcMixing = [this](auto const& mcCollision, auto const& mixingTrigger, auto const& assocParticle, auto const perTriggerWeight) { - HistFillInfoCorr histFillInfo = {getDeltaPhi(mixingTrigger.phi(), assocParticle.phi()), mixingTrigger.eta() - assocParticle.eta(), - mixingTrigger.pt(), assocParticle.pt(), mcCollision.posZ(), static_cast(mcCollision.nChargedInEtaRange())}; - histFillInfo.weight = perTriggerWeight; - fillAssocsMcTrue(histFillInfo, assocParticle); - }; - corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, config.nMixingAt0McTrue.value, - [this](auto const& assocParticle) { return fillMcTrueBasicCondition(assocParticle); }); - } + fillProcessMcTrueTrig(collisions, trueTriggers, mcParticles); } PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueRecoEv, "process mc-true (reco collisions) correlation for multiple associated particles", false); @@ -2052,8 +1956,8 @@ struct HadronPhotonCorrelation { histFillInfo.weight = perTriggerWeight; fillAssocsMcTrue(histFillInfo, assocParticle, []() { return false; }); }; - corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, config.nMixingAt0McTrue.value, - [this](auto const& assocParticle) { return fillMcTrueBasicCondition(assocParticle); }); + corrProcessMixing(mcCollision, mcParticlesThisEvent, funcMixing, config.nMixingAt0McTrue.value, + [this](auto const& assocParticle) { return fillConditionMcTrueBasic(assocParticle); }); } } PROCESS_SWITCH(HadronPhotonCorrelation, processMcTrueRecoEvRecoPtTrig, "process mc-true (reco collisions with reco ptTrig) correlation for multiple associated particles", false); @@ -2087,20 +1991,20 @@ struct HadronPhotonCorrelation { void processMcRecoHadron(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, aod::HpcHadrons const& hadrons) { - fillProcessRecoStd(collisions, triggers, hadrons); + fillProcessRecoMain(collisions, triggers, hadrons); } - PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoHadron, "process standard for associated hardon with additional mc information", false); + PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoHadron, "process standard for associated hadron with additional mc information", false); void processMcRecoPipm(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, aod::HpcPipms const& pipms) { - fillProcessRecoStd(collisions, triggers, pipms); + fillProcessRecoMain(collisions, triggers, pipms); } PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoPipm, "process standard for associated pipm with additional mc information", false); void processMcRecoPhotonPcm(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, soa::Filtered const& photonPcms, aod::V0PhotonsKF const&, aod::V0Legs const&) { - fillProcessRecoStd(collisions, triggers, photonPcms); + fillProcessRecoMain(collisions, triggers, photonPcms); } PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoPhotonPcm, "process standard for associated photonPcm with additional mc information", false); @@ -2173,7 +2077,7 @@ struct HadronPhotonCorrelation { void processMcRecoPhotonPcmPair(soa::Filtered const& collisions, aod::HpcTriggers const& triggers, soa::Filtered const& photonPcmPairs, aod::V0PhotonsKF const&, aod::V0Legs const&) { - fillProcesRecoPhotonPcmPair(collisions, triggers, photonPcmPairs); + fillProcessRecoMain(collisions, triggers, photonPcmPairs); } PROCESS_SWITCH(HadronPhotonCorrelation, processMcRecoPhotonPcmPair, "process correlation for associated photonPcmPair with additional mc information", false); @@ -2269,7 +2173,7 @@ struct HadronPhotonCorrelation { } for (auto const& collision : collisions) { if (!isMcMatchedCollision(collision)) { - histos.fill(HIST("mc/info/h1_pt_noMatch_event"), 0.5); + histos.fill(HIST("mc/info/h1_noMatch_event"), 0.5); continue; } diff --git a/PWGJE/Tasks/hadronPhotonProducer.cxx b/PWGJE/Tasks/hadronPhotonProducer.cxx index 73211cefeb6..f84f6419992 100644 --- a/PWGJE/Tasks/hadronPhotonProducer.cxx +++ b/PWGJE/Tasks/hadronPhotonProducer.cxx @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -89,7 +90,7 @@ struct HadronPhotonProducer { } tableProduction; Configurable zPvMax{"zPvMax", 7, "maximum absZ primary-vertex cut"}; - Configurable occupancyMin{"occupancyMin", 0, "minimum occupancy cut"}; + Configurable occupancyMin{"occupancyMin", -1, "minimum occupancy cut"}; Configurable occupancyMax{"occupancyMax", 2000, "maximum occupancy cut"}; Configurable eventSelections{"eventSelections", "sel8", "JE framework - event selection"}; @@ -130,7 +131,8 @@ struct HadronPhotonProducer { double ptTrueOrigin = -1; }; - // map jetTracks to produced triggers + // map ids + std::map jetToHpcCollisionMap; std::map trackToTriggerMap; HistogramRegistry histos{"histogramRegistry", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; @@ -160,16 +162,27 @@ struct HadronPhotonProducer { return std::tuple(posTrack, negTrack); } + template + std::vector getIntersectTriggerIds(std::initializer_list const& tracks) + { + std::vector intersectTriggerIds; + + for (auto const& track : tracks) { + auto const triggerTrackIt = trackToTriggerMap.find(track.globalIndex()); + if (triggerTrackIt != trackToTriggerMap.end()) { + intersectTriggerIds.push_back(triggerTrackIt->second); + } + } + return intersectTriggerIds; + } + // selections /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // reco only -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - // event selection + // event selection (without trigger skimming) bool checkEventSelection(auto const& collision) { - if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { - return false; - } if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents, applyRctSelection, rctLabel)) { return false; } @@ -194,6 +207,18 @@ struct HadronPhotonProducer { return true; } + // checks v0Photon eta and dcaZ + bool checkPhotonEtaDcaZ(auto const& v0Photon) + { + if (std::abs(v0Photon.eta()) > absEtaMax) { + return false; + } + if (std::abs(v0Photon.dcaZtopv()) < pcmAbsDcaZLim.value[0] || std::abs(v0Photon.dcaZtopv()) > pcmAbsDcaZLim.value[1]) { + return false; + } + return true; + } + // checks pipm selection (just pid (no additional track cuts) bool checkPipmTPCTOF(auto const& track) { @@ -324,6 +349,7 @@ struct HadronPhotonProducer { TruthLevelInfo getMcRecoInfoHadronPipm(auto const& collision, auto const& track) { if (!track.has_mcParticle()) { + histos.fill(HIST("info/h1_noMatch_assoc"), 0.5); return {TruthLevel::Reco, -1}; } auto const& mcParticle = track.mcParticle(); @@ -351,6 +377,7 @@ struct HadronPhotonProducer { auto const [posTrack, negTrack] = getV0LegJetTracks(v0Photon, tracks); if (!posTrack.has_mcParticle() || !negTrack.has_mcParticle()) { + histos.fill(HIST("info/h1_noMatch_assoc"), 0.5); truthLevelInfo.truthLevel = TruthLevel::Reco; return {truthLevelInfo, impurityInfo}; } @@ -404,6 +431,7 @@ struct HadronPhotonProducer { auto const [posTrack1, negTrack1] = getV0LegJetTracks(v0Photon1, tracks); auto const [posTrack2, negTrack2] = getV0LegJetTracks(v0Photon2, tracks); if (!posTrack1.has_mcParticle() || !negTrack1.has_mcParticle() || !posTrack2.has_mcParticle() || !negTrack2.has_mcParticle()) { + histos.fill(HIST("info/h1_noMatch_assoc"), 0.5); truthLevelInfo.truthLevel = TruthLevel::Reco; return {truthLevelInfo, impurityInfo}; } @@ -489,7 +517,8 @@ struct HadronPhotonProducer { throw std::runtime_error("invalid doprocess-collisionTrigger config"); } if (static_cast(doprocessRecoHadronPipmTPCTOF) + static_cast(doprocessMcRecoHadronPipmTPCTOF) + - static_cast(doprocessRecoHadronPipmTPC) + static_cast(doprocessMcRecoHadronPipmTPC) > 1) { + static_cast(doprocessRecoHadronPipmTPC) + static_cast(doprocessMcRecoHadronPipmTPC) > + 1) { throw std::runtime_error("invalid doprocess-hadronPipm config"); } if (static_cast(doprocessRecoPhotonPcm) + static_cast(doprocessMcRecoPhotonPcm) > 1) { @@ -497,6 +526,7 @@ struct HadronPhotonProducer { } // histograms + AxisSpec const axisN{1, 0., 1., "#it{N}_{something}"}; AxisSpec const axisZPv{40, -10, 10, "#it{z}_{pv}"}; AxisSpec const axisMult{101, -0.5, 100.5, "multiplicity"}; AxisSpec const axisHadronicRate{1001, -0.5, 1000.5, "hadronicRate"}; @@ -515,14 +545,22 @@ struct HadronPhotonProducer { // true histos.add("true/h2_zPvMult", "h2_zPvMult", kTH2D, {axisZPv, axisMult}, true); histos.add("true/h3_ptPhiEta_trigger", "h3_ptPhiEta_trigger", kTH3D, {axisPt, axisPhi, axisEta}, true); + // info + // count missing mc match (should be 0 in output) + histos.add("info/h1_noMatch_assoc", "h1_noMatch_assoc", kTH1D, {axisN}, true); } void fillProcessRecoCollisionTrigger(auto const& collisions, auto const& tracks) { // clear mapping at start of dataframe (in first process) + jetToHpcCollisionMap.clear(); trackToTriggerMap.clear(); for (auto const& collision : collisions) { + // skip non-triggered events + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + continue; + } // event selection bool const isSelectedEvent = checkEventSelection(collision); @@ -537,7 +575,6 @@ struct HadronPhotonProducer { } // maximum track pt float maxTrackPt = -1; - int maxTriggerCollisionId = -1; int maxTriggerGlobalIndex = -1; float maxTriggerPhi = 0; float maxTriggerEta = 0; @@ -554,7 +591,6 @@ struct HadronPhotonProducer { nGlobalTracks++; if (track.pt() > maxTrackPt) { maxTrackPt = track.pt(); - maxTriggerCollisionId = track.collisionId(); maxTriggerGlobalIndex = track.globalIndex(); maxTriggerPhi = track.phi(); maxTriggerEta = track.eta(); @@ -572,7 +608,7 @@ struct HadronPhotonProducer { // trigger info histos.fill(HIST("reco/h3_ptPhiEta_trigger"), track.pt(), track.phi(), track.eta()); - tableProduction.trigger(track.collisionId(), + tableProduction.trigger(tableProduction.collision.lastIndex() + 1, track.pt(), track.phi(), track.eta()); tableProduction.triggerTrackId(track.globalIndex()); trackToTriggerMap[track.globalIndex()] = tableProduction.trigger.lastIndex(); @@ -580,7 +616,7 @@ struct HadronPhotonProducer { bool const isTriggerEvent = maxTrackPt > ptTrigMin; if (oneTriggerPerEvent && isSelectedEvent && isTriggerEvent) { histos.fill(HIST("reco/h3_ptPhiEta_trigger"), maxTrackPt, maxTriggerPhi, maxTriggerEta); - tableProduction.trigger(maxTriggerCollisionId, + tableProduction.trigger(tableProduction.collision.lastIndex() + 1, maxTrackPt, maxTriggerPhi, maxTriggerEta); tableProduction.triggerTrackId(maxTriggerGlobalIndex); trackToTriggerMap[maxTriggerGlobalIndex] = tableProduction.trigger.lastIndex(); @@ -595,6 +631,7 @@ struct HadronPhotonProducer { if constexpr (IsCollisionMCD) { tableProduction.collisionMcId(collision.mcCollisionId()); } + jetToHpcCollisionMap[collision.globalIndex()] = tableProduction.collision.lastIndex(); } } @@ -614,6 +651,10 @@ struct HadronPhotonProducer { void fillProcessRecoHadronPipm(auto const& collisions, auto const& tracks) { for (auto const& collision : collisions) { + // skip non-triggered events + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + continue; + } // event selection if (!checkEventSelection(collision)) { continue; @@ -624,18 +665,13 @@ struct HadronPhotonProducer { // hadron/pipm for (auto const& track : tracksThisEvent) { - std::vector intersectTriggerIds; - // track selection if (!checkTrackCuts(track)) { continue; } // get possible overlap with triggers - auto const triggerTrackIt = trackToTriggerMap.find(track.globalIndex()); - if (triggerTrackIt != trackToTriggerMap.end()) { - intersectTriggerIds.push_back(triggerTrackIt->second); - } + std::vector const intersectTriggerIds = getIntersectTriggerIds({track}); // mc reco info TruthLevelInfo const truthLevelInfoHadron = [&] { @@ -649,7 +685,7 @@ struct HadronPhotonProducer { // hadron info if (track.pt() > ptMinHadron) { histos.fill(HIST("reco/h3_ptPhiEta_hadron"), track.pt(), track.phi(), track.eta()); - tableProduction.hadron(track.collisionId(), intersectTriggerIds, + tableProduction.hadron(jetToHpcCollisionMap.at(collision.globalIndex()), intersectTriggerIds, track.pt(), track.phi(), track.eta(), static_cast(truthLevelInfoHadron.truthLevel), truthLevelInfoHadron.ptTruePure); tableProduction.hadronTrackId(track.globalIndex()); @@ -678,7 +714,7 @@ struct HadronPhotonProducer { // pipm info histos.fill(HIST("reco/h3_ptPhiEta_pipm"), track.pt(), track.phi(), track.eta()); - tableProduction.pipm(track.collisionId(), intersectTriggerIds, + tableProduction.pipm(jetToHpcCollisionMap.at(collision.globalIndex()), intersectTriggerIds, track.pt(), track.phi(), track.eta(), static_cast(truthLevelInfoPipm.truthLevel), truthLevelInfoPipm.ptTruePure); tableProduction.pipmTrackId(track.globalIndex()); @@ -719,6 +755,10 @@ struct HadronPhotonProducer { void fillProcessRecoPhotonPcm(auto const& collisions, auto const& v0Photons, auto const& tracks) { for (auto const& collision : collisions) { + // skip non-triggered events + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + continue; + } // event selection if (!checkEventSelection(collision)) { continue; @@ -727,20 +767,8 @@ struct HadronPhotonProducer { // photonsPcm (for some reason collisionId not an index column (?)) auto const v0PhotonsThisEvent = v0Photons.sliceBy(perColV0Photons, collision.collisionId()); - auto const checkPhotonEtaDcaZ = [this](auto const& v0Photon) { - if (std::abs(v0Photon.eta()) > absEtaMax) { - return false; - } - if (std::abs(v0Photon.dcaZtopv()) < pcmAbsDcaZLim.value[0] || std::abs(v0Photon.dcaZtopv()) > pcmAbsDcaZLim.value[1]) { - return false; - } - return true; - }; - // photonPcm for (auto const& v0Photon : v0PhotonsThisEvent) { - std::vector intersectTriggerIds; - // photon selection if (!checkPhotonEtaDcaZ(v0Photon)) { continue; @@ -750,14 +778,7 @@ struct HadronPhotonProducer { auto const [posTrack, negTrack] = getV0LegJetTracks(v0Photon, tracks); // get possible overlap with triggers - auto const triggerPosTrackIt = trackToTriggerMap.find(posTrack.globalIndex()); - if (triggerPosTrackIt != trackToTriggerMap.end()) { - intersectTriggerIds.push_back(triggerPosTrackIt->second); - } - auto const triggerNegTrackIt = trackToTriggerMap.find(negTrack.globalIndex()); - if (triggerNegTrackIt != trackToTriggerMap.end()) { - intersectTriggerIds.push_back(triggerNegTrackIt->second); - } + std::vector const intersectTriggerIds = getIntersectTriggerIds({posTrack, negTrack}); // mc reco info auto const [truthLevelInfoPhotonPcm, impurityInfoPhotonPcm] = [&] { @@ -770,7 +791,7 @@ struct HadronPhotonProducer { // photonPcm info histos.fill(HIST("reco/h3_ptPhiEta_photonPcm"), v0Photon.pt(), v0Photon.phi(), v0Photon.eta()); - tableProduction.photonPcm(collision.globalIndex(), intersectTriggerIds, + tableProduction.photonPcm(jetToHpcCollisionMap.at(collision.globalIndex()), intersectTriggerIds, v0Photon.pt(), v0Photon.phi(), v0Photon.eta(), static_cast(truthLevelInfoPhotonPcm.truthLevel), truthLevelInfoPhotonPcm.ptTruePure, static_cast(impurityInfoPhotonPcm.impurity), impurityInfoPhotonPcm.ptTrueOrigin); @@ -780,8 +801,6 @@ struct HadronPhotonProducer { // photonPcmPair for (auto const& [v0Photon1, v0Photon2] : soa::combinations(soa::CombinationsStrictlyUpperIndexPolicy(v0PhotonsThisEvent, v0PhotonsThisEvent))) { - std::vector intersectTriggerIds; - // get kinematics ROOT::Math::PtEtaPhiMVector const p4V0Pcm1(v0Photon1.pt(), v0Photon1.eta(), v0Photon1.phi(), 0.); ROOT::Math::PtEtaPhiMVector const p4V0Pcm2(v0Photon2.pt(), v0Photon2.eta(), v0Photon2.phi(), 0.); @@ -800,22 +819,7 @@ struct HadronPhotonProducer { auto const [posTrack2, negTrack2] = getV0LegJetTracks(v0Photon2, tracks); // get possible overlap with triggers - auto const triggerPosTrack1It = trackToTriggerMap.find(posTrack1.globalIndex()); - if (triggerPosTrack1It != trackToTriggerMap.end()) { - intersectTriggerIds.push_back(triggerPosTrack1It->second); - } - auto const triggerNegTrack1It = trackToTriggerMap.find(negTrack1.globalIndex()); - if (triggerNegTrack1It != trackToTriggerMap.end()) { - intersectTriggerIds.push_back(triggerNegTrack1It->second); - } - auto const triggerPosTrack2It = trackToTriggerMap.find(posTrack2.globalIndex()); - if (triggerPosTrack2It != trackToTriggerMap.end()) { - intersectTriggerIds.push_back(triggerPosTrack2It->second); - } - auto const triggerNegTrack2It = trackToTriggerMap.find(negTrack2.globalIndex()); - if (triggerNegTrack2It != trackToTriggerMap.end()) { - intersectTriggerIds.push_back(triggerNegTrack2It->second); - } + std::vector const intersectTriggerIds = getIntersectTriggerIds({posTrack1, negTrack1, posTrack2, negTrack2}); // mc reco info auto const [truthLevelInfoPi0Pcm, photonImpurityInfoPi0Pcm] = [&] { @@ -836,7 +840,7 @@ struct HadronPhotonProducer { // photonPcmPair info histos.fill(HIST("reco/h3_ptPhiEta_photonPcmPair"), p4V0PcmPair.Pt(), RecoDecay::constrainAngle(p4V0PcmPair.Phi(), 0), p4V0PcmPair.Eta()); - tableProduction.photonPcmPair(collision.globalIndex(), intersectTriggerIds, + tableProduction.photonPcmPair(jetToHpcCollisionMap.at(collision.globalIndex()), intersectTriggerIds, p4V0PcmPair.Pt(), RecoDecay::constrainAngle(p4V0PcmPair.Phi(), 0), p4V0PcmPair.Eta(), p4V0PcmPair.M(), static_cast(truthLevelInfoPi0Pcm.truthLevel), static_cast(truthLevelInfoEtaPcm.truthLevel), ptTruePurePhotonPcmPair, static_cast(photonImpurityInfoPi0Pcm.impurity), photonImpurityInfoPi0Pcm.ptTrueOrigin); @@ -874,7 +878,6 @@ struct HadronPhotonProducer { int const nSelectSplitMcEv = getThirdFourthDecimalTruePosZ(mcCollision) % nTimesSplitMcEv.value + 1; // maximum charged particle pt float maxChargedPt = -1; - int maxTriggerCollisionId = -1; int maxTriggerGlobalIndex = -1; float maxTriggerPhi = 0; float maxTriggerEta = 0; @@ -898,7 +901,6 @@ struct HadronPhotonProducer { nCharged++; if (mcParticle.pt() > maxChargedPt) { maxChargedPt = mcParticle.pt(); - maxTriggerCollisionId = mcParticle.mcCollisionId(); maxTriggerGlobalIndex = mcParticle.globalIndex(); maxTriggerPhi = mcParticle.phi(); maxTriggerEta = mcParticle.eta(); @@ -914,13 +916,13 @@ struct HadronPhotonProducer { // trigger info histos.fill(HIST("true/h3_ptPhiEta_trigger"), mcParticle.pt(), mcParticle.phi(), mcParticle.eta()); - tableProduction.trueTrigger(mcParticle.mcCollisionId(), mcParticle.globalIndex(), + tableProduction.trueTrigger(mcCollision.globalIndex(), mcParticle.globalIndex(), mcParticle.pt(), mcParticle.phi(), mcParticle.eta()); } bool const isTriggerEvent = maxChargedPt > ptTrigMin; if (oneTriggerPerEvent && isTriggerEvent) { histos.fill(HIST("true/h3_ptPhiEta_trigger"), maxChargedPt, maxTriggerPhi, maxTriggerEta); - tableProduction.trueTrigger(maxTriggerCollisionId, maxTriggerGlobalIndex, + tableProduction.trueTrigger(mcCollision.globalIndex(), maxTriggerGlobalIndex, maxChargedPt, maxTriggerPhi, maxTriggerEta); } From 9f4df3f0fa4d644f5eb3e87379126fbe6158e5a1 Mon Sep 17 00:00:00 2001 From: jkinner2 Date: Fri, 27 Nov 2026 18:13:58 +0100 Subject: [PATCH 10/13] preparePR --- .../TableProducer/photonconversionbuilder.h | 4 +- PWGJE/Tasks/hadronPhotonCorrelation.cxx | 63 +++++++------------ PWGJE/Tasks/hadronPhotonProducer.cxx | 13 ++-- 3 files changed, 30 insertions(+), 50 deletions(-) diff --git a/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.h b/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.h index 2fafaadaff0..fff39a0df75 100644 --- a/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.h +++ b/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.h @@ -2533,9 +2533,7 @@ struct PhotonConversionBuilder { } if (nGreedyFallback > 0) { - LOGF(warning, "group matching: %d conflict group(s) larger than dedupMaxGroupSize = %d of nGroups = %li were solved greedily", nGreedyFallback, maxEnum, groups.size()); - } else { - LOGF(warning, "group matching: groups = %li", groups.size()); + LOGF(warning, "group matching: %d conflict group(s) larger than dedupMaxGroupSize = %d were solved greedily", nGreedyFallback, maxEnum); } // the table expects candidates ordered by collision diff --git a/PWGJE/Tasks/hadronPhotonCorrelation.cxx b/PWGJE/Tasks/hadronPhotonCorrelation.cxx index 668b39fc22a..f879882316f 100644 --- a/PWGJE/Tasks/hadronPhotonCorrelation.cxx +++ b/PWGJE/Tasks/hadronPhotonCorrelation.cxx @@ -533,13 +533,13 @@ struct HadronPhotonCorrelation { return result; } - static std::vector getBinEdges(TH1 const* h1) + static std::vector getBinEdges(TAxis const* axis) { std::vector edges; - for (int iBin = 1; iBin <= h1->GetNbinsX(); iBin++) { - edges.push_back(h1->GetXaxis()->GetBinLowEdge(iBin)); + for (int iBin = 1; iBin <= axis->GetNbins(); iBin++) { + edges.push_back(axis->GetBinLowEdge(iBin)); } - edges.push_back(h1->GetXaxis()->GetXmax()); + edges.push_back(axis->GetXmax()); return edges; } @@ -551,7 +551,7 @@ struct HadronPhotonCorrelation { if (config.applyTriggerPtCorrection.value) { h1PtCorrectionTrigger = ccdb->getForTimeStamp(config.pathCcdbAnalysis.value + "/correction/trigger", noLaterThanCcdb); - const AxisSpec axis{getBinEdges(h1PtCorrectionTrigger), "#it{p}_{T}"}; + const AxisSpec axis{getBinEdges(h1PtCorrectionTrigger->GetXaxis()), "#it{p}_{T}"}; histos.add("usedObjectsCcdb/h1_pt_correction_trigger_ccdb", "h1_pt_correction_trigger_ccdb", kTH1D, {axis}, true); for (int iBin = 0; iBin <= h1PtCorrectionTrigger->GetNbinsX() + 1; iBin++) { histos.get(HIST("usedObjectsCcdb/h1_pt_correction_trigger_ccdb"))->SetBinContent(iBin, h1PtCorrectionTrigger->GetBinContent(iBin)); @@ -562,7 +562,7 @@ struct HadronPhotonCorrelation { if (config.applyScalingK0ShortPt.value) { h1PtScalingK0Short = ccdb->getForTimeStamp(config.pathCcdbAnalysis.value + "/scaling/K0Short", noLaterThanCcdb); - const AxisSpec axis{getBinEdges(h1PtScalingK0Short), "#it{p}_{T}"}; + const AxisSpec axis{getBinEdges(h1PtScalingK0Short->GetXaxis()), "#it{p}_{T}"}; histos.add("usedObjectsCcdb/h1_pt_scaling_K0Short_ccdb", "h1_pt_scaling_K0Short_ccdb", kTH1D, {axis}, true); for (int iBin = 0; iBin <= h1PtScalingK0Short->GetNbinsX() + 1; iBin++) { histos.get(HIST("usedObjectsCcdb/h1_pt_scaling_K0Short_ccdb"))->SetBinContent(iBin, h1PtScalingK0Short->GetBinContent(iBin)); @@ -845,13 +845,10 @@ struct HadronPhotonCorrelation { if (daughters.size() != NDaughtersToGG) { return false; } - auto daughter = daughters.begin(); - auto daughterEnd = daughters.end(); - while (daughter != daughterEnd) { - if ((*daughter).pdgCode() != PDG_t::kGamma) { + for (auto const& daughter : daughters) { + if (daughter.pdgCode() != PDG_t::kGamma) { return false; } - daughter++; } return true; } @@ -873,24 +870,21 @@ struct HadronPhotonCorrelation { return false; } auto const mothers = mcParticle.template mothers_as(); - auto mother = mothers.begin(); - auto motherEnd = mothers.end(); - while (mother != motherEnd) { + for (auto const& mother : mothers) { // exclude pre-hadonisation int const statusPreHadronisationCut = 80; - if ((*mother).producedByGenerator() && std::abs((*mother).getGenStatusCode()) < statusPreHadronisationCut) { + if (mother.producedByGenerator() && std::abs(mother.getGenStatusCode()) < statusPreHadronisationCut) { return false; } // check valid associated particle - if ((*mother).pdgCode() == pdgCode || (*mother).pdgCode() == -pdgCode) { - if (std::abs((*mother).eta()) < config.absEtaMax.value && isDecayPrimary(*mother)) { + if (mother.pdgCode() == pdgCode || mother.pdgCode() == -pdgCode) { + if (std::abs(mother.eta()) < config.absEtaMax.value && isDecayPrimary(mother)) { return true; } } - if (checkForAssocDecay(*mother, assocType)) { + if (checkForAssocDecay(mother, assocType)) { return true; } - mother++; } return false; } @@ -902,29 +896,26 @@ struct HadronPhotonCorrelation { for (AssocType const& assocType : {AssocType::Pi0Pcm, AssocType::EtaPcm}) { decaySelfTrigPlainMap[assocType] = [&]() { - auto trigger = triggersThisEvent.begin(); - auto triggerEnd = triggersThisEvent.end(); // false for no triggers - if (trigger == triggerEnd) { + if (triggersThisEvent.size() == 0) { return false; } // check every trigger for self trigger and return false if unrelated (event triggers independently) - while (trigger != triggerEnd) { + for (auto const& trigger : triggersThisEvent) { if constexpr (TruthLevelV == TruthLevel::TrueRecoEvRecoPtTrig) { - if (!isMcMatchedTrigger(*trigger)) { + if (!isMcMatchedTrigger(trigger)) { return false; } - if (!checkForAssocDecay((*trigger).template jetTrack_as().mcParticle(), assocType)) { + if (!checkForAssocDecay(trigger.template jetTrack_as().mcParticle(), assocType)) { return false; } } else if constexpr (TruthLevelV == TruthLevel::TrueRecoEv || TruthLevelV == TruthLevel::True) { - if (!checkForAssocDecay((*trigger).jetMcParticle(), assocType)) { + if (!checkForAssocDecay(trigger.jetMcParticle(), assocType)) { return false; } } else { static_assert(AlwaysFalseValue, "truthLevel not found"); } - trigger++; } return true; }(); @@ -943,16 +934,13 @@ struct HadronPhotonCorrelation { return false; } auto const daughters = mcParticle.template daughters_as(); - auto daughter = daughters.begin(); - auto daughterEnd = daughters.end(); - while (daughter != daughterEnd) { - if ((*daughter).globalIndex() == triggerParticle.globalIndex()) { + for (auto const& daughter : daughters) { + if (daughter.globalIndex() == triggerParticle.globalIndex()) { return true; } - if (producesTrigger(*daughter, triggerParticle, visited)) { + if (producesTrigger(daughter, triggerParticle, visited)) { return true; } - daughter++; } return false; } @@ -968,16 +956,13 @@ struct HadronPhotonCorrelation { bool checkDaughtersInAcceptance(auto const& mcParticle, std::pair const etaRange, std::pair const phiRange = {0, constants::math::TwoPI}) { auto const& daughters = mcParticle.template daughters_as(); - auto daughter = daughters.begin(); - auto daughterEnd = daughters.end(); - while (daughter != daughterEnd) { - if ((*daughter).eta() < etaRange.first || (*daughter).eta() > etaRange.second) { + for (auto const& daughter : daughters) { + if (daughter.eta() < etaRange.first || daughter.eta() > etaRange.second) { return false; } - if ((*daughter).phi() < phiRange.first || (*daughter).phi() > phiRange.second) { + if (daughter.phi() < phiRange.first || daughter.phi() > phiRange.second) { return false; } - daughter++; } return true; } diff --git a/PWGJE/Tasks/hadronPhotonProducer.cxx b/PWGJE/Tasks/hadronPhotonProducer.cxx index f84f6419992..e53d52836a0 100644 --- a/PWGJE/Tasks/hadronPhotonProducer.cxx +++ b/PWGJE/Tasks/hadronPhotonProducer.cxx @@ -275,21 +275,18 @@ struct HadronPhotonProducer { return std::nullopt; } auto const mothers = mcParticle.template mothers_as(); - auto mother = mothers.begin(); - auto motherEnd = mothers.end(); - while (mother != motherEnd) { + for (auto const& mother : mothers) { // optional exclude pre-hadonisation int const statusPreHadronisationCut = 80; - if (!includePreHadronisation && (*mother).producedByGenerator() && std::abs((*mother).getGenStatusCode()) < statusPreHadronisationCut) { + if (!includePreHadronisation && mother.producedByGenerator() && std::abs(mother.getGenStatusCode()) < statusPreHadronisationCut) { return std::nullopt; } - if ((*mother).pdgCode() == pdgCode || (checkAntiParticle && (*mother).pdgCode() == -pdgCode)) { - return (*mother).pt(); + if (mother.pdgCode() == pdgCode || (checkAntiParticle && mother.pdgCode() == -pdgCode)) { + return mother.pt(); } - if (auto const ptMother = checkForMother(*mother, pdgCode, checkAntiParticle, includePreHadronisation)) { + if (auto const ptMother = checkForMother(mother, pdgCode, checkAntiParticle, includePreHadronisation)) { return ptMother; } - mother++; } return std::nullopt; } From 8638cc6eae95c9b29869dc97892c2c41d068343e Mon Sep 17 00:00:00 2001 From: jkinner2 Date: Tue, 1 Dec 2026 10:05:06 +0100 Subject: [PATCH 11/13] fixMegaLinterErrors --- PWGJE/Tasks/hadronPhotonCorrelation.cxx | 10 ++++++---- PWGJE/Tasks/hadronPhotonCorrelationSim.cxx | 23 ++++++++++++---------- PWGJE/Tasks/hadronPhotonProducer.cxx | 2 +- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/PWGJE/Tasks/hadronPhotonCorrelation.cxx b/PWGJE/Tasks/hadronPhotonCorrelation.cxx index f879882316f..db1f7263fe7 100644 --- a/PWGJE/Tasks/hadronPhotonCorrelation.cxx +++ b/PWGJE/Tasks/hadronPhotonCorrelation.cxx @@ -340,11 +340,11 @@ struct HadronPhotonCorrelation { }; struct HistFillInfoPlainPhiEtaZPvMult { - double ptMax, ptAssoc, phi, eta, zPv, mult; + double ptMax = -1, ptAssoc = -1, phi = 0, eta = 0, zPv = 0, mult = -1; double weight = 1; }; struct HistFillInfoCorr { - double dPhi, dEta, ptTrig, ptAssoc, zPv, mult; + double dPhi = 0, dEta = 0, ptTrig = -1, ptAssoc = -1, zPv = 0, mult = -1; double weight = 1; }; @@ -1300,8 +1300,10 @@ struct HadronPhotonCorrelation { const size_t iStartTrigger = randomIntInInterval(0, config.iTriggerStartFraction.value * nSavedTriggers); // associated loop for (auto const& associated : associatedThisEvent) { - if (!funcConditionAssocOnly(associated)) { - continue; + if constexpr (!std::is_same_v) { + if (!funcConditionAssocOnly(associated)) { + continue; + } } // trigger settings const size_t nTriggerMixing = nMixingPtPowerScaling(nTriggerMixingAt0, associated.pt()); diff --git a/PWGJE/Tasks/hadronPhotonCorrelationSim.cxx b/PWGJE/Tasks/hadronPhotonCorrelationSim.cxx index de4f8e5d32a..44c33f84478 100644 --- a/PWGJE/Tasks/hadronPhotonCorrelationSim.cxx +++ b/PWGJE/Tasks/hadronPhotonCorrelationSim.cxx @@ -99,16 +99,16 @@ struct HadronPhotonCorrelationSim { 0.2, 0.5, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 9.0f, 11.0f, 15.0f}, "p_{T, assoc} [GeV]"}; // Axis for associated particle pt distribution ConfigurableAxis axisDeltaPt = {"axisDeltaPt", {200, 0., 1.2}, "#Delta p_T"}; // Axis for pt ratio between neutral hadrons and decay photons - int nHadrons = 6; - AxisSpec axisPid = {10, -3.5, nHadrons + 0.5, "pid"}; // Axis for PID of neutral hadrons + int nHadron = 6; + AxisSpec axisPid = {10, -3.5, nHadron + 0.5, "pid"}; // Axis for PID of neutral hadrons ConfigurableAxis axisMult = {"axisMult", {100, 0., 99.}, "N_{ch}"}; // Axis for mutplipicity AxisSpec axisAlpha = {100, 0., 1., "alpha"}; // Axis for decay photon pt assymetry ConfigurableAxis axisDeltaRDecay = {"axisDeltaRDecay", {400, 0., 3.2}, "#Delta R"}; // Axis for Delta R = sqrt(Delta eta^2 + Delta phi^2) between neutral hadrons and decay photons - float ptMinTrig; - float ptMaxTrig; - float ptMinAssoc; - float ptMaxAssoc; + float ptMinTrig = -1; + float ptMaxTrig = -1; + float ptMinAssoc = -1; + float ptMaxAssoc = -1; // TPythia8Decayer* decayer = new TPythia8Decayer; // TLorentzVector* motherLV = new TLorentzVector(); // o2-linter: disable= root/lorentz-vector (TLorentzVector is needed for TPythia8Decayer) @@ -338,7 +338,10 @@ struct HadronPhotonCorrelationSim { template static auto test(U* ptr) -> decltype(ptr->has_mcParticle(), std::true_type{}); static std::false_type test(...); - static constexpr bool Value = decltype(test(std::declval()))::value; + static constexpr bool Value() + { + return decltype(test(std::declval()))::value; + } }; // Initialize track @@ -347,7 +350,7 @@ struct HadronPhotonCorrelationSim { { // if constexpr (HasHasMcParticle) { - if constexpr (HasHasMcParticle::Value) { + if constexpr (HasHasMcParticle::Value()) { if (!track.has_mcParticle()) { return false; } @@ -416,7 +419,7 @@ struct HadronPhotonCorrelationSim { bool initTrig(const T& track) { // if constexpr (HasHasMcParticle) { - if constexpr (HasHasMcParticle::Value) { + if constexpr (HasHasMcParticle::Value()) { if (!track.has_mcParticle()) { return false; } @@ -990,7 +993,7 @@ struct HadronPhotonCorrelationSim { // Use PYTHIA to simulate decay /*decayer->Init(); - for (int pid = 1; pid <= nHadrons; pid++) { + for (int pid = 1; pid <= nHadron; pid++) { TParticlePDG* pdgParticle = nullptr; auto it = pidToPdg.find(pid); diff --git a/PWGJE/Tasks/hadronPhotonProducer.cxx b/PWGJE/Tasks/hadronPhotonProducer.cxx index e53d52836a0..0ec2f7245a3 100644 --- a/PWGJE/Tasks/hadronPhotonProducer.cxx +++ b/PWGJE/Tasks/hadronPhotonProducer.cxx @@ -478,7 +478,7 @@ struct HadronPhotonProducer { // returns reco value in case of no mc match int getThirdFourthDecimalTruePosZ(auto const& collision) { - double absPosZ; + double absPosZ = -1; // get third decimal if constexpr (IsCollisionMCD) { From dd25599f5caca586a9a700a565a14c203b0d0986 Mon Sep 17 00:00:00 2001 From: jkinner2 Date: Tue, 1 Dec 2026 10:23:05 +0100 Subject: [PATCH 12/13] fixMegaLinterErrors2 --- PWGJE/Tasks/hadronPhotonCorrelation.cxx | 13 ++++--------- PWGJE/Tasks/hadronPhotonCorrelationSim.cxx | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/PWGJE/Tasks/hadronPhotonCorrelation.cxx b/PWGJE/Tasks/hadronPhotonCorrelation.cxx index db1f7263fe7..c322a8925d4 100644 --- a/PWGJE/Tasks/hadronPhotonCorrelation.cxx +++ b/PWGJE/Tasks/hadronPhotonCorrelation.cxx @@ -1232,12 +1232,7 @@ struct HadronPhotonCorrelation { // generalised correlation functions - struct CorrConditionTrue { - constexpr bool operator()(auto const&) const - { - return true; - } - }; + struct CorrNoCondition {}; // plain info void corrProcessPlain(auto const& collision, auto const& associatedThisEvent, @@ -1267,7 +1262,7 @@ struct HadronPhotonCorrelation { } // mixing - template + template void corrProcessMixing(auto const& collision, auto const& associatedThisEvent, auto const& funcMixing, size_t const nTriggerMixingAt0, T_AssocCondition const& funcConditionAssocOnly = {}) { @@ -1300,7 +1295,7 @@ struct HadronPhotonCorrelation { const size_t iStartTrigger = randomIntInInterval(0, config.iTriggerStartFraction.value * nSavedTriggers); // associated loop for (auto const& associated : associatedThisEvent) { - if constexpr (!std::is_same_v) { + if constexpr (!std::is_same_v) { if (!funcConditionAssocOnly(associated)) { continue; } @@ -1442,7 +1437,7 @@ struct HadronPhotonCorrelation { } } - template + template void fillProcessRecoMain(auto const& collisions, auto const& triggers, auto const& assocs, T_AssocConditionMix const& mixConditionAssocOnly = {}) { for (auto const& collision : collisions) { diff --git a/PWGJE/Tasks/hadronPhotonCorrelationSim.cxx b/PWGJE/Tasks/hadronPhotonCorrelationSim.cxx index 44c33f84478..ef15c5d82ac 100644 --- a/PWGJE/Tasks/hadronPhotonCorrelationSim.cxx +++ b/PWGJE/Tasks/hadronPhotonCorrelationSim.cxx @@ -100,7 +100,7 @@ struct HadronPhotonCorrelationSim { "p_{T, assoc} [GeV]"}; // Axis for associated particle pt distribution ConfigurableAxis axisDeltaPt = {"axisDeltaPt", {200, 0., 1.2}, "#Delta p_T"}; // Axis for pt ratio between neutral hadrons and decay photons int nHadron = 6; - AxisSpec axisPid = {10, -3.5, nHadron + 0.5, "pid"}; // Axis for PID of neutral hadrons + AxisSpec axisPid = {10, -3.5, nHadron + 0.5, "pid"}; // Axis for PID of neutral hadrons ConfigurableAxis axisMult = {"axisMult", {100, 0., 99.}, "N_{ch}"}; // Axis for mutplipicity AxisSpec axisAlpha = {100, 0., 1., "alpha"}; // Axis for decay photon pt assymetry ConfigurableAxis axisDeltaRDecay = {"axisDeltaRDecay", {400, 0., 3.2}, "#Delta R"}; // Axis for Delta R = sqrt(Delta eta^2 + Delta phi^2) between neutral hadrons and decay photons From 5907991593c72b9b119c86c6e55b529668594769 Mon Sep 17 00:00:00 2001 From: jkinner2 Date: Tue, 1 Dec 2026 10:28:00 +0100 Subject: [PATCH 13/13] fixMegaLinterErrors3 --- PWGJE/Tasks/hadronPhotonCorrelation.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PWGJE/Tasks/hadronPhotonCorrelation.cxx b/PWGJE/Tasks/hadronPhotonCorrelation.cxx index c322a8925d4..21ff851d66b 100644 --- a/PWGJE/Tasks/hadronPhotonCorrelation.cxx +++ b/PWGJE/Tasks/hadronPhotonCorrelation.cxx @@ -1232,7 +1232,8 @@ struct HadronPhotonCorrelation { // generalised correlation functions - struct CorrNoCondition {}; + struct CorrNoCondition { + }; // plain info void corrProcessPlain(auto const& collision, auto const& associatedThisEvent,