StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTofCalibMaker.h
1 /*******************************************************************
2  *
3  * $Id: StTofCalibMaker.h,v 1.9 2014/08/06 11:43:46 jeromel Exp $
4  *
5  * Author: Xin Dong
6  *****************************************************************
7  *
8  * Description: Tof Calibration Maker to do the calibration for pVPD
9  * (start timing) , TOFp and TOFr
10  * store into StTofHit
11  *
12  *****************************************************************
13  *
14  * $Log: StTofCalibMaker.h,v $
15  * Revision 1.9 2014/08/06 11:43:46 jeromel
16  * Suffix on literals need to be space (later gcc compiler makes it an error) - first wave of fixes
17  *
18  * Revision 1.8 2008/09/03 22:30:43 dongx
19  * mTStart added, applicable for Run8
20  *
21  * Revision 1.7 2008/06/17 17:49:19 dongx
22  * Update for Run 8 - first release
23  *
24  * Revision 1.6 2007/03/05 18:51:02 dongx
25  * updated for Run V CuCu calibration
26  * - INL correction moved in this maker
27  * - Tot Corr and Z Corr use new tables in data base
28  * - pVPD calibrated information cannot be fully stored within current infrastructure, need update on TofCollection. Configurations better than (1,1) are all selected.
29  *
30  * Revision 1.5 2005/04/12 17:33:48 dongx
31  * update for year 5 data. not completed, leave as empty now.
32  *
33  * Revision 1.4 2004/07/16 18:28:18 dongx
34  * -Tofp Slewing function changed in AuAu200 GeV Run IV
35  * -Include those runs with eastern PVPD dead
36  *
37  * Revision 1.3 2004/07/16 15:06:08 dongx
38  * Z correction function separated for TOFp and TOFr.
39  * Use a new one for RunIV AuAu 200GeV runs
40  *
41  * Revision 1.2 2004/07/15 18:11:22 dongx
42  * -introduce two new tables in dbase: tofAdcRange & tofResolution
43  * -continue update on writing StTofPidTraits
44  *
45  * Revision 1.1 2004/07/01 17:23:48 dongx
46  * first release
47  *
48  *
49  *******************************************************************/
50 #ifndef STTOFCALIMAKER_H
51 #define STTOFCALIMAKER_H
52 
53 #include "TMath.h"
54 #include "TF1.h"
55 #include "StMaker.h"
56 
57 #define VHRBIN2PS 24.4140625 // Very High resolution mode, pico-second per bin
58  // 1000*25/1024 (ps/chn)
59 #define HRBIN2PS 97.65625 // High resolution mode, pico-second per bin
60  // 97.65625= 1000*100/1024 (ps/chn)
61 #define TMAX 51200. // tdc limit
62 
63 #include <string>
64 #include <vector>
65 #ifndef ST_NO_NAMESPACES
66 using std::string;
67 using std::vector;
68 #endif
69 
70 class StEvent;
71 class StTofGeometry;
72 class StTofCollection;
76 class StTofHitCollection;
77 #include "StPhysicalHelixD.hh"
78 #include "StTofUtil/StSortTofRawData.h"
79 
80 #if !defined(ST_NO_TEMPLATE_DEF_ARGS) || defined(__CINT__)
81 typedef vector<Int_t> IntVec;
82 typedef vector<Double_t> DoubleVec;
83 #else
84 typedef vector<Int_t, allocator<Int_t>> IntVec;
85 typedef vector<Double_t, allocator<Double_t>> DoubleVec;
86 #endif
87 
88 class StTofCalibMaker : public StMaker{
89 public:
90 
92  StTofCalibMaker(const char* name="tofCalib");
95 
96  Int_t Init();
97  Int_t InitRun(int);
98  Int_t FinishRun(int);
99  Int_t Make();
100  Int_t Finish();
101 
102  Int_t processEventYear2to4();
103  Int_t processEventYear5();
104  Int_t processEventYear8();
105 
107  void resetPars();
109  Int_t initParameters(int);
111  void initFormulas();
113  void clearFormulars();
114 
115  void setTDCLimits(const Double_t, const Double_t);
116  void setADCCut(const Double_t);
117  void setTDCWidth(const Double_t);
118 
119  void setPVPDADCLimits(const Double_t, const Double_t);
120  void setPVPDTDCLimits(const Double_t, const Double_t);
121  void setPVPDHitsCut(const Int_t, const Int_t);
122 
123  Bool_t validPVPDADC(const Double_t);
124  Bool_t validPVPDTDC(const Double_t);
125 
127  void setOuterGeometry(const bool);
128 
130  void setSlewingCorr(const bool);
131 
133  Double_t tofrT0Corr(const Double_t tof, const Double_t Tstart, const Int_t iDaqChan);
135  Double_t tofrSlewingCorr(const Double_t tof, const Double_t adc, const Int_t iDaqChan);
137  Double_t tofrZCorr(const Double_t tof, const Double_t zlocal);
139  Double_t tofrAllCorr(const Double_t tof, const Double_t Tstart, const Double_t adc, const Double_t zlocal, const Int_t iDaqChan);
140 
142  Double_t tofpT0Corr(const Double_t tof, const Double_t Tstart, const Int_t iDaqChan);
144  Double_t tofpSlewingCorr(const Double_t tof, const Double_t adc, const Int_t iDaqChan);
146  Double_t tofpZCorr(const Double_t tof, const Double_t zlocal);
148  Double_t tofpAllCorr(const Double_t tof, const Double_t Tstart, const Double_t adc, const Double_t zlocal, const Int_t iDaqChan);
149 
151  Double_t tstart(const Double_t *adc, const Double_t *tdc, const Double_t Vz);
152 
154  Double_t GetINLcorr(const int edgeid,const int tempchan,const int bin);
155  Double_t tstart5(const Double_t *tot, const Double_t *time, const Double_t Vz);
156  Double_t tofr5AllCorr(const Double_t tof, const Double_t tot, const Double_t zlocal, const Int_t iModuleChan);
157 
159  void tsum8(const Double_t *tot, const Double_t *time);
160  Double_t tstart8(const Double_t Vz);
161  Double_t tofr8AllCorr(const Double_t tof, const Double_t tot, const Double_t zlocal, const Int_t iTray, const Int_t iModuleChan);
162  Double_t vpdVertexZ();
163 
164 private:
166  static Int_t const mNCell = 6; // number of cells
167  static Int_t const mNTOFr = 120; // TOFr daq channels
168  static Int_t const mNTOFp = 41; // TOFp daq channels
169  static Int_t const mNPVPD = 6; // pVPD daq channels
170  static Int_t const mNMax = 200; // maximum channles
171  static Int_t const mNPar = 10; // maximum correction parameters
173  static Int_t const mNTOFr5 = 192; // TOFr daq channels in Run 5
174  static Int_t const mTdigBoard = 10; // INL tables
175  static Int_t const mTdcOnBoard = 4;
176  static Int_t const mTdcChannel = 1024;
177  static Int_t const mNBinMax = 60;
179  static const Int_t mNTOF = 192; // 192 for tof in Run 8++
180  static const Int_t mNTDIG = 8; // 8 per tray in Run 8++
181  static const Int_t mNTray8 = 5; // 5 trays in Run 8
182  static const Int_t mNModule = 32; // 32 for tofr5++
183  static const Int_t mNVPD = 19; // 19 tubes at each side
184 
185 
186  static const Int_t mNTray = 120; // 120 trays in full
187  static const Int_t mWestVpdTrayId = 121;
188  static const Int_t mEastVpdTrayId = 122;
189 
190  Double_t mTDCBinWidth;
191  Double_t mTDCLowLimit;
192  Double_t mTDCHighLimit;
193  Double_t mADCCut;
194  Double_t mTDCWidth;
195 
196  Double_t mPVPDADCLowLimit;
197  Double_t mPVPDADCHighLimit;
198  Double_t mPVPDTDCLowLimit;
199  Double_t mPVPDTDCHighLimit;
200 
202  Double_t mTofrADCMin[mNTOFr];
203  Double_t mTofrADCMax[mNTOFr];
204  Double_t mTofpADCMin[mNTOFp];
205  Double_t mTofpADCMax[mNTOFp];
206 
207  Bool_t mYear2;
208  Bool_t mYear3;
209  Bool_t mYear4;
210  Bool_t mYear5;
211  Bool_t mYear8;
212 
213  Bool_t mEastPVPDValid; // 022-035 east pVPD dead Run 4
214 
215  Bool_t mValidCalibPar;
216  Bool_t mValidStartTime;
217 
218  Double_t mTofrT0[mNTOFr];
219  Double_t mTofrTAPar[mNTOFr*mNPar];
220  Double_t mTofrZPar[mNPar];
221  Double_t mTofpT0[mNTOFp];
222  Double_t mTofpTAPar[mNTOFp*mNPar];
223  Double_t mTofpZPar[mNPar];
224  Double_t mPVPDTAPar[mNPVPD*mNPar];
225 
226  Double_t mPVPDTdc[mNPVPD];
227  Double_t mPVPDAdc[mNPVPD];
228 
229  Int_t mPVPDEastHitsCut;
230  Int_t mPVPDWestHitsCut;
231 
232  Double_t mTofrRes[mNTOFr]; // resolution of each channel;
233  Double_t mTofpRes[mNTOFp]; //
234  Double_t mPVPDRes[mNPVPD];
235 
236  TF1* mTofrSlewing;
237  TF1* mTofpSlewing;
238  TF1* mTofrZCorr;
239  TF1* mTofpZCorr;
240  TF1* mPVPDSlewing;
241 
243  StSortTofRawData* mSortTofRawData;
244  Double_t mINLtable[mTdigBoard][mTdcOnBoard][mTdcChannel];
245 
246  Double_t mTofr5TotEdge[mNTOFr5][mNBinMax];
247  Double_t mTofr5TotCorr[mNTOFr5][mNBinMax];
248  Double_t mTofr5ZEdge[mNTOFr5][mNBinMax];
249  Double_t mTofr5ZCorr[mNTOFr5][mNBinMax];
250 
251  Double_t mPVPDTotEdge[mNPVPD][mNBinMax];
252  Double_t mPVPDTotCorr[mNPVPD][mNBinMax];
253 
254  Double_t mPVPDLeTime[mNPVPD];
255  Double_t mPVPDTot[mNPVPD];
256 
258  Double_t mTofTotEdge[mNTray][mNTDIG][mNBinMax];
259  Double_t mTofTotCorr[mNTray][mNTDIG][mNBinMax];
260  Double_t mTofZEdge[mNTray][mNTDIG][mNBinMax];
261  Double_t mTofZCorr[mNTray][mNTDIG][mNBinMax];
262  Double_t mTofTZero[mNTray][mNModule][mNCell];
263 
264  Double_t mVPDTotEdge[2*mNVPD][mNBinMax];
265  Double_t mVPDTotCorr[2*mNVPD][mNBinMax];
266  Double_t mVPDTZero[2*mNVPD];
267 
268  Double_t mVPDLeTime[2*mNVPD];
269  Double_t mVPDTot[2*mNVPD];
270 
271  Double_t mTSumEast;
272  Double_t mTSumWest;
273  UInt_t mVPDHitPatternEast;
274  UInt_t mVPDHitPatternWest;
275  Int_t mNEast;
276  Int_t mNWest;
277  Double_t mVPDVtxZ;
278  Double_t mProjVtxZ;
279  Double_t mTDiff;
280  Double_t mTStart;
281 
282  Double_t mPhaseOffset8;
283  StPhysicalHelixD* mBeamHelix;
284  StTofGeometry* mTofpGeom;
286  StEvent* mEvent;
287  Bool_t mOuterGeometry;
288 
289  Bool_t mSlewingCorr;
290 
291  virtual const char *GetCVS() const
292  {static const char cvs[]="Tag $Name: $ $Id: StTofCalibMaker.h,v 1.9 2014/08/06 11:43:46 jeromel Exp $ built " __DATE__ " " __TIME__ ; return cvs;}
293 
294  ClassDef(StTofCalibMaker,5)
295 };
296 
297 inline void StTofCalibMaker::setTDCLimits(const Double_t tmin, const Double_t tmax) { mTDCLowLimit = tmin; mTDCHighLimit = tmax; }
298 
299 inline void StTofCalibMaker::setADCCut(const Double_t cut) { mADCCut = cut; }
300 
301 inline void StTofCalibMaker::setTDCWidth(const Double_t tdcwid) { mTDCWidth = tdcwid; }
302 
303 inline void StTofCalibMaker::setPVPDTDCLimits(const Double_t tmin, const Double_t tmax) { mPVPDTDCLowLimit = tmin; mPVPDTDCHighLimit = tmax; }
304 
305 inline void StTofCalibMaker::setPVPDADCLimits(const Double_t amin, const Double_t amax) { mPVPDADCLowLimit = amin; mPVPDADCHighLimit = amax; }
306 
307 inline Bool_t StTofCalibMaker::validPVPDADC(const Double_t adc) { return (adc>=mPVPDADCLowLimit&&adc<mPVPDADCHighLimit); }
308 
309 inline Bool_t StTofCalibMaker::validPVPDTDC(const Double_t tdc) { return (tdc>=mPVPDTDCLowLimit&&tdc<mPVPDTDCHighLimit); }
310 
311 inline void StTofCalibMaker::setPVPDHitsCut(const Int_t ieast, const Int_t iwest) { mPVPDEastHitsCut=ieast ; mPVPDWestHitsCut=iwest; }
312 
313 inline void StTofCalibMaker::setOuterGeometry(const bool val) { mOuterGeometry=val; }
314 
315 inline void StTofCalibMaker::setSlewingCorr(const bool val) { mSlewingCorr=val; }
316 
317 inline Double_t StTofCalibMaker::vpdVertexZ() { return mVPDVtxZ; }
318 #endif
Double_t tofpSlewingCorr(const Double_t tof, const Double_t adc, const Int_t iDaqChan)
tofp TA slewing correction function
void resetPars()
Reset the calibration parameters.
Int_t initParameters(int)
Initialize the calibration parameters from dbase.
void setOuterGeometry(const bool)
switch to select the Helix Geometry
Double_t tofrAllCorr(const Double_t tof, const Double_t Tstart, const Double_t adc, const Double_t zlocal, const Int_t iDaqChan)
tofr overall correction function
Double_t GetINLcorr(const int edgeid, const int tempchan, const int bin)
Run 5 -&gt;
Double_t tstart(const Double_t *adc, const Double_t *tdc, const Double_t Vz)
Start timing calculation function.
Definition: tof.h:15
void tsum8(const Double_t *tot, const Double_t *time)
Run 8 -&gt;
void initFormulas()
Initialize the formulas of calibration functions.
Double_t tofrSlewingCorr(const Double_t tof, const Double_t adc, const Int_t iDaqChan)
tofr TA slewing correction function
StTofCalibMaker(const char *name="tofCalib")
Default constructor.
Time-of-Flight Geometry Utilities.
Double_t tofpZCorr(const Double_t tof, const Double_t zlocal)
tofp loca Zhit correction function
Double_t tofpT0Corr(const Double_t tof, const Double_t Tstart, const Int_t iDaqChan)
tofp T0 calibration function
void clearFormulars()
Delete the calibration functions.
void setSlewingCorr(const bool)
switch to turn on slewing correction or not - maybe only T0 in the first step.
Double_t tofrZCorr(const Double_t tof, const Double_t zlocal)
tofr local Zhit correction function
Double_t tstart5(const Double_t *tot, const Double_t *time, const Double_t Vz)
~StTofCalibMaker()
Destructor.
Double_t tofrT0Corr(const Double_t tof, const Double_t Tstart, const Int_t iDaqChan)
tofr T0 calibration function
Double_t tofr8AllCorr(const Double_t tof, const Double_t tot, const Double_t zlocal, const Int_t iTray, const Int_t iModuleChan)
tstart calculation splitted into 2 steps in Run 8 since no primary vertex in the event ...
Double_t tofpAllCorr(const Double_t tof, const Double_t Tstart, const Double_t adc, const Double_t zlocal, const Int_t iDaqChan)
tofp overall correction function