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.2 |
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 |
|
|
TrkParams::SetTrackingMode(); |
40 |
|
|
TrkParams::SetPrecisionFactor(); |
41 |
|
|
TrkParams::SetStepMin(); |
42 |
|
|
TrkParams::SetPFA(); |
43 |
mocchiut |
1.1 |
}; |
44 |
|
|
|
45 |
pam-fi |
1.2 |
/** |
46 |
|
|
* Create TrkProcess object, initializing the tracker processing variables according to input parameters. |
47 |
|
|
* @param run Run ID |
48 |
|
|
* @param f2 Pointer to output level2 file |
49 |
|
|
*/ |
50 |
mocchiut |
1.1 |
TrkProcess::TrkProcess(ULong64_t run, TFile *f2){ |
51 |
|
|
|
52 |
|
|
idrun = run; |
53 |
pam-fi |
1.2 |
// DEBUG = false; |
54 |
|
|
// VERBOSE = false; |
55 |
|
|
dbg_mode.SetWarning(); |
56 |
pam-fi |
1.7 |
get1 = 0; |
57 |
|
|
full1 = 0; |
58 |
mocchiut |
1.1 |
get2 = 1; |
59 |
pam-fi |
1.6 |
geth = 0; |
60 |
mocchiut |
1.1 |
standalone = false; |
61 |
|
|
frame2 = "root"; |
62 |
pam-fi |
1.4 |
frame1 = "root"; |
63 |
pam-fi |
1.6 |
frameh = "root"; |
64 |
|
|
pfolder = "/TrackerFolder"; |
65 |
|
|
file1 = ""; |
66 |
mocchiut |
1.1 |
if(f2->IsOpen()){ |
67 |
pam-fi |
1.6 |
file2 = f2->GetPath(); |
68 |
|
|
outdir = gSystem->DirName(gSystem->DirName(file2)); |
69 |
pam-fi |
1.4 |
// check if the indicated output directory exists |
70 |
pam-fi |
1.6 |
FileStat_t t; |
71 |
|
|
if( gSystem->GetPathInfo(outdir.Data(),t) )throw -12; |
72 |
mocchiut |
1.1 |
}else{ |
73 |
pam-fi |
1.6 |
file2 = ""; |
74 |
|
|
outdir = gSystem->WorkingDirectory(); |
75 |
mocchiut |
1.1 |
}; |
76 |
|
|
|
77 |
|
|
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
78 |
|
|
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
79 |
|
|
|
80 |
|
|
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
81 |
|
|
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
82 |
|
|
|
83 |
pam-fi |
1.6 |
if (!frameh.CompareTo("root", TString::kIgnoreCase)) ifrooth = true; |
84 |
|
|
else if (!frameh.CompareTo("hbook", TString::kIgnoreCase)) ifrooth =false; |
85 |
|
|
|
86 |
pam-fi |
1.2 |
ostatus = 0; |
87 |
mocchiut |
1.1 |
|
88 |
pam-fi |
1.10 |
TrkParams::SetTrackingMode(); |
89 |
|
|
TrkParams::SetPrecisionFactor(); |
90 |
|
|
TrkParams::SetStepMin(); |
91 |
|
|
TrkParams::SetPFA(); |
92 |
|
|
|
93 |
mocchiut |
1.1 |
}; |
94 |
pam-fi |
1.2 |
/** |
95 |
|
|
* Set processing variables according to input custom parameters |
96 |
|
|
*/ |
97 |
|
|
void TrkProcess::HandleCustomPar(int ncustom, char *vcustom[]){ |
98 |
mocchiut |
1.1 |
|
99 |
|
|
for (int i=0; i< ncustom; i++){ |
100 |
pam-fi |
1.4 |
|
101 |
mocchiut |
1.1 |
// -----------------------------------------------------// |
102 |
|
|
if (!strcmp(vcustom[i], "-processFolder")){ |
103 |
|
|
if (++i >= ncustom) throw -3; |
104 |
|
|
pfolder = vcustom[i]; |
105 |
|
|
continue; |
106 |
|
|
} |
107 |
|
|
// -----------------------------------------------------// |
108 |
pam-fi |
1.6 |
if (!strcmp(vcustom[i], "--get1") || !strcmp(vcustom[i], "--get-level1") ){ |
109 |
pam-fi |
1.7 |
get1 = 1; |
110 |
|
|
full1 = 0; |
111 |
|
|
continue; |
112 |
|
|
} |
113 |
|
|
// -----------------------------------------------------// |
114 |
|
|
if (!strcmp(vcustom[i], "--get1-full") || !strcmp(vcustom[i], "--get-level1-full") ){ |
115 |
|
|
get1 = 1; |
116 |
|
|
full1 = 1; |
117 |
mocchiut |
1.1 |
continue; |
118 |
|
|
} |
119 |
|
|
// -----------------------------------------------------// |
120 |
pam-fi |
1.6 |
if (!strcmp(vcustom[i], "--geth") || !strcmp(vcustom[i], "--get-hough") ){ |
121 |
|
|
geth = 1; |
122 |
|
|
continue; |
123 |
|
|
} |
124 |
|
|
// -----------------------------------------------------// |
125 |
|
|
if (!strcmp(vcustom[i], "--dontget2") ||!strcmp(vcustom[i], "--dontget-level2") ){ |
126 |
mocchiut |
1.1 |
get2 = 0; |
127 |
|
|
continue; |
128 |
|
|
} |
129 |
|
|
// -----------------------------------------------------// |
130 |
|
|
if (!strcmp(vcustom[i], "--standalone") || !strcmp(vcustom[i], "-s")){ |
131 |
|
|
standalone = true; |
132 |
|
|
continue; |
133 |
|
|
} |
134 |
|
|
// -----------------------------------------------------// |
135 |
|
|
if (!strcmp(vcustom[i], "-processFile1")){ |
136 |
|
|
if (++i >= ncustom) throw -3; |
137 |
|
|
get1 = 1; |
138 |
|
|
file1 = vcustom[i]; |
139 |
|
|
continue; |
140 |
|
|
} |
141 |
|
|
// -----------------------------------------------------// |
142 |
|
|
if (!strcmp(vcustom[i], "-frame1")){ |
143 |
|
|
if (++i >= ncustom)throw -3; |
144 |
|
|
get1 = 1; |
145 |
|
|
frame1 = vcustom[i]; |
146 |
|
|
continue; |
147 |
|
|
} |
148 |
|
|
// -----------------------------------------------------// |
149 |
|
|
if (!strcmp(vcustom[i], "-frame2")){ |
150 |
|
|
if (++i >= ncustom)throw -3; |
151 |
|
|
get2 = 1; |
152 |
|
|
frame2 = vcustom[i]; |
153 |
|
|
continue; |
154 |
|
|
} |
155 |
|
|
// -----------------------------------------------------// |
156 |
pam-fi |
1.2 |
if (!strcmp(vcustom[i], "--verbose") || !strcmp(vcustom[i], "-v")){ |
157 |
|
|
// VERBOSE = true; |
158 |
|
|
this->SetVerboseMode(); |
159 |
|
|
continue; |
160 |
|
|
} |
161 |
|
|
// -----------------------------------------------------// |
162 |
|
|
else if (!strcmp(vcustom[i], "--debug") || !strcmp(vcustom[i], "-d")){ |
163 |
|
|
// DEBUG = true; |
164 |
|
|
this->SetDebugMode(); |
165 |
mocchiut |
1.1 |
continue; |
166 |
pam-fi |
1.2 |
}; |
167 |
mocchiut |
1.1 |
} |
168 |
pam-fi |
1.4 |
|
169 |
mocchiut |
1.1 |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
170 |
|
|
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
171 |
|
|
else throw -201; |
172 |
|
|
|
173 |
|
|
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
174 |
|
|
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
175 |
|
|
else throw -201; |
176 |
pam-fi |
1.4 |
|
177 |
pam-fi |
1.6 |
if (!frameh.CompareTo("root", TString::kIgnoreCase)) ifrooth = true; |
178 |
|
|
else if (!frameh.CompareTo("hbook", TString::kIgnoreCase)) ifrooth =false; |
179 |
|
|
else throw -201; |
180 |
mocchiut |
1.1 |
|
181 |
pam-fi |
1.7 |
if(get1 && !get2)full1=true; |
182 |
|
|
|
183 |
pam-fi |
1.2 |
ostatus = 0; |
184 |
mocchiut |
1.1 |
|
185 |
pam-fi |
1.2 |
}; |
186 |
|
|
/** |
187 |
|
|
* \brief Process Level0 event |
188 |
|
|
* @param l0_event Pointer to an object of the tracker level0 class |
189 |
|
|
* Starting from a Level0 object, this routine fills the level0 common, then calls |
190 |
|
|
* the fortran routines, which process the event and fill level1 and level2 commons. |
191 |
|
|
*/ |
192 |
|
|
void TrkProcess::ProcessEvent(TrkLevel0 *l0_event){ |
193 |
|
|
|
194 |
|
|
// fill Level0 common from Level0 object |
195 |
pam-fi |
1.8 |
// l0_event->GetCommonVar(&level0event_); |
196 |
|
|
l0_event->GetLevel0Struct(); |
197 |
pam-fi |
1.2 |
// process the event Level0->Level1->Level2 |
198 |
|
|
int F77err = 0; |
199 |
|
|
// |
200 |
|
|
reductionflight_(&F77err); |
201 |
|
|
if(F77err < 0)throw F77err; |
202 |
|
|
// |
203 |
pam-fi |
1.9 |
// int pfa=0; //<<< ETA |
204 |
pam-fi |
1.10 |
// int pfa=14;//<<< COG4 |
205 |
|
|
// if(get2) analysisflight_(&pfa); |
206 |
|
|
if(get2) analysisflight_(); |
207 |
pam-fi |
1.2 |
// |
208 |
|
|
ostatus = F77err; |
209 |
|
|
|
210 |
mocchiut |
1.1 |
}; |
211 |
|
|
|
212 |
|
|
void TrkProcess::Dump(){ |
213 |
|
|
|
214 |
|
|
cout <<endl<< "Tracker process parameters: "<< endl; |
215 |
|
|
cout << " idRun " << idrun << endl; |
216 |
pam-fi |
1.6 |
cout << " get level1 " << get1 << endl; |
217 |
pam-fi |
1.7 |
cout << " full level1 " << full1 << endl; |
218 |
pam-fi |
1.6 |
cout << " get level2 " << get2 << endl; |
219 |
|
|
cout << " get hough " << geth << endl; |
220 |
mocchiut |
1.1 |
cout << " frame1 " << frame1 << endl; |
221 |
|
|
cout << " frame2 " << frame2 << endl; |
222 |
pam-fi |
1.6 |
cout << " frameh " << frame2 << endl; |
223 |
mocchiut |
1.1 |
cout << " file1 " << file1 << endl; |
224 |
|
|
cout << " file2 " << file2 << endl; |
225 |
|
|
cout << " outdir " << outdir << endl; |
226 |
pam-fi |
1.2 |
cout << " process folder " << pfolder << endl; |
227 |
mocchiut |
1.1 |
cout << " standalone mode " << standalone << endl; |
228 |
pam-fi |
1.2 |
cout << " debug mode warning " << dbg_mode.warning << endl; |
229 |
|
|
cout << " debug mode verbose " << dbg_mode.verbose << endl; |
230 |
|
|
cout << " debug mode debug " << dbg_mode.debug << endl << endl; |
231 |
mocchiut |
1.1 |
|
232 |
|
|
} |