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

Contents of /root2paw/macros/GroundDataConvert.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Mon Dec 5 16:17:38 2005 UTC (19 years ago) by mocchiut
Branch: GroundDataConvert
CVS Tags: start, v3r00
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
Imported sources

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

  ViewVC Help
Powered by ViewVC 1.1.23