From acf7757a7ff2f0cbd572c027d6bac68a60f4b3b2 Mon Sep 17 00:00:00 2001 From: Adrian Nassirpour Date: Tue, 17 Jun 2025 13:59:47 +0900 Subject: [PATCH 1/2] [PWGJE]: Adding MC weights for JEJE injections, and adding mask for software triggers --- PWGJE/Tasks/statPromptPhoton.cxx | 169 +++++++++++++++---------------- 1 file changed, 82 insertions(+), 87 deletions(-) diff --git a/PWGJE/Tasks/statPromptPhoton.cxx b/PWGJE/Tasks/statPromptPhoton.cxx index 80ebe23550d..63c2061106b 100644 --- a/PWGJE/Tasks/statPromptPhoton.cxx +++ b/PWGJE/Tasks/statPromptPhoton.cxx @@ -13,40 +13,58 @@ /// \brief Reconstruction of Phi yield through track-track Minv correlations for resonance hadrochemistry analysis. /// /// -/// \author Adrian Fereydon Nassirpour +/// \author Adrian Fereydon Nassirpour -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/DataModel/EMCALClusters.h" -#include "PWGJE/DataModel/JetReducedData.h" +#include -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" +#include +#include +#include +#include + +#include +#include #include "Framework/ASoA.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" -#include -#include -#include -#include -#include +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" -#include -#include -#include +#include "Common/Core/RecoDecay.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "CommonConstants/PhysicsConstants.h" -#include -#include -#include -#include -#include +#include "PWGJE/Core/FastJetUtilities.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/EMCALClusters.h" +#include "EMCALBase/Geometry.h" +#include "EMCALCalib/BadChannelMap.h" + +#include "DataFormatsEMCAL/Cell.h" +#include "DataFormatsEMCAL/Constants.h" +#include "DataFormatsEMCAL/AnalysisCluster.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" + +#include "DetectorsBase/Propagator.h" + +#include "CommonDataFormat/InteractionRecord.h" using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; struct statPromptPhoton { + SliceCache cache; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; Configurable cfgMaxDCArToPVcut{"cfgMaxDCArToPVcut", 0.5, "Track DCAr cut to PV Maximum"}; @@ -85,8 +103,12 @@ struct statPromptPhoton { Configurable cfgGenHistograms{"cfgGenHistograms", false, "Enables Generated histograms"}; Configurable cfgRecHistograms{"cfgRecHistograms", false, "Enables Reconstructed histograms"}; Configurable cfgDataHistograms{"cfgDataHistograms", false, "Enables Data histograms"}; + Configurable cfgSkimmedTrigger{"cfgSkimmedTrigger", false, "Enables trigger for skimmied datasets (2023 onwards)"}; + Configurable cfgTriggerMasks{"cfgTriggerMasks", "", "possible JE Trigger masks: fJetChLowPt,fJetChHighPt,fTrackLowPt,fTrackHighPt,fJetD0ChLowPt,fJetD0ChHighPt,fJetLcChLowPt,fJetLcChHighPt,fEMCALReadout,fJetFullHighPt,fJetFullLowPt,fJetNeutralHighPt,fJetNeutralLowPt,fGammaVeryHighPtEMCAL,fGammaVeryHighPtDCAL,fGammaHighPtEMCAL,fGammaHighPtDCAL,fGammaLowPtEMCAL,fGammaLowPtDCAL,fGammaVeryLowPtEMCAL,fGammaVeryLowPtDCAL"}; Configurable cfgDebug{"cfgDebug", false, "Enables debug information for local running"}; + int trackFilter = -1; + std::vector triggerMaskBits; // INIT void init(InitContext const&) @@ -94,6 +116,7 @@ struct statPromptPhoton { std::vector ptBinning = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.5, 3.0, 4.0, 5.0, 6.0, 8.0, 12.0, 16.0, 20.0, 25.0, 30.0, 40.0, 50.0, 75.0, 100.0, 150.0, 200.0, 300.0, 500.0}; AxisSpec pthadAxis = {ptBinning, "#it{p}_{T}^{had sum} [GeV/c]"}; + triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(cfgTriggerMasks); if (cfgJETracks) { trackFilter = jetderiveddatautilities::initialiseTrackSelection(static_cast(cfgTrackFilter)); } @@ -235,8 +258,11 @@ struct statPromptPhoton { using jMCClusters = o2::soa::Join; using jClusters = o2::soa::Join; - using jselectedCollisions = soa::Join; + using jselectedCollisions = soa::Join; + using jselectedDataCollisions = soa::Join; + // using jselectedDataCollisions = soa::Join; using jfilteredCollisions = soa::Filtered; + using jfilteredDataCollisions = soa::Filtered; using jfilteredMCClusters = soa::Filtered; using jfilteredClusters = soa::Filtered; @@ -588,7 +614,7 @@ struct statPromptPhoton { PresliceUnsorted EMCTrackPerTrack = aod::jemctrack::trackId; int nEventsRecMC_JE = 0; - void processMCRec_JE(jfilteredCollisions::iterator const& collision, jfilteredMCClusters const& mcclusters, jTrackCandidates const& tracks, soa::Join const&, TrackCandidates const&, aod::JMcParticles const&, BcCandidates const&, jEMCtracks const& emctracks) + void processMCRec_JE(jfilteredCollisions::iterator const& collision, jfilteredMCClusters const& mcclusters, jTrackCandidates const& tracks, soa::Join const&, TrackCandidates const&, aod::JMcParticles const&, BcCandidates const&, jEMCtracks const& emctracks, aod::JetMcCollisions const&) { nEventsRecMC_JE++; @@ -613,6 +639,20 @@ struct statPromptPhoton { } histos.fill(HIST("REC_nEvents"), 2.5); + + if(cfgSkimmedTrigger){ + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + return; + } + }//JE Software Triggers + + histos.fill(HIST("REC_nEvents"), 3.5); + + double weight = 1; + if (collision.has_mcCollision()) { + weight = collision.mcCollision().weight(); + } + bool noTrk = true; for (auto& track : tracks) { if (cfgJETracks) { @@ -828,9 +868,9 @@ struct statPromptPhoton { histos.fill(HIST("REC_Cluster_QA"), 4.5); clustertrigger = true; double pthadsum = GetPtHadSum(tracks, mccluster, cfgMinR, cfgMaxR, false, false, true); - histos.fill(HIST("REC_Trigger_V_PtHadSum_Photon"), mccluster.energy(), pthadsum); - histos.fill(HIST("REC_PtHadSum_Photon"), pthadsum); - histos.fill(HIST("REC_Trigger_Energy"), mccluster.energy()); + histos.fill(HIST("REC_Trigger_V_PtHadSum_Photon"), mccluster.energy(), pthadsum, weight); + histos.fill(HIST("REC_PtHadSum_Photon"), pthadsum, weight); + histos.fill(HIST("REC_Trigger_Energy"), mccluster.energy(), weight); } auto ClusterParticles = mccluster.mcParticles_as(); @@ -839,11 +879,6 @@ struct statPromptPhoton { bool goodgentrigger = true; double chPe = 0; for (auto& clusterparticle : ClusterParticles) { - // double etaP = clusterparticle.eta(); - // double etaC = mccluster.eta(); - // double phiP = clusterparticle.phi(); - // double phiC = mccluster.phi(); - // double ptP = clusterparticle.pt(); int cindex = clusterparticle.globalIndex(); double pdgcode = fabs(clusterparticle.pdgCode()); if (!clusterparticle.isPhysicalPrimary()) { @@ -884,8 +919,6 @@ struct statPromptPhoton { histos.fill(HIST("REC_Cluster_ParticleWITHtrack_Phi"), clusterparticle.phi()); histos.fill(HIST("REC_Cluster_ParticleWITHtrack_Eta"), clusterparticle.eta()); histos.fill(HIST("REC_Cluster_ParticleWITHtrack_Pt_Phi"), clusterparticle.pt(), clusterparticle.phi()); - // if (phiPrimeP > (0.12/ptP + TMath::Pi()/18. + 0.035) || - // phiPrimeP < (0.1/ptP/ptP + TMath::Pi()/18. - 0.025) ) { histos.fill(HIST("REC_Cluster_ParticleWITHtrack_Pt_PhiPrime"), ptP, phiPrimeP); if (photontrigger) { histos.fill(HIST("REC_Impurity_ParticleWITHtrack_Pt_PhiPrime"), ptP, phiPrimeP); @@ -904,8 +937,6 @@ struct statPromptPhoton { histos.fill(HIST("REC_Cluster_ParticleWITHOUTtrack_Phi"), clusterparticle.phi()); histos.fill(HIST("REC_Cluster_ParticleWITHOUTtrack_Eta"), clusterparticle.eta()); histos.fill(HIST("REC_Cluster_ParticleWITHOUTtrack_Pt_Phi"), clusterparticle.pt(), clusterparticle.phi()); - // if (phiPrimeP > (0.12/ptP + TMath::Pi()/18. + 0.035) || - // phiPrimeP < (0.1/ptP/ptP + TMath::Pi()/18. - 0.025) ) { histos.fill(HIST("REC_Cluster_ParticleWITHOUTtrack_Pt_PhiPrime"), ptP, phiPrimeP); if (photontrigger) { histos.fill(HIST("REC_Impurity_ParticleWITHOUTtrack_Pt_PhiPrime"), ptP, phiPrimeP); @@ -964,12 +995,12 @@ struct statPromptPhoton { std::cout << "Photon mom 2: " << mom2 << std::endl; } if (std::abs(clusterparticle.getGenStatusCode()) > 19 && std::abs(clusterparticle.getGenStatusCode()) < 90) { - histos.fill(HIST("REC_True_Prompt_Trigger_Energy"), clusterparticle.e()); + histos.fill(HIST("REC_True_Prompt_Trigger_Energy"), clusterparticle.e(), weight); TLorentzVector lRealPhoton; lRealPhoton.SetPxPyPzE(clusterparticle.px(), clusterparticle.py(), clusterparticle.pz(), clusterparticle.e()); double truepthadsum = GetPtHadSum(tracks, lRealPhoton, cfgMinR, cfgMaxR, false, false, false); truephotonPt = clusterparticle.e(); - histos.fill(HIST("REC_TrueTrigger_V_PtHadSum_Photon"), truephotonPt, truepthadsum); + histos.fill(HIST("REC_TrueTrigger_V_PtHadSum_Photon"), truephotonPt, truepthadsum, weight); } } // photon check } // clusterparticle loop @@ -1000,39 +1031,6 @@ struct statPromptPhoton { } } // cluster loop - // auto bc = collision.bc_as(); - // int rnr = bc.runNumber(); - - // std::string rnrstring = std::to_string(rnr); - // if (runs.find(rnrstring) == std::string::npos) { - // std::cout<<"++++++++++++++++++++++++++++++++"<getForTimeStamp(ccdbpath, bc.timestamp()); - // if(grpmag) { - // bfield = std::lround(5.f * grpmag->getL3Current() / 30000.f); - // std::cout<<"++++++++++++++++++++++++++++++++"<getForTimeStamp(ccdbpath, bc.timestamp()); - // if(!grpo) { - // std::cout<<"WE CAN NEITHER FETCH GRPMAG OR GRPO!!! SHIT IS SCREWED"<getNominalL3Field(); - // } - // bfield = 5; - // runs += rnrstring; - // std::cout << "++++++++++++++++++++++++++++++++" << std::endl; - // std::cout << "Run is now appended to string: " << runs << std::endl; - // std::cout << "++++++++++++++++++++++++++++++++" << std::endl; - - // } // check mag field for current run number: done! - // clusters done, now we do the sternheimer tracks for (auto& track : tracks) { bool sterntrigger = false; @@ -1057,19 +1055,9 @@ struct statPromptPhoton { phiPrime = 2 * TMath::Pi() - phiPrime; } - // if (bfield < 0) { - // phiPrime = 2 * TMath::Pi() - phiPrime; - // } - phiPrime = phiPrime + TMath::Pi() / 18.; phiPrime = fmod(phiPrime, 2 * TMath::Pi() / 18.); - // double pt = track.pt(); - // if (phiPrime > (0.12/pt + TMath::Pi()/18. + 0.035) || - // phiPrime < (0.1/pt/pt + TMath::Pi()/18. - 0.025) ) { histos.fill(HIST("REC_Track_PhiPrime_Pt"), phiPrime, track.pt()); - // }//geo cut - // Done with geometric cuts - histos.fill(HIST("REC_Track_Pt"), track.pt()); histos.fill(HIST("REC_Track_Phi"), track.phi()); if (clustertrigger) { @@ -1083,12 +1071,12 @@ struct statPromptPhoton { } } double pthadsum = GetPtHadSum(tracks, track, cfgMinR, cfgMaxR, true, false, true); - histos.fill(HIST("REC_Trigger_V_PtHadSum_Nch"), sternPt, pthadsum); + histos.fill(HIST("REC_Trigger_V_PtHadSum_Nch"), sternPt, pthadsum,weight); if (sterntrigger) { bool doStern = true; double sterncount = 1.0; while (doStern) { - histos.fill(HIST("REC_Trigger_V_PtHadSum_Stern"), sterncount, pthadsum, 2.0 / sternPt); + histos.fill(HIST("REC_Trigger_V_PtHadSum_Stern"), sterncount, pthadsum, (2.0 / sternPt)*weight); if (sterncount < sternPt) { sterncount++; } else { @@ -1103,9 +1091,8 @@ struct statPromptPhoton { PROCESS_SWITCH(statPromptPhoton, processMCRec_JE, "processJE MC data", false); int nEventsData = 0; - void processData(jfilteredCollisions::iterator const& collision, jfilteredClusters const& clusters, jDataTrackCandidates const& tracks, soa::Join const&, TrackCandidates const&, BcCandidates const&, jEMCtracks const& emctracks) + void processData(jfilteredDataCollisions::iterator const& collision, jfilteredClusters const& clusters, jDataTrackCandidates const& tracks, soa::Join const&, TrackCandidates const&, BcCandidates const&, jEMCtracks const& emctracks) { - nEventsData++; if (cfgDebug) { if (nEventsData == 1) { @@ -1113,8 +1100,12 @@ struct statPromptPhoton { } if ((nEventsData + 1) % 10000 == 0) { std::cout << "Processed Data Events: " << nEventsData << std::endl; + std::cout << "Events Trigger Bit: " << collision.triggerSel() << std::endl; + std::cout << "Trigger Mask Bit: " << triggerMaskBits[0] << std::endl; + std::cout << "Trigger Mask Cfg Line: " << cfgTriggerMasks << std::endl; } } + histos.fill(HIST("DATA_nEvents"), 0.5); // required cuts @@ -1124,13 +1115,21 @@ struct statPromptPhoton { return; histos.fill(HIST("DATA_nEvents"), 1.5); - if (cfgEmcTrigger) { if (!collision.isEmcalReadout()) return; } + histos.fill(HIST("DATA_nEvents"), 2.5); + if(cfgSkimmedTrigger){ + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + return; + } + }//JE Software Triggers + + histos.fill(HIST("DATA_nEvents"), 3.5); + bool noTrk = true; for (auto& track : tracks) { @@ -1331,10 +1330,6 @@ struct statPromptPhoton { phiPrime = 2 * TMath::Pi() - phiPrime; } - // if (bfield < 0) { - // phiPrime = 2 * TMath::Pi() - phiPrime; - // } - phiPrime = phiPrime + TMath::Pi() / 18.; phiPrime = fmod(phiPrime, 2 * TMath::Pi() / 18.); double pt = track.pt(); From 3bcf550a3cac69d935c145d3114dab17b3d1d028 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Tue, 17 Jun 2025 10:04:39 +0000 Subject: [PATCH 2/2] Please consider the following formatting changes --- PWGJE/Tasks/statPromptPhoton.cxx | 95 +++++++++++++++----------------- 1 file changed, 45 insertions(+), 50 deletions(-) diff --git a/PWGJE/Tasks/statPromptPhoton.cxx b/PWGJE/Tasks/statPromptPhoton.cxx index 63c2061106b..75fdb2ca5bf 100644 --- a/PWGJE/Tasks/statPromptPhoton.cxx +++ b/PWGJE/Tasks/statPromptPhoton.cxx @@ -15,49 +15,45 @@ /// /// \author Adrian Fereydon Nassirpour -#include - -#include -#include -#include -#include - -#include -#include - -#include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/Track.h" +#include "PWGJE/Core/FastJetUtilities.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/EMCALClusters.h" +#include "PWGJE/DataModel/Jet.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/TrackSelection.h" #include "Common/Core/TrackSelectionDefaults.h" #include "Common/Core/trackUtilities.h" #include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/PIDResponse.h" -#include "CommonConstants/PhysicsConstants.h" - -#include "PWGJE/Core/FastJetUtilities.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/DataModel/EMCALClusters.h" -#include "EMCALBase/Geometry.h" -#include "EMCALCalib/BadChannelMap.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "CommonConstants/PhysicsConstants.h" +#include "CommonDataFormat/InteractionRecord.h" +#include "DataFormatsEMCAL/AnalysisCluster.h" #include "DataFormatsEMCAL/Cell.h" #include "DataFormatsEMCAL/Constants.h" -#include "DataFormatsEMCAL/AnalysisCluster.h" -#include "DataFormatsParameters/GRPObject.h" #include "DataFormatsParameters/GRPMagField.h" - +#include "DataFormatsParameters/GRPObject.h" #include "DetectorsBase/Propagator.h" +#include "EMCALBase/Geometry.h" +#include "EMCALCalib/BadChannelMap.h" +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +#include "ReconstructionDataFormats/Track.h" +#include -#include "CommonDataFormat/InteractionRecord.h" +#include +#include + +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -106,7 +102,7 @@ struct statPromptPhoton { Configurable cfgSkimmedTrigger{"cfgSkimmedTrigger", false, "Enables trigger for skimmied datasets (2023 onwards)"}; Configurable cfgTriggerMasks{"cfgTriggerMasks", "", "possible JE Trigger masks: fJetChLowPt,fJetChHighPt,fTrackLowPt,fTrackHighPt,fJetD0ChLowPt,fJetD0ChHighPt,fJetLcChLowPt,fJetLcChHighPt,fEMCALReadout,fJetFullHighPt,fJetFullLowPt,fJetNeutralHighPt,fJetNeutralLowPt,fGammaVeryHighPtEMCAL,fGammaVeryHighPtDCAL,fGammaHighPtEMCAL,fGammaHighPtDCAL,fGammaLowPtEMCAL,fGammaLowPtDCAL,fGammaVeryLowPtEMCAL,fGammaVeryLowPtDCAL"}; Configurable cfgDebug{"cfgDebug", false, "Enables debug information for local running"}; - + int trackFilter = -1; std::vector triggerMaskBits; @@ -259,10 +255,10 @@ struct statPromptPhoton { using jMCClusters = o2::soa::Join; using jClusters = o2::soa::Join; using jselectedCollisions = soa::Join; - using jselectedDataCollisions = soa::Join; - // using jselectedDataCollisions = soa::Join; + using jselectedDataCollisions = soa::Join; + // using jselectedDataCollisions = soa::Join; using jfilteredCollisions = soa::Filtered; - using jfilteredDataCollisions = soa::Filtered; + using jfilteredDataCollisions = soa::Filtered; using jfilteredMCClusters = soa::Filtered; using jfilteredClusters = soa::Filtered; @@ -639,20 +635,19 @@ struct statPromptPhoton { } histos.fill(HIST("REC_nEvents"), 2.5); - - if(cfgSkimmedTrigger){ + if (cfgSkimmedTrigger) { if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { - return; + return; } - }//JE Software Triggers - + } // JE Software Triggers + histos.fill(HIST("REC_nEvents"), 3.5); - + double weight = 1; if (collision.has_mcCollision()) { weight = collision.mcCollision().weight(); } - + bool noTrk = true; for (auto& track : tracks) { if (cfgJETracks) { @@ -1071,12 +1066,12 @@ struct statPromptPhoton { } } double pthadsum = GetPtHadSum(tracks, track, cfgMinR, cfgMaxR, true, false, true); - histos.fill(HIST("REC_Trigger_V_PtHadSum_Nch"), sternPt, pthadsum,weight); + histos.fill(HIST("REC_Trigger_V_PtHadSum_Nch"), sternPt, pthadsum, weight); if (sterntrigger) { bool doStern = true; double sterncount = 1.0; while (doStern) { - histos.fill(HIST("REC_Trigger_V_PtHadSum_Stern"), sterncount, pthadsum, (2.0 / sternPt)*weight); + histos.fill(HIST("REC_Trigger_V_PtHadSum_Stern"), sterncount, pthadsum, (2.0 / sternPt) * weight); if (sterncount < sternPt) { sterncount++; } else { @@ -1100,9 +1095,9 @@ struct statPromptPhoton { } if ((nEventsData + 1) % 10000 == 0) { std::cout << "Processed Data Events: " << nEventsData << std::endl; - std::cout << "Events Trigger Bit: " << collision.triggerSel() << std::endl; - std::cout << "Trigger Mask Bit: " << triggerMaskBits[0] << std::endl; - std::cout << "Trigger Mask Cfg Line: " << cfgTriggerMasks << std::endl; + std::cout << "Events Trigger Bit: " << collision.triggerSel() << std::endl; + std::cout << "Trigger Mask Bit: " << triggerMaskBits[0] << std::endl; + std::cout << "Trigger Mask Cfg Line: " << cfgTriggerMasks << std::endl; } } @@ -1122,14 +1117,14 @@ struct statPromptPhoton { histos.fill(HIST("DATA_nEvents"), 2.5); - if(cfgSkimmedTrigger){ + if (cfgSkimmedTrigger) { if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { - return; + return; } - }//JE Software Triggers - + } // JE Software Triggers + histos.fill(HIST("DATA_nEvents"), 3.5); - + bool noTrk = true; for (auto& track : tracks) {