Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
///////////////////////////////////////////////////////////////////////////////
// //
// THcDCLookupTTDConv //
// //
///////////////////////////////////////////////////////////////////////////////
#include "THcDCLookupTTDConv.h"
ClassImp(THcDCLookupTTDConv)
//______________________________________________________________________________
THcDCLookupTTDConv::THcDCLookupTTDConv()
{
//Normal constructor
}
//______________________________________________________________________________
THcDCLookupTTDConv::THcDCLookupTTDConv( Double_t vel)
{
// Normal constructor
fDriftVel = vel;
// TODO: This should be read from database!!
fA1tdcCor[0] = 2.12e-3;
fA1tdcCor[1] = 0.0;
fA1tdcCor[2] = 0.0;
fA1tdcCor[3] = 0.0;
fA2tdcCor[0] = -4.20e-4;
fA2tdcCor[1] = 1.3e-3;
fA2tdcCor[2] = 1.06e-4;
fA2tdcCor[3] = 0.0;
fdtime = 4.e-9; // 4ns -> 200 microns
}
//______________________________________________________________________________
THcDCLookupTTDConv::~THcDCLookupTTDConv()
{
// Destructor. Remove variables from global list.
}
//______________________________________________________________________________
Double_t THcDCLookupTTDConv::ConvertTimeToDist(Double_t time,
Double_t tanTheta,
Double_t *ddist)
{
// Drift Velocity in m/s
// time in s
// Return m
// printf("Converting Drift Time to Drift Distance!\n");
Double_t a1 = 0.0, a2 = 0.0;
// Find the values of a1 and a2 by evaluating the proper polynomials
// a = A_3 * x^3 + A_2 * x^2 + A_1 * x + A_0
tanTheta = 1.0 / tanTheta; // I assume this has to do w/ making the
// polynomial have the proper variable...
for (Int_t i = 3; i >= 1; i--) {
a1 = tanTheta * (a1 + fA1tdcCor[i]);
a2 = tanTheta * (a2 + fA2tdcCor[i]);
}
a1 += fA1tdcCor[0];
a2 += fA2tdcCor[0];
// printf("a1(%e) = %e\n", tanTheta, a1);
// printf("a2(%e) = %e\n", tanTheta, a2);
// ESPACE software includes corrections to the time for
// 1. Cluster t0 (offset applied to entire cluster)
// 2. Time of flight to scintillators
Double_t dist = fDriftVel * time;
Double_t unc = fDriftVel * fdtime; // watch uncertainty in the timing
if (dist < 0) {
// something screwy is going on
} else if (dist < a1 ) {
// dist = fDriftVel * time * (1 + 1 / (a1/a2 + 1));
dist *= ( 1 + a2 / a1);
unc *= ( 1 + a2 / a1);
} else {
dist += a2;
}
if (ddist) *ddist = unc;
// printf("D(%e) = %e\nUncorrected D = %e\n", time, dist, fDriftVel * time);
return dist;
}
////////////////////////////////////////////////////////////////////////////////