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