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

Annotation of /PamelaDigitizer/Digitizer.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.11 - (hide annotations) (download)
Tue May 5 14:17:46 2009 UTC (15 years, 7 months ago) by pamelats
Branch: MAIN
CVS Tags: v3r05
Changes since 1.10: +0 -10 lines
File MIME type: text/plain
Version of digitizer compatible with chewbacca

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

  ViewVC Help
Powered by ViewVC 1.1.23