| 1 |
/** |
| 2 |
* \file TrkProcess.cpp |
| 3 |
* \author Elena Vannuccini |
| 4 |
*/ |
| 5 |
#include <TrkProcess.h> |
| 6 |
#include <iostream> |
| 7 |
using namespace std; |
| 8 |
/** |
| 9 |
* Create TrkProcess object, initializing the tracker processing variables at default values |
| 10 |
*/ |
| 11 |
TrkProcess::TrkProcess(){ |
| 12 |
|
| 13 |
idrun = 0; |
| 14 |
// dbg_mode.SetNone(); |
| 15 |
get1 = 0; |
| 16 |
full1 = 0; |
| 17 |
geth = 0; |
| 18 |
get2 = 1; |
| 19 |
gete = 1; |
| 20 |
gete_ncheck = 10; |
| 21 |
getn = 1; |
| 22 |
extAlgID = 202; |
| 23 |
standalone = false; |
| 24 |
frame2 = "root"; |
| 25 |
frame1 = "root"; |
| 26 |
frameh = "root"; |
| 27 |
framee = "root"; |
| 28 |
outdir = gSystem->WorkingDirectory(); |
| 29 |
pfolder = "/TrackerFolder"; |
| 30 |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
| 31 |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 = false; |
| 32 |
|
| 33 |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
| 34 |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 = false; |
| 35 |
|
| 36 |
if (!frameh.CompareTo("root", TString::kIgnoreCase)) ifrooth = true; |
| 37 |
else if (!frameh.CompareTo("hbook", TString::kIgnoreCase)) ifrooth = false; |
| 38 |
|
| 39 |
file1 = ""; |
| 40 |
file2 = ""; |
| 41 |
|
| 42 |
ostatus = 0; |
| 43 |
|
| 44 |
npar = 0; |
| 45 |
|
| 46 |
nskip = 0; |
| 47 |
|
| 48 |
watch = false; |
| 49 |
|
| 50 |
// TrkParams::SetTrackingMode(); |
| 51 |
// TrkParams::SetPrecisionFactor(); |
| 52 |
// TrkParams::SetStepMin(); |
| 53 |
TrkParams::SetMiniDefault(); |
| 54 |
TrkParams::SetPFA(); |
| 55 |
}; |
| 56 |
|
| 57 |
/** |
| 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 |
TrkProcess::TrkProcess(ULong64_t run, TFile *f2){ |
| 63 |
|
| 64 |
idrun = run; |
| 65 |
// DEBUG = false; |
| 66 |
// VERBOSE = false; |
| 67 |
// dbg_mode.SetWarning(); |
| 68 |
get1 = 0; |
| 69 |
full1 = 0; |
| 70 |
get2 = 1; |
| 71 |
geth = 0; |
| 72 |
gete = 1; |
| 73 |
gete_ncheck = 10; |
| 74 |
getn = 1; |
| 75 |
extAlgID = 202; |
| 76 |
standalone = false; |
| 77 |
frame2 = "root"; |
| 78 |
frame1 = "root"; |
| 79 |
frameh = "root"; |
| 80 |
framee = "root"; |
| 81 |
pfolder = "/TrackerFolder"; |
| 82 |
file1 = ""; |
| 83 |
if(f2->IsOpen()){ |
| 84 |
file2 = f2->GetPath(); |
| 85 |
outdir = gSystem->DirName(gSystem->DirName(file2)); |
| 86 |
// check if the indicated output directory exists |
| 87 |
FileStat_t t; |
| 88 |
if( gSystem->GetPathInfo(outdir.Data(),t) )throw -12; |
| 89 |
}else{ |
| 90 |
file2 = ""; |
| 91 |
outdir = gSystem->WorkingDirectory(); |
| 92 |
}; |
| 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 |
if (!frameh.CompareTo("root", TString::kIgnoreCase)) ifrooth = true; |
| 101 |
else if (!frameh.CompareTo("hbook", TString::kIgnoreCase)) ifrooth =false; |
| 102 |
|
| 103 |
ostatus = 0; |
| 104 |
|
| 105 |
npar=0; |
| 106 |
|
| 107 |
nskip = 0; |
| 108 |
|
| 109 |
watch = false; |
| 110 |
|
| 111 |
// TrkParams::SetTrackingMode(); |
| 112 |
// TrkParams::SetPrecisionFactor(); |
| 113 |
// TrkParams::SetStepMin(); |
| 114 |
TrkParams::SetMiniDefault(); |
| 115 |
TrkParams::SetPFA(); |
| 116 |
|
| 117 |
}; |
| 118 |
/** |
| 119 |
* Set processing variables according to input custom parameters |
| 120 |
*/ |
| 121 |
int TrkProcess::HandleCustomPar(int ncustom, char *vcustom[]){ |
| 122 |
|
| 123 |
for (int i=0; i< ncustom; i++){ |
| 124 |
|
| 125 |
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 |
// -----------------------------------------------------// |
| 134 |
if (!strcmp(vcustom[i], "-processFolder")){ |
| 135 |
if (++i >= ncustom) throw -3; |
| 136 |
pfolder = vcustom[i]; |
| 137 |
continue; |
| 138 |
} |
| 139 |
// -----------------------------------------------------// |
| 140 |
if (!strcmp(vcustom[i], "--get1") || !strcmp(vcustom[i], "--get-level1") ){ |
| 141 |
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 |
continue; |
| 150 |
} |
| 151 |
// -----------------------------------------------------// |
| 152 |
if (!strcmp(vcustom[i], "--geth") || !strcmp(vcustom[i], "--get-hough") ){ |
| 153 |
geth = 1; |
| 154 |
continue; |
| 155 |
} |
| 156 |
// -----------------------------------------------------// |
| 157 |
// if (!strcmp(vcustom[i], "--dontget2") ||!strcmp(vcustom[i], "--dontget-level2") ){ |
| 158 |
// get2 = 0; |
| 159 |
// gete = 0; |
| 160 |
// getn = 0; |
| 161 |
// continue; |
| 162 |
// } |
| 163 |
// -----------------------------------------------------// |
| 164 |
if (!strcmp(vcustom[i], "--dontgete") ||!strcmp(vcustom[i], "--dontget-exttrack") ){ |
| 165 |
gete = 0; |
| 166 |
continue; |
| 167 |
} |
| 168 |
// -----------------------------------------------------// |
| 169 |
if (!strcmp(vcustom[i], "-extalg")){ |
| 170 |
if (++i >= ncustom) throw -3; |
| 171 |
gete = 1; |
| 172 |
get2 = 1; |
| 173 |
extAlgID = atoi(vcustom[i]); |
| 174 |
continue; |
| 175 |
} |
| 176 |
// -----------------------------------------------------// |
| 177 |
if (!strcmp(vcustom[i], "-extalg-check")){ |
| 178 |
if (++i >= ncustom) throw -3; |
| 179 |
gete_ncheck = atoi(vcustom[i]); |
| 180 |
continue; |
| 181 |
} |
| 182 |
// -----------------------------------------------------// |
| 183 |
if (!strcmp(vcustom[i], "--dontgetn") ||!strcmp(vcustom[i], "--dontget-nuclei") ){ |
| 184 |
getn = 0; |
| 185 |
continue; |
| 186 |
} |
| 187 |
// -----------------------------------------------------// |
| 188 |
if (!strcmp(vcustom[i], "--standalone") || !strcmp(vcustom[i], "-s")){ |
| 189 |
standalone = true; |
| 190 |
continue; |
| 191 |
} |
| 192 |
// -----------------------------------------------------// |
| 193 |
if (!strcmp(vcustom[i], "-processFile1")){ |
| 194 |
if (++i >= ncustom) throw -3; |
| 195 |
get1 = 1; |
| 196 |
file1 = vcustom[i]; |
| 197 |
continue; |
| 198 |
} |
| 199 |
// // -----------------------------------------------------// |
| 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 |
// -----------------------------------------------------// |
| 221 |
if (!strcmp(vcustom[i], "-pfa")){ |
| 222 |
if (++i >= ncustom)throw -3; |
| 223 |
TrkParams::SetPFA(atoi(vcustom[i])); |
| 224 |
continue; |
| 225 |
} |
| 226 |
// -----------------------------------------------------// |
| 227 |
if (!strcmp(vcustom[i], "-skip")){ |
| 228 |
if (++i >= ncustom)throw -3; |
| 229 |
nskip = atoi(vcustom[i]); |
| 230 |
continue; |
| 231 |
} |
| 232 |
// -----------------------------------------------------// |
| 233 |
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 |
if (!strcmp(vcustom[i], "--verbose") || !strcmp(vcustom[i], "-v")){ |
| 242 |
TrkParams::SetVerboseMode(); |
| 243 |
continue; |
| 244 |
} |
| 245 |
// -----------------------------------------------------// |
| 246 |
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 |
if (!strcmp(vcustom[i], "--watch") ){ |
| 257 |
watch = true; |
| 258 |
continue; |
| 259 |
} |
| 260 |
// -----------------------------------------------------// |
| 261 |
else if (!strcmp(vcustom[i], "--debug") || !strcmp(vcustom[i], "-d")){ |
| 262 |
TrkParams::SetDebugMode(); |
| 263 |
continue; |
| 264 |
}; |
| 265 |
} |
| 266 |
|
| 267 |
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 |
|
| 275 |
if (!frameh.CompareTo("root", TString::kIgnoreCase)) ifrooth = true; |
| 276 |
else if (!frameh.CompareTo("hbook", TString::kIgnoreCase)) ifrooth =false; |
| 277 |
else throw -201; |
| 278 |
|
| 279 |
if (!framee.CompareTo("root", TString::kIgnoreCase)) ifroote = true; |
| 280 |
else if (!framee.CompareTo("hbook", TString::kIgnoreCase)) ifroote =false; |
| 281 |
else throw -201; |
| 282 |
|
| 283 |
if(get1 && !get2)full1=true; |
| 284 |
|
| 285 |
ostatus = 0; |
| 286 |
|
| 287 |
return 0; |
| 288 |
|
| 289 |
}; |
| 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 |
l0_event->GetLevel0Struct(); |
| 300 |
// process the event Level0->Level1->Level2 |
| 301 |
int F77err = 0; |
| 302 |
// |
| 303 |
reductionflight_(&F77err); |
| 304 |
if(F77err < 0)throw F77err; |
| 305 |
// |
| 306 |
if(get2) analysisflight_(); |
| 307 |
// |
| 308 |
|
| 309 |
ostatus = F77err; |
| 310 |
|
| 311 |
}; |
| 312 |
|
| 313 |
void TrkProcess::Dump(){ |
| 314 |
cout << endl; |
| 315 |
cout << " |-------------------------------------| "<<endl; |
| 316 |
cout << " tracker-processing input-parameters "<< endl; |
| 317 |
cout << " |-------------------------------------| "<<endl; |
| 318 |
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 |
if(gete) |
| 326 |
cout << " ext.tracking alg " << extAlgID << endl; |
| 327 |
cout << " get nuclei " << getn << endl; |
| 328 |
// 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 |
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 |
|
| 344 |
} |
| 345 |
|
| 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 |
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 |
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 |
printf( "\n -skip NEV : skip first NEV events from each run "); |
| 372 |
// 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 |
} |