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