Convert the raw MDT time (+charge) into a drift radius + error.
It returns whether the conversion was successful.
104 {
105
106 const Identifier& id{calibIn.identify()};
107
109 if (!constantHandle.
isValid()){
111 }
112
113 const MuonCalib::MdtFullCalibData* calibConstants = constantHandle->getCalibData(id, msgStream());
114 if (!calibConstants) {
116 return MdtCalibOutput{};
117 }
118
119
121
122
123 if(!rtRelation) {
125 return MdtCalibOutput{};
126 }
129 return MdtCalibOutput{};
130 }
133 if (!singleTubeData) {
135 return MdtCalibOutput{};
136 }
137 const float invPropSpeed = constantHandle->inversePropSpeed();
138
139 MdtCalibOutput calibResult{};
140
141
144
145
147 const double propagationDistance = calibIn.signalPropagationDistance();
149 <<(invPropSpeed * propagationDistance));
151 }
152
154 const double driftTime = calibIn.tdc() * tdcBinSize
155 - (
m_doTof ? calibIn.timeOfFlight() : 0.)
156 - calibIn.triggerTime()
159
161
162 double corrTime{0.};
164 if (doCorrections) {
167 const MuonCalib::IRtRelation* rt = rtRelation->rt();
170 if (
m_doSlew && corrections->slewing()) {
171 double slewTime=corrections->slewing()->correction(calibResult.
driftTime(), calibIn.adc());
172 corrTime -= slewTime;
174 }
175
176
177 if (
m_doField && corrections->bField()) {
178 MagField::AtlasFieldCache fieldCache{};
179
183 }
184 readHandle->getInitializedCache(fieldCache);
185
187 fieldCache.
getField(calibIn.closestApproach().data(), globalB.data());
188 const Amg::Vector2D locBField = calibIn.projectMagneticField(globalB);
191 locBField[static_cast<int>(BFieldComp::alongWire)],
192 locBField[static_cast<int>(BFieldComp::alongTrack)]));
194 }
201 }
202
203 if (
m_doBkg && corrections->background()) {
204 double bgLevel{0.};
207 }
208 }
209
211
212
213 double r{0.}, reso{0.};
215 double t_inrange =
t;
217
218 assert(rtRelation->rt() != nullptr);
219 r = rtRelation->rt()->radius(t);
220
223 r = rtRelation->rt()->radius( t * (1 + tShift) );
224 }
225
226 if ( t < rtRelation->rt()->tLower()) {
227 t_inrange = rtRelation->rt()->tLower();
228 double rmin = rtRelation->rt()->radius( t_inrange );
229 double drdt = rtRelation->rt()->driftVelocity( t_inrange);
233 }
235 r = rmin + drdt*(
t-t_inrange);
236 } else if( t > rtRelation->rt()->tUpper() ) {
237 t_inrange = rtRelation->rt()->tUpper();
238 double rmax = rtRelation->rt()->radius( t_inrange );
239 double drdt = rtRelation->rt()->driftVelocity(t_inrange);
240
243 }
245 r = rmax + drdt*(
t-t_inrange);
246 }
247
248 assert(rtRelation->rtRes() != nullptr);
249
252 ATH_MSG_VERBOSE(
"Calibrated radius below physical limit "<<
r<<
" vs. "<<calibIn.innerTubeR());
255 reso = std::pow(calibIn.innerTubeR(), 2);
256 }
else if (
r > calibIn.innerTubeR()) {
257 ATH_MSG_VERBOSE(
"Calibrated radius outside tube ."<<
r<<
" vs. "<<calibIn.innerTubeR());
259 r = calibIn.innerTubeR();
260 reso = std::pow(calibIn.innerTubeR(), 2);
261 } else if (!resolFromRtrack) {
262 reso = rtRelation->rtRes()->resolution( t_inrange );
263 } else {
264 const std::optional<double> tFromR = rtRelation->tr()->driftTime(std::abs(calibIn.distanceToTrack()));
265 reso = rtRelation->rtRes()->resolution(tFromR.value_or(0.));
266 }
267
269 assert(rtRelation->rt() != nullptr);
270 const double driftTimeUp = std::min(rtRelation->rt()->tUpper(),
271 calibIn.tdc() * tdcBinSize
272 - (
m_doTof ? calibIn.timeOfFlight() : 0.)
273 - calibIn.triggerTime()
275
276 const double driftTimeDn = std::max(rtRelation->rt()->tLower(),
277 calibIn.tdc() * tdcBinSize
278 - (
m_doTof ? calibIn.timeOfFlight() : 0.)
279 - calibIn.triggerTime()
281 - calibIn.tubeLength() * invPropSpeed);
282
283 const double radiusUp = rtRelation->rt()->radius(driftTimeUp);
284 const double radiusDn = rtRelation->rt()->radius(driftTimeDn);
286 <<
" nominal drift time "<<calibResult.
driftTime()<<
", down: "<<driftTimeDn<<
", up: "<<driftTimeUp
287 <<
" --> driftRadius: "<<
r<<
" pm "<<reso<<
", prop-up: "<<radiusUp<<
", prop-dn: "<<radiusDn
288 <<" delta: "<<(radiusUp-radiusDn));
291 }
292
295
297 <<" passed. "<<std::endl<<"Input: "<<calibIn<<std::endl<<"Extracted calib constants: "<<calibResult<<std::endl);
298 return calibResult;
299}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
void getField(const double *ATH_RESTRICT xyz, double *ATH_RESTRICT bxyz, double *ATH_RESTRICT deriv=nullptr)
get B field value at given position xyz[3] is in mm, bxyz[3] is in kT if deriv[9] is given,...
double backgroundTime() const
Return the time correction arising from background processes.
void setSlewingTime(const double slewTime)
Sets the slewing time.
void setDriftTime(const double driftTime)
Sets the drift time.
void setBackgroundTime(const double bkgTime)
Sets the background time correction.
void setStatus(const MdtDriftCircleStatus stat)
double driftTime() const
Returns the drift time inside the tube.
void setTemperatureTime(const double tempTime)
Sets the temperature time correction.
void setDriftUncertSigProp(const double uncert)
Sets the uncertainty on the drift radius arising from the unknown position along the wires.
void setTubeT0(const double T0)
Sets the tube T0.
double driftUncertSigProp() const
Returns the uncertainty on the drift radius arising from the unknown position along the wire.
void setLorentzTime(const double time)
Sets the Lorentz time.
void setDriftRadius(const double radius, const double uncert)
Sets the charge drift radius and its associated uncertainty.
void setMeanAdc(const double adc)
Sets the mean tube adc.
double temperatureTime() const
Returns the time corrections stemming from temperature & pressure corrections.
double signalPropagationTime() const
Returns the signal propagation time.
double lorentzTime() const
Returns the time corrections from the signal propgation inside a magnetic field.
double tubeT0() const
Returns the point in time where the muon typically enters the chamber.
void setPropagationTime(const double T0)
Sets the signal propagation time in the tube wire.
int multilayer(const Identifier &id) const
Access to components of the ID.
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
float RtScaleFunction(const float t, const bool ml2, const IRtRelation &rtrelation)
MdtDriftCircleStatus
Enum to represent the 'status' of Mdt measurements e.g.
@ MdtStatusAfterSpectrum
The tube produced a hit that is inconsistent with the drift time spectrum, the drift time is larger t...
@ MdtStatusBeforeSpectrum
The tube produced a hit that is inconsistent with the drift time spectrum, the drift time is smaller ...
TubeContainerPtr tubeCalib
CorrectionPtr corrections
float adcCal
quality flag for the SingleTubeCalib constants: 0 all ok, 1 no hits found, 2 too few hits,...
float t0
< relative t0 in chamber (ns)
#define THROW_EXCEPTION(MESSAGE)