--- PamelaDigitizer/Digitizer.cxx 2008/05/21 09:50:43 1.7 +++ PamelaDigitizer/Digitizer.cxx 2008/06/08 06:33:45 1.10 @@ -39,7 +39,7 @@ }; // -Digitizer::Digitizer(TTree* tree, char* &file_raw){ +Digitizer::Digitizer(TTree* tree, char* &file_raw,int nspe,int ntof,int ncat,int ncas,int ncar,int ncal,int nnd,int nstr){ fhBookTree = tree; fFilename = file_raw; fCounter = 0; @@ -80,6 +80,109 @@ 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)); + + + // prepare tree//modified by E.Vannuccini 03/08 if(fhBookTree->GetBranch("Irun"))fhBookTree->SetBranchAddress("Irun",&Irun); if(fhBookTree->GetBranch("Ievnt"))fhBookTree->SetBranchAddress("Ievnt",&Ievnt); @@ -91,7 +194,7 @@ if(fhBookTree->GetBranch("Phi"))fhBookTree->SetBranchAddress("Phi",&Phi); if(fhBookTree->GetBranch("P0"))fhBookTree->SetBranchAddress("P0",&P0); if(fhBookTree->GetBranch("Nthtof"))fhBookTree->SetBranchAddress("Nthtof",&Nthtof); - if(fhBookTree->GetBranch("Ipltof"))fhBookTree->SetBranchAddress("Ipltof",Ipltof); + if(fhBookTree->GetBranch("Ipltof"))fhBookTree->SetBranchAddress("Ipltof",Ipltof);/////////////////////////// if(fhBookTree->GetBranch("Ipaddle"))fhBookTree->SetBranchAddress("Ipaddle",Ipaddle); if(fhBookTree->GetBranch("Ipartof"))fhBookTree->SetBranchAddress("Ipartof",Ipartof); if(fhBookTree->GetBranch("Xintof"))fhBookTree->SetBranchAddress("Xintof",Xintof); @@ -119,7 +222,7 @@ if(fhBookTree->GetBranch("P0cat"))fhBookTree->SetBranchAddress("P0cat",P0cat); if(fhBookTree->GetBranch("Nthcas"))fhBookTree->SetBranchAddress("Nthcas",&Nthcas); if(fhBookTree->GetBranch("Iparcas"))fhBookTree->SetBranchAddress("Iparcas",Iparcas); - if(fhBookTree->GetBranch("Icas"))fhBookTree->SetBranchAddress("Icas",Icas); + if(fhBookTree->GetBranch("Icas"))fhBookTree->SetBranchAddress("Icas",Icas);/////////////////////////////// if(fhBookTree->GetBranch("Xincas"))fhBookTree->SetBranchAddress("Xincas",Xincas); if(fhBookTree->GetBranch("Yincas"))fhBookTree->SetBranchAddress("Yincas",Yincas); if(fhBookTree->GetBranch("Zincas"))fhBookTree->SetBranchAddress("Zincas",Zincas); @@ -159,7 +262,7 @@ if(fhBookTree->GetBranch("Npstripy"))fhBookTree->SetBranchAddress("Npstripy",Npstripy); if(fhBookTree->GetBranch("Ntstripy"))fhBookTree->SetBranchAddress("Ntstripy",Ntstripy); if(fhBookTree->GetBranch("Istripy"))fhBookTree->SetBranchAddress("Istripy",Istripy); - if(fhBookTree->GetBranch("Qstripy"))fhBookTree->SetBranchAddress("Qstripy",Qstripy); + if(fhBookTree->GetBranch("Qstripy"))fhBookTree->SetBranchAddress("Qstripy",Qstripy);/////////////////////// if(fhBookTree->GetBranch("Ystripy"))fhBookTree->SetBranchAddress("Ystripy",Ystripy); if(fhBookTree->GetBranch("Nthcali"))fhBookTree->SetBranchAddress("Nthcali",&Nthcali); if(fhBookTree->GetBranch("Icaplane"))fhBookTree->SetBranchAddress("Icaplane",Icaplane); @@ -177,7 +280,7 @@ if(fhBookTree->GetBranch("Nthnd"))fhBookTree->SetBranchAddress("Nthnd",&Nthnd); if(fhBookTree->GetBranch("Itubend"))fhBookTree->SetBranchAddress("Itubend",Itubend); if(fhBookTree->GetBranch("Iparnd"))fhBookTree->SetBranchAddress("Iparnd",Iparnd); - if(fhBookTree->GetBranch("Xinnd"))fhBookTree->SetBranchAddress("Xinnd",Xinnd); + if(fhBookTree->GetBranch("Xinnd"))fhBookTree->SetBranchAddress("Xinnd",Xinnd);///////////////////////// if(fhBookTree->GetBranch("Yinnd"))fhBookTree->SetBranchAddress("Yinnd",Yinnd); if(fhBookTree->GetBranch("Zinnd"))fhBookTree->SetBranchAddress("Zinnd",Zinnd); if(fhBookTree->GetBranch("Xoutnd"))fhBookTree->SetBranchAddress("Xoutnd",Xoutnd); @@ -187,19 +290,19 @@ if(fhBookTree->GetBranch("Timend"))fhBookTree->SetBranchAddress("Timend",Timend); if(fhBookTree->GetBranch("Pathnd"))fhBookTree->SetBranchAddress("Pathnd",Pathnd); if(fhBookTree->GetBranch("P0nd"))fhBookTree->SetBranchAddress("P0nd",P0nd); - if(fhBookTree->GetBranch("Nthcard"))fhBookTree->SetBranchAddress("Nthcard",&Nthcard); + if(fhBookTree->GetBranch("Nthcard"))fhBookTree->SetBranchAddress("Nthcard",&Nthcard);///////////////////// if(fhBookTree->GetBranch("Iparcard"))fhBookTree->SetBranchAddress("Iparcard",Iparcard); if(fhBookTree->GetBranch("Icard"))fhBookTree->SetBranchAddress("Icard",Icard); if(fhBookTree->GetBranch("Xincard"))fhBookTree->SetBranchAddress("Xincard",Xincard); if(fhBookTree->GetBranch("Yincard"))fhBookTree->SetBranchAddress("Yincard",Yincard); if(fhBookTree->GetBranch("Zincard"))fhBookTree->SetBranchAddress("Zincard",Zincard); if(fhBookTree->GetBranch("Xoutcard"))fhBookTree->SetBranchAddress("Xoutcard",Xoutcard); - if(fhBookTree->GetBranch("Youtcard"))fhBookTree->SetBranchAddress("Youtcard",Youtcard); + if(fhBookTree->GetBranch("Youtcard"))fhBookTree->SetBranchAddress("Youtcard",Youtcard);///////////////// if(fhBookTree->GetBranch("Zoutcard"))fhBookTree->SetBranchAddress("Zoutcard",Zoutcard); if(fhBookTree->GetBranch("Erelcard"))fhBookTree->SetBranchAddress("Erelcard",Erelcard); if(fhBookTree->GetBranch("Timecard"))fhBookTree->SetBranchAddress("Timecard",Timecard); if(fhBookTree->GetBranch("Pathcard"))fhBookTree->SetBranchAddress("Pathcard",Pathcard); - if(fhBookTree->GetBranch("P0card"))fhBookTree->SetBranchAddress("P0card",P0card); + // if(fhBookTree->GetBranch("P0card"))fhBookTree->SetBranchAddress("P0card",P0card); // fhBookTree->SetBranchStatus("*",0); //modified by E.Vannuccini 03/08 } @@ -241,12 +344,13 @@ // end loading, digitizing and writing tracker calibration // TOF ------ read calibration file (get A1, A2, lambda1, lambda2) const int np=48; - Float_t *atte1,*atte2,*lambda1,*lambda2; + float *atte1,*atte2,*lambda1,*lambda2; atte1=(float *)malloc(np *sizeof(float)); atte2=(float *)malloc(np *sizeof(float)); 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.); //end tof calib // // loops over the events @@ -254,51 +358,38 @@ Int_t nentries = fhBookTree->GetEntriesFast(); Long64_t nbytes = 0; - for (Int_t i=0; iGetEntry(i); - // 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 - //DigitizeTRIGGER(); - DigitizeTOF(np,atte1,atte2,lambda1,lambda2); - DigitizeAC(); - DigitizeCALO(); - DigitizeTrack(); - DigitizeS4(); - DigitizeND(); - // - // Add padding to 64 bits - // - AddPadding(); - // - // Create CPU header, we need packet type (0x10 = physics data) and packet length. - // - 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%100 ) std::cout << "writing event " << i << endl; - WriteData(); - }; - + for (Int_t i=0; iGetEntry(i); + // 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); + DigitizeCALO(); + DigitizeTrack(); + DigitizeS4(); + DigitizeND(); + // + // Add padding to 64 bits + // + AddPadding(); + // + // Create CPU header, we need packet type (0x10 = physics data) and packet length. + // + 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; + WriteData(); + } DigitizeRunTrailer(); WriteRunTrailer(); - + fOutputfile.close(); - std::cout << "files closed" << endl << flush; - + cout << "files closed" << endl; }; -//void Digitizer::DigitizeTRIGGER() { - //fDataTrigger: 152 bytes - // corrected 30/11/'07 SO (was 153) - //for (Int_t j=0; j < 152; j++) - // fDataTrigger[j]=0x00; -//}; - - - void Digitizer::ReadData(){ UShort_t InData[64];