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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.18 - (hide annotations) (download)
Mon Jun 23 08:34:18 2014 UTC (10 years, 5 months ago) by pam-ts
Branch: MAIN
CVS Tags: v10RED, v10REDr01, HEAD
Changes since 1.17: +8 -0 lines
extended tracking-algorythm flag added
C

1 mocchiut 1.1 /**
2     * \file TrkProcess.cpp
3     * \author Elena Vannuccini
4     */
5     #include <TrkProcess.h>
6     #include <iostream>
7     using namespace std;
8 pam-fi 1.2 /**
9     * Create TrkProcess object, initializing the tracker processing variables at default values
10     */
11 mocchiut 1.1 TrkProcess::TrkProcess(){
12    
13     idrun = 0;
14 pam-fi 1.11 // dbg_mode.SetNone();
15 pam-fi 1.7 get1 = 0;
16     full1 = 0;
17     geth = 0;
18     get2 = 1;
19 pam-fi 1.16 gete = 1;
20 pam-ts 1.18 gete_ncheck = 10;
21 pam-ts 1.17 getn = 1;
22     extAlgID = 202;
23 mocchiut 1.1 standalone = false;
24     frame2 = "root";
25 pam-fi 1.6 frame1 = "root";
26     frameh = "root";
27 pam-fi 1.16 framee = "root";
28 mocchiut 1.1 outdir = gSystem->WorkingDirectory();
29     pfolder = "/TrackerFolder";
30     if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true;
31 pam-fi 1.2 else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 = false;
32 mocchiut 1.1
33     if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true;
34 pam-fi 1.2 else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 = false;
35 mocchiut 1.1
36 pam-fi 1.6 if (!frameh.CompareTo("root", TString::kIgnoreCase)) ifrooth = true;
37     else if (!frameh.CompareTo("hbook", TString::kIgnoreCase)) ifrooth = false;
38    
39 mocchiut 1.1 file1 = "";
40     file2 = "";
41    
42 pam-fi 1.2 ostatus = 0;
43 pam-fi 1.10
44 pam-fi 1.14 npar = 0;
45    
46     nskip = 0;
47 pam-fi 1.11
48 pam-ts 1.17 watch = false;
49    
50 pam-fi 1.13 // TrkParams::SetTrackingMode();
51     // TrkParams::SetPrecisionFactor();
52     // TrkParams::SetStepMin();
53     TrkParams::SetMiniDefault();
54 pam-fi 1.10 TrkParams::SetPFA();
55 mocchiut 1.1 };
56    
57 pam-fi 1.2 /**
58     * Create TrkProcess object, initializing the tracker processing variables according to input parameters.
59     * @param run Run ID
60     * @param f2 Pointer to output level2 file
61     */
62 mocchiut 1.1 TrkProcess::TrkProcess(ULong64_t run, TFile *f2){
63    
64     idrun = run;
65 pam-fi 1.2 // DEBUG = false;
66     // VERBOSE = false;
67 pam-fi 1.11 // dbg_mode.SetWarning();
68 pam-fi 1.7 get1 = 0;
69     full1 = 0;
70 mocchiut 1.1 get2 = 1;
71 pam-fi 1.6 geth = 0;
72 pam-fi 1.16 gete = 1;
73 pam-ts 1.18 gete_ncheck = 10;
74 pam-ts 1.17 getn = 1;
75     extAlgID = 202;
76 mocchiut 1.1 standalone = false;
77     frame2 = "root";
78 pam-fi 1.4 frame1 = "root";
79 pam-fi 1.6 frameh = "root";
80 pam-fi 1.16 framee = "root";
81 pam-fi 1.6 pfolder = "/TrackerFolder";
82     file1 = "";
83 mocchiut 1.1 if(f2->IsOpen()){
84 pam-fi 1.6 file2 = f2->GetPath();
85     outdir = gSystem->DirName(gSystem->DirName(file2));
86 pam-fi 1.4 // check if the indicated output directory exists
87 pam-fi 1.6 FileStat_t t;
88     if( gSystem->GetPathInfo(outdir.Data(),t) )throw -12;
89 mocchiut 1.1 }else{
90 pam-fi 1.6 file2 = "";
91     outdir = gSystem->WorkingDirectory();
92 mocchiut 1.1 };
93    
94     if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true;
95     else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false;
96    
97     if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true;
98     else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false;
99    
100 pam-fi 1.6 if (!frameh.CompareTo("root", TString::kIgnoreCase)) ifrooth = true;
101     else if (!frameh.CompareTo("hbook", TString::kIgnoreCase)) ifrooth =false;
102    
103 pam-fi 1.2 ostatus = 0;
104 pam-fi 1.11
105     npar=0;
106 mocchiut 1.1
107 pam-fi 1.14 nskip = 0;
108    
109 pam-ts 1.17 watch = false;
110    
111 pam-fi 1.13 // TrkParams::SetTrackingMode();
112     // TrkParams::SetPrecisionFactor();
113     // TrkParams::SetStepMin();
114     TrkParams::SetMiniDefault();
115 pam-fi 1.10 TrkParams::SetPFA();
116    
117 mocchiut 1.1 };
118 pam-fi 1.2 /**
119     * Set processing variables according to input custom parameters
120     */
121 pam-fi 1.12 int TrkProcess::HandleCustomPar(int ncustom, char *vcustom[]){
122 mocchiut 1.1
123     for (int i=0; i< ncustom; i++){
124 pam-fi 1.4
125 mocchiut 1.15 cout << "Handling Parameter " << i+1 << " of " << ncustom << ": " << vcustom[i] << endl;
126    
127     // -----------------------------------------------------//
128     if (!strcmp(vcustom[i], "--simu")){
129     cout << "Setting DarthVader to use Simulated Data\n";
130     TrkParams::SetSimuFlag(kTRUE);
131     continue;
132     }
133 mocchiut 1.1 // -----------------------------------------------------//
134     if (!strcmp(vcustom[i], "-processFolder")){
135     if (++i >= ncustom) throw -3;
136     pfolder = vcustom[i];
137     continue;
138     }
139     // -----------------------------------------------------//
140 pam-fi 1.6 if (!strcmp(vcustom[i], "--get1") || !strcmp(vcustom[i], "--get-level1") ){
141 pam-fi 1.7 get1 = 1;
142     full1 = 0;
143     continue;
144     }
145     // -----------------------------------------------------//
146     if (!strcmp(vcustom[i], "--get1-full") || !strcmp(vcustom[i], "--get-level1-full") ){
147     get1 = 1;
148     full1 = 1;
149 mocchiut 1.1 continue;
150     }
151     // -----------------------------------------------------//
152 pam-fi 1.6 if (!strcmp(vcustom[i], "--geth") || !strcmp(vcustom[i], "--get-hough") ){
153     geth = 1;
154     continue;
155     }
156     // -----------------------------------------------------//
157 pam-ts 1.17 // if (!strcmp(vcustom[i], "--dontget2") ||!strcmp(vcustom[i], "--dontget-level2") ){
158     // get2 = 0;
159     // gete = 0;
160     // getn = 0;
161     // continue;
162     // }
163 mocchiut 1.1 // -----------------------------------------------------//
164 pam-fi 1.16 if (!strcmp(vcustom[i], "--dontgete") ||!strcmp(vcustom[i], "--dontget-exttrack") ){
165     gete = 0;
166     continue;
167     }
168     // -----------------------------------------------------//
169 pam-ts 1.17 if (!strcmp(vcustom[i], "-extalg")){
170 mocchiut 1.1 if (++i >= ncustom) throw -3;
171 pam-ts 1.17 gete = 1;
172     get2 = 1;
173     extAlgID = atoi(vcustom[i]);
174 mocchiut 1.1 continue;
175     }
176     // -----------------------------------------------------//
177 pam-ts 1.18 if (!strcmp(vcustom[i], "-extalg-check")){
178     if (++i >= ncustom) throw -3;
179     gete_ncheck = atoi(vcustom[i]);
180     continue;
181     }
182     // -----------------------------------------------------//
183 pam-ts 1.17 if (!strcmp(vcustom[i], "--dontgetn") ||!strcmp(vcustom[i], "--dontget-nuclei") ){
184     getn = 0;
185 mocchiut 1.1 continue;
186     }
187     // -----------------------------------------------------//
188 pam-ts 1.17 if (!strcmp(vcustom[i], "--standalone") || !strcmp(vcustom[i], "-s")){
189     standalone = true;
190 mocchiut 1.1 continue;
191     }
192     // -----------------------------------------------------//
193 pam-ts 1.17 if (!strcmp(vcustom[i], "-processFile1")){
194     if (++i >= ncustom) throw -3;
195     get1 = 1;
196     file1 = vcustom[i];
197 pam-fi 1.16 continue;
198     }
199 pam-ts 1.17 // // -----------------------------------------------------//
200     // if (!strcmp(vcustom[i], "-frame1")){
201     // if (++i >= ncustom)throw -3;
202     // get1 = 1;
203     // frame1 = vcustom[i];
204     // continue;
205     // }
206     // // -----------------------------------------------------//
207     // if (!strcmp(vcustom[i], "-frame2")){
208     // if (++i >= ncustom)throw -3;
209     // get2 = 1;
210     // frame2 = vcustom[i];
211     // continue;
212     // }
213     // // -----------------------------------------------------//
214     // if (!strcmp(vcustom[i], "-framee")){
215     // if (++i >= ncustom)throw -3;
216     // gete = 1;
217     // framee = vcustom[i];
218     // continue;
219     // }
220 pam-fi 1.16 // -----------------------------------------------------//
221 pam-fi 1.12 if (!strcmp(vcustom[i], "-pfa")){
222     if (++i >= ncustom)throw -3;
223     TrkParams::SetPFA(atoi(vcustom[i]));
224     continue;
225     }
226     // -----------------------------------------------------//
227 pam-fi 1.14 if (!strcmp(vcustom[i], "-skip")){
228     if (++i >= ncustom)throw -3;
229     nskip = atoi(vcustom[i]);
230     continue;
231     }
232     // -----------------------------------------------------//
233 pam-fi 1.11 if ( atoi(vcustom[i]) < 0){
234     if (++i >= ncustom)throw -3;
235     partype[npar]=-1*atoi(vcustom[i-1]);
236     parpath[npar]=vcustom[i];
237     npar++;
238     continue;
239     }
240     // -----------------------------------------------------//
241 pam-fi 1.2 if (!strcmp(vcustom[i], "--verbose") || !strcmp(vcustom[i], "-v")){
242 pam-fi 1.11 TrkParams::SetVerboseMode();
243 pam-fi 1.2 continue;
244     }
245     // -----------------------------------------------------//
246 pam-fi 1.12 if (!strcmp(vcustom[i], "--warning") || !strcmp(vcustom[i], "-w")){
247     TrkParams::SetWarningMode();
248     continue;
249     }
250     // -----------------------------------------------------//
251     if (!strcmp(vcustom[i], "--help") || !strcmp(vcustom[i], "-h")){
252     PrintHelp();
253     return 1;
254     }
255     // -----------------------------------------------------//
256 pam-ts 1.17 if (!strcmp(vcustom[i], "--watch") ){
257     watch = true;
258     continue;
259     }
260     // -----------------------------------------------------//
261 pam-fi 1.2 else if (!strcmp(vcustom[i], "--debug") || !strcmp(vcustom[i], "-d")){
262 pam-fi 1.11 TrkParams::SetDebugMode();
263 mocchiut 1.1 continue;
264 pam-fi 1.2 };
265 mocchiut 1.1 }
266 pam-fi 1.4
267 mocchiut 1.1 if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true;
268     else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false;
269     else throw -201;
270    
271     if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true;
272     else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false;
273     else throw -201;
274 pam-fi 1.4
275 pam-fi 1.6 if (!frameh.CompareTo("root", TString::kIgnoreCase)) ifrooth = true;
276     else if (!frameh.CompareTo("hbook", TString::kIgnoreCase)) ifrooth =false;
277     else throw -201;
278 mocchiut 1.1
279 pam-fi 1.16 if (!framee.CompareTo("root", TString::kIgnoreCase)) ifroote = true;
280     else if (!framee.CompareTo("hbook", TString::kIgnoreCase)) ifroote =false;
281     else throw -201;
282    
283 pam-fi 1.7 if(get1 && !get2)full1=true;
284    
285 pam-fi 1.2 ostatus = 0;
286 mocchiut 1.1
287 pam-fi 1.12 return 0;
288    
289 pam-fi 1.2 };
290     /**
291     * \brief Process Level0 event
292     * @param l0_event Pointer to an object of the tracker level0 class
293     * Starting from a Level0 object, this routine fills the level0 common, then calls
294     * the fortran routines, which process the event and fill level1 and level2 commons.
295     */
296     void TrkProcess::ProcessEvent(TrkLevel0 *l0_event){
297    
298     // fill Level0 common from Level0 object
299 pam-fi 1.8 l0_event->GetLevel0Struct();
300 pam-fi 1.2 // process the event Level0->Level1->Level2
301     int F77err = 0;
302     //
303     reductionflight_(&F77err);
304     if(F77err < 0)throw F77err;
305     //
306 pam-fi 1.10 if(get2) analysisflight_();
307 pam-fi 1.2 //
308 pam-fi 1.16
309 pam-fi 1.2 ostatus = F77err;
310    
311 mocchiut 1.1 };
312    
313     void TrkProcess::Dump(){
314 pam-fi 1.11 cout << endl;
315     cout << " |-------------------------------------| "<<endl;
316     cout << " tracker-processing input-parameters "<< endl;
317     cout << " |-------------------------------------| "<<endl;
318 pam-fi 1.16 cout << " idRun " << idrun << endl;
319     cout << " (skip " << nskip <<" events)"<< endl;
320     cout << " get level1 " << get1 << endl;
321     cout << " full level1 " << full1 << endl;
322     cout << " get level2 " << get2 << endl;
323     cout << " get hough " << geth << endl;
324     cout << " get ext.tracking " << gete << endl;
325 pam-ts 1.17 if(gete)
326     cout << " ext.tracking alg " << extAlgID << endl;
327     cout << " get nuclei " << getn << endl;
328 pam-fi 1.16 // cout << " frame1 " << frame1 << endl;
329     // cout << " frame2 " << frame2 << endl;
330     // cout << " frameh " << frame2 << endl;
331     // cout << " file1 " << file1 << endl;
332     cout << " output file " << file2 << endl;
333     // cout << " outdir " << outdir << endl;
334     // cout << " process folder " << pfolder << endl;
335     // cout << " standalone mode " << standalone << endl;
336 pam-fi 1.11 for(int i=0; i<npar; i++)
337     cout << " force loading parameters of type "<<partype[i]<<" from <--- "<<parpath[i]<<endl;
338     cout<<endl;
339    
340     // cout << " debug mode warning " << dbg_mode.warning << endl;
341     // cout << " debug mode verbose " << dbg_mode.verbose << endl;
342     // cout << " debug mode debug " << dbg_mode.debug << endl << endl;
343 mocchiut 1.1
344     }
345 pam-fi 1.12
346     void TrkProcess::PrintHelp(){
347    
348     printf( "\n\n +TRK [ options ] \n \n");
349     // printf( "\n --version : Print tracker software version and exit ");
350     printf( "Options:");
351     printf( "\n --help, -h : Print this help and exit ");
352     // printf( "\n -idRun RUN : ID number of the run to be processed (for reprocessing RUN=0) \n");
353     // printf( "\n -outDir OUTDIR : Path where to put the LEVEL2 output [default ./ ] ");
354     // printf( "\n -processFolder DIR : Directory (relative to OUTDIR) for other output files [default TrackerFolder/ ] ");
355     // printf( "\n -processFile FILE : Name of the LEVEL2 output file [default RUN.Level2.root]");
356     // printf( "\n -processFile1 FILE : Name of the LEVEL1 output file [default RUN.Level1.rz]");
357     // printf( "\n -frame1 FRAME : type of output for LEVEL1, root/hbook [default hbook ] ");
358     // printf( "\n -frame2 FRAME : type of output for LEVEL2, root/hbook [default root ] ");
359     printf( "\n --get1, --get-level1 : get LEVEL1 output (store only cluster associated to tracks) [default (no LEVEL1 output) ] ");
360     printf( "\n --get1-full, --get-level1-full : get LEVEL1 output (store all clusters) [default (no LEVEL1 output) ] ");
361     printf( "\n --dontget2, --dontget-level2 : do not get LEVEL2 output [default (get LEVEL2 output)]");
362 pam-ts 1.17 printf( "\n --dontgete, --dontget-exttrack : do not get ext.tracking output [default (ext.algorythm 202)]");
363     printf( "\n --dontgetn, --dontget-nuclei : do not get nuclei cleaned tracks [default (get nuclei output)]");
364     printf( "\n --extalg ID : apply ext.tracking algorythm n.ID [default (ID=202) ] ");
365 pam-fi 1.12 printf( "\n --geth,, --get-hough : get Hough-transform output [default (no Hough-t. output) ] ");
366     printf( "\n -pfa PFAID : type of output for LEVEL2, root/hbook [default 14 (COG4) ] ");
367     printf( "\n -N PATH : load parameter of type N=1,2... from PATH [default (from DB) ] ");
368     printf( "\n --verbose, -v : verbose mode ");
369     printf( "\n --debug, -d : debug mode ");
370     printf( "\n --warning, -w : warning mode ");
371 pam-fi 1.14 printf( "\n -skip NEV : skip first NEV events from each run ");
372 pam-fi 1.12 // printf( "\n --standalone, -s : standalone mode (without RunInfo) ... but it might not work \n");
373     // printf( "\n -host HOST : Name for the host [default mysql://localhost/pamelaprod ]");
374     // printf( "\n -user USER : Username for the DB [default anonymous] ");
375     // printf( "\n -psw PSW : Password for the DB [default (none)]\n \n \n");
376    
377    
378     }

  ViewVC Help
Powered by ViewVC 1.1.23