/[PAMELA software]/DarthVader/AnticounterLevel2/src/AcCore.cpp
ViewVC logotype

Annotation of /DarthVader/AnticounterLevel2/src/AcCore.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (hide annotations) (download)
Thu Jan 11 14:33:38 2007 UTC (17 years, 10 months ago) by mocchiut
Branch: MAIN
Changes since 1.8: +7 -0 lines
Incremented SetAutoSave variable for all the trees

1 mocchiut 1.1 //
2     // C/C++ headers
3     //
4     #include <fstream>
5     #include <string.h>
6     //
7     // ROOT headers
8     //
9     #include <TTree.h>
10     #include <TClassEdit.h>
11     #include <TObject.h>
12     #include <TList.h>
13 mocchiut 1.5 #include <TArrayI.h>
14 mocchiut 1.1 #include <TSystem.h>
15     #include <TSystemDirectory.h>
16     #include <TString.h>
17     #include <TFile.h>
18     #include <TClass.h>
19     #include <TCanvas.h>
20     #include <TH1.h>
21     #include <TH1F.h>
22     #include <TH2D.h>
23     #include <TLatex.h>
24     #include <TPad.h>
25     #include <TSQLServer.h>
26     #include <TSQLRow.h>
27     #include <TSQLResult.h>
28     //#include <TClonesArray.h>
29     //
30     // YODA headers
31     //
32     #include <PamelaRun.h>
33     #include <physics/trigger/TriggerEvent.h>
34     #include <physics/anticounter/AnticounterEvent.h>
35     //
36     // RunInfo header
37     //
38     #include <RunInfo.h>
39     //
40     // This program headers
41     //
42     #include <AcCore.h>
43     #include <AcLevel2.h>
44     #include <AcVerl2.h>
45     //
46     using namespace std;
47     //
48     // CORE ROUTINE
49     //
50     //
51 mocchiut 1.5 int AcCore(UInt_t run, TFile *file, TSQLServer *dbc, Int_t Acargc, char *Acargv[]){
52 mocchiut 1.1 Int_t i = 0;
53     Bool_t verbose = false;
54     Bool_t debug = false;
55     //
56     TString processFolder = "AcFolder";
57     if ( Acargc > 0 ){
58     i = 0;
59     while ( i < Acargc ){
60     if ( !strcmp(Acargv[i],"-processFolder") ) {
61     if ( Acargc < i+1 ){
62     throw -3;
63     };
64     processFolder = (TString)Acargv[i+1];
65     i++;
66     };
67     if ( !strcmp(Acargv[i],"-v") || !strcmp(Acargv[i],"--verbose") ) {
68     verbose = true;
69     };
70     if ( !strcmp(Acargv[i],"-g") || !strcmp(Acargv[i],"--debug") ) {
71     debug = true;
72     };
73     i++;
74     };
75     };
76     //
77     // Set these to true to have a very verbose output.
78     //
79     //
80     // Output directory is the working directoy.
81     //
82     const char* outdir = gSystem->DirName(gSystem->DirName(file->GetPath()));
83     //
84     // Variables for level2
85     //
86     TTree *ac = 0;
87 mocchiut 1.5 UInt_t nevents = 0;
88 mocchiut 1.1 //
89     // variables needed to reprocess data
90     //
91     TString acversion;
92     ItoRunInfo *runinfo = 0;
93 mocchiut 1.5 TArrayI *runlist = 0;
94 mocchiut 1.1 TTree *acclone = 0;
95     Bool_t reproc = false;
96     Bool_t reprocall = false;
97     UInt_t nobefrun = 0;
98     UInt_t noaftrun = 0;
99     UInt_t numbofrun = 0;
100     stringstream ftmpname;
101     TString fname;
102 mocchiut 1.5 UInt_t totfileentries = 0;
103     UInt_t idRun = 0;
104 mocchiut 1.1 //
105     // variables needed to handle error signals
106     //
107     Int_t code = 0;
108     Int_t sgnl;
109     //
110     // anticounter level2 classes
111     //
112     AcLevel2 *acl2 = new AcLevel2();
113     AcLevel2 *acl2clone = new AcLevel2();
114     // note: the string "mydect" is now "ac", "mydetector" is "anticounter" (mydectversion -> acversion, mydectclone -> acclone);
115     // the string "mydec" (without t) -> acl2 (acl2, acl2clone)
116     //
117     // define variables for opening and reading level0 file
118     //
119     TFile *l0File = 0;
120     TTree *l0tr = 0;
121     TBranch *l0head = 0;
122     TBranch *l0ac = 0;
123 mocchiut 1.5 pamela::EventHeader *eh = 0;
124     pamela::PscuHeader *ph = 0;
125 mocchiut 1.1 pamela::anticounter::AnticounterEvent *acc = 0;
126     //
127     // Define other basic variables
128     //
129     UInt_t procev = 0;
130     stringstream file2;
131     stringstream file3;
132     stringstream qy;
133     Int_t totevent = 0;
134 mocchiut 1.5 UInt_t atime = 0;
135     UInt_t re = 0;
136 mocchiut 1.1 //
137     // Working filename
138     //
139     TString outputfile;
140     stringstream name;
141     name.str("");
142     name << outdir << "/";
143     //
144     // temporary file and folder
145     //
146     TFile *tempfile = 0;
147     TTree *tempac = 0;
148     stringstream tempname;
149     stringstream acfolder;
150     tempname.str("");
151     tempname << outdir;
152     tempname << "/" << processFolder.Data();
153     acfolder.str("");
154     acfolder << tempname.str().c_str();
155     gSystem->MakeDirectory(acfolder.str().c_str());
156     tempname << "/ac2tree_run";
157     tempname << run << ".root";
158     //
159     // DB classes
160     //
161     GL_ROOT *glroot = new GL_ROOT();
162 mocchiut 1.5 GL_TIMESYNC *dbtime = 0;
163 mocchiut 1.1 //
164 mocchiut 1.4 UShort_t CRCcheck[2]= {0,0};
165     UShort_t Status[2]= {0,0};
166     UShort_t Hitmap[2]= {0,0};
167     UShort_t Hitstatus[2]= {0,0};
168     UShort_t Trigger[2] = {0,0};
169     UShort_t Trigg_old[2] = {0,0};
170     UShort_t Counter[2][16];
171     UShort_t Counter_old[2][16];
172     UShort_t Shift[2][16];
173     Int_t vec[2][16][16];
174     Int_t tmp = 0;
175     memset(vec, 0, 2*16*16*sizeof(UShort_t));
176     memset(Shift, 0, 2*16*sizeof(UShort_t));
177     memset(Counter, 0, 2*16*sizeof(UShort_t));
178     memset(Counter_old, 0, 2*16*sizeof(UShort_t));
179     //
180 mocchiut 1.9 Long64_t maxsize = 10000000000LL;
181     TTree::SetMaxTreeSize(maxsize);
182     //
183     //
184 mocchiut 1.1 // Let's start!
185     //
186     //
187     // As a first thing we must check what we have to do: if run = 0 we must process all events in the file has been passed
188     // if run != 0 we must process only that run but first we have to check if the tree Anticounter already exist in the file
189     // if it exists we are reprocessing data and we must delete that entries, if not we must create it.
190     //
191 mocchiut 1.5 if ( run == 0 ) reproc = true;
192 mocchiut 1.1 //
193     // Output file is "outputfile"
194     //
195     outputfile = name.str().c_str();
196     if ( verbose ) printf("\n Output filename is: \n %s \n\n",outputfile.Data());
197     //
198     //
199     if ( !file->IsOpen() ){
200     if ( verbose ) printf(" ANTICOUNTER - ERROR: cannot open file for writing\n");
201     throw -701;
202     };
203     //
204     // Retrieve GL_RUN variables from the level2 file
205     //
206     acversion = AcInfo(false); // we should decide how to handle versioning system
207     //
208     // create an interface to RunInfo called "runinfo"
209     //
210     runinfo = new ItoRunInfo(file);
211     //
212     // open "Run" tree in level2 file, if not existing return an error (sngl != 0)
213     //
214     sgnl = 0;
215     sgnl = runinfo->Update(run,"AC",acversion);
216     if ( sgnl ){
217     if ( verbose ) printf(" ANTICOUNTER - ERROR: RunInfo exited with non-zero status\n");
218     code = sgnl;
219     goto closeandexit;
220     } else {
221     sgnl = 0;
222     };
223     //
224     // number of events in the file BEFORE the first event of our run
225     //
226     nobefrun = runinfo->GetFirstEntry();
227     //
228     // total number of events in the file
229     //
230     totfileentries = runinfo->GetFileEntries();
231     //
232     // first file entry AFTER the last event of our run
233     //
234     noaftrun = runinfo->GetLastEntry() + 1;
235     //
236     // number of run to be processed
237     //
238     numbofrun = runinfo->GetNoRun();
239     //
240     // Try to access the Anticounter tree in the file, if it exists we are reprocessing data if not we are processing a new run
241     //
242     acclone = (TTree*)file->Get("Anticounter");
243     //
244     if ( !acclone ){
245     //
246     // tree does not exist, we are not reprocessing
247     //
248     reproc = false;
249 mocchiut 1.5 if ( run == 0 && verbose ) printf(" ANTICOUNTER - WARNING: you are reprocessing data but AC tree does not exist!\n");
250     if ( verbose && runinfo->IsReprocessing() && run != 0 ) printf(" ANTICOUNTER - WARNING: it seems you are not reprocessing data but Anticounter\n versioning information already exists in RunInfo.\n");
251 mocchiut 1.1
252     } else {
253     //
254     // tree exists, we are reprocessing data. Are we reprocessing a single run or all the file?
255     //
256 mocchiut 1.9 acclone->SetAutoSave(900000000000000LL);
257 mocchiut 1.1 reproc = true;
258     //
259     //
260     if ( verbose ) printf("\n Preparing the pre-processing...\n");
261     //
262 mocchiut 1.5 if ( run == 0 ){
263 mocchiut 1.1 //
264     // we are reprocessing all the file
265     // if we are reprocessing everything we don't need to copy any old event and we can just work with the new tree and delete the old one immediately
266     //
267     reprocall = true;
268     //
269     if ( verbose ) printf("\n ANTICOUNTER - WARNING: Reprocessing all runs\n");
270     //
271     } else {
272     //
273     // we are reprocessing a single run, we must copy to the new tree the events in the file which preceed the first event of the run
274     //
275     reprocall = false;
276     //
277 mocchiut 1.5 if ( verbose ) printf("\n ANTICOUNTER - WARNING: Reprocessing run number %u \n",run);
278 mocchiut 1.1 //
279     // copying old tree to a new file
280     //
281     tempfile = new TFile(tempname.str().c_str(),"RECREATE");
282     tempac = acclone->CloneTree(-1,"fast");
283     tempac->SetName("Anticounter-old");
284     tempfile->Write();
285     tempfile->Close();
286     }
287     //
288     // Delete the old tree from old file and memory
289     //
290     acclone->Delete("all");
291     //
292     if ( verbose ) printf(" ...done!\n");
293     //
294     };
295     //
296     // create anticounter tree ac
297     //
298     file->cd();
299     ac = new TTree("Anticounter-new","PAMELA Level2 Anticounter data");
300 mocchiut 1.9 ac->SetAutoSave(900000000000000LL);
301 mocchiut 1.1 ac->Branch("AcLevel2","AcLevel2",&acl2);
302     //
303     if ( reproc && !reprocall ){
304     //
305     // open new file and retrieve alo tree informations
306     //
307     tempfile = new TFile(tempname.str().c_str(),"READ");
308     acclone = (TTree*)tempfile->Get("Anticounter-old");
309 mocchiut 1.9 acclone->SetAutoSave(900000000000000LL);
310 mocchiut 1.1 acclone->SetBranchAddress("AcLevel2",&acl2clone);
311     //
312     if ( nobefrun > 0 ){
313     if ( verbose ) {
314     printf("\n Pre-processing: copying events from the old tree before the processed run\n");
315 mocchiut 1.5 printf(" Copying %u events in the file which are before the beginning of the run %u \n",nobefrun,run);
316 mocchiut 1.1 printf(" Start copying at event number 0, end copying at event number %u \n",nobefrun);
317     };
318     for (UInt_t j = 0; j < nobefrun; j++){
319     //
320     acclone->GetEntry(j);
321     //
322     // copy acl2clone to acl2
323     //
324 mocchiut 1.3 acl2->Clear();
325 mocchiut 1.5 //
326 mocchiut 1.1 memcpy(&acl2,&acl2clone,sizeof(acl2clone));
327     //
328     // Fill entry in the new tree
329     //
330     ac->Fill();
331     //
332     };
333     if ( verbose ) printf(" Finished successful copying!\n");
334     };
335     };
336     //
337     // Get the list of run to be processed, if only one run has to be processed the list will contain one entry only.
338     //
339     runlist = runinfo->GetRunList();
340     //
341     // Loop over the run to be processed
342     //
343     for (UInt_t irun=0; irun < numbofrun; irun++){
344     //
345     // retrieve the first run ID to be processed using the RunInfo list
346     //
347     idRun = runlist->At(irun);
348     if ( verbose ){
349     printf("\n\n\n ####################################################################### \n");
350 mocchiut 1.5 printf(" PROCESSING RUN NUMBER %u \n",idRun);
351 mocchiut 1.1 printf(" ####################################################################### \n\n\n");
352     };
353     //
354 mocchiut 1.5 runinfo->ID_ROOT_L0 = 0;
355 mocchiut 1.1 //
356     // store in the runinfo class the GL_RUN variables for our run
357     //
358     sgnl = 0;
359     sgnl = runinfo->GetRunInfo(idRun);
360     if ( sgnl ){
361     if ( verbose ) printf(" ANTICOUNTER - ERROR: RunInfo exited with non-zero status\n");
362     code = sgnl;
363     goto closeandexit;
364     } else {
365     sgnl = 0;
366     };
367     //
368 mocchiut 1.5 // now you can access that variables using the RunInfo class this way runinfo->ID_ROOT_L0
369 mocchiut 1.1 //
370 mocchiut 1.5 if ( runinfo->ID_ROOT_L0 == 0 ){
371     if ( verbose ) printf("\n ANTICOUNTER - ERROR: no run with ID_RUN = %u \n\n Exiting... \n\n",idRun);
372 mocchiut 1.1 code = -5;
373     goto closeandexit;
374     };
375     //
376 mocchiut 1.5 // prepare the timesync for the db
377     //
378 mocchiut 1.7 if ( !dbc->IsConnected() ) throw -705;
379 mocchiut 1.5 dbtime = new GL_TIMESYNC(runinfo->ID_ROOT_L0,"ID",dbc);
380     //
381 mocchiut 1.1 // Search in the DB the path and name of the LEVEL0 file to be processed.
382     //
383 mocchiut 1.7 if ( !dbc->IsConnected() ) throw -705;
384 mocchiut 1.5 glroot->Query_GL_ROOT(runinfo->ID_ROOT_L0,dbc);
385 mocchiut 1.1 //
386     ftmpname.str("");
387     ftmpname << glroot->PATH.Data() << "/";
388     ftmpname << glroot->NAME.Data();
389     fname = ftmpname.str().c_str();
390     //
391     // print out informations
392     //
393 mocchiut 1.5 totevent = runinfo->NEVENTS;
394 mocchiut 1.1 if ( verbose ) {
395     printf("\n LEVEL0 data file: %s \n",fname.Data());
396 mocchiut 1.5 printf(" RUN HEADER absolute time is: %u \n",runinfo->RUNHEADER_TIME);
397     printf(" RUN TRAILER absolute time is: %u \n",runinfo->RUNTRAILER_TIME);
398     printf(" %i events to be processed for run %u: from %i to %i \n\n",totevent,idRun,runinfo->EV_FROM,runinfo->EV_FROM+totevent);
399 mocchiut 1.1 };
400     //
401     // Open Level0 file
402     //
403     l0File = new TFile(fname.Data());
404     if ( !l0File ) {
405     if ( verbose ) printf(" ANTICOUNTER - ERROR: problems opening Level0 file\n");
406     code = -6;
407     goto closeandexit;
408     };
409     l0tr = (TTree*)l0File->Get("Physics");
410     if ( !l0tr ) {
411     if ( verbose ) printf(" ANTICOUNTER - ERROR: no Physics tree in Level0 file\n");
412     l0File->Close();
413     code = -7;
414     goto closeandexit;
415     };
416     l0head = l0tr->GetBranch("Header");
417     if ( !l0head ) {
418     if ( verbose ) printf(" ANTICOUNTER - ERROR: no Header branch in Level0 tree\n");
419     l0File->Close();
420     code = -8;
421     goto closeandexit;
422     };
423     l0ac = l0tr->GetBranch("Anticounter");
424     if ( !l0ac ) {
425     if ( verbose ) printf(" ANTICOUNTER - ERROR: no Anticounter branch in Level0 tree\n");
426     l0File->Close();
427     code = -704;
428     goto closeandexit;
429     };
430     //
431     l0tr->SetBranchAddress("Anticounter", &acc);
432 mocchiut 1.5 l0tr->SetBranchAddress("Header", &eh);
433 mocchiut 1.1 //
434 mocchiut 1.5 nevents = l0ac->GetEntries();
435 mocchiut 1.1 //
436     if ( nevents < 1 ) {
437     if ( verbose ) printf(" ANTICOUNTER - ERROR: Level0 file is empty\n\n");
438     l0File->Close();
439     code = -11;
440     goto closeandexit;
441     };
442     //
443 mocchiut 1.5 if ( runinfo->EV_TO > nevents-1 ) {
444     if ( verbose ) printf(" ANTICOUNTER - ERROR: too few entries in the tree\n");
445 mocchiut 1.1 l0File->Close();
446     code = -12;
447     goto closeandexit;
448     };
449     //
450     // run over all the events of the run
451     //
452     if ( verbose ) printf("\n Ready to start! \n\n Processed events: \n\n");
453     //
454 mocchiut 1.5 for ( re = runinfo->EV_FROM; re < (runinfo->EV_FROM+runinfo->NEVENTS); re++){
455 mocchiut 1.1 //
456     if ( procev%1000 == 0 && procev > 0 && verbose ) printf(" %iK \n",procev/1000);
457     //
458 mocchiut 1.5 l0head->GetEntry(re);
459 mocchiut 1.1 //
460     // absolute time of this event
461     //
462 mocchiut 1.5 ph = eh->GetPscuHeader();
463     atime = dbtime->DBabsTime(ph->GetOrbitalTime());
464 mocchiut 1.1 //
465     // paranoid check
466     //
467     if ( atime > runinfo->RUNTRAILER_TIME || atime < runinfo->RUNHEADER_TIME ) {
468     if ( verbose ) printf(" ANTICOUNTER - WARNING: event at time outside the run time window, skipping it\n");
469     goto jumpev;
470     };
471     //
472     procev++;
473     //
474     // start processing
475     //
476 mocchiut 1.3 acl2->Clear();
477 mocchiut 1.1 //
478 mocchiut 1.5 l0ac->GetEntry(re);
479 pam-se 1.2 //
480 mocchiut 1.1 /***********************************************/
481     // Here starts Anticounter specific code (Silvio)
482     //
483 mocchiut 1.4 memset(vec, 0, 2*16*16*sizeof(UShort_t));
484     memset(Shift, 0, 2*16*sizeof(UShort_t));
485     memset(Counter, 0, 2*16*sizeof(UShort_t));
486     memset(Counter_old, 0, 2*16*sizeof(UShort_t));
487     memset(CRCcheck, 0, 2*sizeof(UShort_t));
488     memset(Status, 0, 2*sizeof(UShort_t));
489     memset(Hitmap, 0, 2*sizeof(UShort_t));
490     memset(Hitstatus, 0, 2*sizeof(UShort_t));
491     memset(Trigger, 0, 2*sizeof(UShort_t));
492     memset(Trigg_old, 0, 2*sizeof(UShort_t));
493     tmp = 0;
494 mocchiut 1.1 //
495     for(Int_t gg = 0; gg < 2; gg++)
496     {
497     Hitstatus[gg] = 0;
498     }
499     //
500     //fetch data
501     //
502     for(Int_t kk = 0; kk < 2; kk++)
503     {
504     if(re>0)
505     {
506     Trigg_old[kk] = Trigger[kk];
507     for(Int_t jj = 0; jj < 16; jj++)
508     Counter_old[kk][jj] = Counter[kk][jj];
509     }
510    
511     for(Int_t jj = 0; jj < 16; jj++)
512     {
513     Counter[kk][jj] = acc->counters[kk][jj];
514     Shift[kk][jj] = acc->shift[kk][jj];
515     }
516     Status[kk] = acc->status[kk];
517     Hitmap[kk] = acc->hitmap[kk];
518     Trigger[kk] = acc->trigg[kk];
519     CRCcheck[kk] = acc->CRCcheck[kk];
520     }
521    
522     /***********************************************/
523     //process data
524     /***********************************************/
525     //shiftregisters
526     for(Int_t b = 0; b < 2; b++){ //card
527     for(Int_t k = 0; k < 16; k++){ //shift register
528     Int_t cnt=1;
529     for(Int_t l = 0; l < 16; l++){ //bin
530     tmp = ((Shift[b][k] & cnt) > 0 ? 1 : 0);
531     vec[b][k][l]=tmp;
532     cnt=cnt<<1;
533     }
534     //cnt=1;
535     }
536     }
537 mocchiut 1.5 //
538 mocchiut 1.1 //fill Level1 file
539     /************************************************/
540     for(Int_t s = 0; s < 2; s++) {
541     acl2->hitmap[s] = Hitmap[s];
542     acl2->trigger[s] = Trigger[s];
543     Int_t cnt=1;
544     for(Int_t k = 0; k < 16; k++) {
545     for(Int_t bin = 5; bin < 9; bin++) { //acceptance window
546     if(vec[s][bin][k]==1)
547     Hitstatus[s] = Hitstatus[s] | cnt;
548     }
549     cnt=cnt<<1;
550     }
551     acl2->hitstatus[s] = Hitstatus[s];
552 mocchiut 1.5 //
553 mocchiut 1.1 //Status
554     /****************************************/
555     if(s==0){
556     if(Trigger[0] != (Trigg_old[0]+1))
557     acl2->status[0] = acl2->status[0] | 0x1;
558     if(Status[0] & 0x001F < 0x001F)
559     acl2->status[0] = acl2->status[0] | 0x2;
560     if(CRCcheck[0] == 0)
561     acl2->status[0] = acl2->status[0] | 0x4;
562     for(Int_t gg = 0; gg < 16; gg++){
563 mocchiut 1.5 if((Counter[0][gg] == Counter_old[0][gg]) && re>0){
564 mocchiut 1.1 acl2->status[0] = acl2->status[0] | 0x8;
565     }
566     }
567     }
568     else {
569     if(Trigger[1] != (Trigg_old[1]+2))
570     acl2->status[1] = acl2->status[1] | 0x1;
571     if(Status[1] & 0x001F < 0x001F)
572     acl2->status[1] = acl2->status[1] | 0x2;
573     if(CRCcheck[1] == 0)
574     acl2->status[1] = acl2->status[1] | 0x4;
575     for(Int_t gg = 0; gg < 16; gg++){
576 mocchiut 1.5 if((Counter[1][gg] == Counter_old[1][gg]) && re>0)
577 mocchiut 1.1 acl2->status[1] = acl2->status[1] | 0x8;
578     }
579     }
580     }
581     //
582     // End Anticounter specific code
583     //
584 mocchiut 1.5 /************************************************/
585 mocchiut 1.6 acl2->unpackError = acc->unpackError;
586 mocchiut 1.1 //
587     // Fill the rootple
588     //
589     ac->Fill();
590     //
591     //
592     jumpev:
593     debug = false;
594     //
595     };
596     //
597     // Here you may want to clear some variables before processing another run
598     //
599 mocchiut 1.5 delete dbtime;
600 mocchiut 1.1 }; // process all the runs
601     //
602     if ( verbose ) printf("\n Finished processing data \n");
603     //
604     closeandexit:
605     //
606     // we have finished processing the run(s). If we processed a single run now we must copy all the events after our run from the old tree to the new one and delete the old tree.
607     //
608     if ( !reprocall && reproc && code >= 0 ){
609     if ( totfileentries > noaftrun ){
610     if ( verbose ){
611     printf("\n Post-processing: copying events from the old tree after the processed run\n");
612     printf(" Copying %i events in the file which are after the end of the run %i \n",(int)(totfileentries-noaftrun),(int)run);
613     printf(" Start copying at event number %i end copying at event number %i \n",(int)noaftrun,(int)totfileentries);
614     };
615     for (UInt_t j = noaftrun; j < totfileentries; j++ ){
616     //
617     // Get entry from old tree
618     //
619     acclone->GetEntry(j);
620     //
621     // copy acl2clone to acl2
622     //
623 mocchiut 1.3 acl2->Clear();
624 mocchiut 1.1 memcpy(&acl2,&acl2clone,sizeof(acl2clone));
625     //
626     // Fill entry in the new tree
627     //
628     ac->Fill();
629     };
630     if ( verbose ) printf(" Finished successful copying!\n");
631     };
632     };
633     //
634     // Close files, delete old tree(s), write and close level2 file
635     //
636     if ( l0File ) l0File->Close();
637     if ( tempfile ) tempfile->Close();
638     gSystem->Unlink(tempname.str().c_str());
639     //
640     if ( code < 0 && verbose ) printf("\n ANTICOUNTER - ERROR: an error occurred, try to save anyway...\n");
641     if ( verbose ) printf("\n Writing and closing rootple\n");
642     if ( runinfo ) runinfo->Close();
643     if ( ac ) ac->SetName("Anticounter");
644     if ( file ){
645     file->cd();
646     file->Write();
647     };
648     //
649     gSystem->Unlink(acfolder.str().c_str());
650     //
651     // the end
652     //
653     if ( verbose ) printf("\n Exiting...\n");
654 mocchiut 1.8 //
655 mocchiut 1.1 if( ac ) ac->Delete();
656 mocchiut 1.4 if ( acl2 ) delete acl2;
657 mocchiut 1.8 if ( acl2clone ) delete acl2clone;
658 mocchiut 1.4 if ( glroot ) delete glroot;
659     if ( runinfo ) delete runinfo;
660     //
661 mocchiut 1.1 if(code < 0) throw code;
662     return(code);
663     }
664    
665    

  ViewVC Help
Powered by ViewVC 1.1.23