@@ -1104,6 +1104,11 @@ class VarManager : public TObject
11041104 return false ;
11051105 }
11061106
1107+ // Flag to set PV recalculation via KF
1108+ static void SetPVrecalculationKF (const bool pvRecalKF) {
1109+ fgPVrecalKF = pvRecalKF;
1110+ }
1111+
11071112 // Setup the collision system
11081113 static void SetCollisionSystem (TString system, float energy);
11091114 static void SetCollisionSystem (o2::parameters::GRPLHCIFData* grplhcif);
@@ -1306,6 +1311,8 @@ class VarManager : public TObject
13061311 static void FillQuadMC (T1 const & t1, T2 const & t2, T2 const & t3, float * values = nullptr );
13071312 template <int pairType, uint32_t collFillMap, uint32_t fillMap, typename C, typename T>
13081313 static void FillPairVertexing (C const & collision, T const & t1, T const & t2, bool propToSV = false , float * values = nullptr );
1314+ template <int pairType, uint32_t collFillMap, uint32_t fillMap, typename C, typename T>
1315+ static void FillPairVertexingRecomputePV (C const & /* collision*/ , T const & t1, T const & t2, o2::dataformats::VertexBase pvRefitted, float * values = nullptr );
13091316 template <uint32_t collFillMap, uint32_t fillMap, typename C, typename T>
13101317 static void FillTripletVertexing (C const & collision, T const & t1, T const & t2, T const & t3, PairCandidateType tripletType, float * values = nullptr );
13111318 template <int candidateType, uint32_t collFillMap, uint32_t fillMap, typename C, typename T1>
@@ -1418,6 +1425,7 @@ class VarManager : public TObject
14181425 private:
14191426 static bool fgUsedVars[kNVars ]; // holds flags for when the corresponding variable is needed (e.g., in the histogram manager, in cuts, mixing handler, etc.)
14201427 static bool fgUsedKF;
1428+ static bool fgPVrecalKF;
14211429 static void SetVariableDependencies (); // toggle those variables on which other used variables might depend
14221430
14231431 static float fgMagField;
@@ -4194,6 +4202,7 @@ void VarManager::FillPairVertexing(C const& collision, T const& t1, T const& t2,
41944202
41954203 if constexpr ((pairType == kDecayToEE || pairType == kDecayToKPi ) && trackHasCov) {
41964204 secondaryVertex = fgFitterTwoProngBarrel.getPCACandidate ();
4205+ // printf("secVtx (first) %f %f %f \n",secondaryVertex[0],secondaryVertex[1],secondaryVertex[2]);
41974206 covMatrixPCA = fgFitterTwoProngBarrel.calcPCACovMatrixFlat ();
41984207 auto chi2PCA = fgFitterTwoProngBarrel.getChi2AtPCACandidate ();
41994208 auto trackParVar0 = fgFitterTwoProngBarrel.getTrack (0 );
@@ -4202,7 +4211,7 @@ void VarManager::FillPairVertexing(C const& collision, T const& t1, T const& t2,
42024211 v1 = {trackParVar0.getPt (), trackParVar0.getEta (), trackParVar0.getPhi (), m1};
42034212 v2 = {trackParVar1.getPt (), trackParVar1.getEta (), trackParVar1.getPhi (), m2};
42044213 v12 = v1 + v2;
4205- primaryVertexNew = RecalculatePrimaryVertex (t1, t2, collision);
4214+ if (fgPVrecalKF) primaryVertexNew = RecalculatePrimaryVertex (t1, t2, collision);
42064215
42074216 } else if constexpr (pairType == kDecayToMuMu && muonHasCov) {
42084217 // Get pca candidate from forward DCA fitter
@@ -4260,13 +4269,14 @@ void VarManager::FillPairVertexing(C const& collision, T const& t1, T const& t2,
42604269 values[kVertexingLxyProjected ] = values[kVertexingLxyProjected ] / TMath::Sqrt ((v12.Px () * v12.Px ()) + (v12.Py () * v12.Py ()));
42614270 values[kVertexingLxyzProjected ] = ((secondaryVertex[0 ] - collision.posX ()) * v12.Px ()) + ((secondaryVertex[1 ] - collision.posY ()) * v12.Py ()) + ((secondaryVertex[2 ] - collision.posZ ()) * v12.Pz ());
42624271 values[kVertexingLxyzProjected ] = values[kVertexingLxyzProjected ] / TMath::Sqrt ((v12.Px () * v12.Px ()) + (v12.Py () * v12.Py ()) + (v12.Pz () * v12.Pz ()));
4272+ if (fgPVrecalKF){
42634273 values[kVertexingLxyProjectedRecalculatePV ] = (secondaryVertex[0 ] - primaryVertexNew.getX ()) * v12.Px () + (secondaryVertex[1 ] - primaryVertexNew.getY ()) * v12.Py ();
42644274 values[kVertexingLxyProjectedRecalculatePV ] = values[kVertexingLxyProjectedRecalculatePV ] / v12.Pt ();
4265-
4275+ }
42664276 values[kVertexingTauxyProjected ] = values[kVertexingLxyProjected ] * v12.M () / (v12.Pt ());
42674277 values[kVertexingTauxyProjectedPoleJPsiMass ] = values[kVertexingLxyProjected ] * o2::constants::physics::MassJPsi / (v12.Pt ());
42684278 values[kVertexingTauxyProjectedNs ] = values[kVertexingTauxyProjected ] / o2::constants::physics::LightSpeedCm2NS;
4269- values[kVertexingTauxyProjectedPoleJPsiMassRecalculatePV ] = values[kVertexingLxyProjectedRecalculatePV ] * o2::constants::physics::MassJPsi / (v12.Pt ());
4279+ if (fgPVrecalKF) values[kVertexingTauxyProjectedPoleJPsiMassRecalculatePV ] = values[kVertexingLxyProjectedRecalculatePV ] * o2::constants::physics::MassJPsi / (v12.Pt ());
42704280 values[kVertexingTauzProjected ] = values[kVertexingLzProjected ] * v12.M () / TMath::Abs (v12.Pz ());
42714281 values[kVertexingTauxyzProjected ] = values[kVertexingLxyzProjected ] * v12.M () / (v12.P ());
42724282 }
@@ -4484,6 +4494,69 @@ void VarManager::FillPairVertexing(C const& collision, T const& t1, T const& t2,
44844494 }
44854495}
44864496
4497+ template <int pairType, uint32_t collFillMap, uint32_t fillMap, typename C, typename T>
4498+ void VarManager::FillPairVertexingRecomputePV (C const & /* collision*/ , T const & t1, T const & t2, o2::dataformats::VertexBase pvRefitted, float * values )
4499+ {
4500+ // recompute decay lenght variables using updated primary vertex
4501+
4502+ // check at compile time that the event and cov matrix have the cov matrix
4503+ constexpr bool eventHasVtxCov = ((collFillMap & Collision) > 0 || (collFillMap & ReducedEventVtxCov) > 0 );
4504+ constexpr bool trackHasCov = ((fillMap & TrackCov) > 0 || (fillMap & ReducedTrackBarrelCov) > 0 );
4505+ constexpr bool muonHasCov = ((fillMap & MuonCov) > 0 || (fillMap & ReducedMuonCov) > 0 );
4506+
4507+ if (!values) {
4508+ values = fgValues;
4509+ }
4510+
4511+ float m1 = o2::constants::physics::MassElectron;
4512+ float m2 = o2::constants::physics::MassElectron;
4513+ if constexpr (pairType == kDecayToKPi ) {
4514+ m1 = o2::constants::physics::MassKaonCharged;
4515+ m2 = o2::constants::physics::MassPionCharged;
4516+ }
4517+ if constexpr (pairType == kDecayToMuMu && muonHasCov) {
4518+ m1 = o2::constants::physics::MassMuon;
4519+ m2 = o2::constants::physics::MassMuon;
4520+ }
4521+ ROOT::Math::PtEtaPhiMVector v1 (t1.pt (), t1.eta (), t1.phi (), m1);
4522+ ROOT::Math::PtEtaPhiMVector v2 (t2.pt (), t2.eta (), t2.phi (), m2);
4523+ ROOT::Math::PtEtaPhiMVector v12 = v1 + v2;
4524+
4525+ if (fgFitterTwoProngBarrel.getNCandidates () == 0 ) return ;
4526+ Vec3D secondaryVertex;
4527+
4528+ if (!fgUsedKF) { // to be updated when seconday vertex is computed with KF
4529+ if constexpr (eventHasVtxCov) {
4530+
4531+ if constexpr ((pairType == kDecayToEE || pairType == kDecayToKPi ) && trackHasCov) {
4532+ // Get pca candidate from forward DCA fitter
4533+ // no need to re-compute secondary vertex (done already in FillPairVertexing)
4534+ secondaryVertex = fgFitterTwoProngBarrel.getPCACandidate ();
4535+ auto trackParVar0 = fgFitterTwoProngBarrel.getTrack (0 );
4536+ auto trackParVar1 = fgFitterTwoProngBarrel.getTrack (1 );
4537+ v1 = {trackParVar0.getPt (), trackParVar0.getEta (), trackParVar0.getPhi (), m1};
4538+ v2 = {trackParVar1.getPt (), trackParVar1.getEta (), trackParVar1.getPhi (), m2};
4539+ v12 = v1 + v2;
4540+
4541+ } else if constexpr (pairType == kDecayToMuMu && muonHasCov) {
4542+ // Get pca candidate from forward DCA fitter
4543+ // no need to re-compute secondary vertex (done already in FillPairVertexing)
4544+ secondaryVertex = fgFitterTwoProngFwd.getPCACandidate ();
4545+ auto trackParVar0 = fgFitterTwoProngFwd.getTrack (0 );
4546+ auto trackParVar1 = fgFitterTwoProngFwd.getTrack (1 );
4547+ v1 = {trackParVar0.getPt (), trackParVar0.getEta (), trackParVar0.getPhi (), m1};
4548+ v2 = {trackParVar1.getPt (), trackParVar1.getEta (), trackParVar1.getPhi (), m2};
4549+ v12 = v1 + v2;
4550+ }
4551+
4552+ values[kVertexingLxyProjectedRecalculatePV ] = (secondaryVertex[0 ] - pvRefitted.getX ()) * v12.Px () + (secondaryVertex[1 ] - pvRefitted.getY ()) * v12.Py ();
4553+ values[kVertexingLxyProjectedRecalculatePV ] = values[kVertexingLxyProjectedRecalculatePV ] / v12.Pt ();
4554+ values[kVertexingTauxyProjectedPoleJPsiMassRecalculatePV ] = values[kVertexingLxyProjectedRecalculatePV ] * o2::constants::physics::MassJPsi / (v12.Pt ());
4555+ }
4556+ }
4557+
4558+ }
4559+
44874560template <uint32_t collFillMap, uint32_t fillMap, typename C, typename T>
44884561void VarManager::FillTripletVertexing (C const & collision, T const & t1, T const & t2, T const & t3, VarManager::PairCandidateType tripletType, float * values)
44894562{
0 commit comments