From 506fb248604fd89c441e2ef0ea32b45b0c34b60b Mon Sep 17 00:00:00 2001 From: Bong-Hwi Lim Date: Tue, 10 Dec 2024 13:59:03 +0100 Subject: [PATCH] update variable name and add new initializer --- PWGLF/DataModel/LFResonanceTables.h | 110 +- PWGLF/TableProducer/Resonances/CMakeLists.txt | 5 + .../Resonances/resonanceInitializer.cxx | 31 +- .../Resonances/resonanceModuleInitializer.cxx | 1257 +++++++++++++++++ PWGLF/Tasks/Resonances/xi1530Analysis.cxx | 2 +- PWGLF/Tasks/Resonances/xi1530Analysisqa.cxx | 2 +- PWGLF/Utils/collisionCuts.h | 66 +- 7 files changed, 1389 insertions(+), 84 deletions(-) create mode 100644 PWGLF/TableProducer/Resonances/resonanceModuleInitializer.cxx diff --git a/PWGLF/DataModel/LFResonanceTables.h b/PWGLF/DataModel/LFResonanceTables.h index 2c74b52a1b6..fe93c2d5833 100644 --- a/PWGLF/DataModel/LFResonanceTables.h +++ b/PWGLF/DataModel/LFResonanceTables.h @@ -53,13 +53,14 @@ enum { kAllCutsINELg010, kECend, }; -DECLARE_SOA_COLUMN(Cent, cent, float); //! Centrality (Multiplicity) percentile (Default: FT0M) -DECLARE_SOA_COLUMN(Spherocity, spherocity, float); //! Spherocity of the event -DECLARE_SOA_COLUMN(EvtPl, evtPl, float); //! Second harmonic event plane -DECLARE_SOA_COLUMN(EvtPlResAB, evtPlResAB, float); //! Second harmonic event plane resolution of A-B sub events -DECLARE_SOA_COLUMN(EvtPlResAC, evtPlResAC, float); //! Second harmonic event plane resolution of A-C sub events -DECLARE_SOA_COLUMN(EvtPlResBC, evtPlResBC, float); //! Second harmonic event plane resolution of B-C sub events -DECLARE_SOA_COLUMN(BMagField, bMagField, float); //! Magnetic field +DECLARE_SOA_INDEX_COLUMN_FULL(Collision, collision, int, Collisions, "_Col"); //! +DECLARE_SOA_COLUMN(Cent, cent, float); //! Centrality (Multiplicity) percentile (Default: FT0M) +DECLARE_SOA_COLUMN(Spherocity, spherocity, float); //! Spherocity of the event +DECLARE_SOA_COLUMN(EvtPl, evtPl, float); //! Second harmonic event plane +DECLARE_SOA_COLUMN(EvtPlResAB, evtPlResAB, float); //! Second harmonic event plane resolution of A-B sub events +DECLARE_SOA_COLUMN(EvtPlResAC, evtPlResAC, float); //! Second harmonic event plane resolution of A-C sub events +DECLARE_SOA_COLUMN(EvtPlResBC, evtPlResBC, float); //! Second harmonic event plane resolution of B-C sub events +DECLARE_SOA_COLUMN(BMagField, bMagField, float); //! Magnetic field // MC DECLARE_SOA_COLUMN(IsVtxIn10, isVtxIn10, bool); //! Vtx10 DECLARE_SOA_COLUMN(IsINELgt0, isINELgt0, bool); //! INEL>0 @@ -71,6 +72,7 @@ DECLARE_SOA_COLUMN(ImpactParameter, impactParameter, float); //! ImpactParamete } // namespace resocollision DECLARE_SOA_TABLE(ResoCollisions, "AOD", "RESOCOLLISION", o2::soa::Index<>, + resocollision::CollisionId, o2::aod::mult::MultNTracksPV, collision::PosX, collision::PosY, @@ -87,6 +89,7 @@ DECLARE_SOA_TABLE(ResoCollisions, "AOD", "RESOCOLLISION", using ResoCollision = ResoCollisions::iterator; DECLARE_SOA_TABLE(ResoMCCollisions, "AOD", "RESOMCCOL", + o2::soa::Index<>, resocollision::IsVtxIn10, resocollision::IsINELgt0, resocollision::IsTriggerTVX, @@ -95,36 +98,54 @@ DECLARE_SOA_TABLE(ResoMCCollisions, "AOD", "RESOMCCOL", resocollision::ImpactParameter); using ResoMCCollision = ResoMCCollisions::iterator; +DECLARE_SOA_TABLE(ResoSpheroCollisions, "AOD", "RESOSPHEROCOLL", + o2::soa::Index<>, + resocollision::CollisionId, + resocollision::Spherocity); +using ResoSpheroCollision = ResoSpheroCollisions::iterator; + +DECLARE_SOA_TABLE(ResoEvtPlCollisions, "AOD", "RESOEVTPLCOLL", + o2::soa::Index<>, + resocollision::CollisionId, + resocollision::EvtPl, + resocollision::EvtPlResAB, + resocollision::EvtPlResAC, + resocollision::EvtPlResBC); +using ResoEvtPlCollision = ResoEvtPlCollisions::iterator; + // Resonance Daughters // inspired from PWGCF/DataModel/FemtoDerived.h namespace resodaughter { DECLARE_SOA_INDEX_COLUMN(ResoCollision, resoCollision); -DECLARE_SOA_COLUMN(Pt, pt, float); //! p_T (GeV/c) -DECLARE_SOA_COLUMN(Px, px, float); //! p_x (GeV/c) -DECLARE_SOA_COLUMN(Py, py, float); //! p_y (GeV/c) -DECLARE_SOA_COLUMN(Pz, pz, float); //! p_z (GeV/c) -DECLARE_SOA_COLUMN(Eta, eta, float); //! Eta -DECLARE_SOA_COLUMN(Phi, phi, float); //! Phi -DECLARE_SOA_COLUMN(PartType, partType, uint8_t); //! Type of the particle, according to resodaughter::ParticleType -DECLARE_SOA_COLUMN(TempFitVar, tempFitVar, float); //! Observable for the template fitting (Track: DCA_xy, V0: CPA) -DECLARE_SOA_COLUMN(Indices, indices, int[2]); //! Field for the track indices to remove auto-correlations -DECLARE_SOA_COLUMN(CascadeIndices, cascIndices, int[3]); //! Field for the track indices to remove auto-correlations (ordered: positive, negative, bachelor) -DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! Sign of the track charge -DECLARE_SOA_COLUMN(TPCNClsCrossedRows, tpcNClsCrossedRows, uint8_t); //! Number of TPC crossed rows -DECLARE_SOA_COLUMN(TPCNClsFound, tpcNClsFound, uint8_t); //! Number of TPC clusters found -DECLARE_SOA_COLUMN(ITSNCls, itsNCls, uint8_t); //! Number of ITS clusters found -DECLARE_SOA_COLUMN(IsGlobalTrackWoDCA, isGlobalTrackWoDCA, bool); //! Is global track without DCA -DECLARE_SOA_COLUMN(IsGlobalTrack, isGlobalTrack, bool); //! Is global track -DECLARE_SOA_COLUMN(IsPrimaryTrack, isPrimaryTrack, bool); //! Is primary track -DECLARE_SOA_COLUMN(IsPVContributor, isPVContributor, bool); //! Is primary vertex contributor -DECLARE_SOA_COLUMN(HasITS, hasITS, bool); //! Has ITS -DECLARE_SOA_COLUMN(HasTPC, hasTPC, bool); //! Has TPC -DECLARE_SOA_COLUMN(HasTOF, hasTOF, bool); //! Has TOF +DECLARE_SOA_INDEX_COLUMN_FULL(Track, track, int, Tracks, "_Trk"); //! +DECLARE_SOA_INDEX_COLUMN_FULL(V0, v0, int, V0s, "_V0"); //! +DECLARE_SOA_INDEX_COLUMN_FULL(Cascade, cascade, int, Cascades, "_Cas"); //! +DECLARE_SOA_COLUMN(Pt, pt, float); //! p_T (GeV/c) +DECLARE_SOA_COLUMN(Px, px, float); //! p_x (GeV/c) +DECLARE_SOA_COLUMN(Py, py, float); //! p_y (GeV/c) +DECLARE_SOA_COLUMN(Pz, pz, float); //! p_z (GeV/c) +DECLARE_SOA_COLUMN(Eta, eta, float); //! Eta +DECLARE_SOA_COLUMN(Phi, phi, float); //! Phi +DECLARE_SOA_COLUMN(PartType, partType, uint8_t); //! Type of the particle, according to resodaughter::ParticleType +DECLARE_SOA_COLUMN(TempFitVar, tempFitVar, float); //! Observable for the template fitting (Track: DCA_xy, V0: CPA) +DECLARE_SOA_COLUMN(Indices, indices, int[2]); //! Field for the track indices to remove auto-correlations +DECLARE_SOA_COLUMN(CascadeIndices, cascadeIndices, int[3]); //! Field for the track indices to remove auto-correlations (ordered: positive, negative, bachelor) +DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! Sign of the track charge +DECLARE_SOA_COLUMN(TPCNClsCrossedRows, tpcNClsCrossedRows, uint8_t); //! Number of TPC crossed rows +DECLARE_SOA_COLUMN(TPCNClsFound, tpcNClsFound, uint8_t); //! Number of TPC clusters found +DECLARE_SOA_COLUMN(ITSNCls, itsNCls, uint8_t); //! Number of ITS clusters found +DECLARE_SOA_COLUMN(IsGlobalTrackWoDCA, isGlobalTrackWoDCA, bool); //! Is global track without DCA +DECLARE_SOA_COLUMN(IsGlobalTrack, isGlobalTrack, bool); //! Is global track +DECLARE_SOA_COLUMN(IsPrimaryTrack, isPrimaryTrack, bool); //! Is primary track +DECLARE_SOA_COLUMN(IsPVContributor, isPVContributor, bool); //! Is primary vertex contributor +DECLARE_SOA_COLUMN(HasITS, hasITS, bool); //! Has ITS +DECLARE_SOA_COLUMN(HasTPC, hasTPC, bool); //! Has TPC +DECLARE_SOA_COLUMN(HasTOF, hasTOF, bool); //! Has TOF DECLARE_SOA_COLUMN(TPCCrossedRowsOverFindableCls, tpcCrossedRowsOverFindableCls, float); DECLARE_SOA_COLUMN(DaughDCA, daughDCA, float); //! DCA between daughters -DECLARE_SOA_COLUMN(CascDaughDCA, cascdaughDCA, float); //! DCA between daughters from cascade +DECLARE_SOA_COLUMN(CascDaughDCA, cascDaughDCA, float); //! DCA between daughters from cascade DECLARE_SOA_COLUMN(V0CosPA, v0CosPA, float); //! V0 Cosine of Pointing Angle DECLARE_SOA_COLUMN(CascCosPA, cascCosPA, float); //! Cascade Cosine of Pointing Angle DECLARE_SOA_COLUMN(MLambda, mLambda, float); //! The invariant mass of V0 candidate, assuming lambda @@ -132,7 +153,7 @@ DECLARE_SOA_COLUMN(MAntiLambda, mAntiLambda, float); //! DECLARE_SOA_COLUMN(MK0Short, mK0Short, float); //! The invariant mass of V0 candidate, assuming k0s DECLARE_SOA_COLUMN(MXi, mXi, float); //! The invariant mass of Xi candidate DECLARE_SOA_COLUMN(TransRadius, transRadius, float); //! Transverse radius of the decay vertex -DECLARE_SOA_COLUMN(CascTransRadius, casctransRadius, float); //! Transverse radius of the decay vertex from cascade +DECLARE_SOA_COLUMN(CascTransRadius, cascTransRadius, float); //! Transverse radius of the decay vertex from cascade DECLARE_SOA_COLUMN(DecayVtxX, decayVtxX, float); //! X position of the decay vertex DECLARE_SOA_COLUMN(DecayVtxY, decayVtxY, float); //! Y position of the decay vertex DECLARE_SOA_COLUMN(DecayVtxZ, decayVtxZ, float); //! Z position of the decay vertex @@ -158,19 +179,20 @@ DECLARE_SOA_COLUMN(DaughterTOFNSigmaBachPr, daughterTOFNSigmaBachPr, float); //! DECLARE_SOA_INDEX_COLUMN(McParticle, mcParticle); //! Index of the corresponding MC particle DECLARE_SOA_COLUMN(IsPhysicalPrimary, isPhysicalPrimary, bool); DECLARE_SOA_COLUMN(ProducedByGenerator, producedByGenerator, bool); -DECLARE_SOA_COLUMN(MothersId, motherId, int); //! Id of the mother particle +DECLARE_SOA_COLUMN(MotherId, motherId, int); //! Id of the mother particle DECLARE_SOA_COLUMN(MotherPDG, motherPDG, int); //! PDG code of the mother particle DECLARE_SOA_COLUMN(DaughterPDG1, daughterPDG1, int); //! PDG code of the first Daughter particle DECLARE_SOA_COLUMN(DaughterPDG2, daughterPDG2, int); //! PDG code of the second Daughter particle -DECLARE_SOA_COLUMN(DaughterID1, daughterId1, int); //! Id of the first Daughter particle -DECLARE_SOA_COLUMN(DaughterID2, daughterId2, int); //! Id of the second Daughter particle +DECLARE_SOA_COLUMN(DaughterID1, daughterID1, int); //! Id of the first Daughter particle +DECLARE_SOA_COLUMN(DaughterID2, daughterID2, int); //! Id of the second Daughter particle DECLARE_SOA_COLUMN(SiblingIds, siblingIds, int[2]); //! Index of the particles with the same mother -DECLARE_SOA_COLUMN(BachTrkID, bachtrkID, int); //! Id of the bach track from cascade +DECLARE_SOA_COLUMN(BachTrkID, bachTrkID, int); //! Id of the bach track from cascade DECLARE_SOA_COLUMN(V0ID, v0ID, int); //! Id of the V0 from cascade } // namespace resodaughter DECLARE_SOA_TABLE(ResoTracks, "AOD", "RESOTRACKS", o2::soa::Index<>, resodaughter::ResoCollisionId, + resodaughter::TrackId, resodaughter::Pt, resodaughter::Px, resodaughter::Py, @@ -211,6 +233,7 @@ using ResoTrack = ResoTracks::iterator; DECLARE_SOA_TABLE(ResoV0s, "AOD", "RESOV0S", o2::soa::Index<>, resodaughter::ResoCollisionId, + resodaughter::V0Id, resodaughter::Pt, resodaughter::Px, resodaughter::Py, @@ -247,6 +270,7 @@ using ResoV0 = ResoV0s::iterator; DECLARE_SOA_TABLE(ResoCascades, "AOD", "RESOCASCADES", o2::soa::Index<>, resodaughter::ResoCollisionId, + resodaughter::CascadeId, resodaughter::Pt, resodaughter::Px, resodaughter::Py, @@ -293,7 +317,7 @@ using ResoCascade = ResoCascades::iterator; DECLARE_SOA_TABLE(ResoMCTracks, "AOD", "RESOMCTRACKS", mcparticle::PdgCode, - resodaughter::MothersId, + resodaughter::MotherId, resodaughter::MotherPDG, resodaughter::SiblingIds, resodaughter::IsPhysicalPrimary, @@ -302,7 +326,7 @@ using ResoMCTrack = ResoMCTracks::iterator; DECLARE_SOA_TABLE(ResoMCV0s, "AOD", "RESOMCV0S", mcparticle::PdgCode, - resodaughter::MothersId, + resodaughter::MotherId, resodaughter::MotherPDG, resodaughter::DaughterID1, resodaughter::DaughterID2, @@ -314,7 +338,7 @@ using ResoMCV0 = ResoMCV0s::iterator; DECLARE_SOA_TABLE(ResoMCCascades, "AOD", "RESOMCCASCADES", mcparticle::PdgCode, - resodaughter::MothersId, + resodaughter::MotherId, resodaughter::MotherPDG, resodaughter::BachTrkID, resodaughter::V0ID, @@ -349,5 +373,17 @@ using Reso2TracksMC = soa::Join; using Reso2TracksPID = soa::Join; using Reso2TracksPIDExt = soa::Join; // Without Extra +using ResoCollisionCandidates = soa::Join; +using ResoRun2CollisionCandidates = soa::Join; +using ResoCollisionCandidatesMC = soa::Join; +using ResoRun2CollisionCandidatesMC = soa::Join; +using ResoTrackCandidates = aod::Reso2TracksPIDExt; +using ResoTrackCandidatesMC = soa::Join; +using ResoV0Candidates = aod::V0Datas; +using ResoV0CandidatesMC = soa::Join; +using ResoCascadesCandidates = aod::CascDatas; +using ResoCascadesCandidatesMC = soa::Join; +using BCsWithRun2Info = soa::Join; + } // namespace o2::aod #endif // PWGLF_DATAMODEL_LFRESONANCETABLES_H_ diff --git a/PWGLF/TableProducer/Resonances/CMakeLists.txt b/PWGLF/TableProducer/Resonances/CMakeLists.txt index d6ca37b8d0c..785dbdf3828 100644 --- a/PWGLF/TableProducer/Resonances/CMakeLists.txt +++ b/PWGLF/TableProducer/Resonances/CMakeLists.txt @@ -30,6 +30,11 @@ o2physics_add_dpl_workflow(resonance-initializer PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsBase COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(resonance-module-initializer + SOURCES resonanceModuleInitializer.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsBase + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(reso2mergedf SOURCES LFResonanceMergeDF.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsBase diff --git a/PWGLF/TableProducer/Resonances/resonanceInitializer.cxx b/PWGLF/TableProducer/Resonances/resonanceInitializer.cxx index 8a76e68ddef..03b0a351b0b 100644 --- a/PWGLF/TableProducer/Resonances/resonanceInitializer.cxx +++ b/PWGLF/TableProducer/Resonances/resonanceInitializer.cxx @@ -456,6 +456,7 @@ struct ResonanceInitializer { if (!isTrackSelected(collision, track)) continue; reso2trks(resoCollisions.lastIndex(), + track.globalIndex(), track.pt(), track.px(), track.py(), @@ -508,6 +509,7 @@ struct ResonanceInitializer { childIDs[0] = v0.posTrackId(); childIDs[1] = v0.negTrackId(); reso2v0s(resoCollisions.lastIndex(), + v0.globalIndex(), v0.pt(), v0.px(), v0.py(), @@ -554,6 +556,7 @@ struct ResonanceInitializer { childIDs[1] = casc.negTrackId(); childIDs[2] = casc.bachelorId(); reso2cascades(resoCollisions.lastIndex(), + casc.globalIndex(), casc.pt(), casc.px(), casc.py(), @@ -1055,7 +1058,7 @@ struct ResonanceInitializer { return; colCuts.fillQA(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillTracks(collision, tracks); } @@ -1071,7 +1074,7 @@ struct ResonanceInitializer { return; colCuts.fillQARun2(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillTracks(collision, tracks); } @@ -1088,7 +1091,7 @@ struct ResonanceInitializer { return; colCuts.fillQA(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), getEvtPl(collision), getEvtPlRes(collision, evtPlDetId, evtPlRefAId), getEvtPlRes(collision, evtPlDetId, evtPlRefBId), getEvtPlRes(collision, evtPlRefAId, evtPlRefBId), dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), getEvtPl(collision), getEvtPlRes(collision, evtPlDetId, evtPlRefAId), getEvtPlRes(collision, evtPlDetId, evtPlRefBId), getEvtPlRes(collision, evtPlRefAId, evtPlRefBId), dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillTracks(collision, tracks); } @@ -1106,7 +1109,7 @@ struct ResonanceInitializer { return; colCuts.fillQA(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillTracks(collision, tracks); fillV0s(collision, V0s, tracks); @@ -1124,7 +1127,7 @@ struct ResonanceInitializer { return; colCuts.fillQARun2(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillTracks(collision, tracks); fillV0s(collision, V0s, tracks); @@ -1144,7 +1147,7 @@ struct ResonanceInitializer { return; colCuts.fillQA(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillTracks(collision, tracks); fillV0s(collision, V0s, tracks); @@ -1164,7 +1167,7 @@ struct ResonanceInitializer { return; colCuts.fillQARun2(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillTracks(collision, tracks); fillV0s(collision, V0s, tracks); @@ -1181,7 +1184,7 @@ struct ResonanceInitializer { initCCDB(bc); colCuts.fillQA(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); auto mccollision = collision.mcCollision_as(); float impactpar = mccollision.impactParameter(); @@ -1204,7 +1207,7 @@ struct ResonanceInitializer { initCCDB(bc); colCuts.fillQA(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), getEvtPl(collision), getEvtPlRes(collision, evtPlDetId, evtPlRefAId), getEvtPlRes(collision, evtPlDetId, evtPlRefBId), getEvtPlRes(collision, evtPlRefAId, evtPlRefBId), dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), getEvtPl(collision), getEvtPlRes(collision, evtPlDetId, evtPlRefAId), getEvtPlRes(collision, evtPlDetId, evtPlRefBId), getEvtPlRes(collision, evtPlRefAId, evtPlRefBId), dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillMCCollision(collision, mcParticles); // Loop over tracks @@ -1223,7 +1226,7 @@ struct ResonanceInitializer { auto bc = collision.bc_as(); colCuts.fillQARun2(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillMCCollision(collision, mcParticles); // Loop over tracks @@ -1244,7 +1247,7 @@ struct ResonanceInitializer { initCCDB(bc); colCuts.fillQA(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillMCCollision(collision, mcParticles); // Loop over tracks @@ -1265,7 +1268,7 @@ struct ResonanceInitializer { auto bc = collision.bc_as(); colCuts.fillQARun2(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillMCCollision(collision, mcParticles); // Loop over tracks @@ -1288,7 +1291,7 @@ struct ResonanceInitializer { initCCDB(bc); colCuts.fillQA(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centEst(collision), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillMCCollision(collision, mcParticles); // Loop over tracks @@ -1312,7 +1315,7 @@ struct ResonanceInitializer { auto bc = collision.bc_as(); colCuts.fillQARun2(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), computeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillMCCollision(collision, mcParticles); // Loop over tracks diff --git a/PWGLF/TableProducer/Resonances/resonanceModuleInitializer.cxx b/PWGLF/TableProducer/Resonances/resonanceModuleInitializer.cxx new file mode 100644 index 00000000000..327585d6295 --- /dev/null +++ b/PWGLF/TableProducer/Resonances/resonanceModuleInitializer.cxx @@ -0,0 +1,1257 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +// +/// \file resonanceModuleInitializer.cxx +/// \brief Initializes variables for the resonance candidate producers +/// +/// \author Bong-Hwi Lim + +#include +#include +#include "CCDB/BasicCCDBManager.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/Centrality.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/Qvectors.h" +#include "Common/Core/EventPlaneHelper.h" +#include "CommonConstants/PhysicsConstants.h" +#include "CommonConstants/MathConstants.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/LFResonanceTables.h" +#include "PWGLF/DataModel/mcCentrality.h" +#include "PWGLF/Utils/collisionCuts.h" +#include "ReconstructionDataFormats/Track.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; +using namespace o2::constants::physics; +using namespace o2::constants::math; + +/** + * @brief Initializer for the event pool for resonance study + * + * This struct is responsible for initializing and processing collision data + * for resonance studies. It handles event selection, centrality estimation, + * and QA histogram filling. + */ +struct ResonanceModuleInitializer { + int mRunNumber; ///< Run number for the current data + int multEstimator; ///< Multiplicity estimator type + float dBz; ///< Magnetic field value + float centrality; ///< Centrality value for the event + Service ccdb; ///< CCDB manager service + Service pdg; ///< PDG database service + EventPlaneHelper helperEP; ///< Helper for event plane calculations + + Produces resoCollisions; ///< Output table for resonance collisions + Produces resoMCCollisions; ///< Output table for MC resonance collisions + + // CCDB options + Configurable ccdbURL{"ccdbURL", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + + Configurable cfgFatalWhenNull{"cfgFatalWhenNull", true, "Fatal when null on ccdb access"}; + + // Configurables + Configurable dBzInput{"dBzInput", -999, "bz field, -999 is automatic"}; + Configurable cfgFillQA{"cfgFillQA", false, "Fill QA histograms"}; + Configurable cfgBypassCCDB{"cfgBypassCCDB", true, "Bypass loading CCDB part to save CPU time and memory"}; // will be affected to b_z value. + Configurable cfgMultName{"cfgMultName", "FT0M", "The name of multiplicity estimator"}; + Configurable cfgCentralityMC{"cfgCentralityMC", 0, "Centrality estimator for MC (0: Reco, 1: MC, 2: impact parameter)"}; + + // EventCorrection for MC + ConfigurableAxis binsCent{"binsCent", {VARIABLE_WIDTH, 0., 0.01, 0.1, 1.0, 5.0, 10., 15., 20., 30., 40., 50., 70., 100.0, 105.}, "Binning of the centrality axis"}; + ConfigurableAxis cfgVtxBins{"cfgVtxBins", {VARIABLE_WIDTH, -20, -15, -10, -7, -5, -3, -2, -1, 0, 1, 2, 3, 5, 7, 10, 15, 20}, "Mixing bins - z-vertex"}; + + /// Event cuts + o2::analysis::CollisonCuts colCuts; + Configurable cfgEvtZvtx{"cfgEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; + Configurable cfgEvtOccupancyInTimeRange{"cfgEvtOccupancyInTimeRange", -1, "Evt sel: maximum track occupancy"}; + Configurable cfgEvtTriggerCheck{"cfgEvtTriggerCheck", false, "Evt sel: check for trigger"}; + Configurable cfgEvtTriggerSel{"cfgEvtTriggerSel", 8, "Evt sel: trigger"}; + Configurable cfgEvtOfflineCheck{"cfgEvtOfflineCheck", true, "Evt sel: check for offline selection"}; + Configurable cfgEvtTriggerTVXSel{"cfgEvtTriggerTVXSel", false, "Evt sel: triggerTVX selection (MB)"}; + Configurable cfgEvtTFBorderCut{"cfgEvtTFBorderCut", false, "Evt sel: apply TF border cut"}; + Configurable cfgEvtUseITSTPCvertex{"cfgEvtUseITSTPCvertex", false, "Evt sel: use at lease on ITS-TPC track for vertexing"}; + Configurable cfgEvtZvertexTimedifference{"cfgEvtZvertexTimedifference", false, "Evt sel: apply Z-vertex time difference"}; + Configurable cfgEvtPileupRejection{"cfgEvtPileupRejection", false, "Evt sel: apply pileup rejection"}; + Configurable cfgEvtNoITSROBorderCut{"cfgEvtNoITSROBorderCut", false, "Evt sel: apply NoITSRO border cut"}; + + // Qvector configuration + Configurable cfgBypassQvec{"cfgBypassQvec", true, "Bypass for qvector task"}; + Configurable cfgEvtPl{"cfgEvtPl", 40500, "Configuration of three subsystems for the event plane and its resolution, 10000*RefA + 100*RefB + S, where FT0C:0, FT0A:1, FT0M:2, FV0A:3, BPos:5, BNeg:6"}; + + int evtPlRefAId = static_cast(cfgEvtPl / 10000); + int evtPlRefBId = static_cast((cfgEvtPl - evtPlRefAId * 10000) / 100); + int evtPlDetId = cfgEvtPl - evtPlRefAId * 10000 - evtPlRefBId * 100; + + HistogramRegistry qaRegistry{"QAHistos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + Filter collisionFilter = nabs(aod::collision::posZ) < cfgEvtZvtx; + + /** + * @brief Initializes the task + * + * @param context Initialization context + */ + void init(InitContext&) + { + mRunNumber = 0; + dBz = 0; + centrality = 0; + // Determine the multiplicity estimator based on the configuration + multEstimator = 0; + if (cfgMultName.value == "FT0M") { + multEstimator = 0; + } else if (cfgMultName.value == "FT0C") { + multEstimator = 1; + } else if (cfgMultName.value == "FT0A") { + multEstimator = 2; + } else if (cfgMultName.value == "FV0A") { + multEstimator = 99; + } + LOGF(info, "Mult estimator: %d, %s", multEstimator, cfgMultName.value.c_str()); + + // Ensure that only one process type is active at a time + if (doprocessRun3 && doprocessRun2) { + LOG(fatal) << "You cannot run both Run2 and Run3 processes at the same time"; + } + if (doprocessRun2MC && doprocessRun3MC) { + LOG(fatal) << "You cannot run both Run2 and Run3 MC processes at the same time"; + } + + // Initialize event selection cuts based on the process type + if (doprocessRun2) { + colCuts.setCuts(cfgEvtZvtx, cfgEvtTriggerCheck, cfgEvtTriggerSel, cfgEvtOfflineCheck, false); + } else if (doprocessRun3) { + colCuts.setCuts(cfgEvtZvtx, cfgEvtTriggerCheck, cfgEvtTriggerSel, cfgEvtOfflineCheck, true, false, cfgEvtOccupancyInTimeRange); + } + colCuts.init(&qaRegistry); + colCuts.setTriggerTVX(cfgEvtTriggerTVXSel); + colCuts.setApplyTFBorderCut(cfgEvtTFBorderCut); + colCuts.setApplyITSTPCvertex(cfgEvtUseITSTPCvertex); + colCuts.setApplyZvertexTimedifference(cfgEvtZvertexTimedifference); + colCuts.setApplyPileupRejection(cfgEvtPileupRejection); + colCuts.setApplyNoITSROBorderCut(cfgEvtNoITSROBorderCut); + + // Configure CCDB access if not bypassed + if (!cfgBypassCCDB) { + ccdb->setURL(ccdbURL.value); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(cfgFatalWhenNull); + uint64_t now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + ccdb->setCreatedNotAfter(now); // TODO must become global parameter from the train creation time + } + + // Initialize QA histograms if required + if (doprocessRun3MC || doprocessRun2MC) { + AxisSpec centAxis = {binsCent, "Centrality (%)"}; + AxisSpec idxMCAxis = {26, -0.5, 25.5, "Index"}; + qaRegistry.add("Event/hMCEventIndices", "hMCEventIndices", kTH2D, {centAxis, idxMCAxis}); + } + } + + /** + * @brief Initializes CCDB for a given BC + * + * @param bc BC iterator + */ + void initCCDB(aod::BCsWithTimestamps::iterator const& bc) // Simple copy from LambdaKzeroFinder.cxx + { + if (cfgBypassCCDB) + return; + if (mRunNumber == bc.runNumber()) { + return; + } + + // In case override, don't proceed, please - no CCDB access required + if (dBzInput > -990) { + dBz = dBzInput; + ; + o2::parameters::GRPMagField grpmag; + if (std::fabs(dBz) > 1e-5) { + grpmag.setL3Current(30000.f / (dBz / 5.0f)); + } + o2::base::Propagator::initFieldFromGRP(&grpmag); + mRunNumber = bc.runNumber(); + return; + } + + auto run3grpTimestamp = bc.timestamp(); + o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp(grpPath, run3grpTimestamp); + o2::parameters::GRPMagField* grpmag = 0x0; + if (grpo) { + o2::base::Propagator::initFieldFromGRP(grpo); + // Fetch magnetic field from ccdb for current collision + dBz = grpo->getNominalL3Field(); + LOG(info) << "Retrieved GRP for timestamp " << run3grpTimestamp << " with magnetic field of " << dBz << " kZG"; + } else { + grpmag = ccdb->getForTimeStamp(grpmagPath, run3grpTimestamp); + if (!grpmag) { + LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grpTimestamp; + } + o2::base::Propagator::initFieldFromGRP(grpmag); + // Fetch magnetic field from ccdb for current collision + dBz = std::lround(5.f * grpmag->getL3Current() / 30000.f); + LOG(info) << "Retrieved GRP for timestamp " << run3grpTimestamp << " with magnetic field of " << dBz << " kZG"; + } + mRunNumber = bc.runNumber(); + // Set magnetic field value once known + LOGF(info, "Bz set to %f for run: ", dBz, mRunNumber); + } + + /** + * @brief Checks if the collision is INEL>0 + * + * @tparam MCPart Type of MC particles + * @param mcparts MC particles + * @return true if INEL>0, false otherwise + */ + template + bool isTrueINEL0(MCPart const& mcparts) + { + for (auto const& mcparticle : mcparts) { + if (!mcparticle.isPhysicalPrimary()) + continue; + auto p = pdg->GetParticle(mcparticle.pdgCode()); + if (p != nullptr) { + if (std::abs(p->Charge()) >= 3) { + if (std::abs(mcparticle.eta()) < 1) + return true; + } + } + } + return false; + } + + /** + * @brief Centrality estimator selection + * + * @tparam ResoColl Type of resonance collision + * @tparam isMC Boolean indicating if it's MC + * @param ResoEvents Resonance events + * @return Centrality value + */ + template + float centEst(ResoColl ResoEvents) + { + float returnValue = -999.0; + switch (multEstimator) { + case 0: + returnValue = ResoEvents.centFT0M(); + break; + case 1: + if constexpr (isMC) { + LOG(fatal) << "CentFV0A is not available for MC"; + return returnValue; + } else { + returnValue = ResoEvents.centFT0C(); + break; + } + case 2: + if constexpr (isMC) { + LOG(fatal) << "CentFT0A is not available for MC"; + return returnValue; + } else { + returnValue = ResoEvents.centFT0A(); + break; + } + case 99: + if constexpr (isMC) { + LOG(fatal) << "CentFV0A is not available for MC"; + return returnValue; + } else { + returnValue = ResoEvents.centFV0A(); + break; + } + default: + returnValue = ResoEvents.centFT0M(); + break; + } + return returnValue; + } + using GenMCCollisions = soa::Join; + float centEstMC(const GenMCCollisions::iterator& collision) { return centEst(collision); } + + /** + * @brief Computes the spherocity of an event + * + * @tparam T Type of the tracks + * @param tracks All tracks + * @param nTracksMin Minimum number of tracks + * @param spdef Spherocity definition + * @return Spherocity value + */ + template + float computeSpherocity(T const& tracks, int nTracksMin, int spdef) + { + // if number of tracks is not enough for spherocity estimation. + int ntrks = tracks.size(); + if (ntrks < nTracksMin) + return -99.; + + // start computing spherocity + + float ptSum = 0.; + for (auto const& track : tracks) { + if (cfgFillQA) { + qaRegistry.fill(HIST("Phi"), track.phi()); + } + if (spdef == 0) { + ptSum += 1.; + } else { + ptSum += track.pt(); + } + } + + float tempSph = 1.; + for (int i = 0; i < 360 / 0.1; ++i) { + float sum = 0., pt = 0.; + float phiparm = (PI * i * 0.1) / 180.; + float nx = std::cos(phiparm); + float ny = std::sin(phiparm); + for (auto const& trk : tracks) { + pt = trk.pt(); + if (spdef == 0) { + pt = 1.; + } + float phi = trk.phi(); + float px = pt * std::cos(phi); + float py = pt * std::sin(phi); + // sum += pt * abs(sin(phiparm - phi)); + sum += std::abs(px * ny - py * nx); + } + float sph = std::pow((sum / ptSum), 2); + if (sph < tempSph) + tempSph = sph; + } + + return std::pow(PIHalf, 2) * tempSph; + } + + /** + * @brief Gets the event plane + * + * @tparam ResoColl Type of resonance collision + * @param ResoEvents Resonance events + * @return Event plane value + */ + template + float getEvtPl(ResoColl ResoEvents) + { + float returnValue = -999.0; + if (ResoEvents.qvecAmp()[evtPlDetId] > 1e-8) + returnValue = helperEP.GetEventPlane(ResoEvents.qvecRe()[evtPlDetId * 4 + 3], ResoEvents.qvecIm()[evtPlDetId * 4 + 3], 2); + return returnValue; + } + + /** + * @brief Gets the event plane resolution + * + * @tparam ResoColl Type of resonance collision + * @param ResoEvents Resonance events + * @param a First index + * @param b Second index + * @return Event plane resolution + */ + template + float getEvtPlRes(ResoColl ResoEvents, int a, int b) + { + float returnValue = -999.0; + if (ResoEvents.qvecAmp()[a] < 1e-8 || ResoEvents.qvecAmp()[b] < 1e-8) + return returnValue; + returnValue = helperEP.GetResolution(helperEP.GetEventPlane(ResoEvents.qvecRe()[a * 4 + 3], ResoEvents.qvecIm()[a * 4 + 3], 2), helperEP.GetEventPlane(ResoEvents.qvecRe()[b * 4 + 3], ResoEvents.qvecIm()[b * 4 + 3], 2), 2); + return returnValue; + } + + /** + * @brief Fills MC particles + * + * @tparam CollisionType Type of collision + * @tparam SelectedMCPartType Type of selected MC particles + * @tparam TotalMCParts Type of total MC particles + * @param collision Collision data + * @param mcParts Selected MC particles + * @param mcParticles Total MC particles + */ + template + void fillMCParticles(CollisionType collision, SelectedMCPartType const& mcParts, TotalMCParts const& mcParticles) + { + for (auto const& mcPart : mcParts) { + std::vector daughterPDGs; + if (mcPart.has_daughters()) { + auto daughter01 = mcParticles.rawIteratorAt(mcPart.daughtersIds()[0] - mcParticles.offset()); + auto daughter02 = mcParticles.rawIteratorAt(mcPart.daughtersIds()[1] - mcParticles.offset()); + daughterPDGs = {daughter01.pdgCode(), daughter02.pdgCode()}; + } else { + daughterPDGs = {-1, -1}; + } + reso2mcparents(collision.globalIndex(), + mcPart.globalIndex(), + mcPart.pdgCode(), + daughterPDGs[0], daughterPDGs[1], + mcPart.isPhysicalPrimary(), + mcPart.producedByGenerator(), + mcPart.pt(), + mcPart.px(), + mcPart.py(), + mcPart.pz(), + mcPart.eta(), + mcPart.phi(), + mcPart.y()); + daughterPDGs.clear(); + } + } + + /** + * @brief Fills MC collision data + * + * @tparam isRun2 Boolean indicating if it's Run2 + * @tparam MCCol Type of MC collision + * @tparam MCPart Type of MC particles + * @param mccol MC collision data + * @param mcparts MC particles + */ + template + void fillMCCollision(MCCol const& mccol, MCPart const& mcparts) + { + const auto& mcColg = mccol.template mcCollision_as(); + float mcCent = 999.0; + if constexpr (isRun2) { + if (cfgCentralityMC == 0) { + mcCent = mccol.centRun2V0M(); + } else { + mcCent = mcColg.impactParameter(); + } + } else { + if (cfgCentralityMC == 0) { + mcCent = centEst(mccol); + } else if (cfgCentralityMC == 1) { + mcCent = centEstMC(mcColg); + } else if (cfgCentralityMC == 2) { + mcCent = mcColg.impactParameter(); + } + } + bool inVtx10 = (std::abs(mcColg.posZ()) > 10.) ? false : true; + bool isTrueINELgt0 = isTrueINEL0(mcparts); + bool isTriggerTVX = mccol.selection_bit(aod::evsel::kIsTriggerTVX); + bool isSel8 = mccol.sel8(); + bool isSelected = colCuts.isSelected(mccol); + resoMCCollisions(inVtx10, isTrueINELgt0, isTriggerTVX, isSel8, isSelected, mcCent); + + // QA for Trigger efficiency + qaRegistry.fill(HIST("Event/hMCEventIndices"), mcCent, aod::resocollision::kINEL); + if (inVtx10) + qaRegistry.fill(HIST("Event/hMCEventIndices"), mcCent, aod::resocollision::kINEL10); + if (isTrueINELgt0) + qaRegistry.fill(HIST("Event/hMCEventIndices"), mcCent, aod::resocollision::kINELg0); + if (inVtx10 && isTrueINELgt0) + qaRegistry.fill(HIST("Event/hMCEventIndices"), mcCent, aod::resocollision::kINELg010); + + // TVX MB trigger + if (isTriggerTVX) + qaRegistry.fill(HIST("Event/hMCEventIndices"), mcCent, aod::resocollision::kTrig); + if (isTriggerTVX && inVtx10) + qaRegistry.fill(HIST("Event/hMCEventIndices"), mcCent, aod::resocollision::kTrig10); + if (isTriggerTVX && isTrueINELgt0) + qaRegistry.fill(HIST("Event/hMCEventIndices"), mcCent, aod::resocollision::kTrigINELg0); + if (isTriggerTVX && isTrueINELgt0 && inVtx10) + qaRegistry.fill(HIST("Event/hMCEventIndices"), mcCent, aod::resocollision::kTrigINELg010); + + // Sel8 event selection + if (isSel8) + qaRegistry.fill(HIST("Event/hMCEventIndices"), mcCent, aod::resocollision::kSel8); + if (isSel8 && inVtx10) + qaRegistry.fill(HIST("Event/hMCEventIndices"), mcCent, aod::resocollision::kSel810); + if (isSel8 && isTrueINELgt0) + qaRegistry.fill(HIST("Event/hMCEventIndices"), mcCent, aod::resocollision::kSel8INELg0); + if (isSel8 && isTrueINELgt0 && inVtx10) + qaRegistry.fill(HIST("Event/hMCEventIndices"), mcCent, aod::resocollision::kSel8INELg010); + + // CollisionCuts selection + if (isSelected) + qaRegistry.fill(HIST("Event/hMCEventIndices"), mcCent, aod::resocollision::kAllCuts); + if (isSelected && inVtx10) + qaRegistry.fill(HIST("Event/hMCEventIndices"), mcCent, aod::resocollision::kAllCuts10); + if (isSelected && isTrueINELgt0) + qaRegistry.fill(HIST("Event/hMCEventIndices"), mcCent, aod::resocollision::kAllCutsINELg0); + if (isSelected && isTrueINELgt0 && inVtx10) + qaRegistry.fill(HIST("Event/hMCEventIndices"), mcCent, aod::resocollision::kAllCutsINELg010); + } + + /** + * @brief Processes Dummy + * + * @param collision Collision data + */ + void processDummy(aod::Collisions const&) + { + } + PROCESS_SWITCH(ResonanceModuleInitializer, processDummy, "process Dummy", true); + + /** + * @brief Processes Run3 data + * + * @param collision Collision data + * @param bc BC data + */ + void processRun3(soa::Filtered::iterator const& collision, + aod::BCsWithTimestamps const&) + { + auto bc = collision.bc_as(); + initCCDB(bc); + // Default event selection + if (!colCuts.isSelected(collision)) + return; + colCuts.fillQA(collision); + centrality = centEst(collision); + + resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centrality, -999, 0., 0., 0., 0., dBz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + } + PROCESS_SWITCH(ResonanceModuleInitializer, processRun3, "Default process for RUN3", false); + + /** + * @brief Processes Run2 data + * + * @param collision Collision data + * @param bc BC data + */ + void processRun2(soa::Filtered::iterator const& collision, + aod::BCsWithRun2Info const&) + { + auto bc = collision.bc_as(); + // Default event selection + if (!colCuts.isSelected(collision)) + return; + colCuts.fillQARun2(collision); + centrality = collision.centRun2V0M(); + + resoCollisions(collision.globalIndex(), 0, collision.posX(), collision.posY(), collision.posZ(), centrality, -999, 0., 0., 0., 0., dBz, bc.timestamp(), -999); + } + PROCESS_SWITCH(ResonanceModuleInitializer, processRun2, "process for RUN2", false); + + /** + * @brief Processes Run3 MC data + * + * @param collision Collision data + * @param mcParticles MC particles + * @param mcCollisions MC collisions + */ + void processRun3MC(soa::Filtered::iterator const& collision, + aod::McParticles const& mcParticles, GenMCCollisions const&) + { + fillMCCollision(collision, mcParticles); + } + PROCESS_SWITCH(ResonanceModuleInitializer, processRun3MC, "process MC for RUN3", false); + + /** + * @brief Processes Run2 MC data + * + * @param collision Collision data + * @param mcParticles MC particles + */ + void processRun2MC(soa::Filtered::iterator const& collision, + aod::McParticles const& mcParticles) + { + fillMCCollision(collision, mcParticles); + } + PROCESS_SWITCH(ResonanceModuleInitializer, processRun2MC, "process MC for RUN2", false); +}; + +/** + * @brief Initializer for the resonance daughters producer + * + * This struct initializes and processes daughters for resonance studies. + * It applies daughter selection criteria and fills QA histograms for daughter properties. + */ +struct ResonanceDaughterInitializer { + SliceCache cache; + Produces reso2trks; ///< Output table for resonance tracks + Produces reso2mctracks; ///< Output table for MC resonance tracks + Produces reso2v0s; ///< Output table for resonance V0s + Produces reso2mcv0s; ///< Output table for MC resonance V0s + Produces reso2cascades; ///< Output table for resonance cascades + Produces reso2mccascades; ///< Output table for MC resonance cascades + + // Configurables + Configurable cfgFillQA{"cfgFillQA", false, "Fill QA histograms"}; + + // Configurables for tracks + Configurable cMaxDCArToPVcut{"cMaxDCArToPVcut", 2.0, "Track DCAr cut to PV Maximum"}; + Configurable cMinDCArToPVcut{"cMinDCArToPVcut", 0.0, "Track DCAr cut to PV Minimum"}; + Configurable cMaxDCAzToPVcut{"cMaxDCAzToPVcut", 2.0, "Track DCAz cut to PV Maximum"}; + Configurable cMinDCAzToPVcut{"cMinDCAzToPVcut", 0.0, "Track DCAz cut to PV Minimum"}; + Configurable trackSelection{"trackSelection", 1, "Track selection: 0 -> No Cut, 1 -> kGlobalTrack, 2 -> kGlobalTrackWoPtEta, 3 -> kGlobalTrackWoDCA, 4 -> kQualityTracks, 5 -> kInAcceptanceTracks"}; + + // Configurables for V0s + Configurable cMinV0Radius{"cMinV0Radius", 0.0, "Minimum V0 radius from PV"}; + Configurable cMaxV0Radius{"cMaxV0Radius", 200.0, "Maximum V0 radius from PV"}; + Configurable cMinV0CosPA{"cMinV0CosPA", 0.995, "Minimum V0 CosPA to PV"}; + + // Configurables for cascades + Configurable cMinCascRadius{"cMinCascRadius", 0.0, "Minimum Cascade radius from PV"}; + Configurable cMaxCascRadius{"cMaxCascRadius", 200.0, "Maximum Cascade radius from PV"}; + Configurable cMinCascCosPA{"cMinCascCosPA", 0.97, "Minimum Cascade CosPA to PV"}; + + // Filters + Filter dcaXYFilter = nabs(aod::track::dcaXY) < cMaxDCArToPVcut && nabs(aod::track::dcaXY) > cMinDCArToPVcut; + Filter dcaZFilter = nabs(aod::track::dcaZ) < cMaxDCAzToPVcut && nabs(aod::track::dcaZ) > cMinDCAzToPVcut; + Preslice perMcCollision = aod::mcparticle::mcCollisionId; + + // Track selection filter based on configuration + Filter trackFilter = (trackSelection.node() == 0) || + ((trackSelection.node() == 1) && requireGlobalTrackInFilter()) || // kGlobalTrack = kQualityTracks | kPrimaryTracks | kInAcceptanceTracks + ((trackSelection.node() == 2) && requireGlobalTrackWoPtEtaInFilter()) || // kGlobalTrackWoPtEta = kQualityTracks | kPrimaryTracks + ((trackSelection.node() == 3) && requireGlobalTrackWoDCAInFilter()) || // kGlobalTrackWoDCA = kQualityTracks | kInAcceptanceTracks + ((trackSelection.node() == 4) && requireQualityTracksInFilter()) || // kQualityTracks = kQualityTracksITS | kQualityTracksTPC + ((trackSelection.node() == 5) && requireTrackCutInFilter(TrackSelectionFlags::kInAcceptanceTracks)); // kInAcceptanceTracks = kPtRange | kEtaRange + HistogramRegistry qaRegistry{"QAHistos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + /** + * @brief Initializes the task + * + * @param context Initialization context + */ + void init(InitContext&) + { + if (cfgFillQA) { + AxisSpec idxAxis = {8, -0.5, 7.5, "Index"}; + AxisSpec ptAxis = {100, 0.0f, 10.0f, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec etaAxis = {100, -1.0f, 1.0f, "#eta"}; + AxisSpec phiAxis = {100, 0.0f, TwoPI, "#phi"}; + + qaRegistry.add("QA/hGoodTrackIndices", "hGoodTrackIndices", kTH1D, {idxAxis}); + if (doprocessMC) { + qaRegistry.add("QA/hGoodMCTrackIndices", "hGoodMCTrackIndices", kTH1D, {idxAxis}); + } + qaRegistry.add("QA/hTrackPt", "Track pT", kTH1F, {ptAxis}); + qaRegistry.add("QA/hTrackEta", "Track eta", kTH1F, {etaAxis}); + qaRegistry.add("QA/hTrackPhi", "Track phi", kTH1F, {phiAxis}); + + if (doprocessV0Data || doprocessV0MC) { + qaRegistry.add("QA/hGoodV0Indices", "hGoodV0Indices", kTH1D, {idxAxis}); + if (doprocessMC) { + qaRegistry.add("QA/hGoodMCV0Indices", "hGoodMCV0Indices", kTH1D, {idxAxis}); + } + AxisSpec radiusAxis = {100, 0.0, 200.0, "V0 Radius"}; + AxisSpec cosPAAxis = {100, 0.995, 1.0, "V0 CosPA"}; + qaRegistry.add("QA/hV0Radius", "V0 Radius", kTH1F, {radiusAxis}); + qaRegistry.add("QA/hV0CosPA", "V0 CosPA", kTH1F, {cosPAAxis}); + } + + if (doprocessCascData || doprocessCascMC) { + AxisSpec radiusAxis = {100, 0.0, 200.0, "Cascade Radius"}; + AxisSpec cosPAAxis = {100, 0.97, 1.0, "Cascade CosPA"}; + qaRegistry.add("QA/hGoodCascIndices", "hGoodCascIndices", kTH1D, {idxAxis}); + if (doprocessMC) { + qaRegistry.add("QA/hGoodMCCascIndices", "hGoodMCCascIndices", kTH1D, {idxAxis}); + } + qaRegistry.add("QA/hCascRadius", "Cascade Radius", kTH1F, {radiusAxis}); + qaRegistry.add("QA/hCascCosPA", "Cascade CosPA", kTH1F, {cosPAAxis}); + } + } + if (doprocessData || doprocessMC) { + LOGF(info, "ResonanceDaughterInitializer initialized with tracks"); + } + if (doprocessV0Data || doprocessV0MC) { + LOGF(info, "ResonanceDaughterInitializer initialized with V0s"); + } + if (doprocessCascData || doprocessCascMC) { + LOGF(info, "ResonanceDaughterInitializer initialized with cascades"); + } + + // Check if the module is initialized with both data and MC + if ((doprocessData && doprocessMC) || (doprocessV0Data && doprocessV0MC) || (doprocessCascData && doprocessCascMC)) { + LOGF(fatal, "ResonanceDaughterInitializer initialized with both data and MC"); + } + // Check if none of the processes are enabled + if (!doprocessDummy && !doprocessData && !doprocessMC && !doprocessV0Data && !doprocessV0MC && !doprocessCascData && !doprocessCascMC) { + LOGF(fatal, "ResonanceDaughterInitializer not initialized, enable at least one process"); + } + } + + /** + * @brief Fills track data + * + * @tparam isMC Boolean indicating if it's MC + * @tparam TrackType Type of track + * @tparam CollisionType Type of collision + * @param collision Collision data + * @param tracks Track data + */ + template + void fillTracks(CollisionType const& collision, TrackType const& tracks) + { + // Loop over tracks + for (auto const& track : tracks) { + if (cfgFillQA) { + qaRegistry.fill(HIST("QA/hGoodTrackIndices"), 0); + qaRegistry.fill(HIST("QA/hTrackPt"), track.pt()); + qaRegistry.fill(HIST("QA/hTrackEta"), track.eta()); + qaRegistry.fill(HIST("QA/hTrackPhi"), track.phi()); + } + reso2trks(collision.globalIndex(), + track.globalIndex(), + track.pt(), + track.px(), + track.py(), + track.pz(), + track.eta(), + track.phi(), + track.sign(), + (uint8_t)track.tpcNClsCrossedRows(), + (uint8_t)track.tpcNClsFound(), + (uint8_t)track.itsNCls(), + track.dcaXY(), + track.dcaZ(), + track.x(), + track.alpha(), + track.hasITS(), + track.hasTPC(), + track.hasTOF(), + track.tpcNSigmaPi(), + track.tpcNSigmaKa(), + track.tpcNSigmaPr(), + track.tpcNSigmaEl(), + track.tofNSigmaPi(), + track.tofNSigmaKa(), + track.tofNSigmaPr(), + track.tofNSigmaEl(), + track.tpcSignal(), + track.passedITSRefit(), + track.passedTPCRefit(), + track.isGlobalTrackWoDCA(), + track.isGlobalTrack(), + track.isPrimaryTrack(), + track.isPVContributor(), + track.tpcCrossedRowsOverFindableCls(), + track.itsChi2NCl(), + track.tpcChi2NCl()); + if constexpr (isMC) { + fillMCTrack(track); + } + } + } + + /** + * @brief Fills MC track data + * + * @tparam TrackType Type of track + * @param track Track data + */ + template + void fillMCTrack(TrackType const& track) + { + // ------ Temporal lambda function to prevent error in build + auto getMothersIndeces = [&](auto const& theMcParticle) { + std::vector lMothersIndeces{}; + for (auto const& lMother : theMcParticle.template mothers_as()) { + LOGF(debug, " mother index lMother: %d", lMother.globalIndex()); + lMothersIndeces.push_back(lMother.globalIndex()); + } + return lMothersIndeces; + }; + auto getMothersPDGCodes = [&](auto const& theMcParticle) { + std::vector lMothersPDGs{}; + for (auto const& lMother : theMcParticle.template mothers_as()) { + LOGF(debug, " mother pdgcode lMother: %d", lMother.pdgCode()); + lMothersPDGs.push_back(lMother.pdgCode()); + } + return lMothersPDGs; + }; + auto getSiblingsIndeces = [&](auto const& theMcParticle) { + std::vector lSiblingsIndeces{}; + for (auto const& lMother : theMcParticle.template mothers_as()) { + LOGF(debug, " mother index lMother: %d", lMother.globalIndex()); + for (auto const& lDaughter : lMother.template daughters_as()) { + LOGF(debug, " daughter index lDaughter: %d", lDaughter.globalIndex()); + if (lDaughter.globalIndex() != 0 && lDaughter.globalIndex() != theMcParticle.globalIndex()) { + lSiblingsIndeces.push_back(lDaughter.globalIndex()); + } + } + } + return lSiblingsIndeces; + }; + // ------ + std::vector mothers = {-1, -1}; + std::vector motherPDGs = {-1, -1}; + int siblings[2] = {0, 0}; + std::vector siblingsTemp = {-1, -1}; + if (track.has_mcParticle()) { + if (cfgFillQA) { + qaRegistry.fill(HIST("QA/hGoodMCTrackIndices"), 0); + } + // Get the MC particle + const auto& particle = track.mcParticle(); + if (particle.has_mothers()) { + mothers = getMothersIndeces(particle); + motherPDGs = getMothersPDGCodes(particle); + siblingsTemp = getSiblingsIndeces(particle); + } + while (mothers.size() > 2) { + mothers.pop_back(); + motherPDGs.pop_back(); + } + if (siblingsTemp.size() > 0) + siblings[0] = siblingsTemp[0]; + if (siblingsTemp.size() > 1) + siblings[1] = siblingsTemp[1]; + reso2mctracks(particle.pdgCode(), + mothers[0], + motherPDGs[0], + siblings, + particle.isPhysicalPrimary(), + particle.producedByGenerator()); + } else { + // No MC particle associated + reso2mctracks(0, + mothers[0], + motherPDGs[0], + siblings, + 0, + 0); + } + } + + /** + * @brief Fills V0 data + * + * @tparam isMC Boolean indicating if it's MC + * @tparam CollisionType Type of collision + * @tparam V0Type Type of V0 + * @tparam TrackType Type of track + * @param collision Collision data + * @param v0s V0 data + * @param tracks Track data + */ + template + void fillV0s(CollisionType const& collision, V0Type const& v0s, TrackType const&) + { + int childIDs[2] = {0, 0}; // these IDs are necessary to keep track of the children + for (auto const& v0 : v0s) { + if (cfgFillQA) { + qaRegistry.fill(HIST("QA/hGoodV0Indices"), 0); + qaRegistry.fill(HIST("QA/hV0Radius"), v0.v0radius()); + qaRegistry.fill(HIST("QA/hV0CosPA"), v0.v0cosPA()); + } + childIDs[0] = v0.posTrackId(); + childIDs[1] = v0.negTrackId(); + reso2v0s(collision.globalIndex(), + v0.globalIndex(), + v0.pt(), + v0.px(), + v0.py(), + v0.pz(), + v0.eta(), + v0.phi(), + childIDs, + v0.template posTrack_as().tpcNSigmaPi(), + v0.template posTrack_as().tpcNSigmaKa(), + v0.template posTrack_as().tpcNSigmaPr(), + v0.template negTrack_as().tpcNSigmaPi(), + v0.template negTrack_as().tpcNSigmaKa(), + v0.template negTrack_as().tpcNSigmaPr(), + v0.template negTrack_as().tofNSigmaPi(), + v0.template negTrack_as().tofNSigmaKa(), + v0.template negTrack_as().tofNSigmaPr(), + v0.template posTrack_as().tofNSigmaPi(), + v0.template posTrack_as().tofNSigmaKa(), + v0.template posTrack_as().tofNSigmaPr(), + v0.v0cosPA(), + v0.dcaV0daughters(), + v0.dcapostopv(), + v0.dcanegtopv(), + v0.dcav0topv(), + v0.mLambda(), + v0.mAntiLambda(), + v0.mK0Short(), + v0.v0radius(), v0.x(), v0.y(), v0.z()); + if constexpr (isMC) { + fillMCV0(v0); + } + } + } + + /** + * @brief Fills MC V0 data + * + * @tparam V0Type Type of V0 + * @param v0 V0 data + */ + template + void fillMCV0(V0Type const& v0) + { + // ------ Temporal lambda function to prevent error in build + auto getMothersIndeces = [&](auto const& theMcParticle) { + std::vector lMothersIndeces{}; + for (auto const& lMother : theMcParticle.template mothers_as()) { + LOGF(debug, " mother index lMother: %d", lMother.globalIndex()); + lMothersIndeces.push_back(lMother.globalIndex()); + } + return lMothersIndeces; + }; + auto getMothersPDGCodes = [&](auto const& theMcParticle) { + std::vector lMothersPDGs{}; + for (auto const& lMother : theMcParticle.template mothers_as()) { + LOGF(debug, " mother pdgcode lMother: %d", lMother.pdgCode()); + lMothersPDGs.push_back(lMother.pdgCode()); + } + return lMothersPDGs; + }; + auto getDaughtersIndeces = [&](auto const& theMcParticle) { + std::vector lDaughtersIndeces{}; + for (auto const& lDaughter : theMcParticle.template daughters_as()) { + LOGF(debug, " daughter index lDaughter: %d", lDaughter.globalIndex()); + if (lDaughter.globalIndex() != 0) { + lDaughtersIndeces.push_back(lDaughter.globalIndex()); + } + } + return lDaughtersIndeces; + }; + auto getDaughtersPDGCodes = [&](auto const& theMcParticle) { + std::vector lDaughtersPDGs{}; + for (auto const& lDaughter : theMcParticle.template daughters_as()) { + LOGF(debug, " daughter pdgcode lDaughter: %d", lDaughter.pdgCode()); + if (lDaughter.globalIndex() != 0) { + lDaughtersPDGs.push_back(lDaughter.pdgCode()); + } + } + return lDaughtersPDGs; + }; + // ------ + std::vector mothers = {-1, -1}; + std::vector motherPDGs = {-1, -1}; + std::vector daughters = {-1, -1}; + std::vector daughterPDGs = {-1, -1}; + if (v0.has_mcParticle()) { + if (cfgFillQA) { + qaRegistry.fill(HIST("QA/hGoodMCV0Indices"), 0); + } + auto v0mc = v0.mcParticle(); + if (v0mc.has_mothers()) { + mothers = getMothersIndeces(v0mc); + motherPDGs = getMothersPDGCodes(v0mc); + } + while (mothers.size() > 2) { + mothers.pop_back(); + motherPDGs.pop_back(); + } + if (v0mc.has_daughters()) { + daughters = getDaughtersIndeces(v0mc); + daughterPDGs = getDaughtersPDGCodes(v0mc); + } + while (daughters.size() > 2) { + LOGF(info, "daughters.size() is larger than 2"); + daughters.pop_back(); + daughterPDGs.pop_back(); + } + reso2mcv0s(v0mc.pdgCode(), + mothers[0], + motherPDGs[0], + daughters[0], + daughters[1], + daughterPDGs[0], + daughterPDGs[1], + v0mc.isPhysicalPrimary(), + v0mc.producedByGenerator()); + } else { + reso2mcv0s(0, + mothers[0], + motherPDGs[0], + daughters[0], + daughters[1], + daughterPDGs[0], + daughterPDGs[1], + 0, + 0); + } + } + + /** + * @brief Fills cascade data + * + * @tparam isMC Boolean indicating if it's MC + * @tparam CollisionType Type of collision + * @tparam CascType Type of cascade + * @tparam TrackType Type of track + * @param collision Collision data + * @param cascades Cascade data + * @param tracks Track data + */ + template + void fillCascades(CollisionType const& collision, CascType const& cascades, TrackType const&) + { + int childIDs[3] = {0, 0, 0}; // these IDs are necessary to keep track of the children + for (auto const& casc : cascades) { + if (cfgFillQA) { + qaRegistry.fill(HIST("QA/hGoodCascIndices"), 0); + qaRegistry.fill(HIST("QA/hCascRadius"), casc.cascradius()); + qaRegistry.fill(HIST("QA/hCascCosPA"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + } + childIDs[0] = casc.posTrackId(); + childIDs[1] = casc.negTrackId(); + childIDs[2] = casc.bachelorId(); + reso2cascades(collision.globalIndex(), + casc.globalIndex(), + casc.pt(), + casc.px(), + casc.py(), + casc.pz(), + casc.eta(), + casc.phi(), + childIDs, + casc.template posTrack_as().tpcNSigmaPi(), + casc.template posTrack_as().tpcNSigmaKa(), + casc.template posTrack_as().tpcNSigmaPr(), + casc.template negTrack_as().tpcNSigmaPi(), + casc.template negTrack_as().tpcNSigmaKa(), + casc.template negTrack_as().tpcNSigmaPr(), + casc.template bachelor_as().tpcNSigmaPi(), + casc.template bachelor_as().tpcNSigmaKa(), + casc.template bachelor_as().tpcNSigmaPr(), + casc.template posTrack_as().tofNSigmaPi(), + casc.template posTrack_as().tofNSigmaKa(), + casc.template posTrack_as().tofNSigmaPr(), + casc.template negTrack_as().tofNSigmaPi(), + casc.template negTrack_as().tofNSigmaKa(), + casc.template negTrack_as().tofNSigmaPr(), + casc.template bachelor_as().tofNSigmaPi(), + casc.template bachelor_as().tofNSigmaKa(), + casc.template bachelor_as().tofNSigmaPr(), + casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()), + casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()), + casc.dcaV0daughters(), + casc.dcacascdaughters(), + casc.dcapostopv(), + casc.dcanegtopv(), + casc.dcabachtopv(), + casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ()), + casc.dcaXYCascToPV(), + casc.dcaZCascToPV(), + casc.sign(), + casc.mXi(), + casc.v0radius(), casc.cascradius(), casc.x(), casc.y(), casc.z()); + if constexpr (isMC) { + fillMCCascade(casc); + } + } + } + + /** + * @brief Fills MC cascade data + * + * @tparam CascType Type of cascade + * @param casc Cascade data + */ + template + void fillMCCascade(CascType const& casc) + { + // ------ Temporal lambda function to prevent error in build + auto getMothersIndeces = [&](auto const& theMcParticle) { + std::vector lMothersIndeces{}; + for (auto const& lMother : theMcParticle.template mothers_as()) { + LOGF(debug, " mother index lMother: %d", lMother.globalIndex()); + lMothersIndeces.push_back(lMother.globalIndex()); + } + return lMothersIndeces; + }; + auto getMothersPDGCodes = [&](auto const& theMcParticle) { + std::vector lMothersPDGs{}; + for (auto const& lMother : theMcParticle.template mothers_as()) { + LOGF(debug, " mother pdgcode lMother: %d", lMother.pdgCode()); + lMothersPDGs.push_back(lMother.pdgCode()); + } + return lMothersPDGs; + }; + auto getDaughtersIndeces = [&](auto const& theMcParticle) { + std::vector lDaughtersIndeces{}; + for (auto const& lDaughter : theMcParticle.template daughters_as()) { + LOGF(debug, " daughter index lDaughter: %d", lDaughter.globalIndex()); + if (lDaughter.globalIndex() != 0) { + lDaughtersIndeces.push_back(lDaughter.globalIndex()); + } + } + return lDaughtersIndeces; + }; + auto getDaughtersPDGCodes = [&](auto const& theMcParticle) { + std::vector lDaughtersPDGs{}; + for (auto const& lDaughter : theMcParticle.template daughters_as()) { + LOGF(debug, " daughter pdgcode lDaughter: %d", lDaughter.pdgCode()); + if (lDaughter.globalIndex() != 0) { + lDaughtersPDGs.push_back(lDaughter.pdgCode()); + } + } + return lDaughtersPDGs; + }; + // ------ + std::vector mothers = {-1, -1}; + std::vector motherPDGs = {-1, -1}; + std::vector daughters = {-1, -1}; + std::vector daughterPDGs = {-1, -1}; + if (casc.has_mcParticle()) { + if (cfgFillQA) { + qaRegistry.fill(HIST("QA/hGoodMCCascIndices"), 0); + } + auto cascmc = casc.mcParticle(); + if (cascmc.has_mothers()) { + mothers = getMothersIndeces(cascmc); + motherPDGs = getMothersPDGCodes(cascmc); + } + while (mothers.size() > 2) { + mothers.pop_back(); + motherPDGs.pop_back(); + } + if (cascmc.has_daughters()) { + daughters = getDaughtersIndeces(cascmc); + daughterPDGs = getDaughtersPDGCodes(cascmc); + } + while (daughters.size() > 2) { + LOGF(info, "daughters.size() is larger than 2"); + daughters.pop_back(); + daughterPDGs.pop_back(); + } + reso2mccascades(cascmc.pdgCode(), + mothers[0], + motherPDGs[0], + daughters[0], + daughters[1], + daughterPDGs[0], + daughterPDGs[1], + cascmc.isPhysicalPrimary(), + cascmc.producedByGenerator()); + } else { + reso2mccascades(0, + mothers[0], + motherPDGs[0], + daughters[0], + daughters[1], + daughterPDGs[0], + daughterPDGs[1], + 0, + 0); + } + } + + /** + * @brief Processes dummy + * + * @param collision Collision data + */ + void processDummy(aod::ResoCollision const&) + { + } + PROCESS_SWITCH(ResonanceDaughterInitializer, processDummy, "Process dummy", true); + + /** + * @brief Processes data tracks + * + * @param collision Collision data + * @param tracks Track data + */ + void processData(aod::ResoCollision const& collision, + soa::Filtered const& tracks) + { + fillTracks(collision, tracks); + } + PROCESS_SWITCH(ResonanceDaughterInitializer, processData, "Process tracks for data", false); + + /** + * @brief Processes MC tracks + * + * @param collision Collision data + * @param tracks Track data + * @param mcParticles MC particles + */ + void processMC(aod::ResoCollision const& collision, + soa::Filtered const& tracks, + aod::McParticles const&) + { + fillTracks(collision, tracks); + } + PROCESS_SWITCH(ResonanceDaughterInitializer, processMC, "Process tracks for MC", false); + + /** + * @brief Processes V0 data + * + * @param collision Collision data + * @param v0s V0 data + * @param tracks Track data + */ + void processV0Data(aod::ResoCollision const& collision, soa::Filtered const& v0s, aod::ResoTrackCandidates const& tracks) + { + fillV0s(collision, v0s, tracks); + } + PROCESS_SWITCH(ResonanceDaughterInitializer, processV0Data, "Process V0s for data", false); + + /** + * @brief Processes MC V0 data + * + * @param collision Collision data + * @param v0s V0 data + * @param tracks Track data + */ + void processV0MC(aod::ResoCollision const& collision, soa::Filtered const& v0s, aod::ResoTrackCandidatesMC const& tracks) + { + fillV0s(collision, v0s, tracks); + } + PROCESS_SWITCH(ResonanceDaughterInitializer, processV0MC, "Process V0s for MC", false); + + /** + * @brief Processes cascade data + * + * @param collision Collision data + * @param cascades Cascade data + * @param tracks Track data + */ + void processCascData(aod::ResoCollision const& collision, soa::Filtered const& cascades, aod::ResoTrackCandidates const& tracks) + { + fillCascades(collision, cascades, tracks); + } + PROCESS_SWITCH(ResonanceDaughterInitializer, processCascData, "Process Cascades for data", false); + + /** + * @brief Processes MC cascade data + * + * @param collision Collision data + * @param cascades Cascade data + * @param tracks Track data + */ + void processCascMC(aod::ResoCollision const& collision, soa::Filtered const& cascades, aod::ResoTrackCandidatesMC const& tracks) + { + fillCascades(collision, cascades, tracks); + } + PROCESS_SWITCH(ResonanceDaughterInitializer, processCascMC, "Process Cascades for MC", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Resonances/xi1530Analysis.cxx b/PWGLF/Tasks/Resonances/xi1530Analysis.cxx index be3c24b8ffb..95a9c48705b 100644 --- a/PWGLF/Tasks/Resonances/xi1530Analysis.cxx +++ b/PWGLF/Tasks/Resonances/xi1530Analysis.cxx @@ -350,7 +350,7 @@ struct cascadeXiAnalysis { histos.fill(HIST("QA_Casc_Xi/h1d_dca_bachtoPV"), casc.dcabachtopv()); histos.fill(HIST("QA_Casc_Xi/h1d_dca_v0toPV"), casc.dcav0topv()); histos.fill(HIST("QA_Casc_Xi/h1d_dca_v0_dau"), casc.daughDCA()); - histos.fill(HIST("QA_Casc_Xi/h1d_dca_casc_dau"), casc.cascdaughDCA()); + histos.fill(HIST("QA_Casc_Xi/h1d_dca_casc_dau"), casc.cascDaughDCA()); } fillDataHisto(cascTracks, resoTracks, resoCollision.cent()); diff --git a/PWGLF/Tasks/Resonances/xi1530Analysisqa.cxx b/PWGLF/Tasks/Resonances/xi1530Analysisqa.cxx index 6781fdffdaf..a7b0212ad88 100644 --- a/PWGLF/Tasks/Resonances/xi1530Analysisqa.cxx +++ b/PWGLF/Tasks/Resonances/xi1530Analysisqa.cxx @@ -489,7 +489,7 @@ struct xi1530analysisqa { // Topological Cuts for Cascades if (track.dcabachtopv() < cDCABachlorToPVcut) return false; - if (track.cascdaughDCA() > cDCAXiDaugtherscut) + if (track.cascDaughDCA() > cDCAXiDaugtherscut) return false; if (track.cascCosPA() < cCosPACasc) return false; diff --git a/PWGLF/Utils/collisionCuts.h b/PWGLF/Utils/collisionCuts.h index a272cb32670..6322e272083 100644 --- a/PWGLF/Utils/collisionCuts.h +++ b/PWGLF/Utils/collisionCuts.h @@ -24,8 +24,6 @@ #include "Framework/Logger.h" #include "Common/DataModel/EventSelection.h" -using namespace o2::framework; - namespace o2::analysis { @@ -79,26 +77,26 @@ class CollisonCuts /// Initializes histograms for the task /// \param registry Histogram registry to be passed - void init(HistogramRegistry* registry) + void init(o2::framework::HistogramRegistry* registry) { if (!mCutsSet) { LOGF(error, "Event selection not set - quitting!"); } mHistogramRegistry = registry; - mHistogramRegistry->add("Event/posZ", "; vtx_{z} (cm); Entries", kTH1F, {{250, -12.5, 12.5}}); // z-vertex histogram after event selections - mHistogramRegistry->add("Event/posZ_noCut", "; vtx_{z} (cm); Entries", kTH1F, {{250, -12.5, 12.5}}); // z-vertex histogram before all selections + mHistogramRegistry->add("Event/posZ", "; vtx_{z} (cm); Entries", o2::framework::kTH1F, {{250, -12.5, 12.5}}); // z-vertex histogram after event selections + mHistogramRegistry->add("Event/posZ_noCut", "; vtx_{z} (cm); Entries", o2::framework::kTH1F, {{250, -12.5, 12.5}}); // z-vertex histogram before all selections if (mCheckIsRun3) { - mHistogramRegistry->add("Event/CentFV0A", "; vCentV0A; Entries", kTH1F, {{110, 0, 110}}); - mHistogramRegistry->add("Event/CentFT0M", "; vCentT0M; Entries", kTH1F, {{110, 0, 110}}); - mHistogramRegistry->add("Event/CentFT0C", "; vCentT0C; Entries", kTH1F, {{110, 0, 110}}); - mHistogramRegistry->add("Event/CentFT0A", "; vCentT0A; Entries", kTH1F, {{110, 0, 110}}); - mHistogramRegistry->add("Event/posZ_ITSOnly", "; vtx_{z} (cm); Entries", kTH1F, {{250, -12.5, 12.5}}); - mHistogramRegistry->add("Event/posZ_ITSTPC", "; vtx_{z} (cm); Entries", kTH1F, {{250, -12.5, 12.5}}); - mHistogramRegistry->add("Event/trackOccupancyInTimeRange_noCut", "; Occupancy; Entries", kTH1F, {{500, 0., 20000.}}); + mHistogramRegistry->add("Event/CentFV0A", "; vCentV0A; Entries", o2::framework::kTH1F, {{110, 0, 110}}); + mHistogramRegistry->add("Event/CentFT0M", "; vCentT0M; Entries", o2::framework::kTH1F, {{110, 0, 110}}); + mHistogramRegistry->add("Event/CentFT0C", "; vCentT0C; Entries", o2::framework::kTH1F, {{110, 0, 110}}); + mHistogramRegistry->add("Event/CentFT0A", "; vCentT0A; Entries", o2::framework::kTH1F, {{110, 0, 110}}); + mHistogramRegistry->add("Event/posZ_ITSOnly", "; vtx_{z} (cm); Entries", o2::framework::kTH1F, {{250, -12.5, 12.5}}); + mHistogramRegistry->add("Event/posZ_ITSTPC", "; vtx_{z} (cm); Entries", o2::framework::kTH1F, {{250, -12.5, 12.5}}); + mHistogramRegistry->add("Event/trackOccupancyInTimeRange_noCut", "; Occupancy; Entries", o2::framework::kTH1F, {{500, 0., 20000.}}); } else { - mHistogramRegistry->add("Event/CentRun2V0M", "; vCentV0M; Entries", kTH1F, {{110, 0, 110}}); + mHistogramRegistry->add("Event/CentRun2V0M", "; vCentV0M; Entries", o2::framework::kTH1F, {{110, 0, 110}}); } - mHistogramRegistry->add("CollCutCounts", "; ; Entries", kTH1F, {{11, 0., 11.}}); + mHistogramRegistry->add("CollCutCounts", "; ; Entries", o2::framework::kTH1F, {{11, 0., 11.}}); mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kAllEvent), "all"); mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kFlagZvertex), "Zvtx"); mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kFlagTrigerTVX), "IsTriggerTVX"); @@ -221,6 +219,11 @@ class CollisonCuts LOGF(debug, "Offline selection failed (sel7)"); return false; } + auto bc = col.template bc_as(); + if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted))) { + LOGF(debug, "Offline selection failed (AliEventCuts)"); + return false; + } mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagTrigerTVX); } if (mCheckTrigger && !col.alias_bit(mTrigger)) { @@ -273,23 +276,24 @@ class CollisonCuts } private: - HistogramRegistry* mHistogramRegistry = nullptr; ///< For QA output - bool mCutsSet = false; ///< Protection against running without cuts - bool mCheckTrigger = false; ///< Check for trigger - bool mTriggerTVXselection = false; ///< Check for trigger TVX selection - bool mCheckOffline = false; ///< Check for offline criteria (might change) - bool mCheckIsRun3 = false; ///< Check if running on Pilot Beam - bool mInitialTriggerScan = false; ///< Check trigger when the event is first selected - bool mApplyTFBorderCut = false; ///< Apply time frame border cut - bool mApplyITSTPCvertex = false; ///< Apply at least one ITS-TPC track for vertexing - bool mApplyZvertexTimedifference = false; ///< removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference. - bool mApplyPileupRejection = false; ///< Pileup rejection - bool mApplyNoITSROBorderCut = false; ///< Apply NoITSRO frame border cut - bool mApplyCollInTimeRangeStandard = false; ///< Apply NoCollInTimeRangeStandard selection - int mTrigger = kINT7; ///< Trigger to check for - float mZvtxMax = 999.f; ///< Maximal deviation from nominal z-vertex (cm) - int mtrackOccupancyInTimeRangeMax = -1; ///< Maximum trackOccupancyInTimeRange cut (-1 no cut) - int mtrackOccupancyInTimeRangeMin = -1; ///< Minimum trackOccupancyInTimeRange cut (-1 no cut) + using BCsWithRun2Info = soa::Join; + o2::framework::HistogramRegistry* mHistogramRegistry = nullptr; ///< For QA output + bool mCutsSet = false; ///< Protection against running without cuts + bool mCheckTrigger = false; ///< Check for trigger + bool mTriggerTVXselection = false; ///< Check for trigger TVX selection + bool mCheckOffline = false; ///< Check for offline criteria (might change) + bool mCheckIsRun3 = false; ///< Check if running on Pilot Beam + bool mInitialTriggerScan = false; ///< Check trigger when the event is first selected + bool mApplyTFBorderCut = false; ///< Apply time frame border cut + bool mApplyITSTPCvertex = false; ///< Apply at least one ITS-TPC track for vertexing + bool mApplyZvertexTimedifference = false; ///< removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference. + bool mApplyPileupRejection = false; ///< Pileup rejection + bool mApplyNoITSROBorderCut = false; ///< Apply NoITSRO frame border cut + bool mApplyCollInTimeRangeStandard = false; ///< Apply NoCollInTimeRangeStandard selection + int mTrigger = kINT7; ///< Trigger to check for + float mZvtxMax = 999.f; ///< Maximal deviation from nominal z-vertex (cm) + int mtrackOccupancyInTimeRangeMax = -1; ///< Maximum trackOccupancyInTimeRange cut (-1 no cut) + int mtrackOccupancyInTimeRangeMin = -1; ///< Minimum trackOccupancyInTimeRange cut (-1 no cut) }; } // namespace o2::analysis