2020
2121#include " bestCollisionTable.h"
2222
23+ #include " Common/Core/fwdtrackUtilities.h"
2324#include " Common/Core/trackUtilities.h"
2425#include " Common/DataModel/CollisionAssociationTables.h"
2526#include " Common/DataModel/TrackSelectionTables.h"
4142#include < string>
4243#include < vector>
4344
44- using SMatrix55 = ROOT::Math::SMatrix<double , 5 , 5 , ROOT::Math::MatRepSym<double , 5 >>;
45- using SMatrix5 = ROOT::Math::SVector<Double_t, 5 >;
46-
4745// This is a special version of the propagation task chosing the closest vertex
4846// among the compatible, which is defined by track-to-collision-associator
4947
@@ -53,20 +51,19 @@ using namespace o2::aod::track;
5351
5452struct AmbiguousTrackPropagation {
5553 Produces<aod::BestCollisionsFwd> fwdtracksBestCollisions;
54+ Produces<aod::BestCollFwdExtra> fwdtracksBestCollExtra;
5655 Produces<aod::BestCollisionsFwd3d> fwdtracksBestCollisions3d;
5756 Produces<aod::BestCollisionsFwd3dExtra> fwdtracksBestCollisions3dExtra;
58- Produces<aod::BestCollFwdExtra> fwdtracksBestCollExtra;
5957 Produces<aod::ReassignedTracksCore> tracksReassignedCore;
6058 Produces<aod::ReassignedTracksExtra> tracksReassignedExtra;
6159 Service<o2::ccdb::BasicCCDBManager> ccdb;
6260
6361 int runNumber = -1 ;
6462 float bZ = 0 ; // Magnetic field for MFT
65- static constexpr double kCenterMFT [3 ] = {0 , 0 , -61.4 }; // Field at center of MFT
66-
67- o2::base::Propagator::MatCorrType matCorr =
68- o2::base::Propagator::MatCorrType::USEMatCorrNONE;
63+ static constexpr double CcenterMFT[3 ] = {0 , 0 , -61.4 }; // Field at center of MFT
64+ float mZShift = 0 ; // z-vertex shift
6965
66+ o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE;
7067 o2::parameters::GRPMagField* grpmag = nullptr ;
7168
7269 Configurable<std::string> ccdburl{" ccdburl" , " http://alice-ccdb.cern.ch" , " url of the ccdb repository" };
@@ -77,6 +74,11 @@ struct AmbiguousTrackPropagation {
7774 Configurable<bool > produceExtra{" produceExtra" , false , " Produce table with refitted track parameters" };
7875 Configurable<bool > produceHistos{" produceHistos" , false , " Produce control histograms" };
7976 Configurable<bool > removeTrivialAssoc{" removeTrivialAssoc" , false , " Skip trivial associations" };
77+ Configurable<uint> cfgDCAtype{" cfgDCAtype" , 2 , " DCA coordinate type [0: DCA-X, 1: DCA-Y, 2: DCA-XY]" };
78+
79+ Configurable<bool > cfgApplyZShiftFromCCDB{" cfgApplyZShiftFromCCDB" , false , " flag to apply z shift from CCDB" };
80+ Configurable<std::string> cfgZShiftPath{" cfgZShiftPath" , " Users/m/mcoquet/ZShift" , " CCDB path for z shift to apply to forward tracks" };
81+ Configurable<float > cfgManualZShift{" cfgManualZShift" , 0 .0f , " manual z-shift for propagation of global muon to PV" };
8082
8183 ConfigurableAxis binsDCAxy{" binsDCAxy" , {200 , -1 ., 1 .}, " " };
8284 ConfigurableAxis binsDCAz{" binsDCAz" , {200 , -1 ., 1 .}, " " };
@@ -102,6 +104,8 @@ struct AmbiguousTrackPropagation {
102104
103105 if (produceHistos) {
104106 if (doprocessMFT || doprocessMFTReassoc || doprocessMFTReassoc3D) {
107+ registry.add ({" DeltaX" , " ; #Delta#it{x}" , {HistType::kTH1F , {{201 , -10.1 , 10.1 }}}});
108+ registry.add ({" DeltaY" , " ; #Delta#it{y}" , {HistType::kTH1F , {{201 , -10.1 , 10.1 }}}});
105109 registry.add ({" DeltaZ" , " ; #Delta#it{z}" , {HistType::kTH1F , {{201 , -10.1 , 10.1 }}}});
106110 registry.add ({" TracksDCAXY" , " ; DCA_{XY} (cm)" , {HistType::kTH1F , {dcaXYAxis}}});
107111 registry.add ({" ReassignedDCAXY" , " ; DCA_{XY} (cm)" , {HistType::kTH1F , {dcaXYAxis}}});
@@ -114,6 +118,8 @@ struct AmbiguousTrackPropagation {
114118 registry.add ({" TracksFirstDCAZ" , " ; DCA_{Z} (cm)" , {HistType::kTH1F , {dcaZAxis}}});
115119 registry.add ({" TracksDCAZ" , " ; DCA_{Z} (cm)" , {HistType::kTH1F , {dcaZAxis}}});
116120 registry.add ({" ReassignedDCAZ" , " ; DCA_{Z} (cm)" , {HistType::kTH1F , {dcaZAxis}}});
121+ registry.add ({" AssignedDCAXY" , " ; DCA_{XY} (cm)" , {HistType::kTH1F , {dcaXYAxis}}});
122+ registry.add ({" AssignedDCAZ" , " ; DCA_{Z} (cm)" , {HistType::kTH1F , {dcaZAxis}}});
117123 registry.add ({" TracksOrigDCAZ" , " ; DCA_{Z} (wrt orig coll) (cm)" , {HistType::kTH1F , {dcaZAxis}}});
118124 }
119125 }
@@ -144,16 +150,30 @@ struct AmbiguousTrackPropagation {
144150
145151 if (doprocessMFT || doprocessMFTReassoc || doprocessMFTReassoc3D) {
146152 o2::field::MagneticField* field = static_cast <o2::field::MagneticField*>(TGeoGlobalMagField::Instance ()->GetField ());
147- bZ = field->getBz (kCenterMFT );
153+ bZ = field->getBz (CcenterMFT );
148154 LOG (info) << " The field at the center of the MFT is bZ = " << bZ;
149155 }
156+
157+ if (cfgApplyZShiftFromCCDB) {
158+ auto * zShift = ccdb->getForTimeStamp <std::vector<float >>(cfgZShiftPath, bc.timestamp ());
159+ if (zShift != nullptr && !zShift->empty ()) {
160+ LOGF (info, " reading z shift %f from %s" , (*zShift)[0 ], cfgZShiftPath.value );
161+ mZShift = (*zShift)[0 ];
162+ } else {
163+ LOGF (info, " z shift is not found in ccdb path %s. set to 0 cm" , cfgZShiftPath.value );
164+ mZShift = 0 ;
165+ }
166+ } else {
167+ LOGF (info, " z shift is manually set to %f cm" , cfgManualZShift.value );
168+ mZShift = cfgManualZShift;
169+ }
150170 }
151171
152- static constexpr TrackSelectionFlags::flagtype kTrackSelectionITS =
172+ static constexpr TrackSelectionFlags::flagtype CtrackSelectionITS =
153173 TrackSelectionFlags::kITSNCls | TrackSelectionFlags::kITSChi2NDF |
154174 TrackSelectionFlags::kITSHits ;
155175
156- static constexpr TrackSelectionFlags::flagtype kTrackSelectionTPC =
176+ static constexpr TrackSelectionFlags::flagtype CtrackSelectionTPC =
157177 TrackSelectionFlags::kTPCNCls |
158178 TrackSelectionFlags::kTPCCrossedRowsOverNCls |
159179 TrackSelectionFlags::kTPCChi2NDF ;
@@ -180,11 +200,11 @@ struct AmbiguousTrackPropagation {
180200 bestDCA[1 ] = dcaInfo[1 ];
181201
182202 auto bestCol = track.has_collision () ? track.collisionId () : -1 ;
183- if ((track.trackCutFlag () & kTrackSelectionITS ) != kTrackSelectionITS ) {
203+ if ((track.trackCutFlag () & CtrackSelectionITS ) != CtrackSelectionITS ) {
184204 continue ;
185205 }
186206 if ((track.detectorMap () & (uint8_t )o2::aod::track::TPC) == (uint8_t )o2::aod::track::TPC) {
187- if ((track.trackCutFlag () & kTrackSelectionTPC ) != kTrackSelectionTPC ) {
207+ if ((track.trackCutFlag () & CtrackSelectionTPC ) != CtrackSelectionTPC ) {
188208 continue ;
189209 }
190210 }
@@ -266,10 +286,7 @@ struct AmbiguousTrackPropagation {
266286 auto track = atrack.mfttrack ();
267287 auto bestCol = track.has_collision () ? track.collisionId () : -1 ;
268288
269- std::vector<double > v1; // Temporary null vector for the computation of the covariance matrix
270- SMatrix55 tcovs (v1.begin (), v1.end ());
271- SMatrix5 tpars (track.x (), track.y (), track.phi (), track.tgl (), track.signed1Pt ());
272- o2::track::TrackParCovFwd trackPar{track.z (), tpars, tcovs, track.chi2 ()};
289+ o2::track::TrackParCovFwd trackPar = o2::aod::fwdtrackutils::getTrackParCovFwdShift (track, mZShift );
273290
274291 int degree = 0 ; // degree of ambiguity of the track
275292
@@ -352,18 +369,14 @@ struct AmbiguousTrackPropagation {
352369 auto bestCol = track.has_collision () ? track.collisionId () : -1 ;
353370
354371 // auto ids = track.compatibleCollIds();
355-
356372 // if (ids.empty() || (ids.size() == 1 && bestCol == ids[0]))
357373 // {
358374 // continue;
359375 // }
360376
361377 auto compatibleColls = track.compatibleColl ();
362378
363- std::vector<double > v1; // Temporary null vector for the computation of the covariance matrix
364- SMatrix55 tcovs (v1.begin (), v1.end ());
365- SMatrix5 tpars (track.x (), track.y (), track.phi (), track.tgl (), track.signed1Pt ());
366- o2::track::TrackParCovFwd trackPar{track.z (), tpars, tcovs, track.chi2 ()};
379+ o2::track::TrackParCovFwd trackPar = o2::aod::fwdtrackutils::getTrackParCovFwdShift (track, mZShift );
367380
368381 for (auto const & collision : compatibleColls) {
369382
@@ -453,15 +466,19 @@ struct AmbiguousTrackPropagation {
453466
454467 auto compatibleColls = track.compatibleColl ();
455468
456- std::vector<double > v1; // Temporary null vector for the computation of the covariance matrix
457- SMatrix55 tcovs (v1.begin (), v1.end ());
458- SMatrix5 tpars (track.x (), track.y (), track.phi (), track.tgl (), track.signed1Pt ());
459- o2::track::TrackParCovFwd trackPar{track.z (), tpars, tcovs, track.chi2 ()};
469+ o2::track::TrackParCovFwd trackPar = o2::aod::fwdtrackutils::getTrackParCovFwdShift (track, mZShift );
460470
461471 for (auto const & collision : compatibleColls) {
462472
463473 trackPar.propagateToDCAhelix (bZ, {collision.posX (), collision.posY (), collision.posZ ()}, dcaInfOrig);
464- dcaInfo[0 ] = std::sqrt (dcaInfOrig[0 ] * dcaInfOrig[0 ] + dcaInfOrig[1 ] * dcaInfOrig[1 ]);
474+
475+ if (cfgDCAtype == 0 ) {
476+ dcaInfo[0 ] = dcaInfOrig[0 ];
477+ } else if (cfgDCAtype == 1 ) {
478+ dcaInfo[0 ] = dcaInfOrig[1 ];
479+ } else if (cfgDCAtype == 2 ) {
480+ dcaInfo[0 ] = std::sqrt (dcaInfOrig[0 ] * dcaInfOrig[0 ] + dcaInfOrig[1 ] * dcaInfOrig[1 ]);
481+ }
465482 dcaInfo[1 ] = dcaInfOrig[2 ];
466483
467484 if ((std::abs (dcaInfo[0 ]) < std::abs (bestDCA[0 ])) && (std::abs (dcaInfo[1 ]) < std::abs (bestDCA[1 ]))) {
@@ -470,21 +487,27 @@ struct AmbiguousTrackPropagation {
470487 bestDCA[1 ] = dcaInfo[1 ];
471488 bestTrackPar = trackPar;
472489 }
490+
473491 if ((track.collisionId () != collision.globalIndex ()) && produceHistos) {
474492 registry.fill (HIST (" DeltaZ" ), track.collision ().posZ () - collision.posZ ()); // deltaZ between the 1st coll zvtx and the other compatible ones
493+ registry.fill (HIST (" DeltaX" ), track.collision ().posX () - collision.posX ());
494+ registry.fill (HIST (" DeltaY" ), track.collision ().posY () - collision.posY ());
475495 registry.fill (HIST (" TracksFirstDCAXY" ), dcaInfo[0 ]);
476496 registry.fill (HIST (" TracksFirstDCAZ" ), dcaInfo[1 ]);
477497 }
478498 if (produceHistos) {
479499 registry.fill (HIST (" TracksDCAXY" ), dcaInfo[0 ]);
480500 registry.fill (HIST (" TracksDCAZ" ), dcaInfo[1 ]);
481501 }
482-
483502 if ((collision.globalIndex () == track.collisionId ()) && produceHistos) {
484503 registry.fill (HIST (" TracksOrigDCAXY" ), dcaInfo[0 ]);
485504 registry.fill (HIST (" TracksOrigDCAZ" ), dcaInfo[1 ]);
486505 }
487506 }
507+ if ((bestCol == track.collisionId ()) && produceHistos) {
508+ registry.fill (HIST (" AssignedDCAXY" ), bestDCA[0 ]);
509+ registry.fill (HIST (" AssignedDCAZ" ), bestDCA[1 ]);
510+ }
488511 if ((bestCol != track.collisionId ()) && produceHistos) {
489512 // reassigned
490513 registry.fill (HIST (" ReassignedDCAXY" ), bestDCA[0 ]);
@@ -500,7 +523,9 @@ struct AmbiguousTrackPropagation {
500523 }
501524
502525 fwdtracksBestCollisions3d (track.globalIndex (), compatibleColls.size (), bestCol, bestDCA[0 ], bestDCA[1 ]);
526+ // LOGP(info, "track {}: {} {} {} {}", track.globalIndex(), compatibleColls.size(), bestCol, bestDCA[0], bestDCA[1]);
503527 if (produceExtra) {
528+ // LOGP(info, "track {}: {} {} {} {} {}", track.globalIndex(), bestTrackPar.getX(), bestTrackPar.getY(), bestTrackPar.getZ(), bestTrackPar.getTgl(), bestTrackPar.getInvQPt());
504529 fwdtracksBestCollisions3dExtra (bestTrackPar.getX (), bestTrackPar.getY (), bestTrackPar.getZ (),
505530 bestTrackPar.getTgl (), bestTrackPar.getInvQPt (), bestTrackPar.getPt (),
506531 bestTrackPar.getP (), bestTrackPar.getEta (), bestTrackPar.getPhi ());
0 commit comments