/[PAMELA software]/PamelaDigitizer/Digitizer.cxx
ViewVC logotype

Diff of /PamelaDigitizer/Digitizer.cxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by pamelats, Sun Jun 8 06:33:45 2008 UTC revision 1.11 by pamelats, Wed Oct 15 14:03:20 2008 UTC
# Line 4  Line 4 
4  //  //
5  // NB: Check length  physics  packet [packet type (0x10 = physics data)]  // NB: Check length  physics  packet [packet type (0x10 = physics data)]
6  //  //
 #include <sstream>  
 #include <fstream>  
 #include <stdlib.h>  
 #include <stdio.h>  
 #include <string.h>  
 #include <ctype.h>  
 #include <time.h>  
 #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"  
 //  
7  #include "Digitizer.h"  #include "Digitizer.h"
8  #include "CRC.h"  
 //  
 #include <PamelaRun.h>  
 #include <physics/calorimeter/CalorimeterEvent.h>  
 #include <CalibCalPedEvent.h>  
 #include "GLTables.h"  
 //  
9  extern "C"{  extern "C"{
10    short crc(short, short);    short crc(short, short);
11  };  };
12  //  //
13    
14  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){
15      nspe=new int[1];
16      ntof=new int[1];
17      ncat=new int[1];
18      ncas=new int[1];
19      ncar=new int[1];
20      ncal=new int[1];
21      nnd=new int[1];
22      nstr=new int[1];
23    
24      *nspe=nspe1;
25      *ntof=ntof1;
26      *ncat=ncat1;
27      *ncas=ncas1;
28      *ncar=ncar1;
29      *ncal=ncal1;
30      *nnd=nnd1;
31      *nstr=nstr1;
32    
33    fhBookTree = tree;    fhBookTree = tree;
34    fFilename =  file_raw;    fFilename =  file_raw;
35    fCounter = 0;    fCounter = 0;
# Line 80  Digitizer::Digitizer(TTree* tree, char* Line 70  Digitizer::Digitizer(TTree* tree, char*
70        
71    std:: cout << "preparing tree" << endl;    std:: cout << "preparing tree" << endl;
72    
73    ntf=(int*)malloc(1 *sizeof(int));    Ipltof=(UChar_t*)malloc(*ntof *sizeof(UChar_t));
74    *ntf=ntof;    Ipaddle=(UChar_t*)malloc(*ntof *sizeof(UChar_t));
75    Ipltof=(UChar_t*)malloc(ntof *sizeof(UChar_t));    Ipartof=(UShort_t*)malloc(*ntof *sizeof(UShort_t));
76    Ipaddle=(UChar_t*)malloc(ntof *sizeof(UChar_t));    //  Ipartof=(UChar_t*)malloc(*ntof *sizeof(UChar_t));//DPMJET
77    // Ipartof=(UShort_t*)malloc(ntof *sizeof(UShort_t));    Xintof=(Float_t*)malloc(*ntof *sizeof(Float_t));
78    Ipartof=(UChar_t*)malloc(ntof *sizeof(UChar_t));    Yintof=(Float_t*)malloc(*ntof *sizeof(Float_t));
79    Xintof=(Float_t*)malloc(ntof *sizeof(Float_t));    Zintof=(Float_t*)malloc(*ntof *sizeof(Float_t));
80    Yintof=(Float_t*)malloc(ntof *sizeof(Float_t));    Xouttof=(Float_t*)malloc(*ntof *sizeof(Float_t));
81    Zintof=(Float_t*)malloc(ntof *sizeof(Float_t));    Youttof=(Float_t*)malloc(*ntof *sizeof(Float_t));
82    Xouttof=(Float_t*)malloc(ntof *sizeof(Float_t));    Zouttof=(Float_t*)malloc(*ntof *sizeof(Float_t));
83    Youttof=(Float_t*)malloc(ntof *sizeof(Float_t));    Ereltof=(Float_t*)malloc(*ntof *sizeof(Float_t));
84    Zouttof=(Float_t*)malloc(ntof *sizeof(Float_t));    Timetof=(Float_t*)malloc(*ntof *sizeof(Float_t));
85    Ereltof=(Float_t*)malloc(ntof *sizeof(Float_t));    Pathtof=(Float_t*)malloc(*ntof *sizeof(Float_t));
86    Timetof=(Float_t*)malloc(ntof *sizeof(Float_t));    P0tof=(Float_t*)malloc(*ntof *sizeof(Float_t));
87    Pathtof=(Float_t*)malloc(ntof *sizeof(Float_t));    Iparcat=(UChar_t*)malloc(*ncat *sizeof(UChar_t));
88    P0tof=(Float_t*)malloc(ntof *sizeof(Float_t));    Icat=(UChar_t*)malloc(*ncat *sizeof(UChar_t));
89    Iparcat=(UChar_t*)malloc(ncat *sizeof(UChar_t));    Xincat=(Float_t*)malloc(*ncat *sizeof(Float_t));
90    Icat=(UChar_t*)malloc(ncat *sizeof(UChar_t));    Yincat=(Float_t*)malloc(*ncat *sizeof(Float_t));
91    Xincat=(Float_t*)malloc(ncat *sizeof(Float_t));    Zincat=(Float_t*)malloc(*ncat *sizeof(Float_t));
92    Yincat=(Float_t*)malloc(ncat *sizeof(Float_t));    Xoutcat=(Float_t*)malloc(*ncat *sizeof(Float_t));
93    Zincat=(Float_t*)malloc(ncat *sizeof(Float_t));    Youtcat=(Float_t*)malloc(*ncat *sizeof(Float_t));
94    Xoutcat=(Float_t*)malloc(ncat *sizeof(Float_t));    Zoutcat=(Float_t*)malloc(*ncat *sizeof(Float_t));
95    Youtcat=(Float_t*)malloc(ncat *sizeof(Float_t));    Erelcat=(Float_t*)malloc(*ncat *sizeof(Float_t));
96    Zoutcat=(Float_t*)malloc(ncat *sizeof(Float_t));    Timecat=(Float_t*)malloc(*ncat *sizeof(Float_t));
97    Erelcat=(Float_t*)malloc(ncat *sizeof(Float_t));    Pathcat=(Float_t*)malloc(*ncat *sizeof(Float_t));
98    Timecat=(Float_t*)malloc(ncat *sizeof(Float_t));    P0cat=(Float_t*)malloc(*ncat *sizeof(Float_t));
99    Pathcat=(Float_t*)malloc(ncat *sizeof(Float_t));    Iparcas=(UChar_t*)malloc(*ncas *sizeof(UChar_t));
100    P0cat=(Float_t*)malloc(ncat *sizeof(Float_t));    Icas=(UChar_t*)malloc(*ncas *sizeof(UChar_t));
101    Iparcas=(UChar_t*)malloc(ncas *sizeof(UChar_t));    Xincas=(Float_t*)malloc(*ncas *sizeof(Float_t));
102    Icas=(UChar_t*)malloc(ncas *sizeof(UChar_t));    Yincas=(Float_t*)malloc(*ncas *sizeof(Float_t));
103    Xincas=(Float_t*)malloc(ncas *sizeof(Float_t));    Zincas=(Float_t*)malloc(*ncas *sizeof(Float_t));
104    Yincas=(Float_t*)malloc(ncas *sizeof(Float_t));    Xoutcas=(Float_t*)malloc(*ncas *sizeof(Float_t));
105    Zincas=(Float_t*)malloc(ncas *sizeof(Float_t));    Youtcas=(Float_t*)malloc(*ncas *sizeof(Float_t));
106    Xoutcas=(Float_t*)malloc(ncas *sizeof(Float_t));    Zoutcas=(Float_t*)malloc(*ncas *sizeof(Float_t));
107    Youtcas=(Float_t*)malloc(ncas *sizeof(Float_t));    Erelcas=(Float_t*)malloc(*ncas *sizeof(Float_t));
108    Zoutcas=(Float_t*)malloc(ncas *sizeof(Float_t));    Timecas=(Float_t*)malloc(*ncas *sizeof(Float_t));
109    Erelcas=(Float_t*)malloc(ncas *sizeof(Float_t));    Pathcas=(Float_t*)malloc(*ncas *sizeof(Float_t));
110    Timecas=(Float_t*)malloc(ncas *sizeof(Float_t));    P0cas=(Float_t*)malloc(*ncas *sizeof(Float_t));
111    Pathcas=(Float_t*)malloc(ncas *sizeof(Float_t));    //  Iparspe=(UShort_t*)malloc(*nspe *sizeof(UShort_t));
112    P0cas=(Float_t*)malloc(ncas *sizeof(Float_t));    //  Iparspe=(UChar_t*)malloc(*nspe *sizeof(UChar_t));
113    //  Iparspe=(UShort_t*)malloc(nspe *sizeof(UShort_t));    Itrpb=(UChar_t*)malloc(*nspe *sizeof(UChar_t));
114    Iparspe=(UChar_t*)malloc(nspe *sizeof(UChar_t));    Itrsl=(UChar_t*)malloc(*nspe *sizeof(UChar_t));
115    Itrpb=(UChar_t*)malloc(nspe *sizeof(UChar_t));    Itspa=(UChar_t*)malloc(*nspe *sizeof(UChar_t));
116    Itrsl=(UChar_t*)malloc(nspe *sizeof(UChar_t));    Xinspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
117    Itspa=(UChar_t*)malloc(nspe *sizeof(UChar_t));    Yinspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
118    Xinspe=(Float_t*)malloc(nspe *sizeof(Float_t));    Zinspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
119    Yinspe=(Float_t*)malloc(nspe *sizeof(Float_t));    Xoutspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
120    Zinspe=(Float_t*)malloc(nspe *sizeof(Float_t));    Youtspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
121    Xoutspe=(Float_t*)malloc(nspe *sizeof(Float_t));    Zoutspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
122    Youtspe=(Float_t*)malloc(nspe *sizeof(Float_t));    Xavspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
123    Zoutspe=(Float_t*)malloc(nspe *sizeof(Float_t));    Yavspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
124    Xavspe=(Float_t*)malloc(nspe *sizeof(Float_t));    Zavspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
125    Yavspe=(Float_t*)malloc(nspe *sizeof(Float_t));    Erelspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
126    Zavspe=(Float_t*)malloc(nspe *sizeof(Float_t));    Pathspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
127    Erelspe=(Float_t*)malloc(nspe *sizeof(Float_t));    P0spe=(Float_t*)malloc(*nspe *sizeof(Float_t));;
128    Pathspe=(Float_t*)malloc(nspe *sizeof(Float_t));    Nxmult=(UChar_t*)malloc(*nspe *sizeof(UChar_t));
129    P0spe=(Float_t*)malloc(nspe *sizeof(Float_t));;    Nymult=(UChar_t*)malloc(*nspe *sizeof(UChar_t));
130    Nxmult=(UChar_t*)malloc(nspe *sizeof(UChar_t));    Istripx=(UShort_t*)malloc(*nstr *sizeof(UShort_t));
131    Nymult=(UChar_t*)malloc(nspe *sizeof(UChar_t));    Qstripx=(Float_t*)malloc(*nstr *sizeof(Float_t));
132    Istripx=(UShort_t*)malloc(nstr *sizeof(UShort_t));    Xstripx=(Float_t*)malloc(*nstr *sizeof(Float_t));
133    Qstripx=(Float_t*)malloc(nstr *sizeof(Float_t));    Npstripx=(UChar_t*)malloc(*nstr *sizeof(UChar_t));
134    Xstripx=(Float_t*)malloc(nstr *sizeof(Float_t));    Ntstripx=(UChar_t*)malloc(*nstr *sizeof(UChar_t));
135    Npstripx=(UChar_t*)malloc(nstr *sizeof(UChar_t));    Npstripy=(UChar_t*)malloc(*nstr *sizeof(UChar_t));
136    Ntstripx=(UChar_t*)malloc(nstr *sizeof(UChar_t));    Ntstripy=(UChar_t*)malloc(*nstr *sizeof(UChar_t));
137    Npstripy=(UChar_t*)malloc(nstr *sizeof(UChar_t));    Istripy=(UShort_t*)malloc(*nstr *sizeof(UShort_t));
138    Ntstripy=(UChar_t*)malloc(nstr *sizeof(UChar_t));    Qstripy=(Float_t*)malloc(*nstr *sizeof(Float_t));
139    Istripy=(UShort_t*)malloc(nstr *sizeof(UShort_t));    Ystripy=(Float_t*)malloc(*nstr *sizeof(Float_t));
140    Qstripy=(Float_t*)malloc(nstr *sizeof(Float_t));    Icapl=(UChar_t*)malloc(*ncal *sizeof(UChar_t));
141    Ystripy=(Float_t*)malloc(nstr *sizeof(Float_t));    Icasi=(UChar_t*)malloc(*ncal *sizeof(UChar_t));
142    Icapl=(UChar_t*)malloc(ncal *sizeof(UChar_t));    Icast=(UChar_t*)malloc(*ncal *sizeof(UChar_t));
143    Icasi=(UChar_t*)malloc(ncal *sizeof(UChar_t));    Xincal=(Float_t*)malloc(*ncal *sizeof(Float_t));
144    Icast=(UChar_t*)malloc(ncal *sizeof(UChar_t));    Yincal=(Float_t*)malloc(*ncal *sizeof(Float_t));
145    Xincal=(Float_t*)malloc(ncal *sizeof(Float_t));    Zincal=(Float_t*)malloc(*ncal *sizeof(Float_t));
146    Yincal=(Float_t*)malloc(ncal *sizeof(Float_t));    Erelcal=(Float_t*)malloc(*ncal *sizeof(Float_t));
147    Zincal=(Float_t*)malloc(ncal *sizeof(Float_t));    Itubend=(UChar_t*)malloc(*nnd *sizeof(UChar_t));
148    Erelcal=(Float_t*)malloc(ncal *sizeof(Float_t));    Iparnd=(UChar_t*)malloc(*nnd *sizeof(UChar_t));
149    Itubend=(UChar_t*)malloc(nnd *sizeof(UChar_t));    Xinnd=(Float_t*)malloc(*nnd *sizeof(Float_t));
150    Iparnd=(UChar_t*)malloc(nnd *sizeof(UChar_t));    Yinnd=(Float_t*)malloc(*nnd *sizeof(Float_t));
151    Xinnd=(Float_t*)malloc(nnd *sizeof(Float_t));    Zinnd=(Float_t*)malloc(*nnd *sizeof(Float_t));
152    Yinnd=(Float_t*)malloc(nnd *sizeof(Float_t));    Xoutnd=(Float_t*)malloc(*nnd *sizeof(Float_t));
153    Zinnd=(Float_t*)malloc(nnd *sizeof(Float_t));    Youtnd=(Float_t*)malloc(*nnd *sizeof(Float_t));
154    Xoutnd=(Float_t*)malloc(nnd *sizeof(Float_t));    Zoutnd=(Float_t*)malloc(*nnd *sizeof(Float_t));
155    Youtnd=(Float_t*)malloc(nnd *sizeof(Float_t));    Erelnd=(Float_t*)malloc(*nnd *sizeof(Float_t));
156    Zoutnd=(Float_t*)malloc(nnd *sizeof(Float_t));    Timend=(Float_t*)malloc(*nnd *sizeof(Float_t));
157    Erelnd=(Float_t*)malloc(nnd *sizeof(Float_t));    Pathnd=(Float_t*)malloc(*nnd *sizeof(Float_t));
158    Timend=(Float_t*)malloc(nnd *sizeof(Float_t));    P0nd=(Float_t*)malloc(*nnd *sizeof(Float_t));
159    Pathnd=(Float_t*)malloc(nnd *sizeof(Float_t));    Iparcard=(UChar_t*)malloc(*ncar *sizeof(UChar_t));
160    P0nd=(Float_t*)malloc(nnd *sizeof(Float_t));    Icard=(UChar_t*)malloc(*ncar *sizeof(UChar_t));
161    Iparcard=(UChar_t*)malloc(ncar *sizeof(UChar_t));    Xincard=(Float_t*)malloc(*ncar *sizeof(Float_t));
162    Icard=(UChar_t*)malloc(ncar *sizeof(UChar_t));    Yincard=(Float_t*)malloc(*ncar *sizeof(Float_t));
163    Xincard=(Float_t*)malloc(ncar *sizeof(Float_t));    Zincard=(Float_t*)malloc(*ncar *sizeof(Float_t));
164    Yincard=(Float_t*)malloc(ncar *sizeof(Float_t));    Xoutcard=(Float_t*)malloc(*ncar *sizeof(Float_t));
165    Zincard=(Float_t*)malloc(ncar *sizeof(Float_t));    Youtcard=(Float_t*)malloc(*ncar *sizeof(Float_t));
166    Xoutcard=(Float_t*)malloc(ncar *sizeof(Float_t));    Zoutcard=(Float_t*)malloc(*ncar *sizeof(Float_t));
167    Youtcard=(Float_t*)malloc(ncar *sizeof(Float_t));    Erelcard=(Float_t*)malloc(*ncar *sizeof(Float_t));
168    Zoutcard=(Float_t*)malloc(ncar *sizeof(Float_t));    Timecard=(Float_t*)malloc(*ncar *sizeof(Float_t));
169    Erelcard=(Float_t*)malloc(ncar *sizeof(Float_t));    Pathcard=(Float_t*)malloc(*ncar *sizeof(Float_t));
170    Timecard=(Float_t*)malloc(ncar *sizeof(Float_t));    P0card=(Float_t*)malloc(*ncar *sizeof(Float_t));
   Pathcard=(Float_t*)malloc(ncar *sizeof(Float_t));  
   P0card=(Float_t*)malloc(ncar *sizeof(Float_t));  
171    
172    
173    
# Line 234  Digitizer::Digitizer(TTree* tree, char* Line 222  Digitizer::Digitizer(TTree* tree, char*
222    if(fhBookTree->GetBranch("Pathcas"))fhBookTree->SetBranchAddress("Pathcas",Pathcas);    if(fhBookTree->GetBranch("Pathcas"))fhBookTree->SetBranchAddress("Pathcas",Pathcas);
223    if(fhBookTree->GetBranch("P0cas"))fhBookTree->SetBranchAddress("P0cas",P0cas);    if(fhBookTree->GetBranch("P0cas"))fhBookTree->SetBranchAddress("P0cas",P0cas);
224    if(fhBookTree->GetBranch("Nthspe"))fhBookTree->SetBranchAddress("Nthspe",&Nthspe);    if(fhBookTree->GetBranch("Nthspe"))fhBookTree->SetBranchAddress("Nthspe",&Nthspe);
225    if(fhBookTree->GetBranch("Iparspe"))fhBookTree->SetBranchAddress("Iparspe",Iparspe);    //  if(fhBookTree->GetBranch("Iparspe"))fhBookTree->SetBranchAddress("Iparspe",Iparspe);
226    if(fhBookTree->GetBranch("Itrpb"))fhBookTree->SetBranchAddress("Itrpb",Itrpb);    if(fhBookTree->GetBranch("Itrpb"))fhBookTree->SetBranchAddress("Itrpb",Itrpb);
227    if(fhBookTree->GetBranch("Itrsl"))fhBookTree->SetBranchAddress("Itrsl",Itrsl);    if(fhBookTree->GetBranch("Itrsl"))fhBookTree->SetBranchAddress("Itrsl",Itrsl);
228    if(fhBookTree->GetBranch("Itspa"))fhBookTree->SetBranchAddress("Itspa",Itspa);    if(fhBookTree->GetBranch("Itspa"))fhBookTree->SetBranchAddress("Itspa",Itspa);
# Line 350  void Digitizer::Loop() { Line 338  void Digitizer::Loop() {
338    lambda1=(float *)malloc(np *sizeof(float));    lambda1=(float *)malloc(np *sizeof(float));
339    lambda2=(float *)malloc(np *sizeof(float));    lambda2=(float *)malloc(np *sizeof(float));
340    LoadTOFCalib(np,atte1,atte2,lambda1,lambda2);    LoadTOFCalib(np,atte1,atte2,lambda1,lambda2);
341    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.);
342    //end tof calib    //end tof calib
343    //    //
344    // loops over the events    // loops over the events
# Line 364  void Digitizer::Loop() { Line 352  void Digitizer::Loop() {
352        // http://www.ts.infn.it/fileadmin/documents/physics/experiments/wizard/cpu/gen_arch/RM_Acquisition.pdf        // http://www.ts.infn.it/fileadmin/documents/physics/experiments/wizard/cpu/gen_arch/RM_Acquisition.pdf
353        // on pamelatov: /cvs/yoda/techmodel/physics/NeutronDetectorReader.cpp        // on pamelatov: /cvs/yoda/techmodel/physics/NeutronDetectorReader.cpp
354        DigitizeTOF(np,atte1,atte2,lambda1,lambda2);        DigitizeTOF(np,atte1,atte2,lambda1,lambda2);
355        DigitizeAC(attenAC);        DigitizeAC();
356        DigitizeCALO();        DigitizeCALO();
357        DigitizeTrack();        DigitizeTrack();
358        DigitizeS4();        DigitizeS4();
# Line 379  void Digitizer::Loop() { Line 367  void Digitizer::Loop() {
367        UInt_t length=2*(fCALOlength+fACbuffer+fTracklength+fNDbuffer+fS4buffer)+fPadding+fTOFbuffer+fTRIGGERbuffer;        UInt_t length=2*(fCALOlength+fACbuffer+fTracklength+fNDbuffer+fS4buffer)+fPadding+fTOFbuffer+fTRIGGERbuffer;
368        //UInt_t length=2*(fCALOlength+fACbuffer+fTracklength+fNDbuffer)+fPadding+fTOFbuffer+fTRIGGERbuffer;        //UInt_t length=2*(fCALOlength+fACbuffer+fTracklength+fNDbuffer)+fPadding+fTOFbuffer+fTRIGGERbuffer;
369        DigitizePSCU(length,0x10,fDataPSCU);        DigitizePSCU(length,0x10,fDataPSCU);
370        if ((i%1000)==0) cout << "writing event " << i << endl;        if ((i%1000)==0)cout << "writing event " << i << endl;
371        WriteData();        WriteData();
372    }    }
373    DigitizeRunTrailer();    DigitizeRunTrailer();

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.23