/[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.11 - (hide annotations) (download)
Tue Apr 17 11:58:10 2007 UTC (17 years, 7 months ago) by mocchiut
Branch: MAIN
Changes since 1.10: +1 -1 lines
XXXFolder bug fixed

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

  ViewVC Help
Powered by ViewVC 1.1.23