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

Annotation of /PamelaDigitizer/Digitizer.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Fri Sep 28 10:46:23 2007 UTC (17 years, 2 months ago) by orsi
Branch: MAIN
Changes since 1.1: +6 -3 lines
File MIME type: text/plain
TOF TDC added; TRK improved; bug fixes

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

  ViewVC Help
Powered by ViewVC 1.1.23