--- PamelaDigitizer/Digitizer.cxx 2008/06/08 06:33:45 1.10 +++ PamelaDigitizer/Digitizer.cxx 2009/10/16 09:15:50 1.14 @@ -4,47 +4,42 @@ // // NB: Check length physics packet [packet type (0x10 = physics data)] // -#include -#include -#include -#include -#include -#include -#include -#include "Riostream.h" -#include "TFile.h" -#include "TDirectory.h" -#include "TTree.h" -#include "TLeafI.h" -#include "TH1.h" -#include "TH2.h" -#include "TF1.h" -#include "TMath.h" -#include "TRandom.h" -#include "TSQLServer.h" -#include "TSystem.h" -#include "CalibTrk1Event.h" -#include "CalibTrk2Event.h" -// #include "Digitizer.h" -#include "CRC.h" -// -#include -#include -#include -#include "GLTables.h" -// + extern "C"{ short crc(short, short); }; // -Digitizer::Digitizer(TTree* tree, char* &file_raw,int nspe,int ntof,int ncat,int ncas,int ncar,int ncal,int nnd,int nstr){ +Digitizer::Digitizer(TTree* tree, char* &file_raw, + int nspe1=200,int ntof1=200,int ncat1=50, + int ncas1=50,int ncar1=100,int ncal1=1000, + int nnd1=200,int nstr1=1000, int comprcalomod=0){ + + nspe=new int[1]; + ntof=new int[1]; + ncat=new int[1]; + ncas=new int[1]; + ncar=new int[1]; + ncal=new int[1]; + nnd=new int[1]; + nstr=new int[1]; + + *nspe=nspe1; + *ntof=ntof1; + *ncat=ncat1; + *ncas=ncas1; + *ncar=ncar1; + *ncal=ncal1; + *nnd=nnd1; + *nstr=nstr1; + fhBookTree = tree; fFilename = file_raw; fCounter = 0; fCounterPhys = 0; // SO 5/12/'07 fOBT = 0; + fModCalo = comprcalomod ; // // DB connections @@ -80,106 +75,104 @@ std:: cout << "preparing tree" << endl; - ntf=(int*)malloc(1 *sizeof(int)); - *ntf=ntof; - Ipltof=(UChar_t*)malloc(ntof *sizeof(UChar_t)); - Ipaddle=(UChar_t*)malloc(ntof *sizeof(UChar_t)); - // Ipartof=(UShort_t*)malloc(ntof *sizeof(UShort_t)); - Ipartof=(UChar_t*)malloc(ntof *sizeof(UChar_t)); - Xintof=(Float_t*)malloc(ntof *sizeof(Float_t)); - Yintof=(Float_t*)malloc(ntof *sizeof(Float_t)); - Zintof=(Float_t*)malloc(ntof *sizeof(Float_t)); - Xouttof=(Float_t*)malloc(ntof *sizeof(Float_t)); - Youttof=(Float_t*)malloc(ntof *sizeof(Float_t)); - Zouttof=(Float_t*)malloc(ntof *sizeof(Float_t)); - Ereltof=(Float_t*)malloc(ntof *sizeof(Float_t)); - Timetof=(Float_t*)malloc(ntof *sizeof(Float_t)); - Pathtof=(Float_t*)malloc(ntof *sizeof(Float_t)); - P0tof=(Float_t*)malloc(ntof *sizeof(Float_t)); - Iparcat=(UChar_t*)malloc(ncat *sizeof(UChar_t)); - Icat=(UChar_t*)malloc(ncat *sizeof(UChar_t)); - Xincat=(Float_t*)malloc(ncat *sizeof(Float_t)); - Yincat=(Float_t*)malloc(ncat *sizeof(Float_t)); - Zincat=(Float_t*)malloc(ncat *sizeof(Float_t)); - Xoutcat=(Float_t*)malloc(ncat *sizeof(Float_t)); - Youtcat=(Float_t*)malloc(ncat *sizeof(Float_t)); - Zoutcat=(Float_t*)malloc(ncat *sizeof(Float_t)); - Erelcat=(Float_t*)malloc(ncat *sizeof(Float_t)); - Timecat=(Float_t*)malloc(ncat *sizeof(Float_t)); - Pathcat=(Float_t*)malloc(ncat *sizeof(Float_t)); - P0cat=(Float_t*)malloc(ncat *sizeof(Float_t)); - Iparcas=(UChar_t*)malloc(ncas *sizeof(UChar_t)); - Icas=(UChar_t*)malloc(ncas *sizeof(UChar_t)); - Xincas=(Float_t*)malloc(ncas *sizeof(Float_t)); - Yincas=(Float_t*)malloc(ncas *sizeof(Float_t)); - Zincas=(Float_t*)malloc(ncas *sizeof(Float_t)); - Xoutcas=(Float_t*)malloc(ncas *sizeof(Float_t)); - Youtcas=(Float_t*)malloc(ncas *sizeof(Float_t)); - Zoutcas=(Float_t*)malloc(ncas *sizeof(Float_t)); - Erelcas=(Float_t*)malloc(ncas *sizeof(Float_t)); - Timecas=(Float_t*)malloc(ncas *sizeof(Float_t)); - Pathcas=(Float_t*)malloc(ncas *sizeof(Float_t)); - P0cas=(Float_t*)malloc(ncas *sizeof(Float_t)); - // Iparspe=(UShort_t*)malloc(nspe *sizeof(UShort_t)); - Iparspe=(UChar_t*)malloc(nspe *sizeof(UChar_t)); - Itrpb=(UChar_t*)malloc(nspe *sizeof(UChar_t)); - Itrsl=(UChar_t*)malloc(nspe *sizeof(UChar_t)); - Itspa=(UChar_t*)malloc(nspe *sizeof(UChar_t)); - Xinspe=(Float_t*)malloc(nspe *sizeof(Float_t)); - Yinspe=(Float_t*)malloc(nspe *sizeof(Float_t)); - Zinspe=(Float_t*)malloc(nspe *sizeof(Float_t)); - Xoutspe=(Float_t*)malloc(nspe *sizeof(Float_t)); - Youtspe=(Float_t*)malloc(nspe *sizeof(Float_t)); - Zoutspe=(Float_t*)malloc(nspe *sizeof(Float_t)); - Xavspe=(Float_t*)malloc(nspe *sizeof(Float_t)); - Yavspe=(Float_t*)malloc(nspe *sizeof(Float_t)); - Zavspe=(Float_t*)malloc(nspe *sizeof(Float_t)); - Erelspe=(Float_t*)malloc(nspe *sizeof(Float_t)); - Pathspe=(Float_t*)malloc(nspe *sizeof(Float_t)); - P0spe=(Float_t*)malloc(nspe *sizeof(Float_t));; - Nxmult=(UChar_t*)malloc(nspe *sizeof(UChar_t)); - Nymult=(UChar_t*)malloc(nspe *sizeof(UChar_t)); - Istripx=(UShort_t*)malloc(nstr *sizeof(UShort_t)); - Qstripx=(Float_t*)malloc(nstr *sizeof(Float_t)); - Xstripx=(Float_t*)malloc(nstr *sizeof(Float_t)); - Npstripx=(UChar_t*)malloc(nstr *sizeof(UChar_t)); - Ntstripx=(UChar_t*)malloc(nstr *sizeof(UChar_t)); - Npstripy=(UChar_t*)malloc(nstr *sizeof(UChar_t)); - Ntstripy=(UChar_t*)malloc(nstr *sizeof(UChar_t)); - Istripy=(UShort_t*)malloc(nstr *sizeof(UShort_t)); - Qstripy=(Float_t*)malloc(nstr *sizeof(Float_t)); - Ystripy=(Float_t*)malloc(nstr *sizeof(Float_t)); - Icapl=(UChar_t*)malloc(ncal *sizeof(UChar_t)); - Icasi=(UChar_t*)malloc(ncal *sizeof(UChar_t)); - Icast=(UChar_t*)malloc(ncal *sizeof(UChar_t)); - Xincal=(Float_t*)malloc(ncal *sizeof(Float_t)); - Yincal=(Float_t*)malloc(ncal *sizeof(Float_t)); - Zincal=(Float_t*)malloc(ncal *sizeof(Float_t)); - Erelcal=(Float_t*)malloc(ncal *sizeof(Float_t)); - Itubend=(UChar_t*)malloc(nnd *sizeof(UChar_t)); - Iparnd=(UChar_t*)malloc(nnd *sizeof(UChar_t)); - Xinnd=(Float_t*)malloc(nnd *sizeof(Float_t)); - Yinnd=(Float_t*)malloc(nnd *sizeof(Float_t)); - Zinnd=(Float_t*)malloc(nnd *sizeof(Float_t)); - Xoutnd=(Float_t*)malloc(nnd *sizeof(Float_t)); - Youtnd=(Float_t*)malloc(nnd *sizeof(Float_t)); - Zoutnd=(Float_t*)malloc(nnd *sizeof(Float_t)); - Erelnd=(Float_t*)malloc(nnd *sizeof(Float_t)); - Timend=(Float_t*)malloc(nnd *sizeof(Float_t)); - Pathnd=(Float_t*)malloc(nnd *sizeof(Float_t)); - P0nd=(Float_t*)malloc(nnd *sizeof(Float_t)); - Iparcard=(UChar_t*)malloc(ncar *sizeof(UChar_t)); - Icard=(UChar_t*)malloc(ncar *sizeof(UChar_t)); - Xincard=(Float_t*)malloc(ncar *sizeof(Float_t)); - Yincard=(Float_t*)malloc(ncar *sizeof(Float_t)); - Zincard=(Float_t*)malloc(ncar *sizeof(Float_t)); - Xoutcard=(Float_t*)malloc(ncar *sizeof(Float_t)); - Youtcard=(Float_t*)malloc(ncar *sizeof(Float_t)); - Zoutcard=(Float_t*)malloc(ncar *sizeof(Float_t)); - Erelcard=(Float_t*)malloc(ncar *sizeof(Float_t)); - Timecard=(Float_t*)malloc(ncar *sizeof(Float_t)); - Pathcard=(Float_t*)malloc(ncar *sizeof(Float_t)); - P0card=(Float_t*)malloc(ncar *sizeof(Float_t)); + Ipltof=(UChar_t*)malloc(*ntof *sizeof(UChar_t)); + Ipaddle=(UChar_t*)malloc(*ntof *sizeof(UChar_t)); + Ipartof=(UShort_t*)malloc(*ntof *sizeof(UShort_t)); + // Ipartof=(UChar_t*)malloc(*ntof *sizeof(UChar_t));//DPMJET + Xintof=(Float_t*)malloc(*ntof *sizeof(Float_t)); + Yintof=(Float_t*)malloc(*ntof *sizeof(Float_t)); + Zintof=(Float_t*)malloc(*ntof *sizeof(Float_t)); + Xouttof=(Float_t*)malloc(*ntof *sizeof(Float_t)); + Youttof=(Float_t*)malloc(*ntof *sizeof(Float_t)); + Zouttof=(Float_t*)malloc(*ntof *sizeof(Float_t)); + Ereltof=(Float_t*)malloc(*ntof *sizeof(Float_t)); + Timetof=(Float_t*)malloc(*ntof *sizeof(Float_t)); + Pathtof=(Float_t*)malloc(*ntof *sizeof(Float_t)); + P0tof=(Float_t*)malloc(*ntof *sizeof(Float_t)); + Iparcat=(UChar_t*)malloc(*ncat *sizeof(UChar_t)); + Icat=(UChar_t*)malloc(*ncat *sizeof(UChar_t)); + Xincat=(Float_t*)malloc(*ncat *sizeof(Float_t)); + Yincat=(Float_t*)malloc(*ncat *sizeof(Float_t)); + Zincat=(Float_t*)malloc(*ncat *sizeof(Float_t)); + Xoutcat=(Float_t*)malloc(*ncat *sizeof(Float_t)); + Youtcat=(Float_t*)malloc(*ncat *sizeof(Float_t)); + Zoutcat=(Float_t*)malloc(*ncat *sizeof(Float_t)); + Erelcat=(Float_t*)malloc(*ncat *sizeof(Float_t)); + Timecat=(Float_t*)malloc(*ncat *sizeof(Float_t)); + Pathcat=(Float_t*)malloc(*ncat *sizeof(Float_t)); + P0cat=(Float_t*)malloc(*ncat *sizeof(Float_t)); + Iparcas=(UChar_t*)malloc(*ncas *sizeof(UChar_t)); + Icas=(UChar_t*)malloc(*ncas *sizeof(UChar_t)); + Xincas=(Float_t*)malloc(*ncas *sizeof(Float_t)); + Yincas=(Float_t*)malloc(*ncas *sizeof(Float_t)); + Zincas=(Float_t*)malloc(*ncas *sizeof(Float_t)); + Xoutcas=(Float_t*)malloc(*ncas *sizeof(Float_t)); + Youtcas=(Float_t*)malloc(*ncas *sizeof(Float_t)); + Zoutcas=(Float_t*)malloc(*ncas *sizeof(Float_t)); + Erelcas=(Float_t*)malloc(*ncas *sizeof(Float_t)); + Timecas=(Float_t*)malloc(*ncas *sizeof(Float_t)); + Pathcas=(Float_t*)malloc(*ncas *sizeof(Float_t)); + P0cas=(Float_t*)malloc(*ncas *sizeof(Float_t)); + // Iparspe=(UShort_t*)malloc(*nspe *sizeof(UShort_t)); + // Iparspe=(UChar_t*)malloc(*nspe *sizeof(UChar_t)); + Itrpb=(UChar_t*)malloc(*nspe *sizeof(UChar_t)); + Itrsl=(UChar_t*)malloc(*nspe *sizeof(UChar_t)); + Itspa=(UChar_t*)malloc(*nspe *sizeof(UChar_t)); + Xinspe=(Float_t*)malloc(*nspe *sizeof(Float_t)); + Yinspe=(Float_t*)malloc(*nspe *sizeof(Float_t)); + Zinspe=(Float_t*)malloc(*nspe *sizeof(Float_t)); + Xoutspe=(Float_t*)malloc(*nspe *sizeof(Float_t)); + Youtspe=(Float_t*)malloc(*nspe *sizeof(Float_t)); + Zoutspe=(Float_t*)malloc(*nspe *sizeof(Float_t)); + Xavspe=(Float_t*)malloc(*nspe *sizeof(Float_t)); + Yavspe=(Float_t*)malloc(*nspe *sizeof(Float_t)); + Zavspe=(Float_t*)malloc(*nspe *sizeof(Float_t)); + Erelspe=(Float_t*)malloc(*nspe *sizeof(Float_t)); + Pathspe=(Float_t*)malloc(*nspe *sizeof(Float_t)); + P0spe=(Float_t*)malloc(*nspe *sizeof(Float_t));; + Nxmult=(UChar_t*)malloc(*nspe *sizeof(UChar_t)); + Nymult=(UChar_t*)malloc(*nspe *sizeof(UChar_t)); + Istripx=(UShort_t*)malloc(*nstr *sizeof(UShort_t)); + Qstripx=(Float_t*)malloc(*nstr *sizeof(Float_t)); + Xstripx=(Float_t*)malloc(*nstr *sizeof(Float_t)); + Npstripx=(UChar_t*)malloc(*nstr *sizeof(UChar_t)); + Ntstripx=(UChar_t*)malloc(*nstr *sizeof(UChar_t)); + Npstripy=(UChar_t*)malloc(*nstr *sizeof(UChar_t)); + Ntstripy=(UChar_t*)malloc(*nstr *sizeof(UChar_t)); + Istripy=(UShort_t*)malloc(*nstr *sizeof(UShort_t)); + Qstripy=(Float_t*)malloc(*nstr *sizeof(Float_t)); + Ystripy=(Float_t*)malloc(*nstr *sizeof(Float_t)); + Icapl=(UChar_t*)malloc(*ncal *sizeof(UChar_t)); + Icasi=(UChar_t*)malloc(*ncal *sizeof(UChar_t)); + Icast=(UChar_t*)malloc(*ncal *sizeof(UChar_t)); + Xincal=(Float_t*)malloc(*ncal *sizeof(Float_t)); + Yincal=(Float_t*)malloc(*ncal *sizeof(Float_t)); + Zincal=(Float_t*)malloc(*ncal *sizeof(Float_t)); + Erelcal=(Float_t*)malloc(*ncal *sizeof(Float_t)); + Itubend=(UChar_t*)malloc(*nnd *sizeof(UChar_t)); + Iparnd=(UChar_t*)malloc(*nnd *sizeof(UChar_t)); + Xinnd=(Float_t*)malloc(*nnd *sizeof(Float_t)); + Yinnd=(Float_t*)malloc(*nnd *sizeof(Float_t)); + Zinnd=(Float_t*)malloc(*nnd *sizeof(Float_t)); + Xoutnd=(Float_t*)malloc(*nnd *sizeof(Float_t)); + Youtnd=(Float_t*)malloc(*nnd *sizeof(Float_t)); + Zoutnd=(Float_t*)malloc(*nnd *sizeof(Float_t)); + Erelnd=(Float_t*)malloc(*nnd *sizeof(Float_t)); + Timend=(Float_t*)malloc(*nnd *sizeof(Float_t)); + Pathnd=(Float_t*)malloc(*nnd *sizeof(Float_t)); + P0nd=(Float_t*)malloc(*nnd *sizeof(Float_t)); + Iparcard=(UChar_t*)malloc(*ncar *sizeof(UChar_t)); + Icard=(UChar_t*)malloc(*ncar *sizeof(UChar_t)); + Xincard=(Float_t*)malloc(*ncar *sizeof(Float_t)); + Yincard=(Float_t*)malloc(*ncar *sizeof(Float_t)); + Zincard=(Float_t*)malloc(*ncar *sizeof(Float_t)); + Xoutcard=(Float_t*)malloc(*ncar *sizeof(Float_t)); + Youtcard=(Float_t*)malloc(*ncar *sizeof(Float_t)); + Zoutcard=(Float_t*)malloc(*ncar *sizeof(Float_t)); + Erelcard=(Float_t*)malloc(*ncar *sizeof(Float_t)); + Timecard=(Float_t*)malloc(*ncar *sizeof(Float_t)); + Pathcard=(Float_t*)malloc(*ncar *sizeof(Float_t)); + P0card=(Float_t*)malloc(*ncar *sizeof(Float_t)); @@ -234,7 +227,7 @@ if(fhBookTree->GetBranch("Pathcas"))fhBookTree->SetBranchAddress("Pathcas",Pathcas); if(fhBookTree->GetBranch("P0cas"))fhBookTree->SetBranchAddress("P0cas",P0cas); if(fhBookTree->GetBranch("Nthspe"))fhBookTree->SetBranchAddress("Nthspe",&Nthspe); - if(fhBookTree->GetBranch("Iparspe"))fhBookTree->SetBranchAddress("Iparspe",Iparspe); + // if(fhBookTree->GetBranch("Iparspe"))fhBookTree->SetBranchAddress("Iparspe",Iparspe); if(fhBookTree->GetBranch("Itrpb"))fhBookTree->SetBranchAddress("Itrpb",Itrpb); if(fhBookTree->GetBranch("Itrsl"))fhBookTree->SetBranchAddress("Itrsl",Itrsl); if(fhBookTree->GetBranch("Itspa"))fhBookTree->SetBranchAddress("Itspa",Itspa); @@ -336,10 +329,6 @@ DigitizePSCU(length,0x13,fDataPSCU); AddPadding(); WriteTrackCalib(); - - DigitizeRunHeader(); - WriteRunHeader(); - LoadMipCor(); // some initialization of parameters -not used now- // end loading, digitizing and writing tracker calibration // TOF ------ read calibration file (get A1, A2, lambda1, lambda2) @@ -350,7 +339,7 @@ lambda1=(float *)malloc(np *sizeof(float)); lambda2=(float *)malloc(np *sizeof(float)); LoadTOFCalib(np,atte1,atte2,lambda1,lambda2); - TF1 *attenAC = new TF1("fAttAC",".825+.64*atan(9.8/x)",0.,45.); + attenAC = new TF1("fAttAC",".825+.64*atan(9.8/x)",0.,45.); //end tof calib // // loops over the events @@ -358,13 +347,14 @@ Int_t nentries = fhBookTree->GetEntriesFast(); Long64_t nbytes = 0; - for (Int_t i=0; iGetEntry(i); + for (Int_t i=0; iGetEntry(i); + fEvent=i; // cecilia for calo compress mode // read detectors sequentially: // http://www.ts.infn.it/fileadmin/documents/physics/experiments/wizard/cpu/gen_arch/RM_Acquisition.pdf // on pamelatov: /cvs/yoda/techmodel/physics/NeutronDetectorReader.cpp - DigitizeTOF(np,atte1,atte2,lambda1,lambda2); - DigitizeAC(attenAC); + DigitizeTOF(np,atte1,atte2,lambda1,lambda2); + DigitizeAC(); DigitizeCALO(); DigitizeTrack(); DigitizeS4(); @@ -379,11 +369,9 @@ UInt_t length=2*(fCALOlength+fACbuffer+fTracklength+fNDbuffer+fS4buffer)+fPadding+fTOFbuffer+fTRIGGERbuffer; //UInt_t length=2*(fCALOlength+fACbuffer+fTracklength+fNDbuffer)+fPadding+fTOFbuffer+fTRIGGERbuffer; DigitizePSCU(length,0x10,fDataPSCU); - if ((i%1000)==0) cout << "writing event " << i << endl; + if ((i%1000)==0)cout << "writing event " << i << endl; WriteData(); } - DigitizeRunTrailer(); - WriteRunTrailer(); fOutputfile.close(); cout << "files closed" << endl;