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 |
geth = 0; |
17 |
get2 = 1; |
18 |
standalone = false; |
19 |
frame2 = "root"; |
20 |
frame1 = "root"; |
21 |
frameh = "root"; |
22 |
outdir = gSystem->WorkingDirectory(); |
23 |
pfolder = "/TrackerFolder"; |
24 |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
25 |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 = false; |
26 |
|
27 |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
28 |
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 = ""; |
34 |
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){ |
45 |
|
46 |
idrun = run; |
47 |
// DEBUG = false; |
48 |
// VERBOSE = false; |
49 |
dbg_mode.SetWarning(); |
50 |
get1 = 0; |
51 |
get2 = 1; |
52 |
geth = 0; |
53 |
standalone = false; |
54 |
frame2 = "root"; |
55 |
frame1 = "root"; |
56 |
frameh = "root"; |
57 |
pfolder = "/TrackerFolder"; |
58 |
file1 = ""; |
59 |
if(f2->IsOpen()){ |
60 |
file2 = f2->GetPath(); |
61 |
outdir = gSystem->DirName(gSystem->DirName(file2)); |
62 |
// check if the indicated output directory exists |
63 |
FileStat_t t; |
64 |
if( gSystem->GetPathInfo(outdir.Data(),t) )throw -12; |
65 |
}else{ |
66 |
file2 = ""; |
67 |
outdir = gSystem->WorkingDirectory(); |
68 |
}; |
69 |
|
70 |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
71 |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
72 |
|
73 |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
74 |
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 |
* 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++){ |
88 |
|
89 |
// -----------------------------------------------------// |
90 |
if (!strcmp(vcustom[i], "-processFolder")){ |
91 |
if (++i >= ncustom) throw -3; |
92 |
pfolder = vcustom[i]; |
93 |
continue; |
94 |
} |
95 |
// -----------------------------------------------------// |
96 |
if (!strcmp(vcustom[i], "--get1") || !strcmp(vcustom[i], "--get-level1") ){ |
97 |
get1 = 1; |
98 |
continue; |
99 |
} |
100 |
// -----------------------------------------------------// |
101 |
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; |
108 |
continue; |
109 |
} |
110 |
// -----------------------------------------------------// |
111 |
if (!strcmp(vcustom[i], "--standalone") || !strcmp(vcustom[i], "-s")){ |
112 |
standalone = true; |
113 |
continue; |
114 |
} |
115 |
// -----------------------------------------------------// |
116 |
if (!strcmp(vcustom[i], "-processFile1")){ |
117 |
if (++i >= ncustom) throw -3; |
118 |
get1 = 1; |
119 |
file1 = vcustom[i]; |
120 |
continue; |
121 |
} |
122 |
// -----------------------------------------------------// |
123 |
if (!strcmp(vcustom[i], "-frame1")){ |
124 |
if (++i >= ncustom)throw -3; |
125 |
get1 = 1; |
126 |
frame1 = vcustom[i]; |
127 |
continue; |
128 |
} |
129 |
// -----------------------------------------------------// |
130 |
if (!strcmp(vcustom[i], "-frame2")){ |
131 |
if (++i >= ncustom)throw -3; |
132 |
get2 = 1; |
133 |
frame2 = vcustom[i]; |
134 |
continue; |
135 |
} |
136 |
// -----------------------------------------------------// |
137 |
if (!strcmp(vcustom[i], "--verbose") || !strcmp(vcustom[i], "-v")){ |
138 |
// VERBOSE = true; |
139 |
this->SetVerboseMode(); |
140 |
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; |
151 |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
152 |
else throw -201; |
153 |
|
154 |
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
155 |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
156 |
else throw -201; |
157 |
|
158 |
if (!frameh.CompareTo("root", TString::kIgnoreCase)) ifrooth = true; |
159 |
else if (!frameh.CompareTo("hbook", TString::kIgnoreCase)) ifrooth =false; |
160 |
else throw -201; |
161 |
|
162 |
ostatus = 0; |
163 |
|
164 |
}; |
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(){ |
192 |
|
193 |
cout <<endl<< "Tracker process parameters: "<< endl; |
194 |
cout << " idRun " << idrun << endl; |
195 |
cout << " get level1 " << get1 << endl; |
196 |
cout << " get level2 " << get2 << endl; |
197 |
cout << " get hough " << geth << endl; |
198 |
cout << " frame1 " << frame1 << endl; |
199 |
cout << " frame2 " << frame2 << endl; |
200 |
cout << " frameh " << frame2 << endl; |
201 |
cout << " file1 " << file1 << endl; |
202 |
cout << " file2 " << file2 << endl; |
203 |
cout << " outdir " << outdir << endl; |
204 |
cout << " process folder " << pfolder << endl; |
205 |
cout << " standalone mode " << standalone << endl; |
206 |
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 |
} |