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