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

Annotation of /PamelaDigitizer/Digitizer.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (hide annotations) (download)
Fri Oct 16 09:15:50 2009 UTC (15 years, 1 month ago) by pizzolot
Branch: MAIN
CVS Tags: HEAD
Changes since 1.13: +7 -1 lines
calorimeter compress mode implemented ; input parameter modified

1 pamelats 1.7 // ------ PAMELA Digitizer ------
2     //
3     // Date, release and how-to: see file Pamelagp2Digits.cxx
4     //
5     // NB: Check length physics packet [packet type (0x10 = physics data)]
6     //
7     #include "Digitizer.h"
8 pamelats 1.11
9 pamelats 1.7 extern "C"{
10     short crc(short, short);
11     };
12     //
13    
14 pizzolot 1.14 Digitizer::Digitizer(TTree* tree, char* &file_raw,
15     int nspe1=200,int ntof1=200,int ncat1=50,
16     int ncas1=50,int ncar1=100,int ncal1=1000,
17     int nnd1=200,int nstr1=1000, int comprcalomod=0){
18    
19 pamelats 1.11 nspe=new int[1];
20     ntof=new int[1];
21     ncat=new int[1];
22     ncas=new int[1];
23     ncar=new int[1];
24     ncal=new int[1];
25     nnd=new int[1];
26     nstr=new int[1];
27    
28     *nspe=nspe1;
29     *ntof=ntof1;
30     *ncat=ncat1;
31     *ncas=ncas1;
32     *ncar=ncar1;
33     *ncal=ncal1;
34     *nnd=nnd1;
35     *nstr=nstr1;
36    
37 pamelats 1.7 fhBookTree = tree;
38     fFilename = file_raw;
39     fCounter = 0;
40     fCounterPhys = 0; // SO 5/12/'07
41     fOBT = 0;
42 pizzolot 1.14 fModCalo = comprcalomod ;
43 pamelats 1.7
44     //
45     // DB connections
46     //
47     TString host = "mysql://localhost/pamelaprod";
48     TString user = "anonymous";
49     TString psw = "";
50     //
51     const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
52     const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
53     const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
54     if ( !pamdbhost ) pamdbhost = "";
55     if ( !pamdbuser ) pamdbuser = "";
56     if ( !pamdbpsw ) pamdbpsw = "";
57     if ( strcmp(pamdbhost,"") ) host = pamdbhost;
58     if ( strcmp(pamdbuser,"") ) user = pamdbuser;
59     if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
60     fDbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
61     //
62     GL_TABLES *glt = new GL_TABLES(host,user,psw);
63     if ( glt->IsConnected(fDbc) ) printf("\n DB INFORMATION:\n SQL: %s Version: %s Host %s Port %i \n\n",fDbc->GetDBMS(),fDbc->ServerInfo(),fDbc->GetHost(),fDbc->GetPort());
64     //
65     // Use UTC in the DB and make timeout bigger
66     //
67     stringstream myquery;
68     myquery.str("");
69     myquery << "SET time_zone='+0:00'";
70     fDbc->Query(myquery.str().c_str());
71     myquery.str("");
72     myquery << "SET wait_timeout=173000;";
73     fDbc->Query(myquery.str().c_str());
74     //
75    
76     std:: cout << "preparing tree" << endl;
77    
78 pamelats 1.11 Ipltof=(UChar_t*)malloc(*ntof *sizeof(UChar_t));
79     Ipaddle=(UChar_t*)malloc(*ntof *sizeof(UChar_t));
80     Ipartof=(UShort_t*)malloc(*ntof *sizeof(UShort_t));
81     // Ipartof=(UChar_t*)malloc(*ntof *sizeof(UChar_t));//DPMJET
82     Xintof=(Float_t*)malloc(*ntof *sizeof(Float_t));
83     Yintof=(Float_t*)malloc(*ntof *sizeof(Float_t));
84     Zintof=(Float_t*)malloc(*ntof *sizeof(Float_t));
85     Xouttof=(Float_t*)malloc(*ntof *sizeof(Float_t));
86     Youttof=(Float_t*)malloc(*ntof *sizeof(Float_t));
87     Zouttof=(Float_t*)malloc(*ntof *sizeof(Float_t));
88     Ereltof=(Float_t*)malloc(*ntof *sizeof(Float_t));
89     Timetof=(Float_t*)malloc(*ntof *sizeof(Float_t));
90     Pathtof=(Float_t*)malloc(*ntof *sizeof(Float_t));
91     P0tof=(Float_t*)malloc(*ntof *sizeof(Float_t));
92     Iparcat=(UChar_t*)malloc(*ncat *sizeof(UChar_t));
93     Icat=(UChar_t*)malloc(*ncat *sizeof(UChar_t));
94     Xincat=(Float_t*)malloc(*ncat *sizeof(Float_t));
95     Yincat=(Float_t*)malloc(*ncat *sizeof(Float_t));
96     Zincat=(Float_t*)malloc(*ncat *sizeof(Float_t));
97     Xoutcat=(Float_t*)malloc(*ncat *sizeof(Float_t));
98     Youtcat=(Float_t*)malloc(*ncat *sizeof(Float_t));
99     Zoutcat=(Float_t*)malloc(*ncat *sizeof(Float_t));
100     Erelcat=(Float_t*)malloc(*ncat *sizeof(Float_t));
101     Timecat=(Float_t*)malloc(*ncat *sizeof(Float_t));
102     Pathcat=(Float_t*)malloc(*ncat *sizeof(Float_t));
103     P0cat=(Float_t*)malloc(*ncat *sizeof(Float_t));
104     Iparcas=(UChar_t*)malloc(*ncas *sizeof(UChar_t));
105     Icas=(UChar_t*)malloc(*ncas *sizeof(UChar_t));
106     Xincas=(Float_t*)malloc(*ncas *sizeof(Float_t));
107     Yincas=(Float_t*)malloc(*ncas *sizeof(Float_t));
108     Zincas=(Float_t*)malloc(*ncas *sizeof(Float_t));
109     Xoutcas=(Float_t*)malloc(*ncas *sizeof(Float_t));
110     Youtcas=(Float_t*)malloc(*ncas *sizeof(Float_t));
111     Zoutcas=(Float_t*)malloc(*ncas *sizeof(Float_t));
112     Erelcas=(Float_t*)malloc(*ncas *sizeof(Float_t));
113     Timecas=(Float_t*)malloc(*ncas *sizeof(Float_t));
114     Pathcas=(Float_t*)malloc(*ncas *sizeof(Float_t));
115     P0cas=(Float_t*)malloc(*ncas *sizeof(Float_t));
116     // Iparspe=(UShort_t*)malloc(*nspe *sizeof(UShort_t));
117     // Iparspe=(UChar_t*)malloc(*nspe *sizeof(UChar_t));
118     Itrpb=(UChar_t*)malloc(*nspe *sizeof(UChar_t));
119     Itrsl=(UChar_t*)malloc(*nspe *sizeof(UChar_t));
120     Itspa=(UChar_t*)malloc(*nspe *sizeof(UChar_t));
121     Xinspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
122     Yinspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
123     Zinspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
124     Xoutspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
125     Youtspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
126     Zoutspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
127     Xavspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
128     Yavspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
129     Zavspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
130     Erelspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
131     Pathspe=(Float_t*)malloc(*nspe *sizeof(Float_t));
132     P0spe=(Float_t*)malloc(*nspe *sizeof(Float_t));;
133     Nxmult=(UChar_t*)malloc(*nspe *sizeof(UChar_t));
134     Nymult=(UChar_t*)malloc(*nspe *sizeof(UChar_t));
135     Istripx=(UShort_t*)malloc(*nstr *sizeof(UShort_t));
136     Qstripx=(Float_t*)malloc(*nstr *sizeof(Float_t));
137     Xstripx=(Float_t*)malloc(*nstr *sizeof(Float_t));
138     Npstripx=(UChar_t*)malloc(*nstr *sizeof(UChar_t));
139     Ntstripx=(UChar_t*)malloc(*nstr *sizeof(UChar_t));
140     Npstripy=(UChar_t*)malloc(*nstr *sizeof(UChar_t));
141     Ntstripy=(UChar_t*)malloc(*nstr *sizeof(UChar_t));
142     Istripy=(UShort_t*)malloc(*nstr *sizeof(UShort_t));
143     Qstripy=(Float_t*)malloc(*nstr *sizeof(Float_t));
144     Ystripy=(Float_t*)malloc(*nstr *sizeof(Float_t));
145     Icapl=(UChar_t*)malloc(*ncal *sizeof(UChar_t));
146     Icasi=(UChar_t*)malloc(*ncal *sizeof(UChar_t));
147     Icast=(UChar_t*)malloc(*ncal *sizeof(UChar_t));
148     Xincal=(Float_t*)malloc(*ncal *sizeof(Float_t));
149     Yincal=(Float_t*)malloc(*ncal *sizeof(Float_t));
150     Zincal=(Float_t*)malloc(*ncal *sizeof(Float_t));
151     Erelcal=(Float_t*)malloc(*ncal *sizeof(Float_t));
152     Itubend=(UChar_t*)malloc(*nnd *sizeof(UChar_t));
153     Iparnd=(UChar_t*)malloc(*nnd *sizeof(UChar_t));
154     Xinnd=(Float_t*)malloc(*nnd *sizeof(Float_t));
155     Yinnd=(Float_t*)malloc(*nnd *sizeof(Float_t));
156     Zinnd=(Float_t*)malloc(*nnd *sizeof(Float_t));
157     Xoutnd=(Float_t*)malloc(*nnd *sizeof(Float_t));
158     Youtnd=(Float_t*)malloc(*nnd *sizeof(Float_t));
159     Zoutnd=(Float_t*)malloc(*nnd *sizeof(Float_t));
160     Erelnd=(Float_t*)malloc(*nnd *sizeof(Float_t));
161     Timend=(Float_t*)malloc(*nnd *sizeof(Float_t));
162     Pathnd=(Float_t*)malloc(*nnd *sizeof(Float_t));
163     P0nd=(Float_t*)malloc(*nnd *sizeof(Float_t));
164     Iparcard=(UChar_t*)malloc(*ncar *sizeof(UChar_t));
165     Icard=(UChar_t*)malloc(*ncar *sizeof(UChar_t));
166     Xincard=(Float_t*)malloc(*ncar *sizeof(Float_t));
167     Yincard=(Float_t*)malloc(*ncar *sizeof(Float_t));
168     Zincard=(Float_t*)malloc(*ncar *sizeof(Float_t));
169     Xoutcard=(Float_t*)malloc(*ncar *sizeof(Float_t));
170     Youtcard=(Float_t*)malloc(*ncar *sizeof(Float_t));
171     Zoutcard=(Float_t*)malloc(*ncar *sizeof(Float_t));
172     Erelcard=(Float_t*)malloc(*ncar *sizeof(Float_t));
173     Timecard=(Float_t*)malloc(*ncar *sizeof(Float_t));
174     Pathcard=(Float_t*)malloc(*ncar *sizeof(Float_t));
175     P0card=(Float_t*)malloc(*ncar *sizeof(Float_t));
176 pamelats 1.8
177    
178    
179 pamelats 1.7 // prepare tree//modified by E.Vannuccini 03/08
180     if(fhBookTree->GetBranch("Irun"))fhBookTree->SetBranchAddress("Irun",&Irun);
181     if(fhBookTree->GetBranch("Ievnt"))fhBookTree->SetBranchAddress("Ievnt",&Ievnt);
182     if(fhBookTree->GetBranch("Ipa"))fhBookTree->SetBranchAddress("Ipa",&Ipa);
183     if(fhBookTree->GetBranch("X0"))fhBookTree->SetBranchAddress("X0",&X0);
184     if(fhBookTree->GetBranch("Y0"))fhBookTree->SetBranchAddress("Y0",&Y0);
185     if(fhBookTree->GetBranch("Z0"))fhBookTree->SetBranchAddress("Z0",&Z0);
186     if(fhBookTree->GetBranch("Theta"))fhBookTree->SetBranchAddress("Theta",&Theta);
187     if(fhBookTree->GetBranch("Phi"))fhBookTree->SetBranchAddress("Phi",&Phi);
188     if(fhBookTree->GetBranch("P0"))fhBookTree->SetBranchAddress("P0",&P0);
189     if(fhBookTree->GetBranch("Nthtof"))fhBookTree->SetBranchAddress("Nthtof",&Nthtof);
190 pamelats 1.8 if(fhBookTree->GetBranch("Ipltof"))fhBookTree->SetBranchAddress("Ipltof",Ipltof);///////////////////////////
191 pamelats 1.7 if(fhBookTree->GetBranch("Ipaddle"))fhBookTree->SetBranchAddress("Ipaddle",Ipaddle);
192     if(fhBookTree->GetBranch("Ipartof"))fhBookTree->SetBranchAddress("Ipartof",Ipartof);
193     if(fhBookTree->GetBranch("Xintof"))fhBookTree->SetBranchAddress("Xintof",Xintof);
194     if(fhBookTree->GetBranch("Yintof"))fhBookTree->SetBranchAddress("Yintof",Yintof);
195     if(fhBookTree->GetBranch("Zintof"))fhBookTree->SetBranchAddress("Zintof",Zintof);
196     if(fhBookTree->GetBranch("Xouttof"))fhBookTree->SetBranchAddress("Xouttof",Xouttof);
197     if(fhBookTree->GetBranch("Youttof"))fhBookTree->SetBranchAddress("Youttof",Youttof);
198     if(fhBookTree->GetBranch("Zouttof"))fhBookTree->SetBranchAddress("Zouttof",Zouttof);
199     if(fhBookTree->GetBranch("Ereltof"))fhBookTree->SetBranchAddress("Ereltof",Ereltof);
200     if(fhBookTree->GetBranch("Timetof"))fhBookTree->SetBranchAddress("Timetof",Timetof);
201     if(fhBookTree->GetBranch("Pathtof"))fhBookTree->SetBranchAddress("Pathtof",Pathtof);
202     if(fhBookTree->GetBranch("P0tof"))fhBookTree->SetBranchAddress("P0tof",P0tof);
203     if(fhBookTree->GetBranch("Nthcat"))fhBookTree->SetBranchAddress("Nthcat",&Nthcat);
204     if(fhBookTree->GetBranch("Iparcat"))fhBookTree->SetBranchAddress("Iparcat",Iparcat);
205     if(fhBookTree->GetBranch("Icat"))fhBookTree->SetBranchAddress("Icat",Icat);
206     if(fhBookTree->GetBranch("Xincat"))fhBookTree->SetBranchAddress("Xincat",Xincat);
207     if(fhBookTree->GetBranch("Yincat"))fhBookTree->SetBranchAddress("Yincat",Yincat);
208     if(fhBookTree->GetBranch("Zincat"))fhBookTree->SetBranchAddress("Zincat",Zincat);
209     if(fhBookTree->GetBranch("Xoutcat"))fhBookTree->SetBranchAddress("Xoutcat",Xoutcat);
210     if(fhBookTree->GetBranch("Youtcat"))fhBookTree->SetBranchAddress("Youtcat",Youtcat);
211     if(fhBookTree->GetBranch("Zoutcat"))fhBookTree->SetBranchAddress("Zoutcat",Zoutcat);
212     if(fhBookTree->GetBranch("Erelcat"))fhBookTree->SetBranchAddress("Erelcat",Erelcat);
213     if(fhBookTree->GetBranch("Timecat"))fhBookTree->SetBranchAddress("Timecat",Timecat);
214     if(fhBookTree->GetBranch("Pathcat"))fhBookTree->SetBranchAddress("Pathcat",Pathcat);
215     if(fhBookTree->GetBranch("P0cat"))fhBookTree->SetBranchAddress("P0cat",P0cat);
216     if(fhBookTree->GetBranch("Nthcas"))fhBookTree->SetBranchAddress("Nthcas",&Nthcas);
217     if(fhBookTree->GetBranch("Iparcas"))fhBookTree->SetBranchAddress("Iparcas",Iparcas);
218 pamelats 1.8 if(fhBookTree->GetBranch("Icas"))fhBookTree->SetBranchAddress("Icas",Icas);///////////////////////////////
219 pamelats 1.7 if(fhBookTree->GetBranch("Xincas"))fhBookTree->SetBranchAddress("Xincas",Xincas);
220     if(fhBookTree->GetBranch("Yincas"))fhBookTree->SetBranchAddress("Yincas",Yincas);
221     if(fhBookTree->GetBranch("Zincas"))fhBookTree->SetBranchAddress("Zincas",Zincas);
222     if(fhBookTree->GetBranch("Xoutcas"))fhBookTree->SetBranchAddress("Xoutcas",Xoutcas);
223     if(fhBookTree->GetBranch("Youtcas"))fhBookTree->SetBranchAddress("Youtcas",Youtcas);
224     if(fhBookTree->GetBranch("Zoutcas"))fhBookTree->SetBranchAddress("Zoutcas",Zoutcas);
225     if(fhBookTree->GetBranch("Erelcas"))fhBookTree->SetBranchAddress("Erelcas",Erelcas);
226     if(fhBookTree->GetBranch("Timecas"))fhBookTree->SetBranchAddress("Timecas",Timecas);
227     if(fhBookTree->GetBranch("Pathcas"))fhBookTree->SetBranchAddress("Pathcas",Pathcas);
228     if(fhBookTree->GetBranch("P0cas"))fhBookTree->SetBranchAddress("P0cas",P0cas);
229     if(fhBookTree->GetBranch("Nthspe"))fhBookTree->SetBranchAddress("Nthspe",&Nthspe);
230 pamelats 1.11 // if(fhBookTree->GetBranch("Iparspe"))fhBookTree->SetBranchAddress("Iparspe",Iparspe);
231 pamelats 1.7 if(fhBookTree->GetBranch("Itrpb"))fhBookTree->SetBranchAddress("Itrpb",Itrpb);
232     if(fhBookTree->GetBranch("Itrsl"))fhBookTree->SetBranchAddress("Itrsl",Itrsl);
233     if(fhBookTree->GetBranch("Itspa"))fhBookTree->SetBranchAddress("Itspa",Itspa);
234     if(fhBookTree->GetBranch("Xinspe"))fhBookTree->SetBranchAddress("Xinspe",Xinspe);
235     if(fhBookTree->GetBranch("Yinspe"))fhBookTree->SetBranchAddress("Yinspe",Yinspe);
236     if(fhBookTree->GetBranch("Zinspe"))fhBookTree->SetBranchAddress("Zinspe",Zinspe);
237     if(fhBookTree->GetBranch("Xoutspe"))fhBookTree->SetBranchAddress("Xoutspe",Xoutspe);
238     if(fhBookTree->GetBranch("Youtspe"))fhBookTree->SetBranchAddress("Youtspe",Youtspe);
239     if(fhBookTree->GetBranch("Zoutspe"))fhBookTree->SetBranchAddress("Zoutspe",Zoutspe);
240     if(fhBookTree->GetBranch("Xavspe"))fhBookTree->SetBranchAddress("Xavspe",Xavspe);
241     if(fhBookTree->GetBranch("Yavspe"))fhBookTree->SetBranchAddress("Yavspe",Yavspe);
242     if(fhBookTree->GetBranch("Zavspe"))fhBookTree->SetBranchAddress("Zavspe",Zavspe);
243     if(fhBookTree->GetBranch("Erelspe"))fhBookTree->SetBranchAddress("Erelspe",Erelspe);
244     if(fhBookTree->GetBranch("Pathspe"))fhBookTree->SetBranchAddress("Pathspe",Pathspe);
245     if(fhBookTree->GetBranch("P0spe"))fhBookTree->SetBranchAddress("P0spe",P0spe);
246     if(fhBookTree->GetBranch("Nxmult"))fhBookTree->SetBranchAddress("Nxmult",Nxmult);
247     if(fhBookTree->GetBranch("Nymult"))fhBookTree->SetBranchAddress("Nymult",Nymult);
248     if(fhBookTree->GetBranch("Nstrpx"))fhBookTree->SetBranchAddress("Nstrpx",&Nstrpx);
249     if(fhBookTree->GetBranch("Npstripx"))fhBookTree->SetBranchAddress("Npstripx",Npstripx);
250     if(fhBookTree->GetBranch("Ntstripx"))fhBookTree->SetBranchAddress("Ntstripx",Ntstripx);
251     if(fhBookTree->GetBranch("Istripx"))fhBookTree->SetBranchAddress("Istripx",Istripx);
252     if(fhBookTree->GetBranch("Qstripx"))fhBookTree->SetBranchAddress("Qstripx",Qstripx);
253     if(fhBookTree->GetBranch("Xstripx"))fhBookTree->SetBranchAddress("Xstripx",Xstripx);
254     if(fhBookTree->GetBranch("Nstrpy"))fhBookTree->SetBranchAddress("Nstrpy",&Nstrpy);
255     if(fhBookTree->GetBranch("Npstripy"))fhBookTree->SetBranchAddress("Npstripy",Npstripy);
256     if(fhBookTree->GetBranch("Ntstripy"))fhBookTree->SetBranchAddress("Ntstripy",Ntstripy);
257     if(fhBookTree->GetBranch("Istripy"))fhBookTree->SetBranchAddress("Istripy",Istripy);
258 pamelats 1.8 if(fhBookTree->GetBranch("Qstripy"))fhBookTree->SetBranchAddress("Qstripy",Qstripy);///////////////////////
259 pamelats 1.7 if(fhBookTree->GetBranch("Ystripy"))fhBookTree->SetBranchAddress("Ystripy",Ystripy);
260     if(fhBookTree->GetBranch("Nthcali"))fhBookTree->SetBranchAddress("Nthcali",&Nthcali);
261     if(fhBookTree->GetBranch("Icaplane"))fhBookTree->SetBranchAddress("Icaplane",Icaplane);
262     if(fhBookTree->GetBranch("Icastrip"))fhBookTree->SetBranchAddress("Icastrip",Icastrip);
263     if(fhBookTree->GetBranch("Icamod"))fhBookTree->SetBranchAddress("Icamod",Icamod);
264     if(fhBookTree->GetBranch("Enestrip"))fhBookTree->SetBranchAddress("Enestrip",Enestrip);
265     if(fhBookTree->GetBranch("Nthcal"))fhBookTree->SetBranchAddress("Nthcal",&Nthcal);
266     if(fhBookTree->GetBranch("Icapl"))fhBookTree->SetBranchAddress("Icapl",Icapl);
267     if(fhBookTree->GetBranch("Icasi"))fhBookTree->SetBranchAddress("Icasi",Icasi);
268     if(fhBookTree->GetBranch("Icast"))fhBookTree->SetBranchAddress("Icast",Icast);
269     if(fhBookTree->GetBranch("Xincal"))fhBookTree->SetBranchAddress("Xincal",Xincal);
270     if(fhBookTree->GetBranch("Yincal"))fhBookTree->SetBranchAddress("Yincal",Yincal);
271     if(fhBookTree->GetBranch("Zincal"))fhBookTree->SetBranchAddress("Zincal",Zincal);
272     if(fhBookTree->GetBranch("Erelcal"))fhBookTree->SetBranchAddress("Erelcal",Erelcal);
273     if(fhBookTree->GetBranch("Nthnd"))fhBookTree->SetBranchAddress("Nthnd",&Nthnd);
274     if(fhBookTree->GetBranch("Itubend"))fhBookTree->SetBranchAddress("Itubend",Itubend);
275     if(fhBookTree->GetBranch("Iparnd"))fhBookTree->SetBranchAddress("Iparnd",Iparnd);
276 pamelats 1.8 if(fhBookTree->GetBranch("Xinnd"))fhBookTree->SetBranchAddress("Xinnd",Xinnd);/////////////////////////
277 pamelats 1.7 if(fhBookTree->GetBranch("Yinnd"))fhBookTree->SetBranchAddress("Yinnd",Yinnd);
278     if(fhBookTree->GetBranch("Zinnd"))fhBookTree->SetBranchAddress("Zinnd",Zinnd);
279     if(fhBookTree->GetBranch("Xoutnd"))fhBookTree->SetBranchAddress("Xoutnd",Xoutnd);
280     if(fhBookTree->GetBranch("Youtnd"))fhBookTree->SetBranchAddress("Youtnd",Youtnd);
281     if(fhBookTree->GetBranch("Zoutnd"))fhBookTree->SetBranchAddress("Zoutnd",Zoutnd);
282     if(fhBookTree->GetBranch("Erelnd"))fhBookTree->SetBranchAddress("Erelnd",Erelnd);
283     if(fhBookTree->GetBranch("Timend"))fhBookTree->SetBranchAddress("Timend",Timend);
284     if(fhBookTree->GetBranch("Pathnd"))fhBookTree->SetBranchAddress("Pathnd",Pathnd);
285     if(fhBookTree->GetBranch("P0nd"))fhBookTree->SetBranchAddress("P0nd",P0nd);
286 pamelats 1.8 if(fhBookTree->GetBranch("Nthcard"))fhBookTree->SetBranchAddress("Nthcard",&Nthcard);/////////////////////
287 pamelats 1.7 if(fhBookTree->GetBranch("Iparcard"))fhBookTree->SetBranchAddress("Iparcard",Iparcard);
288     if(fhBookTree->GetBranch("Icard"))fhBookTree->SetBranchAddress("Icard",Icard);
289     if(fhBookTree->GetBranch("Xincard"))fhBookTree->SetBranchAddress("Xincard",Xincard);
290     if(fhBookTree->GetBranch("Yincard"))fhBookTree->SetBranchAddress("Yincard",Yincard);
291     if(fhBookTree->GetBranch("Zincard"))fhBookTree->SetBranchAddress("Zincard",Zincard);
292     if(fhBookTree->GetBranch("Xoutcard"))fhBookTree->SetBranchAddress("Xoutcard",Xoutcard);
293 pamelats 1.8 if(fhBookTree->GetBranch("Youtcard"))fhBookTree->SetBranchAddress("Youtcard",Youtcard);/////////////////
294 pamelats 1.7 if(fhBookTree->GetBranch("Zoutcard"))fhBookTree->SetBranchAddress("Zoutcard",Zoutcard);
295     if(fhBookTree->GetBranch("Erelcard"))fhBookTree->SetBranchAddress("Erelcard",Erelcard);
296     if(fhBookTree->GetBranch("Timecard"))fhBookTree->SetBranchAddress("Timecard",Timecard);
297     if(fhBookTree->GetBranch("Pathcard"))fhBookTree->SetBranchAddress("Pathcard",Pathcard);
298 pamelats 1.8 // if(fhBookTree->GetBranch("P0card"))fhBookTree->SetBranchAddress("P0card",P0card);
299 pamelats 1.7 // fhBookTree->SetBranchStatus("*",0); //modified by E.Vannuccini 03/08
300     }
301    
302     void Digitizer::Close(){
303     delete fhBookTree;
304     }
305    
306     void Digitizer::Loop() {
307     //
308     // opens the raw output file and loops over the events
309     //
310     fOutputfile.open(fFilename, ios::out | ios::binary);
311     //fOutputfile.open(Form("Output%s",fFilename), ios::out | ios::binary);
312     //
313     // Load in memory and save at the beginning of file the calorimeter calibration
314     //
315     CaloLoadCalib();
316     DigitizeCALOCALIB();
317    
318     // load, digitize and write tracker calibration
319     LoadTrackCalib();
320    
321     DigitizeTrackCalib(1);
322     UInt_t length=fTracklength*2;
323     DigitizePSCU(length,0x12,fDataPSCU);
324     AddPadding();
325     WriteTrackCalib();
326    
327     DigitizeTrackCalib(2);
328     length=fTracklength*2;
329     DigitizePSCU(length,0x13,fDataPSCU);
330     AddPadding();
331     WriteTrackCalib();
332     LoadMipCor(); // some initialization of parameters -not used now-
333     // end loading, digitizing and writing tracker calibration
334     // TOF ------ read calibration file (get A1, A2, lambda1, lambda2)
335     const int np=48;
336 pamelats 1.8 float *atte1,*atte2,*lambda1,*lambda2;
337 pamelats 1.7 atte1=(float *)malloc(np *sizeof(float));
338     atte2=(float *)malloc(np *sizeof(float));
339     lambda1=(float *)malloc(np *sizeof(float));
340     lambda2=(float *)malloc(np *sizeof(float));
341     LoadTOFCalib(np,atte1,atte2,lambda1,lambda2);
342 pamelats 1.11 attenAC = new TF1("fAttAC",".825+.64*atan(9.8/x)",0.,45.);
343 pamelats 1.7 //end tof calib
344     //
345     // loops over the events
346     //
347    
348     Int_t nentries = fhBookTree->GetEntriesFast();
349     Long64_t nbytes = 0;
350 pamelats 1.12 for (Int_t i=0; i<nentries;i++) {
351     nbytes += fhBookTree->GetEntry(i);
352 pizzolot 1.14 fEvent=i; // cecilia for calo compress mode
353 pamelats 1.8 // read detectors sequentially:
354     // http://www.ts.infn.it/fileadmin/documents/physics/experiments/wizard/cpu/gen_arch/RM_Acquisition.pdf
355     // on pamelatov: /cvs/yoda/techmodel/physics/NeutronDetectorReader.cpp
356 pamelats 1.12 DigitizeTOF(np,atte1,atte2,lambda1,lambda2);
357 pamelats 1.11 DigitizeAC();
358 pamelats 1.8 DigitizeCALO();
359     DigitizeTrack();
360     DigitizeS4();
361     DigitizeND();
362     //
363     // Add padding to 64 bits
364     //
365     AddPadding();
366     //
367     // Create CPU header, we need packet type (0x10 = physics data) and packet length.
368     //
369     UInt_t length=2*(fCALOlength+fACbuffer+fTracklength+fNDbuffer+fS4buffer)+fPadding+fTOFbuffer+fTRIGGERbuffer;
370     //UInt_t length=2*(fCALOlength+fACbuffer+fTracklength+fNDbuffer)+fPadding+fTOFbuffer+fTRIGGERbuffer;
371     DigitizePSCU(length,0x10,fDataPSCU);
372 pamelats 1.11 if ((i%1000)==0)cout << "writing event " << i << endl;
373 pamelats 1.8 WriteData();
374     }
375    
376 pamelats 1.7 fOutputfile.close();
377 pamelats 1.8 cout << "files closed" << endl;
378 pamelats 1.7 };
379    
380    
381     void Digitizer::ReadData(){
382    
383     UShort_t InData[64];
384    
385     // for debuggigng purposes only, write your own routine if you like (many
386     // hardwired things.
387    
388     ifstream InputFile;
389    
390     // if (!InputFile) {
391    
392     // std::cout << "ERROR" << endl;
393     // // An error occurred!
394     // // myFile.gcount() returns the number of bytes read.
395     // // calling myFile.clear() will reset the stream state
396     // // so it is usable again.
397     // };
398    
399    
400    
401     //InputFile.seekg(0);
402    
403     InputFile.open(fFilename, ios::in | ios::binary);
404     // fOutputfile.seekg(0);
405     if (!InputFile.is_open()) std::cout << "ERROR" << endl;
406    
407     InputFile.seekg(0);
408    
409     for (Int_t k=0; k<=1000; k++){
410     InputFile.read(reinterpret_cast<char*>(InData),384*sizeof(UShort_t));
411    
412     std::cout << "Read back: " << endl << endl;
413    
414     for (Int_t i=0; i<=384; i++){
415     printf("%4x ", InData[i]);
416     if ((i+1)%8 ==0) cout << endl;
417     }
418    
419     }
420     cout << endl;
421     InputFile.close();
422    
423     };

  ViewVC Help
Powered by ViewVC 1.1.23