17 declareInterface<IMDT_DigitizationTool>(
this);
24 return StatusCode::SUCCESS;
29 CLHEP::HepRandomEngine *rndmEngine)
const {
33 const double maxTubeRadius{detMgr->getMdtReadoutElement(DigitId)->innerTubeRadius()};
34 const double radius{input.radius()};
36 if ((radius < 0) || (radius > maxTubeRadius) ||
37 (radius >=
m_effRadius && CLHEP::RandFlat::shoot(rndmEngine, 0.0, 1.0) > eff)) {
48 double innerTubeRadius,
50 CLHEP::HepRandomEngine *rndmEngine)
const {
54 if (!calibConstants.
isValid()) {
56 throw std::runtime_error(
"No Mdt calibration constants");
59 const RtRelationPtr&
data{calibConstants->getCalibData(DigitId, msgStream())->rtRelation};
71 time = trRelation->
driftTime(std::abs(measRadius)).value_or(0.);
79 double radiusWidth = rtResolution->
resolution(time);
85 ATH_MSG_WARNING(
"Drift velocity <=0 ! Time will not be smeared with resolution but will take the default measRadius-t value");
88 double timeWidth = radiusWidth / velocity;
91 double tUp = rtRelation->
tUpper();
94 double tmin = time - 3.4 * timeWidth;
95 double tmax = time + 3.4 * timeWidth;
97 if (tmin < 0.0) tmin = 0.0;
99 tmax = trRelation->
driftTime(innerTubeRadius).value_or(0.);
102 constexpr double sqrt_one_over_two_pi = 0.39894228;
103 double p1r = 0.8480 * std::exp(-0.5879 * measRadius);
109 t = CLHEP::RandFlat::shoot(rndmEngine, tmin, tmax);
111 gaussian = (1 - p1r) * sqrt_one_over_two_pi * exp(-(t - time) * (t - time) / (2.0 * timeWidth * timeWidth));
112 if (gaussian >= CLHEP::RandFlat::shoot(rndmEngine, 0.0, 1.0) || cutoff > 200) { flag = 1; }
116 ATH_MSG_DEBUG(
"t from r = " << time <<
" t resolution = " << timeWidth <<
"\nr resolution = " << radiusWidth
117 <<
" driftvelocity = " << velocity <<
"\nsmeared t = " << t <<
" cutoff = " << cutoff);
119 ATH_MSG_ERROR(
"Null pointer returned from CalibDBSvc. Returning 0.0 as drift time");
128 constexpr double p0 = 57.38141;
129 constexpr double p1 = 8.616943;
130 constexpr double p2 = 2.497827;
131 constexpr double p3 = -1.625900;
132 constexpr double p4 = 0.3125281;
133 constexpr double p5 = -0.02929554;
134 constexpr double p6 = 0.001367115;
135 constexpr double p7 = -0.00002541936;
137 double adcfunc = p0 + p1 * radius + p2 * std::pow(radius, 2) + p3 * std::pow(radius, 3) + p4 * std::pow(radius, 4) +
138 p5 * std::pow(radius, 5) + p6 * std::pow(radius, 6) + p7 * std::pow(radius, 7);
141 constexpr double g0 = 10.27808;
142 constexpr double g1 = -0.3774593;
143 constexpr double g2 = 0.02751001;
144 constexpr double g3 = -0.0005994742;
146 double adcWidth = g0 + g1 * radius + g2 * std::pow(radius, 2) + g3 * std::pow(radius, 3);
149 double adc = CLHEP::RandGaussZiggurat::shoot(rndmEngine, adcfunc, adcWidth);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
char data[hepevt_bytes_allocation_ATLAS]
generic interface for a rt-relation
virtual double tUpper() const =0
Returns the upper time covered by the r-t.
virtual double driftVelocity(double t) const =0
Returns the drift velocity for a given time.
Generic interface to retrieve the resolution on the drift radius as a function of the drift time.
virtual double resolution(double t, double bgRate=0.0) const =0
returns resolution for a give time and background rate
virtual std::optional< double > driftTime(const double r) const =0
Interface method for fetching the drift-time from the radius Returns a nullopt if the time is out of ...
MdtFullCalibData::RtRelationPtr RtRelationPtr
Ensure that the Athena extensions are properly loaded.