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

Annotation of /PamelaDigitizer/Digitizer.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (hide annotations) (download)
Sun Jun 8 06:33:45 2008 UTC (16 years, 5 months ago) by pamelats
Branch: MAIN
CVS Tags: v3r02
Changes since 1.7: +5 -5 lines
File MIME type: text/plain
*** empty log message ***

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

  ViewVC Help
Powered by ViewVC 1.1.23