1 |
/** |
2 |
* \file ToFLevel2.h |
3 |
* \author Gianfranca DeRosa / Wolfgang Menn |
4 |
*/ |
5 |
|
6 |
#ifndef ToFLevel2_h |
7 |
#define ToFLevel2_h |
8 |
// |
9 |
#include <TObject.h> |
10 |
#include <TArrayI.h> |
11 |
#include <TArrayF.h> |
12 |
#include <TClonesArray.h> |
13 |
|
14 |
#include <math.h> // EMILIANO |
15 |
#include <iostream> // from ToFLevel2.cpp |
16 |
#include <fstream> // Emiliano |
17 |
#include <sstream> // Emiliano |
18 |
#include <string> // Emiliano |
19 |
|
20 |
|
21 |
#include <ToFStruct.h> |
22 |
|
23 |
#include <TrkLevel2.h> // Emiliano |
24 |
#include <TrigLevel2.h> // Emiliano |
25 |
#include <GLTables.h> // Emiliano |
26 |
#include <OrbitalInfo.h> // Emiliano |
27 |
#include <ToFCore.h> // Emiliano |
28 |
#include <physics/tof/TofEvent.h> |
29 |
|
30 |
// |
31 |
// Declaration of the core fortran routines |
32 |
// |
33 |
#define tofl2com tofl2com_ |
34 |
extern "C" int tofl2com(); |
35 |
#define toftrk toftrk_ |
36 |
extern "C" int toftrk(); |
37 |
#define rdtofcal rdtofcal_ |
38 |
extern "C" int rdtofcal(char [], int *); |
39 |
|
40 |
// |
41 |
// class which contains track related variables |
42 |
// |
43 |
#define ZTOF11 53.74 |
44 |
#define ZTOF12 53.04 |
45 |
#define ZTOF21 23.94 |
46 |
#define ZTOF22 23.44 |
47 |
#define ZTOF31 -23.49 |
48 |
#define ZTOF32 -24.34 |
49 |
|
50 |
|
51 |
class ToFGeom : public TObject { |
52 |
|
53 |
private: |
54 |
TArrayI ePlane, eXY; |
55 |
|
56 |
public: |
57 |
ToFGeom() { |
58 |
int plane[24] = { |
59 |
0, 0, 0, 0, 0, 0, 0, 0, |
60 |
1, 1, 1, 1, 1, 1, |
61 |
2, 2, |
62 |
3, 3, |
63 |
4, 4, 4, |
64 |
5, 5, 5 |
65 |
}; |
66 |
int plXY[6]= { 2, 1, 1, 2, 2, 1 }; // X==1, Y==2 */ |
67 |
ePlane.Set(24,plane); |
68 |
eXY.Set(6,plXY); |
69 |
} |
70 |
|
71 |
int GetPad( int idpmt) { return (int)((idpmt+0.5)/2.); } |
72 |
int GetPlane( int idpmt) { return ePlane[ GetPad(idpmt) ]; } |
73 |
int GetXY( int idpmt) { return eXY[ GetPlane(idpmt) ]; } |
74 |
|
75 |
ClassDef(ToFGeom,1); |
76 |
|
77 |
}; |
78 |
|
79 |
|
80 |
/** |
81 |
* \brief Class which contains the PMT data |
82 |
* |
83 |
* If there is a valid ADC or a TDC value (value<4095) for a PMT, both ADC and TDC data |
84 |
* are stored in the PMT class. |
85 |
* Look in the ToFLevel2Ex.cxx example in the repository how to read the PMT class. |
86 |
*/ |
87 |
class ToFPMT : public TObject { |
88 |
|
89 |
private: |
90 |
|
91 |
public: |
92 |
Int_t pmt_id; ///<the identification number of the PMT from 0 to 47 |
93 |
Float_t adc; ///<raw ADC value for this PMT |
94 |
Float_t tdc; ///<raw TDC value for this PMT |
95 |
Float_t tdc_tw; ///<time-walk corrected TDC value for this PMT |
96 |
// |
97 |
ToFPMT(); |
98 |
ToFPMT(const ToFPMT&); |
99 |
// |
100 |
ToFPMT* GetToFPMT(){return this;}; |
101 |
void Clear(Option_t *t=""); |
102 |
|
103 |
|
104 |
|
105 |
ClassDef(ToFPMT,2); |
106 |
}; |
107 |
|
108 |
/** |
109 |
* \brief Class used to calibrate adc to dEdx for each PMT |
110 |
* |
111 |
* Class used to calibrate adc to dEdx for each PMT |
112 |
*/ |
113 |
class ToFdEdx : public TObject { |
114 |
|
115 |
private: |
116 |
// |
117 |
|
118 |
ToFGeom eGeom; // ToF geometry |
119 |
// |
120 |
|
121 |
Float_t adc_he; |
122 |
|
123 |
TArrayF eDEDXpmt; // 0-47 pmt dEdx |
124 |
TArrayF eZpmt; // 0-47 pmt charge |
125 |
TArrayF eDEDXpad; // 0-23 paddle dEdx |
126 |
TArrayF eZpad; // 0-23 paddle charge |
127 |
TArrayF eDEDXlayer; // 0-5 layer dEdx |
128 |
TArrayF eZlayer; // 0-5 layer charge |
129 |
TArrayF eDEDXplane; // 0-2 plane dEdx |
130 |
TArrayF eZplane; // 0-2 plane charge |
131 |
|
132 |
TArrayF INFOpmt; // 0-47 pmt status |
133 |
TArrayF INFOlayer; //0-5 layer status |
134 |
|
135 |
// parameters: |
136 |
TArrayF PMTsat; // 0-47 saturation parameters |
137 |
|
138 |
TArrayF TDx[48]; // 200 x 48 define an array of 200 elements per each pmt |
139 |
TArrayF TDy[48]; |
140 |
|
141 |
TArrayF parAtt[48]; // 48 x 6 |
142 |
TArrayF parPos[48]; // 48 x 4 |
143 |
TArrayF parDesatBB[48]; // 48 x 3 |
144 |
TArrayF parBBneg[48]; // 48 x 3 |
145 |
TArrayF parBBpos; // 48 x 1 |
146 |
|
147 |
double f_adcPC( float x ); |
148 |
double f_BB( TArrayF &p, float x ); |
149 |
double f_BB5B( float x ); |
150 |
double f_att( TArrayF &p, float x ) ; |
151 |
double f_att5B( float x ); |
152 |
double f_desatBB( TArrayF &p, float x ); |
153 |
double f_desatBB5B( float x ); |
154 |
double f_pos( TArrayF &p, float x ); |
155 |
double f_pos5B( float x ); |
156 |
float Get_adc_he( int id, float pl_x[6], float pl_y[6]); |
157 |
|
158 |
Bool_t conn[12]; |
159 |
|
160 |
UInt_t ts[12]; |
161 |
UInt_t te[12]; |
162 |
|
163 |
|
164 |
public: |
165 |
ToFdEdx(); // class constructor |
166 |
~ToFdEdx(){ Delete(); }; // class distructor |
167 |
// |
168 |
void Clear(Option_t *option=""); |
169 |
void Delete(Option_t *option="") { Clear(); } |
170 |
|
171 |
// void InitPar(const char *pardir); // init parameters |
172 |
void Define_PMTsat(); |
173 |
//void ReadParTD( Int_t ipmt, const char *fname ); |
174 |
|
175 |
void ReadParAtt( const char *fname ); |
176 |
void ReadParPos( const char *fname ); |
177 |
void ReadParBBneg( const char *fname ); |
178 |
void ReadParBBpos( const char *fname ); |
179 |
void ReadParDesatBB( const char *fname ); |
180 |
|
181 |
void CheckConnectors(UInt_t atime, GL_PARAM *glparam, TSQLServer *dbc); |
182 |
|
183 |
void Process( UInt_t atime, Float_t betamean, Float_t *xtr_tof, Float_t *ytr_tof, pamela::tof::TofEvent *tofl0 ); // |
184 |
void Print(Option_t *option=""); |
185 |
void PrintTD(); |
186 |
|
187 |
|
188 |
Float_t GetdEdx_pmt(Int_t ipmt) { return eDEDXpmt[ipmt]; } // 0-47 dEdx for each PMT for tracked events |
189 |
Float_t GetCharge_pmt(Int_t ipmt) {return eZpmt[ipmt];} // 0-47 Z for each PMT for tracked events |
190 |
Float_t GetdEdx_pad(Int_t ipad) {return eDEDXpad[ipad];} // 0-23 dEdx for each paddle for tracked events (no request of consistency between PMT's response when both on!) |
191 |
Float_t GetCharge_pad(Int_t ipad) {return eZpad[ipad];} // 0-23 Z for each paddle for tracked events (no request of consistency) |
192 |
Float_t GetdEdx_layer(Int_t ilay) {return eDEDXlayer[ilay];} // 0-5 dEdx for each layer for tracked events |
193 |
Float_t GetCharge_layer(Int_t ilay) {return eZlayer[ilay];} // 0-5 Z for each layer for tracked events |
194 |
Float_t GetdEdx_plane(Int_t ipl) {return eDEDXplane[ipl];} // 0-2 dEdx for each plane for tracked events |
195 |
Float_t GetCharge_plane(Int_t ipl) {return eZplane[ipl];} // 0-2 Z for each plane for tracked events N.B.: here there is a soft request of consistency between the two layers...to be discussed!! |
196 |
|
197 |
Float_t GetInfo_pmt(Int_t ipmt) {return INFOpmt[ipmt];} // 0-47 pmt status |
198 |
Float_t GetInfo_layer(Int_t ilay) {return INFOlayer[ilay];} // 0-5 layer status |
199 |
|
200 |
|
201 |
|
202 |
// |
203 |
// |
204 |
ToFdEdx* GetToFdEdx(){return this;}; |
205 |
|
206 |
|
207 |
|
208 |
|
209 |
ClassDef(ToFdEdx,1); |
210 |
}; |
211 |
|
212 |
|
213 |
/** |
214 |
* \brief Class which contains the tracker related variables |
215 |
* |
216 |
* We can use the ToF standalone to find hitted paddles, calculate beta, etc.. |
217 |
* These results are then stored with the "trkseqno" = -1. |
218 |
* If we use the track from the tracker, then the penetration points in the |
219 |
* scintillators are calculated, which defines the hitted paddles. For these paddles |
220 |
* we calculate then all the output. |
221 |
* Note: The artificial ADC values are stored as dEdx in the output, the dEdx will be |
222 |
* by definition = 1. However, the artificial TDC values are just used internally |
223 |
* and not stored in the output. But one can see in both cases which PMT has artificial |
224 |
* values using "adcflag" and "tdcflag". |
225 |
* Look in the ToFLevel2Ex.cxx example in the repository how to read the tracker related |
226 |
* variables. |
227 |
*/ |
228 |
class ToFTrkVar : public TObject { |
229 |
|
230 |
private: |
231 |
|
232 |
public: |
233 |
// |
234 |
Int_t trkseqno; ///< tracker sequ. number: -1=ToF standalone, 0=first Tracker track, ... |
235 |
// |
236 |
Int_t npmttdc; ///<number of the TDC measurements used to evaluate beta |
237 |
TArrayI pmttdc; ///<contains the ID (0..47) for the PMT used to evaluate beta |
238 |
TArrayI tdcflag; ///<flag for artificial TDC, "0" if normal TDC value |
239 |
|
240 |
/** |
241 |
* \brief beta, 12 measurements for the 12 combinations, beta[13] is modified weighted mean |
242 |
* |
243 |
* The 12 measurements are S11-S31, S11-S32, S12-S31, S12-S32, and then analogue for |
244 |
* S2-S3 and S1-S2. |
245 |
* The calculation of beta[13] is now modified: |
246 |
* We check the individual weights for artificial TDC values, then calculate |
247 |
* am mean beta for the first time. In a second step we loop again through |
248 |
* the single measurements, checking for the residual from the mean |
249 |
* The cut on the residual reject measurements > "x"-sigma. A chi2 value is |
250 |
* calculated, furthermore a "quality" value by adding the weights which |
251 |
* are finally used. If all measurements are taken, "quality" will be = 505. |
252 |
* A chi2 cut around 3-4 and a quality-cut > 400 is needed for clean beta |
253 |
* The Level2 beta[12] which is derived in the fortran routines uses: 10.,200.,20. |
254 |
* This is not a very high quality measurement. One can re-calculate a new beta[13] |
255 |
* using the L2-method "CalcBeta" |
256 |
*/ |
257 |
Float_t beta[13]; |
258 |
// |
259 |
Int_t npmtadc; ///<number of the ADC measurements used for dEdx evaluation |
260 |
TArrayI pmtadc; ///<contains the ID (0..47) for the PMT used to evaluate dEdx |
261 |
TArrayI adcflag; ///<flag for artificial ADCs, "0" if normal ADC value |
262 |
TArrayF dedx; ///<energy loss for this PMT in mip |
263 |
// |
264 |
Float_t xtofpos[3]; ///<x-measurement using the TDC values and the calibration from S12, S21, S32 |
265 |
Float_t ytofpos[3]; ///<x-measurement using the TDC values and the calibration from S11, S22, S31 |
266 |
// |
267 |
Float_t xtr_tof[6]; ///<x-measurement in the ToF layers from tracker |
268 |
Float_t ytr_tof[6]; ///<x-measurement in the ToF layers from tracker |
269 |
// |
270 |
ToFTrkVar(); |
271 |
ToFTrkVar(const ToFTrkVar&); |
272 |
|
273 |
ToFTrkVar* GetToFTrkVar(){return this;}; |
274 |
void Clear(Option_t *t=""); |
275 |
|
276 |
ClassDef(ToFTrkVar,1); |
277 |
// |
278 |
}; |
279 |
|
280 |
/** |
281 |
* \brief Class to describe ToF LEVEL2 data |
282 |
* |
283 |
*/ |
284 |
|
285 |
class ToFLevel2 : public TObject { |
286 |
private: |
287 |
|
288 |
public: |
289 |
// |
290 |
TClonesArray *PMT; ///<class needed to store PMT hit informations |
291 |
TClonesArray *ToFTrk; ///<track related variable class |
292 |
Int_t tof_j_flag[6]; ///<number of hitted paddle(s) for each ToF layer: flag = flag + 2**(paddlenumber-1) |
293 |
// |
294 |
Int_t unpackError;///< zero if no error presente |
295 |
Int_t default_calib; ///< one if the default calibration has been used to process the data, zero otherwise |
296 |
// |
297 |
Float_t GetdEdx(Int_t notrack, Int_t plane, Int_t adcfl); // gf Apr 07 |
298 |
|
299 |
Float_t CalcBeta(Int_t notrack, Float_t resmax, Float_t qualitycut, Float_t chi2cut); // wm feb 08 |
300 |
|
301 |
// |
302 |
// Float_t CalcBeta(Int_t notrack, Float_t resmax, Float_t chi2cut, Float_t qualitycut); // wm feb 08 |
303 |
// |
304 |
// methods to make life simplier during the analysis, returns a pointer to the ToFTrkVar class containing track related variables |
305 |
// |
306 |
Int_t ntrk(){return ToFTrk->GetEntries();}; |
307 |
Int_t npmt(){return PMT->GetEntries();}; |
308 |
|
309 |
// |
310 |
void GetLevel2Struct(cToFLevel2 *) const; |
311 |
// |
312 |
ToFTrkVar *GetToFTrkVar(Int_t notrack); |
313 |
ToFPMT *GetToFPMT(Int_t nohit); |
314 |
Int_t GetPMTid(Int_t gg, Int_t hh); |
315 |
TString GetPMTName(Int_t ind); |
316 |
|
317 |
Int_t GetPlaneIndex(Int_t pmt_id); |
318 |
void GetMatrix(Int_t notrack, Float_t adc[4][12], Float_t tdc[4][12]); |
319 |
void GetPMTIndex(Int_t pmt_id, Int_t &gg, Int_t &hh); |
320 |
|
321 |
// gf Apr 07 |
322 |
void GetdEdxPaddle(Int_t notrack, Int_t paddleid, Int_t adcfl, Float_t &PadEdx, Int_t &SatWarning); // gf Apr 07 |
323 |
TString GetPMTName(Int_t ind, Int_t &iplane, Int_t &ipaddle,Int_t &ipmt); |
324 |
Int_t GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane); // gf Apr 07 |
325 |
Int_t GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane, Float_t margin); // wm jun 2008 |
326 |
void GetPMTPaddle(Int_t pmt_id, Int_t &plane, Int_t &paddle); // gf Apr 07 |
327 |
void GetPaddlePMT(Int_t paddle, Int_t &pmtleft, Int_t &pmtright); // gf Apr 07 |
328 |
void GetPaddleGeometry(Int_t plane, Int_t paddle, Float_t &xleft, Float_t &xright, Float_t &yleft, Float_t &yright); // gf Apr 07 |
329 |
Int_t GetPaddleid(Int_t plane, Int_t paddle); |
330 |
void GetPaddlePlane(Int_t padid, Int_t &plane, Int_t &paddle); |
331 |
Int_t GetNPaddle(Int_t plane); |
332 |
// |
333 |
// |
334 |
// |
335 |
Int_t Process(TrkLevel2 *trk, TrigLevel2 *trg, GL_RUN *run, OrbitalInfo *orb, Bool_t force); // Emiliano |
336 |
|
337 |
// |
338 |
// constructor |
339 |
// |
340 |
ToFLevel2(); |
341 |
~ToFLevel2(){Delete();}; //ELENA |
342 |
void Delete(Option_t *t=""); //ELENA |
343 |
void Set();//ELENA |
344 |
// |
345 |
// |
346 |
ToFLevel2* GetToFLevel2(){return this;}; |
347 |
|
348 |
/** |
349 |
* Method to get the z-position of the 6 TOF layers from the plane ID |
350 |
* @param plane_id Plane ID (11 12 21 22 31 32) |
351 |
*/ |
352 |
Float_t GetZTOF(Int_t plane_id){ |
353 |
switch(plane_id){ |
354 |
case 11: return ZTOF11; |
355 |
case 12: return ZTOF12; |
356 |
case 21: return ZTOF21; |
357 |
case 22: return ZTOF22; |
358 |
case 31: return ZTOF31; |
359 |
case 32: return ZTOF32; |
360 |
default: return 0.; |
361 |
}; |
362 |
}; |
363 |
|
364 |
// |
365 |
// Paddles position |
366 |
// |
367 |
/* |
368 |
S11 8 paddles 33.0 x 5.1 cm |
369 |
S12 6 paddles 40.8 x 5.5 cm |
370 |
S21 2 paddles 18.0 x 7.5 cm |
371 |
S22 2 paddles 15.0 x 9.0 cm |
372 |
S31 3 paddles 15.0 x 6.0 cm |
373 |
S32 3 paddles 18.0 x 5.0 cm |
374 |
*/ |
375 |
|
376 |
Int_t GetToFPlaneID(Int_t ip); |
377 |
Int_t GetToFPlaneIndex(Int_t plane_id); |
378 |
Bool_t HitPaddle(Int_t ,Int_t); |
379 |
Int_t GetNHitPaddles(Int_t plane); |
380 |
void Clear(Option_t *t=""); |
381 |
// |
382 |
ClassDef(ToFLevel2,4); |
383 |
}; |
384 |
|
385 |
#endif |
386 |
|