/[PAMELA software]/DarthVader/S4Level2/src/S4Core.cpp
ViewVC logotype

Annotation of /DarthVader/S4Level2/src/S4Core.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (hide annotations) (download)
Thu Jan 11 14:33:46 2007 UTC (18 years ago) by mocchiut
Branch: MAIN
Changes since 1.8: +6 -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     #include <iostream>
7     #include <cstring>
8     #include <stdio.h>
9     //
10     // ROOT headers
11     //
12 mocchiut 1.4 #include <TGraph.h>
13     #include <TF1.h>
14 mocchiut 1.1 #include <TTree.h>
15     #include <TClassEdit.h>
16     #include <TObject.h>
17     #include <TList.h>
18 mocchiut 1.4 #include <TArrayI.h>
19     #include <TArrayD.h>
20 mocchiut 1.1 #include <TSystem.h>
21     #include <TSystemDirectory.h>
22     #include <TString.h>
23     #include <TFile.h>
24     #include <TClass.h>
25     #include <TSQLServer.h>
26     #include <TSQLRow.h>
27     #include <TSQLResult.h>
28     #include <TClonesArray.h>
29     #include <stdlib.h>
30     #include <math.h>
31     //
32     // YODA headers
33     //
34     #include <PamelaRun.h>
35     #include <PscuHeader.h>
36     #include <PscuEvent.h>
37     #include <EventHeader.h>
38     #include <CalibS4Event.h>
39     #include <physics/S4/S4Event.h>
40     //#include <yodaUtility.h>
41     //
42     // RunInfo header
43     //
44     #include <RunInfo.h>
45     #include <GLTables.h>
46     //
47     // This program headers
48     //
49     #include <S4Level2.h>
50     #include <S4Core.h>
51     #include <S4Verl2.h>
52    
53     using namespace std;
54    
55     //
56 mocchiut 1.4 //
57     //
58     /*
59     * Fit function Received from Valeria Malvezzi 06/02/2006
60     */
61     Double_t fitf(Double_t *x, Double_t *par){
62     Double_t fitval =(par[0]*x[0])+par[1];
63     return fitval;
64     }
65    
66     /*
67     * Fit the S4 calibration with a straight line - Received from Valeria Malvezzi 06/02/2006
68     */
69     TArrayD *S4_paramfit(UInt_t atime, TSQLServer *dbc){
70     //
71     TArrayD *parametri = new TArrayD(2);
72     //
73     GL_S4_CALIB *glS4calib = new GL_S4_CALIB();
74     //
75 mocchiut 1.8 if ( !dbc->IsConnected() ) throw -504;
76 mocchiut 1.4 glS4calib->Query_GL_S4_CALIB(atime, dbc);
77     //
78     GL_ROOT *glroot = new GL_ROOT();
79 mocchiut 1.8 if ( !dbc->IsConnected() ) throw -504;
80 mocchiut 1.4 glroot->Query_GL_ROOT(glS4calib->ID_ROOT_L0,dbc);
81     //
82     stringstream ftmpname;
83     ftmpname.str("");
84     ftmpname << glroot->PATH.Data() << "/";
85     ftmpname << glroot->NAME.Data();
86     //
87     TFile *file = 0;
88     file = new TFile(ftmpname.str().c_str());
89     //
90     if ( !file ) return(NULL);
91     //
92     TTree *tr = 0;
93     tr = (TTree*)file->Get("CalibS4");
94     if ( !tr ){
95     file->Close();
96     return(NULL);
97     };
98     //
99     pamela::CalibS4Event *S4CalibEvent = 0;
100     tr->SetBranchAddress("CalibS4", &S4CalibEvent);
101     if ( tr->GetEntries() < glS4calib->EV_ROOT ) return(NULL);
102     //
103     tr->GetEntry(glS4calib->EV_ROOT);
104     //
105     //----------- variable initialization -------------------------------------------------
106     //
107     Double_t mip[3]={1, 30, 300};
108     Double_t adc[3] = {0.,0.,0.};
109     //
110     //------------ Fit calibrations and find parameters to calibrate data ------------------
111     //
112     pamela::S4::S4Event *s4Record = 0;
113     //
114     for (Int_t j = 0; j < 4; j++){
115     for (Int_t i = 0; i < 128; i++){
116     s4Record = (pamela::S4::S4Event*)S4CalibEvent->Records->At((j*128 + i));
117     switch (j) {
118     case 0 :{
119     adc[0]=adc[0]+((s4Record->S4_DATA)-32);
120     break;
121     };
122     case 1 :{
123     adc[1]=adc[1]+((s4Record->S4_DATA)-32);
124     break;
125     };
126     case 3 :{
127     adc[2]=adc[2]+((s4Record->S4_DATA)-32);
128     break;
129     };
130     };
131     };
132     };
133     //
134     adc[0]=adc[0]/128;
135     adc[1]=adc[1]/128;
136     adc[2]=adc[2]/128;
137     // if ( IsDebug() ) printf(" adc1 = %g adc2 = %g adc3 = %g\n",adc[0],adc[1],adc[2]);
138     TGraph *fitpar = new TGraph (3, adc, mip);
139     TF1 *func = new TF1("fitf", fitf, -1., 400., 2); // definizione della funzione, 2 = num. parametri
140     // TF1 *func = new TF1("fitf", fitf, -0., 1000., 2); // definizione della funzione, 2 = num. parametri
141     //
142     func->SetParameters(0.3,1.); //inizializzazione dei parametri a 1
143     func->SetParNames("m","q"); //definisce il nome dei parametri
144     fitpar->Fit(func,"qr"); //fitta fitpar con la funzione func nel range definito nella funzione
145     //fitpar->Fit(func,"r"); //fitta fitpar con la funzione func nel range definito nella funzione
146     parametri->AddAt(func->GetParameter(0),0);
147     parametri->AddAt(func->GetParameter(1),1);
148     // if ( parametri[0] < 0. || parametri[0] > 0.5 || parametri[1] < 0.7 || parametri[1] > 1.1 ) valid = 0;
149     //
150     delete glroot;
151     delete glS4calib;
152     delete fitpar;
153     delete func;
154     file->Close();
155     //
156     return parametri;
157     };
158    
159     //
160 mocchiut 1.1 // CORE ROUTINE
161     //
162     //
163 mocchiut 1.4 int S4Core(UInt_t run, TFile *file, TSQLServer *dbc, Int_t S4argc, char *S4argv[]){
164 mocchiut 1.1 Int_t i = 0;
165     //
166     TString processFolder = "S4Folder";
167     //
168 mocchiut 1.4 Bool_t debug = false;
169 mocchiut 1.1 //
170 mocchiut 1.4 Bool_t verbose = false;
171 mocchiut 1.1 //
172     if ( S4argc > 0 ){
173     i = 0;
174     while ( i < S4argc ){
175     if ( !strcmp(S4argv[i],"-processFolder") ) {
176     if ( S4argc < i+1 ){
177     throw -3;
178     };
179     processFolder = (TString)S4argv[i+1];
180     i++;
181     };
182     if ( (!strcmp(S4argv[i],"--debug")) || (!strcmp(S4argv[i],"-g"))) {
183     verbose = true;
184     };
185     if ( (!strcmp(S4argv[i],"--verbose")) || (!strcmp(S4argv[i],"-v"))) {
186     verbose = true;
187     };
188     i++;
189     };
190     };
191 mocchiut 1.4 //
192 mocchiut 1.1 const char* outDir = gSystem->DirName(gSystem->DirName(file->GetPath()));
193 mocchiut 1.4 //
194 mocchiut 1.1 // Variables for level2
195     //
196     TTree *S4tr = 0;
197 mocchiut 1.4 UInt_t nevents = 0;
198 mocchiut 1.1 //
199     // variables needed to reprocess data
200     //
201 mocchiut 1.9 Long64_t maxsize = 10000000000LL;
202     TTree::SetMaxTreeSize(maxsize);
203     //
204 mocchiut 1.1 TString S4version;
205     ItoRunInfo *runinfo = 0;
206 mocchiut 1.4 TArrayI *runlist = 0;
207 mocchiut 1.1 TTree *S4trclone = 0;
208     Bool_t reproc = false;
209     Bool_t reprocall = false;
210     UInt_t nobefrun = 0;
211     UInt_t noaftrun = 0;
212     UInt_t numbofrun = 0;
213     stringstream ftmpname;
214     TString fname;
215 mocchiut 1.4 UInt_t totfileentries = 0;
216     UInt_t idRun = 0;
217     Double_t ParamFit0 = 0.;
218     Double_t ParamFit1 = 0.;
219 mocchiut 1.1 //
220     // variables needed to handle error signals
221     //
222     Int_t code = 0;
223     Int_t sgnl;
224     //
225     // S4 level2 classes
226     //
227     S4Level2 *s4 = new S4Level2();
228     S4Level2 *s4clone = new S4Level2();
229     //
230     // define variables for opening and reading level0 file
231     //
232     TFile *l0File = 0;
233     TTree *l0tr = 0;
234     TBranch *l0head = 0;
235     TBranch *l0S4 =0;
236     pamela::S4::S4Event *l0s4e = 0;
237     pamela::EventHeader *eh = 0;
238 mocchiut 1.4 pamela::PscuHeader *ph = 0;
239 mocchiut 1.1 //
240     // Define other basic variables
241     //
242     UInt_t procev = 0;
243     stringstream file2;
244     stringstream file3;
245     stringstream qy;
246     Int_t totevent = 0;
247 mocchiut 1.4 UInt_t atime = 0;
248     // Int_t ei = 0;
249     UInt_t re = 0;
250 mocchiut 1.1 //
251     // Working filename
252     //
253     TString outputfile;
254     stringstream name;
255     name.str("");
256     name << outDir << "/";
257     //
258     // temporary file and folder
259     //
260     TFile *tempfile = 0;
261     TTree *tempS4 = 0;
262     stringstream tempname;
263     stringstream S4folder;
264     tempname.str("");
265     tempname << outDir;
266     tempname << "/" << processFolder.Data();
267     S4folder.str("");
268     S4folder << tempname.str().c_str();
269     gSystem->MakeDirectory(S4folder.str().c_str());
270     tempname << "/S4tree_run";
271     tempname << run << ".root";
272     //
273     // DB classes
274     //
275     GL_ROOT *glroot = new GL_ROOT();
276 mocchiut 1.4 GL_TIMESYNC *dbtime = 0;
277 mocchiut 1.1 //
278     // Let's start!
279     //
280     // 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
281     // if run != 0 we must process only that run but first we have to check if the tree MyDetector2 already exist in the file
282     // if it exists we are reprocessing data and we must delete that entries, if not we must create it.
283     //
284 mocchiut 1.4 if ( run == 0 ) reproc = true;
285 mocchiut 1.1 //
286     //
287     // Output file is "outputfile"
288     //
289     if ( !file->IsOpen() ){
290     //printf(" S4 - ERROR: cannot open file for writing\n");
291     throw -501;
292     };
293     //
294     // Retrieve GL_RUN variables from the level2 file
295     //
296     S4version = S4Info(false); // we should decide how to handle versioning system
297     //
298     // create an interface to RunInfo called "runinfo"
299     //
300     runinfo = new ItoRunInfo(file);
301     //
302     // open "Run" tree in level2 file, if not existing return an error (sngl != 0)
303     //
304     sgnl = 0;
305     sgnl = runinfo->Update(run,"S4",S4version);
306     if ( sgnl ){
307     //printf(" S4 - ERROR: RunInfo exited with non-zero status\n");
308     code = sgnl;
309     goto closeandexit;
310     } else {
311     sgnl = 0;
312     };
313     //
314     // number of events in the file BEFORE the first event of our run
315     //
316     nobefrun = runinfo->GetFirstEntry();
317     //
318     // total number of events in the file
319     //
320     totfileentries = runinfo->GetFileEntries();
321     //
322     // first file entry AFTER the last event of our run
323     //
324     noaftrun = runinfo->GetLastEntry() + 1;
325     //
326     // number of run to be processed
327     //
328     numbofrun = runinfo->GetNoRun();
329     //
330     // Try to access the S4 tree in the file, if it exists we are reprocessing data if not we are processing a new run
331     //
332     S4trclone = (TTree*)file->Get("S4");
333     //
334     if ( !S4trclone ){
335     //
336     // tree does not exist, we are not reprocessing
337     //
338     reproc = false;
339 mocchiut 1.4 if ( run == 0 ){
340 mocchiut 1.1 if (verbose) printf(" S4 - WARNING: you are reprocessing data but S4 tree does not exist!\n");
341     }
342 mocchiut 1.4 if ( runinfo->IsReprocessing() && run != 0 ) {
343 mocchiut 1.1 if (verbose) printf(" S4 - WARNING: it seems you are not reprocessing data but S4\n versioning information already exists in RunInfo.\n");
344     }
345     } else {
346     //
347     // tree exists, we are reprocessing data. Are we reprocessing a single run or all the file?
348     //
349 mocchiut 1.9 S4trclone->SetAutoSave(900000000000000LL);
350 mocchiut 1.1 reproc = true;
351     //
352     // update versioning information
353     //
354     if (verbose) printf("\n Preparing the pre-processing...\n");
355     //
356 mocchiut 1.4 if ( run == 0 ){
357 mocchiut 1.1 //
358     // we are reprocessing all the file
359     // 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
360     //
361     reprocall = true;
362     //
363     if (verbose) printf("\n S4 - WARNING: Reprocessing all runs\n");
364     //
365     } else {
366     //
367     // 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
368     //
369     reprocall = false;
370     //
371 mocchiut 1.4 if (verbose) printf("\n S4 - WARNING: Reprocessing run number %u \n",run);
372 mocchiut 1.1 //
373     // copying old tree to a new file
374     //
375     tempfile = new TFile(tempname.str().c_str(),"RECREATE");
376     tempS4 = S4trclone->CloneTree(-1,"fast");
377     tempS4->SetName("S4-old");
378     tempfile->Write();
379     tempfile->Close();
380     }
381     //
382     // Delete the old tree from old file and memory
383     //
384     S4trclone->Delete("all");
385     //
386     if (verbose) printf(" ...done!\n");
387     //
388     };
389     //
390     // create mydetector tree mydect
391     //
392     file->cd();
393     S4tr = new TTree("S4-new","PAMELA Level2 S4 data");
394 mocchiut 1.9 S4tr->SetAutoSave(900000000000000LL);
395 mocchiut 1.1 S4tr->Branch("S4Level2","S4Level2",&s4);
396     //
397     if ( reproc && !reprocall ){
398     //
399     // open new file and retrieve also tree informations
400     //
401     tempfile = new TFile(tempname.str().c_str(),"READ");
402     S4trclone = (TTree*)tempfile->Get("S4-old");
403 mocchiut 1.9 S4trclone->SetAutoSave(900000000000000LL);
404 mocchiut 1.1 S4trclone->SetBranchAddress("S4Level2",&s4clone);
405     //
406     if ( nobefrun > 0 ){
407     if (verbose){
408     printf("\n Pre-processing: copying events from the old tree before the processed run\n");
409 mocchiut 1.4 printf(" Copying %u events in the file which are before the beginning of the run %u \n",nobefrun,run);
410 mocchiut 1.1 printf(" Start copying at event number 0, end copying at event number %u \n",nobefrun);
411     }
412     for (UInt_t j = 0; j < nobefrun; j++){
413     //
414     S4trclone->GetEntry(j);
415     //
416     // copy s4clone to mydec
417     //
418 mocchiut 1.2 s4->Clear();
419 mocchiut 1.4 //
420 mocchiut 1.1 memcpy(&s4,&s4clone,sizeof(s4clone));
421     //
422     // Fill entry in the new tree
423     //
424     S4tr->Fill();
425     //
426     };
427     if (verbose) printf(" Finished successful copying!\n");
428     };
429     };
430     //
431     // Get the list of run to be processed, if only one run has to be processed the list will contain one entry only.
432     //
433     runlist = runinfo->GetRunList();
434     //
435     // Loop over the run to be processed
436     //
437     for (UInt_t irun=0; irun < numbofrun; irun++){
438     //
439     // retrieve the first run ID to be processed using the RunInfo list
440     //
441     idRun = runlist->At(irun);
442     if (verbose){
443     printf("\n\n\n ####################################################################### \n");
444 mocchiut 1.4 printf(" PROCESSING RUN NUMBER %u \n",idRun);
445 mocchiut 1.1 printf(" ####################################################################### \n\n\n");
446     }
447     //
448 mocchiut 1.4 runinfo->ID_ROOT_L0 = 0;
449 mocchiut 1.1 //
450     // store in the runinfo class the GL_RUN variables for our run
451     //
452     sgnl = 0;
453     sgnl = runinfo->GetRunInfo(idRun);
454     if ( sgnl ){
455 mocchiut 1.4 if ( debug ) printf(" S4 - ERROR: RunInfo exited with non-zero status\n");
456 mocchiut 1.1 code = sgnl;
457     goto closeandexit;
458     } else {
459     sgnl = 0;
460     };
461     //
462 mocchiut 1.5 // now you can access that variables using the RunInfo class this way runinfo->ID_ROOT_L0
463 mocchiut 1.1 //
464 mocchiut 1.4 if ( runinfo->ID_ROOT_L0 == 0 ){
465     if ( debug ) printf("\n S4 - ERROR: no run with ID_RUN = %u \n\n Exiting... \n\n",idRun);
466 mocchiut 1.1 code = -5;
467     goto closeandexit;
468     };
469     //
470 mocchiut 1.4 // prepare the timesync for the db
471     //
472 mocchiut 1.8 if ( !dbc->IsConnected() ) throw -504;
473 mocchiut 1.4 dbtime = new GL_TIMESYNC(runinfo->ID_ROOT_L0,"ID",dbc);
474     //
475 mocchiut 1.1 // Search in the DB the path and name of the LEVEL0 file to be processed.
476     //
477 mocchiut 1.8 if ( !dbc->IsConnected() ) throw -504;
478 mocchiut 1.4 glroot->Query_GL_ROOT(runinfo->ID_ROOT_L0,dbc);
479 mocchiut 1.1 //
480     ftmpname.str("");
481     ftmpname << glroot->PATH.Data() << "/";
482     ftmpname << glroot->NAME.Data();
483     fname = ftmpname.str().c_str();
484     //
485     // print out informations
486     //
487 mocchiut 1.4 totevent = runinfo->NEVENTS;
488 mocchiut 1.1 if (verbose){
489     printf("\n LEVEL0 data file: %s \n",fname.Data());
490 mocchiut 1.4 printf(" RUN HEADER absolute time is: %u \n",runinfo->RUNHEADER_TIME);
491     printf(" RUN TRAILER absolute time is: %u \n",runinfo->RUNTRAILER_TIME);
492     printf(" %i events to be processed for run %u: from %u to %u \n\n",totevent,idRun,runinfo->EV_FROM,(runinfo->EV_FROM+totevent));
493 mocchiut 1.1 }
494     //
495     // Open Level0 file
496     //
497     l0File = new TFile(fname.Data());
498     if ( !l0File ) {
499 mocchiut 1.4 if ( debug ) printf(" S4 - ERROR: problems opening Level0 file\n");
500 mocchiut 1.1 code = -6;
501     goto closeandexit;
502     };
503 mocchiut 1.4 //
504 mocchiut 1.1 l0tr = (TTree*)l0File->Get("Physics");
505     if ( !l0tr ) {
506 mocchiut 1.4 if ( debug ) printf(" S4 - ERROR: no Physics tree in Level0 file\n");
507 mocchiut 1.1 l0File->Close();
508     code = -7;
509     goto closeandexit;
510     };
511     l0head = l0tr->GetBranch("Header");
512     if ( !l0head ) {
513 mocchiut 1.4 if ( debug ) printf(" S4 - ERROR: no Header branch in Level0 tree\n");
514 mocchiut 1.1 l0File->Close();
515     code = -8;
516     goto closeandexit;
517     };
518     l0S4 = l0tr->GetBranch("S4");
519     if ( !l0S4 ) {
520 mocchiut 1.4 if ( debug ) printf(" S4 - ERROR: no S4 branch in Level0 tree\n");
521 mocchiut 1.1 l0File->Close();
522     code = -503;
523     goto closeandexit;
524     };
525     //
526     l0tr->SetBranchAddress("S4", &l0s4e);
527     l0tr->SetBranchAddress("Header", &eh);
528     //
529 mocchiut 1.4 nevents = l0S4->GetEntries();
530 mocchiut 1.1 //
531     if ( nevents < 1 ) {
532 mocchiut 1.4 if ( debug ) printf(" S4 - ERROR: Level0 file is empty\n\n");
533 mocchiut 1.1 l0File->Close();
534     code = -11;
535     goto closeandexit;
536     };
537     //
538 mocchiut 1.5 if ( runinfo->EV_TO > nevents-1 ) {
539 mocchiut 1.4 if ( debug ) printf(" S4 - ERROR: too few entries in the S4 tree\n");
540 mocchiut 1.1 l0File->Close();
541     code = -12;
542     goto closeandexit;
543     };
544     //
545     // Check if we have to load parameter files (or calibration associated to runs and not to events)
546     // second query: which is the value of paramfit relative to the calibration?
547     //
548 mocchiut 1.4 TArrayD *params = 0;
549     params = S4_paramfit(runinfo->RUNHEADER_TIME, dbc);
550     if ( !params ){
551     code = -13;
552     goto closeandexit;
553     };
554     //
555     ParamFit0 = params->At(0);
556     ParamFit1 = params->At(1);
557 mocchiut 1.1 //
558     // run over all the events of the run
559     //
560     if (verbose) printf("\n Ready to start! \n\n Processed events: \n\n");
561     //
562 mocchiut 1.4 for ( re = runinfo->EV_FROM; re < (runinfo->EV_FROM+runinfo->NEVENTS); re++){
563 mocchiut 1.1 //
564     if ( procev%1000 == 0 && procev > 0 && verbose ) printf(" %iK \n",procev/1000);
565     //
566 mocchiut 1.4 l0head->GetEntry(re);
567 mocchiut 1.1 //
568     // absolute time of this event
569     //
570 mocchiut 1.4 ph = eh->GetPscuHeader();
571     atime = dbtime->DBabsTime(ph->GetOrbitalTime());
572 mocchiut 1.1 //
573     // paranoid check
574     //
575     if ( (atime > runinfo->RUNTRAILER_TIME) || (atime < runinfo->RUNHEADER_TIME) ) {
576     if (verbose) printf(" S4 - WARNING: event at time outside the run time window, skipping it\n");
577     goto jumpev;
578     };
579     //
580     procev++;
581     //
582     // start processing
583     //
584 mocchiut 1.2 s4->Clear();
585 mocchiut 1.4 l0S4->GetEntry(re);
586 mocchiut 1.6 if (l0s4e->unpackError == 0){
587     s4->S4adc = l0s4e->S4_DATA;
588     //
589     if ((l0s4e->S4_DATA) > 31 ){
590     s4->S4calibrated = ParamFit0*((l0s4e->S4_DATA)-32)+ParamFit1;
591     }else{
592     s4->S4calibrated = 0;
593     }
594     };
595 mocchiut 1.4 //
596 mocchiut 1.7 s4->unpackError = l0s4e->unpackError;
597     //
598 mocchiut 1.1 S4tr->Fill();
599     //
600     //
601     jumpev:
602     debug = false;
603     //
604     };
605     //
606     // Here you may want to clear some variables before processing another run
607     //
608 mocchiut 1.4 delete dbtime;
609     if ( params ) delete params;
610     //
611 mocchiut 1.1 }; // process all the runs
612     //
613     if (verbose) printf("\n Finished processing data \n");
614     //
615     closeandexit:
616     //
617     // 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.
618     //
619     if ( !reprocall && reproc && code >= 0 ){
620     if ( totfileentries > noaftrun ){
621     if (verbose){
622     printf("\n Post-processing: copying events from the old tree after the processed run\n");
623     printf(" Copying %i events in the file which are after the end of the run %i \n",(int)(totfileentries-noaftrun),(int)run);
624     printf(" Start copying at event number %i end copying at event number %i \n",(int)noaftrun,(int)totfileentries);
625     }
626     for (UInt_t j = noaftrun; j < totfileentries; j++ ){
627     //
628     // Get entry from old tree
629     //
630     S4trclone->GetEntry(j);
631     //
632     // copy s4clone to s4
633     //
634 mocchiut 1.2 // s4 = new S4Level2();
635     s4->Clear();
636 mocchiut 1.1 memcpy(&s4,&s4clone,sizeof(s4clone));
637     //
638     // Fill entry in the new tree
639     //
640     S4tr->Fill();
641     };
642     if (verbose) printf(" Finished successful copying!\n");
643     };
644     };
645     //
646     // Close files, delete old tree(s), write and close level2 file
647     //
648     if ( l0File ) l0File->Close();
649     if ( tempfile ) tempfile->Close();
650     gSystem->Unlink(tempname.str().c_str());
651 mocchiut 1.4 //
652 mocchiut 1.1 if ( runinfo ) runinfo->Close();
653     if ( S4tr ) S4tr->SetName("S4");
654     if ( file ){
655     file->cd();
656     file->Write();
657     };
658     //
659     gSystem->Unlink(S4folder.str().c_str());
660     //
661     // the end
662     //
663     if (verbose) printf("\n Exiting...\n");
664 mocchiut 1.4 if ( S4tr ) S4tr->Delete();
665 mocchiut 1.3 //
666     if ( s4 ) delete s4;
667     if ( s4clone ) delete s4clone;
668     if ( glroot ) delete glroot;
669     if ( runinfo ) delete runinfo;
670     //
671 mocchiut 1.1 if(code < 0) throw code;
672     return(code);
673     }
674    
675    

  ViewVC Help
Powered by ViewVC 1.1.23