--- PamelaDigitizer/Digitizer.h 2007/09/13 11:00:53 1.1.1.1 +++ PamelaDigitizer/Digitizer.h 2008/05/21 09:50:44 1.5 @@ -1,5 +1,14 @@ #ifndef 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 + #include #include @@ -32,10 +41,13 @@ static const int fPSCUbuffer = 8; - static const int fTRIGGERbuffer = 153; //(bytes) + static const int fTRIGGERbuffer = 152; //(bytes) static const int fTOFbuffer = 276; //(bytes) + static const int fRunHeaderbuffer = 27; // ?? + static const int fRunTrailerbuffer = 17; static const int fACbuffer = 128; - static const int fNDbuffer = 4; + static const int fNDbuffer = 6; + static const int fS4buffer = 3; static const int fPADbuffer = 64; // changed from 32! static const int fCALObuffer = 10000; static const float fCALOGeV2MIPratio = 0.0001059994; @@ -62,24 +74,27 @@ static const float fAveSigmay = 8.; // to be adjusted static const float fSigmaSigmay =0.1; // to be adjusted static const float fSigmaCommon = 25.; // to be adjusted - static const float fMipCor = 1.; // to be adjusted // end dimensions of vectors and buffer, parameter for tracker UShort_t fDataPSCU[fPSCUbuffer]; UInt_t fCounter; + UInt_t fCounterPhys; UInt_t fOBT; UShort_t fDataPadding[fPADbuffer]; UInt_t fPadding; - UChar_t fDataTrigger[fTRIGGERbuffer]; + UShort_t fDataRunHeader[fRunHeaderbuffer]; + UShort_t fDataRunTrailer[fRunTrailerbuffer]; + UChar_t fDataTrigger[fTRIGGERbuffer]; UChar_t fDataTof[fTOFbuffer]; UShort_t fDataAC[fACbuffer]; - UShort_t fDataND[fACbuffer]; + UShort_t fDataND[fNDbuffer]; + UShort_t fDataS4[fS4buffer]; UShort_t fDataDummy[fDummybuffer]; UShort_t fDataCALO[fCALObuffer]; @@ -100,6 +115,7 @@ char* fFilename; UInt_t fLen; + // vectors, buffer, and variables for tracker @@ -107,6 +123,8 @@ UInt_t fTracklength; // Actual length of buffer Float_t fPedeTrack[fNviews][fNstrips_view]; Float_t fSigmaTrack[fNviews][fNstrips_view]; +// UShort_t fBadTrack[fNviews][fNstrips_view]; + Float_t fMipCor[fNladder][fNviews] ; // end vectors, buffer, and variables for tracker @@ -126,117 +144,117 @@ Float_t Phi; Float_t P0; Int_t Nthtof; - UChar_t Ipltof[100]; //[Nthtof] - UChar_t Ipaddle[100]; //[Nthtof] - UChar_t Ipartof[100]; //[Nthtof] - Float_t Xintof[100]; //[Nthtof] - Float_t Yintof[100]; //[Nthtof] - Float_t Zintof[100]; //[Nthtof] - Float_t Xouttof[100]; //[Nthtof] - Float_t Youttof[100]; //[Nthtof] - Float_t Zouttof[100]; //[Nthtof] - Float_t Ereltof[100]; //[Nthtof] - Float_t Timetof[100]; //[Nthtof] - Float_t Pathtof[100]; //[Nthtof] - Float_t P0tof[100]; //[Nthtof] + UChar_t Ipltof[ntof]; + UChar_t Ipaddle[ntof]; + UChar_t Ipartof[ntof]; + Float_t Xintof[ntof]; + Float_t Yintof[ntof]; + Float_t Zintof[ntof]; + Float_t Xouttof[ntof]; + Float_t Youttof[ntof]; + Float_t Zouttof[ntof]; + Float_t Ereltof[ntof]; + Float_t Timetof[ntof]; + Float_t Pathtof[ntof]; + Float_t P0tof[ntof]; Int_t Nthcat; - UChar_t Iparcat[50]; //[Nthcat] - UChar_t Icat[50]; //[Nthcat] - Float_t Xincat[50]; //[Nthcat] - Float_t Yincat[50]; //[Nthcat] - Float_t Zincat[50]; //[Nthcat] - Float_t Xoutcat[50]; //[Nthcat] - Float_t Youtcat[50]; //[Nthcat] - Float_t Zoutcat[50]; //[Nthcat] - Float_t Erelcat[50]; //[Nthcat] - Float_t Timecat[50]; //[Nthcat] - Float_t Pathcat[50]; //[Nthcat] - Float_t P0cat[50]; //[Nthcat] + UChar_t Iparcat[ncat]; + UChar_t Icat[ncat]; + Float_t Xincat[ncat]; + Float_t Yincat[ncat]; + Float_t Zincat[ncat]; + Float_t Xoutcat[ncat]; + Float_t Youtcat[ncat]; + Float_t Zoutcat[ncat]; + Float_t Erelcat[ncat]; + Float_t Timecat[ncat]; + Float_t Pathcat[ncat]; + Float_t P0cat[ncat]; Int_t Nthcas; - UChar_t Iparcas[50]; //[Nthcas] - UChar_t Icas[50]; //[Nthcas] - Float_t Xincas[50]; //[Nthcas] - Float_t Yincas[50]; //[Nthcas] - Float_t Zincas[50]; //[Nthcas] - Float_t Xoutcas[50]; //[Nthcas] - Float_t Youtcas[50]; //[Nthcas] - Float_t Zoutcas[50]; //[Nthcas] - Float_t Erelcas[50]; //[Nthcas] - Float_t Timecas[50]; //[Nthcas] - Float_t Pathcas[50]; //[Nthcas] - Float_t P0cas[50]; //[Nthcas] + UChar_t Iparcas[ncas]; + UChar_t Icas[ncas]; + Float_t Xincas[ncas]; + Float_t Yincas[ncas]; + Float_t Zincas[ncas]; + Float_t Xoutcas[ncas]; + Float_t Youtcas[ncas]; + Float_t Zoutcas[ncas]; + Float_t Erelcas[ncas]; + Float_t Timecas[ncas]; + Float_t Pathcas[ncas]; + Float_t P0cas[ncas]; Int_t Nthspe; - UChar_t Iparspe[100]; //[Nthspe] - UChar_t Itrpb[100]; //[Nthspe] - UChar_t Itrsl[100]; //[Nthspe] - UChar_t Itspa[100]; //[Nthspe] - Float_t Xinspe[100]; //[Nthspe] - Float_t Yinspe[100]; //[Nthspe] - Float_t Zinspe[100]; //[Nthspe] - Float_t Xoutspe[100]; //[Nthspe] - Float_t Youtspe[100]; //[Nthspe] - Float_t Zoutspe[100]; //[Nthspe] - Float_t Xavspe[100]; //[Nthspe] - Float_t Yavspe[100]; //[Nthspe] - Float_t Zavspe[100]; //[Nthspe] - Float_t Erelspe[100]; //[Nthspe] - Float_t Pathspe[100]; //[Nthspe] - Float_t P0spe[100]; //[Nthspe] - UChar_t Nxmult[100]; //[Nthspe] - UChar_t Nymult[100]; //[Nthspe] + UChar_t Iparspe[nspe]; + UChar_t Itrpb[nspe]; + UChar_t Itrsl[nspe]; + UChar_t Itspa[nspe]; + Float_t Xinspe[nspe]; + Float_t Yinspe[nspe]; + Float_t Zinspe[nspe]; + Float_t Xoutspe[nspe]; + Float_t Youtspe[nspe]; + Float_t Zoutspe[nspe]; + Float_t Xavspe[nspe]; + Float_t Yavspe[nspe]; + Float_t Zavspe[nspe]; + Float_t Erelspe[nspe]; + Float_t Pathspe[nspe]; + Float_t P0spe[nspe]; + UChar_t Nxmult[nspe]; + UChar_t Nymult[nspe]; Int_t Nstrpx; - UChar_t Npstripx[1000]; //[Nstrpx] - UChar_t Ntstripx[1000]; //[Nstrpx] - UShort_t Istripx[1000]; //[Nstrpx] - //UInt_t Istripx[1000]; //[Nstrpx] - Float_t Qstripx[1000]; //[Nstrpx] - Float_t Xstripx[1000]; //[Nstrpx] + UChar_t Npstripx[nstr]; + UChar_t Ntstripx[nstr]; + UShort_t Istripx[nstr]; + //UInt_t Istripx[nstr]; + Float_t Qstripx[nstr]; + Float_t Xstripx[nstr]; Int_t Nstrpy; - UChar_t Npstripy[1000]; //[Nstrpy] - UChar_t Ntstripy[1000]; //[Nstrpy] - UShort_t Istripy[1000]; //[Nstrpy] - //UInt_t Istripy[1000]; //[Nstrpy] - Float_t Qstripy[1000]; //[Nstrpy] - Float_t Ystripy[1000]; //[Nstrpy] + UChar_t Npstripy[nstr]; + UChar_t Ntstripy[nstr]; + UShort_t Istripy[nstr]; + //UInt_t Istripy[nstr]; + Float_t Qstripy[nstr]; + Float_t Ystripy[nstr]; Int_t Nthcali; - UChar_t Icaplane[4224]; //[Nthcali] - UChar_t Icastrip[4224]; //[Nthcali] - Int_t Icamod[4224]; //[Nthcali] - Float_t Enestrip[4224]; //[Nthcali] + UChar_t Icaplane[4224]; + UChar_t Icastrip[4224]; + Int_t Icamod[4224]; + Float_t Enestrip[4224]; Int_t Nthcal; - UChar_t Icapl[1000]; //[Nthcal] - UChar_t Icasi[1000]; //[Nthcal] - UChar_t Icast[1000]; //[Nthcal] - Float_t Xincal[1000]; //[Nthcal] - Float_t Yincal[1000]; //[Nthcal] - Float_t Zincal[1000]; //[Nthcal] - Float_t Erelcal[1000]; //[Nthcal] + UChar_t Icapl[ncal]; + UChar_t Icasi[ncal]; + UChar_t Icast[ncal]; + Float_t Xincal[ncal]; + Float_t Yincal[ncal]; + Float_t Zincal[ncal]; + Float_t Erelcal[ncal]; Int_t Nthnd; - UChar_t Itubend[200]; //[Nthnd] - UChar_t Iparnd[200]; //[Nthnd] - Float_t Xinnd[200]; //[Nthnd] - Float_t Yinnd[200]; //[Nthnd] - Float_t Zinnd[200]; //[Nthnd] - Float_t Xoutnd[200]; //[Nthnd] - Float_t Youtnd[200]; //[Nthnd] - Float_t Zoutnd[200]; //[Nthnd] - Float_t Erelnd[200]; //[Nthnd] - Float_t Timend[200]; //[Nthnd] - Float_t Pathnd[200]; //[Nthnd] - Float_t P0nd[200]; //[Nthnd] + UChar_t Itubend[nnd]; + UChar_t Iparnd[nnd]; + Float_t Xinnd[nnd]; + Float_t Yinnd[nnd]; + Float_t Zinnd[nnd]; + Float_t Xoutnd[nnd]; + Float_t Youtnd[nnd]; + Float_t Zoutnd[nnd]; + Float_t Erelnd[nnd]; + Float_t Timend[nnd]; + Float_t Pathnd[nnd]; + Float_t P0nd[nnd]; Int_t Nthcard; - UChar_t Iparcard[100]; //[Nthcard] - UChar_t Icard[100]; //[Nthcard] - Float_t Xincard[100]; //[Nthcard] - Float_t Yincard[100]; //[Nthcard] - Float_t Zincard[100]; //[Nthcard] - Float_t Xoutcard[100]; //[Nthcard] - Float_t Youtcard[100]; //[Nthcard] - Float_t Zoutcard[100]; //[Nthcard] - Float_t Erelcard[100]; //[Nthcard] - Float_t Timecard[100]; //[Nthcard] - Float_t Pathcard[100]; //[Nthcard] - Float_t P0card[100]; //[Nthcard] + UChar_t Iparcard[ncar]; + UChar_t Icard[ncar]; + Float_t Xincard[ncar]; + Float_t Yincard[ncar]; + Float_t Zincard[ncar]; + Float_t Xoutcard[ncar]; + Float_t Youtcard[ncar]; + Float_t Zoutcard[ncar]; + Float_t Erelcard[ncar]; + Float_t Timecard[ncar]; + Float_t Pathcard[ncar]; + Float_t P0card[ncar]; // List of branches TBranch *b_Irun; //! @@ -365,20 +383,19 @@ Digitizer(TTree *tree, char* &file_raw); // constructor void Close(); - void SetTree(TTree *tree) {fhBookTree = tree;}; - - void Loop(); // does the looping over events - - - void DigitizePSCU(UInt_t, UChar_t); // digitizes the CPU header + void DigitizePSCU(UInt_t, UChar_t, UShort_t*); // digitizes the CPU header void AddPadding(); - void DigitizeTRIGGER(); // digitizes the trigger - Int_t DigitizeTOF(); // digitizes the tof + void DigitizeRunHeader(); + void DigitizeRunTrailer(); + // void DigitizeTRIGGER(); // SO nov'07: included in DigitizeTOF + void DigitizeTOF(int np,float *atte1,float *atte2,float *lambda1,float *lambda2); // digitizes the tof + void LoadTOFCalib(int np,float *atte1,float *atte2,float *lambda1,float *lambda2); //load TOF calibration void DigitizeAC(); // digitizes the anti-counter void DigitizeND(); // digitizes the ND + void DigitizeS4(); // digitizes the S4 void DigitizeCALO(); // digitizes the calorimeter void DigitizeCALOCALIB(); // digitizes the calorimeter calibration void DigitizeCALORAW(); // digitizes the calorimeter @@ -397,6 +414,9 @@ void Paddle2Pmt(Int_t, Int_t, Int_t*, Int_t*); //void Paddle2Pmt(Int_t, Int_t, Int_t &pmtleft, Int_t &pmtright); UChar_t Bin2GrayTof(UChar_t, UChar_t); + void Crc8Tof(UChar_t*, UChar_t*); + + UChar_t EvaluateCrcTrigger(UChar_t*, Int_t); UShort_t* GetDataAC(){return(fDataAC);}; // retrieve AC data (not used right now) @@ -410,9 +430,12 @@ void LoadTrackCalib(); // load in memmory tracker calibration void CompressTrackData(Float_t AdcTrack[fNviews][fNstrips_view]); // Compress and Digitize data of one Ladder in turn void LoadMipCor(); // Load the strip calibration in memory - Float_t SaturationTrack(Float_t ADC); // Saturation simulation + Float_t SaturationTrackx(Float_t ADC); // Saturation simulation + Float_t SaturationTracky(Float_t ADC); // Saturation simulation // end methods for Tracker + void WriteRunHeader(); + void WriteRunTrailer(); void WriteData(); // writes data to file void ReadData();