/[PAMELA software]/DarthVader/CalorimeterLevel2/src/CaloCore.cpp
ViewVC logotype

Annotation of /DarthVader/CalorimeterLevel2/src/CaloCore.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.43 - (hide annotations) (download)
Thu Sep 4 15:46:14 2008 UTC (16 years, 3 months ago) by mocchiut
Branch: MAIN
Changes since 1.42: +3 -3 lines
Reprocessing bug fixed

1 mocchiut 1.1 //
2     // Given a calibration and a data file this program create an ntuple with LEVEL2 calorimeter variables - Emiliano Mocchiutti
3     //
4 mocchiut 1.3 // CaloCore.cxx version 3.05 (2006-05-30)
5 mocchiut 1.1 //
6     // The only input needed is the path to the directory created by YODA for the data file you want to analyze.
7     //
8     // Changelog:
9 mocchiut 1.3 //
10 mocchiut 1.11 // 3.08 (2006-11-13): Added high energy nuclei capability and "process all events" capability.
11     //
12 mocchiut 1.4 // 3.04 - 3.05 (2006-05-30): Qlast and nlast are now calculated using 4 (not 8) strips aournd the shower axis. Small bug fixed.
13 mocchiut 1.2 //
14     // 3.03 - 3.04 (2006-05-23): Forgot to put impx and impy in the PAMELA reference system, fixed.
15 mocchiut 1.1 //
16     // 3.02 - 3.03 (2006-05-18): updated to be called in DarthVader. Output dimension are now in cm and in the PAMELA reference system.
17     //
18     // 3.01 - 3.02 (2006-04-21): when copying entries get size of caclone and not of ca... (shouldn't matter). Fixed increasing file dimension bug when reprocessing.
19     // Added variable planemax[2], plane of maximum energy release (x and y) in final output. Use ItoRunInfo instead of RunInfo.
20     //
21     // 3.00 - 3.01 (2006-04-14): fixed small bug in tagging the track used to determine track-related variables, put in caloprocessing the opening of parameters files, fixed
22     // small bug in fortran routines
23     //
24     // 2.01 - 3.00 (2006-04-14): almost everything has changed. Now it can process one, all or some runs, introduced the final CaloLevel2 class+methods and the
25     // working class "CaloProcessing", linked to the preliminary tracker flight software v0r00, reads YODA unique output files,
26     // reduced the number of installed libraries, F77 programs splitted depending on the function contained, introduced the readout and
27     // processing of self-trigger events, if the tracker provides more than one track all calorimeter track-related variables are saved
28     // as many times as the number of tracks (via the TClonesArray object in the level2 rootple) and many other small changes.
29     //
30     // 2.00 - 2.01 (2006-01-26): bug: wrong calculation of baselines in some cases, fixed.
31     //
32     // 1.00 - 2.00 (2006-01-11): use TSQL ROOT classes instead of directly calling MySQL.
33     //
34     // 0.00 - 1.00 (2005-09-14): seems working.
35     //
36     // 0.00 (2005-09-09): clone of CaloLEVEL2.c .
37     //
38     // C/C++ headers
39     //
40     #include <fstream>
41     #include <string.h>
42     //
43     // ROOT headers
44     //
45     #include <TTree.h>
46     #include <TClassEdit.h>
47     #include <TObject.h>
48     #include <TList.h>
49 mocchiut 1.8 #include <TArrayI.h>
50 mocchiut 1.1 #include <TSystem.h>
51     #include <TSystemDirectory.h>
52     #include <TString.h>
53     #include <TFile.h>
54     #include <TClass.h>
55     #include <TCanvas.h>
56     #include <TH1.h>
57     #include <TH1F.h>
58     #include <TH2D.h>
59     #include <TLatex.h>
60     #include <TPad.h>
61     #include <TSQLServer.h>
62     #include <TSQLRow.h>
63     #include <TSQLResult.h>
64     #include <TClonesArray.h>
65     #include <TStreamerInfo.h>
66     //
67 mocchiut 1.20 // This program headers
68     //
69     #include <RunInfo.h>
70     //
71 mocchiut 1.1 // YODA headers
72     //
73     #include <PamelaRun.h>
74     #include <physics/trigger/TriggerEvent.h>
75     //
76     // This program headers
77     //
78     #include <CaloCore.h>
79 mocchiut 1.13 #include <CaloLevel1.h>
80 mocchiut 1.1 #include <CaloLevel2.h>
81 mocchiut 1.22 #include <CaloLevel0.h>
82 mocchiut 1.1 #include <CaloVerl2.h>
83     //
84     // Tracker classes headers and definitions
85     //
86     #include <TrkLevel2.h>
87     //
88     using namespace std;
89     //
90     // CORE ROUTINE
91     //
92 mocchiut 1.32 int CaloCore(UInt_t run, TFile *file, GL_TABLES *glt, Int_t calargc, char *calargv[]){
93 mocchiut 1.1 //
94     // Set these to true to have a very verbose output.
95     //
96     Bool_t verbose = false;
97     Bool_t debug = false;
98     //
99 mocchiut 1.21 Bool_t crosst = true;
100 mocchiut 1.36 Bool_t ctground = false;
101 mocchiut 1.41 Bool_t usetable = true;
102     Bool_t noselfct = false;
103 mocchiut 1.21 //
104 mocchiut 1.11 Bool_t trackanyway = true;
105     //
106     Float_t rigdefault = 50.;
107 mocchiut 1.35 //
108 mocchiut 1.11 Bool_t hZn = true;
109     //
110     Bool_t withtrk = true;
111     //
112     Bool_t st = true;
113     //
114 mocchiut 1.13 Bool_t getl1 = true;
115     //
116 mocchiut 1.23 Bool_t mechal = false;
117     //
118 mocchiut 1.30 Bool_t checksimu = true;
119     //
120 mocchiut 1.1 // Output directory is the working directoy.
121     //
122     const char* outdir = gSystem->DirName(gSystem->DirName(file->GetPath()));
123     //
124     Int_t ri = 0;
125 mocchiut 1.26 TString processFolder = Form("calorimeterFolder_%u",run);
126 mocchiut 1.1 if ( calargc > 0 ){
127     ri = 0;
128     while ( ri < calargc ){
129     if ( !strcmp(calargv[ri],"-processFolder") ) {
130     if ( calargc < ri+1 ){
131     throw -3;
132     };
133     processFolder = (TString)calargv[ri+1];
134     ri++;
135     };
136     if ( !strcmp(calargv[ri],"-v") || !strcmp(calargv[ri],"--verbose") ) {
137     verbose = true;
138     };
139     if ( !strcmp(calargv[ri],"-g") || !strcmp(calargv[ri],"--debug") ) {
140 mocchiut 1.13 verbose = true;
141 mocchiut 1.1 debug = true;
142     };
143 mocchiut 1.11 if ( !strcmp(calargv[ri],"--alltracks") ) {
144     trackanyway = true;
145     };
146 mocchiut 1.23 if ( !strcmp(calargv[ri],"--use-default-alig") ) {
147     mechal = true;
148     };
149 mocchiut 1.21 if ( !strcmp(calargv[ri],"--no-crosstalk") ) {
150     crosst = false;
151     };
152 mocchiut 1.34 if ( !strcmp(calargv[ri],"--flight-crosstalk") ) {
153     ctground = false;
154     };
155 mocchiut 1.41 if ( !strcmp(calargv[ri],"--ct-use-pulse") ) {
156     usetable = false;
157     };
158     if ( !strcmp(calargv[ri],"--ct-use-table") ) {
159     usetable = true;
160     };
161 mocchiut 1.34 if ( !strcmp(calargv[ri],"--ground-crosstalk") ) {
162     ctground = true;
163     };
164 mocchiut 1.41 if ( !strcmp(calargv[ri],"--no-self-crosstalk") ) {
165     noselfct = true;
166     };
167 mocchiut 1.11 if ( !strcmp(calargv[ri],"--no-tracker") ) {
168     withtrk = false;
169     };
170     if ( !strcmp(calargv[ri],"--with-tracker") ) {
171     withtrk = true;
172     };
173     if ( !strcmp(calargv[ri],"--defrig") ) {
174     if ( calargc < ri+1 ){
175     throw -3;
176     };
177     rigdefault = atof(calargv[ri+1]);
178     ri++;
179     };
180     if ( !strcmp(calargv[ri],"--no-alltracks") ) {
181     trackanyway = false;
182     };
183     if ( !strcmp(calargv[ri],"--highZnuclei") ) {
184     hZn = true;
185     };
186     if ( !strcmp(calargv[ri],"--no-highZnuclei") ) {
187     hZn = false;
188     };
189     if ( !strcmp(calargv[ri],"--selftrigger") ) {
190     st = true;
191     };
192     if ( !strcmp(calargv[ri],"--no-selftrigger") ) {
193     st = false;
194     };
195 mocchiut 1.13 if ( !strcmp(calargv[ri],"--no-level1") ) {
196     getl1 = false;
197     };
198 mocchiut 1.41 if ( !strcmp(calargv[ri],"--level1") ) {
199     getl1 = true;
200     };
201 mocchiut 1.30 if ( !strcmp(calargv[ri],"--ignore-h20") ) {
202     checksimu = false;
203     };
204 mocchiut 1.11 if ( !strcmp(calargv[ri],"--help") ) {
205     printf("\n\n CALORIMETER HELP CALLED\n\n");
206     printf(" CaloCore options: \n");
207     printf(" -v | --verbose be verbose\n");
208     printf(" -g | --debug be really verbose\n");
209     printf(" --defrig rig rig is the default rigidity in GV to be used to\n");
210     printf(" obtain calorimeter variables in the routines\n");
211     printf(" \"alltracks\" and \"higZnuclei\" [default = 50]\n");
212     printf(" --alltracks fill the track related variables even in the case\n");
213     printf(" of no tracks from tracker and no selftrigger event\n");
214 mocchiut 1.14 printf(" when we have a calorimeter fit for both views [default]\n");
215     printf(" --no-alltracks fill the track related variables only in the case\n");
216     printf(" of a good track from tracker or selftrigger\n");
217 mocchiut 1.11 printf(" --highZnuclei call the routine to analyze high Z nuclei\n");
218     printf(" selftrigger events [default]\n");
219     printf(" --no-highZnuclei do not call the routine to analyze high Z nuclei\n");
220     printf(" selftrigger events\n");
221     printf(" --no-tracker do not use tracker level2\n");
222     printf(" --with-tracker use tracker level2 [default]\n");
223 mocchiut 1.21 printf(" --no-crosstalk do not apply crosstalk corrections\n");
224 mocchiut 1.37 printf(" --ground-crosstalk apply ground crosstalk corrections\n");
225     printf(" --flight-crosstalk apply flight crosstalk corrections [default]\n");
226 mocchiut 1.41 printf(" --no-self-crosstalk do not apply preamplifiers crosstalk corrections to the strip itself\n");
227     printf(" --ct--use-pulse flight crosstalk corrections from pulse calibrations \n");
228     printf(" --ct--use-table flight crosstalk corrections from calibration table [default] \n");
229 mocchiut 1.11 printf(" --selftrigger process selftrigger events [default]\n");
230     printf(" --no-selftrigger skip selftrigger events\n");
231 mocchiut 1.13 printf(" --no-level1 do not save Level1 TBranch\n");
232 mocchiut 1.41 printf(" --level1 save Level1 TBranch [default] \n");
233 mocchiut 1.30 printf(" --ignore-h20 do not check if it is a file from simulations\n");
234 mocchiut 1.27 printf(" --use-default-alig use default mechanical alignement (defined in CaloLevel1.h)\n");
235 mocchiut 1.11 throw -114;
236     };
237 mocchiut 1.1 ri++;
238     };
239     };
240     //
241 mocchiut 1.13 if ( verbose ){
242     printf("\n");
243     if ( getl1 ) printf(" Saving calorimeter level1 data \n");
244     if ( st ) printf(" Calling selftrigger subroutine \n");
245     if ( hZn ) printf(" Calling high energy nuclei subroutine \n");
246     if ( trackanyway ) printf(" Filling track related variables for all the possible tracks \n");
247     if ( hZn || trackanyway ) printf(" => default assumed rigidity %f \n",rigdefault);
248     if ( withtrk ) printf(" Using tracker level2 data \n");
249 mocchiut 1.27 if ( mechal ) printf(" Using default mechanical alignement (defined in CaloLevel1.h)\n");
250 mocchiut 1.34 if ( crosst ){
251     printf(" Applying cross-talk corrections \n");
252     if ( ctground ){
253     printf(" => Using ground cross-talk coefficients \n");
254     } else {
255 mocchiut 1.41 printf(" => Using flight cross-talk coefficients... \n");
256     };
257     if ( usetable ){
258     printf(" ... coming from tables \n");
259     } else {
260     printf(" ... coming from pulse calibrations \n");
261 mocchiut 1.34 };
262     } else {
263     printf(" Do not applying cross-talk corrections \n");
264     };
265     if ( !checksimu ) printf(" Check on h20 TTree in level2 file skipped \n");
266 mocchiut 1.13 printf("\n");
267     };
268 mocchiut 1.11 //
269 mocchiut 1.1 // Working filename
270     //
271     TString outputfile;
272     stringstream name;
273     name.str("");
274     name << outdir << "/";
275     //
276     // Variables.
277     //
278     TTree *tracker = 0;
279     TTree *calo = 0;
280     TTree *caloclone = 0;
281     Bool_t reproc = false;
282     Bool_t reprocall = false;
283 mocchiut 1.8 UInt_t nevents = 0;
284 mocchiut 1.1 UInt_t nobefrun = 0;
285     UInt_t noaftrun = 0;
286     UInt_t numbofrun = 0;
287 mocchiut 1.8 UInt_t totnorun = 0;
288 mocchiut 1.1 //
289     Int_t code = 0;
290     Int_t sgnl;
291     //
292     // calorimeter level2 classes
293     //
294 mocchiut 1.13 CaloLevel1 *c1 = 0;
295     CaloLevel1 *c1clone = 0;
296     if ( getl1 ){
297     c1 = new CaloLevel1();
298     c1clone = new CaloLevel1();
299     };
300     //
301     // calorimeter level2 classes
302     //
303 mocchiut 1.1 CaloLevel2 *ca = new CaloLevel2();
304     CaloLevel2 *caclone = new CaloLevel2();
305     //
306     TrkLevel2 *trk = new TrkLevel2();
307 mocchiut 1.8 Int_t nevtrkl2 = 0;
308 mocchiut 1.1 //
309     UInt_t procev = 0;
310     //
311 mocchiut 1.8 // define variables where to store the absolute run header and run trailer times (unsigned long long integers, when set to a number use to store the correct number).
312 mocchiut 1.1 //
313 mocchiut 1.8 UInt_t runheadtime = 0;
314     UInt_t runtrailtime = 0;
315 mocchiut 1.1 UInt_t evfrom = 0;
316     UInt_t evto = 0;
317 mocchiut 1.8 UInt_t totfileentries = 0;
318     UInt_t idRun = 0;
319 mocchiut 1.1 Int_t id_reg_run=-1;
320     stringstream ftmpname;
321     TString fname;
322     //
323     // define variables for opening and reading level0 file
324     //
325     TFile *l0File = 0;
326     TTree *l0tr = 0;
327 mocchiut 1.24 TTree *softinfo = 0;
328 mocchiut 1.1 TBranch *l0head = 0;
329     TBranch *l0calo = 0;
330     TBranch *l0trig = 0;
331 mocchiut 1.8 pamela::EventHeader *eh = 0;
332     pamela::PscuHeader *ph = 0;
333 mocchiut 1.1 pamela::trigger::TriggerEvent *trig = 0;
334 mocchiut 1.24 Int_t yodaver = 0;
335 mocchiut 1.1 //
336     // Define some basic variables
337     //
338 mocchiut 1.22 CaloLevel0 *event = new CaloLevel0(); // NOTICE: very important to call here the constructor!
339 mocchiut 1.21 event->SetCrossTalk(crosst);
340 mocchiut 1.41 // event->SetCrossTalkType(ctground);
341     Int_t ict = -1;
342     if ( ctground ) ict = 0;
343     if ( !ctground ){
344     ict = 1;
345     };
346     if ( !ctground && noselfct ){
347     ict = 2;
348     };
349     event->SetCrossTalkType(ict);
350 mocchiut 1.1 stringstream file2;
351     stringstream file3;
352     stringstream qy;
353     // Bool_t imtrack = false;
354     Bool_t filled = false;
355     //
356 mocchiut 1.8 UInt_t caloevents = 0;
357 mocchiut 1.1 stringstream calfile;
358     stringstream aligfile;
359     //
360     Int_t i = -1;
361     Int_t itr = -1;
362     Int_t badevent = 0;
363     Int_t totevent = 0;
364     //
365 mocchiut 1.8 UInt_t atime = 0;
366 mocchiut 1.1 //
367     Int_t S3 = 0;
368     Int_t S2 = 0;
369     Int_t S12 = 0;
370     Int_t S11 = 0;
371     UInt_t re = 0;
372 mocchiut 1.9 UInt_t jumped = 0;
373 mocchiut 1.1 //
374     TString caloversion;
375     ItoRunInfo *runinfo = 0;
376 mocchiut 1.8 TArrayI *runlist = 0;
377 mocchiut 1.1 //
378     Float_t tmptrigty = -1.;
379     Int_t ntrkentry = 0;
380     GL_PARAM *q4 = new GL_PARAM();
381 mocchiut 1.8 UInt_t tttrkpar1 = 0;
382 mocchiut 1.1 Bool_t trkpar1 = true;
383     GL_ROOT *glroot = new GL_ROOT();
384 mocchiut 1.8 GL_TIMESYNC *dbtime = 0;
385 mocchiut 1.1 //
386 mocchiut 1.15 Long64_t maxsize = 10000000000LL;
387     TTree::SetMaxTreeSize(maxsize);
388 mocchiut 1.1 //
389     //
390     TFile *tempfile = 0;
391     TTree *tempcalo = 0;
392 mocchiut 1.30 Bool_t myfold = false;
393 mocchiut 1.1 stringstream tempname;
394     stringstream calofolder;
395     tempname.str("");
396     tempname << outdir;
397     tempname << "/" << processFolder.Data();
398     calofolder.str("");
399     calofolder << tempname.str().c_str();
400     tempname << "/calotree_run";
401     tempname << run << ".root";
402     //
403     // As a first thing we must check what we have to do: if run = -1 we must process all events in the file has been passed
404     // if run != -1 we must process only that run but first we have to check if the branch calorimeter already exist in the file
405     // if it exists we are reprocessing data and we must delete that entries, if not we must create it.
406     //
407 mocchiut 1.8 if ( run == 0 ) reproc = true;
408 mocchiut 1.1 //
409     //
410     //
411     if ( !file->IsOpen() ){
412     if ( verbose ) printf(" CALORIMETER - ERROR: cannot open file for writing\n");
413     throw -101;
414     };
415     //
416 mocchiut 1.11 if ( withtrk ){
417     //
418     // Does it contain the Tracker tree?
419     //
420     tracker = (TTree*)file->Get("Tracker");
421     if ( !tracker ) {
422     if ( verbose ) printf(" CALORIMETER - ERROR: no tracker tree\n");
423     code = -102;
424     goto closeandexit;
425     };
426     tracker->SetBranchAddress("TrkLevel2",&trk);
427     nevtrkl2 = tracker->GetEntries();
428 mocchiut 1.1 };
429     //
430 mocchiut 1.30 // Is it a file from simulations?
431     //
432     if ( checksimu ){
433     TTree *h20 = (TTree*)file->Get("h20");
434     if ( h20 ){
435     //
436     // yes!
437     //
438     crosst = false;
439 mocchiut 1.34 ctground = true;
440 mocchiut 1.30 mechal = true;
441     if ( verbose ) printf("\n\n SIMULATION!!! Setting --use-default-alig and --no-crosstalk flags!\n\n");
442     h20->Delete();
443     };
444     };
445     //
446 mocchiut 1.1 // Call runinfo
447     //
448     sgnl = 0;
449     runinfo = new ItoRunInfo(file);
450     //
451     // update versioning information and retrieve informations about the run to be processed
452     //
453     caloversion = CaloInfo(false);
454     sgnl = runinfo->Update(run,"CALO",caloversion);
455     //
456     if ( sgnl ){
457     if ( verbose ) printf(" CALORIMETER - ERROR: RunInfo exited with non-zero status\n");
458     code = sgnl;
459     goto closeandexit;
460     } else {
461     sgnl = 0;
462     };
463     //
464     // number of events in the file BEFORE the first event of our run
465     //
466     nobefrun = runinfo->GetFirstEntry();
467     //
468     // total number of events in the file
469     //
470     totfileentries = runinfo->GetFileEntries();
471     //
472     // first file entry AFTER the last event of our run
473     //
474     noaftrun = runinfo->GetLastEntry() + 1;
475     //
476     // number of run to be processed
477     //
478     numbofrun = runinfo->GetNoRun();
479     //
480     // number of runs in the file
481     //
482     totnorun = runinfo->GetRunEntries();
483     //
484     // Does it contain already a Calorimeter branch? if so we are reprocessing data, if not we must create it.
485     //
486     caloclone = (TTree*)file->Get("Calorimeter");
487     //
488     if ( !caloclone ){
489     reproc = false;
490 mocchiut 1.8 if ( run == 0 && verbose ) printf(" CALORIMETER - WARNING: you are reprocessing data but calorimeter tree does not exist!\n");
491     if ( runinfo->IsReprocessing() && run != 0 && verbose ) printf(" CALORIMETER - WARNING: it seems you are not reprocessing data but calorimeter\n versioning information already exists in RunInfo.\n");
492 mocchiut 1.1 //
493     } else {
494     //
495 mocchiut 1.15 caloclone->SetAutoSave(900000000000000LL);
496 mocchiut 1.1 reproc = true;
497     //
498     if ( verbose ) printf("\n Preparing the pre-processing...\n");
499     //
500 mocchiut 1.28 if ( run == 0 || totnorun == 1 ){
501 mocchiut 1.1 //
502     // if we are reprocessing everything we don't need to copy any old event and we can just create a new branch in the clone tree and jump steps 4/5/7.
503     //
504     if ( verbose ) printf("\n CALORIMETER - WARNING: Reprocessing all runs in the file\n");
505     reprocall = true;
506     //
507     } else {
508     //
509     // we are reprocessing a single run
510     //
511 mocchiut 1.8 if ( verbose ) printf("\n CALORIMETER - WARNING: Reprocessing run number %u \n",run);
512 mocchiut 1.1 reprocall = false;
513     //
514     //
515     //
516 mocchiut 1.30 gSystem->MakeDirectory(calofolder.str().c_str());
517     myfold = true;
518 mocchiut 1.1 tempfile = new TFile(tempname.str().c_str(),"RECREATE");
519     tempcalo = caloclone->CloneTree(-1,"fast");
520     tempcalo->SetName("Calorimeter-old");
521     tempfile->Write();
522     tempfile->Close();
523     };
524     //
525     // delete old tree
526     //
527     caloclone->Delete("all");
528     //
529     if ( verbose ) printf("\n ...done!\n");
530     //
531     };
532     //
533     // create calorimeter tree calo
534     //
535     file->cd();
536     calo = new TTree("Calorimeter-new","PAMELA Level2 calorimeter data");
537 mocchiut 1.15 calo->SetAutoSave(900000000000000LL);
538 pam-fi 1.16 ca->Set();
539 mocchiut 1.1 calo->Branch("CaloLevel2","CaloLevel2",&ca);
540 mocchiut 1.13 if ( getl1 ) calo->Branch("CaloLevel1","CaloLevel1",&c1);
541 mocchiut 1.1 //
542     if ( reproc && !reprocall ){
543     //
544     //
545     //
546     tempfile = new TFile(tempname.str().c_str(),"READ");
547     caloclone = (TTree*)tempfile->Get("Calorimeter-old");
548 mocchiut 1.15 caloclone->SetAutoSave(900000000000000LL);
549 mocchiut 1.1 caloclone->SetBranchAddress("CaloLevel2",&caclone);
550 mocchiut 1.13 TBranch *havel1 = caloclone->GetBranch("CaloLevel1");
551     if ( !havel1 && getl1 ) throw -117;
552     if ( havel1 && !getl1 ) throw -118;
553     if ( getl1 ) caloclone->SetBranchAddress("CaloLevel1",&c1clone);
554 mocchiut 1.1 //
555     if ( nobefrun > 0 ){
556     if ( verbose ) printf("\n Pre-processing: copying events from the old tree before the processed run\n");
557 mocchiut 1.8 if ( verbose ) printf(" Copying %u events in the file which are before the beginning of the run %u \n",nobefrun,run);
558 mocchiut 1.1 if ( verbose ) printf(" Start copying at event number 0, end copying at event number %u \n",nobefrun);
559     for (UInt_t j = 0; j < nobefrun; j++){
560     //
561     caloclone->GetEntry(j);
562     //
563     // copy caclone to ca
564     //
565 mocchiut 1.13 if ( getl1 ) memcpy(&c1,&c1clone,sizeof(c1clone));
566 mocchiut 1.1 memcpy(&ca,&caclone,sizeof(caclone));
567     //
568     // Fill entry in the new tree
569     //
570     calo->Fill();
571     //
572 mocchiut 1.13 if ( getl1 ) c1->Clear();
573 mocchiut 1.6 ca->Clear();
574     //
575 mocchiut 1.1 };
576     if ( verbose ) printf(" Finished successful copying!\n");
577     };
578     };
579     //
580     // Get the list of run to be processed
581     //
582     runlist = runinfo->GetRunList();
583     //
584     // Loop over the run to be processed
585     //
586     for (UInt_t irun=0; irun < numbofrun; irun++){
587     //
588     badevent = 0;
589     //
590     idRun = runlist->At(irun);
591     if ( verbose ) printf("\n\n\n ####################################################################### \n");
592 mocchiut 1.8 if ( verbose ) printf(" PROCESSING RUN NUMBER %u \n",idRun);
593 mocchiut 1.1 if ( verbose ) printf(" ####################################################################### \n\n\n");
594     //
595     sgnl = runinfo->GetRunInfo(idRun);
596     if ( sgnl ){
597     if ( verbose ) printf(" CALORIMETER - ERROR: RunInfo exited with non-zero status\n");
598     code = sgnl;
599     goto closeandexit;
600     } else {
601     sgnl = 0;
602     };
603 mocchiut 1.8 id_reg_run = runinfo->ID_ROOT_L0;
604 mocchiut 1.1 runheadtime = runinfo->RUNHEADER_TIME;
605     runtrailtime = runinfo->RUNTRAILER_TIME;
606 mocchiut 1.8 evfrom = runinfo->EV_FROM;
607     evto = runinfo->EV_TO;
608 mocchiut 1.1 //
609     if ( id_reg_run == -1 ){
610 mocchiut 1.8 if ( verbose ) printf("\n CALORIMETER - ERROR: no run with ID_RUN = %u \n\n Exiting... \n\n",idRun);
611 mocchiut 1.1 code = -5;
612     goto closeandexit;
613     };
614     //
615 mocchiut 1.8 // prepare the timesync for the db
616     //
617 mocchiut 1.32 TString host = glt->CGetHost();
618     TString user = glt->CGetUser();
619     TString psw = glt->CGetPsw();
620     TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
621     if ( !dbc->IsConnected() ) throw -116;
622 mocchiut 1.33 stringstream myquery;
623     myquery.str("");
624     myquery << "SET time_zone='+0:00'";
625     dbc->Query(myquery.str().c_str());
626 mocchiut 1.32 //
627 mocchiut 1.31 // if ( !dbc->IsConnected() ) throw -116;
628 mocchiut 1.8 dbtime = new GL_TIMESYNC(runinfo->ID_ROOT_L0,"ID",dbc);
629     //
630 mocchiut 1.1 // Search in the DB the path and name of the LEVEL0 file to be processed.
631     //
632 mocchiut 1.31 // if ( !dbc->IsConnected() ) throw -116;
633 mocchiut 1.8 glroot->Query_GL_ROOT(runinfo->ID_ROOT_L0,dbc);
634 mocchiut 1.1 //
635     ftmpname.str("");
636     ftmpname << glroot->PATH.Data() << "/";
637     ftmpname << glroot->NAME.Data();
638     fname = ftmpname.str().c_str();
639     //
640     // print out informations
641     //
642 mocchiut 1.8 totevent = runinfo->NEVENTS;
643 mocchiut 1.1 if ( verbose ) printf("\n LEVEL0 data file: %s \n",fname.Data());
644 mocchiut 1.8 if ( verbose ) printf(" RUN HEADER absolute time is: %u \n",runheadtime);
645     if ( verbose ) printf(" RUN TRAILER absolute time is: %u \n",runtrailtime);
646     if ( verbose ) printf(" %i events to be processed for run %u: from %i to %i (reg entries)\n\n",totevent,idRun,evfrom,evfrom+totevent);
647 mocchiut 1.1 //
648 mocchiut 1.43 // if ( !totevent ) goto closeandexit;
649 mocchiut 1.42 //
650 mocchiut 1.1 // Open Level0 file
651     //
652     l0File = new TFile(fname.Data());
653     if ( !l0File ) {
654     if ( verbose ) printf(" CALORIMETER - ERROR: problems opening Level0 file\n");
655     code = -6;
656     goto closeandexit;
657     };
658     l0tr = (TTree*)l0File->Get("Physics");
659     if ( !l0tr ) {
660     if ( verbose ) printf(" CALORIMETER - ERROR: no Physics tree in Level0 file\n");
661     l0File->Close();
662     code = -7;
663     goto closeandexit;
664     };
665     l0head = l0tr->GetBranch("Header");
666     if ( !l0head ) {
667     if ( verbose ) printf(" CALORIMETER - ERROR: no Header branch in Level0 tree\n");
668     l0File->Close();
669     code = -8;
670     goto closeandexit;
671     };
672     l0calo = l0tr->GetBranch("Calorimeter");
673     if ( !l0calo ) {
674     if ( verbose ) printf(" CALORIMETER - ERROR: no Calorimeter branch in Level0 tree\n");
675     l0File->Close();
676     code = -103;
677     goto closeandexit;
678     };
679     l0trig = l0tr->GetBranch("Trigger");
680     if ( !l0trig ) {
681     if ( verbose ) printf(" CALORIMETER - ERROR: no Trigger branch in Level0 tree\n");
682     l0File->Close();
683     code = -104;
684     goto closeandexit;
685     };
686     //
687     l0tr->SetBranchAddress("Trigger", &trig);
688 mocchiut 1.8 l0tr->SetBranchAddress("Header", &eh);
689 mocchiut 1.1 //
690 mocchiut 1.24 softinfo = (TTree*)l0File->Get("SoftInfo");
691     if ( softinfo ){
692     softinfo->SetBranchAddress("SoftInfo",&yodaver);
693     softinfo->GetEntry(0);
694     };
695     if ( debug ) printf(" LEVEL0 FILE GENERATED WITH YODA VERSION %i \n",yodaver);
696     //
697 mocchiut 1.38 if ( withtrk ){
698     if ( trkpar1 || ( tttrkpar1 != 0 && tttrkpar1 < runheadtime ) ){
699     trkpar1 = false;
700     Int_t glpar = q4->Query_GL_PARAM(runinfo->RUNHEADER_TIME,1,dbc);
701     if ( glpar < 0 ){
702     code = glpar;
703     goto closeandexit;
704     };
705     tttrkpar1 = q4->TO_TIME;
706     // ----------------------------
707     // Read the magnetic field
708     // ----------------------------
709     if ( verbose ) printf(" Reading magnetic field maps at %s\n",(q4->PATH+q4->NAME).Data());
710     trk->LoadField(q4->PATH+q4->NAME);
711     if ( verbose ) printf("\n");
712     };
713     };
714     //
715     // Close DB connection
716     //
717     if ( dbc ){
718     dbc->Close();
719     delete dbc;
720     };
721     //
722     //
723 mocchiut 1.1 // Construct the event object, look for the calibration which include the first header
724     //
725     sgnl = 0;
726     if ( verbose ) printf(" Check for calorimeter calibrations and initialize event object \n");
727 mocchiut 1.31 // if ( !dbc->IsConnected() ) throw -116;
728 mocchiut 1.32 event->ProcessingInit(glt,runheadtime,sgnl,l0tr,debug,verbose);
729 mocchiut 1.1 if ( verbose ) printf("\n");
730     if ( sgnl == 100 ) {
731     code = sgnl;
732     if ( verbose ) printf(" CALORIMETER - WARNING: run header not included in any calibration interval\n");
733     sgnl = 0;
734     };
735     if ( sgnl ){
736     l0File->Close();
737     code = sgnl;
738     goto closeandexit;
739     };
740     //
741     qy.str("");
742     //
743 mocchiut 1.8 nevents = l0head->GetEntries();
744 mocchiut 1.1 caloevents = l0calo->GetEntries();
745     //
746 mocchiut 1.43 if ( nevents < 1 && totevent ) {
747 mocchiut 1.1 if ( verbose ) printf(" CALORIMETER - ERROR: Level0 file is empty\n\n");
748     l0File->Close();
749     code = -11;
750     goto closeandexit;
751     };
752     //
753 mocchiut 1.43 if ( evto > nevents-1 && totevent ) {
754 mocchiut 1.1 if ( verbose ) printf(" CALORIMETER - ERROR: too few entries in the registry tree\n");
755     l0File->Close();
756     code = -12;
757     goto closeandexit;
758     };
759     //
760     // Check if we have to load parameter files
761     //
762     sgnl = 0;
763 mocchiut 1.32 sgnl = event->ChkParam(glt,runheadtime,mechal); // calorimeter parameter files
764 mocchiut 1.1 if ( sgnl < 0 ){
765     code = sgnl;
766     l0File->Close();
767     goto closeandexit;
768     };
769     //
770 mocchiut 1.34 // Calculate the cross talk corrections needed for this run using calibration informations
771     //
772     if ( crosst && !ctground ){
773     sgnl = 0;
774 mocchiut 1.41 sgnl = event->CalcCrossTalkCorr(glt,runheadtime,usetable);
775 mocchiut 1.34 if ( sgnl < 0 ){
776     code = sgnl;
777     l0File->Close();
778     goto closeandexit;
779     };
780     };
781     //
782 mocchiut 1.1 // run over all the events of the run
783     //
784     if ( verbose ) printf("\n Ready to start! \n\n Processed events: \n\n");
785     //
786 mocchiut 1.19 for ( re = runinfo->EV_FROM; re < (runinfo->EV_FROM+runinfo->NEVENTS); re++){
787 mocchiut 1.40 //for ( re = 92012+3400; re < 92012+3700; re++){
788 mocchiut 1.18 // printf(" i = %i \n",re-200241);
789 mocchiut 1.1 //
790     if ( procev%1000 == 0 && procev > 0 && verbose ) printf(" %iK \n",procev/1000);
791     //
792 mocchiut 1.39 if ( debug ) printf("\n\n\n EVENT NUMBER %i \n",procev);
793     //
794 mocchiut 1.8 l0head->GetEntry(re);
795 mocchiut 1.1 //
796     // absolute time of this event
797     //
798 mocchiut 1.8 ph = eh->GetPscuHeader();
799     atime = dbtime->DBabsTime(ph->GetOrbitalTime());
800 mocchiut 1.1 //
801     //
802     //
803 mocchiut 1.8 if ( re > caloevents-1 ){
804 mocchiut 1.1 if ( verbose ) printf(" CALORIMETER - ERROR: no physics events with entry = %i in Level0 file\n",i);
805     l0File->Close();
806     code = -112;
807     goto closeandexit;
808     };
809     //
810     if ( atime > runtrailtime || atime < runheadtime ) {
811     if ( verbose ) printf(" CALORIMETER - WARNING: event at time outside the run time window, skipping it\n");
812 mocchiut 1.9 jumped++;
813 mocchiut 1.1 goto jumpev;
814     };
815     //
816     // retrieve tracker informations
817     //
818     if ( !reprocall ){
819 mocchiut 1.19 itr = nobefrun + (re - evfrom - jumped);
820     //itr = re-(46438+200241);
821 mocchiut 1.1 } else {
822 mocchiut 1.9 itr = runinfo->GetFirstEntry() + (re - evfrom - jumped);
823 mocchiut 1.1 };
824 mocchiut 1.11 //
825     if ( withtrk ){
826     if ( itr > nevtrkl2 ){
827     if ( verbose ) printf(" CALORIMETER - ERROR: no tracker events with entry = %i in Level2 file\n",itr);
828     l0File->Close();
829     code = -113;
830     goto closeandexit;
831     };
832     //
833     trk->Clear();
834     //
835     tracker->GetEntry(itr);
836     //
837 mocchiut 1.1 };
838 mocchiut 1.10 //
839 mocchiut 1.1 procev++;
840     //
841     // start processing
842     //
843 mocchiut 1.13 if ( getl1 ) c1->Clear();
844 mocchiut 1.6 ca->Clear();
845 mocchiut 1.1 //
846     // determine who generate the trigger for this event (TOF, S4/PULSER, CALO)
847     //
848 mocchiut 1.8 l0trig->GetEntry(re);
849 mocchiut 1.1 S3 = 0;
850     S2 = 0;
851     S12 = 0;
852     S11 = 0;
853     S3 = trig->patterntrig[2];
854     S2 = trig->patterntrig[3];
855     S12 = trig->patterntrig[4];
856     S11 = trig->patterntrig[5];
857 mocchiut 1.17 if ( trig->patterntrig[1] & (1<<0) ) tmptrigty = 1.;
858 mocchiut 1.1 if ( trig->patterntrig[0] ) tmptrigty = 2.;
859     if ( S3 || S2 || S12 || S11 ) tmptrigty = 0.;
860 mocchiut 1.17 if ( !(trig->patterntrig[1] & (1<<0)) && !trig->patterntrig[0] && !S3 && !S2 && !S12 && !S11 ) tmptrigty = 1.;
861 mocchiut 1.1 event->clevel2->trigty = tmptrigty;
862     //
863     // check if the calibration we are using is still good, if not load another calibration
864     //
865     sgnl = 0;
866 mocchiut 1.32 sgnl = event->ChkCalib(glt,atime);
867 mocchiut 1.1 if ( sgnl < 0 ){
868     code = sgnl;
869     goto closeandexit;
870     };
871     if ( sgnl == 100 ){
872     code = sgnl;
873     if ( verbose ) printf(" CALORIMETER - WARNING: data not associated to any calibration interval\n");
874     badevent++;
875     sgnl = 0;
876     };
877     //
878 mocchiut 1.11 // do we have at least one track from the tracker? this check has been disabled
879 mocchiut 1.1 //
880     event->clevel1->good2 = 1;
881 mocchiut 1.8 //
882 mocchiut 1.29 // use the whole calorimeter, 22 W planes
883     //
884     event->clevel1->npla = 22;
885     //
886     // Use the standard silicon planes shifting
887     //
888     event->clevel1->reverse = 0;
889     //
890 mocchiut 1.1 //
891 mocchiut 1.8 // Calibrate calorimeter event "re" and store output in the two structures that will be passed to fortran routine
892 mocchiut 1.1 //
893 mocchiut 1.11 event->Calibrate(re);
894 mocchiut 1.1 //
895     // Here we have calibrated data, ready to be passed to the FORTRAN routine which will extract topological variables.
896     //
897     //
898     // Calculate variables common to all tracks (qtot, nstrip, etc.)
899     //
900     event->GetCommonVar();
901     //
902     // Fill common variables
903     //
904 mocchiut 1.13 event->FillCommonVar(c1,ca);
905 mocchiut 1.1 //
906     // Calculate variables related to tracks only if we have at least one track (from selftrigger and/or tracker)
907     //
908     ntrkentry = 0;
909     //
910     filled = false;
911     //
912 mocchiut 1.11 // Run over tracks (tracker or calorimeter )
913     //
914     if ( withtrk ){
915     for(Int_t nt=0; nt < trk->ntrk(); nt++){
916     //
917     event->clevel1->good2 = 1;
918     //
919     TrkTrack *ptt = trk->GetStoredTrack(nt);
920     //
921     event->clevel1->trkchi2 = 0;
922     //
923     // Copy the alpha vector in the input structure
924     //
925     for (Int_t e = 0; e < 5 ; e++){
926     event->clevel1->al_p[e][0] = ptt->al[e];
927     };
928     //
929     // Get tracker related variables for this track
930     //
931     event->GetTrkVar();
932     //
933     // Save tracker track sequence number
934     //
935     event->trkseqno = nt;
936     //
937     // Copy values in the class ca from the structure clevel2
938     //
939     event->FillTrkVar(ca,ntrkentry);
940     ntrkentry++;
941     filled = true;
942     //
943     }; // loop on all the tracks
944     };
945     //
946     // if no tracks found but there is the possibility to have a good track we should try to calculate anyway the track related variables using the calorimeter
947     // fit of the track (to be used for example when TRK is off due to any reason like IPM3/5 off).
948     // here we make an event selection so it must be done very carefully...
949     //
950     // conditions are: 0) no track from the tracker 1) we have a track fit both in x and y 2) no problems with calo for this event 3) no selftrigger event
951     //
952     if ( trackanyway && !filled && event->clevel2->npcfit[0] >= 2 && event->clevel2->npcfit[1] >= 2 && event->clevel2->good != 0 && event->clevel2->trigty < 2. ){
953     if ( debug ) printf(" Event with a track not fitted by the tracker at entry %i \n",itr);
954     //
955     // Disable "track mode" in the fortran routine
956     //
957     event->clevel1->good2 = 0;
958     event->clevel1->riginput = rigdefault;
959     if ( debug ) printf(" Using as default rigidity: %f \n",event->clevel1->riginput);
960     //
961     // We have a selftrigger event to analyze.
962     //
963     for (Int_t e = 0; e < 5 ; e++){
964     event->clevel1->al_p[e][0] = 0.;
965     event->clevel1->al_p[e][1] = 0.;
966     };
967     event->clevel1->trkchi2 = 0;
968     //
969     event->GetTrkVar();
970     //
971     // if we had no problem (clevel1->good2 = 0, NOTICE zero, not one in this mode!), fill and go on
972 mocchiut 1.1 //
973 mocchiut 1.11 if ( event->clevel1->good2 == 0 ) {
974 mocchiut 1.1 //
975 mocchiut 1.11 // In selftrigger mode the trkentry variable is set to -1
976 mocchiut 1.1 //
977 mocchiut 1.11 event->trkseqno = -3;
978 mocchiut 1.1 //
979 mocchiut 1.11 // Copy values in the class ca from the structure clevel2
980 mocchiut 1.1 //
981 mocchiut 1.11 event->FillTrkVar(ca,ntrkentry);
982     ntrkentry++;
983     filled = true;
984     //
985     } else {
986     if ( verbose ) printf(" Selftrigger: problems with event at entry %i \n",itr);
987     };
988     //
989     };
990     //
991     // Call high energy nuclei routine
992     //
993     if ( hZn && event->clevel2->trigty >= 2. ){
994     if ( debug ) printf(" Calling selftrigger high energy nuclei routine for entry %i \n",itr);
995     //
996     // Disable "track mode" in the fortran routine
997     //
998     event->clevel1->good2 = 0;
999     //
1000     // Set high energy nuclei flag to one
1001     //
1002     event->clevel1->hzn = 1;
1003     event->clevel1->riginput = rigdefault;
1004     //
1005     // We have a selftrigger event to analyze.
1006     //
1007     for (Int_t e = 0; e < 5 ; e++){
1008     event->clevel1->al_p[e][0] = 0.;
1009     event->clevel1->al_p[e][1] = 0.;
1010 mocchiut 1.1 };
1011 mocchiut 1.11 event->clevel1->trkchi2 = 0;
1012     //
1013     event->GetTrkVar();
1014     //
1015     // if we had no problem (clevel1->good2 = 0, NOTICE zero, not one in this mode!), fill and go on
1016     //
1017     if ( event->clevel1->good2 == 0 ) {
1018     //
1019     // In selftrigger mode the trkentry variable is set to -1
1020     //
1021     event->trkseqno = -2;
1022     //
1023     // Copy values in the class ca from the structure clevel2
1024 mocchiut 1.1 //
1025 mocchiut 1.11 event->FillTrkVar(ca,ntrkentry);
1026     ntrkentry++;
1027     filled = true;
1028 mocchiut 1.1 //
1029 mocchiut 1.11 } else {
1030     if ( verbose ) printf(" Selftrigger: problems with event at entry %i \n",itr);
1031     };
1032     //
1033     };
1034     //
1035     // self trigger event
1036     //
1037     if ( st && event->clevel2->trigty >= 2. ){
1038     if ( verbose ) printf(" Selftrigger event at entry %i \n",itr);
1039     //
1040     // Disable "track mode" in the fortran routine
1041     //
1042     event->clevel1->good2 = 0;
1043     //
1044     // disable high enery nuclei flag;
1045     //
1046     event->clevel1->hzn = 0;
1047     //
1048     // We have a selftrigger event to analyze.
1049     //
1050     for (Int_t e = 0; e < 5 ; e++){
1051     event->clevel1->al_p[e][0] = 0.;
1052     event->clevel1->al_p[e][1] = 0.;
1053     };
1054     event->clevel1->trkchi2 = 0;
1055     //
1056     event->GetTrkVar();
1057     //
1058     // if we had no problem (clevel2->good = 0, NOTICE zero, not one in selftrigger mode!), fill and go on
1059     //
1060     if ( event->clevel1->good2 == 0 ) {
1061 mocchiut 1.1 //
1062 mocchiut 1.11 // In selftrigger mode the trkentry variable is set to -1
1063 mocchiut 1.1 //
1064 mocchiut 1.11 event->trkseqno = -1;
1065 mocchiut 1.1 //
1066 mocchiut 1.11 // Copy values in the class ca from the structure clevel2
1067 mocchiut 1.1 //
1068 mocchiut 1.11 event->FillTrkVar(ca,ntrkentry);
1069     ntrkentry++;
1070     filled = true;
1071 mocchiut 1.1 //
1072 mocchiut 1.11 } else {
1073     if ( verbose ) printf(" Selftrigger: problems with event at entry %i \n",itr);
1074 mocchiut 1.1 };
1075     };
1076     //
1077     if ( !filled ) badevent++;
1078     //
1079     // Clear structures used to communicate with fortran
1080     //
1081     event->ClearStructs();
1082     //
1083     // Fill the rootple
1084     //
1085     calo->Fill();
1086     //
1087 mocchiut 1.6 // delete ca;
1088 mocchiut 1.1 //
1089     jumpev:
1090 mocchiut 1.23 if ( !debug ) debug = false;
1091 mocchiut 1.1 //
1092     };
1093     //
1094     if ( verbose ) printf("\n SUMMARY:\n");
1095     if ( verbose ) printf(" Total number of events: %i \n",totevent);
1096     if ( verbose ) printf(" Events with at least one track: %i \n",totevent-badevent);
1097     if ( verbose ) printf(" Events without tracks: %i \n",badevent);
1098     //
1099     if ( badevent == totevent ){
1100 mocchiut 1.8 if ( verbose ) printf("\n CALORIMETER - WARNING no tracks or good events in run %u \n",idRun);
1101 mocchiut 1.1 code = 101;
1102     };
1103     //
1104 mocchiut 1.8 delete dbtime;
1105 mocchiut 1.1 //
1106     // Clear variables before processing another run (needed to have always the same result when reprocessing data with the same software).
1107     //
1108     event->RunClose();
1109     if ( l0File ) l0File->Close();
1110     //
1111     }; // process all the runs
1112     //
1113     if ( verbose ) printf("\n Finished processing data \n");
1114     //
1115     closeandexit:
1116     //
1117     if ( !reprocall && reproc && code >= 0 ){
1118     if ( totfileentries > noaftrun ){
1119     if ( verbose ) printf("\n Post-processing: copying events from the old tree after the processed run\n");
1120 mocchiut 1.8 if ( verbose ) printf(" Copying %u events in the file which are after the end of the run %u \n",(totfileentries-noaftrun),run);
1121     if ( verbose ) printf(" Start copying at event number %u end copying at event number %u \n",noaftrun,totfileentries);
1122 mocchiut 1.1 for (UInt_t j = noaftrun; j < totfileentries; j++ ){
1123     //
1124     // Get entry from old tree
1125     //
1126     caloclone->GetEntry(j);
1127     //
1128     // copy caclone to ca
1129     //
1130 mocchiut 1.13 if ( getl1 ) c1->Clear();
1131 mocchiut 1.6 ca->Clear();
1132 mocchiut 1.8 //
1133 mocchiut 1.13 if ( getl1 ) memcpy(&c1,&c1clone,sizeof(c1clone));
1134 mocchiut 1.1 memcpy(&ca,&caclone,sizeof(caclone));
1135     //
1136     // Fill entry in the new tree
1137     //
1138     calo->Fill();
1139     //
1140     };
1141     if ( verbose ) printf(" Finished successful copying!\n");
1142     };
1143     };
1144     //
1145     // Case of no errors: close files, delete old tree(s), write and close level2 file
1146     //
1147     if ( l0File ) l0File->Close();
1148     if ( tempfile ) tempfile->Close();
1149 mocchiut 1.30 if ( myfold ) gSystem->Unlink(tempname.str().c_str());
1150 mocchiut 1.1 if ( tracker ) tracker->Delete();
1151     //
1152     if ( code < 0 ) printf("\n CALORIMETER - ERROR: an error occurred, try to save anyway...\n");
1153     if ( verbose ) printf("\n Writing and closing rootple\n");
1154     if ( runinfo ) runinfo->Close();
1155     if ( calo ) calo->SetName("Calorimeter");
1156     if ( file ){
1157     file->cd();
1158     file->Write();
1159     };
1160     if ( calo ) calo->Delete();
1161     //
1162 mocchiut 1.30 if ( myfold ) gSystem->Unlink(calofolder.str().c_str());
1163 mocchiut 1.1 //
1164 mocchiut 1.7 if ( ca ) delete ca;
1165     if ( caclone ) delete caclone;
1166 mocchiut 1.13 if ( c1 ) delete c1;
1167     if ( c1clone ) delete c1clone;
1168 mocchiut 1.7 if ( trk ) delete trk;
1169     if ( q4 ) delete q4;
1170     if ( glroot ) delete glroot;
1171     if ( runinfo ) delete runinfo;
1172     //
1173 mocchiut 1.1 // the end
1174     //
1175     if ( verbose ) printf("\n Exiting...\n");
1176     if ( code < 0 ) throw code;
1177     return(code);
1178     }
1179    
1180    
1181    

  ViewVC Help
Powered by ViewVC 1.1.23