1 |
mocchiut |
1.1 |
// |
2 |
|
|
// Program to convert rootples to ntuples and viceversa for the PAMELA ground data. |
3 |
|
|
// Written by Emiliano Mocchiutti. |
4 |
|
|
// |
5 |
mocchiut |
1.2 |
// Version 3.01 (2006/02/14) |
6 |
mocchiut |
1.1 |
// |
7 |
|
|
// Changelog: |
8 |
|
|
// |
9 |
mocchiut |
1.2 |
// 3.00 - 3.01 (2006/02/14): bug in the booking of the level2 tracker rootple (wrong dimension of axv and wrong dereference to image[ntrk]), fixed (thanks to Silvio Orsi). |
10 |
|
|
// |
11 |
mocchiut |
1.1 |
// 2.00 - 3.00 (2005/11/29): compiled. |
12 |
|
|
// |
13 |
|
|
// 1.05 - 2.00 (2005/10/07): added TOF and TRIGGER level1 conversion (from PAW to ROOT). |
14 |
|
|
// |
15 |
|
|
// 1.04 - 1.05 (2005/10/04): tracker version 2.00 conversion. |
16 |
|
|
// |
17 |
|
|
// 1.03 - 1.04 (2005/09/07): small bug unloading libraries fixed. |
18 |
|
|
// |
19 |
|
|
// 1.02 - 1.03 (2005/08/03): changes for working on 64 bit machines. |
20 |
|
|
// |
21 |
|
|
// 1.01 - 1.02 (2005/07/21): don't load yodaUtility.c anymore and use clone routines in CaloFunctions.h |
22 |
|
|
// |
23 |
|
|
// 1.00 - 1.01 (2005/07/14): small change in the call to getLEVname (changed to be compiled). |
24 |
|
|
// |
25 |
|
|
// 0.1 - 1.00 (2005/07/05): working, it converts AC level1 rootples to ntuples and TRK level1 and level2 ntuples to rootples. |
26 |
|
|
// |
27 |
|
|
// v. 0.1 (2005/06/15): created. |
28 |
|
|
// |
29 |
|
|
// |
30 |
|
|
#include <math.h> |
31 |
|
|
#include <stdio.h> |
32 |
|
|
// |
33 |
|
|
#include <fstream> |
34 |
|
|
#include <sstream> |
35 |
|
|
#include <iostream> |
36 |
|
|
#include <iomanip> |
37 |
|
|
// |
38 |
|
|
//#include <trklev1struct.h> |
39 |
|
|
#include <ctrkstruct.h> |
40 |
|
|
#include <ctofstruct.h> |
41 |
|
|
#include <cacstruct.h> |
42 |
|
|
// |
43 |
|
|
#if !defined (__CINT__) |
44 |
|
|
#include <event/PamelaRun.h> |
45 |
|
|
#include <event/physics/trigger/TriggerEvent.h> |
46 |
|
|
#include <event/physics/tof/TofEvent.h> |
47 |
|
|
#include <event/physics/tracker/TrackerEvent.h> |
48 |
|
|
#include <event/physics/anticounter/AnticounterEvent.h> |
49 |
|
|
#include <event/CalibCalPedEvent.h> |
50 |
|
|
extern const char *pathtocalibration(); |
51 |
|
|
extern void coptrklev2(const char [], struct Tracklev2 &, int &); |
52 |
|
|
extern void cretrklev2(int &, Tracklev2 &); |
53 |
|
|
extern void ccltrklev2(struct Tracklev2 &); |
54 |
|
|
extern void coptrklev1(const char [], struct Tracklev1 &, int &); |
55 |
|
|
extern void cretrklev1(int &, Tracklev1 &); |
56 |
|
|
extern void ccltrklev1(struct Tracklev1 &); |
57 |
|
|
extern void coptoflev1(const char [], struct Toflev1 &, int &); |
58 |
|
|
extern void cretoflev1(int &, Toflev1 &); |
59 |
|
|
extern void ccltoflev1(struct Toflev1 &); |
60 |
|
|
extern void copaclev1(const char []); |
61 |
|
|
extern void cfiaclev1(struct AClev1 &); |
62 |
|
|
extern void cclaclev1(); |
63 |
|
|
#endif |
64 |
|
|
// |
65 |
|
|
// |
66 |
|
|
#include <CaloFunctions.h> |
67 |
|
|
// |
68 |
|
|
#include <ctrkinclude.h> |
69 |
|
|
#include <ctofinclude.h> |
70 |
|
|
#include <aclev1class.h> |
71 |
|
|
|
72 |
|
|
int GroundDataConvert(TString filename, TString detector, TString level, TString outDir = "", Int_t FORCE = 0){ |
73 |
|
|
gROOT->GetListOfCanvases()->Delete(); |
74 |
|
|
gDirectory->GetList()->Delete(); |
75 |
|
|
#if defined (__CINT__) |
76 |
|
|
emicheckLib(); |
77 |
|
|
#endif |
78 |
|
|
const char* startingdir = gSystem->WorkingDirectory(); |
79 |
|
|
TString path; |
80 |
|
|
stringcopy(path,startingdir); |
81 |
|
|
const char *decname = detector; |
82 |
|
|
TString level2; |
83 |
|
|
stringcopy(level2,level); |
84 |
|
|
const char *lev = level2; |
85 |
|
|
Int_t lev1 = 0; |
86 |
|
|
Int_t lev2 = 0; |
87 |
|
|
if ( !strcmp(lev,"1") ){ |
88 |
|
|
lev1 = 1; |
89 |
|
|
}; |
90 |
|
|
if ( !strcmp(lev,"2") ){ |
91 |
|
|
lev2 = 1; |
92 |
|
|
}; |
93 |
|
|
Int_t TRK = 0; |
94 |
|
|
stringstream bdir; |
95 |
|
|
bdir.str(""); |
96 |
|
|
if ( !strcmp(decname,"tracker") ) { |
97 |
|
|
#if defined (__CINT__) |
98 |
|
|
const char *sdir=gSystem->Getenv("PAM_LIB"); |
99 |
|
|
if ( !strcmp(lev,"1") ){ |
100 |
|
|
bdir << sdir << "/liboptrklev1.so"; |
101 |
|
|
gSystem->Load(bdir.str().c_str()); |
102 |
|
|
bdir.str(""); |
103 |
|
|
bdir << sdir << "/liboptrklev1_C.so"; |
104 |
|
|
gSystem->Load(bdir.str().c_str()); |
105 |
|
|
bdir.str(""); |
106 |
|
|
bdir << sdir << "/libretrklev1.so"; |
107 |
|
|
gSystem->Load(bdir.str().c_str()); |
108 |
|
|
bdir.str(""); |
109 |
|
|
bdir << sdir << "/libretrklev1_C.so"; |
110 |
|
|
gSystem->Load(bdir.str().c_str()); |
111 |
|
|
bdir.str(""); |
112 |
|
|
bdir << sdir << "/libcltrklev1.so"; |
113 |
|
|
gSystem->Load(bdir.str().c_str()); |
114 |
|
|
bdir.str(""); |
115 |
|
|
bdir << sdir << "/libcltrklev1_C.so"; |
116 |
|
|
gSystem->Load(bdir.str().c_str()); |
117 |
|
|
bdir.str(""); |
118 |
|
|
}; |
119 |
|
|
if ( !strcmp(lev,"2") ){ |
120 |
|
|
bdir << sdir << "/liboptrklev2.so"; |
121 |
|
|
gSystem->Load(bdir.str().c_str()); |
122 |
|
|
bdir.str(""); |
123 |
|
|
bdir << sdir << "/liboptrklev2_C.so"; |
124 |
|
|
gSystem->Load(bdir.str().c_str()); |
125 |
|
|
bdir.str(""); |
126 |
|
|
bdir << sdir << "/libretrklev2.so"; |
127 |
|
|
gSystem->Load(bdir.str().c_str()); |
128 |
|
|
bdir.str(""); |
129 |
|
|
bdir << sdir << "/libretrklev2_C.so"; |
130 |
|
|
gSystem->Load(bdir.str().c_str()); |
131 |
|
|
bdir.str(""); |
132 |
|
|
bdir << sdir << "/libcltrklev2.so"; |
133 |
|
|
gSystem->Load(bdir.str().c_str()); |
134 |
|
|
bdir.str(""); |
135 |
|
|
bdir << sdir << "/libcltrklev2_C.so"; |
136 |
|
|
gSystem->Load(bdir.str().c_str()); |
137 |
|
|
bdir.str(""); |
138 |
|
|
}; |
139 |
|
|
#endif |
140 |
|
|
TRK = 1; |
141 |
|
|
}; |
142 |
|
|
Int_t AC = 0; |
143 |
|
|
if ( !strcmp(decname,"anticounter") ) { |
144 |
|
|
if ( strcmp(lev,"1") ) printf("WARNING: this program can convert only LEVEL1 AC rootples!\nWARNING: assuming you are meaning level=1\n"); |
145 |
|
|
lev="1"; |
146 |
|
|
lev1 = 1; |
147 |
|
|
lev2 = 0; |
148 |
|
|
level = "1"; |
149 |
|
|
#if defined (__CINT__) |
150 |
|
|
const char *sdir=gSystem->Getenv("PAM_LIB"); |
151 |
|
|
bdir << sdir << "/libopaclev1.so"; |
152 |
|
|
gSystem->Load(bdir.str().c_str()); |
153 |
|
|
bdir.str(""); |
154 |
|
|
bdir << sdir << "/libopaclev1_C.so"; |
155 |
|
|
gSystem->Load(bdir.str().c_str()); |
156 |
|
|
bdir.str(""); |
157 |
|
|
bdir << sdir << "/libfiaclev1.so"; |
158 |
|
|
gSystem->Load(bdir.str().c_str()); |
159 |
|
|
bdir.str(""); |
160 |
|
|
bdir << sdir << "/libfiaclev1_C.so"; |
161 |
|
|
gSystem->Load(bdir.str().c_str()); |
162 |
|
|
bdir.str(""); |
163 |
|
|
bdir << sdir << "/libclaclev1.so"; |
164 |
|
|
gSystem->Load(bdir.str().c_str()); |
165 |
|
|
bdir.str(""); |
166 |
|
|
bdir << sdir << "/libclaclev1_C.so"; |
167 |
|
|
gSystem->Load(bdir.str().c_str()); |
168 |
|
|
bdir.str(""); |
169 |
|
|
#endif |
170 |
|
|
AC = 1; |
171 |
|
|
}; |
172 |
|
|
Int_t TOF = 0; |
173 |
|
|
if ( !strcmp(decname,"tof") ) { |
174 |
|
|
if ( strcmp(lev,"1") ) printf("WARNING: this program can convert only LEVEL1 TOF ntuples!\nWARNING: assuming you are meaning level=1\n"); |
175 |
|
|
lev="1"; |
176 |
|
|
lev1 = 1; |
177 |
|
|
lev2 = 0; |
178 |
|
|
level = "1"; |
179 |
|
|
#if defined (__CINT__) |
180 |
|
|
const char *sdir=gSystem->Getenv("PAM_LIB"); |
181 |
|
|
bdir << sdir << "/liboptoflev1.so"; |
182 |
|
|
gSystem->Load(bdir.str().c_str()); |
183 |
|
|
bdir.str(""); |
184 |
|
|
bdir << sdir << "/liboptoflev1_C.so"; |
185 |
|
|
gSystem->Load(bdir.str().c_str()); |
186 |
|
|
bdir.str(""); |
187 |
|
|
bdir << sdir << "/libretoflev1.so"; |
188 |
|
|
gSystem->Load(bdir.str().c_str()); |
189 |
|
|
bdir.str(""); |
190 |
|
|
bdir << sdir << "/libretoflev1_C.so"; |
191 |
|
|
gSystem->Load(bdir.str().c_str()); |
192 |
|
|
bdir.str(""); |
193 |
|
|
bdir << sdir << "/libcltoflev1.so"; |
194 |
|
|
gSystem->Load(bdir.str().c_str()); |
195 |
|
|
bdir.str(""); |
196 |
|
|
bdir << sdir << "/libcltoflev1_C.so"; |
197 |
|
|
gSystem->Load(bdir.str().c_str()); |
198 |
|
|
bdir.str(""); |
199 |
|
|
#endif |
200 |
|
|
TOF = 1; |
201 |
|
|
}; |
202 |
|
|
// |
203 |
|
|
printf("\n Check the existence of input data: \n\n"); |
204 |
|
|
// |
205 |
|
|
Int_t isfileinput = 0; |
206 |
|
|
stringstream ifile; |
207 |
|
|
if ( TRK ){ |
208 |
|
|
const string fil = (const char*)filename; |
209 |
|
|
// |
210 |
|
|
Int_t posiz = fil.find(".rz"); |
211 |
|
|
if ( posiz == -1 ) posiz = fil.find(".RZ"); |
212 |
|
|
if ( posiz == -1 ){ |
213 |
|
|
const string fil2 = (const char*)filename; |
214 |
|
|
Int_t nposiz = fil2.find("dw_"); |
215 |
|
|
if ( nposiz == -1 ) nposiz = fil2.find("DW_"); |
216 |
|
|
if ( nposiz == -1 ) return(5); |
217 |
|
|
nposiz = nposiz+3; |
218 |
|
|
Int_t nposiz2 = nposiz+10; |
219 |
|
|
TString ufile2; |
220 |
|
|
stringcopy(ufile2,filename,nposiz,nposiz2); |
221 |
|
|
const char *trname = ufile2; |
222 |
|
|
// |
223 |
|
|
ifile << filename.Data() << "/Physics/Level"; |
224 |
|
|
ifile << lev << "/DW_"; |
225 |
|
|
ifile << trname << "_level"; |
226 |
|
|
ifile << lev << ".rz"; |
227 |
|
|
} else { |
228 |
|
|
if ( outDir == "" ){ |
229 |
|
|
printf("ERROR: if you give as input the name of the file to convert you must give also the output directory where to store data\n"); |
230 |
|
|
printf("Exiting...\n"); |
231 |
|
|
return(6); |
232 |
|
|
}; |
233 |
|
|
TString ufile2; |
234 |
|
|
Int_t nposiz = posiz -1; |
235 |
|
|
Int_t nposiz2 = posiz; |
236 |
|
|
stringcopy(ufile2,filename,nposiz,nposiz2); |
237 |
|
|
const char *levname = ufile2; |
238 |
|
|
if ( strcmp(lev,levname) ){ |
239 |
|
|
printf("ERROR: you asked to process LEVEL%s data but the input file contains LEVEL%s data!\n\n Exiting... \n",lev,levname); |
240 |
|
|
return(6); |
241 |
|
|
}; |
242 |
|
|
ifile << filename; |
243 |
|
|
isfileinput = 1; |
244 |
|
|
}; |
245 |
|
|
ifstream mypawfile; |
246 |
|
|
mypawfile.open(ifile.str().c_str()); |
247 |
|
|
if ( !mypawfile ){ |
248 |
|
|
printf("ERROR: file %s does not exist \n\n",ifile.str().c_str()); |
249 |
|
|
printf("Exiting...\n"); |
250 |
|
|
return(2); |
251 |
|
|
}; |
252 |
|
|
printf(" OK, TRACKER input file exists \n\n"); |
253 |
|
|
}; |
254 |
|
|
// |
255 |
|
|
if ( TOF ){ |
256 |
|
|
const string fil = (const char*)filename; |
257 |
|
|
// |
258 |
|
|
Int_t posiz = fil.find(".rz"); |
259 |
|
|
if ( posiz == -1 ) posiz = fil.find(".RZ"); |
260 |
|
|
if ( posiz == -1 ){ |
261 |
|
|
const string fil2 = (const char*)filename; |
262 |
|
|
Int_t nposiz = fil2.find("dw_"); |
263 |
|
|
if ( nposiz == -1 ) nposiz = fil2.find("DW_"); |
264 |
|
|
if ( nposiz == -1 ) return(5); |
265 |
|
|
nposiz = nposiz+3; |
266 |
|
|
Int_t nposiz2 = nposiz+10; |
267 |
|
|
TString ufile2; |
268 |
|
|
stringcopy(ufile2,filename,nposiz,nposiz2); |
269 |
|
|
const char *trname = ufile2; |
270 |
|
|
// |
271 |
|
|
ifile << filename.Data() << "/Physics/Level"; |
272 |
|
|
ifile << lev << "/DW_"; |
273 |
|
|
ifile << trname << "_toftrack.rz"; |
274 |
|
|
} else { |
275 |
|
|
if ( outDir == "" ){ |
276 |
|
|
printf("ERROR: if you give as input the name of the file to convert you must give also the output directory where to store data\n"); |
277 |
|
|
printf("Exiting...\n"); |
278 |
|
|
return(6); |
279 |
|
|
}; |
280 |
|
|
// |
281 |
|
|
ifile << filename; |
282 |
|
|
isfileinput = 1; |
283 |
|
|
}; |
284 |
|
|
ifstream mypawfile; |
285 |
|
|
mypawfile.open(ifile.str().c_str()); |
286 |
|
|
if ( !mypawfile ){ |
287 |
|
|
printf("ERROR: file %s does not exist \n\n",ifile.str().c_str()); |
288 |
|
|
printf("Exiting...\n"); |
289 |
|
|
return(2); |
290 |
|
|
}; |
291 |
|
|
printf(" OK, TOF input file exists \n\n"); |
292 |
|
|
}; |
293 |
|
|
// |
294 |
|
|
TFile *headerFile = 0; |
295 |
|
|
TTree *tr = 0; |
296 |
|
|
TFile *acFile = 0; |
297 |
|
|
if ( AC ){ |
298 |
|
|
headerFile = emigetFile(filename, "Physics", "Header"); |
299 |
|
|
if ( !headerFile ){ |
300 |
|
|
headerFile->Close(); |
301 |
|
|
printf("No header file, exiting...\n"); |
302 |
|
|
return(1); |
303 |
|
|
}; |
304 |
|
|
tr = (TTree*)headerFile->Get("Pscu"); |
305 |
|
|
// |
306 |
|
|
acFile = emigetFile(filename, "Physics.Level1","Anticounter"); |
307 |
|
|
if ( !acFile ){ |
308 |
|
|
printf("ERROR: No AC file! \n Exiting... \n\n"); |
309 |
|
|
return(2); |
310 |
|
|
}; |
311 |
|
|
printf(" OK, AC file exists \n\n"); |
312 |
|
|
tr->AddFriend("AcLevel1",acFile); |
313 |
|
|
}; |
314 |
|
|
// |
315 |
|
|
if ( !FORCE ) printf(" Not in FORCE mode, check the existence of output data: \n"); |
316 |
|
|
Int_t nofile = 0; |
317 |
|
|
// |
318 |
|
|
TString filety = ""; |
319 |
|
|
TString detc = ""; // detector |
320 |
|
|
// |
321 |
|
|
if ( TRK ){ |
322 |
|
|
filety = "root"; |
323 |
|
|
detc = "Tracker"; // detector |
324 |
|
|
}; |
325 |
|
|
if ( TOF ){ |
326 |
|
|
filety = "root"; |
327 |
|
|
detc = "TofTrigger"; // detector |
328 |
|
|
}; |
329 |
|
|
if ( AC ){ |
330 |
|
|
filety = "rz"; |
331 |
|
|
detc = "Anticounter"; // detector |
332 |
|
|
} |
333 |
|
|
char *file; |
334 |
|
|
if ( !isfileinput ){ |
335 |
|
|
file = getLEVname(filename,detc,lev,filety); |
336 |
|
|
} else { |
337 |
|
|
file = getfileLEVname(filename,detc,lev,filety); |
338 |
|
|
}; |
339 |
|
|
// |
340 |
|
|
stringstream file2; |
341 |
|
|
file2.str(""); |
342 |
|
|
stringstream file3; |
343 |
|
|
file3.str(""); |
344 |
|
|
const char *file4 = 0; |
345 |
|
|
if ( outDir == "" ){ |
346 |
|
|
file4 = filename; |
347 |
|
|
file3 << file4 << "/Physics/Level"; |
348 |
|
|
file3 << lev; |
349 |
|
|
} else { |
350 |
|
|
file4 = outDir; |
351 |
|
|
file3 << file4; |
352 |
|
|
}; |
353 |
|
|
file2 << file3.str().c_str() << "/"; |
354 |
|
|
file2 << file; |
355 |
|
|
// |
356 |
|
|
printf("\n Filename will be: \n %s \n\n",file2.str().c_str()); |
357 |
|
|
ifstream mypawfile; |
358 |
|
|
mypawfile.open(file2.str().c_str()); |
359 |
|
|
if ( mypawfile ){ |
360 |
|
|
nofile = 1; |
361 |
|
|
} else { |
362 |
|
|
if ( !FORCE ) printf("Error in opening file: file %s does not exist \n",file2.str().c_str()); |
363 |
|
|
}; |
364 |
|
|
// |
365 |
|
|
if ( !FORCE ){ |
366 |
|
|
if ( nofile ){ |
367 |
|
|
printf(" ERROR: file already exists! Use FORCE = 1 to override \n\n"); |
368 |
|
|
gSystem->ChangeDirectory(path); |
369 |
|
|
return(3); |
370 |
|
|
} else { |
371 |
|
|
printf("\n OK, I will create it!\n\n"); |
372 |
|
|
}; |
373 |
|
|
}; |
374 |
|
|
// |
375 |
|
|
// |
376 |
|
|
// |
377 |
|
|
if ( TRK ){ |
378 |
|
|
if ( lev1 ){ |
379 |
|
|
// |
380 |
|
|
// create output file: |
381 |
|
|
// |
382 |
|
|
struct Tracklev1 trklev1; |
383 |
|
|
char *type; |
384 |
|
|
type = "NEW"; |
385 |
|
|
if ( FORCE ) type = "RECREATE"; |
386 |
|
|
TFile *hfile = 0; |
387 |
|
|
TTree *tree = 0; |
388 |
|
|
hfile = new TFile(file2.str().c_str(),type,"Tracker LEVEL1 data"); |
389 |
|
|
tree = new TTree("TrkLevel1","PAMELA level1 tracker data"); |
390 |
|
|
tree->Branch("good1",&trklev1.good1,"good1/O"); |
391 |
|
|
tree->Branch("nev1",&trklev1.nev1,"nev1/I"); |
392 |
|
|
tree->Branch("pkt_type1",&trklev1.pkt_type1,"pkt_type1/I"); |
393 |
|
|
tree->Branch("pkt_num1",&trklev1.pkt_num1,"pkt_num1/I"); |
394 |
|
|
tree->Branch("obt1",&trklev1.obt1,"obt1/I"); |
395 |
|
|
tree->Branch("which_calib1",&trklev1.which_calib1,"which_calib1/I"); |
396 |
|
|
tree->Branch("nclstr1",&trklev1.nclstr1,"nclstr1/I"); |
397 |
|
|
tree->Branch("view",trklev1.view,"view[nclstr1]/I"); |
398 |
|
|
tree->Branch("ladder",trklev1.ladder,"ladder[nclstr1]/I"); |
399 |
|
|
tree->Branch("maxs",trklev1.maxs,"maxs[nclstr1]/I"); |
400 |
|
|
tree->Branch("mult",trklev1.mult,"mult[nclstr1]/I"); |
401 |
|
|
tree->Branch("dedx",trklev1.dedx,"dedx[nclstr1]/F"); |
402 |
|
|
tree->Branch("indstart",trklev1.indstart,"indstart[nclstr1]/I"); |
403 |
|
|
tree->Branch("indmax",trklev1.indmax,"indmax[nclstr1]/I"); |
404 |
|
|
tree->Branch("totcllength",&trklev1.totcllength,"totcllength/I"); |
405 |
|
|
tree->Branch("clsignal",trklev1.clsignal,"clsignal[totcllength]/F"); |
406 |
|
|
tree->Branch("cnev",trklev1.cnev,"cnev[24][12]/F"); |
407 |
|
|
// |
408 |
|
|
Int_t trnev = 0; |
409 |
|
|
coptrklev1(ifile.str().c_str(),trklev1,trnev); |
410 |
|
|
printf(" The tracker ntuple contains %i events\n Processing data: \n",trnev ); |
411 |
|
|
for ( Int_t i = 1; i < trnev+1; i++){ |
412 |
|
|
if ( i%1000 == 0 ) printf("%iK \n",i/1000); |
413 |
|
|
// |
414 |
|
|
cretrklev1(i,trklev1); |
415 |
|
|
// |
416 |
|
|
tree->Fill(); |
417 |
|
|
}; |
418 |
|
|
printf(" Finished! Closing ntuple...\n"); |
419 |
|
|
ccltrklev1(trklev1); |
420 |
|
|
// |
421 |
|
|
hfile->Write(); |
422 |
|
|
hfile->Close(); |
423 |
|
|
// |
424 |
|
|
gSystem->ChangeDirectory(path); |
425 |
|
|
#if defined (__CINT__) |
426 |
|
|
char *sdir=gSystem->Getenv("PAM_LIB"); |
427 |
|
|
bdir.str(""); |
428 |
|
|
bdir << sdir << "/libcltrklev1_C.so"; |
429 |
|
|
gSystem->Unload(bdir.str().c_str()); |
430 |
|
|
bdir.str(""); |
431 |
|
|
bdir << sdir << "/libcltrklev1.so"; |
432 |
|
|
gSystem->Unload(bdir.str().c_str()); |
433 |
|
|
bdir.str(""); |
434 |
|
|
bdir << sdir << "/libretrklev1_C.so"; |
435 |
|
|
gSystem->Unload(bdir.str().c_str()); |
436 |
|
|
bdir.str(""); |
437 |
|
|
bdir << sdir << "/libretrklev1.so"; |
438 |
|
|
gSystem->Unload(bdir.str().c_str()); |
439 |
|
|
bdir.str(""); |
440 |
|
|
bdir << sdir << "/liboptrklev1_C.so"; |
441 |
|
|
gSystem->Unload(bdir.str().c_str()); |
442 |
|
|
stringstream cdir; |
443 |
|
|
cdir.str(""); |
444 |
|
|
char *sdir=gSystem->Getenv("PAM_LIB"); |
445 |
|
|
cdir << sdir << "/liboptrklev1.so"; |
446 |
|
|
gSystem->Unload(cdir.str().c_str()); |
447 |
|
|
#endif |
448 |
|
|
return(0); |
449 |
|
|
}; |
450 |
|
|
if ( lev2 ){ |
451 |
|
|
struct Tracklev2 trklev2; |
452 |
|
|
char *type; |
453 |
|
|
type = "NEW"; |
454 |
|
|
if ( FORCE ) type = "RECREATE"; |
455 |
|
|
TFile *hfile = 0; |
456 |
|
|
TTree *tree = 0; |
457 |
|
|
hfile = new TFile(file2.str().c_str(),type,"Tracker LEVEL2 data"); |
458 |
|
|
tree = new TTree("TrkLevel2","PAMELA level2 tracker data"); |
459 |
|
|
tree->Branch("good2",&trklev2.good2,"good2/O"); |
460 |
|
|
tree->Branch("nev2",&trklev2.nev2,"nev2/I"); |
461 |
|
|
tree->Branch("pkt_type",&trklev2.pkt_type,"pkt_type/I"); |
462 |
|
|
tree->Branch("pkt_num",&trklev2.pkt_num,"pkt_num/I"); |
463 |
|
|
tree->Branch("obt",&trklev2.obt,"obt/I"); |
464 |
|
|
tree->Branch("which_calib",&trklev2.which_calib,"which_calib/I"); |
465 |
|
|
tree->Branch("ntrk",&trklev2.ntrk,"ntrk/I"); |
466 |
mocchiut |
1.2 |
tree->Branch("image",trklev2.image,"image[ntrk]/I"); |
467 |
mocchiut |
1.1 |
tree->Branch("xm",trklev2.xm,"xm[ntrk][6]/F"); |
468 |
|
|
tree->Branch("ym",trklev2.ym,"ym[ntrk][6]/F"); |
469 |
|
|
tree->Branch("zm",trklev2.zm,"zm[ntrk][6]/F"); |
470 |
|
|
tree->Branch("resx",trklev2.resx,"resx[ntrk][6]/F"); |
471 |
|
|
tree->Branch("resy",trklev2.resy,"resy[ntrk][6]/F"); |
472 |
|
|
tree->Branch("al",trklev2.al,"al[ntrk][5]/F"); |
473 |
|
|
tree->Branch("coval",trklev2.coval,"coval[ntrk][5][5]/F"); |
474 |
|
|
tree->Branch("chi2",trklev2.chi2,"chi2[ntrk]/F"); |
475 |
|
|
tree->Branch("xgood",trklev2.xgood,"xgood[ntrk][6]/I"); |
476 |
|
|
tree->Branch("ygood",trklev2.ygood,"ygood[ntrk][6]/I"); |
477 |
|
|
tree->Branch("xv",trklev2.xv,"xv[ntrk][6]/F"); |
478 |
|
|
tree->Branch("yv",trklev2.yv,"yv[ntrk][6]/F"); |
479 |
|
|
tree->Branch("zv",trklev2.zv,"zv[ntrk][6]/F"); |
480 |
mocchiut |
1.2 |
tree->Branch("axv",trklev2.axv,"axv[ntrk][6]/F"); |
481 |
mocchiut |
1.1 |
tree->Branch("ayv",trklev2.ayv,"ayv[ntrk][6]/F"); |
482 |
|
|
tree->Branch("dedxp",trklev2.dedxp,"dedxp[ntrk][6]/F"); |
483 |
|
|
tree->Branch("nclsx",trklev2.nclsx,"nclsx[6]/I"); |
484 |
|
|
tree->Branch("nclsy",trklev2.nclsy,"nclsy[6]/I"); |
485 |
|
|
// |
486 |
|
|
Int_t trnev = 0; |
487 |
|
|
coptrklev2(ifile.str().c_str(),trklev2,trnev); |
488 |
|
|
printf(" The tracker ntuple contains %i events\n Processing data: \n",trnev ); |
489 |
|
|
for ( Int_t i = 1; i < trnev+1; i++){ |
490 |
|
|
if ( i%1000 == 0 ) printf("%iK \n",i/1000); |
491 |
|
|
// |
492 |
|
|
cretrklev2(i,trklev2); |
493 |
|
|
// |
494 |
|
|
tree->Fill(); |
495 |
|
|
}; |
496 |
|
|
printf(" Finished! Closing ntuple...\n"); |
497 |
|
|
ccltrklev2(trklev2); |
498 |
|
|
// |
499 |
|
|
hfile->Write(); |
500 |
|
|
hfile->Close(); |
501 |
|
|
// |
502 |
|
|
gSystem->ChangeDirectory(path); |
503 |
|
|
#if defined (__CINT__) |
504 |
|
|
char *sdir=gSystem->Getenv("PAM_LIB"); |
505 |
|
|
bdir.str(""); |
506 |
|
|
bdir << sdir << "/libcltrklev2_C.so"; |
507 |
|
|
gSystem->Unload(bdir.str().c_str()); |
508 |
|
|
bdir.str(""); |
509 |
|
|
bdir << sdir << "/libcltrklev2.so"; |
510 |
|
|
gSystem->Unload(bdir.str().c_str()); |
511 |
|
|
bdir.str(""); |
512 |
|
|
bdir << sdir << "/libretrklev2_C.so"; |
513 |
|
|
gSystem->Unload(bdir.str().c_str()); |
514 |
|
|
bdir.str(""); |
515 |
|
|
bdir << sdir << "/libretrklev2.so"; |
516 |
|
|
gSystem->Unload(bdir.str().c_str()); |
517 |
|
|
bdir.str(""); |
518 |
|
|
bdir << sdir << "/liboptrklev2_C.so"; |
519 |
|
|
gSystem->Unload(bdir.str().c_str()); |
520 |
|
|
stringstream bdir; |
521 |
|
|
bdir.str(""); |
522 |
|
|
char *sdir=gSystem->Getenv("PAM_LIB"); |
523 |
|
|
bdir << sdir << "/liboptrklev2.so"; |
524 |
|
|
gSystem->Unload(bdir.str().c_str()); |
525 |
|
|
bdir.str(""); |
526 |
|
|
#endif |
527 |
|
|
return(0); |
528 |
|
|
}; |
529 |
|
|
}; |
530 |
|
|
if ( TOF ){ |
531 |
|
|
if ( lev1 ){ |
532 |
|
|
// |
533 |
|
|
// create output file: |
534 |
|
|
// |
535 |
|
|
struct Toflev1 toflev1; |
536 |
|
|
char *type; |
537 |
|
|
type = "NEW"; |
538 |
|
|
if ( FORCE ) type = "RECREATE"; |
539 |
|
|
TFile *hfile = 0; |
540 |
|
|
TTree *tree = 0; |
541 |
|
|
hfile = new TFile(file2.str().c_str(),type,"Tof and Trigger LEVEL1 data"); |
542 |
|
|
tree = new TTree("TofLevel1","PAMELA level1 tof and trigger data"); |
543 |
|
|
tree->Branch("good2",&toflev1.good2,"good2/O"); |
544 |
|
|
tree->Branch("nev2",&toflev1.nev2,"nev2/I"); |
545 |
|
|
tree->Branch("pkt_type",&toflev1.pkt_type,"pkt_type/I"); |
546 |
|
|
tree->Branch("pkt_num",&toflev1.pkt_num,"pkt_num/I"); |
547 |
|
|
tree->Branch("obt",&toflev1.obt,"obt/I"); |
548 |
|
|
tree->Branch("which_calib",&toflev1.which_calib,"which_calib/I"); |
549 |
|
|
tree->Branch("tdcid",toflev1.tdcid,"tdcid[12]/I"); |
550 |
|
|
tree->Branch("evcount",toflev1.evcount,"evcount[12]/I"); |
551 |
|
|
tree->Branch("tdcmask",toflev1.tdcmask,"tdcmask[12]/I"); |
552 |
|
|
tree->Branch("adc",toflev1.adc,"adc[12][4]/I"); |
553 |
|
|
tree->Branch("tdc",toflev1.tdc,"tdc[12][4]/I"); |
554 |
|
|
tree->Branch("temp1",toflev1.temp1,"temp1[12]/I"); |
555 |
|
|
tree->Branch("temp2",toflev1.temp2,"temp2[12]/I"); |
556 |
|
|
tree->Branch("beta",toflev1.beta,"beta[5]/F"); |
557 |
|
|
tree->Branch("xtof",toflev1.xtof,"xtof[3]/F"); |
558 |
|
|
tree->Branch("ytof",toflev1.ytof,"ytof[3]/F"); |
559 |
|
|
tree->Branch("adc_c",toflev1.adc_c,"adc_c[12][4]/F"); |
560 |
|
|
tree->Branch("iflag",toflev1.iflag,"iflag[6]/I"); |
561 |
|
|
tree->Branch("jflag",toflev1.jflag,"jflag[6]/I"); |
562 |
|
|
tree->Branch("xout",toflev1.xout,"xout[3]/F"); |
563 |
|
|
tree->Branch("yout",toflev1.yout,"yout[3]/F"); |
564 |
|
|
tree->Branch("trig_evcount",&toflev1.trig_evcount,"trig_evcount/I"); |
565 |
|
|
tree->Branch("pmtpl",toflev1.pmtpl,"pmtpl[3]/I"); |
566 |
|
|
tree->Branch("trigrate",toflev1.trigrate,"trigrate[6]/I"); |
567 |
|
|
tree->Branch("dltime",toflev1.dltime,"dltime[2]/I"); |
568 |
|
|
tree->Branch("s4calcount",toflev1.s4calcount,"s4calcount[2]/I"); |
569 |
|
|
tree->Branch("pmtcount1",toflev1.pmtcount1,"pmtcount1[24]/I"); |
570 |
|
|
tree->Branch("pmtcount2",toflev1.pmtcount2,"pmtcount2[24]/I"); |
571 |
|
|
tree->Branch("patternbusy",toflev1.patternbusy,"patternbusy[3]/I"); |
572 |
|
|
tree->Branch("patterntrig",toflev1.patterntrig,"patterntrig[6]/I"); |
573 |
|
|
tree->Branch("trigconf",&toflev1.trigconf,"trigconf/I"); |
574 |
|
|
tree->Branch("ntrk",&toflev1.ntrk,"ntrk/I"); |
575 |
|
|
tree->Branch("image",&toflev1.image,"image[ntrk]/I"); |
576 |
|
|
tree->Branch("xm",toflev1.xm,"xm[ntrk][6]/F"); |
577 |
|
|
tree->Branch("ym",toflev1.ym,"ym[ntrk][6]/F"); |
578 |
|
|
tree->Branch("zm",toflev1.zm,"zm[ntrk][6]/F"); |
579 |
|
|
tree->Branch("resx",toflev1.resx,"resx[ntrk][6]/F"); |
580 |
|
|
tree->Branch("resy",toflev1.resy,"resy[ntrk][6]/F"); |
581 |
|
|
tree->Branch("al",toflev1.al,"al[ntrk][5]/F"); |
582 |
|
|
tree->Branch("coval",toflev1.coval,"coval[ntrk][5][5]/F"); |
583 |
|
|
tree->Branch("chi2",toflev1.chi2,"chi2[ntrk]/F"); |
584 |
|
|
tree->Branch("xgood",toflev1.xgood,"xgood[ntrk][6]/I"); |
585 |
|
|
tree->Branch("ygood",toflev1.ygood,"ygood[ntrk][6]/I"); |
586 |
|
|
tree->Branch("xv",toflev1.xv,"xv[ntrk][6]/F"); |
587 |
|
|
tree->Branch("yv",toflev1.yv,"yv[ntrk][6]/F"); |
588 |
|
|
tree->Branch("zv",toflev1.zv,"zv[ntrk][6]/F"); |
589 |
|
|
tree->Branch("axv",toflev1.axv,"axv[ntrk]/F"); |
590 |
|
|
tree->Branch("ayv",toflev1.ayv,"ayv[ntrk][6]/F"); |
591 |
|
|
tree->Branch("dedxp",toflev1.dedxp,"dedxp[ntrk][6]/F"); |
592 |
|
|
tree->Branch("nclsx",toflev1.nclsx,"nclsx[6]/I"); |
593 |
|
|
tree->Branch("nclsy",toflev1.nclsy,"nclsy[6]/I"); |
594 |
|
|
// |
595 |
|
|
Int_t trnev = 0; |
596 |
|
|
coptoflev1(ifile.str().c_str(),toflev1,trnev); |
597 |
|
|
printf(" The tof ntuple contains %i events\n Processing data: \n",trnev ); |
598 |
|
|
for ( Int_t i = 1; i < trnev+1; i++){ |
599 |
|
|
if ( i%1000 == 0 ) printf("%iK \n",i/1000); |
600 |
|
|
// |
601 |
|
|
cretoflev1(i,toflev1); |
602 |
|
|
// |
603 |
|
|
tree->Fill(); |
604 |
|
|
}; |
605 |
|
|
printf(" Finished! Closing ntuple...\n"); |
606 |
|
|
ccltoflev1(toflev1); |
607 |
|
|
// |
608 |
|
|
hfile->Write(); |
609 |
|
|
hfile->Close(); |
610 |
|
|
// |
611 |
|
|
gSystem->ChangeDirectory(path); |
612 |
|
|
#if defined (__CINT__) |
613 |
|
|
char *sdir=gSystem->Getenv("PAM_LIB"); |
614 |
|
|
bdir.str(""); |
615 |
|
|
bdir << sdir << "/libcltoflev1_C.so"; |
616 |
|
|
gSystem->Unload(bdir.str().c_str()); |
617 |
|
|
bdir.str(""); |
618 |
|
|
bdir << sdir << "/libcltoflev1.so"; |
619 |
|
|
gSystem->Unload(bdir.str().c_str()); |
620 |
|
|
bdir.str(""); |
621 |
|
|
bdir << sdir << "/libretoflev1_C.so"; |
622 |
|
|
gSystem->Unload(bdir.str().c_str()); |
623 |
|
|
bdir.str(""); |
624 |
|
|
bdir << sdir << "/libretoflev1.so"; |
625 |
|
|
gSystem->Unload(bdir.str().c_str()); |
626 |
|
|
bdir.str(""); |
627 |
|
|
bdir << sdir << "/liboptoflev1_C.so"; |
628 |
|
|
gSystem->Unload(bdir.str().c_str()); |
629 |
|
|
stringstream cdir; |
630 |
|
|
cdir.str(""); |
631 |
|
|
char *sdir=gSystem->Getenv("PAM_LIB"); |
632 |
|
|
cdir << sdir << "/liboptoflev1.so"; |
633 |
|
|
gSystem->Unload(cdir.str().c_str()); |
634 |
|
|
#endif |
635 |
|
|
return(0); |
636 |
|
|
}; |
637 |
|
|
}; |
638 |
|
|
if ( AC ){ |
639 |
|
|
Long64_t nevents = tr->GetEntries(); |
640 |
|
|
if ( nevents < 1 ) { |
641 |
|
|
printf("The file is empty!\n"); |
642 |
|
|
return(1); |
643 |
|
|
}; |
644 |
|
|
AnticounterLevel1 *ac = new AnticounterLevel1(); |
645 |
|
|
tr->SetBranchAddress("Event",&ac); |
646 |
|
|
// |
647 |
|
|
// Open the rz file with a fortran call |
648 |
|
|
// |
649 |
|
|
struct AClev1 aclev1; |
650 |
|
|
copaclev1(file2.str().c_str()); |
651 |
|
|
// |
652 |
|
|
// run over all the events: |
653 |
|
|
// |
654 |
|
|
for (Int_t i = 0; i < nevents; i++){ |
655 |
|
|
if ( i%1000 == 0 ) printf("%iK \n",i/1000); |
656 |
|
|
// |
657 |
|
|
// open the rootple and copy variables values in "evento_" |
658 |
|
|
// |
659 |
|
|
tr->GetEntry(i); |
660 |
|
|
// |
661 |
|
|
// here you must run over all your variables and copy them in evento_.... |
662 |
|
|
// |
663 |
|
|
aclev1.obt = ac->obt; |
664 |
|
|
aclev1.evfile = ac->evfile; |
665 |
|
|
aclev1.headc = ac->headc; |
666 |
|
|
for (Int_t j = 0; j<2 ; j++){ |
667 |
|
|
aclev1.status[j] = (int)ac->status[j]; |
668 |
|
|
aclev1.hitmap[j] = (int)ac->hitmap[j]; |
669 |
|
|
aclev1.hitstatus[j] = (int)ac->hitstatus[j]; |
670 |
|
|
aclev1.trigger[j] = (int)ac->trigger[j]; |
671 |
|
|
}; |
672 |
|
|
// |
673 |
|
|
// fill the ntuple |
674 |
|
|
// |
675 |
|
|
cfiaclev1(aclev1); |
676 |
|
|
}; |
677 |
|
|
// |
678 |
|
|
// close the rz file |
679 |
|
|
// |
680 |
|
|
printf("\nClose rz file! \n\n"); |
681 |
|
|
cclaclev1(); |
682 |
|
|
printf("File saved in \n\n %s \n\n",file2.str().c_str()); |
683 |
|
|
gSystem->ChangeDirectory(path); |
684 |
|
|
#if defined (__CINT__) |
685 |
|
|
char *sdir=gSystem->Getenv("PAM_LIB"); |
686 |
|
|
bdir.str(""); |
687 |
|
|
bdir << sdir << "/libclaclev1_C.so"; |
688 |
|
|
gSystem->Unload(bdir.str().c_str()); |
689 |
|
|
bdir.str(""); |
690 |
|
|
bdir << sdir << "/libclaclev1.so"; |
691 |
|
|
gSystem->Unload(bdir.str().c_str()); |
692 |
|
|
bdir.str(""); |
693 |
|
|
bdir << sdir << "/libfiaclev1_C.so"; |
694 |
|
|
gSystem->Unload(bdir.str().c_str()); |
695 |
|
|
bdir.str(""); |
696 |
|
|
bdir << sdir << "/libfiaclev1.so"; |
697 |
|
|
gSystem->Unload(bdir.str().c_str()); |
698 |
|
|
bdir.str(""); |
699 |
|
|
bdir << sdir << "/libopaclev1_C.so"; |
700 |
|
|
gSystem->Unload(bdir.str().c_str()); |
701 |
|
|
char *sdir=gSystem->Getenv("PAM_LIB"); |
702 |
|
|
stringstream bdir; |
703 |
|
|
bdir.str(""); |
704 |
|
|
bdir << sdir << "/libopaclev1.so"; |
705 |
|
|
gSystem->Unload(bdir.str().c_str()); |
706 |
|
|
bdir.str(""); |
707 |
|
|
#endif |
708 |
|
|
return(0); |
709 |
|
|
}; |
710 |
|
|
return(0); |
711 |
|
|
} |