1 |
#ifndef DIGITIZER_H |
#ifndef DIGITIZER_H |
2 |
#define DIGITIZER_H |
#define DIGITIZER_H |
3 |
|
|
4 |
#include <iostream> |
#include <iostream> |
5 |
#include <fstream> |
#include <fstream> |
6 |
|
|
16 |
#include "TLeafI.h" |
#include "TLeafI.h" |
17 |
#include "TH1.h" |
#include "TH1.h" |
18 |
#include "TH2.h" |
#include "TH2.h" |
19 |
|
#include "TF1.h" |
20 |
#include "TMath.h" |
#include "TMath.h" |
21 |
#include "TSQLServer.h" |
#include "TSQLServer.h" |
22 |
// |
#include "TGraph.h" |
23 |
|
#include "GLTables.h" |
24 |
|
#include "TSystem.h" |
25 |
|
#include "TRandom.h" |
26 |
|
|
27 |
#include "CRC.h" |
#include "CRC.h" |
28 |
|
#include <CalibCalPedEvent.h> |
29 |
|
#include "CalibTrk1Event.h" |
30 |
|
#include "CalibTrk2Event.h" |
31 |
|
|
32 |
class Digitizer{ |
class Digitizer{ |
33 |
|
|
|
|
|
34 |
protected: |
protected: |
35 |
|
|
36 |
// in and output data members |
// in and output data members |
37 |
|
|
38 |
TTree* fhBookTree; |
TTree* fhBookTree; |
39 |
ofstream fOutputfile; |
ofstream fOutputfile; |
40 |
|
int *nspe; |
41 |
|
int *ntof; |
42 |
|
int *ncat; |
43 |
|
int *ncas; |
44 |
|
int *ncar; |
45 |
|
int *ncal; |
46 |
|
int *nnd; |
47 |
|
int *nstr; |
48 |
|
|
49 |
static const int fPSCUbuffer = 8; |
static const int fPSCUbuffer = 8; |
50 |
static const int fTRIGGERbuffer = 153; //(bytes) |
static const int fTRIGGERbuffer = 152; //(bytes) |
51 |
static const int fTOFbuffer = 276; //(bytes) |
static const int fTOFbuffer = 276; //(bytes) |
52 |
|
static const int fRunHeaderbuffer = 37; // 37 not 27 |
53 |
|
static const int fRunTrailerbuffer = 25; // 25 not 17 |
54 |
static const int fACbuffer = 128; |
static const int fACbuffer = 128; |
55 |
static const int fNDbuffer = 4; |
static const int fNDbuffer = 6; |
56 |
|
static const int fS4buffer = 3; |
57 |
static const int fPADbuffer = 64; // changed from 32! |
static const int fPADbuffer = 64; // changed from 32! |
58 |
static const int fCALObuffer = 10000; |
static const int fCALObuffer = 10000; |
59 |
static const float fCALOGeV2MIPratio = 0.0001059994; |
static const float fCALOGeV2MIPratio = 0.0001059994; |
80 |
static const float fAveSigmay = 8.; // to be adjusted |
static const float fAveSigmay = 8.; // to be adjusted |
81 |
static const float fSigmaSigmay =0.1; // to be adjusted |
static const float fSigmaSigmay =0.1; // to be adjusted |
82 |
static const float fSigmaCommon = 25.; // to be adjusted |
static const float fSigmaCommon = 25.; // to be adjusted |
|
static const float fMipCor = 1.; // to be adjusted |
|
83 |
|
|
84 |
|
|
85 |
// end dimensions of vectors and buffer, parameter for tracker |
// end dimensions of vectors and buffer, parameter for tracker |
86 |
|
|
87 |
UShort_t fDataPSCU[fPSCUbuffer]; |
UShort_t fDataPSCU[fPSCUbuffer]; |
88 |
UInt_t fCounter; |
UInt_t fCounter; |
89 |
|
UInt_t fCounterPhys; |
90 |
UInt_t fOBT; |
UInt_t fOBT; |
91 |
|
|
92 |
UShort_t fDataPadding[fPADbuffer]; |
UShort_t fDataPadding[fPADbuffer]; |
93 |
UInt_t fPadding; |
UInt_t fPadding; |
94 |
|
|
95 |
UChar_t fDataTrigger[fTRIGGERbuffer]; |
UShort_t fDataRunHeader[fRunHeaderbuffer]; |
96 |
|
UShort_t fDataRunTrailer[fRunTrailerbuffer]; |
97 |
|
|
98 |
|
UChar_t fDataTrigger[fTRIGGERbuffer]; |
99 |
UChar_t fDataTof[fTOFbuffer]; |
UChar_t fDataTof[fTOFbuffer]; |
100 |
|
|
101 |
UShort_t fDataAC[fACbuffer]; |
UShort_t fDataAC[fACbuffer]; |
102 |
UShort_t fDataND[fACbuffer]; |
UShort_t fDataND[fNDbuffer]; |
103 |
|
UShort_t fDataS4[fS4buffer]; |
104 |
UShort_t fDataDummy[fDummybuffer]; |
UShort_t fDataDummy[fDummybuffer]; |
105 |
|
|
106 |
UShort_t fDataCALO[fCALObuffer]; |
UShort_t fDataCALO[fCALObuffer]; |
121 |
|
|
122 |
char* fFilename; |
char* fFilename; |
123 |
UInt_t fLen; |
UInt_t fLen; |
124 |
|
|
125 |
|
|
126 |
|
|
127 |
// vectors, buffer, and variables for tracker |
// vectors, buffer, and variables for tracker |
129 |
UInt_t fTracklength; // Actual length of buffer |
UInt_t fTracklength; // Actual length of buffer |
130 |
Float_t fPedeTrack[fNviews][fNstrips_view]; |
Float_t fPedeTrack[fNviews][fNstrips_view]; |
131 |
Float_t fSigmaTrack[fNviews][fNstrips_view]; |
Float_t fSigmaTrack[fNviews][fNstrips_view]; |
132 |
|
// UShort_t fBadTrack[fNviews][fNstrips_view]; |
133 |
|
Float_t fMipCor[fNladder][fNviews] ; |
134 |
// end vectors, buffer, and variables for tracker |
// end vectors, buffer, and variables for tracker |
135 |
|
|
136 |
|
|
150 |
Float_t Phi; |
Float_t Phi; |
151 |
Float_t P0; |
Float_t P0; |
152 |
Int_t Nthtof; |
Int_t Nthtof; |
153 |
UChar_t Ipltof[100]; //[Nthtof] |
UChar_t *Ipltof; |
154 |
UChar_t Ipaddle[100]; //[Nthtof] |
UChar_t *Ipaddle; |
155 |
UChar_t Ipartof[100]; //[Nthtof] |
// UChar_t *Ipartof;//DPMJET |
156 |
Float_t Xintof[100]; //[Nthtof] |
UShort_t *Ipartof; |
157 |
Float_t Yintof[100]; //[Nthtof] |
Float_t *Xintof; |
158 |
Float_t Zintof[100]; //[Nthtof] |
Float_t *Yintof; |
159 |
Float_t Xouttof[100]; //[Nthtof] |
Float_t *Zintof; |
160 |
Float_t Youttof[100]; //[Nthtof] |
Float_t *Xouttof; |
161 |
Float_t Zouttof[100]; //[Nthtof] |
Float_t *Youttof; |
162 |
Float_t Ereltof[100]; //[Nthtof] |
Float_t *Zouttof; |
163 |
Float_t Timetof[100]; //[Nthtof] |
Float_t *Ereltof; |
164 |
Float_t Pathtof[100]; //[Nthtof] |
Float_t *Timetof; |
165 |
Float_t P0tof[100]; //[Nthtof] |
Float_t *Pathtof; |
166 |
|
Float_t *P0tof; |
167 |
Int_t Nthcat; |
Int_t Nthcat; |
168 |
UChar_t Iparcat[50]; //[Nthcat] |
UChar_t *Iparcat; |
169 |
UChar_t Icat[50]; //[Nthcat] |
UChar_t *Icat; |
170 |
Float_t Xincat[50]; //[Nthcat] |
Float_t *Xincat; |
171 |
Float_t Yincat[50]; //[Nthcat] |
Float_t *Yincat; |
172 |
Float_t Zincat[50]; //[Nthcat] |
Float_t *Zincat; |
173 |
Float_t Xoutcat[50]; //[Nthcat] |
Float_t *Xoutcat; |
174 |
Float_t Youtcat[50]; //[Nthcat] |
Float_t *Youtcat; |
175 |
Float_t Zoutcat[50]; //[Nthcat] |
Float_t *Zoutcat; |
176 |
Float_t Erelcat[50]; //[Nthcat] |
Float_t *Erelcat; |
177 |
Float_t Timecat[50]; //[Nthcat] |
Float_t *Timecat; |
178 |
Float_t Pathcat[50]; //[Nthcat] |
Float_t *Pathcat; |
179 |
Float_t P0cat[50]; //[Nthcat] |
Float_t *P0cat; |
180 |
Int_t Nthcas; |
Int_t Nthcas; |
181 |
UChar_t Iparcas[50]; //[Nthcas] |
UChar_t *Iparcas; |
182 |
UChar_t Icas[50]; //[Nthcas] |
UChar_t *Icas; |
183 |
Float_t Xincas[50]; //[Nthcas] |
Float_t *Xincas; |
184 |
Float_t Yincas[50]; //[Nthcas] |
Float_t *Yincas; |
185 |
Float_t Zincas[50]; //[Nthcas] |
Float_t *Zincas; |
186 |
Float_t Xoutcas[50]; //[Nthcas] |
Float_t *Xoutcas; |
187 |
Float_t Youtcas[50]; //[Nthcas] |
Float_t *Youtcas; |
188 |
Float_t Zoutcas[50]; //[Nthcas] |
Float_t *Zoutcas; |
189 |
Float_t Erelcas[50]; //[Nthcas] |
Float_t *Erelcas; |
190 |
Float_t Timecas[50]; //[Nthcas] |
Float_t *Timecas; |
191 |
Float_t Pathcas[50]; //[Nthcas] |
Float_t *Pathcas; |
192 |
Float_t P0cas[50]; //[Nthcas] |
Float_t *P0cas; |
193 |
Int_t Nthspe; |
Int_t Nthspe; |
194 |
UChar_t Iparspe[100]; //[Nthspe] |
// UChar_t *Iparspe;//DPMJET |
195 |
UChar_t Itrpb[100]; //[Nthspe] |
// UShort_t *Iparspe; |
196 |
UChar_t Itrsl[100]; //[Nthspe] |
UChar_t *Itrpb; |
197 |
UChar_t Itspa[100]; //[Nthspe] |
UChar_t *Itrsl; |
198 |
Float_t Xinspe[100]; //[Nthspe] |
UChar_t *Itspa; |
199 |
Float_t Yinspe[100]; //[Nthspe] |
Float_t *Xinspe; |
200 |
Float_t Zinspe[100]; //[Nthspe] |
Float_t *Yinspe; |
201 |
Float_t Xoutspe[100]; //[Nthspe] |
Float_t *Zinspe; |
202 |
Float_t Youtspe[100]; //[Nthspe] |
Float_t *Xoutspe; |
203 |
Float_t Zoutspe[100]; //[Nthspe] |
Float_t *Youtspe; |
204 |
Float_t Xavspe[100]; //[Nthspe] |
Float_t *Zoutspe; |
205 |
Float_t Yavspe[100]; //[Nthspe] |
Float_t *Xavspe; |
206 |
Float_t Zavspe[100]; //[Nthspe] |
Float_t *Yavspe; |
207 |
Float_t Erelspe[100]; //[Nthspe] |
Float_t *Zavspe; |
208 |
Float_t Pathspe[100]; //[Nthspe] |
Float_t *Erelspe; |
209 |
Float_t P0spe[100]; //[Nthspe] |
Float_t *Pathspe; |
210 |
UChar_t Nxmult[100]; //[Nthspe] |
Float_t *P0spe; |
211 |
UChar_t Nymult[100]; //[Nthspe] |
UChar_t *Nxmult; |
212 |
|
UChar_t *Nymult; |
213 |
Int_t Nstrpx; |
Int_t Nstrpx; |
214 |
UChar_t Npstripx[1000]; //[Nstrpx] |
UChar_t *Npstripx; |
215 |
UChar_t Ntstripx[1000]; //[Nstrpx] |
UChar_t *Ntstripx; |
216 |
UShort_t Istripx[1000]; //[Nstrpx] |
UShort_t *Istripx; |
217 |
//UInt_t Istripx[1000]; //[Nstrpx] |
Float_t *Qstripx; |
218 |
Float_t Qstripx[1000]; //[Nstrpx] |
Float_t *Xstripx; |
|
Float_t Xstripx[1000]; //[Nstrpx] |
|
219 |
Int_t Nstrpy; |
Int_t Nstrpy; |
220 |
UChar_t Npstripy[1000]; //[Nstrpy] |
UChar_t *Npstripy; |
221 |
UChar_t Ntstripy[1000]; //[Nstrpy] |
UChar_t *Ntstripy; |
222 |
UShort_t Istripy[1000]; //[Nstrpy] |
UShort_t *Istripy; |
223 |
//UInt_t Istripy[1000]; //[Nstrpy] |
Float_t *Qstripy; |
224 |
Float_t Qstripy[1000]; //[Nstrpy] |
Float_t *Ystripy; |
|
Float_t Ystripy[1000]; //[Nstrpy] |
|
225 |
Int_t Nthcali; |
Int_t Nthcali; |
226 |
UChar_t Icaplane[4224]; //[Nthcali] |
UChar_t Icaplane[4224]; |
227 |
UChar_t Icastrip[4224]; //[Nthcali] |
UChar_t Icastrip[4224]; |
228 |
Int_t Icamod[4224]; //[Nthcali] |
Int_t Icamod[4224]; |
229 |
Float_t Enestrip[4224]; //[Nthcali] |
Float_t Enestrip[4224]; |
230 |
Int_t Nthcal; |
Int_t Nthcal; |
231 |
UChar_t Icapl[1000]; //[Nthcal] |
UChar_t *Icapl; |
232 |
UChar_t Icasi[1000]; //[Nthcal] |
UChar_t *Icasi; |
233 |
UChar_t Icast[1000]; //[Nthcal] |
UChar_t *Icast; |
234 |
Float_t Xincal[1000]; //[Nthcal] |
Float_t *Xincal; |
235 |
Float_t Yincal[1000]; //[Nthcal] |
Float_t *Yincal; |
236 |
Float_t Zincal[1000]; //[Nthcal] |
Float_t *Zincal; |
237 |
Float_t Erelcal[1000]; //[Nthcal] |
Float_t *Erelcal; |
238 |
Int_t Nthnd; |
Int_t Nthnd; |
239 |
UChar_t Itubend[200]; //[Nthnd] |
UChar_t *Itubend; |
240 |
UChar_t Iparnd[200]; //[Nthnd] |
UChar_t *Iparnd; |
241 |
Float_t Xinnd[200]; //[Nthnd] |
Float_t *Xinnd; |
242 |
Float_t Yinnd[200]; //[Nthnd] |
Float_t *Yinnd; |
243 |
Float_t Zinnd[200]; //[Nthnd] |
Float_t *Zinnd; |
244 |
Float_t Xoutnd[200]; //[Nthnd] |
Float_t *Xoutnd; |
245 |
Float_t Youtnd[200]; //[Nthnd] |
Float_t *Youtnd; |
246 |
Float_t Zoutnd[200]; //[Nthnd] |
Float_t *Zoutnd; |
247 |
Float_t Erelnd[200]; //[Nthnd] |
Float_t *Erelnd; |
248 |
Float_t Timend[200]; //[Nthnd] |
Float_t *Timend; |
249 |
Float_t Pathnd[200]; //[Nthnd] |
Float_t *Pathnd; |
250 |
Float_t P0nd[200]; //[Nthnd] |
Float_t *P0nd; |
251 |
Int_t Nthcard; |
Int_t Nthcard; |
252 |
UChar_t Iparcard[100]; //[Nthcard] |
UChar_t *Iparcard; |
253 |
UChar_t Icard[100]; //[Nthcard] |
UChar_t *Icard; |
254 |
Float_t Xincard[100]; //[Nthcard] |
Float_t *Xincard; |
255 |
Float_t Yincard[100]; //[Nthcard] |
Float_t *Yincard; |
256 |
Float_t Zincard[100]; //[Nthcard] |
Float_t *Zincard; |
257 |
Float_t Xoutcard[100]; //[Nthcard] |
Float_t *Xoutcard; |
258 |
Float_t Youtcard[100]; //[Nthcard] |
Float_t *Youtcard; |
259 |
Float_t Zoutcard[100]; //[Nthcard] |
Float_t *Zoutcard; |
260 |
Float_t Erelcard[100]; //[Nthcard] |
Float_t *Erelcard; |
261 |
Float_t Timecard[100]; //[Nthcard] |
Float_t *Timecard; |
262 |
Float_t Pathcard[100]; //[Nthcard] |
Float_t *Pathcard; |
263 |
Float_t P0card[100]; //[Nthcard] |
Float_t *P0card; |
264 |
|
|
265 |
// List of branches |
// List of branches |
266 |
TBranch *b_Irun; //! |
TBranch *b_Irun; //! |
383 |
TBranch *b_Pathcard; //! |
TBranch *b_Pathcard; //! |
384 |
TBranch *b_P0card; //! |
TBranch *b_P0card; //! |
385 |
// |
// |
386 |
|
TF1 *attenAC; |
387 |
public: |
public: |
388 |
|
|
389 |
Digitizer(TTree *tree, char* &file_raw); // constructor |
Digitizer(TTree*,char*&,int,int,int,int,int,int,int,int); // constructor |
390 |
|
|
391 |
void Close(); |
void Close(); |
|
|
|
392 |
void SetTree(TTree *tree) {fhBookTree = tree;}; |
void SetTree(TTree *tree) {fhBookTree = tree;}; |
|
|
|
|
|
|
393 |
void Loop(); // does the looping over events |
void Loop(); // does the looping over events |
394 |
|
|
395 |
|
void DigitizePSCU(UInt_t, UChar_t, UShort_t*); // digitizes the CPU header |
|
|
|
|
void DigitizePSCU(UInt_t, UChar_t); // digitizes the CPU header |
|
396 |
void AddPadding(); |
void AddPadding(); |
397 |
void DigitizeTRIGGER(); // digitizes the trigger |
void DigitizeRunHeader(); |
398 |
Int_t DigitizeTOF(); // digitizes the tof |
void DigitizeRunTrailer(); |
399 |
|
// void DigitizeTRIGGER(); // SO nov'07: included in DigitizeTOF |
400 |
|
void DigitizeTOF(int np,float *atte1,float *atte2,float *lambda1,float *lambda2); // digitizes the tof |
401 |
|
void LoadTOFCalib(int np,float *atte1,float *atte2,float *lambda1,float *lambda2); //load TOF calibration |
402 |
void DigitizeAC(); // digitizes the anti-counter |
void DigitizeAC(); // digitizes the anti-counter |
403 |
void DigitizeND(); // digitizes the ND |
void DigitizeND(); // digitizes the ND |
404 |
|
void DigitizeS4(); // digitizes the S4 |
405 |
void DigitizeCALO(); // digitizes the calorimeter |
void DigitizeCALO(); // digitizes the calorimeter |
406 |
void DigitizeCALOCALIB(); // digitizes the calorimeter calibration |
void DigitizeCALOCALIB(); // digitizes the calorimeter calibration |
407 |
void DigitizeCALORAW(); // digitizes the calorimeter |
void DigitizeCALORAW(); // digitizes the calorimeter |
420 |
void Paddle2Pmt(Int_t, Int_t, Int_t*, Int_t*); |
void Paddle2Pmt(Int_t, Int_t, Int_t*, Int_t*); |
421 |
//void Paddle2Pmt(Int_t, Int_t, Int_t &pmtleft, Int_t &pmtright); |
//void Paddle2Pmt(Int_t, Int_t, Int_t &pmtleft, Int_t &pmtright); |
422 |
UChar_t Bin2GrayTof(UChar_t, UChar_t); |
UChar_t Bin2GrayTof(UChar_t, UChar_t); |
423 |
|
void Crc8Tof(UChar_t*, UChar_t*); |
424 |
|
|
425 |
|
UChar_t EvaluateCrcTrigger(UChar_t*, Int_t); |
426 |
|
|
427 |
UShort_t* GetDataAC(){return(fDataAC);}; // retrieve AC data (not used right now) |
UShort_t* GetDataAC(){return(fDataAC);}; // retrieve AC data (not used right now) |
428 |
|
|
436 |
void LoadTrackCalib(); // load in memmory tracker calibration |
void LoadTrackCalib(); // load in memmory tracker calibration |
437 |
void CompressTrackData(Float_t AdcTrack[fNviews][fNstrips_view]); // Compress and Digitize data of one Ladder in turn |
void CompressTrackData(Float_t AdcTrack[fNviews][fNstrips_view]); // Compress and Digitize data of one Ladder in turn |
438 |
void LoadMipCor(); // Load the strip calibration in memory |
void LoadMipCor(); // Load the strip calibration in memory |
439 |
Float_t SaturationTrack(Float_t ADC); // Saturation simulation |
Float_t SaturationTrackx(Float_t ADC); // Saturation simulation |
440 |
|
Float_t SaturationTracky(Float_t ADC); // Saturation simulation |
441 |
// end methods for Tracker |
// end methods for Tracker |
442 |
|
|
443 |
|
void WriteRunHeader(); |
444 |
|
void WriteRunTrailer(); |
445 |
void WriteData(); // writes data to file |
void WriteData(); // writes data to file |
446 |
void ReadData(); |
void ReadData(); |
447 |
|
|