11 |
TrkProcess::TrkProcess(){ |
TrkProcess::TrkProcess(){ |
12 |
|
|
13 |
idrun = 0; |
idrun = 0; |
14 |
// DEBUG = false; |
// dbg_mode.SetNone(); |
15 |
// VERBOSE = false; |
get1 = 0; |
16 |
dbg_mode.SetNone(); |
full1 = 0; |
17 |
get1 = 0; |
geth = 0; |
18 |
get2 = 1; |
get2 = 1; |
19 |
standalone = false; |
standalone = false; |
20 |
frame2 = "root"; |
frame2 = "root"; |
21 |
frame1 = "hbook"; |
frame1 = "root"; |
22 |
|
frameh = "root"; |
23 |
outdir = gSystem->WorkingDirectory(); |
outdir = gSystem->WorkingDirectory(); |
24 |
pfolder = "/TrackerFolder"; |
pfolder = "/TrackerFolder"; |
25 |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
28 |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
29 |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 = false; |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 = false; |
30 |
|
|
31 |
|
if (!frameh.CompareTo("root", TString::kIgnoreCase)) ifrooth = true; |
32 |
|
else if (!frameh.CompareTo("hbook", TString::kIgnoreCase)) ifrooth = false; |
33 |
|
|
34 |
file1 = ""; |
file1 = ""; |
35 |
file2 = ""; |
file2 = ""; |
36 |
|
|
37 |
ostatus = 0; |
ostatus = 0; |
38 |
|
|
39 |
|
npar = 0; |
40 |
|
|
41 |
|
nskip = 0; |
42 |
|
|
43 |
|
// TrkParams::SetTrackingMode(); |
44 |
|
// TrkParams::SetPrecisionFactor(); |
45 |
|
// TrkParams::SetStepMin(); |
46 |
|
TrkParams::SetMiniDefault(); |
47 |
|
TrkParams::SetPFA(); |
48 |
}; |
}; |
49 |
|
|
50 |
/** |
/** |
57 |
idrun = run; |
idrun = run; |
58 |
// DEBUG = false; |
// DEBUG = false; |
59 |
// VERBOSE = false; |
// VERBOSE = false; |
60 |
dbg_mode.SetWarning(); |
// dbg_mode.SetWarning(); |
61 |
get1 = 0; |
get1 = 0; |
62 |
|
full1 = 0; |
63 |
get2 = 1; |
get2 = 1; |
64 |
|
geth = 0; |
65 |
standalone = false; |
standalone = false; |
66 |
frame2 = "root"; |
frame2 = "root"; |
67 |
frame1 = "hbook"; |
frame1 = "root"; |
68 |
ifroot1 = false; |
frameh = "root"; |
69 |
ifroot2 = true; |
pfolder = "/TrackerFolder"; |
70 |
file1 = ""; |
file1 = ""; |
71 |
if(f2->IsOpen()){ |
if(f2->IsOpen()){ |
72 |
file2 = f2->GetPath(); |
file2 = f2->GetPath(); |
|
// TString temp = file2(0,file2.Last(':')); |
|
|
// outdir = temp(0,temp.Last('/')); |
|
73 |
outdir = gSystem->DirName(gSystem->DirName(file2)); |
outdir = gSystem->DirName(gSystem->DirName(file2)); |
74 |
// check if the indicated output directory exists |
// check if the indicated output directory exists |
75 |
FileStat_t t; |
FileStat_t t; |
76 |
if( gSystem->GetPathInfo(outdir.Data(),t) )throw -12; |
if( gSystem->GetPathInfo(outdir.Data(),t) )throw -12; |
77 |
}else{ |
}else{ |
78 |
file2 = ""; |
file2 = ""; |
79 |
outdir = gSystem->WorkingDirectory(); |
outdir = gSystem->WorkingDirectory(); |
80 |
}; |
}; |
|
pfolder = "/TrackerFolder"; |
|
81 |
|
|
82 |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
83 |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
85 |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
86 |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
87 |
|
|
88 |
|
if (!frameh.CompareTo("root", TString::kIgnoreCase)) ifrooth = true; |
89 |
|
else if (!frameh.CompareTo("hbook", TString::kIgnoreCase)) ifrooth =false; |
90 |
|
|
91 |
ostatus = 0; |
ostatus = 0; |
92 |
|
|
93 |
|
npar=0; |
94 |
|
|
95 |
|
nskip = 0; |
96 |
|
|
97 |
|
// TrkParams::SetTrackingMode(); |
98 |
|
// TrkParams::SetPrecisionFactor(); |
99 |
|
// TrkParams::SetStepMin(); |
100 |
|
TrkParams::SetMiniDefault(); |
101 |
|
TrkParams::SetPFA(); |
102 |
|
|
103 |
}; |
}; |
104 |
/** |
/** |
105 |
* Set processing variables according to input custom parameters |
* Set processing variables according to input custom parameters |
106 |
*/ |
*/ |
107 |
void TrkProcess::HandleCustomPar(int ncustom, char *vcustom[]){ |
int TrkProcess::HandleCustomPar(int ncustom, char *vcustom[]){ |
108 |
|
|
109 |
for (int i=0; i< ncustom; i++){ |
for (int i=0; i< ncustom; i++){ |
110 |
|
|
111 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
112 |
if (!strcmp(vcustom[i], "-processFolder")){ |
if (!strcmp(vcustom[i], "-processFolder")){ |
113 |
if (++i >= ncustom) throw -3; |
if (++i >= ncustom) throw -3; |
115 |
continue; |
continue; |
116 |
} |
} |
117 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
118 |
if (!strcmp(vcustom[i], "--get1")){ |
if (!strcmp(vcustom[i], "--get1") || !strcmp(vcustom[i], "--get-level1") ){ |
119 |
get1 = 1; |
get1 = 1; |
120 |
|
full1 = 0; |
121 |
|
continue; |
122 |
|
} |
123 |
|
// -----------------------------------------------------// |
124 |
|
if (!strcmp(vcustom[i], "--get1-full") || !strcmp(vcustom[i], "--get-level1-full") ){ |
125 |
|
get1 = 1; |
126 |
|
full1 = 1; |
127 |
continue; |
continue; |
128 |
} |
} |
129 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
130 |
if (!strcmp(vcustom[i], "--dontget2")){ |
if (!strcmp(vcustom[i], "--geth") || !strcmp(vcustom[i], "--get-hough") ){ |
131 |
|
geth = 1; |
132 |
|
continue; |
133 |
|
} |
134 |
|
// -----------------------------------------------------// |
135 |
|
if (!strcmp(vcustom[i], "--dontget2") ||!strcmp(vcustom[i], "--dontget-level2") ){ |
136 |
get2 = 0; |
get2 = 0; |
137 |
continue; |
continue; |
138 |
} |
} |
163 |
continue; |
continue; |
164 |
} |
} |
165 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
166 |
|
if (!strcmp(vcustom[i], "-pfa")){ |
167 |
|
if (++i >= ncustom)throw -3; |
168 |
|
TrkParams::SetPFA(atoi(vcustom[i])); |
169 |
|
continue; |
170 |
|
} |
171 |
|
// -----------------------------------------------------// |
172 |
|
if (!strcmp(vcustom[i], "-skip")){ |
173 |
|
if (++i >= ncustom)throw -3; |
174 |
|
nskip = atoi(vcustom[i]); |
175 |
|
continue; |
176 |
|
} |
177 |
|
// -----------------------------------------------------// |
178 |
|
if ( atoi(vcustom[i]) < 0){ |
179 |
|
if (++i >= ncustom)throw -3; |
180 |
|
partype[npar]=-1*atoi(vcustom[i-1]); |
181 |
|
parpath[npar]=vcustom[i]; |
182 |
|
npar++; |
183 |
|
continue; |
184 |
|
} |
185 |
|
// -----------------------------------------------------// |
186 |
if (!strcmp(vcustom[i], "--verbose") || !strcmp(vcustom[i], "-v")){ |
if (!strcmp(vcustom[i], "--verbose") || !strcmp(vcustom[i], "-v")){ |
187 |
// VERBOSE = true; |
TrkParams::SetVerboseMode(); |
188 |
this->SetVerboseMode(); |
continue; |
189 |
|
} |
190 |
|
// -----------------------------------------------------// |
191 |
|
if (!strcmp(vcustom[i], "--warning") || !strcmp(vcustom[i], "-w")){ |
192 |
|
TrkParams::SetWarningMode(); |
193 |
continue; |
continue; |
194 |
} |
} |
195 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
196 |
|
if (!strcmp(vcustom[i], "--help") || !strcmp(vcustom[i], "-h")){ |
197 |
|
PrintHelp(); |
198 |
|
return 1; |
199 |
|
} |
200 |
|
// -----------------------------------------------------// |
201 |
else if (!strcmp(vcustom[i], "--debug") || !strcmp(vcustom[i], "-d")){ |
else if (!strcmp(vcustom[i], "--debug") || !strcmp(vcustom[i], "-d")){ |
202 |
// DEBUG = true; |
TrkParams::SetDebugMode(); |
|
this->SetDebugMode(); |
|
203 |
continue; |
continue; |
204 |
}; |
}; |
205 |
} |
} |
206 |
|
|
|
// dbg_.debug = DEBUG; |
|
|
// dbg_.verbose = VERBOSE; |
|
|
|
|
207 |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
208 |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
209 |
else throw -201; |
else throw -201; |
211 |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
212 |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
213 |
else throw -201; |
else throw -201; |
214 |
|
|
215 |
if(get1){ |
if (!frameh.CompareTo("root", TString::kIgnoreCase)) ifrooth = true; |
216 |
TString filety; |
else if (!frameh.CompareTo("hbook", TString::kIgnoreCase)) ifrooth =false; |
217 |
if ( ifroot1) filety=".root"; |
else throw -201; |
|
else if (!ifroot1) filety=".rz"; |
|
|
else throw -200; |
|
|
// file1 = outdir + "/"+ pfolder + "/" + file2(file2.Last('/')+1,file2.Last('.')) + ".Level1" + filety; |
|
|
// cout << p->file1 << endl; |
|
|
// TString path = gSystem->DirName(p->file1); |
|
|
// FileStat_t t; |
|
|
// // check if processFolder directory exists, and possibly create it |
|
|
// if( gSystem->GetPathInfo(path.Data(),t) ) { |
|
|
// if( gSystem->MakeDirectory(path.Data()) == -1)throw -13; |
|
|
// }; |
|
|
// // if it does, open/create teh putput file |
|
218 |
|
|
219 |
}; |
if(get1 && !get2)full1=true; |
220 |
|
|
221 |
ostatus = 0; |
ostatus = 0; |
222 |
|
|
223 |
|
return 0; |
224 |
|
|
225 |
}; |
}; |
226 |
/** |
/** |
227 |
* \brief Process Level0 event |
* \brief Process Level0 event |
232 |
void TrkProcess::ProcessEvent(TrkLevel0 *l0_event){ |
void TrkProcess::ProcessEvent(TrkLevel0 *l0_event){ |
233 |
|
|
234 |
// fill Level0 common from Level0 object |
// fill Level0 common from Level0 object |
235 |
l0_event->GetCommonVar(&level0event_); |
l0_event->GetLevel0Struct(); |
|
|
|
236 |
// process the event Level0->Level1->Level2 |
// process the event Level0->Level1->Level2 |
237 |
int F77err = 0; |
int F77err = 0; |
238 |
// |
// |
239 |
reductionflight_(&F77err); |
reductionflight_(&F77err); |
240 |
if(F77err < 0)throw F77err; |
if(F77err < 0)throw F77err; |
|
else if(F77err > 0 && WarningMode())cout<<" WARNING ("<<F77err<<") - TrkCore - Level1 reduction (CN computation failure, ...)"<<endl; |
|
241 |
// |
// |
242 |
if(get2) analysisflight_(); |
if(get2) analysisflight_(); |
|
// if(F77err < 0)throw F77err; |
|
|
// else if(F77err > 0 && WarningMode())cout<<" WARNING ("<<F77err<<") - TrkCore - @ Level2 reduction "<<endl; |
|
243 |
// |
// |
244 |
ostatus = F77err; |
ostatus = F77err; |
245 |
|
|
246 |
}; |
}; |
247 |
|
|
248 |
void TrkProcess::Dump(){ |
void TrkProcess::Dump(){ |
249 |
|
cout << endl; |
250 |
|
cout << " |-------------------------------------| "<<endl; |
251 |
|
cout << " tracker-processing input-parameters "<< endl; |
252 |
|
cout << " |-------------------------------------| "<<endl; |
253 |
|
cout << " idRun " << idrun << endl; |
254 |
|
cout << " (skip " << nskip <<" events)"<< endl; |
255 |
|
cout << " get level1 " << get1 << endl; |
256 |
|
cout << " full level1 " << full1 << endl; |
257 |
|
cout << " get level2 " << get2 << endl; |
258 |
|
cout << " get hough " << geth << endl; |
259 |
|
// cout << " frame1 " << frame1 << endl; |
260 |
|
// cout << " frame2 " << frame2 << endl; |
261 |
|
// cout << " frameh " << frame2 << endl; |
262 |
|
// cout << " file1 " << file1 << endl; |
263 |
|
cout << " output file " << file2 << endl; |
264 |
|
// cout << " outdir " << outdir << endl; |
265 |
|
// cout << " process folder " << pfolder << endl; |
266 |
|
// cout << " standalone mode " << standalone << endl; |
267 |
|
for(int i=0; i<npar; i++) |
268 |
|
cout << " force loading parameters of type "<<partype[i]<<" from <--- "<<parpath[i]<<endl; |
269 |
|
cout<<endl; |
270 |
|
|
271 |
|
// cout << " debug mode warning " << dbg_mode.warning << endl; |
272 |
|
// cout << " debug mode verbose " << dbg_mode.verbose << endl; |
273 |
|
// cout << " debug mode debug " << dbg_mode.debug << endl << endl; |
274 |
|
|
275 |
|
} |
276 |
|
|
277 |
|
void TrkProcess::PrintHelp(){ |
278 |
|
|
279 |
cout <<endl<< "Tracker process parameters: "<< endl; |
printf( "\n\n +TRK [ options ] \n \n"); |
280 |
cout << " idRun " << idrun << endl; |
// printf( "\n --version : Print tracker software version and exit "); |
281 |
cout << " get1 " << get1 << endl; |
printf( "Options:"); |
282 |
cout << " get2 " << get2 << endl; |
printf( "\n --help, -h : Print this help and exit "); |
283 |
cout << " frame1 " << frame1 << endl; |
// printf( "\n -idRun RUN : ID number of the run to be processed (for reprocessing RUN=0) \n"); |
284 |
cout << " frame2 " << frame2 << endl; |
// printf( "\n -outDir OUTDIR : Path where to put the LEVEL2 output [default ./ ] "); |
285 |
cout << " file1 " << file1 << endl; |
// printf( "\n -processFolder DIR : Directory (relative to OUTDIR) for other output files [default TrackerFolder/ ] "); |
286 |
cout << " file2 " << file2 << endl; |
// printf( "\n -processFile FILE : Name of the LEVEL2 output file [default RUN.Level2.root]"); |
287 |
cout << " outdir " << outdir << endl; |
// printf( "\n -processFile1 FILE : Name of the LEVEL1 output file [default RUN.Level1.rz]"); |
288 |
cout << " process folder " << pfolder << endl; |
// printf( "\n -frame1 FRAME : type of output for LEVEL1, root/hbook [default hbook ] "); |
289 |
cout << " standalone mode " << standalone << endl; |
// printf( "\n -frame2 FRAME : type of output for LEVEL2, root/hbook [default root ] "); |
290 |
cout << " debug mode warning " << dbg_mode.warning << endl; |
printf( "\n --get1, --get-level1 : get LEVEL1 output (store only cluster associated to tracks) [default (no LEVEL1 output) ] "); |
291 |
cout << " debug mode verbose " << dbg_mode.verbose << endl; |
printf( "\n --get1-full, --get-level1-full : get LEVEL1 output (store all clusters) [default (no LEVEL1 output) ] "); |
292 |
cout << " debug mode debug " << dbg_mode.debug << endl << endl; |
printf( "\n --dontget2, --dontget-level2 : do not get LEVEL2 output [default (get LEVEL2 output)]"); |
293 |
|
printf( "\n --geth,, --get-hough : get Hough-transform output [default (no Hough-t. output) ] "); |
294 |
|
printf( "\n -pfa PFAID : type of output for LEVEL2, root/hbook [default 14 (COG4) ] "); |
295 |
|
printf( "\n -N PATH : load parameter of type N=1,2... from PATH [default (from DB) ] "); |
296 |
|
printf( "\n --verbose, -v : verbose mode "); |
297 |
|
printf( "\n --debug, -d : debug mode "); |
298 |
|
printf( "\n --warning, -w : warning mode "); |
299 |
|
printf( "\n -skip NEV : skip first NEV events from each run "); |
300 |
|
// printf( "\n --standalone, -s : standalone mode (without RunInfo) ... but it might not work \n"); |
301 |
|
// printf( "\n -host HOST : Name for the host [default mysql://localhost/pamelaprod ]"); |
302 |
|
// printf( "\n -user USER : Username for the DB [default anonymous] "); |
303 |
|
// printf( "\n -psw PSW : Password for the DB [default (none)]\n \n \n"); |
304 |
|
|
305 |
|
|
306 |
} |
} |