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