@@ -90,12 +90,17 @@ class Response
9090 // / Gets the deviation to the expected signal
9191 template <typename TrackType>
9292 float GetSignalDelta (const TrackType& trk, const o2::track::PID::ID id) const ;
93+
9394 // / Gets relative dEdx resolution contribution due to relative pt resolution
9495 float GetRelativeResolutiondEdx (const float p, const float mass, const float charge, const float resol) const ;
9596
9697 void PrintAll () const ;
9798
9899 private:
100+ // / Compute expected sigma given a pre-computed expected signal, avoiding a redundant Bethe-Bloch call.
101+ template <typename TrackType>
102+ float sigmaFromSignal (float expectedSignal, const long multTPC, const TrackType& track, const o2::track::PID::ID id) const ;
103+
99104 std::array<float , 5 > mBetheBlochParams = {0.03209809958934784 , 19.9768009185791 , 2.5266601063857674e-16 , 2.7212300300598145 , 6.080920219421387 };
100105 std::array<float , 2 > mResolutionParamsDefault = {0.07 , 0.0 };
101106 std::vector<double > mResolutionParams = {5.43799e-7 , 0.053044 , 0.667584 , 0.0142667 , 0.00235175 , 1.22482 , 2.3501e-7 , 0.031585 };
@@ -135,13 +140,18 @@ inline float Response::GetExpectedSigmaAtMultiplicity(const long multTPC, const
135140 if (!track.hasTPC ()) {
136141 return -999 .f ;
137142 }
138- float resolution = 0 .;
143+ return sigmaFromSignal (GetExpectedSignal (track, id), multTPC, track, id);
144+ }
145+
146+ template <typename TrackType>
147+ inline float Response::sigmaFromSignal (float expectedSignal, const long multTPC, const TrackType& track, const o2::track::PID::ID id) const
148+ {
149+ float resolution = 0 .f ;
139150 if (mUseDefaultResolutionParam ) {
140- const float reso = GetExpectedSignal (track, id) * mResolutionParamsDefault [0 ] * (static_cast <float >(track.tpcNClsFound ()) > 0 ? std::sqrt (1 . + mResolutionParamsDefault [1 ] / static_cast <float >(track.tpcNClsFound ())) : 1 .f );
151+ const float reso = expectedSignal * mResolutionParamsDefault [0 ] * (static_cast <float >(track.tpcNClsFound ()) > 0 ? std::sqrt (1 . + mResolutionParamsDefault [1 ] / static_cast <float >(track.tpcNClsFound ())) : 1 .f );
141152 reso >= 0 .f ? resolution = reso : resolution = -999 .f ;
142153 } else {
143-
144- const double ncl = nClNorm / track.tpcNClsFound (); //
154+ const double ncl = nClNorm / track.tpcNClsFound ();
145155 const double p = track.tpcInnerParam ();
146156 const double mass = o2::track::pid_constants::sMasses [id];
147157 const double bg = p / mass;
@@ -160,16 +170,15 @@ inline float Response::GetExpectedSigmaAtMultiplicity(const long multTPC, const
160170template <typename CollisionType, typename TrackType>
161171inline float Response::GetNumberOfSigma (const CollisionType& collision, const TrackType& trk, const o2::track::PID::ID id) const
162172{
163- if (GetExpectedSigma (collision, trk, id) < 0 .) {
164- return -999 .f ;
165- }
166- if (GetExpectedSignal (trk, id) < 0 .) {
173+ const float signal = GetExpectedSignal (trk, id);
174+ if (signal < 0 .f ) {
167175 return -999 .f ;
168176 }
169- if (!trk.hasTPC ()) {
177+ const float sigma = sigmaFromSignal (signal, collision.multTPC (), trk, id);
178+ if (sigma < 0 .f ) {
170179 return -999 .f ;
171180 }
172- return (( trk.tpcSignal () - GetExpectedSignal (trk, id)) / GetExpectedSigma (collision, trk, id)) ;
181+ return (trk.tpcSignal () - signal) / sigma ;
173182}
174183
175184template <typename CollisionType, typename TrackType>
@@ -181,29 +190,26 @@ inline float Response::GetNumberOfSigmaMCTuned(const CollisionType& collision, c
181190template <typename TrackType>
182191inline float Response::GetNumberOfSigmaMCTunedAtMultiplicity (const long multTPC, const TrackType& trk, const o2::track::PID::ID id, float mcTunedTPCSignal) const
183192{
184- if (GetExpectedSigmaAtMultiplicity (multTPC, trk, id) < 0 .) {
193+ const float signal = GetExpectedSignal (trk, id);
194+ if (signal < 0 .f ) {
185195 return -999 .f ;
186196 }
187- if (GetExpectedSignal (trk, id) < 0 .) {
197+ const float sigma = sigmaFromSignal (signal, multTPC, trk, id);
198+ if (sigma < 0 .f ) {
188199 return -999 .f ;
189200 }
190- if (!trk.hasTPC ()) {
191- return -999 .f ;
192- }
193- return ((mcTunedTPCSignal - GetExpectedSignal (trk, id)) / GetExpectedSigmaAtMultiplicity (multTPC, trk, id));
201+ return (mcTunedTPCSignal - signal) / sigma;
194202}
195203
196204// / Gets the deviation between the actual signal and the expected signal
197205template <typename TrackType>
198206inline float Response::GetSignalDelta (const TrackType& trk, const o2::track::PID::ID id) const
199207{
200- if (GetExpectedSignal (trk, id) < 0 .) {
201- return -999 .f ;
202- }
203- if (!trk.hasTPC ()) {
208+ const float signal = GetExpectedSignal (trk, id);
209+ if (signal < 0 .f ) {
204210 return -999 .f ;
205211 }
206- return ( trk.tpcSignal () - GetExpectedSignal (trk, id)) ;
212+ return trk.tpcSignal () - signal ;
207213}
208214
209215// // Gets relative dEdx resolution contribution due relative pt resolution
0 commit comments