/[PAMELA software]/DarthVader/ToFLevel2/src/ToFCore.cpp
ViewVC logotype

Contents of /DarthVader/ToFLevel2/src/ToFCore.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.45 - (show annotations) (download)
Wed Feb 17 11:50:53 2010 UTC (15 years ago) by mocchiut
Branch: MAIN
CVS Tags: v9r00, v9r01
Changes since 1.44: +4 -0 lines
New ToF timing for Z>1

1 //
2 // C/C++ headers
3 //
4 #include <fstream>
5 #include <string.h>
6 #include <iomanip>
7 //
8 // ROOT headers
9 //
10 #include <TTree.h>
11 #include <TClassEdit.h>
12 #include <TObject.h>
13 #include <TList.h>
14 #include <TArrayI.h>
15 #include <TSystem.h>
16 #include <TSystemDirectory.h>
17 #include <TString.h>
18 #include <TFile.h>
19 #include <TClass.h>
20 #include <TCanvas.h>
21 #include <TH1.h>
22 #include <TH1F.h>
23 #include <TH2D.h>
24 #include <TLatex.h>
25 #include <TPad.h>
26 #include <TSQLServer.h>
27 #include <TSQLRow.h>
28 #include <TSQLResult.h>
29 #include <TClonesArray.h>
30 //
31 // RunInfo header
32 //
33 #include <RunInfo.h>
34 //
35 // YODA headers
36 //
37 #include <PamelaRun.h>
38 #include <physics/trigger/TriggerEvent.h>
39 #include <physics/tof/TofEvent.h>
40 //
41 // This program headers
42 //
43 #include <ToFCore.h>
44 #include <ToFLevel2.h>
45 #include <ToFVerl2.h>
46 //
47 //
48 // Declaration of the core fortran routines
49 //
50 #define tofl2com tofl2com_
51 extern "C" int tofl2com();
52 #define toftrk toftrk_
53 extern "C" int toftrk();
54 #define rdtofcal rdtofcal_
55 extern "C" int rdtofcal(char [], int *);
56
57 //
58 // Tracker classes headers and definitions
59 //
60 #include <TrkLevel2.h>
61 //
62 using namespace std;
63 //
64 //
65 // CORE ROUTINE
66 //
67 //
68 int ToFCore(UInt_t run, TFile *file, GL_TABLES *glt, Int_t ToFargc, char *ToFargv[]){
69 //
70 //
71 // Set these to true to have a very verbose output.
72 //
73 Bool_t verbose = false;
74 Bool_t debug = false;
75 //
76 TString processFolder = Form("ToFFolder_%u",run);
77 if ( ToFargc > 0 ){
78 Int_t i = 0;
79 while ( i < ToFargc ){
80 if ( !strcmp(ToFargv[i],"-processFolder") ) {
81 if ( ToFargc < i+1 ){
82 throw -3;
83 };
84 processFolder = (TString)ToFargv[i+1];
85 i++;
86 };
87 if ( !strcmp(ToFargv[i],"-v") || !strcmp(ToFargv[i],"--verbose") ) {
88 verbose = true;
89 };
90 if ( !strcmp(ToFargv[i],"-g") || !strcmp(ToFargv[i],"--debug") ) {
91 verbose = true;
92 debug = true;
93 };
94 i++;
95 };
96 };
97 //
98 //
99 // Output directory is the working directoy.
100 //
101 const char* outdir = gSystem->DirName(gSystem->DirName(file->GetPath()));
102 //
103 // Variables for level2
104 //
105 TTree *tracker = 0;
106 TTree *toft = 0;
107 UInt_t nevents = 0;
108 Long64_t maxsize = 10000000000LL;
109 TTree::SetMaxTreeSize(maxsize);
110 //
111 // variables needed to reprocess data
112 //
113 TString tofversion;
114 ItoRunInfo *runinfo = 0;
115 TArrayI *runlist = 0;
116 TTree *toftclone = 0;
117 Bool_t reproc = false;
118 Bool_t reprocall = false;
119 UInt_t nobefrun = 0;
120 UInt_t noaftrun = 0;
121 UInt_t numbofrun = 0;
122 stringstream ftmpname;
123 TString fname;
124 UInt_t totfileentries = 0;
125 UInt_t idRun = 0;
126 //
127 // variables needed to handle error signals
128 //
129 Int_t code = 0;
130 Int_t sgnl;
131 //
132 // tof level2 classes
133 //
134 ToFLevel2 *tof = new ToFLevel2();
135 ToFLevel2 *tofclone = new ToFLevel2();
136 ToFdEdx *tofdedx = new ToFdEdx();
137 //
138 // tracker level2 variables
139 //
140 TrkLevel2 *trk = new TrkLevel2();
141 Int_t nevtrkl2 = 0;
142 //
143 // define variables for opening and reading level0 file
144 //
145 TFile *l0File = 0;
146 TTree *l0tr = 0;
147 TBranch *l0head = 0;
148 TBranch *l0trig = 0;
149 TBranch *l0tof = 0;
150 pamela::EventHeader *eh = 0;
151 pamela::PscuHeader *ph = 0;
152 pamela::trigger::TriggerEvent *trig = 0;
153 pamela::tof::TofEvent *tofEvent = 0;
154 //
155 // Define other basic variables
156 //
157 UInt_t procev = 0;
158 stringstream file2;
159 stringstream file3;
160 stringstream qy;
161 Int_t itr = -1;
162 Int_t totevent = 0;
163 UInt_t atime = 0;
164 UInt_t re = 0;
165 UInt_t jumped = 0;
166 //
167 // Working filename
168 //
169 TString outputfile;
170 stringstream name;
171 name.str("");
172 name << outdir << "/";
173 //
174 // temporary file and folder
175 //
176 TFile *tempfile = 0;
177 TTree *temptof = 0;
178 stringstream tempname;
179 stringstream toffolder;
180 Bool_t myfold = false;
181 tempname.str("");
182 tempname << outdir;
183 tempname << "/" << processFolder.Data();
184 toffolder.str("");
185 toffolder << tempname.str().c_str();
186 tempname << "/toftree_run";
187 tempname << run << ".root";
188 UInt_t totnorun = 0;
189 //
190 // variables needed to load magnetic field maps
191 //
192 Int_t ntrkentry = 0;
193 Int_t npmtentry = 0;
194 UInt_t tttrkpar1 = 0;
195 Bool_t trkpar1 = true;
196 UInt_t tttofpar1 = 0;
197 Bool_t tofpar1 = true;
198 //
199 // DB classes
200 //
201 GL_ROOT *glroot = new GL_ROOT();
202 GL_PARAM *glparam = new GL_PARAM();
203 GL_TIMESYNC *dbtime = 0;
204 //
205 // declaring external output and input structures
206 //
207 extern struct ToFInput tofinput_;
208 extern struct ToFOutput tofoutput_;
209 //
210 // WM variables perform dE/dx II order corrections
211 //
212 Float_t dedx_corr_m[100][48],dedx_corr[48];
213 Double_t mtime[100],t1,t2,tm;
214 Float_t yhelp1,yhelp2,slope,inter,thelp1,thelp2;
215 Float_t xmean1,xwidth1;
216 Int_t ical,ii,wj,jj;
217 Float_t xleft=0;
218 Float_t xright=0;
219 Float_t yleft=0;
220 Float_t yright=0;
221 //
222 // Let's start!
223 //
224 //
225 // 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
226 // if run != 0 we must process only that run but first we have to check if the tree ToF already exist in the file
227 // if it exists we are reprocessing data and we must delete that entries, if not we must create it.
228 //
229 if ( run == 0 ) reproc = true;
230 //
231 //
232 // Output file is "outputfile"
233 //
234 if ( !file->IsOpen() ){
235 if ( verbose ) printf(" ToF - ERROR: cannot open file for writing\n");
236 throw -301;
237 };
238 //
239 // Does it contain the Tracker tree?
240 //
241 tracker = (TTree*)file->Get("Tracker");
242 if ( !tracker ) {
243 if ( verbose ) printf(" TOF - ERROR: no tracker tree\n");
244 code = -302;
245 goto closeandexit;
246 };
247 //
248 // get tracker level2 data pointer
249 //
250 tracker->SetBranchAddress("TrkLevel2",&trk);
251 nevtrkl2 = tracker->GetEntries();
252 //
253 // Retrieve GL_RUN variables from the level2 file
254 //
255 tofversion = ToFInfo(false); // we should decide how to handle versioning system
256 //
257 // create an interface to RunInfo called "runinfo"
258 //
259 // ItoRunInfo= interface with RunInfo and GL_RUN
260 runinfo = new ItoRunInfo(file);
261 //
262 // open "Run" tree in level2 file, if not existing return an error (sngl != 0)
263 //
264 sgnl = 0;
265 sgnl = runinfo->Update(run, "TOF",tofversion);
266 if ( sgnl ){
267 if ( verbose ) printf(" TOF - ERROR: RunInfo exited with non-zero status\n");
268 code = sgnl;
269 goto closeandexit;
270 } else {
271 sgnl = 0;
272 };
273 //
274 // number of events in the file BEFORE the first event of our run
275 //
276 nobefrun = runinfo->GetFirstEntry();
277 //
278 // total number of events in the file
279 //
280 totfileentries = runinfo->GetFileEntries();
281 //
282 // first file entry AFTER the last event of our run
283 //
284 noaftrun = runinfo->GetLastEntry() + 1;
285 //
286 // number of run to be processed
287 //
288 numbofrun = runinfo->GetNoRun();
289 totnorun = runinfo->GetRunEntries();
290 //
291 // Try to access the ToF tree in the file, if it exists we are reprocessing data if not we are processing a new run
292 //
293 toftclone = (TTree*)file->Get("ToF");
294 //
295 if ( !toftclone ){
296 //
297 // tree does not exist, we are not reprocessing
298 //
299 reproc = false;
300 if ( run == 0 && verbose ) printf(" ToF - WARNING: you are reprocessing data but ToF tree does not exist!\n");
301 if ( runinfo->IsReprocessing() && run != 0 && verbose ) printf(" ToF - WARNING: it seems you are not reprocessing data but ToF\n versioning information already exists in RunInfo.\n");
302
303 } else {
304 //
305 // tree exists, we are reprocessing data. Are we reprocessing a single run or all the file?
306 //
307 toftclone->SetAutoSave(900000000000000LL);
308 reproc = true;
309 //
310 // update versioning information
311 //
312 if ( verbose ) printf("\n Preparing the pre-processing...\n");
313 //
314 if ( run == 0 || totnorun == 1 ){
315 //
316 // we are reprocessing all the file
317 // 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
318 //
319 reprocall = true;
320 //
321 if ( verbose ) printf("\n ToF - WARNING: Reprocessing all runs\n");
322 //
323 } else {
324 //
325 // 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
326 //
327 reprocall = false;
328 //
329 if ( verbose ) printf("\n ToF - WARNING: Reprocessing run number %u \n",run);
330 //
331 // copying old tree to a new file
332 //
333 gSystem->MakeDirectory(toffolder.str().c_str());
334 myfold = true;
335 tempfile = new TFile(tempname.str().c_str(),"RECREATE");
336 temptof = toftclone->CloneTree(-1,"fast");
337 temptof->SetName("ToF-old");
338 tempfile->Write();
339 tempfile->Close();
340 }
341 //
342 // Delete the old tree from old file and memory
343 //
344 toftclone->Delete("all");
345 //
346 if ( verbose ) printf(" ...done!\n");
347 //
348 };
349 //
350 // create ToF detector tree toft
351 //
352 file->cd();
353 toft = new TTree("ToF-new","PAMELA Level2 ToF data");
354 toft->SetAutoSave(900000000000000LL);
355 tof->Set();//ELENA **TEMPORANEO?**
356 toft->Branch("ToFLevel2","ToFLevel2",&tof);
357 //
358 if ( reproc && !reprocall ){
359 //
360 // open new file and retrieve all tree informations
361 //
362 tempfile = new TFile(tempname.str().c_str(),"READ");
363 toftclone = (TTree*)tempfile->Get("ToF-old");
364 toftclone->SetAutoSave(900000000000000LL);
365 toftclone->SetBranchAddress("ToFLevel2",&tofclone);
366 //
367 if ( nobefrun > 0 ){
368 if ( verbose ) printf("\n Pre-processing: copying events from the old tree before the processed run\n");
369 if ( verbose ) printf(" Copying %u events in the file which are before the beginning of the run %u \n",nobefrun,run);
370 if ( verbose ) printf(" Start copying at event number 0, end copying at event number %u \n",nobefrun);
371 for (UInt_t j = 0; j < nobefrun; j++){
372 //
373 if ( toftclone->GetEntry(j) <= 0 ) throw -36;
374 //
375 // copy tofclone to tof
376 //
377 tof->Clear();
378 memcpy(&tof,&tofclone,sizeof(tofclone));
379 //
380 // Fill entry in the new tree
381 //
382 toft->Fill();
383 //
384 };
385 if ( verbose ) printf(" Finished successful copying!\n");
386 };
387 };
388 //
389 // Get the list of run to be processed, if only one run has to be processed the list will contain one entry only.
390 //
391 runlist = runinfo->GetRunList();
392 //
393 // Loop over the run to be processed
394 //
395 for (UInt_t irun=0; irun < numbofrun; irun++){
396 //
397 // retrieve the first run ID to be processed using the RunInfo list
398 //
399 idRun = runlist->At(irun);
400 if ( verbose ) printf("\n\n\n ####################################################################### \n");
401 if ( verbose ) printf(" PROCESSING RUN NUMBER %u \n",idRun);
402 if ( verbose ) printf(" ####################################################################### \n\n\n");
403 //
404 runinfo->ID_ROOT_L0 = 0;
405 //
406 // store in the runinfo class the GL_RUN variables for our run
407 //
408 sgnl = 0;
409 sgnl = runinfo->GetRunInfo(idRun);
410 if ( sgnl ){
411 if ( verbose ) printf(" TOF - ERROR: RunInfo exited with non-zero status\n");
412 code = sgnl;
413 goto closeandexit;
414 } else {
415 sgnl = 0;
416 };
417 //
418 // now you can access that variables using the RunInfo class this way runinfo->ID_ROOT_L0
419 //
420 if ( runinfo->ID_ROOT_L0 == 0 ){
421 if ( verbose ) printf("\n TOF - ERROR: no run with ID_RUN = %u \n\n Exiting... \n\n",idRun);
422 code = -5;
423 goto closeandexit;
424 };
425 //
426 // prepare the timesync for the db
427 //
428 TString host = glt->CGetHost();
429 TString user = glt->CGetUser();
430 TString psw = glt->CGetPsw();
431 TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
432 if ( !dbc->IsConnected() ) throw -314;
433 stringstream myquery;
434 myquery.str("");
435 myquery << "SET time_zone='+0:00'";
436 dbc->Query(myquery.str().c_str());
437 dbtime = new GL_TIMESYNC(runinfo->ID_ROOT_L0,"ID",dbc);
438 //
439 // Search in the DB the path and name of the LEVEL0 file to be processed.
440 //
441 // if ( !dbc->IsConnected() ) throw -314;
442 glroot->Query_GL_ROOT(runinfo->ID_ROOT_L0,dbc);
443 //
444 ftmpname.str("");
445 ftmpname << glroot->PATH.Data() << "/";
446 ftmpname << glroot->NAME.Data();
447 fname = ftmpname.str().c_str();
448 //
449 // print out informations
450 //
451 totevent = runinfo->NEVENTS;
452 if ( verbose ) printf("\n LEVEL0 data file: %s \n",fname.Data());
453 if ( verbose ) printf(" RUN HEADER absolute time is: %u \n",runinfo->RUNHEADER_TIME);
454 if ( verbose ) printf(" RUN TRAILER absolute time is: %u \n",runinfo->RUNTRAILER_TIME);
455 if ( verbose ) printf(" %i events to be processed for run %u: from %i to %i \n\n",totevent,idRun,runinfo->EV_FROM,runinfo->EV_FROM+totevent);
456 //
457 // if ( !totevent ) goto closeandexit;
458 //
459 // Open Level0 file
460 //
461 l0File = new TFile(fname.Data());
462 if ( !l0File ) {
463 if ( verbose ) printf(" TOF - ERROR: problems opening Level0 file\n");
464 code = -6;
465 goto closeandexit;
466 };
467 l0tr = (TTree*)l0File->Get("Physics");
468 if ( !l0tr ) {
469 if ( verbose ) printf(" TOF - ERROR: no Physics tree in Level0 file\n");
470 l0File->Close();
471 code = -7;
472 goto closeandexit;
473 };
474 l0head = l0tr->GetBranch("Header");
475 if ( !l0head ) {
476 if ( verbose ) printf(" TOF - ERROR: no Header branch in Level0 tree\n");
477 l0File->Close();
478 code = -8;
479 goto closeandexit;
480 };
481 l0trig = l0tr->GetBranch("Trigger");
482 if ( !l0trig ) {
483 if ( verbose ) printf(" TOF - ERROR: no Trigger branch in Level0 tree\n");
484 l0File->Close();
485 code = -300;
486 goto closeandexit;
487 };
488 l0tof = l0tr->GetBranch("Tof");
489 if ( !l0tof ) {
490 if ( verbose ) printf(" TOF - ERROR: no ToF branch in Level0 tree\n");
491 l0File->Close();
492 code = -303;
493 goto closeandexit;
494 };
495 //
496 l0tr->SetBranchAddress("Trigger", &trig);
497 l0tr->SetBranchAddress("Tof", &tofEvent);
498 l0tr->SetBranchAddress("Header", &eh);
499 //
500 nevents = l0tof->GetEntries();
501 //
502 if ( nevents < 1 && totevent ) {
503 if ( verbose ) printf(" TOF - ERROR: Level0 file is empty\n\n");
504 l0File->Close();
505 code = -11;
506 goto closeandexit;
507 };
508 //
509 if ( runinfo->EV_TO > nevents-1 && totevent ) {
510 if ( verbose ) printf(" TOF - ERROR: too few entries in the registry tree\n");
511 l0File->Close();
512 code = -12;
513 goto closeandexit;
514 };
515 //
516 // Check if we have to load parameter files (or calibration associated to runs and not to events)
517 //
518 // for example let's assume that we could have different magnetic field maps for different runs:
519 //
520 if ( trkpar1 || ( tttrkpar1 != 0 && tttrkpar1 < runinfo->RUNHEADER_TIME ) ){
521 trkpar1 = false;
522 // read from DB infos about Magnetic filed maps
523 // if ( !dbc->IsConnected() ) throw -314;
524 glparam->Query_GL_PARAM(runinfo->RUNHEADER_TIME,1,dbc); // parameters stored in DB in GL_PRAM table
525 tttrkpar1 = glparam->TO_TIME;
526 // ----------------------------
527 // Read the magnetic field
528 // ----------------------------
529 if ( verbose ) printf(" Reading magnetic field maps: \n");
530 trk->LoadField(glparam->PATH+glparam->NAME);
531 if ( verbose ) printf("\n");
532 };
533 //
534 // variable to save information about the tof calibration used
535 //
536 Bool_t defcal = true;
537 //
538 if ( tofpar1 || ( tttofpar1 != 0 && tttofpar1 < runinfo->RUNHEADER_TIME ) ){
539 tofpar1 = false;
540 //
541 // if ( !dbc->IsConnected() ) throw -314;
542 Int_t error=glparam->Query_GL_PARAM(runinfo->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table
543 if ( error<0 ) {
544 code = error;
545 goto closeandexit;
546 };
547 //
548 if ( verbose ) printf(" Reading ToF parameter file: %s \n",(glparam->PATH+glparam->NAME).Data());
549 //
550 if ( (UInt_t)glparam->TO_TIME != (UInt_t)4294967295UL ) defcal = false;
551 //
552 tttofpar1 = glparam->TO_TIME;
553 Int_t nlen = (Int_t)(glparam->PATH+glparam->NAME).Length();
554 rdtofcal((char *)(glparam->PATH+glparam->NAME).Data(),&nlen);
555 //
556 };
557 //
558 Int_t error=glparam->Query_GL_PARAM(runinfo->RUNHEADER_TIME,204,dbc); // parameters stored in DB in GL_PRAM table
559 if ( error<0 ) {
560 code = error;
561 goto closeandexit;
562 };
563 //
564 if ( verbose ) printf(" Reading ToF attenuation parameter file: %s \n",(glparam->PATH+glparam->NAME).Data());
565 tofdedx->ReadParAtt((glparam->PATH+glparam->NAME).Data());
566
567 //
568 error=glparam->Query_GL_PARAM(runinfo->RUNHEADER_TIME,205,dbc); // parameters stored in DB in GL_PRAM table
569 if ( error<0 ) {
570 code = error;
571 goto closeandexit;
572 };
573 //
574 if ( verbose ) printf(" Reading ToF desaturation on position parameter file: %s \n",(glparam->PATH+glparam->NAME).Data());
575 tofdedx->ReadParPos((glparam->PATH+glparam->NAME).Data());
576
577 //
578 error=glparam->Query_GL_PARAM(runinfo->RUNHEADER_TIME,206,dbc); // parameters stored in DB in GL_PRAM table
579 if ( error<0 ) {
580 code = error;
581 goto closeandexit;
582 };
583 //
584 if ( verbose ) printf(" Reading ToF BetheBloch parameter file: %s \n",(glparam->PATH+glparam->NAME).Data());
585 tofdedx->ReadParBBneg((glparam->PATH+glparam->NAME).Data());
586
587 //
588 error=glparam->Query_GL_PARAM(runinfo->RUNHEADER_TIME,207,dbc); // parameters stored in DB in GL_PRAM table
589 if ( error<0 ) {
590 code = error;
591 goto closeandexit;
592 };
593 //
594 if ( verbose ) printf(" Reading ToF Bethe-Bloch parameter file for beta gt1: %s \n",(glparam->PATH+glparam->NAME).Data());
595 tofdedx->ReadParBBpos((glparam->PATH+glparam->NAME).Data());
596
597 //
598 error=glparam->Query_GL_PARAM(runinfo->RUNHEADER_TIME,208,dbc); // parameters stored in DB in GL_PRAM table
599 if ( error<0 ) {
600 code = error;
601 goto closeandexit;
602 };
603 //
604 if ( verbose ) printf(" Reading ToF desaturation on beta parameter file: %s \n",(glparam->PATH+glparam->NAME).Data());
605 tofdedx->ReadParDesatBB((glparam->PATH+glparam->NAME).Data());
606
607
608 tofdedx->CheckConnectors(runinfo->RUNHEADER_TIME,glparam,dbc);
609
610 //
611 // WM reading parameter file for dE/dx II order corrections
612 //
613 memset(dedx_corr_m,0,100*48*sizeof(Float_t));
614 memset(dedx_corr,0,48*sizeof(Float_t));
615 memset(mtime,0,100*sizeof(Double_t));
616 //
617 // Query the DB to get the file
618 //
619 error=glparam->Query_GL_PARAM(runinfo->RUNHEADER_TIME,203,dbc); // parameters stored in DB in GL_PRAM table
620 if ( error<0 ) {
621 code = error;
622 goto closeandexit;
623 };
624 //
625 if ( verbose ) printf(" Reading ToF dE/dx II order correction parameter file: %s \n",(glparam->PATH+glparam->NAME).Data());
626 //
627 ical=0; // counter set to zero if first-time reading
628 //-----------------------------------------------------------
629 // Here I read the dEdx_korr parameters
630 //-----------------------------------------------------------
631 jj=0;
632 ifstream fin((glparam->PATH+glparam->NAME).Data());
633 UInt_t window = 200000;
634 Bool_t first = true;
635 Bool_t last = true;
636 Float_t sdedx_corr_m[48];
637 memset(sdedx_corr_m,0,48*sizeof(Float_t));
638 Double_t stm = 0;
639 while ( !fin.eof() ){
640 stm = tm;
641 // if ( jj > 0 ) memcpy(sdedx_corr_m,dedx_corr_m[jj-1],48*sizeof(Float_t)); // BUG sdedx should be the previous in time not the previous saved [absurd dE/dx for 8th reduction March and > March 2008 data - fixed on 2009/02/04
642 fin>>t1>>tm>>t2;
643 if ( verbose ) cout << setiosflags(ios::fixed) << setw(10) << setprecision(3) << tm << endl;
644 if ( (tm >= (runinfo->RUNHEADER_TIME-window) && tm <= (runinfo->RUNTRAILER_TIME+window)) || (tm > (runinfo->RUNTRAILER_TIME+window) && last) ){
645 if ( first ){
646 mtime[jj]=stm;
647 jj++;
648 if ( jj >= 100 ){
649 code = -318;
650 goto closeandexit;
651 };
652 };
653 mtime[jj]=tm;
654 };
655 for (ii=0; ii<48;ii++){
656 fin>>wj>>xmean1>>xwidth1;
657 if ( (tm >= (runinfo->RUNHEADER_TIME-window) && tm <= (runinfo->RUNTRAILER_TIME+window)) || (tm > (runinfo->RUNTRAILER_TIME+window) && last) ){
658 if ( first ){
659 dedx_corr_m[jj-1][ii]=sdedx_corr_m[ii];
660 };
661 dedx_corr_m[jj][ii]=xmean1;
662 };
663 sdedx_corr_m[ii]=xmean1; // BUG sdedx should be the previous in time not the previous saved [absurd dE/dx for 8th reduction March and > March 2008 data - fixed on 2009/02/04
664 };
665 if ( (tm >= (runinfo->RUNHEADER_TIME-window) && tm <= (runinfo->RUNTRAILER_TIME+window)) || (tm > (runinfo->RUNTRAILER_TIME+window) && last)){
666 if ( first ) first = false;
667 if ( tm > (runinfo->RUNTRAILER_TIME+window) ) last = false;
668 jj++;
669 };
670 if ( jj >= 100 ){
671 code = -318;
672 goto closeandexit;
673 };
674 };
675 //
676 fin.close();
677 // this is a possible bug...
678 // Bool_t ff = false;
679 // while ( runinfo->RUNHEADER_TIME > mtime[ical] && ical < 100 ) {
680 // ical = ical+1;
681 // ff = true;
682 // };
683 while ( (mtime[ical] > runinfo->RUNHEADER_TIME || runinfo->RUNHEADER_TIME > mtime[ical+1] ) && ical < 99 ) {
684 ical = ical+1;
685 // ff = true;
686 };
687 // if ( ff ) ical = ical-1;
688 if ( verbose ) cout<<"rh time "<<runinfo->RUNHEADER_TIME<<" rt time "<<runinfo->RUNTRAILER_TIME<<" limit low "<<mtime[ical]<<" limit up "<<mtime[ical+1]<<" ical "<<ical<< " jj " << jj<< endl;
689 if ( ical < 0 || ical >= 98 ){
690 code = -315;
691 goto closeandexit;
692 };
693 //
694 // run over all the events of the run
695 //
696 if ( verbose ) printf("\n Ready to start! \n\n Processed events: \n\n");
697 //
698 if ( dbc ){
699 dbc->Close();
700 delete dbc;
701 };
702 //
703 jumped = 0;
704 //
705 for ( re = runinfo->EV_FROM; re < (runinfo->EV_FROM+runinfo->NEVENTS); re++){
706 //
707 if ( procev%1000 == 0 && procev > 0 && verbose ) printf(" %iK \n",procev/1000);
708 //
709 if ( l0head->GetEntry(re) <= 0 ) throw -36;
710 //
711 // absolute time of this event
712 //
713 ph = eh->GetPscuHeader();
714 atime = dbtime->DBabsTime(ph->GetOrbitalTime());
715 //
716 tof->Clear();
717 Int_t pmt_id = 0;
718 ToFPMT *t_pmt = new ToFPMT();
719 if(!(tof->PMT))tof->PMT = new TClonesArray("ToFPMT",12); //ELENA
720 TClonesArray &tpmt = *tof->PMT;
721 ToFTrkVar *t_tof = new ToFTrkVar();
722 if(!(tof->ToFTrk))tof->ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA
723 TClonesArray &t = *tof->ToFTrk;
724 //
725 // paranoid check
726 //
727 if ( atime > (runinfo->RUNTRAILER_TIME+1) || atime < (runinfo->RUNHEADER_TIME-1) ) {
728 if ( verbose ) printf(" TOF - WARNING: event at time outside the run time window, skipping it\n");
729 jumped++;
730 goto jumpev;
731 };
732 //
733 // retrieve tracker informations, the LEVEL2 entry which correspond to our event will be "itr"
734 //
735 if ( !reprocall ){
736 itr = nobefrun + (re - runinfo->EV_FROM -jumped);
737 } else {
738 itr = runinfo->GetFirstEntry() + (re - runinfo->EV_FROM -jumped);
739 };
740 if ( itr > nevtrkl2 ){ // nevtrkl2 tracker entry number
741 if ( verbose ) printf(" TOF - ERROR: no tracker events with entry = %i in Level2 file\n",itr);
742 l0File->Close();
743 code = -313;
744 goto closeandexit;
745 };
746 //
747 trk->Clear();
748 //
749 if ( tracker->GetEntry(itr) <= 0 ) throw -36;
750 ///
751 //
752 if ( l0tof->GetEntry(re) <= 0 ) throw -36;
753 if ( l0trig->GetEntry(re) <= 0 ) throw -36;
754 ///
755 //
756 procev++;
757 //
758 // start processing
759 //
760 // dE/dx II order correction: check time limits and interpolate time correction
761 //==================================================================
762 //== if time is outside time limits:
763 //==================================================================
764 if ( atime<mtime[ical] || atime>mtime[ical+1] ){
765 if ( verbose ) cout<<"Checking Time Limits!"<<endl;
766 ical=0;
767 //Bool_t fg = false;
768 while ( ( mtime[ical] > atime || atime > mtime[ical+1]) && ical < 99 ){
769 ical = ical+1;
770 //fg = true;
771 }
772 // if ( fg ) ical = ical-1;
773 if ( ical < 0 || ical >= 98 ){
774 code = -317;
775 goto closeandexit;
776 };
777 if ( verbose ) cout<<"abs time "<<atime<<" limit low "<<mtime[ical]<<" limit up "<<mtime[ical+1]<<" ical "<<ical<<endl;
778 };
779 //==================================================================
780 //== interpolate betwen time limits
781 //==================================================================
782 thelp1 = mtime[ical];
783 thelp2 = mtime[ical+1];
784 for (ii=0; ii<48;ii++) {
785 yhelp1 = fabs(dedx_corr_m[ical][ii]);
786 if ( yhelp1 < 0.1 ) yhelp1 = 4.;
787 yhelp2 = fabs(dedx_corr_m[ical+1][ii]);
788 if ( yhelp2 < 0.1 ) yhelp2 = 4.;
789 slope = (yhelp2-yhelp1)/(thelp2-thelp1);
790 inter = yhelp1 - slope*thelp1;
791 dedx_corr[ii] = slope*atime + inter;
792 if ( fabs(dedx_corr[ii]) <= 1e-15 ){
793 if ( verbose ) printf("ii %i slope %f atime %u inter %f dedx_corr %f \n",ii,slope,atime,inter,dedx_corr[ii]);
794 if ( verbose ) printf("ical %i yhelp2 %f yhelp1 %f thelp2 %f thelp1 %f \n",ical,yhelp2,yhelp1,thelp2,thelp1);
795 code = -316;
796 goto closeandexit;
797 };
798 };
799 //================================================================
800 //================================================================
801 //
802 // Here we will use some procedure to calibrate our data and put some kind of informations in the cinput structure
803 //
804 for (Int_t gg=0; gg<4;gg++){
805 for (Int_t hh=0; hh<12;hh++){
806 tofinput_.tdc[hh][gg]=tofEvent->tdc[gg][hh];
807 tofinput_.adc[hh][gg]=tofEvent->adc[gg][hh];
808 };
809 };
810 //
811 tofdedx->Init(tofEvent);
812 //
813 for (Int_t hh=0; hh<5;hh++){
814 tofinput_.patterntrig[hh]=trig->patterntrig[hh];
815 };
816 //
817 // Here we have calibrated data, ready to be passed to the FORTRAN routine which will extract common and track-related variables.
818 //
819 npmtentry = 0;
820 //
821 ntrkentry = 0;
822 //
823 // Calculate tracks informations from ToF alone
824 //
825 tofl2com();
826 //
827 memcpy(tof->tof_j_flag,tofoutput_.tof_j_flag,6*sizeof(Int_t));
828 //
829 t_tof->trkseqno = -1;
830 //
831 // and now we must copy from the output structure to the level2 class:
832 //
833 t_tof->npmttdc = 0;
834 //
835 for (Int_t hh=0; hh<12;hh++){
836 for (Int_t kk=0; kk<4;kk++){
837 if ( tofoutput_.tofmask[hh][kk] != 0 ){
838 pmt_id = tof->GetPMTid(kk,hh);
839 t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc);
840 t_tof->tdcflag.AddAt(tofoutput_.tdcflagtof[hh][kk],t_tof->npmttdc); // gf: Jan 09/07
841 t_tof->npmttdc++;
842 };
843 };
844 };
845 for (Int_t kk=0; kk<13;kk++){
846 t_tof->beta[kk] = tofoutput_.betatof_a[kk];
847 }
848 //
849
850 //
851 memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos));
852 memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos));
853 memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof));
854 memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof));
855 //
856 {
857
858 Float_t xtof_temp[6]={100.,100.,100.,100.,100.,100.};
859 Float_t ytof_temp[6]={100.,100.,100.,100.,100.,100.};
860
861 if(t_tof->xtofpos[0]<100. && t_tof->ytofpos[0]<100.){
862 xtof_temp[1]=t_tof->xtofpos[0];
863 ytof_temp[0]=t_tof->ytofpos[0];
864 }else if(t_tof->xtofpos[0]>=100. && t_tof->ytofpos[0]<100.){
865 ytof_temp[0]=t_tof->ytofpos[0];
866 tof->GetPaddleGeometry(0,(Int_t)log2(tof->tof_j_flag[0]),xleft, xright, yleft, yright);
867 xtof_temp[1]=xleft+2.55;
868 }else if(t_tof->ytofpos[0]>=100. && t_tof->xtofpos[0]<100.){
869 xtof_temp[1]=t_tof->xtofpos[0];
870 tof->GetPaddleGeometry(1,(Int_t)log2(tof->tof_j_flag[1]),xleft, xright, yleft, yright);
871 ytof_temp[0]=yleft+2.75;
872 }
873
874 if(t_tof->xtofpos[1]<100. && t_tof->ytofpos[1]<100.){
875 xtof_temp[2]=t_tof->xtofpos[1];
876 ytof_temp[3]=t_tof->ytofpos[1];
877 }else if(t_tof->xtofpos[1]>=100. && t_tof->ytofpos[1]<100.){
878 ytof_temp[3]=t_tof->ytofpos[1];
879 tof->GetPaddleGeometry(3,(Int_t)log2(tof->tof_j_flag[3]),xleft, xright, yleft, yright);
880 xtof_temp[2]=xleft+4.5;
881 }else if(t_tof->ytofpos[1]>=100. && t_tof->xtofpos[1]<100.){
882 xtof_temp[2]=t_tof->xtofpos[1];
883 tof->GetPaddleGeometry(2,(Int_t)log2(tof->tof_j_flag[2]),xleft, xright, yleft, yright);
884 ytof_temp[3]=yleft+3.75;
885 }
886
887 if(t_tof->xtofpos[2]<100. && t_tof->ytofpos[2]<100.){
888 xtof_temp[5]=t_tof->xtofpos[2];
889 ytof_temp[4]=t_tof->ytofpos[2];
890 }else if(t_tof->xtofpos[2]>=100. && t_tof->ytofpos[2]<100.){
891 ytof_temp[4]=t_tof->ytofpos[2];
892 tof->GetPaddleGeometry(4,(Int_t)log2(tof->tof_j_flag[4]),xleft, xright, yleft, yright);
893 xtof_temp[5]=xleft+3;
894 }else if(t_tof->ytofpos[2]>=100. && t_tof->xtofpos[2]<100.){
895 xtof_temp[5]=t_tof->xtofpos[2];
896 tof->GetPaddleGeometry(5,(Int_t)log2(tof->tof_j_flag[5]),xleft, xright, yleft, yright);
897 ytof_temp[4]=yleft+2.5;
898 }
899 // Float_t xtof_temp[6]={0.,t_tof->xtofpos[0],t_tof->xtofpos[1],0.,0.,t_tof->xtofpos[2]};
900 // Float_t ytof_temp[6]={t_tof->ytofpos[0],0.,0.,t_tof->ytofpos[1],t_tof->ytofpos[2],0.};
901 tofdedx->Process(atime,t_tof->beta[12], (Float_t *)xtof_temp,(Float_t *)ytof_temp);
902 t_tof->npmtadc = 0;
903 for (Int_t hh=0; hh<12;hh++){
904 for (Int_t kk=0; kk<4;kk++){
905 pmt_id = tof->GetPMTid(kk,hh);
906 Int_t Iplane=-1;
907 Int_t Ipaddle=-1;
908 // Int_t IpaddleT=-1;
909 tof->GetPMTPaddle(pmt_id, Iplane, Ipaddle);
910 tof->GetPaddleGeometry(Iplane,Ipaddle,xleft,xright,yleft,yright);
911 if ( tofdedx->GetdEdx_pmt(pmt_id)>-1. &&((xtof_temp[Iplane]>=xleft&&xtof_temp[Iplane]<=xright) || (ytof_temp[Iplane]>=yleft&&ytof_temp[Iplane]<=yright)) ){ //attenzione:qui va inserito un controllo sulla traccia tof o sulle variabili di posizione !!!!
912 t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),t_tof->npmtadc);
913 t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);
914 t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07
915 t_tof->npmtadc++;
916 };
917 };
918 };
919 };
920
921 /*
922 cout<<"ToFCore tofl2com"<<endl;
923 cout<<tofoutput_.xtofpos[0]<<" "<<tofoutput_.xtofpos[1]<<" "<<tofoutput_.xtofpos[2]<<endl;
924 cout<<tofoutput_.ytofpos[0]<<" "<<tofoutput_.ytofpos[1]<<" "<<tofoutput_.ytofpos[2]<<endl;
925 cout<<tofoutput_.xtr_tof[0]<<" "<<tofoutput_.xtr_tof[1]<<" "<<tofoutput_.xtr_tof[2]<<" "<<tofoutput_.xtr_tof[3]<<" "<<tofoutput_.xtr_tof[4]<<" "<<tofoutput_.xtr_tof[5]<<endl;
926 cout<<tofoutput_.ytr_tof[0]<<" "<<tofoutput_.ytr_tof[1]<<" "<<tofoutput_.ytr_tof[2]<<" "<<tofoutput_.ytr_tof[3]<<" "<<tofoutput_.ytr_tof[4]<<" "<<tofoutput_.ytr_tof[5]<<endl;
927 */
928
929
930 new(t[ntrkentry]) ToFTrkVar(*t_tof);
931 ntrkentry++;
932 t_tof->Clear();
933 //
934 //
935 //
936 t_pmt->Clear();
937 //
938 for (Int_t hh=0; hh<12;hh++){
939 for (Int_t kk=0; kk<4;kk++){
940 // new WM
941 if ( tofoutput_.tdc_c[hh][kk] < 4095 || tofEvent->adc[kk][hh] < 4095 || tofEvent->tdc[kk][hh] < 4095 ){
942 //
943 t_pmt->pmt_id = tof->GetPMTid(kk,hh);
944 t_pmt->tdc_tw = tofoutput_.tdc_c[hh][kk];
945 t_pmt->adc = (Float_t)tofEvent->adc[kk][hh];
946 t_pmt->tdc = (Float_t)tofEvent->tdc[kk][hh];
947 //
948 new(tpmt[npmtentry]) ToFPMT(*t_pmt);
949 npmtentry++;
950 t_pmt->Clear();
951 };
952 };
953 };
954 //
955 if ( debug ) printf(" ATIME %u re %u \n",atime,(UInt_t)re);
956 // Calculate track-related variables
957 //
958 if ( trk->ntrk() > 0 ){
959 //
960 // We have at least one track
961 //
962 //
963 // Run over tracks
964 //
965 for(Int_t nt=0; nt < trk->ntrk(); nt++){
966 //
967 TrkTrack *ptt = trk->GetStoredTrack(nt);
968 //
969 // Copy the alpha vector in the input structure
970 //
971 for (Int_t e = 0; e < 5 ; e++){
972 tofinput_.al_pp[e] = ptt->al[e];
973 };
974
975 // new input for 9th reduction: tracker dEdx
976 tofinput_.trkmip = ptt->GetDEDX();
977
978 //
979 // Get tracker related variables for this track
980 //
981 toftrk();
982 //
983 // Copy values in the class from the structure (we need to use a temporary class to store variables).
984 //
985 t_tof->npmttdc = 0;
986 for (Int_t hh=0; hh<12;hh++){
987 for (Int_t kk=0; kk<4;kk++){
988 if ( tofoutput_.tofmask[hh][kk] != 0 ){
989 pmt_id = tof->GetPMTid(kk,hh);
990 t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc);
991 t_tof->tdcflag.AddAt(tofoutput_.tdcflag[hh][kk],t_tof->npmttdc); // gf: Jan 09/07
992 t_tof->npmttdc++;
993 };
994 };
995 };
996 for (Int_t kk=0; kk<13;kk++){
997 t_tof->beta[kk] = tofoutput_.beta_a[kk];
998 };
999 memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos));
1000 memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos));
1001 memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof));
1002 memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof));
1003 //
1004 tofdedx->Process(atime,t_tof->beta[12], (Float_t *)t_tof->xtr_tof,(Float_t *)t_tof->ytr_tof);
1005 t_tof->npmtadc = 0;
1006 // for (Int_t rrtt = 0; rrtt<48; rrtt++){
1007 // printf(" ===>>> %i ===> %f \n",rrtt,tofdedx->GetdEdx_pmt(rrtt));
1008 // };
1009 for (Int_t hh=0; hh<12;hh++){
1010 for (Int_t kk=0; kk<4;kk++){
1011 pmt_id = tof->GetPMTid(kk,hh);
1012 Int_t Iplane=-1;
1013 Int_t Ipaddle=-1;
1014 Int_t IpaddleT=-1;
1015 tof->GetPMTPaddle(pmt_id, Iplane, Ipaddle);
1016 IpaddleT=tof->GetPaddleIdOfTrack(t_tof->xtr_tof[Iplane],t_tof->ytr_tof[Iplane], Iplane,0.0);
1017 if ( debug ) printf(" 1nt %i pmt_id %i npmtadc %i dedx %f dedx corr %f\n",nt,pmt_id,t_tof->npmtadc,(tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),dedx_corr[pmt_id]);
1018 if ( tofdedx->GetdEdx_pmt(pmt_id) > -1. && Ipaddle==IpaddleT ){
1019 t_tof->dedx.AddAt((tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),t_tof->npmtadc);
1020 if ( debug ) printf(" 2nt %i npmtadc %i dedx %f dedx corr %f\n",nt,t_tof->npmtadc,(tofdedx->GetdEdx_pmt(pmt_id)*4./dedx_corr[pmt_id]),dedx_corr[pmt_id]);
1021 t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);
1022 t_tof->adcflag.AddAt(0,t_tof->npmtadc); // gf: Jan 09/07
1023 t_tof->npmtadc++;
1024 };
1025
1026 };
1027 };
1028 //
1029
1030 /*
1031 cout<<"ToFCore toftrk"<<endl;
1032 cout<<tofoutput_.xtofpos[0]<<" "<<tofoutput_.xtofpos[1]<<" "<<tofoutput_.xtofpos[2]<<endl;
1033 cout<<tofoutput_.ytofpos[0]<<" "<<tofoutput_.ytofpos[1]<<" "<<tofoutput_.ytofpos[2]<<endl;
1034 cout<<tofoutput_.xtr_tof[0]<<" "<<tofoutput_.xtr_tof[1]<<" "<<tofoutput_.xtr_tof[2]<<" "<<tofoutput_.xtr_tof[3]<<" "<<tofoutput_.xtr_tof[4]<<" "<<tofoutput_.xtr_tof[5]<<endl;
1035 cout<<tofoutput_.ytr_tof[0]<<" "<<tofoutput_.ytr_tof[1]<<" "<<tofoutput_.ytr_tof[2]<<" "<<tofoutput_.ytr_tof[3]<<" "<<tofoutput_.ytr_tof[4]<<" "<<tofoutput_.ytr_tof[5]<<endl;
1036 */
1037
1038 //
1039 // Store the tracker track number in order to be sure to have shyncronized data during analysis
1040 //
1041 t_tof->trkseqno = nt;
1042 //
1043 // create a new object for this event with track-related variables
1044 //
1045 new(t[ntrkentry]) ToFTrkVar(*t_tof);
1046 ntrkentry++;
1047 t_tof->Clear();
1048 //
1049 }; // loop on all the tracks
1050 };
1051 //
1052 tof->unpackError = tofEvent->unpackError;
1053 if ( defcal ){
1054 tof->default_calib = 1;
1055 } else {
1056 tof->default_calib = 0;
1057 };
1058 //
1059 // Fill the rootple
1060 //
1061 toft->Fill();
1062 //
1063 //
1064 //
1065 delete t_tof;
1066 //
1067 //
1068 //
1069 jumpev:
1070 if ( !debug ) debug = false;
1071 //
1072 };
1073 //
1074 // Here you may want to clear some variables before processing another run
1075 //
1076 delete dbtime;
1077 }; // process all the runs
1078 //
1079 if ( verbose ) printf("\n Finished processing data \n");
1080 //
1081 closeandexit:
1082 //
1083 // 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.
1084 //
1085 if ( !reprocall && reproc && code >= 0 ){
1086 if ( totfileentries > noaftrun ){
1087 if ( verbose ) printf("\n Post-processing: copying events from the old tree after the processed run\n");
1088 if ( verbose ) printf(" Copying %i events in the file which are after the end of the run %i \n",(int)(totfileentries-noaftrun),(int)run);
1089 if ( verbose ) printf(" Start copying at event number %i end copying at event number %i \n",(int)noaftrun,(int)totfileentries);
1090 for (UInt_t j = noaftrun; j < totfileentries; j++ ){
1091 //
1092 // Get entry from old tree
1093 //
1094 if ( toftclone->GetEntry(j) <= 0 ) throw -36;
1095 //
1096 // copy tofclone to tof
1097 //
1098 tof->Clear();
1099 memcpy(&tof,&tofclone,sizeof(tofclone));
1100 //
1101 // Fill entry in the new tree
1102 //
1103 toft->Fill();
1104 };
1105 if ( verbose ) printf(" Finished successful copying!\n");
1106 };
1107 };
1108 //
1109 // Close files, delete old tree(s), write and close level2 file
1110 //
1111 if ( l0File ) l0File->Close();
1112 if ( tempfile ) tempfile->Close();
1113 if ( myfold ) gSystem->Unlink(tempname.str().c_str());
1114 if ( tracker ) tracker->Delete(); // delete tracker tree from memory only to avoid writing a copy to file!
1115 //
1116 if ( code < 0 && verbose ) printf("\n TOF - ERROR: an error occurred, try to save anyway...\n");
1117 if ( verbose ) printf("\n Writing and closing rootple\n");
1118 if ( runinfo ) runinfo->Close();
1119 if ( toft ) toft->SetName("ToF");
1120 if ( file ){
1121 file->cd();
1122 file->Write("ToF");
1123 };
1124 //
1125 if ( myfold ) gSystem->Unlink(toffolder.str().c_str());
1126 //
1127 // the end
1128 //
1129 if ( verbose ) printf("\n Exiting...\n");
1130 if(toft)toft->Delete();
1131 //
1132 if ( tof ) delete tof;
1133 if ( tofclone ) delete tofclone;
1134 if ( tofdedx ) delete tofdedx;
1135 if ( glroot ) delete glroot;
1136 if ( runinfo ) delete runinfo;
1137 //
1138 if ( code < 0 ) throw code;
1139 return(code);
1140 }

  ViewVC Help
Powered by ViewVC 1.1.23