20using namespace garfield;
21using namespace constants;
24bool DiffusionAndTimeStructEstimator::sampleTimeStruct(
float vdrift)
34 if (std::abs(mTimeLastVdrift - vdrift) < 1.e-3) {
37 mTimeLastVdrift = vdrift;
40 constexpr float fVDsmp[8] = {1.032, 1.158, 1.299, 1.450, 1.610, 1.783, 1.959, 2.134};
42 if (vdrift < fVDsmp[0]) {
43 LOG(
debug) <<
"TRD: Drift Velocity too small " << vdrift <<
" < " << fVDsmp[0];
46 }
else if (vdrift > fVDsmp[7]) {
47 LOG(
debug) <<
"TRD: Drift Velocity too large " << vdrift <<
" > " << fVDsmp[7];
51 if (vdrift > fVDsmp[6]) {
60 }
else if (vdrift > fVDsmp[5]) {
69 }
else if (vdrift > fVDsmp[4]) {
78 }
else if (vdrift > fVDsmp[3]) {
87 }
else if (vdrift > fVDsmp[2]) {
96 }
else if (vdrift > fVDsmp[1]) {
105 }
else if (vdrift > (fVDsmp[0] - 1.0e-5)) {
115 mInvBinWidth = 1. / (mVDhi - mVDlo);
140 if (!sampleTimeStruct(vdrift)) {
145 int r1 = (
int)(10 * dist);
156 const int kz1 = ((
int)(100 *
z / 2.5));
157 const int kz2 = kz1 + 1;
159 if ((r1 < 0) || (r1 > 37) || (kz1 < 0) || (kz1 > 10)) {
160 LOG(warn) << Form(
"TRD: Time struct indices out of range: dist=%.2f, z=%.2f, r1=%d, kz1=%d", dist,
z, r1, kz1);
163 const float ky111 = mTimeStruct1[r1 + 38 * kz1];
164 const float ky221 = ((r2 <= 37) && (kz2 <= 10)) ? mTimeStruct1[r2 + 38 * kz2] : mTimeStruct1[37 + 38 * 10];
165 const float ky121 = (kz2 <= 10) ? mTimeStruct1[r1 + 38 * kz2] : mTimeStruct1[r1 + 38 * 10];
166 const float ky211 = mTimeStruct1[r2 + 38 * kz1];
168 const float ky112 = mTimeStruct2[r1 + 38 * kz1];
169 const float ky222 = ((r2 <= 37) && (kz2 <= 10)) ? mTimeStruct2[r2 + 38 * kz2] : mTimeStruct2[37 + 38 * 10];
170 const float ky122 = (kz2 <= 10) ? mTimeStruct2[r1 + 38 * kz2] : mTimeStruct2[r1 + 38 * 10];
171 const float ky212 = mTimeStruct2[r2 + 38 * kz1];
174 const float ky11 = (ky211 - ky111) * 10 * dist + ky111 - (ky211 - ky111) * r1;
175 const float ky21 = (ky221 - ky121) * 10 * dist + ky121 - (ky221 - ky121) * r1;
178 const float ky12 = (ky212 - ky112) * 10 * dist + ky112 - (ky212 - ky112) * r1;
179 const float ky22 = (ky222 - ky122) * 10 * dist + ky122 - (ky222 - ky122) * r1;
183 dist -= Geometry::amThick() * 0.5;
186 const bool condition = ((std::abs(dist) > 0.005) || (
z > 0.005));
187 const float ktdrift1 =
188 condition ? (ky21 - ky11) * 100 *
z / 2.5 + ky11 - (ky21 - ky11) * kz1 : 0.0;
190 const float ktdrift2 =
191 condition ? (ky22 - ky12) * 100 *
z / 2.5 + ky12 - (ky22 - ky12) * kz1 : 0.0;
194 const float a = (ktdrift2 - ktdrift1) * mInvBinWidth;
195 const float b = ktdrift2 -
a * mVDhi;
196 const float t =
a * vdrift +
b;
210 if (std::abs(mDiffLastVdrift - vdrift) < 0.001) {
215 mDiffLastVdrift = vdrift;
223 constexpr int kNb = 5;
227 int ib = ((
int)(10 * (mBz - 0.15)));
228 ib = std::max(0, ib);
229 ib = std::min(kNb - 1, ib);
232 constexpr float p0T[kNb] = {0.009550, 0.009599, 0.009674, 0.009757, 0.009850};
233 constexpr float p1T[kNb] = {0.006667, 0.006539, 0.006359, 0.006153, 0.005925};
234 constexpr float p2T[kNb] = {-0.000853, -0.000798, -0.000721, -0.000635, -0.000541};
235 constexpr float p3T[kNb] = {0.000131, 0.000122, 0.000111, 0.000098, 0.000085};
237 constexpr float p0L[kNb] = {0.007440, 0.007493, 0.007513, 0.007672, 0.007831};
238 constexpr float p1L[kNb] = {0.019252, 0.018912, 0.018636, 0.018012, 0.017343};
239 constexpr float p2L[kNb] = {-0.005042, -0.004926, -0.004867, -0.004650, -0.004424};
240 constexpr float p3L[kNb] = {0.000195, 0.000189, 0.000195, 0.000182, 0.000169};
242 const float v2 = vdrift * vdrift;
243 const float v3 =
v2 * vdrift;
244 mDiffusionL = p0L[ib] + p1L[ib] * vdrift + p2L[ib] *
v2 + p3L[ib] *
v3;
245 mDiffusionT = p0T[ib] + p1T[ib] * vdrift + p2T[ib] *
v2 + p3T[ib] *
v3;
254 mDiffusionL = 0.0182;
255 mDiffusionT = 0.0159;
bool getDiffCoeff(float &dl, float &dt, float vdrift)
determines the diffusion coefficients as a function of drift velocity
float timeStruct(float vdrift, float xd, float z, bool *errFlag=nullptr)
determines drift time as function of drift velocity and coordinates
GLboolean GLboolean GLboolean b
GLfloat GLfloat GLfloat GLfloat v3
GLboolean GLboolean GLboolean GLboolean a
GLfloat GLfloat GLfloat v2
GLdouble GLdouble GLdouble z
constexpr std::array< std::array< float, ZBINSGARFIELD >, TIMEBINSGARFIELD > Time1800
constexpr std::array< std::array< float, ZBINSGARFIELD >, TIMEBINSGARFIELD > Time1600
constexpr std::array< std::array< float, ZBINSGARFIELD >, TIMEBINSGARFIELD > Time1900
constexpr std::array< std::array< float, ZBINSGARFIELD >, TIMEBINSGARFIELD > Time1500
constexpr std::array< std::array< float, ZBINSGARFIELD >, TIMEBINSGARFIELD > Time1700
constexpr std::array< std::array< float, ZBINSGARFIELD >, TIMEBINSGARFIELD > Time2200
constexpr int ZBINSGARFIELD
constexpr int TIMEBINSGARFIELD
constexpr std::array< std::array< float, ZBINSGARFIELD >, TIMEBINSGARFIELD > Time2000
constexpr std::array< std::array< float, ZBINSGARFIELD >, TIMEBINSGARFIELD > Time2100
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"