| 5 |
#include <TrkProcess.h> |
#include <TrkProcess.h> |
| 6 |
#include <iostream> |
#include <iostream> |
| 7 |
using namespace std; |
using namespace std; |
| 8 |
|
/** |
| 9 |
|
* Create TrkProcess object, initializing the tracker processing variables at default values |
| 10 |
|
*/ |
| 11 |
TrkProcess::TrkProcess(){ |
TrkProcess::TrkProcess(){ |
| 12 |
|
|
| 13 |
idrun = 0; |
idrun = 0; |
| 14 |
DEBUG = false; |
// DEBUG = false; |
| 15 |
|
// VERBOSE = false; |
| 16 |
|
dbg_mode.SetNone(); |
| 17 |
get1 = 0; |
get1 = 0; |
| 18 |
get2 = 1; |
get2 = 1; |
| 19 |
standalone = false; |
standalone = false; |
| 22 |
outdir = gSystem->WorkingDirectory(); |
outdir = gSystem->WorkingDirectory(); |
| 23 |
pfolder = "/TrackerFolder"; |
pfolder = "/TrackerFolder"; |
| 24 |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
| 25 |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 = false; |
| 26 |
|
|
| 27 |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
| 28 |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 = false; |
| 29 |
|
|
| 30 |
file1 = ""; |
file1 = ""; |
| 31 |
file2 = ""; |
file2 = ""; |
| 32 |
|
|
| 33 |
|
ostatus = 0; |
| 34 |
}; |
}; |
| 35 |
|
|
| 36 |
|
/** |
| 37 |
|
* Create TrkProcess object, initializing the tracker processing variables according to input parameters. |
| 38 |
|
* @param run Run ID |
| 39 |
|
* @param f2 Pointer to output level2 file |
| 40 |
|
*/ |
| 41 |
TrkProcess::TrkProcess(ULong64_t run, TFile *f2){ |
TrkProcess::TrkProcess(ULong64_t run, TFile *f2){ |
| 42 |
|
|
| 43 |
idrun = run; |
idrun = run; |
| 44 |
DEBUG = false; |
// DEBUG = false; |
| 45 |
|
// VERBOSE = false; |
| 46 |
|
dbg_mode.SetWarning(); |
| 47 |
get1 = 0; |
get1 = 0; |
| 48 |
get2 = 1; |
get2 = 1; |
| 49 |
standalone = false; |
standalone = false; |
| 50 |
frame2 = "root"; |
frame2 = "root"; |
| 51 |
frame1 = "hbook"; |
frame1 = "root"; |
| 52 |
ifroot1 = false; |
// ifroot1 = false; |
| 53 |
ifroot2 = true; |
// ifroot2 = true; |
| 54 |
file1 = ""; |
pfolder = "/TrackerFolder"; |
| 55 |
|
file1 = ""; |
| 56 |
if(f2->IsOpen()){ |
if(f2->IsOpen()){ |
| 57 |
file2 = f2->GetPath(); |
file2 = f2->GetPath(); |
| 58 |
// TString temp = file2(0,file2.Last(':')); |
outdir = gSystem->DirName(gSystem->DirName(file2)); |
| 59 |
// outdir = temp(0,temp.Last('/')); |
// check if the indicated output directory exists |
| 60 |
outdir = gSystem->DirName(gSystem->DirName(file2)); |
FileStat_t t; |
| 61 |
// check if the indicated output directory exists |
if( gSystem->GetPathInfo(outdir.Data(),t) )throw -12; |
|
FileStat_t t; |
|
|
if( gSystem->GetPathInfo(outdir.Data(),t) )throw -12; |
|
| 62 |
}else{ |
}else{ |
| 63 |
file2 = ""; |
file2 = ""; |
| 64 |
outdir = gSystem->WorkingDirectory(); |
outdir = gSystem->WorkingDirectory(); |
| 65 |
}; |
}; |
|
pfolder = "/TrackerFolder"; |
|
| 66 |
|
|
| 67 |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
| 68 |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
| 70 |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
| 71 |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
| 72 |
|
|
| 73 |
|
ostatus = 0; |
| 74 |
|
|
| 75 |
}; |
}; |
| 76 |
|
/** |
| 77 |
int TrkProcess::HandleCustomPar(int ncustom, char *vcustom[]){ |
* Set processing variables according to input custom parameters |
| 78 |
|
*/ |
| 79 |
|
void TrkProcess::HandleCustomPar(int ncustom, char *vcustom[]){ |
| 80 |
|
|
| 81 |
for (int i=0; i< ncustom; i++){ |
for (int i=0; i< ncustom; i++){ |
| 82 |
|
|
| 83 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
| 84 |
if (!strcmp(vcustom[i], "-processFolder")){ |
if (!strcmp(vcustom[i], "-processFolder")){ |
| 85 |
if (++i >= ncustom) throw -3; |
if (++i >= ncustom) throw -3; |
| 123 |
continue; |
continue; |
| 124 |
} |
} |
| 125 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
| 126 |
else if (!strcmp(vcustom[i], "--verbose") || !strcmp(vcustom[i], "-v")){ |
if (!strcmp(vcustom[i], "--verbose") || !strcmp(vcustom[i], "-v")){ |
| 127 |
DEBUG = true; |
// VERBOSE = true; |
| 128 |
|
this->SetVerboseMode(); |
| 129 |
continue; |
continue; |
| 130 |
} |
} |
| 131 |
|
// -----------------------------------------------------// |
| 132 |
|
else if (!strcmp(vcustom[i], "--debug") || !strcmp(vcustom[i], "-d")){ |
| 133 |
|
// DEBUG = true; |
| 134 |
|
this->SetDebugMode(); |
| 135 |
|
continue; |
| 136 |
|
}; |
| 137 |
} |
} |
| 138 |
|
|
| 139 |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
| 140 |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
| 141 |
else throw -201; |
else throw -201; |
| 143 |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
| 144 |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
| 145 |
else throw -201; |
else throw -201; |
| 146 |
|
|
| 147 |
if(get1){ |
// if(get1){ |
| 148 |
TString filety; |
// |
| 149 |
if ( ifroot1) filety=".root"; |
// TString filety; |
| 150 |
else if (!ifroot1) filety=".rz"; |
// if ( ifroot1) filety=".root"; |
| 151 |
else throw -200; |
// else if (!ifroot1) filety=".rz"; |
| 152 |
// file1 = outdir + "/"+ pfolder + "/" + file2(file2.Last('/')+1,file2.Last('.')) + ".Level1" + filety; |
// else throw -200; |
| 153 |
// cout << p->file1 << endl; |
// |
| 154 |
// TString path = gSystem->DirName(p->file1); |
// TString base = file2; |
| 155 |
// FileStat_t t; |
// if(base.Contains(".Level2.root"))base = base(0,base.Index(".Level2.root")); |
| 156 |
// // check if processFolder directory exists, and possibly create it |
// else base = base(0,base.Index(".root")); |
| 157 |
// if( gSystem->GetPathInfo(path.Data(),t) ) { |
// base = gSystem->BaseName(base); |
| 158 |
// if( gSystem->MakeDirectory(path.Data()) == -1)throw -13; |
// file1 = outdir + "/"+ gSystem->BaseName(pfolder) + "/" + base +".Level1"+filety; |
| 159 |
// }; |
// // cout << "Requested Level1 output. "<< endl << "Level1 File: "<< file1 << endl; |
| 160 |
// // if it does, open/create teh putput file |
// TString path = gSystem->DirName(file1); |
| 161 |
|
// FileStat_t t; |
| 162 |
}; |
// // check if processFolder directory exists, and possibly create it |
| 163 |
|
// if( gSystem->GetPathInfo(path.Data(),t) ) { |
| 164 |
|
// if( gSystem->MakeDirectory(path.Data()) == -1)throw -13; |
| 165 |
|
// }; |
| 166 |
|
// // if it does, open/create teh putput file |
| 167 |
|
// |
| 168 |
|
// }; |
| 169 |
|
|
| 170 |
|
ostatus = 0; |
| 171 |
|
|
| 172 |
return 0; |
}; |
| 173 |
|
/** |
| 174 |
|
* \brief Process Level0 event |
| 175 |
|
* @param l0_event Pointer to an object of the tracker level0 class |
| 176 |
|
* Starting from a Level0 object, this routine fills the level0 common, then calls |
| 177 |
|
* the fortran routines, which process the event and fill level1 and level2 commons. |
| 178 |
|
*/ |
| 179 |
|
void TrkProcess::ProcessEvent(TrkLevel0 *l0_event){ |
| 180 |
|
|
| 181 |
|
// fill Level0 common from Level0 object |
| 182 |
|
l0_event->GetCommonVar(&level0event_); |
| 183 |
|
|
| 184 |
|
// process the event Level0->Level1->Level2 |
| 185 |
|
int F77err = 0; |
| 186 |
|
// |
| 187 |
|
reductionflight_(&F77err); |
| 188 |
|
if(F77err < 0)throw F77err; |
| 189 |
|
// else if(F77err > 0 && WarningMode())cout<<" WARNING ("<<F77err<<") - TrkCore - Level1 reduction (CN computation failure, ...)"<<endl; |
| 190 |
|
// |
| 191 |
|
if(get2) analysisflight_(); |
| 192 |
|
// if(F77err < 0)throw F77err; |
| 193 |
|
// else if(F77err > 0 && WarningMode())cout<<" WARNING ("<<F77err<<") - TrkCore - @ Level2 reduction "<<endl; |
| 194 |
|
// |
| 195 |
|
ostatus = F77err; |
| 196 |
|
|
| 197 |
}; |
}; |
| 198 |
|
|
| 199 |
void TrkProcess::Dump(){ |
void TrkProcess::Dump(){ |
| 207 |
cout << " file1 " << file1 << endl; |
cout << " file1 " << file1 << endl; |
| 208 |
cout << " file2 " << file2 << endl; |
cout << " file2 " << file2 << endl; |
| 209 |
cout << " outdir " << outdir << endl; |
cout << " outdir " << outdir << endl; |
| 210 |
cout << " process folder " << pfolder << endl; |
cout << " process folder " << pfolder << endl; |
| 211 |
cout << " standalone mode " << standalone << endl; |
cout << " standalone mode " << standalone << endl; |
| 212 |
cout << " debug mode " << DEBUG << endl<< endl; |
cout << " debug mode warning " << dbg_mode.warning << endl; |
| 213 |
|
cout << " debug mode verbose " << dbg_mode.verbose << endl; |
| 214 |
|
cout << " debug mode debug " << dbg_mode.debug << endl << endl; |
| 215 |
|
|
| 216 |
} |
} |