|
22 | 22 | #include <stdexcept> |
23 | 23 | #include <string> |
24 | 24 | #include <filesystem> |
25 | | -#include <limits> |
26 | 25 |
|
27 | 26 | #include <gsl/span> |
28 | 27 |
|
@@ -155,78 +154,31 @@ class TrackFinderTask |
155 | 154 | } |
156 | 155 |
|
157 | 156 | private: |
158 | | - std::pair<InteractionRecord, bool> trackBC2IR(double trackBCinTF, const ROFRecord& trackROF, uint32_t firstTForbit) const |
| 157 | + void setTrackTime(TrackMCH& track, const ROFRecord& clusterROF, uint32_t firstTForbit, const gsl::span<const Cluster> usedClusters, const gsl::span<const Digit> usedDigits) const |
159 | 158 | { |
160 | | - // limits of the current ROF |
161 | | - const InteractionRecord& rofStart = trackROF.getBCData(); |
162 | | - const InteractionRecord& rofEnd = trackROF.getBCData() + int64_t(trackROF.getBCWidth()); |
163 | | - |
164 | | - // wrap-up one full orbit if the track time is negative, |
165 | | - // the first TF orbit is also decreased by one to compensate |
166 | | - if (trackBCinTF < 0) { |
167 | | - trackBCinTF += o2::constants::lhc::LHCMaxBunches; |
168 | | - firstTForbit -= 1; |
169 | | - } |
170 | | - |
171 | | - // get the bc-in-orbit value |
172 | | - uint16_t trackBC = uint16_t(uint64_t(trackBCinTF) % o2::constants::lhc::LHCMaxBunches); |
173 | | - // get the absolute track orbit by adding the first orbit of the current TF |
174 | | - uint32_t trackOrbit = uint32_t(uint64_t(trackBCinTF) / o2::constants::lhc::LHCMaxBunches) + firstTForbit; |
175 | | - |
176 | | - // build the track interaction record |
177 | | - InteractionRecord trackIR{trackBC, trackOrbit}; |
178 | | - |
179 | | - // if we are outside the cluster ROF, something must be wrong |
180 | | - // in this case we log a warning message and we return a default IR value |
181 | | - bool isOk = true; |
182 | | - if (trackIR < rofStart || trackIR > rofEnd) { |
183 | | - LOG(warning) << fmt::format("track time incompatible with track ROF. TRACK: BC={}, IR={},{} ROF: start={},{}, end={},{} FIRST_TF_ORBIT: {}", |
184 | | - trackBCinTF, trackIR.orbit, trackIR.bc, rofStart.orbit, rofStart.bc, rofEnd.orbit, rofEnd.bc, firstTForbit); |
185 | | - isOk = false; |
186 | | - } |
187 | | - |
188 | | - return {trackIR, isOk}; |
189 | | - } |
190 | | - |
191 | | - //_________________________________________________________________________________________________ |
192 | | - void setTrackTimeFromROF(TrackMCH& track, const ROFRecord& trackROF, uint32_t firstTForbit) const |
193 | | - { |
194 | | - // the track time is taken at the middle of the track ROF, |
195 | | - // in microseconds relative to the beginning of the TF |
196 | | - InteractionRecord startIR{0, firstTForbit}; |
197 | | - float rofHalfWidth = 0.5 * trackROF.getBCWidth(); |
198 | | - auto ir = trackROF.getBCData(); |
199 | | - float bcDiff = ir.differenceInBC(startIR); |
200 | | - bcDiff += rofHalfWidth; |
201 | | - float tMean = o2::constants::lhc::LHCBunchSpacingMUS * bcDiff; |
202 | | - // the time resolution is estimated as the half-width of the track ROF |
203 | | - float tErr = o2::constants::lhc::LHCBunchSpacingMUS * rofHalfWidth; |
204 | | - track.setTimeMUS(tMean, tErr); |
205 | | - } |
206 | | - |
207 | | - //_________________________________________________________________________________________________ |
208 | | - void setTrackTime(TrackMCH& track, const ROFRecord& trackROF, uint32_t firstTForbit, const gsl::span<const Cluster> usedClusters, const gsl::span<const Digit> usedDigits) const |
209 | | - { |
210 | | - float trackBCinTF = 0; |
| 159 | + double trackBCinTF = 0; |
211 | 160 | int nDigits = 0; |
212 | 161 |
|
213 | 162 | // loop over digits and compute the average track time |
214 | 163 | for (const auto& cluster : usedClusters.subspan(track.getFirstClusterIdx(), track.getNClusters())) { |
215 | 164 | for (const auto& digit : usedDigits.subspan(cluster.firstDigit, cluster.nDigits)) { |
216 | 165 | nDigits += 1; |
217 | | - trackBCinTF += (float(digit.getTime()) - trackBCinTF) / nDigits; |
| 166 | + trackBCinTF += (double(digit.getTime()) - trackBCinTF) / nDigits; |
218 | 167 | } |
219 | 168 | } |
220 | 169 |
|
221 | 170 | // set the track IR from the computed average digits time |
222 | 171 | if (nDigits > 0) { |
223 | | - float tMean = o2::constants::lhc::LHCBunchSpacingMUS * trackBCinTF; |
| 172 | + // convert the average digit time from bunch-crossing units to microseconds |
| 173 | + // add 1.5 BC to account for the fact that the actual digit time in BC units |
| 174 | + // can be between t and t+3, hence t+1.5 in average |
| 175 | + float tMean = o2::constants::lhc::LHCBunchSpacingMUS * (trackBCinTF + 1.5); |
224 | 176 | float tErr = o2::constants::lhc::LHCBunchSpacingMUS * mTrackTime3Sigma; |
225 | 177 | track.setTimeMUS(tMean, tErr); |
226 | 178 | } else { |
227 | 179 | // if no digits are found, compute the time directly from the track's ROF |
228 | | - LOG(warning) << "no digits found when computing the track mean time"; |
229 | | - setTrackTimeFromROF(track, trackROF, firstTForbit); |
| 180 | + LOG(fatal) << "MCH: no digits found when computing the track mean time"; |
| 181 | + track.setTimeMUS(clusterROF.getTimeMUS({0, firstTForbit}).first); |
230 | 182 | } |
231 | 183 | } |
232 | 184 |
|
@@ -277,16 +229,16 @@ class TrackFinderTask |
277 | 229 | } |
278 | 230 |
|
279 | 231 | // compute the track time |
280 | | - if (mDigits && usedDigits) { |
| 232 | + if (mDigits) { |
281 | 233 | setTrackTime(mchTracks.back(), clusterROF, firstTForbit, usedClusters, *usedDigits); |
282 | 234 | } else { |
283 | | - setTrackTimeFromROF(mchTracks.back(), clusterROF, firstTForbit); |
| 235 | + mchTracks.back().setTimeMUS(clusterROF.getTimeMUS({0, firstTForbit}).first); |
284 | 236 | } |
285 | 237 | } |
286 | 238 | } |
287 | 239 |
|
288 | 240 | bool mDigits = false; ///< send to associated digits |
289 | | - float mTrackTime3Sigma{6.0}; ///< three times the track time resolution, in BC units |
| 241 | + float mTrackTime3Sigma{6.0}; ///< three times the digit time resolution, in BC units |
290 | 242 | TrackFinder mTrackFinder{}; ///< track finder |
291 | 243 | std::chrono::duration<double> mElapsedTime{}; ///< timer |
292 | 244 | }; |
|
0 commit comments