/[PAMELA software]/DarthVader/ToFLevel2/inc/ToFLevel2.h
ViewVC logotype

Contents of /DarthVader/ToFLevel2/inc/ToFLevel2.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.30 - (show annotations) (download)
Thu Apr 12 12:27:07 2012 UTC (12 years, 7 months ago) by mocchiut
Branch: MAIN
Changes since 1.29: +16 -4 lines
File MIME type: text/plain
New TrigLevel2, ToFLevel2, OrbitalInfo classes, new order in DV processing (trigger first), ToF bugs fixed, new tof calibration, new variables in ToF and OrbitalInfo

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

  ViewVC Help
Powered by ViewVC 1.1.23