/[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.16 - (hide annotations) (download)
Fri Sep 7 21:14:15 2007 UTC (17 years, 3 months ago) by mocchiut
Branch: MAIN
Changes since 1.15: +7 -2 lines
Close MySQL connection before start the main loop in core routines

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

  ViewVC Help
Powered by ViewVC 1.1.23