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; |
dbg_mode.SetNone(); |
15 |
get1 = 0; |
get1 = 0; |
16 |
|
geth = 0; |
17 |
get2 = 1; |
get2 = 1; |
18 |
standalone = false; |
standalone = false; |
19 |
frame2 = "root"; |
frame2 = "root"; |
20 |
frame1 = "hbook"; |
frame1 = "root"; |
21 |
|
frameh = "root"; |
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 |
|
if (!frameh.CompareTo("root", TString::kIgnoreCase)) ifrooth = true; |
31 |
|
else if (!frameh.CompareTo("hbook", TString::kIgnoreCase)) ifrooth = false; |
32 |
|
|
33 |
file1 = ""; |
file1 = ""; |
34 |
file2 = ""; |
file2 = ""; |
35 |
|
|
36 |
|
ostatus = 0; |
37 |
}; |
}; |
38 |
|
|
39 |
|
/** |
40 |
|
* Create TrkProcess object, initializing the tracker processing variables according to input parameters. |
41 |
|
* @param run Run ID |
42 |
|
* @param f2 Pointer to output level2 file |
43 |
|
*/ |
44 |
TrkProcess::TrkProcess(ULong64_t run, TFile *f2){ |
TrkProcess::TrkProcess(ULong64_t run, TFile *f2){ |
45 |
|
|
46 |
idrun = run; |
idrun = run; |
47 |
DEBUG = false; |
// DEBUG = false; |
48 |
|
// VERBOSE = false; |
49 |
|
dbg_mode.SetWarning(); |
50 |
get1 = 0; |
get1 = 0; |
51 |
get2 = 1; |
get2 = 1; |
52 |
|
geth = 0; |
53 |
standalone = false; |
standalone = false; |
54 |
frame2 = "root"; |
frame2 = "root"; |
55 |
frame1 = "hbook"; |
frame1 = "root"; |
56 |
ifroot1 = false; |
frameh = "root"; |
57 |
ifroot2 = true; |
pfolder = "/TrackerFolder"; |
58 |
file1 = ""; |
file1 = ""; |
59 |
if(f2->IsOpen()){ |
if(f2->IsOpen()){ |
60 |
file2 = f2->GetPath(); |
file2 = f2->GetPath(); |
|
// TString temp = file2(0,file2.Last(':')); |
|
|
// outdir = temp(0,temp.Last('/')); |
|
61 |
outdir = gSystem->DirName(gSystem->DirName(file2)); |
outdir = gSystem->DirName(gSystem->DirName(file2)); |
62 |
// check if the indicated output directory exists |
// check if the indicated output directory exists |
63 |
FileStat_t t; |
FileStat_t t; |
64 |
if( gSystem->GetPathInfo(outdir.Data(),t) )throw -12; |
if( gSystem->GetPathInfo(outdir.Data(),t) )throw -12; |
65 |
}else{ |
}else{ |
66 |
file2 = ""; |
file2 = ""; |
67 |
outdir = gSystem->WorkingDirectory(); |
outdir = gSystem->WorkingDirectory(); |
68 |
}; |
}; |
|
pfolder = "/TrackerFolder"; |
|
69 |
|
|
70 |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
71 |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
73 |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
74 |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
75 |
|
|
76 |
|
if (!frameh.CompareTo("root", TString::kIgnoreCase)) ifrooth = true; |
77 |
|
else if (!frameh.CompareTo("hbook", TString::kIgnoreCase)) ifrooth =false; |
78 |
|
|
79 |
|
ostatus = 0; |
80 |
|
|
81 |
}; |
}; |
82 |
|
/** |
83 |
int TrkProcess::HandleCustomPar(int ncustom, char *vcustom[]){ |
* Set processing variables according to input custom parameters |
84 |
|
*/ |
85 |
|
void TrkProcess::HandleCustomPar(int ncustom, char *vcustom[]){ |
86 |
|
|
87 |
for (int i=0; i< ncustom; i++){ |
for (int i=0; i< ncustom; i++){ |
88 |
|
|
89 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
90 |
if (!strcmp(vcustom[i], "-processFolder")){ |
if (!strcmp(vcustom[i], "-processFolder")){ |
91 |
if (++i >= ncustom) throw -3; |
if (++i >= ncustom) throw -3; |
93 |
continue; |
continue; |
94 |
} |
} |
95 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
96 |
if (!strcmp(vcustom[i], "--get1")){ |
if (!strcmp(vcustom[i], "--get1") || !strcmp(vcustom[i], "--get-level1") ){ |
97 |
get1 = 1; |
get1 = 1; |
98 |
continue; |
continue; |
99 |
} |
} |
100 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
101 |
if (!strcmp(vcustom[i], "--dontget2")){ |
if (!strcmp(vcustom[i], "--geth") || !strcmp(vcustom[i], "--get-hough") ){ |
102 |
|
geth = 1; |
103 |
|
continue; |
104 |
|
} |
105 |
|
// -----------------------------------------------------// |
106 |
|
if (!strcmp(vcustom[i], "--dontget2") ||!strcmp(vcustom[i], "--dontget-level2") ){ |
107 |
get2 = 0; |
get2 = 0; |
108 |
continue; |
continue; |
109 |
} |
} |
134 |
continue; |
continue; |
135 |
} |
} |
136 |
// -----------------------------------------------------// |
// -----------------------------------------------------// |
137 |
else if (!strcmp(vcustom[i], "--verbose") || !strcmp(vcustom[i], "-v")){ |
if (!strcmp(vcustom[i], "--verbose") || !strcmp(vcustom[i], "-v")){ |
138 |
DEBUG = true; |
// VERBOSE = true; |
139 |
|
this->SetVerboseMode(); |
140 |
continue; |
continue; |
141 |
} |
} |
142 |
|
// -----------------------------------------------------// |
143 |
|
else if (!strcmp(vcustom[i], "--debug") || !strcmp(vcustom[i], "-d")){ |
144 |
|
// DEBUG = true; |
145 |
|
this->SetDebugMode(); |
146 |
|
continue; |
147 |
|
}; |
148 |
} |
} |
149 |
|
|
150 |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
151 |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
152 |
else throw -201; |
else throw -201; |
154 |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
155 |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
156 |
else throw -201; |
else throw -201; |
157 |
|
|
158 |
if(get1){ |
if (!frameh.CompareTo("root", TString::kIgnoreCase)) ifrooth = true; |
159 |
TString filety; |
else if (!frameh.CompareTo("hbook", TString::kIgnoreCase)) ifrooth =false; |
160 |
if ( ifroot1) filety=".root"; |
else throw -201; |
|
else if (!ifroot1) filety=".rz"; |
|
|
else throw -200; |
|
|
// file1 = outdir + "/"+ pfolder + "/" + file2(file2.Last('/')+1,file2.Last('.')) + ".Level1" + filety; |
|
|
// cout << p->file1 << endl; |
|
|
// TString path = gSystem->DirName(p->file1); |
|
|
// FileStat_t t; |
|
|
// // check if processFolder directory exists, and possibly create it |
|
|
// if( gSystem->GetPathInfo(path.Data(),t) ) { |
|
|
// if( gSystem->MakeDirectory(path.Data()) == -1)throw -13; |
|
|
// }; |
|
|
// // if it does, open/create teh putput file |
|
|
|
|
|
}; |
|
161 |
|
|
162 |
|
ostatus = 0; |
163 |
|
|
164 |
return 0; |
}; |
165 |
|
/** |
166 |
|
* \brief Process Level0 event |
167 |
|
* @param l0_event Pointer to an object of the tracker level0 class |
168 |
|
* Starting from a Level0 object, this routine fills the level0 common, then calls |
169 |
|
* the fortran routines, which process the event and fill level1 and level2 commons. |
170 |
|
*/ |
171 |
|
void TrkProcess::ProcessEvent(TrkLevel0 *l0_event){ |
172 |
|
|
173 |
|
// fill Level0 common from Level0 object |
174 |
|
l0_event->GetCommonVar(&level0event_); |
175 |
|
|
176 |
|
// process the event Level0->Level1->Level2 |
177 |
|
int F77err = 0; |
178 |
|
// |
179 |
|
reductionflight_(&F77err); |
180 |
|
if(F77err < 0)throw F77err; |
181 |
|
// else if(F77err > 0 && WarningMode())cout<<" WARNING ("<<F77err<<") - TrkCore - Level1 reduction (CN computation failure, ...)"<<endl; |
182 |
|
// |
183 |
|
if(get2) analysisflight_(); |
184 |
|
// if(F77err < 0)throw F77err; |
185 |
|
// else if(F77err > 0 && WarningMode())cout<<" WARNING ("<<F77err<<") - TrkCore - @ Level2 reduction "<<endl; |
186 |
|
// |
187 |
|
ostatus = F77err; |
188 |
|
|
189 |
}; |
}; |
190 |
|
|
191 |
void TrkProcess::Dump(){ |
void TrkProcess::Dump(){ |
192 |
|
|
193 |
cout <<endl<< "Tracker process parameters: "<< endl; |
cout <<endl<< "Tracker process parameters: "<< endl; |
194 |
cout << " idRun " << idrun << endl; |
cout << " idRun " << idrun << endl; |
195 |
cout << " get1 " << get1 << endl; |
cout << " get level1 " << get1 << endl; |
196 |
cout << " get2 " << get2 << endl; |
cout << " get level2 " << get2 << endl; |
197 |
|
cout << " get hough " << geth << endl; |
198 |
cout << " frame1 " << frame1 << endl; |
cout << " frame1 " << frame1 << endl; |
199 |
cout << " frame2 " << frame2 << endl; |
cout << " frame2 " << frame2 << endl; |
200 |
|
cout << " frameh " << frame2 << endl; |
201 |
cout << " file1 " << file1 << endl; |
cout << " file1 " << file1 << endl; |
202 |
cout << " file2 " << file2 << endl; |
cout << " file2 " << file2 << endl; |
203 |
cout << " outdir " << outdir << endl; |
cout << " outdir " << outdir << endl; |
204 |
cout << " process folder " << pfolder << endl; |
cout << " process folder " << pfolder << endl; |
205 |
cout << " standalone mode " << standalone << endl; |
cout << " standalone mode " << standalone << endl; |
206 |
cout << " debug mode " << DEBUG << endl<< endl; |
cout << " debug mode warning " << dbg_mode.warning << endl; |
207 |
|
cout << " debug mode verbose " << dbg_mode.verbose << endl; |
208 |
|
cout << " debug mode debug " << dbg_mode.debug << endl << endl; |
209 |
|
|
210 |
} |
} |