| 1 | #ifndef DIGITIZER_H | #ifndef DIGITIZER_H | 
| 2 | #define DIGITIZER_H | #define DIGITIZER_H | 
|  | #define nspe 200 |  | 
|  | #define ntof 200 |  | 
|  | #define ncat 50 |  | 
|  | #define ncas 50 |  | 
|  | #define ncar 100 |  | 
|  | #define ncal 1000 |  | 
|  | #define nnd 200 |  | 
|  | #define nstr 1000 |  | 
| 3 |  |  | 
| 4 | #include <iostream> | #include <iostream> | 
| 5 |  | #include <istream> | 
| 6 | #include <fstream> | #include <fstream> | 
| 7 |  |  | 
| 8 |  |  | 
| 17 | #include "TLeafI.h" | #include "TLeafI.h" | 
| 18 | #include "TH1.h" | #include "TH1.h" | 
| 19 | #include "TH2.h" | #include "TH2.h" | 
| 20 |  | #include "TF1.h" | 
| 21 | #include "TMath.h" | #include "TMath.h" | 
| 22 | #include "TSQLServer.h" | #include "TSQLServer.h" | 
| 23 | // | #include "TGraph.h" | 
| 24 |  | #include "GLTables.h" | 
| 25 |  | #include "TSystem.h" | 
| 26 |  | #include "TRandom.h" | 
| 27 |  |  | 
| 28 | #include "CRC.h" | #include "CRC.h" | 
| 29 |  | #include <CalibCalPedEvent.h> | 
| 30 |  | #include "CalibTrk1Event.h" | 
| 31 |  | #include "CalibTrk2Event.h" | 
| 32 |  |  | 
| 33 | class Digitizer{ | class Digitizer{ | 
| 34 |  |  | 
|  |  |  | 
| 35 | protected: | protected: | 
| 36 |  |  | 
| 37 | // in and output data members | // in and output data members | 
| 38 |  |  | 
| 39 | TTree* fhBookTree; | TTree* fhBookTree; | 
| 40 | ofstream fOutputfile; | ofstream fOutputfile; | 
| 41 |  | int *nspe; | 
| 42 |  | int *ntof; | 
| 43 |  | int *ncat; | 
| 44 |  | int *ncas; | 
| 45 |  | int *ncar; | 
| 46 |  | int *ncal; | 
| 47 |  | int *nnd; | 
| 48 |  | int *nstr; | 
| 49 |  | int *comprcalomod; | 
| 50 |  |  | 
| 51 | static const int fPSCUbuffer = 8; | static const int fPSCUbuffer = 8; | 
| 52 | static const int fTRIGGERbuffer = 152; //(bytes) | static const int fTRIGGERbuffer = 152; //(bytes) | 
| 53 | static const int fTOFbuffer = 276;     //(bytes) | static const int fTOFbuffer = 276;     //(bytes) | 
|  | static const int fRunHeaderbuffer = 27; // ?? |  | 
|  | static const int fRunTrailerbuffer = 17; |  | 
| 54 | static const int fACbuffer = 128; | static const int fACbuffer = 128; | 
| 55 | static const int fNDbuffer = 6; | static const int fNDbuffer = 6; | 
| 56 | static const int fS4buffer = 3; | static const int fS4buffer = 3; | 
| 92 | UShort_t fDataPadding[fPADbuffer]; | UShort_t fDataPadding[fPADbuffer]; | 
| 93 | UInt_t fPadding; | UInt_t fPadding; | 
| 94 |  |  | 
|  | UShort_t fDataRunHeader[fRunHeaderbuffer]; |  | 
|  | UShort_t fDataRunTrailer[fRunTrailerbuffer]; |  | 
|  |  |  | 
| 95 | UChar_t fDataTrigger[fTRIGGERbuffer]; | UChar_t fDataTrigger[fTRIGGERbuffer]; | 
| 96 | UChar_t fDataTof[fTOFbuffer]; | UChar_t fDataTof[fTOFbuffer]; | 
| 97 |  |  | 
| 104 | UShort_t fSecCalo[4]; | UShort_t fSecCalo[4]; | 
| 105 | UShort_t fSecCALOLength[4]; | UShort_t fSecCALOLength[4]; | 
| 106 | UShort_t fCALOlength; | UShort_t fCALOlength; | 
| 107 | UShort_t fModCalo; | UShort_t fModCalo ; //  0 is RAW, 1 is COMPRESS, 2 is FULL | 
| 108 | Float_t fCalomip[2][22][96]; // ADC to MIP conversion values | Float_t fCalomip[2][22][96]; // ADC to MIP conversion values | 
| 109 | Float_t fcalped[4][11][96]; // pedestals | Float_t fcalped[4][11][96]; // pedestals | 
| 110 | Float_t fcalgood[4][11][96]; // used or not in the common noise calculation | Float_t fcalgood[4][11][96]; // used or not in the common noise calculation | 
| 119 | char* fFilename; | char* fFilename; | 
| 120 | UInt_t fLen; | UInt_t fLen; | 
| 121 |  |  | 
| 122 |  | UInt_t fEvent ; // cecilia, current evt nr | 
| 123 |  |  | 
| 124 |  |  | 
| 125 | //  vectors, buffer, and variables for tracker | //  vectors, buffer, and variables for tracker | 
| 148 | Float_t         Phi; | Float_t         Phi; | 
| 149 | Float_t         P0; | Float_t         P0; | 
| 150 | Int_t           Nthtof; | Int_t           Nthtof; | 
| 151 | UChar_t         Ipltof[ntof]; | UChar_t         *Ipltof; | 
| 152 | UChar_t         Ipaddle[ntof]; | UChar_t         *Ipaddle; | 
| 153 | UChar_t         Ipartof[ntof]; | //    UChar_t         *Ipartof;//DPMJET | 
| 154 | Float_t         Xintof[ntof]; | UShort_t        *Ipartof; | 
| 155 | Float_t         Yintof[ntof]; | Float_t         *Xintof; | 
| 156 | Float_t         Zintof[ntof]; | Float_t         *Yintof; | 
| 157 | Float_t         Xouttof[ntof]; | Float_t         *Zintof; | 
| 158 | Float_t         Youttof[ntof]; | Float_t         *Xouttof; | 
| 159 | Float_t         Zouttof[ntof]; | Float_t         *Youttof; | 
| 160 | Float_t         Ereltof[ntof]; | Float_t         *Zouttof; | 
| 161 | Float_t         Timetof[ntof]; | Float_t         *Ereltof; | 
| 162 | Float_t         Pathtof[ntof]; | Float_t         *Timetof; | 
| 163 | Float_t         P0tof[ntof]; | Float_t         *Pathtof; | 
| 164 |  | Float_t         *P0tof; | 
| 165 | Int_t           Nthcat; | Int_t           Nthcat; | 
| 166 | UChar_t         Iparcat[ncat]; | UChar_t         *Iparcat; | 
| 167 | UChar_t         Icat[ncat]; | UChar_t         *Icat; | 
| 168 | Float_t         Xincat[ncat]; | Float_t         *Xincat; | 
| 169 | Float_t         Yincat[ncat]; | Float_t         *Yincat; | 
| 170 | Float_t         Zincat[ncat]; | Float_t         *Zincat; | 
| 171 | Float_t         Xoutcat[ncat]; | Float_t         *Xoutcat; | 
| 172 | Float_t         Youtcat[ncat]; | Float_t         *Youtcat; | 
| 173 | Float_t         Zoutcat[ncat]; | Float_t         *Zoutcat; | 
| 174 | Float_t         Erelcat[ncat]; | Float_t         *Erelcat; | 
| 175 | Float_t         Timecat[ncat]; | Float_t         *Timecat; | 
| 176 | Float_t         Pathcat[ncat]; | Float_t         *Pathcat; | 
| 177 | Float_t         P0cat[ncat]; | Float_t         *P0cat; | 
| 178 | Int_t           Nthcas; | Int_t           Nthcas; | 
| 179 | UChar_t         Iparcas[ncas]; | UChar_t         *Iparcas; | 
| 180 | UChar_t         Icas[ncas]; | UChar_t         *Icas; | 
| 181 | Float_t         Xincas[ncas]; | Float_t         *Xincas; | 
| 182 | Float_t         Yincas[ncas]; | Float_t         *Yincas; | 
| 183 | Float_t         Zincas[ncas]; | Float_t         *Zincas; | 
| 184 | Float_t         Xoutcas[ncas]; | Float_t         *Xoutcas; | 
| 185 | Float_t         Youtcas[ncas]; | Float_t         *Youtcas; | 
| 186 | Float_t         Zoutcas[ncas]; | Float_t         *Zoutcas; | 
| 187 | Float_t         Erelcas[ncas]; | Float_t         *Erelcas; | 
| 188 | Float_t         Timecas[ncas]; | Float_t         *Timecas; | 
| 189 | Float_t         Pathcas[ncas]; | Float_t         *Pathcas; | 
| 190 | Float_t         P0cas[ncas]; | Float_t         *P0cas; | 
| 191 | Int_t           Nthspe; | Int_t           Nthspe; | 
| 192 | UChar_t         Iparspe[nspe]; | //    UChar_t         *Iparspe;//DPMJET | 
| 193 | UChar_t         Itrpb[nspe]; | //    UShort_t        *Iparspe; | 
| 194 | UChar_t         Itrsl[nspe]; | UChar_t         *Itrpb; | 
| 195 | UChar_t         Itspa[nspe]; | UChar_t         *Itrsl; | 
| 196 | Float_t         Xinspe[nspe]; | UChar_t         *Itspa; | 
| 197 | Float_t         Yinspe[nspe]; | Float_t         *Xinspe; | 
| 198 | Float_t         Zinspe[nspe]; | Float_t         *Yinspe; | 
| 199 | Float_t         Xoutspe[nspe]; | Float_t         *Zinspe; | 
| 200 | Float_t         Youtspe[nspe]; | Float_t         *Xoutspe; | 
| 201 | Float_t         Zoutspe[nspe]; | Float_t         *Youtspe; | 
| 202 | Float_t         Xavspe[nspe]; | Float_t         *Zoutspe; | 
| 203 | Float_t         Yavspe[nspe]; | Float_t         *Xavspe; | 
| 204 | Float_t         Zavspe[nspe]; | Float_t         *Yavspe; | 
| 205 | Float_t         Erelspe[nspe]; | Float_t         *Zavspe; | 
| 206 | Float_t         Pathspe[nspe]; | Float_t         *Erelspe; | 
| 207 | Float_t         P0spe[nspe]; | Float_t         *Pathspe; | 
| 208 | UChar_t         Nxmult[nspe]; | Float_t         *P0spe; | 
| 209 | UChar_t         Nymult[nspe]; | UChar_t         *Nxmult; | 
| 210 |  | UChar_t         *Nymult; | 
| 211 | Int_t           Nstrpx; | Int_t           Nstrpx; | 
| 212 | UChar_t         Npstripx[nstr]; | UChar_t         *Npstripx; | 
| 213 | UChar_t         Ntstripx[nstr]; | UChar_t         *Ntstripx; | 
| 214 | UShort_t        Istripx[nstr]; | UShort_t        *Istripx; | 
| 215 | //UInt_t        Istripx[nstr]; | Float_t         *Qstripx; | 
| 216 | Float_t         Qstripx[nstr]; | Float_t         *Xstripx; | 
|  | Float_t         Xstripx[nstr]; |  | 
| 217 | Int_t           Nstrpy; | Int_t           Nstrpy; | 
| 218 | UChar_t         Npstripy[nstr]; | UChar_t         *Npstripy; | 
| 219 | UChar_t         Ntstripy[nstr]; | UChar_t         *Ntstripy; | 
| 220 | UShort_t        Istripy[nstr]; | UShort_t        *Istripy; | 
| 221 | //UInt_t        Istripy[nstr]; | Float_t         *Qstripy; | 
| 222 | Float_t         Qstripy[nstr]; | Float_t         *Ystripy; | 
|  | Float_t         Ystripy[nstr]; |  | 
| 223 | Int_t           Nthcali; | Int_t           Nthcali; | 
| 224 | UChar_t         Icaplane[4224]; | UChar_t         Icaplane[4224]; | 
| 225 | UChar_t         Icastrip[4224]; | UChar_t         Icastrip[4224]; | 
| 226 | Int_t           Icamod[4224]; | Int_t           Icamod[4224]; | 
| 227 | Float_t         Enestrip[4224]; | Float_t         Enestrip[4224]; | 
| 228 | Int_t           Nthcal; | Int_t           Nthcal; | 
| 229 | UChar_t         Icapl[ncal]; | UChar_t         *Icapl; | 
| 230 | UChar_t         Icasi[ncal]; | UChar_t         *Icasi; | 
| 231 | UChar_t         Icast[ncal]; | UChar_t         *Icast; | 
| 232 | Float_t         Xincal[ncal]; | Float_t         *Xincal; | 
| 233 | Float_t         Yincal[ncal]; | Float_t         *Yincal; | 
| 234 | Float_t         Zincal[ncal]; | Float_t         *Zincal; | 
| 235 | Float_t         Erelcal[ncal]; | Float_t         *Erelcal; | 
| 236 | Int_t           Nthnd; | Int_t           Nthnd; | 
| 237 | UChar_t         Itubend[nnd]; | UChar_t         *Itubend; | 
| 238 | UChar_t         Iparnd[nnd]; | UChar_t         *Iparnd; | 
| 239 | Float_t         Xinnd[nnd]; | Float_t         *Xinnd; | 
| 240 | Float_t         Yinnd[nnd]; | Float_t         *Yinnd; | 
| 241 | Float_t         Zinnd[nnd]; | Float_t         *Zinnd; | 
| 242 | Float_t         Xoutnd[nnd]; | Float_t         *Xoutnd; | 
| 243 | Float_t         Youtnd[nnd]; | Float_t         *Youtnd; | 
| 244 | Float_t         Zoutnd[nnd]; | Float_t         *Zoutnd; | 
| 245 | Float_t         Erelnd[nnd]; | Float_t         *Erelnd; | 
| 246 | Float_t         Timend[nnd]; | Float_t         *Timend; | 
| 247 | Float_t         Pathnd[nnd]; | Float_t         *Pathnd; | 
| 248 | Float_t         P0nd[nnd]; | Float_t         *P0nd; | 
| 249 | Int_t           Nthcard; | Int_t           Nthcard; | 
| 250 | UChar_t         Iparcard[ncar]; | UChar_t         *Iparcard; | 
| 251 | UChar_t         Icard[ncar]; | UChar_t         *Icard; | 
| 252 | Float_t         Xincard[ncar]; | Float_t         *Xincard; | 
| 253 | Float_t         Yincard[ncar]; | Float_t         *Yincard; | 
| 254 | Float_t         Zincard[ncar]; | Float_t         *Zincard; | 
| 255 | Float_t         Xoutcard[ncar]; | Float_t         *Xoutcard; | 
| 256 | Float_t         Youtcard[ncar]; | Float_t         *Youtcard; | 
| 257 | Float_t         Zoutcard[ncar]; | Float_t         *Zoutcard; | 
| 258 | Float_t         Erelcard[ncar]; | Float_t         *Erelcard; | 
| 259 | Float_t         Timecard[ncar]; | Float_t         *Timecard; | 
| 260 | Float_t         Pathcard[ncar]; | Float_t         *Pathcard; | 
| 261 | Float_t         P0card[ncar]; | Float_t         *P0card; | 
| 262 |  |  | 
| 263 | // List of branches | // List of branches | 
| 264 | TBranch        *b_Irun;   //! | TBranch        *b_Irun;   //! | 
| 381 | TBranch        *b_Pathcard;   //! | TBranch        *b_Pathcard;   //! | 
| 382 | TBranch        *b_P0card;   //! | TBranch        *b_P0card;   //! | 
| 383 | // | // | 
| 384 |  | TF1 *attenAC; | 
| 385 | public: | public: | 
| 386 |  |  | 
| 387 | Digitizer(TTree *tree, char* &file_raw); // constructor | Digitizer(TTree*,char*&,int,int,int,int,int,int,int,int,int); // constructor | 
| 388 |  |  | 
| 389 | void Close(); | void Close(); | 
| 390 | void SetTree(TTree *tree) {fhBookTree = tree;}; | void SetTree(TTree *tree) {fhBookTree = tree;}; | 
| 392 |  |  | 
| 393 | void DigitizePSCU(UInt_t, UChar_t, UShort_t*);  // digitizes the CPU header | void DigitizePSCU(UInt_t, UChar_t, UShort_t*);  // digitizes the CPU header | 
| 394 | void AddPadding(); | void AddPadding(); | 
|  | void DigitizeRunHeader(); |  | 
|  | void DigitizeRunTrailer(); |  | 
|  | //    void DigitizeTRIGGER();  // SO nov'07: included in DigitizeTOF |  | 
| 395 | void DigitizeTOF(int np,float *atte1,float *atte2,float *lambda1,float *lambda2);  // digitizes the tof | void DigitizeTOF(int np,float *atte1,float *atte2,float *lambda1,float *lambda2);  // digitizes the tof | 
| 396 | void LoadTOFCalib(int np,float *atte1,float *atte2,float *lambda1,float *lambda2); //load TOF calibration | void LoadTOFCalib(int np,float *atte1,float *atte2,float *lambda1,float *lambda2); //load TOF calibration | 
| 397 | void DigitizeAC();  // digitizes the anti-counter | void DigitizeAC();  // digitizes the anti-counter | 
| 435 | Float_t SaturationTracky(Float_t ADC); // Saturation simulation | Float_t SaturationTracky(Float_t ADC); // Saturation simulation | 
| 436 | //  end methods for Tracker | //  end methods for Tracker | 
| 437 |  |  | 
| 438 | void WriteRunHeader(); | // AC Methods | 
| 439 | void WriteRunTrailer(); | UShort_t EvaluateCrcAC( UShort_t* , Bool_t ); | 
| 440 |  | UShort_t crcAC(UShort_t, UShort_t); | 
| 441 |  |  | 
| 442 |  |  | 
| 443 | void WriteData(); // writes data to file | void WriteData(); // writes data to file | 
| 444 | void ReadData(); | void ReadData(); | 
| 445 |  |  |