--- PamelaDigitizer/Digitizer.h 2007/09/13 11:00:53 1.1 +++ PamelaDigitizer/Digitizer.h 2009/05/05 14:17:46 1.11 @@ -1,5 +1,6 @@ #ifndef DIGITIZER_H #define DIGITIZER_H + #include #include @@ -15,27 +16,42 @@ #include "TLeafI.h" #include "TH1.h" #include "TH2.h" +#include "TF1.h" #include "TMath.h" #include "TSQLServer.h" -// +#include "TGraph.h" +#include "GLTables.h" +#include "TSystem.h" +#include "TRandom.h" + #include "CRC.h" +#include +#include "CalibTrk1Event.h" +#include "CalibTrk2Event.h" class Digitizer{ - protected: // in and output data members TTree* fhBookTree; ofstream fOutputfile; - + int *nspe; + int *ntof; + int *ncat; + int *ncas; + int *ncar; + int *ncal; + int *nnd; + int *nstr; 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 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 +78,24 @@ 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]; - 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 +116,7 @@ char* fFilename; UInt_t fLen; + // vectors, buffer, and variables for tracker @@ -107,6 +124,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 +145,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; + UChar_t *Ipaddle; + // UChar_t *Ipartof;//DPMJET + UShort_t *Ipartof; + Float_t *Xintof; + Float_t *Yintof; + Float_t *Zintof; + Float_t *Xouttof; + Float_t *Youttof; + Float_t *Zouttof; + Float_t *Ereltof; + Float_t *Timetof; + Float_t *Pathtof; + Float_t *P0tof; 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; + UChar_t *Icat; + Float_t *Xincat; + Float_t *Yincat; + Float_t *Zincat; + Float_t *Xoutcat; + Float_t *Youtcat; + Float_t *Zoutcat; + Float_t *Erelcat; + Float_t *Timecat; + Float_t *Pathcat; + Float_t *P0cat; 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; + UChar_t *Icas; + Float_t *Xincas; + Float_t *Yincas; + Float_t *Zincas; + Float_t *Xoutcas; + Float_t *Youtcas; + Float_t *Zoutcas; + Float_t *Erelcas; + Float_t *Timecas; + Float_t *Pathcas; + Float_t *P0cas; 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;//DPMJET + // UShort_t *Iparspe; + UChar_t *Itrpb; + UChar_t *Itrsl; + UChar_t *Itspa; + Float_t *Xinspe; + Float_t *Yinspe; + Float_t *Zinspe; + Float_t *Xoutspe; + Float_t *Youtspe; + Float_t *Zoutspe; + Float_t *Xavspe; + Float_t *Yavspe; + Float_t *Zavspe; + Float_t *Erelspe; + Float_t *Pathspe; + Float_t *P0spe; + UChar_t *Nxmult; + UChar_t *Nymult; 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; + UChar_t *Ntstripx; + UShort_t *Istripx; + Float_t *Qstripx; + Float_t *Xstripx; 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; + UChar_t *Ntstripy; + UShort_t *Istripy; + Float_t *Qstripy; + Float_t *Ystripy; 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; + UChar_t *Icasi; + UChar_t *Icast; + Float_t *Xincal; + Float_t *Yincal; + Float_t *Zincal; + Float_t *Erelcal; 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; + UChar_t *Iparnd; + Float_t *Xinnd; + Float_t *Yinnd; + Float_t *Zinnd; + Float_t *Xoutnd; + Float_t *Youtnd; + Float_t *Zoutnd; + Float_t *Erelnd; + Float_t *Timend; + Float_t *Pathnd; + Float_t *P0nd; 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; + UChar_t *Icard; + Float_t *Xincard; + Float_t *Yincard; + Float_t *Zincard; + Float_t *Xoutcard; + Float_t *Youtcard; + Float_t *Zoutcard; + Float_t *Erelcard; + Float_t *Timecard; + Float_t *Pathcard; + Float_t *P0card; // List of branches TBranch *b_Irun; //! @@ -359,26 +378,22 @@ TBranch *b_Pathcard; //! TBranch *b_P0card; //! // - + TF1 *attenAC; public: - Digitizer(TTree *tree, char* &file_raw); // constructor + Digitizer(TTree*,char*&,int,int,int,int,int,int,int,int); // 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 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 +412,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,7 +428,8 @@ 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 WriteData(); // writes data to file