/[PAMELA software]/root2paw/macros/GroundDataConvert.c
ViewVC logotype

Contents of /root2paw/macros/GroundDataConvert.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Thu Mar 9 15:46:26 2006 UTC (18 years, 9 months ago) by mocchiut
Branch: MAIN
CVS Tags: v4r00, HEAD
Changes since 1.2: +29 -7 lines
File MIME type: text/plain
Convert tracker output from software v3r02. Some small bugs fixed

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

  ViewVC Help
Powered by ViewVC 1.1.23