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

Annotation of /PamelaDigitizer/Digitizer.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations) (download)
Wed Dec 5 13:02:50 2007 UTC (16 years, 11 months ago) by silvio
Branch: MAIN
CVS Tags: v2r01
Changes since 1.3: +16 -4 lines
File MIME type: text/plain
Changes in AC, TRG, RunHeader/Trailer, Makefile

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

  ViewVC Help
Powered by ViewVC 1.1.23