Convert the raw MDT time (+charge) into a drift radius + error.
It returns whether the conversion was successful.
102 {
103
104 const Identifier& id{calibIn.identify()};
105
106 const MuonCalib::MdtCalibDataContainer* calibData{nullptr};
109 }
110
111 const MuonCalib::MdtFullCalibData* calibConstants = calibData->
getCalibData(
id, msgStream());
112 if (!calibConstants) {
114 return MdtCalibOutput{};
115 }
116
117
119
120
121 if(!rtRelation) {
123 return MdtCalibOutput{};
124 }
127 return MdtCalibOutput{};
128 }
131 if (!singleTubeData) {
133 return MdtCalibOutput{};
134 }
136
137 MdtCalibOutput calibResult{};
138
139
142
143
145 const double propagationDistance = calibIn.signalPropagationDistance();
147 <<(invPropSpeed * propagationDistance));
149 }
150
152 const double driftTime = calibIn.tdc() * tdcBinSize
153 - (
m_doTof ? calibIn.timeOfFlight() : 0.)
154 - calibIn.triggerTime()
157
159
160 double corrTime{0.};
162 if (doCorrections) {
165 const MuonCalib::IRtRelation* rt = rtRelation->rt();
168 if (
m_doSlew && corrections->slewing()) {
169 double slewTime=corrections->slewing()->correction(calibResult.
driftTime(), calibIn.adc());
170 corrTime -= slewTime;
172 }
173
174
175 if (
m_doField && corrections->bField()) {
176 MagField::AtlasFieldCache fieldCache{};
177 const AtlasFieldCacheCondObj* bFieldCondCache{nullptr};
180 }
182
184 fieldCache.
getField(calibIn.closestApproach().data(), globalB.data());
185 const Amg::Vector2D locBField = calibIn.projectMagneticField(globalB);
188 locBField[static_cast<int>(BFieldComp::alongWire)],
189 locBField[static_cast<int>(BFieldComp::alongTrack)]));
191 }
198 }
199
200 if (
m_doBkg && corrections->background()) {
201 double bgLevel{0.};
204 }
205 }
206
208
209
210 double r{0.}, reso{0.};
212 double t_inrange =
t;
214
215 assert(rtRelation->rt() != nullptr);
216 r = rtRelation->rt()->radius(t);
217
220 r = rtRelation->rt()->radius( t * (1 + tShift) );
221 }
222
223 if ( t < rtRelation->rt()->tLower()) {
224 t_inrange = rtRelation->rt()->tLower();
225 double rmin = rtRelation->rt()->radius( t_inrange );
226 double drdt = rtRelation->rt()->driftVelocity( t_inrange);
230 }
232 r = rmin + drdt*(
t-t_inrange);
233 } else if( t > rtRelation->rt()->tUpper() ) {
234 t_inrange = rtRelation->rt()->tUpper();
235 double rmax = rtRelation->rt()->radius( t_inrange );
236 double drdt = rtRelation->rt()->driftVelocity(t_inrange);
237
240 }
242 r = rmax + drdt*(
t-t_inrange);
243 }
244
245 assert(rtRelation->rtRes() != nullptr);
246
249 ATH_MSG_VERBOSE(
"Calibrated radius below physical limit "<<
r<<
" vs. "<<calibIn.innerTubeR());
252 reso = std::pow(calibIn.innerTubeR(), 2);
253 }
else if (
r > calibIn.innerTubeR()) {
254 ATH_MSG_VERBOSE(
"Calibrated radius outside tube ."<<
r<<
" vs. "<<calibIn.innerTubeR());
256 r = calibIn.innerTubeR();
257 reso = std::pow(calibIn.innerTubeR(), 2);
258 } else if (!resolFromRtrack) {
259 reso = rtRelation->rtRes()->resolution( t_inrange );
260 } else {
261 const std::optional<double> tFromR = rtRelation->tr()->driftTime(std::abs(calibIn.distanceToTrack()));
262 reso = rtRelation->rtRes()->resolution(tFromR.value_or(0.));
263 }
264
266 assert(rtRelation->rt() != nullptr);
267 const double driftTimeUp = std::min(rtRelation->rt()->tUpper(),
268 calibIn.tdc() * tdcBinSize
269 - (
m_doTof ? calibIn.timeOfFlight() : 0.)
270 - calibIn.triggerTime()
272
273 const double driftTimeDn = std::max(rtRelation->rt()->tLower(),
274 calibIn.tdc() * tdcBinSize
275 - (
m_doTof ? calibIn.timeOfFlight() : 0.)
276 - calibIn.triggerTime()
278 - calibIn.tubeLength() * invPropSpeed);
279
280 const double radiusUp = rtRelation->rt()->radius(driftTimeUp);
281 const double radiusDn = rtRelation->rt()->radius(driftTimeDn);
283 <<
" nominal drift time "<<calibResult.
driftTime()<<
", down: "<<driftTimeDn<<
", up: "<<driftTimeUp
284 <<
" --> driftRadius: "<<
r<<
" pm "<<reso<<
", prop-up: "<<radiusUp<<
", prop-dn: "<<radiusDn
285 <<" delta: "<<(radiusUp-radiusDn));
288 }
289
292
294 <<" passed. "<<std::endl<<"Input: "<<calibIn<<std::endl<<"Extracted calib constants: "<<calibResult<<std::endl);
295 return calibResult;
296}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
void getInitializedCache(MagField::AtlasFieldCache &cache) const
get B field cache for evaluation as a function of 2-d or 3-d position.
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.
float inversePropSpeed() const
const MdtFullCalibData * getCalibData(const Identifier &measId, MsgStream &msg) const
Returns the calibration data associated with this station.
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 ...
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
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)