@@ -1112,6 +1112,12 @@ class VarManager : public TObject
11121112 return false ;
11131113 }
11141114
1115+ // Flag to set PV recalculation via KF
1116+ static void SetPVrecalculationKF (const bool pvRecalKF)
1117+ {
1118+ fgPVrecalKF = pvRecalKF;
1119+ }
1120+
11151121 // Setup the collision system
11161122 static void SetCollisionSystem (TString system, float energy);
11171123 static void SetCollisionSystem (o2::parameters::GRPLHCIFData* grplhcif);
@@ -1314,6 +1320,8 @@ class VarManager : public TObject
13141320 static void FillQuadMC (T1 const & t1, T2 const & t2, T2 const & t3, float * values = nullptr );
13151321 template <int pairType, uint32_t collFillMap, uint32_t fillMap, typename C, typename T>
13161322 static void FillPairVertexing (C const & collision, T const & t1, T const & t2, bool propToSV = false , float * values = nullptr );
1323+ template <int pairType, uint32_t collFillMap, uint32_t fillMap, typename C, typename T>
1324+ static void FillPairVertexingRecomputePV (C const & /* collision*/ , T const & t1, T const & t2, o2::dataformats::VertexBase pvRefitted, float * values = nullptr );
13171325 template <uint32_t collFillMap, uint32_t fillMap, typename C, typename T>
13181326 static void FillTripletVertexing (C const & collision, T const & t1, T const & t2, T const & t3, PairCandidateType tripletType, float * values = nullptr );
13191327 template <int candidateType, uint32_t collFillMap, uint32_t fillMap, typename C, typename T1>
@@ -1428,6 +1436,7 @@ class VarManager : public TObject
14281436 private:
14291437 static bool fgUsedVars[kNVars ]; // holds flags for when the corresponding variable is needed (e.g., in the histogram manager, in cuts, mixing handler, etc.)
14301438 static bool fgUsedKF;
1439+ static bool fgPVrecalKF;
14311440 static void SetVariableDependencies (); // toggle those variables on which other used variables might depend
14321441
14331442 static float fgMagField;
@@ -4207,6 +4216,7 @@ void VarManager::FillPairVertexing(C const& collision, T const& t1, T const& t2,
42074216
42084217 if constexpr ((pairType == kDecayToEE || pairType == kDecayToKPi ) && trackHasCov) {
42094218 secondaryVertex = fgFitterTwoProngBarrel.getPCACandidate ();
4219+ // printf("secVtx (first) %f %f %f \n",secondaryVertex[0],secondaryVertex[1],secondaryVertex[2]);
42104220 covMatrixPCA = fgFitterTwoProngBarrel.calcPCACovMatrixFlat ();
42114221 auto chi2PCA = fgFitterTwoProngBarrel.getChi2AtPCACandidate ();
42124222 auto trackParVar0 = fgFitterTwoProngBarrel.getTrack (0 );
@@ -4215,7 +4225,8 @@ void VarManager::FillPairVertexing(C const& collision, T const& t1, T const& t2,
42154225 v1 = {trackParVar0.getPt (), trackParVar0.getEta (), trackParVar0.getPhi (), m1};
42164226 v2 = {trackParVar1.getPt (), trackParVar1.getEta (), trackParVar1.getPhi (), m2};
42174227 v12 = v1 + v2;
4218- primaryVertexNew = RecalculatePrimaryVertex (t1, t2, collision);
4228+ if (fgPVrecalKF)
4229+ primaryVertexNew = RecalculatePrimaryVertex (t1, t2, collision);
42194230
42204231 } else if constexpr (pairType == kDecayToMuMu && muonHasCov) {
42214232 // Get pca candidate from forward DCA fitter
@@ -4273,13 +4284,15 @@ void VarManager::FillPairVertexing(C const& collision, T const& t1, T const& t2,
42734284 values[kVertexingLxyProjected ] = values[kVertexingLxyProjected ] / TMath::Sqrt ((v12.Px () * v12.Px ()) + (v12.Py () * v12.Py ()));
42744285 values[kVertexingLxyzProjected ] = ((secondaryVertex[0 ] - collision.posX ()) * v12.Px ()) + ((secondaryVertex[1 ] - collision.posY ()) * v12.Py ()) + ((secondaryVertex[2 ] - collision.posZ ()) * v12.Pz ());
42754286 values[kVertexingLxyzProjected ] = values[kVertexingLxyzProjected ] / TMath::Sqrt ((v12.Px () * v12.Px ()) + (v12.Py () * v12.Py ()) + (v12.Pz () * v12.Pz ()));
4276- values[kVertexingLxyProjectedRecalculatePV ] = (secondaryVertex[0 ] - primaryVertexNew.getX ()) * v12.Px () + (secondaryVertex[1 ] - primaryVertexNew.getY ()) * v12.Py ();
4277- values[kVertexingLxyProjectedRecalculatePV ] = values[kVertexingLxyProjectedRecalculatePV ] / v12.Pt ();
4278-
4287+ if (fgPVrecalKF) {
4288+ values[kVertexingLxyProjectedRecalculatePV ] = (secondaryVertex[0 ] - primaryVertexNew.getX ()) * v12.Px () + (secondaryVertex[1 ] - primaryVertexNew.getY ()) * v12.Py ();
4289+ values[kVertexingLxyProjectedRecalculatePV ] = values[kVertexingLxyProjectedRecalculatePV ] / v12.Pt ();
4290+ }
42794291 values[kVertexingTauxyProjected ] = values[kVertexingLxyProjected ] * v12.M () / (v12.Pt ());
42804292 values[kVertexingTauxyProjectedPoleJPsiMass ] = values[kVertexingLxyProjected ] * o2::constants::physics::MassJPsi / (v12.Pt ());
42814293 values[kVertexingTauxyProjectedNs ] = values[kVertexingTauxyProjected ] / o2::constants::physics::LightSpeedCm2NS;
4282- values[kVertexingTauxyProjectedPoleJPsiMassRecalculatePV ] = values[kVertexingLxyProjectedRecalculatePV ] * o2::constants::physics::MassJPsi / (v12.Pt ());
4294+ if (fgPVrecalKF)
4295+ values[kVertexingTauxyProjectedPoleJPsiMassRecalculatePV ] = values[kVertexingLxyProjectedRecalculatePV ] * o2::constants::physics::MassJPsi / (v12.Pt ());
42834296 values[kVertexingTauzProjected ] = values[kVertexingLzProjected ] * v12.M () / TMath::Abs (v12.Pz ());
42844297 values[kVertexingTauxyzProjected ] = values[kVertexingLxyzProjected ] * v12.M () / (v12.P ());
42854298 }
@@ -4497,6 +4510,69 @@ void VarManager::FillPairVertexing(C const& collision, T const& t1, T const& t2,
44974510 }
44984511}
44994512
4513+ template <int pairType, uint32_t collFillMap, uint32_t fillMap, typename C, typename T>
4514+ void VarManager::FillPairVertexingRecomputePV (C const & /* collision*/ , T const & t1, T const & t2, o2::dataformats::VertexBase pvRefitted, float * values)
4515+ {
4516+ // recompute decay lenght variables using updated primary vertex
4517+
4518+ // check at compile time that the event and cov matrix have the cov matrix
4519+ constexpr bool eventHasVtxCov = ((collFillMap & Collision) > 0 || (collFillMap & ReducedEventVtxCov) > 0 );
4520+ constexpr bool trackHasCov = ((fillMap & TrackCov) > 0 || (fillMap & ReducedTrackBarrelCov) > 0 );
4521+ constexpr bool muonHasCov = ((fillMap & MuonCov) > 0 || (fillMap & ReducedMuonCov) > 0 );
4522+
4523+ if (!values) {
4524+ values = fgValues;
4525+ }
4526+
4527+ float m1 = o2::constants::physics::MassElectron;
4528+ float m2 = o2::constants::physics::MassElectron;
4529+ if constexpr (pairType == kDecayToKPi ) {
4530+ m1 = o2::constants::physics::MassKaonCharged;
4531+ m2 = o2::constants::physics::MassPionCharged;
4532+ }
4533+ if constexpr (pairType == kDecayToMuMu && muonHasCov) {
4534+ m1 = o2::constants::physics::MassMuon;
4535+ m2 = o2::constants::physics::MassMuon;
4536+ }
4537+ ROOT::Math::PtEtaPhiMVector v1 (t1.pt (), t1.eta (), t1.phi (), m1);
4538+ ROOT::Math::PtEtaPhiMVector v2 (t2.pt (), t2.eta (), t2.phi (), m2);
4539+ ROOT::Math::PtEtaPhiMVector v12 = v1 + v2;
4540+
4541+ if (fgFitterTwoProngBarrel.getNCandidates () == 0 )
4542+ return ;
4543+ Vec3D secondaryVertex;
4544+
4545+ if (!fgUsedKF) { // to be updated when seconday vertex is computed with KF
4546+ if constexpr (eventHasVtxCov) {
4547+
4548+ if constexpr ((pairType == kDecayToEE || pairType == kDecayToKPi ) && trackHasCov) {
4549+ // Get pca candidate from forward DCA fitter
4550+ // no need to re-compute secondary vertex (done already in FillPairVertexing)
4551+ secondaryVertex = fgFitterTwoProngBarrel.getPCACandidate ();
4552+ auto trackParVar0 = fgFitterTwoProngBarrel.getTrack (0 );
4553+ auto trackParVar1 = fgFitterTwoProngBarrel.getTrack (1 );
4554+ v1 = {trackParVar0.getPt (), trackParVar0.getEta (), trackParVar0.getPhi (), m1};
4555+ v2 = {trackParVar1.getPt (), trackParVar1.getEta (), trackParVar1.getPhi (), m2};
4556+ v12 = v1 + v2;
4557+
4558+ } else if constexpr (pairType == kDecayToMuMu && muonHasCov) {
4559+ // Get pca candidate from forward DCA fitter
4560+ // no need to re-compute secondary vertex (done already in FillPairVertexing)
4561+ secondaryVertex = fgFitterTwoProngFwd.getPCACandidate ();
4562+ auto trackParVar0 = fgFitterTwoProngFwd.getTrack (0 );
4563+ auto trackParVar1 = fgFitterTwoProngFwd.getTrack (1 );
4564+ v1 = {trackParVar0.getPt (), trackParVar0.getEta (), trackParVar0.getPhi (), m1};
4565+ v2 = {trackParVar1.getPt (), trackParVar1.getEta (), trackParVar1.getPhi (), m2};
4566+ v12 = v1 + v2;
4567+ }
4568+
4569+ values[kVertexingLxyProjectedRecalculatePV ] = (secondaryVertex[0 ] - pvRefitted.getX ()) * v12.Px () + (secondaryVertex[1 ] - pvRefitted.getY ()) * v12.Py ();
4570+ values[kVertexingLxyProjectedRecalculatePV ] = values[kVertexingLxyProjectedRecalculatePV ] / v12.Pt ();
4571+ values[kVertexingTauxyProjectedPoleJPsiMassRecalculatePV ] = values[kVertexingLxyProjectedRecalculatePV ] * o2::constants::physics::MassJPsi / (v12.Pt ());
4572+ }
4573+ }
4574+ }
4575+
45004576template <uint32_t collFillMap, uint32_t fillMap, typename C, typename T>
45014577void VarManager::FillTripletVertexing (C const & collision, T const & t1, T const & t2, T const & t3, VarManager::PairCandidateType tripletType, float * values)
45024578{
0 commit comments