/[PAMELA software]/DarthVader/TrackerLevel2/src/TrkCore.cpp
ViewVC logotype

Annotation of /DarthVader/TrackerLevel2/src/TrkCore.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.23 - (hide annotations) (download)
Thu Mar 15 12:17:10 2007 UTC (17 years, 8 months ago) by pam-fi
Branch: MAIN
Changes since 1.22: +17 -15 lines
workaround to retrieve clusters + other minor adjustments

1 mocchiut 1.1 /**
2     * \file TrkCore.cpp
3     * \author Elena Vannuccini
4     */
5     // .........................................................
6     // ROOT header files
7     // .........................................................
8     #include <TTree.h>
9     #include <TClassEdit.h>
10     #include <TObject.h>
11     #include <TList.h>
12     #include <TSystem.h>
13     #include <TSystemDirectory.h>
14     #include <TString.h>
15     #include <TFile.h>
16     #include <TClass.h>
17     #include <TCanvas.h>
18     #include <TH1.h>
19     #include <TH1F.h>
20     #include <TH2D.h>
21     #include <TLatex.h>
22     #include <TPad.h>
23     #include <TSQLServer.h>
24     #include <TSQLRow.h>
25     #include <TSQLResult.h>
26 pam-fi 1.11 #include <TBenchmark.h>
27    
28 mocchiut 1.1 // .........................................................
29     // other general header files
30     // .........................................................
31     #include <fstream>
32     #include <iostream>
33     // .........................................................
34     // files in the inc directory
35     // .........................................................
36     #include <RunInfo.h>
37     #include <GLTables.h>
38     #include <TrkVerl2.h>
39     #include <TrkProcess.h>
40 pam-fi 1.2 //#include <TrkStruct.h>
41 mocchiut 1.1 #include <TrkLevel2.h>
42 pam-fi 1.6 #include <TrkLevel1.h>
43 mocchiut 1.1 #include <TrkLevel0.h>
44 pam-fi 1.15 #include <TrkHough.h>
45 mocchiut 1.1 // .........................................................
46     // YODA header files
47     // .........................................................
48     #include <PamelaRun.h>
49 pam-fi 1.7 //#include <RegistryEvent.h>
50 mocchiut 1.1 #include <physics/tracker/TrackerEvent.h>
51     #include <CalibTrk1Event.h>
52     #include <CalibTrk2Event.h>
53 pam-fi 1.2
54 mocchiut 1.1 // .........................................................
55     // namespaces
56     // .........................................................
57     using namespace std;
58     using namespace pamela;
59     // ================================================================================
60     //
61     //
62     // ================================================================================
63     /**
64     * \brief Tracker data reduction routine.
65     *
66     * It performs data reduction LEVEL0->LEVEL1->LEVEL2, producing LEVEL1 and or LEVEL2 output, in ROOT or HBOOK format.
67     * Input parameters:
68     * @param run id of the run to be processed (if run=0 a whole file is reprocessed)
69     * @param dbc pointer to BD server
70     * @param file1 output LEVEL1 file name (null if no LEVEL1 output is required)
71     * @param file2 output LEVEL2 file name (null if no LEVEL2 output is required)
72     * @param standalone (flag to run the program in standalone mode, that is without reading RunInfo)
73     */
74     //short int TrkCore(Int_t run, TSQLServer *dbc, TString file1, TString file2, Bool_t standalone)
75 pam-fi 1.7 int TrkCore(UInt_t run, TFile *f2, TSQLServer *dbc, int ncustom, char*vcustom[])
76 mocchiut 1.1 {
77     // ---------------------------
78     // Define some basic variables
79     // ---------------------------
80    
81     TString filename = 0;
82     TString trkcalibfile = 0;
83     Int_t last_trk_calib_used = 0;
84 pam-fi 1.7 Long64_t nentries = 0LL;
85 pam-fi 1.2
86 mocchiut 1.1 // LEVEL0 input
87     TFile *f0 = 0;
88 pam-fi 1.2 TFile *f0_c = 0;
89 mocchiut 1.1 TTree *physicsTree = 0;
90     TBranch *b_trk = 0;
91     TBranch *b_header = 0;
92     EventHeader *header = 0;
93     PscuHeader *pscu = 0;
94 pam-fi 1.22 TrkLevel0 *l0_event = new TrkLevel0();
95 mocchiut 1.1 // RunInfo
96     ItoRunInfo *runinfo = 0;
97 pam-fi 1.7 TArrayI *runlist = 0;
98     UInt_t from_run;
99     UInt_t to_run;
100 mocchiut 1.1 Bool_t reprocessing = false;
101     //LEVEL2 output - ROOT
102     TTree *t_level2 = 0;
103     TTree *t_clone = 0;
104     TrkLevel2 *l2_event = new TrkLevel2();
105     TrkLevel2 *l2_clone = new TrkLevel2();
106 pam-fi 1.13 //LEVEL1 output - ROOT
107     TrkLevel1 *l1_event = new TrkLevel1();
108 pam-fi 1.15 TrkHough *lh_event = new TrkHough();
109 mocchiut 1.1 // -----------------------
110     // -----------------------
111     // Handle input parameters
112     // (data)
113     //
114     // - open/create output files, determining the environment root/hbook from the estension
115     // - create the level1/level2 tree+branch/nt-uple
116     // -----------------------
117     // -----------------------
118     TrkProcess *p = new TrkProcess(run,f2);
119     p->HandleCustomPar(ncustom,vcustom);
120 pam-fi 1.2 if( p->DebugMode() )p->Dump();
121 mocchiut 1.1
122     // ===================================
123     // Open/Create level2 output file
124     // ===================================
125     if(p->get2){
126 pam-fi 1.13 //-------------------------------------------
127     // read RunInfo
128     //-------------------------------------------
129     if(!(p->standalone)){
130     // Open "RunInfo" tree and get list of run
131     runinfo = new ItoRunInfo(f2);
132     char *trkversion = TrkInfo(false);
133     int runinfo_error = runinfo->Update(run,"TRK",trkversion);
134     if( runinfo_error ) throw runinfo_error;
135     runlist = runinfo->GetRunList();
136     reprocessing = runinfo->IsReprocessing();//????
137     if(p->VerboseMode()){
138     cout << "#events "<< runinfo->GetFileEntries() << endl;// #events in the file
139     cout << "#runs "<< runinfo->GetRunEntries() << endl;// #runs in the file
140     cout << "1-st run "<< runlist->At(0) << endl;
141     cout << "last run "<< runlist->At(runinfo->GetRunEntries()-1) << endl;
142     cout << "1-st event "<< runinfo->GetFirstEntry() << endl;// first event of our run
143     cout << "last event+1 "<< runinfo->GetLastEntry() << endl;// first event AFTER the last event of our run
144     cout << "reprocessing "<< runinfo->IsReprocessing() << endl << endl;
145     };
146     };
147     //-------------------------------------------
148     //
149     //-------------------------------------------
150     // Take (if present) the old Tracker tree
151     t_clone = (TTree*)f2->Get("Tracker");
152     if( t_clone != NULL ) t_clone->SetBranchAddress("TrkLevel2",&l2_clone);
153     // Create NEW Tracker tree
154     t_level2 = new TTree("Tracker","PAMELA tracker level2 data ");
155 pam-fi 1.21 l2_event->Set(); // ****NBNBNBN*****
156 pam-fi 1.13 t_level2->Branch("TrkLevel2","TrkLevel2",&l2_event);
157     if(p->get1){
158     if(p->VerboseMode())cout << endl << "Requested LEVEL1 output" << endl;
159 pam-fi 1.21 l1_event->Set(); // ****NBNBNBN*****
160 pam-fi 1.13 t_level2->Branch("TrkLevel1","TrkLevel1",&l1_event);
161     t_level2->BranchRef();
162 pam-fi 1.16 }
163     if(p->geth){
164     if(p->VerboseMode())cout << endl << "Requested Hough-Transform output" << endl;
165     t_level2->Branch("TrkHough","TrkHough",&lh_event);
166     // t_level2->BranchRef();
167 pam-fi 1.7 };
168 pam-fi 1.13 };
169 mocchiut 1.1
170    
171     // -------------------------------------------
172     // define runs to be processed/reprocessed
173     // -------------------------------------------
174     if(run == 0){
175 pam-fi 1.13 // reprocessing ALL runs
176     if(p->standalone)throw -298; // reprocessing not implemented
177     from_run = runlist->At(0);
178     to_run = runlist->At(runinfo->GetRunEntries()-1);
179 mocchiut 1.1 }else{
180     // processing/reprocessing ONE single run
181 pam-fi 1.13 from_run = run;
182     to_run = run;
183 mocchiut 1.1 };
184    
185     //
186     // init "expiration date" of calibrations and parameters
187     //
188 pam-fi 1.7 UInt_t pedsig_time =0;
189 pam-fi 1.13 UInt_t B_time =0;
190     UInt_t mip_time =0;
191     UInt_t charge_time =0;
192     UInt_t eta_time =0;
193     UInt_t align_time =0;
194     UInt_t mask_time =0;
195 mocchiut 1.1 //
196     // init event counter
197     //
198     Int_t ev_count =0;
199     //
200     // create query-results objects
201     //
202 pam-fi 1.7 GL_RUN q1 = GL_RUN();
203 mocchiut 1.1 GL_TRK_CALIB q2 = GL_TRK_CALIB();
204     GL_ROOT q3 = GL_ROOT();
205     GL_PARAM q4 = GL_PARAM();
206    
207     // ------------------------------------------------------------
208     // if reprocessing one run, copy all the events BEFORE the run
209     // ------------------------------------------------------------
210     if( !(p->standalone) ){
211 pam-fi 1.13 for(UInt_t i=0; i<runinfo->GetFirstEntry(); i++){
212     t_clone->GetEntry(i);
213     *l2_event = *l2_clone;
214     t_level2->Fill();
215     l2_event->Clear();
216     // COPY COPY COPY
217     };
218 mocchiut 1.1 };
219     // ------------------------------------------------------------
220     // ------------------------------------------------------------
221     // START LOOP OVER RUNS TO PROCESSED/REPROCESSED
222     // ------------------------------------------------------------
223     // ------------------------------------------------------------
224 pam-fi 1.7 for(UInt_t idRun = from_run; idRun <= to_run; idRun++){
225 mocchiut 1.1
226 pam-fi 1.2 if(p->VerboseMode()) cout << endl<<" ========================= Run: "<< idRun << endl;
227 pam-fi 1.7 UInt_t runheadtime = 0;
228     UInt_t runtrailtime = 0;
229 mocchiut 1.1 UInt_t evfrom = 0;
230     UInt_t evto = 0;
231 pam-fi 1.7 UInt_t nevents = 0;
232     Int_t id_root_l0 =-1;
233 mocchiut 1.1 Int_t trk_calib_used = 0;
234 pam-fi 1.7
235 mocchiut 1.1 if(p->standalone){
236     // ==============================
237     // first query: retrieve run info
238     // ==============================
239 pam-fi 1.7 if (q1.Query_GL_RUN(idRun,dbc) )throw -50;
240     id_root_l0 = q1.ID_ROOT_L0;
241 mocchiut 1.1 runheadtime = q1.RUNHEADER_TIME;
242     runtrailtime = q1.RUNTRAILER_TIME;
243 pam-fi 1.7 evfrom = q1.EV_FROM;
244     evto = q1.EV_TO;
245 pam-fi 1.13 nevents = q1.NEVENTS;
246     trk_calib_used = q1.TRK_CALIB_USED;
247 mocchiut 1.1 }else{
248     // ==============================
249     // get run info from RunInfo tree
250     // ==============================
251 pam-fi 1.3 int runinfo_error = runinfo->GetRunInfo(idRun);
252 pam-fi 1.7 if( runinfo_error ) throw runinfo_error;
253     id_root_l0 = runinfo->ID_ROOT_L0;
254 mocchiut 1.1 runheadtime = runinfo->RUNHEADER_TIME;
255     runtrailtime = runinfo->RUNTRAILER_TIME;
256 pam-fi 1.7 evfrom = runinfo->EV_FROM;
257     evto = runinfo->EV_TO;
258 pam-fi 1.13 nevents = runinfo->NEVENTS;
259     trk_calib_used = runinfo->TRK_CALIB_USED;
260 mocchiut 1.1 };
261     //
262 pam-fi 1.2 if(p->VerboseMode()){
263 pam-fi 1.7 cout << "ROOT file ID "<< id_root_l0 << endl;
264 mocchiut 1.1 cout << "RunHeader time "<< runheadtime << endl;
265     cout << "RunTrailer time "<< runtrailtime << endl;
266 pam-fi 1.7 cout << " from event "<< evfrom << endl;
267     cout << " to event "<< evto << endl;
268     cout << " num. events "<< nevents << endl;
269     cout << "trk-calibration used "<< trk_calib_used << endl;
270 mocchiut 1.1 };
271     // ========================================================
272     // second query: search the LEVEL0 file that contains idRun
273     // ========================================================
274     TString lastfilename = filename;
275 pam-fi 1.7 if( q3.Query_GL_ROOT(id_root_l0,dbc) )throw -51;
276 mocchiut 1.1 filename = q3.PATH + q3.NAME;
277     // ========================================================
278     // Open the input LEVEL0 data file
279     // ========================================================
280     if(filename.CompareTo(lastfilename)){
281     if(!lastfilename.IsNull())f0->Close();
282     //if( debug ) cout << "Opening LEVEL0 file: "<< filename << endl;
283 pam-fi 1.2 if(p->VerboseMode()) cout << "Opening LEVEL0 file: "<< filename << endl;
284     FileStat_t t;
285 pam-fi 1.22 // cout << "A"<<endl;
286 pam-fi 1.2 if( gSystem->GetPathInfo(filename.Data(),t) )throw -6;
287 pam-fi 1.22 // cout << "B"<<endl;
288 mocchiut 1.1 f0 = new TFile(filename);
289 pam-fi 1.22 // cout << "C"<<endl;
290 mocchiut 1.1 if ( !f0 ) throw -6;
291 pam-fi 1.22 // cout << "D"<<endl;
292 mocchiut 1.1 physicsTree = (TTree*)f0->Get("Physics"); if(!physicsTree) throw -7;
293     b_header = physicsTree ->GetBranch("Header"); if(!b_header ) throw -8;
294 pam-fi 1.7 // b_registry = physicsTree ->GetBranch("Registry"); if(!b_registry ) throw -9;
295 mocchiut 1.1 b_trk = physicsTree ->GetBranch("Tracker"); if(!b_trk ) throw -203;
296 pam-fi 1.22 l0_event->Set();
297     // cout << "E"<<endl;
298     cout << l0_event->GetTrackerEvent() << endl;
299     cout << l0_event->GetPointerToTrackerEvent() << endl;
300     physicsTree->SetBranchAddress("Tracker" ,l0_event->GetPointerToTrackerEvent());
301 pam-fi 1.7 // physicsTree->SetBranchAddress("Registry",&reg);
302 mocchiut 1.1 physicsTree->SetBranchAddress("Header",&header);
303    
304 pam-fi 1.7 nentries = physicsTree->GetEntries();
305     if ( nentries < 1 ) throw -11;
306     if ( nentries < (evto+1)) throw -12;
307    
308 mocchiut 1.1 };
309    
310 pam-fi 1.7 GL_TIMESYNC *dbtime = new GL_TIMESYNC(id_root_l0,"ID",dbc);
311    
312 mocchiut 1.1 // =============================================================
313 pam-fi 1.2 // retrieve calibration file needed to reduce data
314 mocchiut 1.1 // =============================================================
315 pam-fi 1.2 // if run OBT is > last calibration "expiration date"
316     // - search for new calibration packet
317     // - load calibration parameters (full + truncated)
318 pam-fi 1.5 if(p->VerboseMode() )cout << "Full pedestals for cluster finding:";
319 pam-fi 1.2 if(runheadtime > pedsig_time){
320     if( q2.Query_GL_TRK_CALIB(runheadtime,dbc) )throw -53;
321     pedsig_time = q2.TO_TIME;
322 pam-fi 1.7 if(q2.EV_ROOT_CALIBTRK1 != q2.EV_ROOT_CALIBTRK2)
323     printf("WARNING!! ---> EV_ROOT_CALIBTRK1=%d it's different from EV_ROOT_CALIBTRK2=%d \n\n",q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2);
324     if( q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc) )throw -51;
325 pam-fi 1.5 trkcalibfile = q3.PATH + q3.NAME;
326     if(p->VerboseMode()) cout << " >> Loading from LEVEL0 file: "<< trkcalibfile << endl;
327 pam-fi 1.2 if(trkcalibfile.CompareTo(filename)){
328 pam-fi 1.5 FileStat_t t;
329     if( gSystem->GetPathInfo(trkcalibfile.Data(),t) )throw -6;
330     f0_c=new TFile(trkcalibfile);
331     if ( !f0_c ) throw -6;
332 pam-fi 1.2 }else{
333 pam-fi 1.5 f0_c = f0;
334 pam-fi 1.2 };
335     if(p->VerboseMode()) {
336 pam-fi 1.7 cout << " calibration entries "<< q2.EV_ROOT_CALIBTRK1 << " " << q2.EV_ROOT_CALIBTRK2;
337     cout << " (from time "<< q2.FROM_TIME <<" to time "<< q2.TO_TIME <<")"<<endl;
338 pam-fi 1.2 };
339 pam-fi 1.22 // pedsigbad_.FillACalibFrom(f0_c,q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2);
340     // mask_.Set(f0_c,q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2);
341     TrkParams::FillACalibFrom(f0_c,q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2);
342     TrkParams::FillMask(f0_c,q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2);
343    
344 pam-fi 1.5 }else{
345     if(p->VerboseMode() )cout<< " already loaded. "<< endl;
346 pam-fi 1.2 };
347     if( p->DebugMode() ) for(int i=0; i<12; i++) cout << " DSP "<< i << " "<< pedsigbad_.pedestal[64][12][i] << endl;
348     // =============================================================
349     // retrieve calibration file needed to uncompress data
350     // =============================================================
351     // if the run was compressed using default calib
352     // load truncated pedestals from default
353     // otherwise reload them from on-line calibration
354     if(p->VerboseMode() )cout << "Truncated pedestals for uncompression:";
355 mocchiut 1.1 if(trk_calib_used==104 && last_trk_calib_used!=104){
356    
357 pam-fi 1.5 if(p->VerboseMode() )cout << " >> Loading default calibration " << endl;
358 pam-fi 1.7 if (q4.Query_GL_PARAM(runheadtime,7,dbc) )throw -52;
359 pam-fi 1.22 // pedsigbad_.FillTCalibFrom(q4.PATH+q4.NAME);
360     TrkParams::FillTCalibFrom(q4.PATH+q4.NAME);
361 pam-fi 1.2
362     }else if( (trk_calib_used==1 | trk_calib_used==2) && last_trk_calib_used==104 ){
363    
364     if(p->VerboseMode()) cout << ">> Re-loading on-line calibration " << endl;
365 pam-fi 1.22 // pedsigbad_.FillTCalibFrom(f0_c,q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2);
366     TrkParams::FillTCalibFrom(f0_c,q2.EV_ROOT_CALIBTRK1,q2.EV_ROOT_CALIBTRK2);
367 pam-fi 1.2 }else{
368 pam-fi 1.18 if(p->VerboseMode()) cout << ">> already loaded " << endl;
369 pam-fi 1.2 };
370     if( p->DebugMode() ) for(int i=0; i<12; i++) cout << " DSP "<< i << " "<< pedsigbad_.pedestal_t[64][12][i] << endl;
371     last_trk_calib_used = trk_calib_used;
372    
373 mocchiut 1.1 // =============================================================
374     // retrieve information about parameters to process LEVEL2
375     // =============================================================
376     //
377     // magnetic field
378     //
379 pam-fi 1.2 if(p->VerboseMode()) cout << "Loading parameter files : "<< endl;
380    
381 mocchiut 1.1 if(runheadtime > B_time){
382 pam-fi 1.7 if( q4.Query_GL_PARAM(runheadtime,1,dbc) )throw -52;
383 mocchiut 1.1 B_time = q4.TO_TIME;
384     l2_event->LoadField(q4.PATH+q4.NAME);
385 pam-fi 1.2 // l2_event->LoadField(q4.PATH+q4.NAME);
386 mocchiut 1.1 if(path_.error) throw -215;
387     };
388     //
389     // mip conversion parameters
390     //
391     if(runheadtime > mip_time){
392 pam-fi 1.7 if( q4.Query_GL_PARAM(runheadtime,2,dbc) )throw -52;
393 mocchiut 1.1 mip_time = q4.TO_TIME;
394     path_.FillWith(q4.PATH+q4.NAME);
395     readmipparam_();
396     if(path_.error) throw -212;
397     };
398     //
399     // charge correlation parameters
400     //
401     if(runheadtime > charge_time){
402 pam-fi 1.7 if( q4.Query_GL_PARAM(runheadtime,3,dbc) )throw -52;
403 mocchiut 1.1 charge_time = q4.TO_TIME;
404     path_.FillWith(q4.PATH+q4.NAME);
405     readchargeparam_();
406     if(path_.error) throw -213;
407     };
408     //
409     // eta p.f.a. parameters
410     //
411     if(runheadtime > eta_time){
412 pam-fi 1.7 if( q4.Query_GL_PARAM(runheadtime,4,dbc) )throw -52;
413 mocchiut 1.1 eta_time = q4.TO_TIME;
414     path_.FillWith(q4.PATH+q4.NAME);
415     readetaparam_();
416     if(path_.error) throw -214;
417     };
418     //
419     // alignment parameters
420     //
421     if(runheadtime > align_time){
422 pam-fi 1.7 if( q4.Query_GL_PARAM(runheadtime,5,dbc) )throw -52;
423 mocchiut 1.1 align_time = q4.TO_TIME;
424     path_.FillWith(q4.PATH+q4.NAME);
425     readalignparam_();
426     if(path_.error) throw -211;
427     };
428     //
429     // viking mask
430     //
431     if(runheadtime > mask_time){
432 pam-fi 1.7 if( q4.Query_GL_PARAM(runheadtime,6,dbc) )throw -52;
433 mocchiut 1.1 mask_time = q4.TO_TIME;
434     path_.FillWith(q4.PATH+q4.NAME);
435     readvkmask_();
436     if(path_.error) throw -210;
437     };
438    
439 pam-fi 1.11 TBenchmark *reduction = new TBenchmark();
440     if(p->VerboseMode())reduction->Start("reduction");
441     Int_t ntrk=0;
442 mocchiut 1.1 // ====================================================
443     // start looping on events cointained in the data file
444     // ====================================================
445 pam-fi 1.7 for (UInt_t re = evfrom; re < evfrom+nevents; re++){
446 mocchiut 1.1
447     ev_count++;
448    
449 pam-fi 1.23 // if ( p->DebugMode() && re%100 == 0 && re > 0 ) cout << ".";
450 mocchiut 1.1
451 pam-fi 1.13 b_trk->GetEntry(re);
452     b_header->GetEntry(re);
453     pscu = header->GetPscuHeader();
454 pam-fi 1.23
455     if( p->DebugMode() )cout << ">>> "<<ev_count-1<<" @ OBT "<<pscu->GetOrbitalTime()<<endl;
456    
457 pam-fi 1.13 if ( dbtime->DBabsTime(pscu->GetOrbitalTime()) > runtrailtime || dbtime->DBabsTime(pscu->GetOrbitalTime()) < runheadtime) {
458 pam-fi 1.7
459 pam-fi 1.14 if (p->VerboseMode()){
460     printf(" TrkCore - WARNING: event outside the run time window, skipping it\n");
461     cout << " OBT "<<pscu->GetOrbitalTime()<<" ABS-time "<<dbtime->DBabsTime(pscu->GetOrbitalTime())<<" RUN "<<runheadtime<<"-"<<runtrailtime<<endl;
462     };
463 pam-fi 1.13 }else{
464 pam-fi 1.23 if ( p->DebugMode() )
465     printf("\n-------------------------------\nevent %d\n",re-evfrom);
466 pam-fi 1.16
467 pam-fi 1.13 p->ProcessEvent(l0_event);
468 pam-fi 1.7
469 pam-fi 1.13 // ----------------
470     // LEVEL1 output
471     // ----------------
472     if(p->get1){
473     if(p->ifroot1){ // root
474     l1_event->Clear();
475 pam-fi 1.22 // l1_event->SetFromLevel1Struct(&level1event_,p->full1);
476     l1_event->SetFromLevel1Struct(p->full1);
477 pam-fi 1.13 // t_level1->Fill();
478 pam-fi 1.23 }else{ // hbook
479 pam-fi 1.13 throw -299;
480     };
481     };
482     // ----------------
483     // HOUGH output
484     // ----------------
485     if(p->geth){
486     if(p->ifrooth){ // root
487 pam-fi 1.23 lh_event->Delete();
488     lh_event->SetFromHoughStruct(&houghevent_);
489 pam-fi 1.13 }else{ // hbook
490     throw -299;
491     };
492     };
493     // ----------------
494     // LEVEL2 output
495     // ----------------
496     if(p->get2){
497 pam-fi 1.23 l2_event->Clear();
498     if(p->get1){
499     l2_event->SetFromLevel2Struct(&level2event_,l1_event);//set references to level1
500     }else{
501     l2_event->SetFromLevel2Struct(&level2event_);
502     }
503 pam-fi 1.10 // l2_event->Dump();
504 pam-fi 1.23 t_level2->Fill();
505     if( l2_event->ntrk()>0 )ntrk++;
506 mocchiut 1.1 };
507 pam-fi 1.13 };
508 mocchiut 1.1 }; // end loop on events
509 pam-fi 1.11 if(p->VerboseMode()){
510 pam-fi 1.13 cout << " >>> processed "<< ev_count <<" events"<< endl;
511     if(ev_count)cout << ntrk << " events with at least one track ("<<(Int_t)(100*ntrk/ev_count)<<"%)\n";
512     reduction->Show("reduction");
513 pam-fi 1.11 }
514     delete reduction;
515 pam-fi 1.7
516     delete dbtime;
517    
518 pam-fi 1.13 }; // end loop on runs
519    
520    
521 mocchiut 1.1 // ------------------------------------------------------------
522     // if reprocessing one run, copy all the events AFTER the run
523     // ------------------------------------------------------------
524     if( !(p->standalone) ){
525     for(UInt_t i=runinfo->GetLastEntry()+1; i<runinfo->GetFileEntries(); i++){
526     t_clone->GetEntry(i);
527     *l2_event = *l2_clone;
528     t_level2->Fill();
529     l2_event->Clear();
530     // COPY COPY COPY
531     };
532     };
533     // ---------------
534     // close the files
535     // ---------------
536     if(p->get2){
537 pam-fi 1.13 if( t_clone )t_clone->Delete("all");//delete old tree from file
538     if( !(p->standalone) )runinfo->Close();
539     f2->Write("Tracker");
540     if( t_level2 )t_level2->Delete(); //delete new tree from memory
541    
542     };
543 pam-fi 1.6
544 pam-fi 1.13 if( f0->IsOpen() ) f0->Close();
545 pam-fi 1.2 if( f0_c->IsOpen() )f0_c->Close();
546 pam-fi 1.13
547     // lh_event->Delete();
548     l1_event->Delete();
549     l2_event->Delete();
550     l2_clone->Delete();
551 pam-fi 1.2
552     return(p->ostatus);
553 mocchiut 1.1 }
554    

  ViewVC Help
Powered by ViewVC 1.1.23