@@ -98,7 +98,7 @@ struct PhotonConversionBuilder {
9898 Produces<aod::V0Legs> v0legs;
9999 Produces<aod::V0LegsXYZ> v0legsXYZ;
100100 Produces<aod::V0LegsDeDxMC> v0legsDeDxMC;
101- Produces<aod::V0PhotonsPhiV> v0photonsphiv ;
101+ Produces<aod::V0PhotonsPhiVPsi> v0photonsphivpsi ;
102102 // Produces<aod::V0PhotonsKFCov> v0photonskfcov;
103103 // Produces<aod::EMEventsNgPCM> events_ngpcm;
104104
@@ -165,7 +165,7 @@ struct PhotonConversionBuilder {
165165 Configurable<bool > loadModelsFromCCDB{" loadModelsFromCCDB" , false , " Flag to enable or disable the loading of models from CCDB" };
166166 Configurable<int > nClassesPCMMl{" nClassesPCMMl" , static_cast <int >(o2::analysis::em_cuts_ml::NCutScores), " Number of classes in ML model" };
167167 Configurable<int > timestampCCDB{" timestampCCDB" , -1 , " timestamp of the ONNX file for ML model used to query in CCDB" };
168- Configurable<std::string > centTypePCMMl{" centTypePCMMl" , " CentFT0C " , " Centrality type for 2D ML application: CentFT0C, CentFT0M, or CentFT0A " };
168+ Configurable<int > centTypePCMMl{" centTypePCMMl" , 2 , " Centrality type for 2D ML application: FT0M:0, FT0A:1, FT0C:2 " };
169169 Configurable<std::vector<int >> cutDirPCMMl{" cutDirPCMMl" , std::vector<int >{o2::analysis::em_cuts_ml::vecCutDir}, " Whether to reject score values greater or smaller than the threshold" };
170170 Configurable<std::vector<std::string>> namesInputFeatures{" namesInputFeatures" , std::vector<std::string>{" feature1" , " feature2" }, " Names of ML model input features" };
171171 Configurable<std::vector<std::string>> modelPathsCCDB{" modelPathsCCDB" , std::vector<std::string>{" path_ccdb/BDT_PCM/" }, " Paths of models on CCDB" };
@@ -176,8 +176,11 @@ struct PhotonConversionBuilder {
176176 Configurable<std::vector<double >> binsCentPCMMl{" binsCentPCMMl" , std::vector<double >{0.0 , 100.0 }, " Centrality bin limits for ML application" };
177177 Configurable<std::vector<double >> cutsPCMMlFlat{" cutsPCMMlFlat" , {0.5 }, " Flattened ML cuts: [bin0_score0, bin0_score1, ..., binN_scoreM]" };
178178
179+ Configurable<float > propV0LegsRadius{" propV0LegsRadius" , 60 .f , " Radius to which the V0 legs are propagated to calculate psipair and phiV" };
180+
179181 o2::analysis::EmMlResponsePCM<float > emMlResponse;
180182 std::vector<float > outputML;
183+ V0PhotonCandidate v0photoncandidate;
181184 o2::ccdb::CcdbApi ccdbApi;
182185
183186 int mRunNumber ;
@@ -213,9 +216,7 @@ struct PhotonConversionBuilder {
213216 {" V0/hRxy_minX_ITSTPC_TPC" , " min trackiu X vs. R_{xy};trackiu X (cm);min trackiu X - R_{xy} (cm)" , {HistType::kTH2F , {{100 , 0 .0f , 100 .f }, {100 , -50.0 , 50 .0f }}}},
214217 {" V0/hRxy_minX_TPC_TPC" , " min trackiu X vs. R_{xy};trackiu X (cm);min trackiu X - R_{xy} (cm)" , {HistType::kTH2F , {{100 , 0 .0f , 100 .f }, {100 , -50.0 , 50 .0f }}}},
215218 {" V0/hPCA_diffX" , " PCA vs. trackiu X - R_{xy};distance btween 2 legs (cm);min trackiu X - R_{xy} (cm)" , {HistType::kTH2F , {{500 , 0 .0f , 5 .f }, {100 , -50.0 , 50 .0f }}}},
216- {" V0/hPhiV" , " #phi_{V}; #phi_{V} (rad.)" , {HistType::kTH1F , {{500 , 0 .0f , o2::constants::math::TwoPI}}}},
217- {" V0/hBDTvalueBeforeCutVsPt" , " BDT response before cut vs pT; pT (GeV/c); BDT response" , {HistType::kTH2F , {{1000 , 0 .0f , 20 .0f }, {1000 , 0 .0f , 1 .0f }}}},
218- {" V0/hBDTvalueAfterCutVsPt" , " BDT response after cut vs pT; pT (GeV/c); BDT response" , {HistType::kTH2F , {{1000 , 0 .0f , 20 .0f }, {1000 , 0 .0f , 1 .0f }}}},
219+ {" V0/hPhiVPsiPair" , " phiV vs. psi pair;#psi_{pair} (rad.);#phi_{V} (rad.)" , {HistType::kTH2F , {{500 , -o2::constants::math::PI, o2::constants::math::PI}, {500 , 0 .0f , o2::constants::math::TwoPI}}}},
219220 {" V0Leg/hPt" , " pT of leg at SV;p_{T,e} (GeV/c)" , {HistType::kTH1F , {{1000 , 0 .0f , 10 .0f }}}},
220221 {" V0Leg/hEtaPhi" , " #eta vs. #varphi of leg at SV;#varphi (rad.);#eta" , {HistType::kTH2F , {{72 , 0 .0f , o2::constants::math::TwoPI}, {200 , -1 , +1 }}}},
221222 {" V0Leg/hRelDeltaPt" , " pT resolution;p_{T} (GeV/c);#Deltap_{T}/p_{T}" , {HistType::kTH2F , {{1000 , 0 .f , 10 .f }, {100 , 0 , 1 }}}},
@@ -305,6 +306,22 @@ struct PhotonConversionBuilder {
305306 }
306307 emMlResponse.cacheInputFeaturesIndices (namesInputFeatures);
307308 emMlResponse.init ();
309+ if (nClassesPCMMl == 2 ) {
310+ registry.add (" V0/hBDTBackgroundScoreBeforeCutVsPt" , " BDT background score before cut vs pT; pT (GeV/c); BDT background score" , {HistType::kTH2F , {{1000 , 0 .0f , 20 .0f }, {1000 , 0 .0f , 1 .0f }}});
311+ registry.add (" V0/hBDTBackgroundScoreAfterCutVsPt" , " BDT background score after cut vs pT; pT (GeV/c); BDT background score" , {HistType::kTH2F , {{1000 , 0 .0f , 20 .0f }, {1000 , 0 .0f , 1 .0f }}});
312+ registry.add (" V0/hBDTSignalScoreBeforeCutVsPt" , " BDT signal score before cut vs pT; pT (GeV/c); BDT signal score" , {HistType::kTH2F , {{1000 , 0 .0f , 20 .0f }, {1000 , 0 .0f , 1 .0f }}});
313+ registry.add (" V0/hBDTSignalScoreAfterCutVsPt" , " BDT signal score after cut vs pT; pT (GeV/c); BDT signal score" , {HistType::kTH2F , {{1000 , 0 .0f , 20 .0f }, {1000 , 0 .0f , 1 .0f }}});
314+ } else if (nClassesPCMMl == 3 ) {
315+ registry.add (" V0/hBDTBackgroundScoreBeforeCutVsPt" , " BDT background score before cut vs pT; pT (GeV/c); BDT background score" , {HistType::kTH2F , {{1000 , 0 .0f , 20 .0f }, {1000 , 0 .0f , 1 .0f }}});
316+ registry.add (" V0/hBDTBackgroundScoreAfterCutVsPt" , " BDT background score after cut vs pT; pT (GeV/c); BDT background score" , {HistType::kTH2F , {{1000 , 0 .0f , 20 .0f }, {1000 , 0 .0f , 1 .0f }}});
317+ registry.add (" V0/hBDTPrimaryPhotonScoreBeforeCutVsPt" , " BDT primary photon score before cut vs pT; pT (GeV/c); BDT primary photon score" , {HistType::kTH2F , {{1000 , 0 .0f , 20 .0f }, {1000 , 0 .0f , 1 .0f }}});
318+ registry.add (" V0/hBDTPrimaryPhotonScoreAfterCutVsPt" , " BDT primary photon score after cut vs pT; pT (GeV/c); BDT primary photon score" , {HistType::kTH2F , {{1000 , 0 .0f , 20 .0f }, {1000 , 0 .0f , 1 .0f }}});
319+ registry.add (" V0/hBDTSecondaryPhotonScoreBeforeCutVsPt" , " BDT secondary photon score before cut vs pT; pT (GeV/c); BDT secondary photon score" , {HistType::kTH2F , {{1000 , 0 .0f , 20 .0f }, {1000 , 0 .0f , 1 .0f }}});
320+ registry.add (" V0/hBDTSecondaryPhotonScoreAfterCutVsPt" , " BDT secondary photon score after cut vs pT; pT (GeV/c); BDT secondary photon score" , {HistType::kTH2F , {{1000 , 0 .0f , 20 .0f }, {1000 , 0 .0f , 1 .0f }}});
321+ } else {
322+ registry.add (" V0/hBDTScoreBeforeCutVsPt" , " BDT score before cut vs pT; pT (GeV/c); BDT score" , {HistType::kTH2F , {{1000 , 0 .0f , 20 .0f }, {1000 , 0 .0f , 1 .0f }}});
323+ registry.add (" V0/hBDTScoreAfterCutVsPt" , " BDT score after cut vs pT; pT (GeV/c); BDT score" , {HistType::kTH2F , {{1000 , 0 .0f , 20 .0f }, {1000 , 0 .0f , 1 .0f }}});
324+ }
308325 }
309326 }
310327
@@ -468,17 +485,17 @@ struct PhotonConversionBuilder {
468485 return cospaRZ;
469486 }
470487
471- template <bool isMC, typename TTrack, typename TShiftedTrack, typename TKFParticle >
472- void fillTrackTable (TTrack const & track, TShiftedTrack const & shiftedtrack, TKFParticle const & kfp, const float dcaXY, const float dcaZ)
488+ template <bool isMC, typename TTrack, typename TShiftedTrack >
489+ void fillTrackTable (TTrack const & track, TShiftedTrack const & shiftedtrack, const float dcaXY, const float dcaZ)
473490 {
474491 v0legs (track.collisionId (), track.globalIndex (), track.sign (),
475- kfp .GetPx (), kfp .GetPy (), kfp .GetPz (), dcaXY, dcaZ,
492+ shiftedtrack .GetPx (), shiftedtrack .GetPy (), shiftedtrack .GetPz (), dcaXY, dcaZ,
476493 track.tpcNClsFindable (), track.tpcNClsFindableMinusFound (), track.tpcNClsFindableMinusCrossedRows (), track.tpcNClsShared (),
477494 track.tpcChi2NCl (), track.tpcInnerParam (), track.tpcSignal (),
478495 track.tpcNSigmaEl (), track.tpcNSigmaPi (),
479496 track.itsClusterSizes (), track.itsChi2NCl (), track.detectorMap ());
480497
481- v0legsXYZ (shiftedtrack.getX (), shiftedtrack.getY (), shiftedtrack.getZ ());
498+ v0legsXYZ (shiftedtrack.GetX (), shiftedtrack.GetY (), shiftedtrack.GetZ ());
482499
483500 if constexpr (isMC) {
484501 v0legsDeDxMC (track.mcTunedTPCSignal ());
@@ -564,6 +581,37 @@ struct PhotonConversionBuilder {
564581 return ; // RZ line cut
565582 }
566583
584+ float phiv = 999 .f ;
585+ float psipair = 999 .f ;
586+ float baseR = std::hypot (xyz[0 ], xyz[1 ]);
587+ float offsetsR[3 ] = {propV0LegsRadius, 30 .f , 10 .f };
588+ bool pPropagatedSuccess = false ;
589+ bool nPropagatedSuccess = false ;
590+ auto pTrackProp = pTrack;
591+ auto nTrackProp = nTrack;
592+ for (float offsetR : offsetsR) {
593+ pTrackProp = pTrack;
594+ pTrackProp.setPID (o2::track::PID::Electron);
595+ nTrackProp = nTrack;
596+ nTrackProp.setPID (o2::track::PID::Electron);
597+ o2::base::Propagator::Instance ()->propagateToDCABxByBz ({collision.posX (), collision.posY (), collision.posZ ()}, pTrackProp, 2 .f , matCorr, &dcaInfo);
598+ o2::base::Propagator::Instance ()->propagateToDCABxByBz ({collision.posX (), collision.posY (), collision.posZ ()}, nTrackProp, 2 .f , matCorr, &dcaInfo);
599+ pPropagatedSuccess = o2::base::Propagator::Instance ()->propagateToR (pTrackProp, baseR + offsetR);
600+ nPropagatedSuccess = o2::base::Propagator::Instance ()->propagateToR (nTrackProp, baseR + offsetR);
601+ if (pPropagatedSuccess && nPropagatedSuccess) {
602+ KFPTrack kfp_track_posProp = createKFPTrackFromTrackParCov (pTrackProp, pos.sign (), pos.tpcNClsFound (), pos.tpcChi2NCl ());
603+ KFPTrack kfp_track_eleProp = createKFPTrackFromTrackParCov (nTrackProp, ele.sign (), ele.tpcNClsFound (), ele.tpcChi2NCl ());
604+ phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair (kfp_track_posProp.GetPx (), kfp_track_posProp.GetPy (), kfp_track_posProp.GetPz (), kfp_track_eleProp.GetPx (), kfp_track_eleProp.GetPy (), kfp_track_eleProp.GetPz (), pos.sign (), ele.sign (), d_bz);
605+ psipair = o2::aod::pwgem::dilepton::utils::pairutil::getPsiPair (kfp_track_posProp.GetPx (), kfp_track_posProp.GetPy (), kfp_track_posProp.GetPz (), kfp_track_eleProp.GetPx (), kfp_track_eleProp.GetPy (), kfp_track_eleProp.GetPz ());
606+ break ;
607+ } else {
608+ LOG (debug) << " Propagation to offset" << offsetR << " cm failed for " << (pPropagatedSuccess ? " negative" : " positive" ) << " track. Trying smaller offset." ;
609+ }
610+ }
611+ if (phiv == 999 .f || psipair == 999 .f ) {
612+ LOG (debug) << " Propagation failed for all radii (" << propV0LegsRadius << " , 30, 10 cm). Using default values for phiv and psipair (999.f)." ;
613+ }
614+
567615 KFPTrack kfp_track_pos = createKFPTrackFromTrackParCov (pTrack, pos.sign (), pos.tpcNClsFound (), pos.tpcChi2NCl ());
568616 KFPTrack kfp_track_ele = createKFPTrackFromTrackParCov (nTrack, ele.sign (), ele.tpcNClsFound (), ele.tpcChi2NCl ());
569617 KFParticle kfp_pos (kfp_track_pos, kPositron );
@@ -674,7 +722,8 @@ struct PhotonConversionBuilder {
674722 kfp_pos_DecayVtx.TransportToPoint (xyz); // Don't set Primary Vertex
675723 kfp_ele_DecayVtx.TransportToPoint (xyz); // Don't set Primary Vertex
676724
677- V0PhotonCandidate v0photoncandidate (gammaKF_DecayVtx, kfp_pos_DecayVtx, kfp_ele_DecayVtx, collision, cospa_kf, d_bz);
725+ CentType centType = static_cast <CentType>(centTypePCMMl.value );
726+ v0photoncandidate.setPhotonCandidate (gammaKF_DecayVtx, kfp_pos_DecayVtx, kfp_ele_DecayVtx, collision, cospa_kf, psipair, phiv, centType);
678727
679728 if (!ele.hasITS () && !pos.hasITS ()) { // V0s with TPConly-TPConly
680729 if (max_r_itsmft_ss < rxy && rxy < maxX + margin_r_tpc) {
@@ -724,26 +773,36 @@ struct PhotonConversionBuilder {
724773 bool isSelectedML = false ;
725774 std::vector<float > mlInputFeatures = emMlResponse.getInputFeatures (v0photoncandidate, pos, ele);
726775 if (use2DBinning) {
727- if (std::string (centTypePCMMl) == " CentFT0C" ) {
728- isSelectedML = emMlResponse.isSelectedMl (mlInputFeatures, v0photoncandidate.getPt (), v0photoncandidate.getCentFT0C (), outputML);
729- } else if (std::string (centTypePCMMl) == " CentFT0A" ) {
730- isSelectedML = emMlResponse.isSelectedMl (mlInputFeatures, v0photoncandidate.getPt (), v0photoncandidate.getCentFT0A (), outputML);
731- } else if (std::string (centTypePCMMl) == " CentFT0M" ) {
732- isSelectedML = emMlResponse.isSelectedMl (mlInputFeatures, v0photoncandidate.getPt (), v0photoncandidate.getCentFT0M (), outputML);
733- } else {
734- LOG (fatal) << " Unsupported centTypePCMMl: " << centTypePCMMl << " , please choose from CentFT0C, CentFT0A, CentFT0M." ;
735- }
776+ isSelectedML = emMlResponse.isSelectedMl (mlInputFeatures, v0photoncandidate.getPt (), v0photoncandidate.getCent (), outputML);
736777 } else {
737778 isSelectedML = emMlResponse.isSelectedMl (mlInputFeatures, v0photoncandidate.getPt (), outputML);
738779 }
739780 if (filltable) {
740- registry.fill (HIST (" V0/hBDTvalueBeforeCutVsPt" ), v0photoncandidate.getPt (), outputML[0 ]);
781+ if (nClassesPCMMl == 2 ) {
782+ registry.fill (HIST (" V0/hBDTBackgroundScoreBeforeCutVsPt" ), v0photoncandidate.getPt (), outputML[0 ]);
783+ registry.fill (HIST (" V0/hBDTSignalScoreBeforeCutVsPt" ), v0photoncandidate.getPt (), outputML[1 ]);
784+ } else if (nClassesPCMMl == 3 ) {
785+ registry.fill (HIST (" V0/hBDTPrimaryPhotonScoreBeforeCutVsPt" ), v0photoncandidate.getPt (), outputML[0 ]);
786+ registry.fill (HIST (" V0/hBDTSecondaryPhotonScoreBeforeCutVsPt" ), v0photoncandidate.getPt (), outputML[1 ]);
787+ registry.fill (HIST (" V0/hBDTBackgroundScoreBeforeCutVsPt" ), v0photoncandidate.getPt (), outputML[2 ]);
788+ } else {
789+ registry.fill (HIST (" V0/hBDTScoreBeforeCutVsPt" ), v0photoncandidate.getPt (), outputML[0 ]);
790+ }
741791 }
742792 if (!isSelectedML) {
743793 return ;
744794 }
745795 if (filltable) {
746- registry.fill (HIST (" V0/hBDTvalueAfterCutVsPt" ), v0photoncandidate.getPt (), outputML[0 ]);
796+ if (nClassesPCMMl == 2 ) {
797+ registry.fill (HIST (" V0/hBDTBackgroundScoreAfterCutVsPt" ), v0photoncandidate.getPt (), outputML[0 ]);
798+ registry.fill (HIST (" V0/hBDTSignalScoreAfterCutVsPt" ), v0photoncandidate.getPt (), outputML[1 ]);
799+ } else if (nClassesPCMMl == 3 ) {
800+ registry.fill (HIST (" V0/hBDTPrimaryPhotonScoreAfterCutVsPt" ), v0photoncandidate.getPt (), outputML[0 ]);
801+ registry.fill (HIST (" V0/hBDTSecondaryPhotonScoreAfterCutVsPt" ), v0photoncandidate.getPt (), outputML[1 ]);
802+ registry.fill (HIST (" V0/hBDTBackgroundScoreAfterCutVsPt" ), v0photoncandidate.getPt (), outputML[2 ]);
803+ } else {
804+ registry.fill (HIST (" V0/hBDTScoreAfterCutVsPt" ), v0photoncandidate.getPt (), outputML[0 ]);
805+ }
747806 }
748807 }
749808
@@ -760,7 +819,7 @@ struct PhotonConversionBuilder {
760819 registry.fill (HIST (" V0/hPCA_Rxy" ), rxy, v0photoncandidate.getPCA ());
761820 registry.fill (HIST (" V0/hDCAxyz" ), v0photoncandidate.getDcaXYToPV (), v0photoncandidate.getDcaZToPV ());
762821 registry.fill (HIST (" V0/hPCA_diffX" ), v0photoncandidate.getPCA (), std::min (pTrack.getX (), nTrack.getX ()) - rxy); // trackiu.x() - rxy should be positive
763- registry.fill (HIST (" V0/hPhiV " ), v0photoncandidate.getPhiV ());
822+ registry.fill (HIST (" V0/hPhiVPsiPair " ), v0photoncandidate. getPsiPair ( ), v0photoncandidate.getPhiV ());
764823
765824 float cospaXY_kf = cospaXY_KF (gammaKF_DecayVtx, KFPV);
766825 float cospaRZ_kf = cospaRZ_KF (gammaKF_DecayVtx, KFPV);
@@ -797,12 +856,12 @@ struct PhotonConversionBuilder {
797856 v0_sv.M (), v0photoncandidate.getDcaXYToPV (), v0photoncandidate.getDcaZToPV (),
798857 cospa_kf, cospaXY_kf, cospaRZ_kf,
799858 v0photoncandidate.getPCA (), v0photoncandidate.getAlpha (), v0photoncandidate.getQt (), v0photoncandidate.getChi2NDF ());
800- v0photonsphiv (v0photoncandidate.getPhiV ());
859+ v0photonsphivpsi (v0photoncandidate.getPhiV (), v0photoncandidate. getPsiPair ());
801860
802861 // v0photonskfcov(gammaKF_PV.GetCovariance(9), gammaKF_PV.GetCovariance(14), gammaKF_PV.GetCovariance(20), gammaKF_PV.GetCovariance(13), gammaKF_PV.GetCovariance(19), gammaKF_PV.GetCovariance(18));
803862
804- fillTrackTable<isMC>(pos, pTrack, kfp_pos_DecayVtx, posdcaXY, posdcaZ); // positive leg first
805- fillTrackTable<isMC>(ele, nTrack, kfp_ele_DecayVtx, eledcaXY, eledcaZ); // negative leg second
863+ fillTrackTable<isMC>(pos, kfp_pos_DecayVtx, posdcaXY, posdcaZ); // positive leg first
864+ fillTrackTable<isMC>(ele, kfp_ele_DecayVtx, eledcaXY, eledcaZ); // negative leg second
806865 } // end of fill table
807866 }
808867
0 commit comments