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