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 |
// DEBUG = false; |
15 |
|
|
// VERBOSE = false; |
16 |
|
|
dbg_mode.SetNone(); |
17 |
mocchiut |
1.1 |
get1 = 0; |
18 |
|
|
get2 = 1; |
19 |
|
|
standalone = false; |
20 |
|
|
frame2 = "root"; |
21 |
|
|
frame1 = "hbook"; |
22 |
|
|
outdir = gSystem->WorkingDirectory(); |
23 |
|
|
pfolder = "/TrackerFolder"; |
24 |
|
|
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
25 |
pam-fi |
1.2 |
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 = false; |
26 |
mocchiut |
1.1 |
|
27 |
|
|
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
28 |
pam-fi |
1.2 |
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 = false; |
29 |
mocchiut |
1.1 |
|
30 |
|
|
file1 = ""; |
31 |
|
|
file2 = ""; |
32 |
|
|
|
33 |
pam-fi |
1.2 |
ostatus = 0; |
34 |
mocchiut |
1.1 |
}; |
35 |
|
|
|
36 |
pam-fi |
1.2 |
/** |
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 |
mocchiut |
1.1 |
TrkProcess::TrkProcess(ULong64_t run, TFile *f2){ |
42 |
|
|
|
43 |
|
|
idrun = run; |
44 |
pam-fi |
1.2 |
// DEBUG = false; |
45 |
|
|
// VERBOSE = false; |
46 |
|
|
dbg_mode.SetWarning(); |
47 |
mocchiut |
1.1 |
get1 = 0; |
48 |
|
|
get2 = 1; |
49 |
|
|
standalone = false; |
50 |
|
|
frame2 = "root"; |
51 |
pam-fi |
1.4 |
frame1 = "root"; |
52 |
|
|
// ifroot1 = false; |
53 |
|
|
// ifroot2 = true; |
54 |
|
|
pfolder = "/TrackerFolder"; |
55 |
|
|
file1 = ""; |
56 |
mocchiut |
1.1 |
if(f2->IsOpen()){ |
57 |
pam-fi |
1.4 |
file2 = f2->GetPath(); |
58 |
|
|
outdir = gSystem->DirName(gSystem->DirName(file2)); |
59 |
|
|
// check if the indicated output directory exists |
60 |
|
|
FileStat_t t; |
61 |
|
|
if( gSystem->GetPathInfo(outdir.Data(),t) )throw -12; |
62 |
mocchiut |
1.1 |
}else{ |
63 |
pam-fi |
1.4 |
file2 = ""; |
64 |
|
|
outdir = gSystem->WorkingDirectory(); |
65 |
mocchiut |
1.1 |
}; |
66 |
|
|
|
67 |
|
|
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
68 |
|
|
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
69 |
|
|
|
70 |
|
|
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
71 |
|
|
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
72 |
|
|
|
73 |
pam-fi |
1.2 |
ostatus = 0; |
74 |
mocchiut |
1.1 |
|
75 |
|
|
}; |
76 |
pam-fi |
1.2 |
/** |
77 |
|
|
* Set processing variables according to input custom parameters |
78 |
|
|
*/ |
79 |
|
|
void TrkProcess::HandleCustomPar(int ncustom, char *vcustom[]){ |
80 |
mocchiut |
1.1 |
|
81 |
|
|
for (int i=0; i< ncustom; i++){ |
82 |
pam-fi |
1.4 |
|
83 |
mocchiut |
1.1 |
// -----------------------------------------------------// |
84 |
|
|
if (!strcmp(vcustom[i], "-processFolder")){ |
85 |
|
|
if (++i >= ncustom) throw -3; |
86 |
|
|
pfolder = vcustom[i]; |
87 |
|
|
continue; |
88 |
|
|
} |
89 |
|
|
// -----------------------------------------------------// |
90 |
|
|
if (!strcmp(vcustom[i], "--get1")){ |
91 |
|
|
get1 = 1; |
92 |
|
|
continue; |
93 |
|
|
} |
94 |
|
|
// -----------------------------------------------------// |
95 |
|
|
if (!strcmp(vcustom[i], "--dontget2")){ |
96 |
|
|
get2 = 0; |
97 |
|
|
continue; |
98 |
|
|
} |
99 |
|
|
// -----------------------------------------------------// |
100 |
|
|
if (!strcmp(vcustom[i], "--standalone") || !strcmp(vcustom[i], "-s")){ |
101 |
|
|
standalone = true; |
102 |
|
|
continue; |
103 |
|
|
} |
104 |
|
|
// -----------------------------------------------------// |
105 |
|
|
if (!strcmp(vcustom[i], "-processFile1")){ |
106 |
|
|
if (++i >= ncustom) throw -3; |
107 |
|
|
get1 = 1; |
108 |
|
|
file1 = vcustom[i]; |
109 |
|
|
continue; |
110 |
|
|
} |
111 |
|
|
// -----------------------------------------------------// |
112 |
|
|
if (!strcmp(vcustom[i], "-frame1")){ |
113 |
|
|
if (++i >= ncustom)throw -3; |
114 |
|
|
get1 = 1; |
115 |
|
|
frame1 = vcustom[i]; |
116 |
|
|
continue; |
117 |
|
|
} |
118 |
|
|
// -----------------------------------------------------// |
119 |
|
|
if (!strcmp(vcustom[i], "-frame2")){ |
120 |
|
|
if (++i >= ncustom)throw -3; |
121 |
|
|
get2 = 1; |
122 |
|
|
frame2 = vcustom[i]; |
123 |
|
|
continue; |
124 |
|
|
} |
125 |
|
|
// -----------------------------------------------------// |
126 |
pam-fi |
1.2 |
if (!strcmp(vcustom[i], "--verbose") || !strcmp(vcustom[i], "-v")){ |
127 |
|
|
// VERBOSE = true; |
128 |
|
|
this->SetVerboseMode(); |
129 |
|
|
continue; |
130 |
|
|
} |
131 |
|
|
// -----------------------------------------------------// |
132 |
|
|
else if (!strcmp(vcustom[i], "--debug") || !strcmp(vcustom[i], "-d")){ |
133 |
|
|
// DEBUG = true; |
134 |
|
|
this->SetDebugMode(); |
135 |
mocchiut |
1.1 |
continue; |
136 |
pam-fi |
1.2 |
}; |
137 |
mocchiut |
1.1 |
} |
138 |
pam-fi |
1.4 |
|
139 |
mocchiut |
1.1 |
if (!frame2.CompareTo("root", TString::kIgnoreCase)) ifroot2 = true; |
140 |
|
|
else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false; |
141 |
|
|
else throw -201; |
142 |
|
|
|
143 |
|
|
if (!frame1.CompareTo("root", TString::kIgnoreCase)) ifroot1 = true; |
144 |
|
|
else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false; |
145 |
|
|
else throw -201; |
146 |
pam-fi |
1.4 |
|
147 |
pam-fi |
1.5 |
// if(get1){ |
148 |
|
|
// |
149 |
|
|
// TString filety; |
150 |
|
|
// if ( ifroot1) filety=".root"; |
151 |
|
|
// else if (!ifroot1) filety=".rz"; |
152 |
|
|
// else throw -200; |
153 |
|
|
// |
154 |
|
|
// TString base = file2; |
155 |
|
|
// if(base.Contains(".Level2.root"))base = base(0,base.Index(".Level2.root")); |
156 |
|
|
// else base = base(0,base.Index(".root")); |
157 |
|
|
// base = gSystem->BaseName(base); |
158 |
|
|
// file1 = outdir + "/"+ gSystem->BaseName(pfolder) + "/" + base +".Level1"+filety; |
159 |
|
|
// // cout << "Requested Level1 output. "<< endl << "Level1 File: "<< file1 << endl; |
160 |
|
|
// 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 |
mocchiut |
1.1 |
|
170 |
pam-fi |
1.2 |
ostatus = 0; |
171 |
mocchiut |
1.1 |
|
172 |
pam-fi |
1.2 |
}; |
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 |
mocchiut |
1.3 |
// else if(F77err > 0 && WarningMode())cout<<" WARNING ("<<F77err<<") - TrkCore - Level1 reduction (CN computation failure, ...)"<<endl; |
190 |
pam-fi |
1.2 |
// |
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 |
mocchiut |
1.1 |
}; |
198 |
|
|
|
199 |
|
|
void TrkProcess::Dump(){ |
200 |
|
|
|
201 |
|
|
cout <<endl<< "Tracker process parameters: "<< endl; |
202 |
|
|
cout << " idRun " << idrun << endl; |
203 |
|
|
cout << " get1 " << get1 << endl; |
204 |
|
|
cout << " get2 " << get2 << endl; |
205 |
|
|
cout << " frame1 " << frame1 << endl; |
206 |
|
|
cout << " frame2 " << frame2 << endl; |
207 |
|
|
cout << " file1 " << file1 << endl; |
208 |
|
|
cout << " file2 " << file2 << endl; |
209 |
|
|
cout << " outdir " << outdir << endl; |
210 |
pam-fi |
1.2 |
cout << " process folder " << pfolder << endl; |
211 |
mocchiut |
1.1 |
cout << " standalone mode " << standalone << endl; |
212 |
pam-fi |
1.2 |
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 |
mocchiut |
1.1 |
|
216 |
|
|
} |