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