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

Contents of /PamelaDigitizer/Digitizer.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13 - (show annotations) (download)
Fri Oct 16 09:15:51 2009 UTC (15 years, 1 month ago) by pizzolot
Branch: MAIN
Changes since 1.12: +4 -2 lines
File MIME type: text/plain
calorimeter compress mode implemented ; input parameter modified

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

  ViewVC Help
Powered by ViewVC 1.1.23