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

Annotation of /PamelaDigitizer/Digitizer.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Thu Sep 13 11:00:53 2007 UTC (17 years, 2 months ago) by silvio
Branch: MAIN
Branch point for: PamelaDigitizer/
File MIME type: text/plain
Initial revision

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

  ViewVC Help
Powered by ViewVC 1.1.23