19 #define _SQR_(arg) ((arg)*(arg))
26 if (!digi->fTransverseDispersion || !digi->fLongitudinalDispersion ||
27 !digi->fLongitudinalIntrinsicResolution || !digi->fTransverseIntrinsicResolution ||
28 !digi->fGemVerticalPadSize)
30 std::cout <<
"-E- EicTpcDigiHitProducer::HandleHit(): part of digi parameters not assigned!" << std::endl;
55 double zLen = 0.1 * (dynamic_cast <
const TpcGeoParData*>(mGptr))->mTotalGasVolumeLength/4.0;
57 double rstart = sqrt(
_SQR_(lstart[0]) +
_SQR_(lstart[1]));
58 double rend = sqrt(
_SQR_(lend [0]) +
_SQR_(lend [1]));
62 unsigned nstart = (int)floor(rstart/digi->fGemVerticalPadSize);
63 unsigned nend = (int)floor(rend /digi->fGemVerticalPadSize);
64 unsigned hnum = nstart >= nend ? nstart - nend : nend - nstart;
73 double x1 = lstart[0];
74 double y1 = lstart[1];
79 double B = x2*(x1-
x2) + y2*(y1-y2);
80 unsigned min = nstart < nend ? nstart : nend;
82 for(
unsigned iqq=0; iqq<hnum; iqq++)
84 double R = (min + iqq + 1)*digi->fGemVerticalPadSize;
88 double det =
_SQR_(B) - A*
C;
90 double rr[2] = {(-B + sqrt(det))/A, (-B - sqrt(det))/A};
95 unsigned ok_counter = 0;
96 for(
unsigned ir=0;
ir<2;
ir++)
100 if (alfa >= 0 && alfa <= 1)
105 TVector3 local = alfa * lstart + (1 - alfa) * lend;
114 double qResolution[3] = {digi->fTransverseIntrinsicResolution,
115 digi->fTransverseIntrinsicResolution,
116 digi->fLongitudinalIntrinsicResolution};
120 TVector3 driftCff(digi->fTransverseDispersion, digi->fTransverseDispersion,
121 digi->fLongitudinalDispersion);
125 double driftDist = zLen - local[2];
129 if (driftDist < 0.0) driftDist = 0.0;
131 for(
int iq=0; iq<3; iq++)
132 qResolution[iq] = sqrt(
_SQR_(qResolution[iq]) +
_SQR_(driftCff[iq]*sqrt(driftDist)));
135 for(
int iq=0; iq<3; iq++)
138 qResolution[iq] /= 1E4;
139 local[iq] += gRandom->Gaus(0.0, qResolution[iq]);
164 double locarr[3] = {local.X(), local.Y(), local.Z()};
166 double qCovariance[3][3];
167 memset(qCovariance, 0x00,
sizeof(qCovariance));
168 for(
unsigned ip=0;
ip<3;
ip++)
171 new((*mDigiHitArray)[mDigiHitArray->GetEntriesFast()])
181 double radialResolution = digi->fRadialIntrinsicResolution ?
182 digi->fRadialIntrinsicResolution : 1E4*digi->fGemVerticalPadSize/sqrt(12.);
183 double qResolution[3] = {radialResolution,
184 digi->fTransverseIntrinsicResolution,
185 digi->fLongitudinalIntrinsicResolution};
190 TVector3 driftCff(digi->fTransverseDispersion, digi->fTransverseDispersion,
191 digi->fLongitudinalDispersion);
195 double driftDist = zLen - local[2];
199 if (driftDist < 0.0) driftDist = 0.0;
202 for(
int iq=0; iq<3; iq++)
203 qResolution[iq] = sqrt(
_SQR_(qResolution[iq]) +
_SQR_(driftCff[iq]*sqrt(driftDist)));
206 for(
int iq=0; iq<3; iq++)
207 qResolution[iq] /= 1E4;
213 double buffer[3] = {
R, 0.0, local[2]}, smeared[3];
222 buffer[0] += digi->fRadialIntrinsicResolution ?
223 gRandom->Gaus(0.0, qResolution[0]) : digi->fGemVerticalPadSize * gRandom->Uniform(-0.5, 0.5);
224 for(
int iq=1; iq<3; iq++)
225 buffer[iq] += gRandom->Gaus(0.0, qResolution[iq]);
229 double phi = atan2(local[1], local[0]);
230 double s = sin(phi),
c =
cos(phi);
231 double r[2][2] = {{
c, -s}, {
s,
c}};
233 memset(smeared, 0x00,
sizeof(smeared));
234 for(
unsigned ip=0;
ip<2;
ip++)
235 for(
unsigned iq=0; iq<2; iq++)
236 smeared[
ip] += r[
ip][iq]*buffer[iq];
237 smeared[2] = buffer[2];
243 double qCovariance[3][3], qBuffer[2][2];
244 memset(qCovariance, 0x00,
sizeof(qCovariance));
248 memset(qBuffer, 0x00,
sizeof(qBuffer));
249 for(
unsigned ip=0;
ip<2;
ip++)
252 for(
unsigned ip=0; ip<2; ip++)
253 for(
unsigned iq=0; iq<2; iq++)
254 for(
unsigned it=0;
it<2;
it++)
255 for(
unsigned is=0; is<2; is++)
256 qCovariance[ip][is] += r[ip][iq] * qBuffer[iq][
it] * r[is][
it];
257 qCovariance[2][2] =
_SQR_(qResolution[2]);
260 TVector3 vCoord(smeared);
261 new((*mDigiHitArray)[mDigiHitArray->GetEntriesFast()])
270 assert(ok_counter == 1);
284 TFile fout(fileName,
"RECREATE");
288 std::cout <<
"-E- EicTpcDigiHitProducer::exportTpcDigiParameters(): failed to open '" <<
289 fileName <<
"'!" << std::endl;
293 fout.WriteObject(digi, mDetName->Name() +
"DigiParData");
303 TString expandedFileName(fileName);
306 if (!expandedFileName.BeginsWith(
"./") && !expandedFileName.BeginsWith(
"/"))
308 TString wrkDir = getenv(
"VMCWORKDIR");
310 expandedFileName = wrkDir +
"/input/" + expandedFileName;
313 TFile fin(expandedFileName);
317 std::cout <<
"-E- EicTpcDigiHitProducer::importTpcDigiParameters(): failed to open '" <<
318 fileName <<
"'!" << std::endl;
323 fin.GetObject(mDetName->Name() +
"DigiParData", digi); assert(digi);
334 printf(
"\n-I- TPC 'naive' digitization parameters:\n\n");
335 printf(
" transverse dispersion : %7.2f [um]/sqrt(D[cm])\n", fTransverseDispersion);
336 printf(
" longitudinal dispersion : %7.2f [um]/sqrt(D[cm])\n", fLongitudinalDispersion);
337 printf(
" transverse intrinsic resolution : %7.2f [um]\n", fTransverseIntrinsicResolution);
338 printf(
" longitudinal intrinsic resolution: %7.2f [um]\n", fLongitudinalIntrinsicResolution);
339 printf(
" radial intrinsic resolution : %7.2f [um]\n", fRadialIntrinsicResolution);
340 printf(
" GEM vertical pad size : %7.2f [cm]\n\n", fGemVerticalPadSize);