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