/[PAMELA software]/PamelaDigitizer/Digitizer.h
ViewVC logotype

Contents of /PamelaDigitizer/Digitizer.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (show annotations) (download)
Fri Feb 20 10:22:18 2009 UTC (15 years, 9 months ago) by mocchiut
Branch: MAIN
Changes since 1.9: +2 -2 lines
File MIME type: text/plain
Wrong RunHeader and RunTrailer lengths lead to crash PamLevel2 with new software, fixed

1 #ifndef DIGITIZER_H
2 #define DIGITIZER_H
3
4 #include <iostream>
5 #include <fstream>
6
7
8 #include <stdlib.h>
9 #include <string.h>
10 #include <ctype.h>
11
12 #include "Riostream.h"
13 #include "TFile.h"
14 #include "TDirectory.h"
15 #include "TTree.h"
16 #include "TLeafI.h"
17 #include "TH1.h"
18 #include "TH2.h"
19 #include "TF1.h"
20 #include "TMath.h"
21 #include "TSQLServer.h"
22 #include "TGraph.h"
23 #include "GLTables.h"
24 #include "TSystem.h"
25 #include "TRandom.h"
26
27 #include "CRC.h"
28 #include <CalibCalPedEvent.h>
29 #include "CalibTrk1Event.h"
30 #include "CalibTrk2Event.h"
31
32 class Digitizer{
33
34 protected:
35
36 // in and output data members
37
38 TTree* fhBookTree;
39 ofstream fOutputfile;
40 int *nspe;
41 int *ntof;
42 int *ncat;
43 int *ncas;
44 int *ncar;
45 int *ncal;
46 int *nnd;
47 int *nstr;
48
49 static const int fPSCUbuffer = 8;
50 static const int fTRIGGERbuffer = 152; //(bytes)
51 static const int fTOFbuffer = 276; //(bytes)
52 static const int fRunHeaderbuffer = 37; // 37 not 27
53 static const int fRunTrailerbuffer = 25; // 25 not 17
54 static const int fACbuffer = 128;
55 static const int fNDbuffer = 6;
56 static const int fS4buffer = 3;
57 static const int fPADbuffer = 64; // changed from 32!
58 static const int fCALObuffer = 10000;
59 static const float fCALOGeV2MIPratio = 0.0001059994;
60
61 static const int fDummybuffer = 64;
62
63 // dimensions of vectors and buffer, parameter for tracker
64 static const int fTRACKbuffer = 50000; // to be optimized
65 static const int fNviews = 12;
66 static const int fNstrips_view = 3072;
67 static const int fNladder=3;
68 static const int fNstrips_ladder = 1024;
69 static const int fCutzop= 4;
70 static const int fCutclu= 7;
71 static const int fNclst = 2;
72
73
74 static const float fAvePedex = 1200.; // to be adjusted
75 static const float fSigmaPedex = 1.; // to be adjusted
76 static const float fAveSigmax = 4.3; // to be adjusted
77 static const float fSigmaSigmax =0.1; // to be adjusted
78 static const float fAvePedey = 2800.; // to be adjusted
79 static const float fSigmaPedey = 1.; // to be adjusted
80 static const float fAveSigmay = 8.; // to be adjusted
81 static const float fSigmaSigmay =0.1; // to be adjusted
82 static const float fSigmaCommon = 25.; // to be adjusted
83
84
85 // end dimensions of vectors and buffer, parameter for tracker
86
87 UShort_t fDataPSCU[fPSCUbuffer];
88 UInt_t fCounter;
89 UInt_t fCounterPhys;
90 UInt_t fOBT;
91
92 UShort_t fDataPadding[fPADbuffer];
93 UInt_t fPadding;
94
95 UShort_t fDataRunHeader[fRunHeaderbuffer];
96 UShort_t fDataRunTrailer[fRunTrailerbuffer];
97
98 UChar_t fDataTrigger[fTRIGGERbuffer];
99 UChar_t fDataTof[fTOFbuffer];
100
101 UShort_t fDataAC[fACbuffer];
102 UShort_t fDataND[fNDbuffer];
103 UShort_t fDataS4[fS4buffer];
104 UShort_t fDataDummy[fDummybuffer];
105
106 UShort_t fDataCALO[fCALObuffer];
107 UShort_t fSecCalo[4];
108 UShort_t fSecCALOLength[4];
109 UShort_t fCALOlength;
110 UShort_t fModCalo;
111 Float_t fCalomip[2][22][96]; // ADC to MIP conversion values
112 Float_t fcalped[4][11][96]; // pedestals
113 Float_t fcalgood[4][11][96]; // used or not in the common noise calculation
114 Float_t fcalthr[4][11][6]; // thresholds
115 Float_t fcalrms[4][11][96]; // rms
116 Float_t fcalbase[4][11][6]; // baselines (common noise) during calibration
117 Float_t fcalvar[4][11][6]; // variance
118 Float_t fcstwerr[4]; // status word
119 Float_t fcperror[4]; // unpacking error flag
120 UInt_t fGivenCaloCalib;
121
122 char* fFilename;
123 UInt_t fLen;
124
125
126
127 // vectors, buffer, and variables for tracker
128 UShort_t fDataTrack[fTRACKbuffer];
129 UInt_t fTracklength; // Actual length of buffer
130 Float_t fPedeTrack[fNviews][fNstrips_view];
131 Float_t fSigmaTrack[fNviews][fNstrips_view];
132 // UShort_t fBadTrack[fNviews][fNstrips_view];
133 Float_t fMipCor[fNladder][fNviews] ;
134 // end vectors, buffer, and variables for tracker
135
136
137
138 //
139 // db variables
140 //
141 TSQLServer *fDbc;
142 // Declaration of leave types
143 Int_t Irun;
144 Int_t Ievnt;
145 Int_t Ipa;
146 Float_t X0;
147 Float_t Y0;
148 Float_t Z0;
149 Float_t Theta;
150 Float_t Phi;
151 Float_t P0;
152 Int_t Nthtof;
153 UChar_t *Ipltof;
154 UChar_t *Ipaddle;
155 // UChar_t *Ipartof;//DPMJET
156 UShort_t *Ipartof;
157 Float_t *Xintof;
158 Float_t *Yintof;
159 Float_t *Zintof;
160 Float_t *Xouttof;
161 Float_t *Youttof;
162 Float_t *Zouttof;
163 Float_t *Ereltof;
164 Float_t *Timetof;
165 Float_t *Pathtof;
166 Float_t *P0tof;
167 Int_t Nthcat;
168 UChar_t *Iparcat;
169 UChar_t *Icat;
170 Float_t *Xincat;
171 Float_t *Yincat;
172 Float_t *Zincat;
173 Float_t *Xoutcat;
174 Float_t *Youtcat;
175 Float_t *Zoutcat;
176 Float_t *Erelcat;
177 Float_t *Timecat;
178 Float_t *Pathcat;
179 Float_t *P0cat;
180 Int_t Nthcas;
181 UChar_t *Iparcas;
182 UChar_t *Icas;
183 Float_t *Xincas;
184 Float_t *Yincas;
185 Float_t *Zincas;
186 Float_t *Xoutcas;
187 Float_t *Youtcas;
188 Float_t *Zoutcas;
189 Float_t *Erelcas;
190 Float_t *Timecas;
191 Float_t *Pathcas;
192 Float_t *P0cas;
193 Int_t Nthspe;
194 // UChar_t *Iparspe;//DPMJET
195 // UShort_t *Iparspe;
196 UChar_t *Itrpb;
197 UChar_t *Itrsl;
198 UChar_t *Itspa;
199 Float_t *Xinspe;
200 Float_t *Yinspe;
201 Float_t *Zinspe;
202 Float_t *Xoutspe;
203 Float_t *Youtspe;
204 Float_t *Zoutspe;
205 Float_t *Xavspe;
206 Float_t *Yavspe;
207 Float_t *Zavspe;
208 Float_t *Erelspe;
209 Float_t *Pathspe;
210 Float_t *P0spe;
211 UChar_t *Nxmult;
212 UChar_t *Nymult;
213 Int_t Nstrpx;
214 UChar_t *Npstripx;
215 UChar_t *Ntstripx;
216 UShort_t *Istripx;
217 Float_t *Qstripx;
218 Float_t *Xstripx;
219 Int_t Nstrpy;
220 UChar_t *Npstripy;
221 UChar_t *Ntstripy;
222 UShort_t *Istripy;
223 Float_t *Qstripy;
224 Float_t *Ystripy;
225 Int_t Nthcali;
226 UChar_t Icaplane[4224];
227 UChar_t Icastrip[4224];
228 Int_t Icamod[4224];
229 Float_t Enestrip[4224];
230 Int_t Nthcal;
231 UChar_t *Icapl;
232 UChar_t *Icasi;
233 UChar_t *Icast;
234 Float_t *Xincal;
235 Float_t *Yincal;
236 Float_t *Zincal;
237 Float_t *Erelcal;
238 Int_t Nthnd;
239 UChar_t *Itubend;
240 UChar_t *Iparnd;
241 Float_t *Xinnd;
242 Float_t *Yinnd;
243 Float_t *Zinnd;
244 Float_t *Xoutnd;
245 Float_t *Youtnd;
246 Float_t *Zoutnd;
247 Float_t *Erelnd;
248 Float_t *Timend;
249 Float_t *Pathnd;
250 Float_t *P0nd;
251 Int_t Nthcard;
252 UChar_t *Iparcard;
253 UChar_t *Icard;
254 Float_t *Xincard;
255 Float_t *Yincard;
256 Float_t *Zincard;
257 Float_t *Xoutcard;
258 Float_t *Youtcard;
259 Float_t *Zoutcard;
260 Float_t *Erelcard;
261 Float_t *Timecard;
262 Float_t *Pathcard;
263 Float_t *P0card;
264
265 // List of branches
266 TBranch *b_Irun; //!
267 TBranch *b_Ievnt; //!
268 TBranch *b_Ipa; //!
269 TBranch *b_X0; //!
270 TBranch *b_Y0; //!
271 TBranch *b_Z0; //!
272 TBranch *b_Theta; //!
273 TBranch *b_Phi; //!
274 TBranch *b_P0; //!
275 TBranch *b_Nthtof; //!
276 TBranch *b_Ipltof; //!
277 TBranch *b_Ipaddle; //!
278 TBranch *b_Ipartof; //!
279 TBranch *b_Xintof; //!
280 TBranch *b_Yintof; //!
281 TBranch *b_Zintof; //!
282 TBranch *b_Xouttof; //!
283 TBranch *b_Youttof; //!
284 TBranch *b_Zouttof; //!
285 TBranch *b_Ereltof; //!
286 TBranch *b_Timetof; //!
287 TBranch *b_Pathtof; //!
288 TBranch *b_P0tof; //!
289 TBranch *b_Nthcat; //!
290 TBranch *b_Iparcat; //!
291 TBranch *b_Icat; //!
292 TBranch *b_Xincat; //!
293 TBranch *b_Yincat; //!
294 TBranch *b_Zincat; //!
295 TBranch *b_Xoutcat; //!
296 TBranch *b_Youtcat; //!
297 TBranch *b_Zoutcat; //!
298 TBranch *b_Erelcat; //!
299 TBranch *b_Timecat; //!
300 TBranch *b_Pathcat; //!
301 TBranch *b_P0cat; //!
302 TBranch *b_Nthcas; //!
303 TBranch *b_Iparcas; //!
304 TBranch *b_Icas; //!
305 TBranch *b_Xincas; //!
306 TBranch *b_Yincas; //!
307 TBranch *b_Zincas; //!
308 TBranch *b_Xoutcas; //!
309 TBranch *b_Youtcas; //!
310 TBranch *b_Zoutcas; //!
311 TBranch *b_Erelcas; //!
312 TBranch *b_Timecas; //!
313 TBranch *b_Pathcas; //!
314 TBranch *b_P0cas; //!
315 TBranch *b_Nthspe; //!
316 TBranch *b_Iparspe; //!
317 TBranch *b_Itrpb; //!
318 TBranch *b_Itrsl; //!
319 TBranch *b_Itspa; //!
320 TBranch *b_Xinspe; //!
321 TBranch *b_Yinspe; //!
322 TBranch *b_Zinspe; //!
323 TBranch *b_Xoutspe; //!
324 TBranch *b_Youtspe; //!
325 TBranch *b_Zoutspe; //!
326 TBranch *b_Xavspe; //!
327 TBranch *b_Yavspe; //!
328 TBranch *b_Zavspe; //!
329 TBranch *b_Erelspe; //!
330 TBranch *b_Pathspe; //!
331 TBranch *b_P0spe; //!
332 TBranch *b_Nxmult; //!
333 TBranch *b_Nymult; //!
334 TBranch *b_Nstrpx; //!
335 TBranch *b_Npstripx; //!
336 TBranch *b_Ntstripx; //!
337 TBranch *b_Istripx; //!
338 TBranch *b_Qstripx; //!
339 TBranch *b_Xstripx; //!
340 TBranch *b_Nstrpy; //!
341 TBranch *b_Npstripy; //!
342 TBranch *b_Ntstripy; //!
343 TBranch *b_Istripy; //!
344 TBranch *b_Qstripy; //!
345 TBranch *b_Ystripy; //!
346 TBranch *b_Nthcali; //!
347 TBranch *b_Icaplane; //!
348 TBranch *b_Icastrip; //!
349 TBranch *b_Icamod; //!
350 TBranch *b_Enestrip; //!
351 TBranch *b_Nthcal; //!
352 TBranch *b_Icapl; //!
353 TBranch *b_Icasi; //!
354 TBranch *b_Icast; //!
355 TBranch *b_Xincal; //!
356 TBranch *b_Yincal; //!
357 TBranch *b_Zincal; //!
358 TBranch *b_Erelcal; //!
359 TBranch *b_Nthnd; //!
360 TBranch *b_Itubend; //!
361 TBranch *b_Iparnd; //!
362 TBranch *b_Xinnd; //!
363 TBranch *b_Yinnd; //!
364 TBranch *b_Zinnd; //!
365 TBranch *b_Xoutnd; //!
366 TBranch *b_Youtnd; //!
367 TBranch *b_Zoutnd; //!
368 TBranch *b_Erelnd; //!
369 TBranch *b_Timend; //!
370 TBranch *b_Pathnd; //!
371 TBranch *b_P0nd; //!
372 TBranch *b_Nthcard; //!
373 TBranch *b_Iparcard; //!
374 TBranch *b_Icard; //!
375 TBranch *b_Xincard; //!
376 TBranch *b_Yincard; //!
377 TBranch *b_Zincard; //!
378 TBranch *b_Xoutcard; //!
379 TBranch *b_Youtcard; //!
380 TBranch *b_Zoutcard; //!
381 TBranch *b_Erelcard; //!
382 TBranch *b_Timecard; //!
383 TBranch *b_Pathcard; //!
384 TBranch *b_P0card; //!
385 //
386 TF1 *attenAC;
387 public:
388
389 Digitizer(TTree*,char*&,int,int,int,int,int,int,int,int); // constructor
390
391 void Close();
392 void SetTree(TTree *tree) {fhBookTree = tree;};
393 void Loop(); // does the looping over events
394
395 void DigitizePSCU(UInt_t, UChar_t, UShort_t*); // digitizes the CPU header
396 void AddPadding();
397 void DigitizeRunHeader();
398 void DigitizeRunTrailer();
399 // void DigitizeTRIGGER(); // SO nov'07: included in DigitizeTOF
400 void DigitizeTOF(int np,float *atte1,float *atte2,float *lambda1,float *lambda2); // digitizes the tof
401 void LoadTOFCalib(int np,float *atte1,float *atte2,float *lambda1,float *lambda2); //load TOF calibration
402 void DigitizeAC(); // digitizes the anti-counter
403 void DigitizeND(); // digitizes the ND
404 void DigitizeS4(); // digitizes the S4
405 void DigitizeCALO(); // digitizes the calorimeter
406 void DigitizeCALOCALIB(); // digitizes the calorimeter calibration
407 void DigitizeCALORAW(); // digitizes the calorimeter
408 void DigitizeCALOCOMPRESS(); // digitizes the calorimeter
409 void DigitizeCALOFULL(); // digitizes the calorimeter
410
411 Float_t GetCALOen(Int_t sec, Int_t plane, Int_t strip); // retrieve calorimeter strip energy from the simulation
412 void ClearCaloCalib(Int_t s); // clear calorimeter calibration variables for section s
413 Int_t CaloLoadCalib(Int_t s,TString fcalname, UInt_t calibno); // load calorimeter calibration variables for section s from file fcalname entry calibno
414 void CaloLoadCalib();
415
416 void DigitizeDummy(); // digitizes the dummy detector
417
418 // ToF methods:
419 UChar_t EvaluateCrcTof(UChar_t*);
420 void Paddle2Pmt(Int_t, Int_t, Int_t*, Int_t*);
421 //void Paddle2Pmt(Int_t, Int_t, Int_t &pmtleft, Int_t &pmtright);
422 UChar_t Bin2GrayTof(UChar_t, UChar_t);
423 void Crc8Tof(UChar_t*, UChar_t*);
424
425 UChar_t EvaluateCrcTrigger(UChar_t*, Int_t);
426
427 UShort_t* GetDataAC(){return(fDataAC);}; // retrieve AC data (not used right now)
428
429 UShort_t* GetDataCALO(){return(fDataCALO);}; // retrieve AC data (not used right now)
430
431 // methods for Tracker
432 void DigitizeTrack(); // digitizes the Tracker data
433 void DigitizeTrackCalib(Int_t ii); // digitizes the Tracker calibration (x view or y view)
434 void WriteTrackCalib(); // writes Tracker calibration to file
435 void ClearTrackCalib(); // clear tracker calibration
436 void LoadTrackCalib(); // load in memmory tracker calibration
437 void CompressTrackData(Float_t AdcTrack[fNviews][fNstrips_view]); // Compress and Digitize data of one Ladder in turn
438 void LoadMipCor(); // Load the strip calibration in memory
439 Float_t SaturationTrackx(Float_t ADC); // Saturation simulation
440 Float_t SaturationTracky(Float_t ADC); // Saturation simulation
441 // end methods for Tracker
442
443 void WriteRunHeader();
444 void WriteRunTrailer();
445 void WriteData(); // writes data to file
446 void ReadData();
447
448 //
449
450 };
451
452 #endif /* DIGITIZER_H */
453
454
455

  ViewVC Help
Powered by ViewVC 1.1.23