Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaVDCAnalyticTTDConv.cxx
Go to the documentation of this file.
1
2// //
3// THaVDCAnalyticTTDConv //
4// //
6
8#include "TError.h"
9
11
12using namespace std;
13
14namespace VDC {
15
16//_____________________________________________________________________________
18
19{
20 // Constructor
21
22 for( Int_t i=0; i<4; ++i ) {
23 fA1tdcCor[i] = fA2tdcCor[i] = kBig;
24 }
25}
26
27//_____________________________________________________________________________
29 Double_t* ddist) const
30{
31 // Drift Velocity in m/s
32 // time in s
33 // Return m
34
35 if( !fIsSet ) {
36 Error( "VDC::AnalyticTTDConv::ConvertTimeToDist", "Parameters not set. "
37 "Fix database." );
38 return kBig;
39 }
40
41// printf("Converting Drift Time to Drift Distance!\n");
42
43 // Find the values of a1 and a2 by evaluating the proper polynomials
44 // a = A_3 * x^3 + A_2 * x^2 + A_1 * x + A_0
45 Double_t a1 = 0.0, a2 = 0.0;
46
47 tanTheta = 1.0 / tanTheta;
48
49 for (Int_t i = 3; i >= 1; i--) {
50 a1 = tanTheta * (a1 + fA1tdcCor[i]);
51 a2 = tanTheta * (a2 + fA2tdcCor[i]);
52 }
53 a1 += fA1tdcCor[0];
54 a2 += fA2tdcCor[0];
55
57 Double_t unc = fDriftVel * fdtime; // watch uncertainty in the timing
58 if (dist < 0) {
59 // something screwy is going on
60 } else if (dist < a1 ) {
61 // dist = fDriftVel * time * (1 + 1 / (a1/a2 + 1));
62 dist *= ( 1 + a2 / a1);
63 unc *= ( 1 + a2 / a1);
64 } else {
65 dist += a2;
66 }
67
68 if (ddist) *ddist = unc;
69
70 return dist;
71}
72
73//_____________________________________________________________________________
75{
76 // Get i-th parameter
77
78 switch(i) {
79 case 0:
80 case 1:
81 case 2:
82 case 3:
83 return fA1tdcCor[i];
84 case 4:
85 case 5:
86 case 6:
87 case 7:
88 return fA2tdcCor[i-4];
89 case 8:
90 return fdtime;
91 default:
92 return kBig;
93 }
94}
95
96//_____________________________________________________________________________
97Int_t AnalyticTTDConv::SetParameters( const vector<double>& parameters )
98{
99 // Set coefficients of a1 and a2 4-th order polynomial and uncertainty
100 // of drift time measurement
101 // 0-3: A1
102 // 4-7: A2
103 // 8: sigma_time (s)
104
105 if( (UInt_t)parameters.size() < fNparam )
106 return -1;
107
108 for( size_t i = 0; i<4; ++i ) {
109 fA1tdcCor[i] = parameters[i];
110 fA2tdcCor[i] = parameters[i+4];
111 }
112 fdtime = parameters[8];
113
114 fIsSet = true;
115 return 0;
116}
117
118//_____________________________________________________________________________
119// void AnalyticTTDConv::SetDefaultParam()
120// {
121// // Set some reasonable defaults for the polynomial coefficients and
122// // drift time uncertainty. Applicable to Hall A VDCs.
123
124// fA1tdcCor[0] = 2.12e-3;
125// fA1tdcCor[1] = 0.0;
126// fA1tdcCor[2] = 0.0;
127// fA1tdcCor[3] = 0.0;
128// fA2tdcCor[0] = -4.20e-4;
129// fA2tdcCor[1] = 1.3e-3;
130// fA2tdcCor[2] = 1.06e-4;
131// fA2tdcCor[3] = 0.0;
132
133// fdtime = 4.e-9; // 4ns -> 200 microns
134// }
135
136} //namespace VDC
137
int Int_t
unsigned int UInt_t
const Data_t kBig
Definition DataType.h:15
uint32_t time
double Double_t
virtual Double_t ConvertTimeToDist(Double_t time, Double_t tanTheta, Double_t *ddist=0) const
virtual Double_t GetParameter(UInt_t i) const
virtual Int_t SetParameters(const std::vector< double > &param)
double dist(AxisAngle const &r1, AxisAngle const &r2)
void Error(const char *location, const char *fmt,...)
STL namespace.
ClassImp(TPyArg)