@@ -46,7 +46,6 @@ static constexpr float kCSPEDDInv = 1.f / kCSPEED; /// Inverse of
4646static constexpr float defaultReturnValue = -999 .f; // / Default return value in case TOF measurement is not available
4747
4848// / \brief Class to handle the the TOF detector response for the TOF beta measurement
49- template <typename TrackType>
5049class Beta
5150{
5251 public:
@@ -62,11 +61,19 @@ class Beta
6261 // / Gets the beta for the track of interest
6362 // / \param track Track of interest
6463 // / \param collisionTime Collision time
65- static float GetBeta (const TrackType& track, const float collisionTime) { return track.hasTOF () ? GetBeta (track.length (), track.tofSignal (), collisionTime) : defaultReturnValue; }
64+ template <typename TrackType>
65+ static float GetBeta (const TrackType& track, const float collisionTime)
66+ {
67+ return track.hasTOF () ? GetBeta (track.length (), track.tofSignal (), collisionTime) : defaultReturnValue;
68+ }
6669
6770 // / Gets the beta for the track of interest
6871 // / \param track Track of interest
69- static float GetBeta (const TrackType& track) { return GetBeta (track, track.tofEvTime ()); }
72+ template <typename TrackType>
73+ static float GetBeta (const TrackType& track)
74+ {
75+ return GetBeta (track, track.tofEvTime ());
76+ }
7077
7178 // / Computes the expected uncertainty on the beta measurement
7279 // / \param length Length in cm of the track
@@ -77,7 +84,11 @@ class Beta
7784
7885 // / Gets the expected uncertainty on the beta measurement of the track of interest
7986 // / \param track Track of interest
80- float GetExpectedSigma (const TrackType& track) const { return GetExpectedSigma (track.length (), track.tofSignal (), track.tofEvTime (), mExpectedResolution ); }
87+ template <typename TrackType>
88+ float GetExpectedSigma (const TrackType& track) const
89+ {
90+ return GetExpectedSigma (track.length (), track.tofSignal (), track.tofEvTime (), mExpectedResolution );
91+ }
8192
8293 // / Gets the expected beta for a given mass hypothesis (no energy loss taken into account)
8394 // / \param momentum momentum in GeV/c of the track
@@ -86,15 +97,15 @@ class Beta
8697
8798 // / Gets the expected beta given the particle index (no energy loss taken into account) of the track of interest
8899 // / \param track Track of interest
89- template <o2::track::PID::ID id>
100+ template <o2::track::PID::ID id, typename TrackType >
90101 float GetExpectedBeta (const TrackType& track) const
91102 {
92103 return GetExpectedBeta (track.p (), o2::track::PID::getMass2Z (id));
93104 }
94105
95106 // / Gets the number of sigmas with respect the approximate beta (no energy loss taken into account) of the track of interest
96107 // / \param track Track of interest
97- template <o2::track::PID::ID id>
108+ template <o2::track::PID::ID id, typename TrackType >
98109 float GetSeparation (const TrackType& track) const
99110 {
100111 return (GetBeta (track) - GetExpectedBeta<id>(track)) / GetExpectedSigma (track);
@@ -104,7 +115,6 @@ class Beta
104115};
105116
106117// / \brief Class to handle the the TOF detector response for the TOF mass measurement
107- template <typename TrackType>
108118class TOFMass
109119{
110120 public:
@@ -118,11 +128,19 @@ class TOFMass
118128
119129 // / Gets the TOF mass for the track of interest
120130 // / \param track Track of interest
121- static float GetTOFMass (const TrackType& track, const float beta) { return track.hasTOF () ? GetTOFMass (track.p (), beta) : defaultReturnValue; }
131+ template <typename TrackType>
132+ static float GetTOFMass (const TrackType& track, const float beta)
133+ {
134+ return track.hasTOF () ? GetTOFMass (track.p (), beta) : defaultReturnValue;
135+ }
122136
123137 // / Gets the TOF mass for the track of interest
124138 // / \param track Track of interest
125- static float GetTOFMass (const TrackType& track) { return track.hasTOF () ? GetTOFMass (track.p (), Beta<TrackType>::GetBeta (track)) : defaultReturnValue; }
139+ template <typename TrackType>
140+ static float GetTOFMass (const TrackType& track)
141+ {
142+ return track.hasTOF () ? GetTOFMass (track.p (), Beta::GetBeta<TrackType>(track)) : defaultReturnValue;
143+ }
126144};
127145
128146// / \brief Next implementation class to store TOF response parameters for exp. times
@@ -219,7 +237,7 @@ class TOFResoParamsV2 : public o2::tof::Parameters<13>
219237 }
220238 f.Close ();
221239 }
222- LOG (info) << " Set the Time Shift parameters from file " << filename << " and object " << objname << " for " << (positive ? " positive" : " negative" );
240+ LOG (info) << " Set the Time Shift parameters from file " << filename << " and object " << objname << " for " << (positive ? " positive" : " negative" ) << " example of shift at eta 0: " << getTimeShift ( 0 , positive) ;
223241 }
224242 void setTimeShiftParameters (TGraph* g, bool positive)
225243 {
@@ -266,7 +284,7 @@ class TOFResoParamsV3 : public o2::tof::Parameters<13>
266284 " time_resolution" , " time_resolution" , " time_resolution" , " time_resolution" },
267285 " TOFResoParamsV3" )
268286 {
269- setParameters (std::array<float , 13 >{60.0 });
287+ setParameters (std::array<float , 13 >{60.0 , 60.0 , 60.0 , 60.0 , 60.0 , 60.0 , 60.0 , 60.0 , 60.0 , 60.0 , 60.0 , 60.0 , 60.0 });
270288 } // Default constructor with default parameters
271289
272290 ~TOFResoParamsV3 () = default ;
@@ -372,6 +390,20 @@ class TOFResoParamsV3 : public o2::tof::Parameters<13>
372390 return gNegEtaTimeCorr ->Eval (eta);
373391 }
374392
393+ void printTimeShiftParameters () const
394+ {
395+ if (gPosEtaTimeCorr ) {
396+ LOG (info) << " Using a time shift for Pos " << gPosEtaTimeCorr ->GetName () << " " << gPosEtaTimeCorr ->GetTitle () << " value at 0: " << gPosEtaTimeCorr ->Eval (0 ) << " vs correction " << getTimeShift (0 , 1 );
397+ } else {
398+ LOG (info) << " Using no time shift for Pos vs correction " << getTimeShift (0 , 1 );
399+ }
400+ if (gNegEtaTimeCorr ) {
401+ LOG (info) << " Using a time shift for Neg " << gNegEtaTimeCorr ->GetName () << " " << gNegEtaTimeCorr ->GetTitle () << " value at 0: " << gNegEtaTimeCorr ->Eval (0 ) << " vs correction " << getTimeShift (0 , -1 );
402+ } else {
403+ LOG (info) << " Using no time shift for Neg vs correction " << getTimeShift (0 , -1 );
404+ }
405+ }
406+
375407 void setResolutionParametrization (std::unordered_map<std::string, float > const & pars)
376408 {
377409 static constexpr std::array<const char *, 9 > particleNames = {" El" , " Mu" , " Pi" , " Ka" , " Pr" , " De" , " Tr" , " He" , " Al" };
@@ -382,6 +414,9 @@ class TOFResoParamsV3 : public o2::tof::Parameters<13>
382414 if (key.find (baseOpt) == 0 ) {
383415 // Remove from the key the baseOpt
384416 const std::string fun = key.substr (baseOpt.size ());
417+ if (mResolution [i]) {
418+ delete mResolution [i];
419+ }
385420 mResolution [i] = new TF2 (baseOpt.c_str (), fun.c_str (), 0 ., 20 , -1 , 1 .);
386421 LOG (info) << " Set the resolution function for " << particleNames[i] << " with formula " << mResolution [i]->GetFormula ()->GetExpFormula ();
387422 break ;
@@ -404,6 +439,26 @@ class TOFResoParamsV3 : public o2::tof::Parameters<13>
404439 return mResolution [pid]->Eval (p, eta);
405440 }
406441
442+ void printResolution () const
443+ {
444+ static constexpr std::array<const char *, 9 > particleNames = {" El" , " Mu" , " Pi" , " Ka" , " Pr" , " De" , " Tr" , " He" , " Al" };
445+ // Print a summary
446+ for (int i = 0 ; i < 9 ; ++i) {
447+ if (!mResolution [i]) {
448+ LOG (info) << " Resolution function for " << particleNames[i] << " is not defined yet" ;
449+ continue ;
450+ }
451+ LOG (info) << " Resolution function for " << particleNames[i] << " is " << mResolution [i]->GetName () << " with formula " << mResolution [i]->GetFormula ()->GetExpFormula ();
452+ }
453+ }
454+ void printFullConfig () const
455+ {
456+ print ();
457+ printMomentumChargeShiftParameters ();
458+ printTimeShiftParameters ();
459+ printResolution ();
460+ }
461+
407462 private:
408463 // Charge calibration
409464 int mEtaN = 0 ; // Number of eta bins, 0 means no correction
0 commit comments