3#include "GaudiKernel/AlgFactory.h"
4#include "GaudiKernel/IDataProviderSvc.h"
5#include "GaudiKernel/INTupleSvc.h"
6#include "GaudiKernel/IPartPropSvc.h"
7#include "GaudiKernel/IService.h"
8#include "GaudiKernel/ISvcLocator.h"
9#include "GaudiKernel/MsgStream.h"
10#include "GaudiKernel/NTuple.h"
11#include "GaudiKernel/PropertyMgr.h"
12#include "GaudiKernel/SmartDataPtr.h"
16#include "TStopwatch.h"
49#include "GaudiKernel/IPartPropSvc.h"
77#include "TGraphErrors.h"
82#include "CLHEP/Vector/LorentzVector.h"
83#include "CLHEP/Vector/ThreeVector.h"
84#include "CLHEP/Vector/TwoVector.h"
85using CLHEP::Hep2Vector;
86using CLHEP::Hep3Vector;
87using CLHEP::HepLorentzVector;
91vector<double>
Vec_layer,
Vec_phi,
Vec_Z,
Vec_layerid,
Vec_Virlayerid,
Vec_v,
Vec_flag,
Vec_Q,
Vec_sheetid,
Vec_xCluSize,
128 declareProperty(
"sigma", sigma = 0.13);
129 declareProperty(
"Run10_Flag", Run10_Flag =
false);
130 declareProperty(
"Align_Flag", Align_Flag =
false);
132 declareProperty(
"Method", Method = 0);
133 declareProperty(
"MAX_COMB",
MAX_COMB = 50);
134 declareProperty(
"MAX_Clusters", MAX_Clusters = 500);
135 declareProperty(
"MaxClu_Sheet",
Nmax = 3);
136 declareProperty(
"Chisq_cut", Chisq_cut = 2000);
137 declareProperty(
"TEST_N",
TEST_N = 0);
139 declareProperty(
"Debug",
debug = 0);
141 declareProperty(
"MC",
MC = 0);
142 declareProperty(
"LUTfile", m_LUTfile =
"/bes3fs/cgemCosmic/data/CGEM_cosmic_look_up_table_17.root");
148 MsgStream log(
msgSvc(), name());
151 log << MSG::INFO <<
"in initialize()" << endreq;
153 NTuplePtr cosmic(
ntupleSvc(),
"LineFit/cosmic");
154 if (cosmic) m_tuple = cosmic;
156 m_tuple =
ntupleSvc()->book(
"LineFit/cosmic", CLID_ColumnWiseTuple,
"N-Tuple example");
159 sc = m_tuple->addItem(
"run", run);
160 sc = m_tuple->addItem(
"event", event);
161 sc = m_tuple->addItem(
"R0", R0);
162 sc = m_tuple->addItem(
"R1", R1);
163 sc = m_tuple->addItem(
"R2", R2);
164 sc = m_tuple->addItem(
"clst_0", clst_0);
165 sc = m_tuple->addItem(
"clst_1", clst_1);
166 sc = m_tuple->addItem(
"clst_2", clst_2);
167 sc = m_tuple->addItem(
"clst_01", clst_01);
168 sc = m_tuple->addItem(
"clst_00", clst_00);
169 sc = m_tuple->addItem(
"clst_11", clst_11);
170 sc = m_tuple->addItem(
"clst_10", clst_10);
171 sc = m_tuple->addItem(
"clst_21", clst_21);
172 sc = m_tuple->addItem(
"clst_20", clst_20);
173 sc = m_tuple->addItem(
"status1", status1);
174 sc = m_tuple->addItem(
"status2", status2);
175 sc = m_tuple->addItem(
"status3", status3);
176 sc = m_tuple->addItem(
"ini_0", ini_0);
177 sc = m_tuple->addItem(
"ini_1", ini_1);
178 sc = m_tuple->addItem(
"ini_2", ini_2);
179 sc = m_tuple->addItem(
"ini_3", ini_3);
180 sc = m_tuple->addItem(
"inim_0", inim_0);
181 sc = m_tuple->addItem(
"inim_1", inim_1);
182 sc = m_tuple->addItem(
"inim_2", inim_2);
183 sc = m_tuple->addItem(
"inim_3", inim_3);
184 sc = m_tuple->addItem(
"inii_0", inii_0);
185 sc = m_tuple->addItem(
"inii_1", inii_1);
186 sc = m_tuple->addItem(
"inii_2", inii_2);
187 sc = m_tuple->addItem(
"inii_3", inii_3);
188 sc = m_tuple->addItem(
"par0", par0);
189 sc = m_tuple->addItem(
"par1", par1);
190 sc = m_tuple->addItem(
"par2", par2);
191 sc = m_tuple->addItem(
"par3", par3);
192 sc = m_tuple->addItem(
"MC_par0", MC_par0);
193 sc = m_tuple->addItem(
"MC_par1", MC_par1);
194 sc = m_tuple->addItem(
"MC_par2", MC_par2);
195 sc = m_tuple->addItem(
"MC_par3", MC_par3);
196 sc = m_tuple->addItem(
"MC_px", MC_px);
197 sc = m_tuple->addItem(
"MC_py", MC_py);
198 sc = m_tuple->addItem(
"MC_pz", MC_pz);
199 sc = m_tuple->addItem(
"Err_par0", Err_par0);
200 sc = m_tuple->addItem(
"Err_par1", Err_par1);
201 sc = m_tuple->addItem(
"Err_par2", Err_par2);
202 sc = m_tuple->addItem(
"Err_par3", Err_par3);
204 sc = m_tuple->addItem(
"x_2_up", x_2_up);
205 sc = m_tuple->addItem(
"x_1_up", x_1_up);
206 sc = m_tuple->addItem(
"x_0_up", x_0_up);
207 sc = m_tuple->addItem(
"v_2_up", v_2_up);
208 sc = m_tuple->addItem(
"v_1_up", v_1_up);
209 sc = m_tuple->addItem(
"v_0_up", v_0_up);
210 sc = m_tuple->addItem(
"z_2_up", z_2_up);
211 sc = m_tuple->addItem(
"z_1_up", z_1_up);
212 sc = m_tuple->addItem(
"z_0_up", z_0_up);
213 sc = m_tuple->addItem(
"x_2_down", x_2_down);
214 sc = m_tuple->addItem(
"x_1_down", x_1_down);
215 sc = m_tuple->addItem(
"x_0_down", x_0_down);
216 sc = m_tuple->addItem(
"v_2_down", v_2_down);
217 sc = m_tuple->addItem(
"v_1_down", v_1_down);
218 sc = m_tuple->addItem(
"v_0_down", v_0_down);
219 sc = m_tuple->addItem(
"z_2_down", z_2_down);
220 sc = m_tuple->addItem(
"z_1_down", z_1_down);
221 sc = m_tuple->addItem(
"z_0_down", z_0_down);
223 sc = m_tuple->addItem(
"x_2_up_m", x_2_up_m);
224 sc = m_tuple->addItem(
"x_1_up_m", x_1_up_m);
225 sc = m_tuple->addItem(
"x_0_up_m", x_0_up_m);
226 sc = m_tuple->addItem(
"v_2_up_m", v_2_up_m);
227 sc = m_tuple->addItem(
"v_1_up_m", v_1_up_m);
228 sc = m_tuple->addItem(
"v_0_up_m", v_0_up_m);
229 sc = m_tuple->addItem(
"z_2_up_m", z_2_up_m);
230 sc = m_tuple->addItem(
"z_1_up_m", z_1_up_m);
231 sc = m_tuple->addItem(
"z_0_up_m", z_0_up_m);
233 sc = m_tuple->addItem(
"x_2_down_m", x_2_down_m);
234 sc = m_tuple->addItem(
"x_1_down_m", x_1_down_m);
235 sc = m_tuple->addItem(
"x_0_down_m", x_0_down_m);
236 sc = m_tuple->addItem(
"v_2_down_m", v_2_down_m);
237 sc = m_tuple->addItem(
"v_1_down_m", v_1_down_m);
238 sc = m_tuple->addItem(
"v_0_down_m", v_0_down_m);
239 sc = m_tuple->addItem(
"z_2_down_m", z_2_down_m);
240 sc = m_tuple->addItem(
"z_1_down_m", z_1_down_m);
241 sc = m_tuple->addItem(
"z_0_down_m", z_0_down_m);
243 sc = m_tuple->addItem(
"x_2_up_f", x_2_up_f);
244 sc = m_tuple->addItem(
"x_1_up_f", x_1_up_f);
245 sc = m_tuple->addItem(
"x_0_up_f", x_0_up_f);
246 sc = m_tuple->addItem(
"v_2_up_f", v_2_up_f);
247 sc = m_tuple->addItem(
"v_1_up_f", v_1_up_f);
248 sc = m_tuple->addItem(
"v_0_up_f", v_0_up_f);
250 sc = m_tuple->addItem(
"x_2_down_f", x_2_down_f);
251 sc = m_tuple->addItem(
"x_1_down_f", x_1_down_f);
252 sc = m_tuple->addItem(
"x_0_down_f", x_0_down_f);
253 sc = m_tuple->addItem(
"v_2_down_f", v_2_down_f);
254 sc = m_tuple->addItem(
"v_1_down_f", v_1_down_f);
255 sc = m_tuple->addItem(
"v_0_down_f", v_0_down_f);
257 sc = m_tuple->addItem(
"x_2_up_pre", x_2_up_mc);
258 sc = m_tuple->addItem(
"x_1_up_pre", x_1_up_mc);
259 sc = m_tuple->addItem(
"x_0_up_pre", x_0_up_mc);
260 sc = m_tuple->addItem(
"v_2_up_pre", v_2_up_mc);
261 sc = m_tuple->addItem(
"v_1_up_pre", v_1_up_mc);
262 sc = m_tuple->addItem(
"v_0_up_pre", v_0_up_mc);
264 sc = m_tuple->addItem(
"x_2_down_pre", x_2_down_mc);
265 sc = m_tuple->addItem(
"x_1_down_pre", x_1_down_mc);
266 sc = m_tuple->addItem(
"x_0_down_pre", x_0_down_mc);
267 sc = m_tuple->addItem(
"v_2_down_pre", v_2_down_mc);
268 sc = m_tuple->addItem(
"v_1_down_pre", v_1_down_mc);
269 sc = m_tuple->addItem(
"v_0_down_pre", v_0_down_mc);
271 sc = m_tuple->addItem(
"x_2_up_hit", x_2_up_mc2);
272 sc = m_tuple->addItem(
"x_1_up_hit", x_1_up_mc2);
273 sc = m_tuple->addItem(
"x_0_up_hit", x_0_up_mc2);
274 sc = m_tuple->addItem(
"v_2_up_hit", v_2_up_mc2);
275 sc = m_tuple->addItem(
"v_1_up_hit", v_1_up_mc2);
276 sc = m_tuple->addItem(
"v_0_up_hit", v_0_up_mc2);
277 sc = m_tuple->addItem(
"z_2_up_hit", z_2_up_mc2);
278 sc = m_tuple->addItem(
"z_1_up_hit", z_1_up_mc2);
279 sc = m_tuple->addItem(
"z_0_up_hit", z_0_up_mc2);
281 sc = m_tuple->addItem(
"x_2_down_hit", x_2_down_mc2);
282 sc = m_tuple->addItem(
"x_1_down_hit", x_1_down_mc2);
283 sc = m_tuple->addItem(
"x_0_down_hit", x_0_down_mc2);
284 sc = m_tuple->addItem(
"v_2_down_hit", v_2_down_mc2);
285 sc = m_tuple->addItem(
"v_1_down_hit", v_1_down_mc2);
286 sc = m_tuple->addItem(
"v_0_down_hit", v_0_down_mc2);
287 sc = m_tuple->addItem(
"z_2_down_hit", z_2_down_mc2);
288 sc = m_tuple->addItem(
"z_1_down_hit", z_1_down_mc2);
289 sc = m_tuple->addItem(
"z_0_down_hit", z_0_down_mc2);
291 sc = m_tuple->addItem(
"x_2_up_size", x_2_up_size, 0, 100);
292 sc = m_tuple->addItem(
"x_1_up_size", x_1_up_size, 0, 100);
293 sc = m_tuple->addItem(
"x_0_up_size", x_0_up_size, 0, 100);
294 sc = m_tuple->addItem(
"v_2_up_size", v_2_up_size, 0, 100);
295 sc = m_tuple->addItem(
"v_1_up_size", v_1_up_size, 0, 100);
296 sc = m_tuple->addItem(
"v_0_up_size", v_0_up_size, 0, 100);
298 sc = m_tuple->addItem(
"x_2_down_size", x_2_down_size, 0, 100);
299 sc = m_tuple->addItem(
"x_1_down_size", x_1_down_size, 0, 100);
300 sc = m_tuple->addItem(
"x_0_down_size", x_0_down_size, 0, 100);
301 sc = m_tuple->addItem(
"v_2_down_size", v_2_down_size, 0, 100);
302 sc = m_tuple->addItem(
"v_1_down_size", v_1_down_size, 0, 100);
303 sc = m_tuple->addItem(
"v_0_down_size", v_0_down_size, 0, 100);
305 sc = m_tuple->addItem(
"x_2_up_Q", x_2_up_Q);
306 sc = m_tuple->addItem(
"x_1_up_Q", x_1_up_Q);
307 sc = m_tuple->addItem(
"x_0_up_Q", x_0_up_Q);
308 sc = m_tuple->addItem(
"v_2_up_Q", v_2_up_Q);
309 sc = m_tuple->addItem(
"v_1_up_Q", v_1_up_Q);
310 sc = m_tuple->addItem(
"v_0_up_Q", v_0_up_Q);
312 sc = m_tuple->addItem(
"x_2_down_Q", x_2_down_Q);
313 sc = m_tuple->addItem(
"x_1_down_Q", x_1_down_Q);
314 sc = m_tuple->addItem(
"x_0_down_Q", x_0_down_Q);
315 sc = m_tuple->addItem(
"v_2_down_Q", v_2_down_Q);
316 sc = m_tuple->addItem(
"v_1_down_Q", v_1_down_Q);
317 sc = m_tuple->addItem(
"v_0_down_Q", v_0_down_Q);
319 sc = m_tuple->addIndexedItem(
"x_2_up_stripQ", x_2_up_size, x_2_up_stripQ);
320 sc = m_tuple->addIndexedItem(
"x_1_up_stripQ", x_1_up_size, x_1_up_stripQ);
321 sc = m_tuple->addIndexedItem(
"x_0_up_stripQ", x_0_up_size, x_0_up_stripQ);
322 sc = m_tuple->addIndexedItem(
"v_2_up_stripQ", v_2_up_size, v_2_up_stripQ);
323 sc = m_tuple->addIndexedItem(
"v_1_up_stripQ", v_1_up_size, v_1_up_stripQ);
324 sc = m_tuple->addIndexedItem(
"v_0_up_stripQ", v_0_up_size, v_0_up_stripQ);
326 sc = m_tuple->addIndexedItem(
"x_2_down_stripQ", x_2_down_size, x_2_down_stripQ);
327 sc = m_tuple->addIndexedItem(
"x_1_down_stripQ", x_1_down_size, x_1_down_stripQ);
328 sc = m_tuple->addIndexedItem(
"x_0_down_stripQ", x_0_down_size, x_0_down_stripQ);
329 sc = m_tuple->addIndexedItem(
"v_2_down_stripQ", v_2_down_size, v_2_down_stripQ);
330 sc = m_tuple->addIndexedItem(
"v_1_down_stripQ", v_1_down_size, v_1_down_stripQ);
331 sc = m_tuple->addIndexedItem(
"v_0_down_stripQ", v_0_down_size, v_0_down_stripQ);
333 sc = m_tuple->addIndexedItem(
"x_2_up_stripT", x_2_up_size, x_2_up_stripT);
334 sc = m_tuple->addIndexedItem(
"x_1_up_stripT", x_1_up_size, x_1_up_stripT);
335 sc = m_tuple->addIndexedItem(
"x_0_up_stripT", x_0_up_size, x_0_up_stripT);
336 sc = m_tuple->addIndexedItem(
"v_2_up_stripT", v_2_up_size, v_2_up_stripT);
337 sc = m_tuple->addIndexedItem(
"v_1_up_stripT", v_1_up_size, v_1_up_stripT);
338 sc = m_tuple->addIndexedItem(
"v_0_up_stripT", v_0_up_size, v_0_up_stripT);
340 sc = m_tuple->addIndexedItem(
"x_2_down_stripT", x_2_down_size, x_2_down_stripT);
341 sc = m_tuple->addIndexedItem(
"x_1_down_stripT", x_1_down_size, x_1_down_stripT);
342 sc = m_tuple->addIndexedItem(
"x_0_down_stripT", x_0_down_size, x_0_down_stripT);
343 sc = m_tuple->addIndexedItem(
"v_2_down_stripT", v_2_down_size, v_2_down_stripT);
344 sc = m_tuple->addIndexedItem(
"v_1_down_stripT", v_1_down_size, v_1_down_stripT);
345 sc = m_tuple->addIndexedItem(
"v_0_down_stripT", v_0_down_size, v_0_down_stripT);
347 sc = m_tuple->addIndexedItem(
"x_2_up_stripTf", x_2_up_size, x_2_up_stripTf);
348 sc = m_tuple->addIndexedItem(
"x_1_up_stripTf", x_1_up_size, x_1_up_stripTf);
349 sc = m_tuple->addIndexedItem(
"x_0_up_stripTf", x_0_up_size, x_0_up_stripTf);
350 sc = m_tuple->addIndexedItem(
"v_2_up_stripTf", v_2_up_size, v_2_up_stripTf);
351 sc = m_tuple->addIndexedItem(
"v_1_up_stripTf", v_1_up_size, v_1_up_stripTf);
352 sc = m_tuple->addIndexedItem(
"v_0_up_stripTf", v_0_up_size, v_0_up_stripTf);
354 sc = m_tuple->addIndexedItem(
"x_2_down_stripTf", x_2_down_size, x_2_down_stripTf);
355 sc = m_tuple->addIndexedItem(
"x_1_down_stripTf", x_1_down_size, x_1_down_stripTf);
356 sc = m_tuple->addIndexedItem(
"x_0_down_stripTf", x_0_down_size, x_0_down_stripTf);
357 sc = m_tuple->addIndexedItem(
"v_2_down_stripTf", v_2_down_size, v_2_down_stripTf);
358 sc = m_tuple->addIndexedItem(
"v_1_down_stripTf", v_1_down_size, v_1_down_stripTf);
359 sc = m_tuple->addIndexedItem(
"v_0_down_stripTf", v_0_down_size, v_0_down_stripTf);
361 sc = m_tuple->addIndexedItem(
"x_2_up_stripID", x_2_up_size, x_2_up_stripID);
362 sc = m_tuple->addIndexedItem(
"x_1_up_stripID", x_1_up_size, x_1_up_stripID);
363 sc = m_tuple->addIndexedItem(
"x_0_up_stripID", x_0_up_size, x_0_up_stripID);
364 sc = m_tuple->addIndexedItem(
"v_2_up_stripID", v_2_up_size, v_2_up_stripID);
365 sc = m_tuple->addIndexedItem(
"v_1_up_stripID", v_1_up_size, v_1_up_stripID);
366 sc = m_tuple->addIndexedItem(
"v_0_up_stripID", v_0_up_size, v_0_up_stripID);
368 sc = m_tuple->addIndexedItem(
"x_2_down_stripID", x_2_down_size, x_2_down_stripID);
369 sc = m_tuple->addIndexedItem(
"x_1_down_stripID", x_1_down_size, x_1_down_stripID);
370 sc = m_tuple->addIndexedItem(
"x_0_down_stripID", x_0_down_size, x_0_down_stripID);
371 sc = m_tuple->addIndexedItem(
"v_2_down_stripID", v_2_down_size, v_2_down_stripID);
372 sc = m_tuple->addIndexedItem(
"v_1_down_stripID", v_1_down_size, v_1_down_stripID);
373 sc = m_tuple->addIndexedItem(
"v_0_down_stripID", v_0_down_size, v_0_down_stripID);
375 sc = m_tuple->addItem(
"inter_1_x", inter_1_x);
376 sc = m_tuple->addItem(
"inter_2_x", inter_2_x);
377 sc = m_tuple->addItem(
"inter_3_x", inter_3_x);
378 sc = m_tuple->addItem(
"inter_4_x", inter_4_x);
379 sc = m_tuple->addItem(
"inter_5_x", inter_5_x);
380 sc = m_tuple->addItem(
"inter_6_x", inter_6_x);
381 sc = m_tuple->addItem(
"inter_x", inter_x);
383 sc = m_tuple->addItem(
"inter_1_V", inter_1_V);
384 sc = m_tuple->addItem(
"inter_2_V", inter_2_V);
385 sc = m_tuple->addItem(
"inter_3_V", inter_3_V);
386 sc = m_tuple->addItem(
"inter_4_V", inter_4_V);
387 sc = m_tuple->addItem(
"inter_5_V", inter_5_V);
388 sc = m_tuple->addItem(
"inter_6_V", inter_6_V);
389 sc = m_tuple->addItem(
"inter_V", inter_V);
391 sc = m_tuple->addItem(
"inter_1_flag", inter_1_flag);
392 sc = m_tuple->addItem(
"inter_2_flag", inter_2_flag);
393 sc = m_tuple->addItem(
"inter_3_flag", inter_3_flag);
394 sc = m_tuple->addItem(
"inter_4_flag", inter_4_flag);
395 sc = m_tuple->addItem(
"inter_5_flag", inter_5_flag);
396 sc = m_tuple->addItem(
"inter_6_flag", inter_6_flag);
397 sc = m_tuple->addItem(
"inter_flag", inter_flag);
399 sc = m_tuple->addItem(
"inter_1_z", inter_1_z);
400 sc = m_tuple->addItem(
"inter_2_z", inter_2_z);
401 sc = m_tuple->addItem(
"inter_3_z", inter_3_z);
402 sc = m_tuple->addItem(
"inter_4_z", inter_4_z);
403 sc = m_tuple->addItem(
"inter_5_z", inter_5_z);
404 sc = m_tuple->addItem(
"inter_6_z", inter_6_z);
405 sc = m_tuple->addItem(
"inter_z", inter_z);
407 sc = m_tuple->addItem(
"chisq_1", chisq_1);
408 sc = m_tuple->addItem(
"chisq_2", chisq_2);
409 sc = m_tuple->addItem(
"chisq_3", chisq_3);
410 sc = m_tuple->addItem(
"pos_x", pos_x);
411 sc = m_tuple->addItem(
"pos_y", pos_y);
412 sc = m_tuple->addItem(
"pos_z", pos_z);
414 sc = m_tuple->addItem(
"hit_x", hit_x);
415 sc = m_tuple->addItem(
"hit_y", hit_y);
416 sc = m_tuple->addItem(
"hit_z", hit_z);
418 sc = m_tuple->addItem(
"ang_1", ang_1);
419 sc = m_tuple->addItem(
"x_2_up_ang", ang_1_x);
420 sc = m_tuple->addItem(
"v_2_up_ang", ang_1_v);
422 sc = m_tuple->addItem(
"ang_2", ang_2);
423 sc = m_tuple->addItem(
"x_1_up_ang", ang_2_x);
424 sc = m_tuple->addItem(
"v_1_up_ang", ang_2_v);
426 sc = m_tuple->addItem(
"ang_3", ang_3);
427 sc = m_tuple->addItem(
"x_0_up_ang", ang_3_x);
428 sc = m_tuple->addItem(
"v_0_up_ang", ang_3_v);
430 sc = m_tuple->addItem(
"ang_4", ang_4);
431 sc = m_tuple->addItem(
"x_0_down_ang", ang_4_x);
432 sc = m_tuple->addItem(
"v_0_down_ang", ang_4_v);
434 sc = m_tuple->addItem(
"ang_5", ang_5);
435 sc = m_tuple->addItem(
"x_1_down_ang", ang_5_x);
436 sc = m_tuple->addItem(
"v_1_down_ang", ang_5_v);
438 sc = m_tuple->addItem(
"ang_6", ang_6);
439 sc = m_tuple->addItem(
"x_2_down_ang", ang_6_x);
440 sc = m_tuple->addItem(
"v_2_down_ang", ang_6_v);
442 sc = m_tuple->addItem(
"Angle", Angle);
443 sc = m_tuple->addItem(
"ang_x", ang_x);
444 sc = m_tuple->addItem(
"ang_v", ang_v);
446 sc = m_tuple->addItem(
"Rec_phi", Rec_phi);
447 sc = m_tuple->addItem(
"Rec_V", Rec_V);
448 sc = m_tuple->addItem(
"Rec_Z", Rec_Z);
449 sc = m_tuple->addItem(
"Test_phi", Test_phi);
450 sc = m_tuple->addItem(
"Test_V", Test_V);
451 sc = m_tuple->addItem(
"Test_Z", Test_Z);
453 log << MSG::ERROR <<
"Cannot book N-tuple:" << long(m_tuple) << endmsg;
454 return StatusCode::FAILURE;
461 m_tuple_track =
ntupleSvc()->book(
"LineFit/Track", CLID_ColumnWiseTuple,
"N-Tuple example");
463 sc = m_tuple_track->addItem(
"run", tr_run);
464 sc = m_tuple_track->addItem(
"event", tr_event);
465 sc = m_tuple_track->addItem(
"drho", tr_drho);
466 sc = m_tuple_track->addItem(
"phi0", tr_phi0);
467 sc = m_tuple_track->addItem(
"dz0", tr_dz0);
468 sc = m_tuple_track->addItem(
"chisq", tr_chisq);
469 sc = m_tuple_track->addItem(
"Is_fitted", tr_Is_fitted);
470 sc = m_tuple_track->addItem(
"tanLam", tr_tanLam);
471 sc = m_tuple_track->addItem(
"ncluster", tr_ncluster, 0, 5000);
472 sc = m_tuple_track->addIndexedItem(
"id_cluster", tr_ncluster, tr_id_cluster);
473 sc = m_tuple_track->addIndexedItem(
"x_cluster", tr_ncluster, tr_x_cluster);
474 sc = m_tuple_track->addIndexedItem(
"y_cluster", tr_ncluster, tr_y_cluster);
475 sc = m_tuple_track->addIndexedItem(
"z_cluster", tr_ncluster, tr_z_cluster);
476 sc = m_tuple_track->addIndexedItem(
"Q_cluster", tr_ncluster, tr_Q_cluster);
477 sc = m_tuple_track->addIndexedItem(
"phi_cluster", tr_ncluster, tr_phi_cluster);
478 sc = m_tuple_track->addIndexedItem(
"layer_cluster", tr_ncluster, tr_layer_cluster);
479 sc = m_tuple_track->addIndexedItem(
"sheet_cluster", tr_ncluster, tr_sheet_cluster);
480 sc = m_tuple_track->addIndexedItem(
"Is_selected_cluster", tr_ncluster, tr_Is_selected_cluster);
483 log << MSG::ERROR <<
"Cannot book N-tuple:" << long(m_tuple_track) << endmsg;
484 return StatusCode::FAILURE;
489 sc = service(
"RawDataProviderSvc", irawDataProviderSvc);
491 if (sc.isFailure()) {
492 log << MSG::FATAL << name() <<
" Could not load RawDataProviderSvc!" << endreq;
493 return StatusCode::FAILURE;
497 sc = service(
"CgemGeomSvc", icgemGeomSvc);
498 m_cgemGeomSvc =
dynamic_cast<CgemGeomSvc *
>(icgemGeomSvc);
500 if (sc.isFailure()) {
501 log << MSG::FATAL <<
"Could not load CgemGeomSvc!" << endreq;
502 return StatusCode::FAILURE;
505 for (
int i = 0; i < myNCgemLayers; i++) {
531 cout <<
"CgemLineFit alignment: is it on? " << Align_Flag << endl;
533 for (
int ilay = 0; ilay < 6; ilay++) {
534 cout <<
"LAYER " << ilay + 1 << endl;
535 cout <<
"shift dx " <<
Al->
getDx(ilay) <<
" dy " <<
Al->
getDy(ilay) <<
" dz " <<
Al->
getDz(ilay) << endl;
536 cout <<
"rotation Rx " <<
Al->
getRx(ilay) <<
" Ry " <<
Al->
getRy(ilay) <<
" Rz " <<
Al->
getRz(ilay) << endl;
537 cout <<
"midplane radius " <<
Mp->
getR(
int(ilay / 2)) << endl;
542 sc = service(
"CgemCalibFunSvc", icgemCalibSvc);
544 if (sc.isFailure()) {
545 log << MSG::FATAL <<
"Could not load CgemCalibFunSvc!" << endreq;
546 return StatusCode::FAILURE;
548 sc = service(
"CgemCalibFunSvc", myCgemCalibSvc);
549 if (sc.isFailure()) {
550 cout << name() <<
"Could not load MdcCalibFunSvc!" << endl;
557 return StatusCode::SUCCESS;
562 MsgStream log(
msgSvc(), name());
563 log << MSG::INFO <<
"in execute()" << endreq;
564 if (
debug) cout <<
"CgemLineFit::execute START" << endl;
566 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
568 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
569 return StatusCode::FAILURE;
572 SmartDataPtr<RecCgemClusterCol> recCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
573 if (!recCgemClusterCol) {
574 log << MSG::WARNING <<
"Could not retrieve Cgem cluster list" << endreq;
575 return StatusCode::FAILURE;
577 SmartDataPtr<CgemDigiCol> cgemDigiCol(eventSvc(),
"/Event/Digi/CgemDigiCol");
579 log << MSG::WARNING <<
"Could not retrieve Cgem digi list" << endreq;
580 return StatusCode::FAILURE;
583 if (
debug) cout <<
"CgemLineFit::execute - read the collection" << endl;
585 m_event = eventHeader->eventNumber();
586 m_run = eventHeader->runNumber();
591 if ((m_event % 500) == 0) cout <<
" begin evt : " <<
event << endl;
614 SmartRefVector<RecCgemCluster>().swap(vecclusters);
627 if (
debug) cout <<
"CgemLineFit::execute - cleaned the variables" << endl;
631 if (
debug) cout <<
"start Straight line fit" << endl;
636 m_tuple_track->write();
637 if (
debug) cout <<
"CgemLineFit::execute - method 0 failed" << endl;
638 return StatusCode::SUCCESS;
640 }
else if (Method == 1) {
644 m_tuple_track->write();
645 if (
debug) cout <<
"CgemLineFit::execute - method 1 failed" << endl;
646 return StatusCode::SUCCESS;
648 }
else if (Method == 2) {
652 m_tuple_track->write();
653 if (
debug) cout <<
"CgemLineFit::execute - method 2 failed" << endl;
654 return StatusCode::SUCCESS;
656 }
else if (Method == 3) {
660 m_tuple_track->write();
661 if (
debug) cout <<
"CgemLineFit::execute - method 3 failed" << endl;
662 return StatusCode::SUCCESS;
664 }
else if (Method == 4) {
668 m_tuple_track->write();
671 if (
debug) cout <<
"CgemLineFit::execute - method 4 failed" << endl;
672 return StatusCode::SUCCESS;
678 if (
Vec_layerid.size() < 4 && Run10_Flag)
return StatusCode::SUCCESS;
683 if (
debug) cout <<
"CgemLineFit::execute - set initial parameter" << endl;
686 double trkpar[4] = {-999, -999, -999, -999};
687 double trkparErr[4] = {-999, -999, -999, -999};
688 Int_t ierflg, npari, nparx, istat3;
689 Double_t fmin, edm, errdef;
690 fit->mnstat(fmin, edm, errdef, npari, nparx, istat3);
691 for (
int i = 0; i < 4; i++) { fit->GetParameter(i, trkpar[i], trkparErr[i]); }
693 fit->mnemat(emat, 4);
694 chisq_3 = fit->fAmin;
698 double chisq_last = chisq_3;
701 vector<double> _trkpar =
Trans(trkpar[0], trkpar[1], trkpar[2], trkpar[3]);
707 Err_par0 = trkparErr[0];
708 Err_par1 = trkparErr[1];
709 Err_par2 = trkparErr[2];
710 Err_par3 = trkparErr[3];
728 if (
debug) cout <<
"Get_otherIniPar" << endl;
735 if (
debug) cout <<
"Rec_Clusters" << endl;
745 if (
debug) cout <<
"Fit_Clusters" << endl;
749 if (
debug) cout <<
"GetIntersection" << endl;
751 StraightLine interline(trkpar[0], trkpar[1], trkpar[2], trkpar[3]);
754 if (
debug) cout <<
"GetRes" << endl;
756 StraightLine l_fit(trkpar[0], trkpar[1], trkpar[2], trkpar[3]);
763 tr_tanLam = trkpar[3];
765 tr_chisq = chisq_last;
766 m_tuple_track->write();
769 if (
debug) cout <<
"CgemLineFit::execute END" << endl;
782 return StatusCode::SUCCESS;
786 MsgStream log(
msgSvc(), name());
787 log << MSG::INFO <<
"in finalize()" << endreq;
788 return StatusCode::SUCCESS;
797 double cl_00(0), cl_01(0), cl_11(0), cl_10(0);
800 SmartDataPtr<RecCgemClusterCol> recCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
801 RecCgemClusterCol::iterator
iter = recCgemClusterCol->begin();
802 for (;
iter != recCgemClusterCol->end();
iter++) {
806 if (flag != 2)
continue;
812 double _v = cluster->
getrecv();
815 int vir_layerid =
GetVirLay(layerid, _phi);
816 if (layerid == 2 || ((!Run10_Flag) && layerid == 0 && _phi > acos(-1)))
continue;
830 vecclusters.push_back(cluster);
832 int NC = vecclusters.size();
833 if (
debug) cout <<
"NC is " <<
NC << endl;
835 if (
Vec_layer.size() < 3) {
return false; }
837 for (
int i_cl = 0; i_cl <
Vec_layerid.size(); i_cl++) {
858 if (
debug) cout <<
"CgemLineFit::DataMax - START" << endl;
860 double cl_00(0), cl_01(0), cl_11(0), cl_10(0), cl_20(0), cl_21(0);
862 double maxQ_11(0), maxQ_10(0), maxQ_00(0), maxQ_01(0), maxQ_21(0), maxQ_20(0);
863 int max_11(-1), max_10(-1), max_00(-1), max_01(-1), max_21(-1), max_20(-1);
864 double maxv_00(0), maxv_01(0);
866 double phi_11(-1), phi_10(-1), phi_00(-1), phi_01(-1), phi_21(-1), phi_20(-1);
867 double z_11(0), z_10(0), z_00(0), z_01(0), z_21(0), z_20(0);
868 double cid_11(-1), cid_10(-1), cid_00(-1), cid_01(-1), cid_21(-1), cid_20(-1);
869 double Xid_11(-1), Xid_10(-1), Xid_00(-1), Xid_01(-1), Xid_21(-1), Xid_20(-1);
870 double Vid_11(-1), Vid_10(-1), Vid_00(-1), Vid_01(-1), Vid_21(-1), Vid_20(-1);
872 SmartDataPtr<RecCgemClusterCol> recCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
873 RecCgemClusterCol::iterator
iter = recCgemClusterCol->begin();
877 if (
debug) cout <<
"CgemLineFit::DataMax - First loop on cluster" << endl;
878 for (;
iter != recCgemClusterCol->end();
iter++) {
880 if (
debug) cout << _loop << endl;
886 double _v = cluster->
getrecv();
895 if (
debug) cout <<
" flag: " << flag << endl;
897 cout <<
"CgemLineFit::DataMax - cluster info - ID: " << clusterid <<
" layer: " << layerid <<
" sheet: " << sheetid
898 <<
" Xid: " << clusterflagb <<
" Vid: " << clusterflage <<
" Phi: " << _phi <<
" Z: " << z <<
" X: " <<
x
899 <<
" Y: " << y <<
" Q: " << _Q << endl;
901 if (_loop > MAX_Clusters)
break;
902 if (flag != 2)
continue;
905 tr_id_cluster[ic] = clusterid;
906 tr_x_cluster[ic] =
x;
907 tr_y_cluster[ic] = y;
908 tr_z_cluster[ic] = z;
909 tr_Q_cluster[ic] = _Q;
917 if (layerid == 2 && sheetid == 1 && maxQ_21 < _Q) {
923 Xid_21 = clusterflagb;
924 Vid_21 = clusterflage;
926 if (layerid == 2 && sheetid == 0 && maxQ_20 < _Q) {
932 Xid_20 = clusterflagb;
933 Vid_20 = clusterflage;
935 if (layerid == 1 && sheetid == 1 && maxQ_11 < _Q) {
941 Xid_11 = clusterflagb;
942 Vid_11 = clusterflage;
944 if (layerid == 1 && sheetid == 0 && maxQ_10 < _Q) {
950 Xid_10 = clusterflagb;
951 Vid_10 = clusterflage;
953 if (layerid == 0 && sheetid == 0 && _phi > 0 && maxQ_01 < _Q && maxv_00 != _v) {
959 Xid_01 = clusterflagb;
960 Vid_01 = clusterflage;
962 if (layerid == 0 && sheetid == 0 && _phi < 0 && maxQ_00 < _Q && maxv_00 != _v) {
968 Xid_00 = clusterflagb;
969 Vid_00 = clusterflage;
972 if (layerid == 2 && sheetid == 1) cl_21++;
973 if (layerid == 2 && sheetid == 0) cl_20++;
974 if (layerid == 1 && sheetid == 1) cl_11++;
975 if (layerid == 1 && sheetid == 0) cl_10++;
976 if (layerid == 0 && sheetid == 0 && _phi > 0) cl_01++;
977 if (layerid == 0 && sheetid == 0 && _phi < 0) cl_00++;
980 if (
debug) cout <<
"CgemLineFit::DataMax - First loop on cluster ended - number of cluster: " << ic << endl;
983 for (
int i = 0; i < ic; i++) {
984 tr_Is_selected_cluster[i] = 0;
985 if (i == (max_00 - 1) && maxQ_00 > 0) tr_Is_selected_cluster[i] = 1;
986 if (i == (max_01 - 1) && maxQ_01 > 0) tr_Is_selected_cluster[i] = 1;
987 if (i == (max_10 - 1) && maxQ_10 > 0) tr_Is_selected_cluster[i] = 1;
988 if (i == (max_11 - 1) && maxQ_11 > 0) tr_Is_selected_cluster[i] = 1;
989 if (i == (max_20 - 1) && maxQ_20 > 0) tr_Is_selected_cluster[i] = 1;
990 if (i == (max_21 - 1) && maxQ_21 > 0) tr_Is_selected_cluster[i] = 1;
1002 cout <<
"CgemLineFit::DataMax - number of cluster per sheet/layer: " << clst_00 <<
" " << clst_10 <<
" " << clst_01 <<
" "
1003 << clst_11 <<
" " << clst_20 <<
" " << clst_21 << endl;
1005 iter = recCgemClusterCol->begin();
1006 for (;
iter != recCgemClusterCol->end();
iter++) {
1009 int flag = cluster->
getflag();
1010 if (flag != 2)
continue;
1015 double _v = cluster->
getrecv();
1021 int vir_layerid =
GetVirLay(layerid, _phi);
1023 RecCgemClusterCol::iterator iter_begin = recCgemClusterCol->begin();
1032 RecCgemClusterCol::iterator id_XCluster = recCgemClusterCol->begin() + clusterflagb;
1036 RecCgemClusterCol::iterator id_VCluster = recCgemClusterCol->begin() + clusterflage;
1044 int layerid_str, sheetid_str, stripid_str, time_chnnel;
1047 double energydeposit;
1048 double Q_fC, T_ns, Tf_ns;
1049 SmartDataPtr<CgemDigiCol> cgemDigiCol(eventSvc(),
"/Event/Digi/CgemDigiCol");
1050 CgemDigiCol::iterator iter_digi = cgemDigiCol->begin();
1059 for (; iter_digi != cgemDigiCol->end(); iter_digi++) {
1065 if (striptype ==
true) flagxv = 0;
1067 if (layerid == layerid_str && sheetid == sheetid_str) {
1068 Q_fC = (*iter_digi)->getCharge_fc();
1069 T_ns = (*iter_digi)->getTime_ns();
1070 Tf_ns = get_Time(iter_digi);
1072 if (stripid_str >= xclusterb && stripid_str <= xclustere) {
1073 if (xclustersize < 100) {
1083 if (stripid_str >= vclusterb && stripid_str <= vclustere) {
1084 if (vclustersize < 100) {
1097 if (
debug) cout <<
"cl ID: " << _loop << endl;
1098 if (!(_loop == max_00 || _loop == max_10 || _loop == max_01 || _loop == max_11 || _loop == max_20 || _loop == max_21))
1100 if (
debug) cout <<
"is selected" << endl;
1127 Vec_v.push_back(_v);
1132 Vec_v.push_back(t_v);
1133 Vec_Z.push_back(t_Z);
1138 double merged_Z = A_readoutPlane->
getZFromPhiV(merged_phi, merged_v);
1139 Vec_phi.push_back(merged_phi);
1140 Vec_v.push_back(merged_v);
1141 Vec_Z.push_back(merged_Z);
1144 Vec_Q.push_back(_Q);
1146 vecclusters.push_back(cluster);
1148 NC = vecclusters.size();
1150 if (
debug) cout <<
"CgemLineFit::DataMax - Number of points: " <<
Vec_layer.size() << endl;
1157 for (
int i_cl = 0; i_cl <
Vec_layerid.size(); i_cl++) {
1168 if (
debug) cout <<
"CgemLineFit::DataMax - Vec_layerid.size(): " <<
Vec_layerid.size() << endl;
1181 double cl_00(0), cl_01(0), cl_11(0), cl_10(0);
1183 double maxQ_11(0), maxQ_10(0), maxQ_00(0);
1184 int max_11(-1), max_10(-1), max_00(-1);
1185 SmartDataPtr<RecCgemClusterCol> recCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
1186 RecCgemClusterCol::iterator
iter = recCgemClusterCol->begin();
1188 for (;
iter != recCgemClusterCol->end();
iter++) {
1191 int flag = cluster->
getflag();
1196 if (flag != 2)
continue;
1197 if (layerid == 1 && sheetid == 1 && maxQ_11 < _Q) {
1201 if (layerid == 1 && sheetid == 0 && maxQ_10 < _Q) {
1205 if (layerid == 1 && sheetid == 1) cl_11++;
1206 if (layerid == 0 && sheetid == 0 && _phi > 0) cl_01++;
1207 if (layerid == 0 && sheetid == 0 && _phi < 0) cl_00++;
1208 if (layerid == 1 && sheetid == 0) cl_10++;
1215 iter = recCgemClusterCol->begin();
1216 for (;
iter != recCgemClusterCol->end();
iter++) {
1219 int flag = cluster->
getflag();
1220 if (flag != 2)
continue;
1225 double _v = cluster->
getrecv();
1231 int vir_layerid =
GetVirLay(layerid, _phi);
1233 RecCgemClusterCol::iterator iter_begin = recCgemClusterCol->begin();
1239 if (_loop != max_11 && _loop != max_10 && layerid != 0)
continue;
1252 Vec_v.push_back(_v);
1256 Vec_v.push_back(t_v);
1257 Vec_Z.push_back(t_Z);
1261 double merged_Z = A_readoutPlane->
getZFromPhiV(merged_phi, merged_v);
1262 Vec_phi.push_back(merged_phi);
1263 Vec_v.push_back(merged_v);
1264 Vec_Z.push_back(merged_Z);
1267 Vec_Q.push_back(_Q);
1269 vecclusters.push_back(cluster);
1271 NC = vecclusters.size();
1273 if (
Vec_layer.size() < 3) {
return false; }
1274 for (
int i_cl = 0; i_cl <
Vec_layerid.size(); i_cl++) {
1296 double cl_00(0), cl_01(0), cl_11(0), cl_10(0);
1298 double maxQ_11(0), maxQ_10(0), maxQ_00(0);
1299 int max_11(-1), max_10(-1), max_00(-1);
1300 double C_00(0), C_10(0), C_11(0), C_01(0);
1301 vector<double> Vec_00_layer, Vec_00_phi, Vec_00_Z, Vec_00_layerid, Vec_00_v, Vec_00_flag, Vec_00_Q, Vec_00_sheetid;
1302 vector<double> Vec_01_layer, Vec_01_phi, Vec_01_Z, Vec_01_layerid, Vec_01_v, Vec_01_flag, Vec_01_Q, Vec_01_sheetid;
1303 vector<double> Vec_10_layer, Vec_10_phi, Vec_10_Z, Vec_10_layerid, Vec_10_v, Vec_10_flag, Vec_10_Q, Vec_10_sheetid;
1304 vector<double> Vec_11_layer, Vec_11_phi, Vec_11_Z, Vec_11_layerid, Vec_11_v, Vec_11_flag, Vec_11_Q, Vec_11_sheetid;
1306 SmartDataPtr<RecCgemClusterCol> recCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
1307 RecCgemClusterCol::iterator
iter = recCgemClusterCol->begin();
1308 vector<int> L_00, L_01, L_10, L_11;
1310 for (;
iter != recCgemClusterCol->end();
iter++) {
1314 int flag = cluster->
getflag();
1318 double _v = cluster->
getrecv();
1325 double z = cluster->
getRecZ();
1326 if (_loop > MAX_Clusters)
break;
1328 if (flag != 0)
continue;
1330 if (layerid == 1 && sheetid == 1 &&
TEST_N != 1) { L_11.push_back(_loop); }
1331 if (layerid == 1 && sheetid == 0 &&
TEST_N != 4) { L_10.push_back(_loop); }
1332 if (layerid == 0 && sheetid == 0 && _phi > 0 &&
TEST_N != 2) { L_01.push_back(_loop); }
1333 if (layerid == 0 && sheetid == 0 && _phi < 0 &&
TEST_N != 3) { L_00.push_back(_loop); }
1336 if (
TEST_N == 1) L_11.push_back(-1);
1337 if (
TEST_N == 2) L_01.push_back(-1);
1338 if (
TEST_N == 3) L_00.push_back(-1);
1339 if (
TEST_N == 4) L_10.push_back(-1);
1341 double Min_chi(1E10);
1343 if ((L_00.size() * L_01.size() * L_10.size() * L_11.size()) >
MAX_COMB) {
return false; }
1345 NXComb = L_00.size() * L_01.size() * L_10.size() * L_11.size();
1347 for (
int i_11 = 0; i_11 < L_11.size(); i_11++) {
1348 for (
int i_10 = 0; i_10 < L_10.size(); i_10++) {
1349 for (
int i_00 = 0; i_00 < L_00.size(); i_00++) {
1350 for (
int i_01 = 0; i_01 < L_01.size(); i_01++) {
1370 iter = recCgemClusterCol->begin();
1371 for (;
iter != recCgemClusterCol->end();
iter++) {
1374 int flag = cluster->
getflag();
1375 if (!(_loop == L_11[i_11] || _loop == L_10[i_10] || _loop == L_00[i_00] || _loop == L_01[i_01]))
continue;
1379 double _v = cluster->
getrecv();
1389 int vir_layerid =
GetVirLay(layerid, _phi);
1403 Vec_v.push_back(_v);
1408 Vec_v.push_back(t_v);
1409 Vec_Z.push_back(t_Z);
1414 double merged_Z = A_readoutPlane->
getZFromPhiV(merged_phi, merged_v);
1415 Vec_phi.push_back(merged_phi);
1416 Vec_v.push_back(merged_v);
1417 Vec_Z.push_back(merged_Z);
1432 TMinuit *_fit =
Fit(l_outer_tmp,
fa, 1);
1433 double _chi = _fit->fAmin;
1434 if (_chi < Min_chi) {
1449 iter = recCgemClusterCol->begin();
1456 for (;
iter != recCgemClusterCol->end();
iter++) {
1459 int flag = cluster->
getflag();
1460 if (flag != 2)
continue;
1469 RecCgemClusterCol::iterator iter_begin = recCgemClusterCol->begin();
1476 if (C_00 == _phi || C_01 == _phi || C_11 == _phi || C_10 == _phi) {
1477 if (layerid == 1 && sheetid == 1) { L_11.push_back(_loop); }
1478 if (layerid == 1 && sheetid == 0) { L_10.push_back(_loop); }
1479 if (layerid == 0 && sheetid == 0 && _phi > 0) { L_01.push_back(_loop); }
1480 if (layerid == 0 && sheetid == 0 && _phi < 0) { L_00.push_back(_loop); }
1485 if (
TEST_N == 1) L_11.push_back(-1);
1486 if (
TEST_N == 2) L_01.push_back(-1);
1487 if (
TEST_N == 3) L_00.push_back(-1);
1488 if (
TEST_N == 4) L_10.push_back(-1);
1490 clst_11 = L_11.size();
1491 clst_01 = L_01.size();
1492 clst_10 = L_10.size();
1493 clst_00 = L_00.size();
1494 if ((L_00.size() * L_01.size() * L_10.size() * L_11.size()) >
MAX_COMB) {
1495 cout <<
"xv size much " << endl;
1499 NVComb = L_00.size() * L_01.size() * L_10.size() * L_11.size();
1501 for (
int i_11 = 0; i_11 < L_11.size(); i_11++) {
1502 for (
int i_10 = 0; i_10 < L_10.size(); i_10++) {
1503 for (
int i_00 = 0; i_00 < L_00.size(); i_00++) {
1504 for (
int i_01 = 0; i_01 < L_01.size(); i_01++) {
1524 iter = recCgemClusterCol->begin();
1525 for (;
iter != recCgemClusterCol->end();
iter++) {
1528 int flag = cluster->
getflag();
1529 if (flag != 2)
continue;
1534 double _v = cluster->
getrecv();
1541 RecCgemClusterCol::iterator iter_begin = recCgemClusterCol->begin();
1547 int vir_layerid =
GetVirLay(layerid, _phi);
1549 if (!(_loop == L_11[i_11] || _loop == L_10[i_10] || _loop == L_00[i_00] || _loop == L_01[i_01]))
continue;
1563 Vec_v.push_back(_v);
1568 Vec_v.push_back(t_v);
1569 Vec_Z.push_back(t_Z);
1574 double merged_Z = A_readoutPlane->
getZFromPhiV(merged_phi, merged_v);
1575 Vec_phi.push_back(merged_phi);
1576 Vec_v.push_back(merged_v);
1577 Vec_Z.push_back(merged_Z);
1596 TMinuit *_fit =
Fit(l_outer_tmp,
fa, 2);
1597 double _chi = _fit->fAmin;
1598 if (_chi < Min_chi) {
1631 iter = recCgemClusterCol->begin();
1632 for (;
iter != recCgemClusterCol->end();
iter++) {
1635 int flag = cluster->
getflag();
1639 double _v = cluster->
getrecv();
1650 double z = cluster->
getRecZ();
1651 int vir_layerid =
GetVirLay(layerid, _phi);
1653 if (_loop > MAX_Clusters)
break;
1654 if (flag != 2)
continue;
1656 RecCgemClusterCol::iterator iter_begin = recCgemClusterCol->begin();
1662 tr_id_cluster[ic] = clusterid;
1663 tr_x_cluster[ic] =
x;
1664 tr_y_cluster[ic] = y;
1665 tr_z_cluster[ic] = z;
1666 tr_Q_cluster[ic] = _Q;
1670 tr_Is_selected_cluster[ic] = 0;
1672 if (!(_loop == C_00 || _loop == C_10 || _loop == C_01 || _loop == C_11))
continue;
1674 tr_Is_selected_cluster[ic - 1] = 1;
1688 Vec_v.push_back(_v);
1693 Vec_v.push_back(t_v);
1694 Vec_Z.push_back(t_Z);
1699 double merged_Z = A_readoutPlane->
getZFromPhiV(merged_phi, merged_v);
1700 Vec_phi.push_back(merged_phi);
1701 Vec_v.push_back(merged_v);
1702 Vec_Z.push_back(merged_Z);
1706 vecclusters.push_back(cluster);
1709 NC = vecclusters.size();
1712 for (
int i_cl = 0; i_cl <
Vec_layerid.size(); i_cl++) {
1727 if (Min_chi < Chisq_cut)
return true;
1737 double cl_00(0), cl_01(0), cl_11(0), cl_10(0), cl_20(0), cl_21(0);
1739 double maxQ_21(0), maxQ_20(0), maxQ_11(0), maxQ_10(0), maxQ_00(0);
1740 int max_21(-1), max_20(-1), max_11(-1), max_10(-1), max_00(-1);
1741 double C_00(0), C_10(0), C_11(0), C_01(0), C_20(0), C_21(0);
1742 int iC_00(0), iC_10(0), iC_11(0), iC_01(0), iC_20(0), iC_21(0);
1744 vector<double> Vec_00_layer, Vec_00_phi, Vec_00_Z, Vec_00_layerid, Vec_00_v, Vec_00_flag, Vec_00_Q, Vec_00_sheetid;
1745 vector<double> Vec_01_layer, Vec_01_phi, Vec_01_Z, Vec_01_layerid, Vec_01_v, Vec_01_flag, Vec_01_Q, Vec_01_sheetid;
1746 vector<double> Vec_10_layer, Vec_10_phi, Vec_10_Z, Vec_10_layerid, Vec_10_v, Vec_10_flag, Vec_10_Q, Vec_10_sheetid;
1747 vector<double> Vec_11_layer, Vec_11_phi, Vec_11_Z, Vec_11_layerid, Vec_11_v, Vec_11_flag, Vec_11_Q, Vec_11_sheetid;
1748 vector<double> Vec_20_layer, Vec_20_phi, Vec_20_Z, Vec_20_layerid, Vec_20_v, Vec_20_flag, Vec_20_Q, Vec_20_sheetid;
1749 vector<double> Vec_21_layer, Vec_21_phi, Vec_21_Z, Vec_21_layerid, Vec_21_v, Vec_21_flag, Vec_21_Q, Vec_21_sheetid;
1751 SmartDataPtr<RecCgemClusterCol> recCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
1752 RecCgemClusterCol::iterator
iter = recCgemClusterCol->begin();
1753 vector<int> L_00, L_01, L_10, L_11, L_20, L_21;
1754 vector<double> Q_00, Q_01, Q_10, Q_11, Q_20, Q_21;
1755 vector<int> ZL_00, ZL_01, ZL_10, ZL_11, ZL_20, ZL_21;
1756 set<int> ZL_00_s, ZL_01_s, ZL_10_s, ZL_11_s, ZL_20_s, ZL_21_s;
1759 if (
debug) cout <<
"start Loop_MaxQ method" << endl;
1761 for (;
iter != recCgemClusterCol->end();
iter++) {
1765 int flag = cluster->
getflag();
1766 if (flag != 2)
continue;
1770 double _v = cluster->
getrecv();
1777 double z = cluster->
getRecZ();
1791 if (
debug) cout <<
"layerid is " << layerid << endl;
1792 if (_loop > MAX_Clusters)
break;
1794 if (layerid == 2 && sheetid == 1) {
1795 ZL_21_s.insert(clusterflagb);
1798 if (layerid == 2 && sheetid == 0) {
1799 ZL_20_s.insert(clusterflagb);
1802 if (layerid == 1 && sheetid == 1) {
1803 ZL_11_s.insert(clusterflagb);
1806 if (layerid == 1 && sheetid == 0) {
1807 ZL_10_s.insert(clusterflagb);
1810 if (layerid == 0 && sheetid == 0 && _phi > 0) {
1811 ZL_01_s.insert(clusterflagb);
1814 if (layerid == 0 && sheetid == 0 && _phi < 0) {
1815 ZL_00_s.insert(clusterflagb);
1819 ZL_21.assign(ZL_21_s.begin(), ZL_21_s.end());
1820 ZL_20.assign(ZL_20_s.begin(), ZL_20_s.end());
1821 ZL_11.assign(ZL_11_s.begin(), ZL_11_s.end());
1822 ZL_10.assign(ZL_10_s.begin(), ZL_10_s.end());
1823 ZL_01.assign(ZL_01_s.begin(), ZL_01_s.end());
1824 ZL_00.assign(ZL_00_s.begin(), ZL_00_s.end());
1839 iter = recCgemClusterCol->begin();
1841 for (;
iter != recCgemClusterCol->end();
iter++) {
1844 int flag = cluster->
getflag();
1849 double _v = cluster->
getrecv();
1854 if (flag != 0)
continue;
1855 if (layerid == 2 && sheetid == 1) {
1856 for (
int i_21 = 0; i_21 < ZL_21.size(); i_21++) {
1857 if (clusterid == ZL_21[i_21]) {
1858 L_21.push_back(_loop);
1863 if (layerid == 2 && sheetid == 0) {
1864 for (
int i_20 = 0; i_20 < ZL_20.size(); i_20++) {
1865 if (clusterid == ZL_20[i_20]) {
1866 L_20.push_back(_loop);
1871 if (layerid == 1 && sheetid == 1) {
1872 for (
int i_11 = 0; i_11 < ZL_11.size(); i_11++) {
1873 if (clusterid == ZL_11[i_11]) {
1874 L_11.push_back(_loop);
1879 if (layerid == 1 && sheetid == 0) {
1880 for (
int i_10 = 0; i_10 < ZL_10.size(); i_10++) {
1881 if (clusterid == ZL_10[i_10]) {
1882 L_10.push_back(_loop);
1887 if (layerid == 0 && sheetid == 0 && _phi > 0) {
1888 for (
int i_01 = 0; i_01 < ZL_01.size(); i_01++) {
1889 if (clusterid == ZL_01[i_01]) {
1890 L_01.push_back(_loop);
1895 if (layerid == 0 && sheetid == 0 && _phi < 0) {
1896 for (
int i_00 = 0; i_00 < ZL_00.size(); i_00++) {
1897 if (clusterid == ZL_00[i_00]) {
1898 L_00.push_back(_loop);
1906 vector<int> L_00_s, L_01_s, L_10_s, L_11_s, L_20_s, L_21_s;
1915 if (
debug) cout <<
"L_21_s.size() : " << L_21_s.size() << endl;
1920 L_21_s.push_back(-1);
1921 }
else if (
TEST_N == 2) {
1923 L_11_s.push_back(-1);
1924 }
else if (
TEST_N == 3) {
1926 L_01_s.push_back(-1);
1927 }
else if (
TEST_N == 4) {
1929 L_00_s.push_back(-1);
1930 }
else if (
TEST_N == 5) {
1932 L_10_s.push_back(-1);
1933 }
else if (
TEST_N == 6) {
1935 L_20_s.push_back(-1);
1938 if (
debug) cout <<
"finish the first loop" << endl;
1940 double Min_chi(1E10);
1941 NXComb = L_00_s.size() * L_01_s.size() * L_10_s.size() * L_11_s.size() * L_20_s.size() * L_21_s.size();
1943 int com0, com1, com2, com3, com4, com5;
1944 for (
int i_21 = 0; i_21 < L_21_s.size(); i_21++) {
1945 for (
int i_20 = 0; i_20 < L_20_s.size(); i_20++) {
1946 for (
int i_11 = 0; i_11 < L_11_s.size(); i_11++) {
1947 for (
int i_10 = 0; i_10 < L_10_s.size(); i_10++) {
1948 for (
int i_00 = 0; i_00 < L_00_s.size(); i_00++) {
1949 for (
int i_01 = 0; i_01 < L_01_s.size(); i_01++) {
1969 iter = recCgemClusterCol->begin();
1973 for (;
iter != recCgemClusterCol->end();
iter++) {
1976 int flag = cluster->
getflag();
1980 if (!(_loop == L_21_s[i_21] || _loop == L_20_s[i_20] || _loop == L_11_s[i_11] || _loop == L_10_s[i_10] ||
1981 _loop == L_00_s[i_00] || _loop == L_01_s[i_01]))
1990 double _v = cluster->
getrecv();
2002 int vir_layerid =
GetVirLay(layerid, _phi);
2009 Com.push_back(_loop);
2017 Vec_v.push_back(_v);
2019 if (
debug) cout <<
"1st phi, v, by merge: " << merged_phi <<
", " << merged_v << endl;
2020 if (
debug) cout <<
"1st phi, v, by CC: " << _phi <<
", " << _v << endl;
2023 Vec_v.push_back(t_v);
2024 Vec_Z.push_back(t_Z);
2028 double merged_Z = A_readoutPlane->
getZFromPhiV(merged_phi, merged_v);
2029 Vec_phi.push_back(merged_phi);
2030 Vec_v.push_back(merged_v);
2031 Vec_Z.push_back(merged_Z);
2032 if (
debug) cout <<
"1st phi, v, by merge: " << merged_phi <<
", " << merged_v << endl;
2033 if (
debug) cout <<
"1st phi, v, by CC: " << _phi <<
", " << _v << endl;
2039 if (
debug) cout <<
"before OrderCluster" << endl;
2050 if (
debug) cout <<
"before IniPar" << endl;
2058 if (
debug) cout <<
"before fit" << endl;
2059 TMinuit *_fit =
Fit(l_outer_tmp,
fa, 1);
2061 if (
debug) cout <<
"chisq is : " << _fit->fAmin << endl;
2062 if (
debug) cout <<
"===========================================" << endl;
2064 double _chi = _fit->fAmin;
2065 if (
debug) cout <<
"finish the fit and the chisq is " << _chi << endl;
2066 if (
debug) cout <<
"----------------------------------------" << endl;
2067 if (_chi < Min_chi) {
2093 if (
debug) cout <<
"finish the second loop" << endl;
2095 iter = recCgemClusterCol->begin();
2123 if (
debug) cout <<
"c00, c01, c11, c10 : " << C_00 <<
", " << C_01 <<
", " << C_11 <<
", " << C_10 << endl;
2124 if (
debug) cout <<
"ids is : " << com0 <<
", " << com1 <<
", " << com2 <<
", " << com3 <<
", " << com4 <<
", " << com5 << endl;
2125 for (;
iter != recCgemClusterCol->end();
iter++) {
2128 int flag = cluster->
getflag();
2129 if (flag != 2)
continue;
2140 RecCgemClusterCol::iterator iter_begin = recCgemClusterCol->begin();
2145 cout <<
"2D: phi_cc, phi_merge, index " << cluster->
getrecphi() <<
", " << cluster->
get_merge_phi() <<
", " << _loop
2158 if (fabs(C_00 - _phi) < 0.001 || fabs(C_01 - _phi) < 0.001 || fabs(C_11 - _phi) < 0.001 || fabs(C_10 - _phi) < 0.001 ||
2159 fabs(C_21 - _phi) < 0.001 || fabs(C_20 - _phi) < 0.001) {
2160 if (layerid == 2 && sheetid == 1) {
2161 L_21.push_back(_loop);
2164 if (layerid == 2 && sheetid == 0) {
2165 L_20.push_back(_loop);
2168 if (layerid == 1 && sheetid == 1) {
2169 L_11.push_back(_loop);
2172 if (layerid == 1 && sheetid == 0) {
2173 L_10.push_back(_loop);
2176 if (layerid == 0 && sheetid == 0 && _phi > 0) {
2177 L_01.push_back(_loop);
2180 if (layerid == 0 && sheetid == 0 && _phi < 0) {
2181 L_00.push_back(_loop);
2187 if (
debug) cout <<
"finish the third loop" << endl;
2191 clst_21 = L_21.size();
2192 clst_11 = L_11.size();
2193 clst_01 = L_01.size();
2194 clst_20 = L_20.size();
2195 clst_10 = L_10.size();
2196 clst_00 = L_00.size();
2199 cout <<
"clst_21, clst_11, clst_01, clst_20, clst_10, clst_00 : " << clst_21 <<
", " << clst_11 <<
", " << clst_01 <<
", "
2200 << clst_20 <<
", " << clst_10 <<
", " << clst_00 << endl;
2211 L_21_s.push_back(-1);
2212 }
else if (
TEST_N == 2) {
2214 L_11_s.push_back(-1);
2215 }
else if (
TEST_N == 3) {
2217 L_01_s.push_back(-1);
2218 }
else if (
TEST_N == 4) {
2220 L_00_s.push_back(-1);
2221 }
else if (
TEST_N == 5) {
2223 L_10_s.push_back(-1);
2224 }
else if (
TEST_N == 6) {
2226 L_20_s.push_back(-1);
2229 NVComb = L_00_s.size() * L_01_s.size() * L_10_s.size() * L_11_s.size() * L_20_s.size() * L_21_s.size();
2231 for (
int i_21 = 0; i_21 < L_21_s.size(); i_21++) {
2232 for (
int i_20 = 0; i_20 < L_20_s.size(); i_20++) {
2233 for (
int i_11 = 0; i_11 < L_11_s.size(); i_11++) {
2234 for (
int i_10 = 0; i_10 < L_10_s.size(); i_10++) {
2235 for (
int i_00 = 0; i_00 < L_00_s.size(); i_00++) {
2236 for (
int i_01 = 0; i_01 < L_01_s.size(); i_01++) {
2256 iter = recCgemClusterCol->begin();
2257 for (;
iter != recCgemClusterCol->end();
iter++) {
2260 int flag = cluster->
getflag();
2261 if (flag != 2)
continue;
2262 if (!(_loop == L_21_s[i_21] || _loop == L_20_s[i_20] || _loop == L_11_s[i_11] || _loop == L_10_s[i_10] ||
2263 _loop == L_00_s[i_00] || _loop == L_01_s[i_01]))
2269 double _v = cluster->
getrecv();
2276 RecCgemClusterCol::iterator iter_begin = recCgemClusterCol->begin();
2282 int vir_layerid =
GetVirLay(layerid, _phi);
2296 Vec_v.push_back(_v);
2300 Vec_v.push_back(t_v);
2301 Vec_Z.push_back(t_Z);
2305 double merged_Z = A_readoutPlane->
getZFromPhiV(merged_phi, merged_v);
2306 Vec_phi.push_back(merged_phi);
2307 Vec_v.push_back(merged_v);
2308 Vec_Z.push_back(merged_Z);
2329 TMinuit *_fit =
Fit(l_outer_tmp,
fa, 2);
2330 double _chi = _fit->fAmin;
2331 if (_chi < Min_chi) {
2333 iC_00 = L_00_s[i_00];
2334 iC_01 = L_01_s[i_01];
2335 iC_10 = L_10_s[i_10];
2336 iC_11 = L_11_s[i_11];
2337 iC_20 = L_20_s[i_20];
2338 iC_21 = L_21_s[i_21];
2378 if (
debug) cout <<
"finish the forth loop" << endl;
2381 iter = recCgemClusterCol->begin();
2382 for (;
iter != recCgemClusterCol->end();
iter++) {
2385 int flag = cluster->
getflag();
2389 double _v = cluster->
getrecv();
2401 double z = cluster->
getRecZ();
2402 int vir_layerid =
GetVirLay(layerid, _phi);
2403 if (_loop > MAX_Clusters)
break;
2404 if (flag != 2)
continue;
2406 RecCgemClusterCol::iterator iter_begin = recCgemClusterCol->begin();
2412 tr_id_cluster[ic] = clusterid;
2413 tr_x_cluster[ic] =
x;
2414 tr_y_cluster[ic] = y;
2415 tr_z_cluster[ic] = z;
2416 tr_Q_cluster[ic] = _Q;
2417 tr_phi_cluster[ic] = _phi;
2418 tr_layer_cluster[ic] = layerid;
2419 tr_sheet_cluster[ic] = sheetid;
2420 tr_Is_selected_cluster[ic] = 0;
2428 if (!(_loop == iC_00 || _loop == iC_10 || _loop == iC_20 || _loop == iC_01 || _loop == iC_11 || _loop == iC_21))
continue;
2429 tr_Is_selected_cluster[ic - 1] = 1;
2430 SmartDataPtr<CgemDigiCol> cgemDigiCol(eventSvc(),
"/Event/Digi/CgemDigiCol");
2433 RecCgemClusterCol::iterator id_XCluster = recCgemClusterCol->begin() + clusterflagb;
2437 RecCgemClusterCol::iterator id_VCluster = recCgemClusterCol->begin() + clusterflage;
2445 int layerid_str, sheetid_str, stripid_str, time_chnnel;
2448 double energydeposit;
2449 double Q_fC, T_ns, Tf_ns;
2450 CgemDigiCol::iterator iter_digi = cgemDigiCol->begin();
2459 for (; iter_digi != cgemDigiCol->end(); iter_digi++) {
2465 if (striptype ==
true) flagxv = 0;
2467 if (layerid == layerid_str && sheetid == sheetid_str) {
2468 Q_fC = (*iter_digi)->getCharge_fc();
2469 T_ns = (*iter_digi)->getTime_ns();
2470 Tf_ns = get_Time(iter_digi);
2472 if (stripid_str >= xclusterb && stripid_str <= xclustere) {
2475 if (xclustersize < 100) {
2485 if (stripid_str >= vclusterb && stripid_str <= vclustere) {
2486 if (vclustersize < 100) {
2522 Vec_v.push_back(_v);
2526 Vec_v.push_back(t_v);
2527 Vec_Z.push_back(t_Z);
2531 double merged_Z = A_readoutPlane->
getZFromPhiV(merged_phi, merged_v);
2532 Vec_phi.push_back(merged_phi);
2533 Vec_v.push_back(merged_v);
2534 Vec_Z.push_back(merged_Z);
2538 vecclusters.push_back(cluster);
2541 NC = vecclusters.size();
2543 if (
debug) cout <<
"finish the fifth loop" << endl;
2545 for (
int i_cl = 0; i_cl <
Vec_layerid.size(); i_cl++) {
2562 cout <<
"Event " <<
event <<
", Clu. ID are " << iC_00 <<
", " << iC_01 <<
", " << iC_10 <<
", " << iC_11 <<
", " << iC_20
2563 <<
", " << iC_21 <<
", Loop_MaxQ Min_chi = " << Min_chi << endl;
2566 if (Min_chi < Chisq_cut)
return true;
2575 MsgStream log(
msgSvc(), name());
2577 IDataProviderSvc *eventSvc = NULL;
2578 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
2580 log << MSG::INFO <<
"makeTds:event Svc has been found" << endreq;
2582 log << MSG::FATAL <<
"makeTds:Could not find eventSvc" << endreq;
2583 return StatusCode::FAILURE;
2586 IDataManagerSvc *dataManSvc =
dynamic_cast<IDataManagerSvc *
>(eventSvc);
2591 DataObject *aRecMdcTrackCol;
2592 eventSvc->findObject(
"/Event/Recon/RecMdcTrackCol", aRecMdcTrackCol);
2593 if (aRecMdcTrackCol != NULL) {
2594 dataManSvc->clearSubTree(
"/Event/Recon/RecMdcTrackCol");
2595 eventSvc->unregisterObject(
"/Event/Recon/RecMdcTrackCol");
2598 sc = eventSvc->registerObject(
"/Event/Recon/RecMdcTrackCol", recMdcTrackCol);
2599 if (sc.isFailure()) {
2600 log << MSG::FATAL <<
" Could not register RecMdcTrack collection" << endreq;
2601 return StatusCode::FAILURE;
2603 log << MSG::INFO <<
"RecMdcTrackCol registered successfully!" << endreq;
2606 DataObject *aRecMdcHitCol;
2607 eventSvc->findObject(
"/Event/Recon/RecMdcHitCol", aRecMdcHitCol);
2608 if (aRecMdcHitCol != NULL) {
2609 dataManSvc->clearSubTree(
"/Event/Recon/RecMdcHitCol");
2610 eventSvc->unregisterObject(
"/Event/Recon/RecMdcHitCol");
2613 sc = eventSvc->registerObject(
"/Event/Recon/RecMdcHitCol", recMdcHitCol);
2614 if (sc.isFailure()) {
2615 log << MSG::FATAL <<
" Could not register RecMdcHit collection" << endreq;
2616 return StatusCode::FAILURE;
2618 log << MSG::INFO <<
"RecMdcHitCol registered successfully!" << endreq;
2620 return StatusCode::SUCCESS;
2636 if (flagg == 2) flagg = 0;
2638 chisq += dx1 / _sigma2;
2657 if (flagg == 2) flagg = 1;
2662 chisq += dv1 / _sigma2;
2671 double dv1(0), dx1(0);
2685 chisq += (dv1 / _sigma2);
2688 chisq += dx1 / _sigma2;
2695double CgemLineFit::dx(
double vir_layerid,
double R,
double dr,
double phi0,
double dz,
double tanl,
double x) {
2696 if (dr > R)
return 9999999999999;
2698 double phiV_up[2], phiV_down[2];
2700 double phiV_up1_old[2], phiV_down1_old[2];
2702 bool findinter =
false;
2704 else findinter =
Mp->
getPointAligned(vir_layerid, l1, Up, Down, phiV_up, phiV_down);
2706 if (!findinter)
return 9999999999999;
2708 phiV_up[0] = fmod((phiV_up[0]), (2.0 * TMath::Pi()));
2709 phiV_down[0] = fmod((phiV_down[0]), (2.0 * TMath::Pi()));
2711 if (phiV_up[0] < 0) phiV_up[0] += 2.0 * TMath::Pi();
2712 if (phiV_down[0] < 0) phiV_down[0] += 2.0 * TMath::Pi();
2716 double mdv = min(pow(dx1, 2.0), pow(dx2, 2.0));
2720double CgemLineFit::dV(
int vir_layerid,
double R,
double dr,
double phi0,
double z0,
double tglam,
double x,
double V) {
2724 double phiV_up[2], phiV_down[2];
2725 bool findinter =
false;
2727 else findinter =
Mp->
getPointAligned(vir_layerid, l1, Up, Down, phiV_up, phiV_down);
2729 if (!findinter)
return 9999999999999;
2734 if (dx1 < dx2)
return pow(fabs(phiV_down[1] - V), 2.0);
2735 else return pow(fabs(phiV_up[1] - V), 2.0);
2743 double trkpar[4] = {-999, -999, -999, -999};
2744 double trkparErr[4] = {-999, -999, -999, -999};
2749 Int_t ierflg, npari, nparx, istat1, istat2, istat3;
2750 Double_t fmin, edm, errdef;
2751 Double_t arglist[10];
2753 arglist[0] = 2000000;
2754 arglist[1] = 0.0001;
2756 TMinuit *Min3 =
new TMinuit(4);
2758 Min3->SetPrintLevel(-1);
2760 Min3->mnparm(1,
"phi0",
l_outer->
phi0(), 0.01, -100 * acos(-1), 100 * acos(-1),
2762 Min3->mnparm(2,
"dz",
l_outer->
dz(), 0.1, -0.5 * length, 0.5 * length, ierflg);
2763 Min3->mnparm(3,
"tanL",
l_outer->
tanl(), 0.01, -9999, 9999, ierflg);
2764 Min3->mnexcm(
"MIGRAD", arglist, 2, ierflg);
2771 arglist[0] = 2000000;
2772 arglist[1] = 0.0001;
2774 TMinuit *Min =
new TMinuit(2);
2775 Min->SetPrintLevel(-1);
2777 Min->SetErrorDef(1.0);
2779 Min->mnparm(1,
"phi0",
l_outer->
phi0(), 0.001, -100 * acos(-1), 100 * acos(-1), ierflg);
2780 arglist[0] = 2000000;
2782 Min->mnexcm(
"MIGRAD", arglist, 2, ierflg);
2783 Min->mnstat(fmin, edm, errdef, npari, nparx, istat1);
2784 Min->GetParameter(0, trkpar[0], trkparErr[0]);
2786 Min->GetParameter(1, trkpar[1], trkparErr[1]);
2793 chisq_1 = Min->fAmin;
2795 if (typ == 1)
return Min;
2801 TMinuit *Min2 =
new TMinuit(2);
2803 Min2->SetPrintLevel(-1);
2804 Min2->mnparm(0,
"dz",
l_outer->
dz(), 0.001, -0.5 * length, 0.5 * length, ierflg);
2805 Min2->mnparm(1,
"tanL",
l_outer->
tanl(), 0.001, -9999, 9999, ierflg);
2806 Min2->mnexcm(
"MIGRAD", arglist, 2, ierflg);
2807 Min2->mnstat(fmin, edm, errdef, npari, nparx, istat2);
2808 for (
int i = 0; i < 2; i++) { Min2->GetParameter(i, trkpar[i + 2], trkparErr[i + 2]); }
2809 chisq_2 = Min2->fAmin;
2816 TMinuit *Min3 =
new TMinuit(4);
2818 Min3->SetPrintLevel(-1);
2819 Min3->mnparm(0,
"dr", trkpar[0], 0.001, -1 *
R_layer[2],
R_layer[2], ierflg);
2820 Min3->mnparm(1,
"phi0", trkpar[1], 0.001, -100 * acos(-1), 100 * acos(-1), ierflg);
2821 Min3->mnparm(2,
"dz", trkpar[2], 0.001, -0.5 * length, 0.5 * length, ierflg);
2822 Min3->mnparm(3,
"tanL", trkpar[3], 0.001, -9999, 9999, ierflg);
2823 Min3->mnexcm(
"MIGRAD", arglist, 2, ierflg);
2830 if (typ == 0)
return Min3;
2836 while (noswap !=
Vec_flag.size() - 1) {
2838 for (
int i = 0; i <
Vec_flag.size() - 1; i++) {
2882 while (noswap !=
Vec_flag.size() - 1) {
2884 for (
int i = 0; i <
Vec_flag.size() - 1; i++) {
2936 vector<double> _x, _v;
2939 for (
int i = 0; i < 3; i++) {
2941 _v.push_back(
Vec_v[i]);
2944 if (_x[0] == _x[1] && _v[0] == _v[2]) wrong = 0;
2945 else if (_x[0] == _x[1] && _v[1] == _v[2]) wrong = 1;
2946 else if (_x[0] == _x[2] && _v[0] == _v[1]) wrong = 0;
2947 else if (_x[0] == _x[2] && _v[2] == _v[1]) wrong = 2;
2948 else if (_x[1] == _x[2] && _v[1] == _v[0]) wrong = 1;
2949 else if (_x[1] == _x[2] && _v[2] == _v[0]) wrong = 2;
2950 else {
return false; }
2951 erase(_iter[wrong]);
2956 vector<double>::iterator _iter_v;
2957 _iter_v =
Vec_v.begin();
2958 Vec_v.erase(_iter_v + i);
2960 vector<double>::iterator _iter_phi;
2964 vector<double>::iterator _iter_Z;
2965 _iter_Z =
Vec_Z.begin();
2966 Vec_Z.erase(_iter_Z + i);
2968 vector<double>::iterator _iter_layer;
2972 vector<double>::iterator _iter_layerid;
2976 vector<double>::iterator _iter_Virlayerid;
2980 vector<double>::iterator _iter_flag;
2986 for (
int i = 0; i <
Vec_layer.size(); i++) {
2992 int Gi = int(i / 2);
2993 int Gj = int(j / 2);
3013 vector<double> dst_up;
3014 vector<double> dst_down;
3019 for (
int i = 0; i <
Vec_layer.size(); i++) {
3021 number.push_back(i);
3027 for (
int j = 0; j < number.size(); j++) {
int i = number[j]; }
3032 while (Loop != number.size() - 1) {
3034 for (
int j = 0; j < number.size() - 1; j++) {
3035 if (dst_up[j] > dst_up[j + 1]) {
3036 swap(dst_up[j], dst_up[j + 1]);
3037 swap(dst_down[j], dst_down[j + 1]);
3038 swap(number[j], number[j + 1]);
3044 for (
int j = 0; j < number.size(); j++) {
int i = number[j]; }
3047 number.erase(number.begin());
3048 dst_up.erase(dst_up.begin());
3049 dst_down.erase(dst_down.begin());
3052 for (
int j = 0; j < number.size(); j++) {
int i = number[j]; }
3056 while (Loop != number.size() - 1) {
3058 for (
int j = 0; j < number.size() - 1; j++) {
3059 if (dst_down[j] > dst_down[j + 1]) {
3060 swap(dst_down[j], dst_down[j + 1]);
3061 swap(number[j], number[j + 1]);
3066 for (
int j = 0; j < number.size(); j++) {
int i = number[j]; }
3068 number.erase(number.begin());
3072 for (
int i = 0; i <
Vec_layer.size(); i++) {
3074 number.push_back(i);
3081 while (Loop != number.size() - 1) {
3083 for (
int j = 0; j < number.size() - 1; j++) {
3084 if (dst[j] > dst[j + 1]) {
3085 swap(dst[j], dst[j + 1]);
3086 swap(number[j], number[j + 1]);
3091 number.erase(number.begin());
3095 for (
int j = 0; j < number.size(); j++) {
int i = number[j]; }
3097 sort(number.begin(), number.end(), less<int>());
3098 for (
int i = number.size() - 1; i != -1; i--)
3104 vector<double> Vec_truth;
3108 vector<double> _Vec_truth =
Trans(Vec_truth[0], Vec_truth[1], Vec_truth[2], Vec_truth[3]);
3110 MC_par0 = _Vec_truth[0];
3111 MC_par1 = _Vec_truth[1];
3112 MC_par2 = _Vec_truth[2];
3113 MC_par3 = _Vec_truth[3];
3114 MC_px = Vec_truth[4];
3115 MC_py = Vec_truth[5];
3116 MC_pz = Vec_truth[6];
3118 vector<double> V_MC_clusters =
Get_Clusters(Vec_truth);
3119 x_0_up_mc = V_MC_clusters[0];
3120 v_0_up_mc = V_MC_clusters[1];
3121 x_0_down_mc = V_MC_clusters[2];
3122 v_0_down_mc = V_MC_clusters[3];
3124 x_1_up_mc = V_MC_clusters[4];
3125 v_1_up_mc = V_MC_clusters[5];
3126 x_1_down_mc = V_MC_clusters[6];
3127 v_1_down_mc = V_MC_clusters[7];
3129 x_2_up_mc = V_MC_clusters[8];
3130 v_2_up_mc = V_MC_clusters[9];
3131 x_2_down_mc = V_MC_clusters[10];
3132 v_2_down_mc = V_MC_clusters[11];
3137 int nTruth[3] = {0, 0, 0};
3138 int trkID_Layer1[100], trkID_Layer2[100], trkID_Layer3[100];
3139 int pdg_Layer1[100], pdg_Layer2[100], pdg_Layer3[100];
3140 double x_pre_Layer1[100], x_pre_Layer2[100], x_pre_Layer3[100];
3141 double y_pre_Layer1[100], y_pre_Layer2[100], y_pre_Layer3[100];
3142 double z_pre_Layer1[100], z_pre_Layer2[100], z_pre_Layer3[100];
3143 double x_post_Layer1[100], x_post_Layer2[100], x_post_Layer3[100];
3144 double y_post_Layer1[100], y_post_Layer2[100], y_post_Layer3[100];
3145 double z_post_Layer1[100], z_post_Layer2[100], z_post_Layer3[100];
3146 double phi_Layer1[100], phi_Layer2[100], phi_Layer3[100];
3147 double z_Layer1[100], z_Layer2[100], z_Layer3[100];
3148 double V_Layer1[100], V_Layer2[100], V_Layer3[100];
3149 double px_pre_Layer1[100], px_pre_Layer2[100], px_pre_Layer3[100];
3150 double py_pre_Layer1[100], py_pre_Layer2[100], py_pre_Layer3[100];
3151 double pz_pre_Layer1[100], pz_pre_Layer2[100], pz_pre_Layer3[100];
3152 double en_Layer1[100], en_Layer2[100], en_Layer3[100];
3153 SmartDataPtr<Event::CgemMcHitCol> cgemMcHitCol(eventSvc(),
"/Event/MC/CgemMcHitCol");
3159 Event::CgemMcHitCol::iterator iter_truth = cgemMcHitCol->begin();
3160 for (; iter_truth != cgemMcHitCol->end(); iter_truth++) {
3161 int iLayer = (*iter_truth)->GetLayerID();
3162 int trkID = (*iter_truth)->GetTrackID();
3163 int pdg = (*iter_truth)->GetPDGCode();
3164 double x_pre = (*iter_truth)->GetPositionXOfPrePoint();
3165 double y_pre = (*iter_truth)->GetPositionYOfPrePoint();
3166 double z_pre = (*iter_truth)->GetPositionZOfPrePoint();
3167 double x_post = (*iter_truth)->GetPositionXOfPostPoint();
3168 double y_post = (*iter_truth)->GetPositionYOfPostPoint();
3169 double z_post = (*iter_truth)->GetPositionZOfPostPoint();
3170 double x_middle = 0.5 * (x_pre + x_post);
3171 double y_middle = 0.5 * (y_pre + y_post);
3172 double z_middle = 0.5 * (z_pre + z_post);
3173 double r_middle = sqrt(x_middle * x_middle + y_middle * y_middle);
3174 double phi_middle = atan2(y_middle, x_middle);
3175 double px_pre = (*iter_truth)->GetMomentumXOfPrePoint();
3176 double py_pre = (*iter_truth)->GetMomentumYOfPrePoint();
3177 double pz_pre = (*iter_truth)->GetMomentumZOfPrePoint();
3178 double en = (*iter_truth)->GetTotalEnergyDeposit();
3182 for (
int j = 0; j < myNSheets[iLayer]; j++) {
3186 if (readoutPlane->
OnThePlane(phi_middle, z_middle))
break;
3187 readoutPlane = NULL;
3189 double V_mid = 9999;
3190 if (readoutPlane == NULL) {
3191 cout <<
"CgemClusterCreate::fillMCTruth() readoutPlane not found with phi_middle = " << phi_middle <<
", layer = " << iLayer
3196 V_mid = readoutPlane->
getVFromPhiZ(phi_middle, z_middle);
3202 if (nTruth[0] >= 100)
break;
3203 trkID_Layer1[nTruth[0]] = trkID;
3204 pdg_Layer1[nTruth[0]] = pdg;
3205 x_pre_Layer1[nTruth[0]] = x_pre;
3206 y_pre_Layer1[nTruth[0]] = y_pre;
3207 z_pre_Layer1[nTruth[0]] = z_pre;
3208 x_post_Layer1[nTruth[0]] = x_post;
3209 y_post_Layer1[nTruth[0]] = y_post;
3210 z_post_Layer1[nTruth[0]] = z_post;
3211 phi_Layer1[nTruth[0]] = atan2(y_post + y_pre, x_post + x_pre);
3212 z_Layer1[nTruth[0]] = z_middle;
3213 V_Layer1[nTruth[0]] = V_mid;
3214 if (atan2(y_post + y_pre, x_post + x_pre) > 0) {
3215 x_0_up_mc2 = atan2(y_post + y_pre, x_post + x_pre);
3216 z_0_up_mc2 = z_middle;
3219 x_0_down_mc2 = atan2(y_post + y_pre, x_post + x_pre);
3220 z_0_down_mc2 = z_middle;
3221 v_0_down_mc2 = V_mid;
3223 px_pre_Layer1[nTruth[0]] = px_pre;
3224 py_pre_Layer1[nTruth[0]] = py_pre;
3225 pz_pre_Layer1[nTruth[0]] = pz_pre;
3226 en_Layer1[nTruth[0]] = en;
3229 if (nTruth[1] >= 100)
break;
3230 trkID_Layer2[nTruth[1]] = trkID;
3231 pdg_Layer2[nTruth[1]] = pdg;
3232 x_pre_Layer2[nTruth[1]] = x_pre;
3233 y_pre_Layer2[nTruth[1]] = y_pre;
3234 z_pre_Layer2[nTruth[1]] = z_pre;
3235 x_post_Layer2[nTruth[1]] = x_post;
3236 y_post_Layer2[nTruth[1]] = y_post;
3237 z_post_Layer2[nTruth[1]] = z_post;
3238 phi_Layer2[nTruth[1]] = atan2(y_post + y_pre, x_post + x_pre);
3239 z_Layer2[nTruth[1]] = z_middle;
3240 V_Layer2[nTruth[1]] = V_mid;
3241 if (atan2(y_post + y_pre, x_post + x_pre) > 0) {
3242 x_1_up_mc2 = atan2(y_post + y_pre, x_post + x_pre);
3243 z_1_up_mc2 = z_middle;
3246 x_1_down_mc2 = atan2(y_post + y_pre, x_post + x_pre);
3247 z_1_down_mc2 = z_middle;
3248 v_1_down_mc2 = V_mid;
3250 px_pre_Layer2[nTruth[1]] = px_pre;
3251 py_pre_Layer2[nTruth[1]] = py_pre;
3252 pz_pre_Layer2[nTruth[1]] = pz_pre;
3253 en_Layer2[nTruth[1]] = en;
3256 if (nTruth[2] >= 100)
break;
3257 trkID_Layer3[nTruth[2]] = trkID;
3258 pdg_Layer3[nTruth[2]] = pdg;
3259 x_pre_Layer3[nTruth[2]] = x_pre;
3260 y_pre_Layer3[nTruth[2]] = y_pre;
3261 z_pre_Layer3[nTruth[2]] = z_pre;
3262 x_post_Layer3[nTruth[2]] = x_post;
3263 y_post_Layer3[nTruth[2]] = y_post;
3264 z_post_Layer3[nTruth[2]] = z_post;
3265 phi_Layer3[nTruth[2]] = atan2(y_post + y_pre, x_post + x_pre);
3266 z_Layer3[nTruth[2]] = z_middle;
3267 V_Layer3[nTruth[2]] = V_mid;
3268 if (atan2(y_post + y_pre, x_post + x_pre) > 0) {
3269 x_2_up_mc2 = atan2(y_post + y_pre, x_post + x_pre);
3271 z_2_up_mc2 = z_middle;
3273 x_2_down_mc2 = atan2(y_post + y_pre, x_post + x_pre);
3274 v_2_down_mc2 = V_mid;
3275 z_2_down_mc2 = z_middle;
3277 px_pre_Layer3[nTruth[2]] = px_pre;
3278 py_pre_Layer3[nTruth[2]] = py_pre;
3279 pz_pre_Layer3[nTruth[2]] = pz_pre;
3280 en_Layer3[nTruth[2]] = en;
3282 default: cout <<
"wrong layer ID for CGEM: " << iLayer << endl;
3286 for (
int i = 0; i < 3; i++)
3287 if (nTruth[i] > 100) nTruth[i] = 100;
3288 SmartDataPtr<Event::McParticleCol> mcParticleCol(eventSvc(),
"/Event/MC/McParticleCol");
3290 Event::McParticleCol::iterator iter_mc = mcParticleCol->begin();
3291 HepLorentzVector p4_mu(0, 0, 0, 0);
3292 HepLorentzVector p4_pos(0, 0, 0, 0);
3293 for (; iter_mc != mcParticleCol->end(); iter_mc++) {
3294 if (!(*iter_mc)->decayFromGenerator())
continue;
3295 HepLorentzVector p4_mc(0, 0, 0, 0);
3297 if (13 ==
abs((*iter_mc)->particleProperty())) {
3299 p4_mu = (*iter_mc)->initialFourMomentum();
3300 p4_pos = (*iter_mc)->initialPosition();
3304 Hep3Vector _BP(p4_pos.x() * 10, p4_pos.y() * 10, p4_pos.z() * 10);
3310 _mc.push_back(p4_mu.px());
3311 _mc.push_back(p4_mu.py());
3312 _mc.push_back(p4_mu.pz());
3313 if (
HitPos(p4_mu, _BP)) _mc.push_back(1);
3314 else _mc.push_back(0);
3320 vector<double> _V_par;
3322 double xb = p4.px();
3323 double yb = p4.py();
3324 double zb = p4.pz();
3328 double k = -1 * (xa * xb + ya * yb) / (xb * xb + yb * yb);
3329 double xc = k * xb + xa;
3330 double yc = k * yb + ya;
3331 double zc = k * zb + za;
3335 _V_par.push_back(l.
dr());
3336 _V_par.push_back(l.
phi0());
3337 _V_par.push_back(l.
dz());
3338 _V_par.push_back(l.
tanl());
3343 double L(500), W(160),
H(600);
3345 vector<double> _V_par;
3347 double xb = p4.px();
3348 double yb = p4.py();
3349 double zb = p4.pz();
3353 double k =
H / yb * -1;
3354 double xc = k * xb + xa;
3355 double yc = k * yb + ya;
3356 double zc = k * zb + za;
3361 if (fabs(xc) > W / 2)
return false;
3362 if (fabs(zc) > L / 2)
return false;
3371 if (clst_0 >= 2 && clst_1 >= 2) {
3376 vector<double> inii_par =
Trans(l_ini_i->
dr(), l_ini_i->
phi0(), l_ini_i->
dz(), l_ini_i->
tanl());
3377 inii_0 = inii_par[0];
3378 inii_1 = inii_par[1];
3379 inii_2 = inii_par[2];
3380 inii_3 = inii_par[3];
3386 vector<double> inim_par =
Trans(l_ini_m->
dr(), l_ini_m->
phi0(), l_ini_m->
dz(), l_ini_m->
tanl());
3388 inim_0 = inim_par[0];
3389 inim_1 = inim_par[1];
3390 inim_2 = inim_par[2];
3391 inim_3 = inim_par[3];
3396 if (clst_0 >= 2 && clst_1 >= 2) {
3401 vector<double> inii_par =
Trans(l_ini_i->
dr(), l_ini_i->
phi0(), l_ini_i->
dz(), l_ini_i->
tanl());
3402 inii_0 = inii_par[0];
3403 inii_1 = inii_par[1];
3404 inii_2 = inii_par[2];
3405 inii_3 = inii_par[3];
3411 vector<double> inim_par =
Trans(l_ini_m->
dr(), l_ini_m->
phi0(), l_ini_m->
dz(), l_ini_m->
tanl());
3413 inim_0 = inim_par[0];
3414 inim_1 = inim_par[1];
3415 inim_2 = inim_par[2];
3416 inim_3 = inim_par[3];
3433 v_2_down =
Vec_v[i];
3434 z_2_down =
Vec_Z[i];
3444 v_1_down =
Vec_v[i];
3445 z_1_down =
Vec_Z[i];
3456 v_0_down =
Vec_v[i];
3457 z_0_down =
Vec_Z[i];
3681 vector<double> Vec_truth;
3682 Vec_truth.push_back(par[0]);
3683 Vec_truth.push_back(par[1]);
3684 Vec_truth.push_back(par[2]);
3685 Vec_truth.push_back(par[3]);
3689 x_0_up_f = clusters[0];
3690 v_0_up_f = clusters[1];
3691 x_0_down_f = clusters[2];
3692 v_0_down_f = clusters[3];
3694 x_1_up_f = clusters[4];
3695 v_1_up_f = clusters[5];
3696 x_1_down_f = clusters[6];
3697 v_1_down_f = clusters[7];
3699 x_2_up_f = clusters[8];
3700 v_2_up_f = clusters[9];
3701 x_2_down_f = clusters[10];
3702 v_2_down_f = clusters[11];
3707 if (
debug) cout <<
"Start Getintersection" << endl;
3708 Double_t fmin, edm, errdef;
3709 Int_t ierflg, npari, nparx, istat;
3710 double trkpar[4] = {-999, -999, -999, -999};
3711 double trkparErr[4] = {-999, -999, -999, -999};
3713 double phiV_up[2], phiV_down[2];
3715 double phiV_up_Tmp[2], phiV_down_Tmp[2];
3721 TMinuit *fit =
Fit(line,
fa -
f21, 0);
3722 fit->mnstat(fmin, edm, errdef, npari, nparx, istat);
3723 inter_1_flag = istat;
3724 for (
int i = 0; i < 4; i++) { fit->GetParameter(i, trkpar[i], trkparErr[i]); }
3736 inter_1_x = phiV_up[0];
3737 inter_1_V = phiV_up[1];
3762 fit->mnstat(fmin, edm, errdef, npari, nparx, istat);
3763 inter_2_flag = istat;
3764 for (
int i = 0; i < 4; i++) { fit->GetParameter(i, trkpar[i], trkparErr[i]); }
3773 inter_2_x = phiV_up[0];
3774 inter_2_V = phiV_up[1];
3788 fit->mnstat(fmin, edm, errdef, npari, nparx, istat);
3789 inter_3_flag = istat;
3790 for (
int i = 0; i < 4; i++) { fit->GetParameter(i, trkpar[i], trkparErr[i]); }
3800 inter_3_x = phiV_up[0];
3801 inter_3_V = phiV_up[1];
3815 fit->mnstat(fmin, edm, errdef, npari, nparx, istat);
3816 inter_4_flag = istat;
3817 for (
int i = 0; i < 4; i++) { fit->GetParameter(i, trkpar[i], trkparErr[i]); }
3828 inter_4_x = phiV_down[0];
3829 inter_4_V = phiV_down[1];
3830 inter_4_z = Down[2];
3842 fit->mnstat(fmin, edm, errdef, npari, nparx, istat);
3843 inter_5_flag = istat;
3844 for (
int i = 0; i < 4; i++) { fit->GetParameter(i, trkpar[i], trkparErr[i]); }
3853 inter_5_x = phiV_down[0];
3854 inter_5_V = phiV_down[1];
3855 inter_5_z = Down[2];
3867 fit->mnstat(fmin, edm, errdef, npari, nparx, istat);
3868 inter_6_flag = istat;
3869 for (
int i = 0; i < 4; i++) { fit->GetParameter(i, trkpar[i], trkparErr[i]); }
3880inter_6_x = phiV_down[0];
3881inter_6_V = phiV_down[1];
3894 vector<double> clusters;
3895 StraightLine l(Vec_truth[0], Vec_truth[1], Vec_truth[2], Vec_truth[3]);
3896 double phiV_up[2], phiV_down[2];
3899 double phiV_up_Tmp[2], phiV_down_Tmp[2];
3910 clusters.push_back(phiV_up[0]);
3911 clusters.push_back(phiV_up[1]);
3912 clusters.push_back(phiV_down[0]);
3913 clusters.push_back(phiV_down[1]);
3923 clusters.push_back(phiV_up[0]);
3924 clusters.push_back(phiV_up[1]);
3925 clusters.push_back(phiV_down[0]);
3926 clusters.push_back(phiV_down[1]);
3936 clusters.push_back(phiV_up[0]);
3937 clusters.push_back(phiV_up[1]);
3938 clusters.push_back(phiV_down[0]);
3939 clusters.push_back(phiV_down[1]);
3951 while (
arg < -1 * acos(-1))
arg += acos(-1) * 2;
3952 while (
arg > acos(-1))
arg -= acos(-1) * 2;
3958 double diff_raw = fabs(arg1 - arg2);
3960 if (diff_raw > acos(-1))
return (2 * acos(-1) - diff_raw);
3961 else return diff_raw;
3966 double phiV_up[2], phiV_down[2];
3974 double ds1 = pow((phiV_up[1] -
v), 2) + pow(
R_layer[R_id] *
Min_diff(phiV_up[0],
x), 2);
3976 double ds2 = pow((phiV_down[1] -
v), 2) + pow(
R_layer[R_id] *
Min_diff(phiV_down[0],
x), 2);
3978 return min(ds1, ds2);
3983 double phiV_up[2], phiV_down[2];
3988 double ds1 = pow((phiV_up[1] - z), 2) + pow(
R_layer[R_id] *
Min_diff(phiV_up[0],
x), 2);
3996 double phiV_up[2], phiV_down[2];
4002 double ds2 = pow((phiV_down[1] -
v), 2) + pow(
R_layer[R_id] *
Min_diff(phiV_down[0],
x), 2);
4010 double phiV_up[2], phiV_down[2];
4015 if (Up[0] > 9999 || Up[1] > 9999 || Down[0] > 9999 || Down[1] > 9999)
return false;
4020 vector<double> rotat;
4023 rotat.push_back(par0);
4024 rotat.push_back(par1);
4025 rotat.push_back(par2);
4026 rotat.push_back(par3);
4031 int virsheet = (phi < 0) ? 0 : 1;
4032 int virlay = geolay * 2 + virsheet;
4039 vector<double> Q_11_s;
4041 if (L_11.size() >
Nmax) {
4042 for (
int i = 0; i <
Nmax; i++) {
4043 for (
int j = i + 1; j < L_11.size(); j++) {
4044 if (Q_11[i] < Q_11[j]) {
4054 Q_11_s.push_back(Q_11[i]);
4055 L_11_s.push_back(L_11[i]);
4059 L_11_s.assign(L_11.begin(), L_11.end());
4060 Q_11_s.assign(Q_11.begin(), Q_11.end());
4066 int max_1_0(0), max_0_0(0);
4071 for (
int i = 0; i <
Vec_flag.size(); i++) {
4078 for (
int j = 0; j <
Vec_flag.size(); j++) {
4084 for (
int k =
Vec_flag.size() - 1; k > max_0_0; k--) {
erase(k); }
4085 for (
int m =
Vec_flag.size() - 2; m > max_1_0; m--) {
erase(m); }
4089 double trkpar[4] = {-999, -999, -999, -999};
4090 double trkparErr[4] = {-999, -999, -999, -999};
4092 Int_t ierflg, npari, nparx, istat3;
4093 Double_t fmin, edm, errdef;
4095 fit->mnstat(fmin, edm, errdef, npari, nparx, istat3);
4096 for (
int i = 0; i < 4; i++) { fit->GetParameter(i, trkpar[i], trkparErr[i]); }
4098 fit->mnemat(emat, 4);
4103 helixPar[0] = trkpar[0];
4104 helixPar[1] = trkpar[1];
4106 helixPar[3] = trkpar[2];
4107 helixPar[4] = trkpar[3];
4108 double errorMat[15];
4110 errorMat[0] = emat[0];
4111 errorMat[1] = emat[1];
4113 errorMat[3] = emat[2];
4114 errorMat[4] = emat[3];
4115 errorMat[5] = emat[5];
4117 errorMat[7] = emat[6];
4118 errorMat[8] = emat[7];
4122 errorMat[12] = emat[10];
4123 errorMat[13] = emat[11];
4124 errorMat[14] = emat[15];
4126 recMdcTrack->
setChi2(fit->fAmin);
4142 m_trackList_tds->push_back(recMdcTrack);
4151 const Hep3Vector Normals(cluster[0], cluster[1], 0);
4155 const Hep3Vector CosmicRay(x2[0] - x1[0], x2[1] - x1[1], x2[2] - x1[2]);
4156 const Hep3Vector z(0, 0, 1);
4157 const Hep3Vector phi = z.cross(Normals);
4158 Hep3Vector _phi = phi;
4160 const Hep3Vector V = _phi.rotate(-1 * theta, Normals);
4162 const Hep3Vector N_V = Normals.cross(V);
4163 const Hep3Vector N_phi = Normals.cross(phi);
4165 Hep3Vector C_phi = CosmicRay - CosmicRay.project(N_phi);
4166 double s_C_phi = Normals.dot(C_phi);
4167 Hep3Vector v_phi = Normals.cross(C_phi);
4170 double s_phi = v_phi.dot(z);
4172 ang[0] = -(Normals.angle(-C_phi));
4173 if (s_phi < 0) ang[0] = Normals.angle(-C_phi);
4181 }
else if (s_C_phi > 0) {
4182 double s_phi = v_phi.dot(z);
4184 ang[0] = -(Normals.angle(
4186 if (s_phi > 0) ang[0] = Normals.angle(C_phi);
4195 Hep3Vector C_V = CosmicRay - CosmicRay.project(N_V);
4196 double s_C_V = Normals.dot(C_V);
4197 Hep3Vector v_V = Normals.cross(C_V);
4200 double s_V = v_V.dot(z);
4201 if (s_V >= 0) ang[1] = -(Normals.angle(-C_V));
4202 if (s_V < 0) ang[1] = Normals.angle(-C_V);
4210 }
else if (s_C_V > 0) {
4211 double s_V = v_V.dot(z);
4212 if (s_V <= 0) ang[1] = -(Normals.angle(C_V));
4213 if (s_V > 0) ang[1] = Normals.angle(C_V);
4222 ang[2] = Normals.angle(CosmicRay);
4228void CgemLineFit::GetRes(
StraightLine *l,
int i_inter) {
4231 if (i_inter == 1 || i_inter == 6) {
4233 if (i_inter == 1) i_sheet = 1;
4235 if (i_inter == 2 || i_inter == 5) {
4237 if (i_inter == 2) i_sheet = 1;
4242 double phiV_up[2], phiV_down[2];
4244 double phiV_up_Tmp[2], phiV_down_Tmp[2];
4252 double V, phi, min_dst(99999), min_V(99999), min_phi(99999);
4253 double Z, min_Z(99999);
4259 if (i_inter == 4 || i_inter == 5 || i_inter == 6) {
4267 SmartDataPtr<RecCgemClusterCol> recCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
4268 RecCgemClusterCol::iterator
iter = recCgemClusterCol->begin();
4270 for (;
iter != recCgemClusterCol->end();
iter++) {
4273 int flag = cluster->
getflag();
4276 if (layerid != i_layer)
continue;
4278 if (sheetid != i_sheet)
continue;
4281 double _V = cluster->
getrecv();
4284 if (flag != 2)
continue;
4286 double dX = (_phi - phi) *
R_layer[layerid];
4291 if (
abs(dst) < min_dst) {
4310 Double_t fmin, edm, errdef;
4311 Int_t ierflg, npari, nparx, istat;
4312 double trkpar[4] = {-999, -999, -999, -999};
4313 double trkparErr[4] = {-999, -999, -999, -999};
4354 TMinuit *fit =
Fit(l,
fa - test_flag, 0);
4355 fit->mnstat(fmin, edm, errdef, npari, nparx, istat);
4357 for (
int i = 0; i < 4; i++) { fit->GetParameter(i, trkpar[i], trkparErr[i]); }
4370 inter_x = phiV_up[0];
4371 inter_V = phiV_up[1];
4374 if (i_inter == 4 || i_inter == 5 || i_inter == 6) {
4375 inter_x = phiV_down[0];
4376 inter_V = phiV_down[1];
4396 if (SimuPhi <= TMath::Pi()) RPhi = SimuPhi;
4397 else RPhi = SimuPhi - 2 * TMath::Pi();
4409 double angle[
n] = {-1.35, -1.25, -1.15, -1.05, -0.95, -0.85, -0.75, -0.65, -0.55, -0.45, -0.35, -0.25, -0.15, -0.05,
4410 0.05, 0.15, 0.25, 0.35, 0.45, 0.55, 0.65, 0.75, 0.85, 0.95, 1.05, 1.15, 1.25, 1.35};
4411 double y[
n] = {2.3576, 1.44448, 1.137, 0.998306, 0.819508, 0.695739, 0.583851, 0.487318, 0.408487, 0.317606,
4412 0.245717, 0.178443, 0.109751, 0.0469862, 0.0463951, 0.109757, 0.180819, 0.252827, 0.326331, 0.409922,
4413 0.482766, 0.594053, 0.690917, 0.835596, 0.93621, 1.25398, 1.56933, 1.93546};
4414 double *ex =
nullptr;
4415 double ey[
n] = {0.179035, 0.0641824, 0.0347424, 0.0256942, 0.015515, 0.0123214, 0.00893213,
4416 0.00584735, 0.00470714, 0.00334024, 0.00247131, 0.00171306, 0.00101272, 0.000571988,
4417 0.000525056, 0.00106782, 0.00170087, 0.00260604, 0.00347387, 0.00486819, 0.00638214,
4418 0.00910626, 0.0117511, 0.0172709, 0.0236933, 0.040096, 0.0607565, 0.171064};
4419 TGraphErrors
gr(
n, angle, y, ex, ey);
4420 sigma =
gr.Eval(Ang[0]);
4424 double angle[
n] = {-1.25, -1.15, -1.05, -0.95, -0.85, -0.75, -0.65, -0.55, -0.45, -0.35, -0.25, -0.15, -0.05,
4425 0.05, 0.15, 0.25, 0.35, 0.45, 0.55, 0.65, 0.75, 0.85, 0.95, 1.05, 1.15, 1.25};
4426 double y[
n] = {1.32155, 1.00793, 0.844239, 0.745985, 0.607887, 0.525712, 0.449061, 0.372476, 0.305783,
4427 0.231835, 0.167037, 0.105903, 0.0526632, 0.0518158, 0.106611, 0.170067, 0.235356, 0.301801,
4428 0.374196, 0.46125, 0.526767, 0.61776, 0.749122, 0.848473, 1.01892, 1.50534};
4429 double *ex =
nullptr;
4430 double ey[
n] = {0.108111, 0.0523342, 0.0275105, 0.0227304, 0.0135576, 0.0095431, 0.00675217,
4431 0.00439062, 0.00328685, 0.00225977, 0.0013645, 0.000902477, 0.000515666, 0.000505206,
4432 0.000917112, 0.00148768, 0.00221462, 0.0031313, 0.0046925, 0.00745832, 0.00983847,
4433 0.0151778, 0.0227792, 0.033388, 0.0477401, 0.159787};
4434 TGraphErrors
gr(
n, angle, y, ex, ey);
4435 sigma =
gr.Eval(Ang[1]);
4443 double angle[
n] = {-0.65, -0.55, -0.45, -0.35, -0.25, -0.15, -0.05, 0.05, 0.15, 0.25, 0.35, 0.45, 0.55, 0.65};
4444 double y[
n] = {0.459771, 0.381421, 0.310736, 0.238213, 0.169008, 0.103486, 0.0461908,
4445 0.0453169, 0.103585, 0.166698, 0.240332, 0.3125, 0.37973, 0.462382};
4446 double *ex =
nullptr;
4447 double ey[
n] = {0.00685022, 0.00437997, 0.00320362, 0.00214694, 0.00136347, 0.00081222, 0.000440626,
4448 0.000435363, 0.000818715, 0.00128686, 0.00214114, 0.00313311, 0.00436737, 0.0071195};
4450 TGraphErrors
gr(
n, angle, y, ex, ey);
4451 sigma =
gr.Eval(Ang[0]);
4455 double angle[
n] = {-0.75, -0.65, -0.55, -0.45, -0.35, -0.25, -0.15, -0.05, 0.05, 0.15, 0.25, 0.35, 0.45, 0.55, 0.65, 0.75};
4456 double y[
n] = {0.543351, 0.449597, 0.376926, 0.299783, 0.234983, 0.165406, 0.105945, 0.0544188,
4457 0.0540844, 0.10723, 0.167146, 0.234566, 0.300303, 0.37238, 0.461751, 0.570197};
4458 double *ex =
nullptr;
4459 double ey[
n] = {0.0255211, 0.00933694, 0.00529557, 0.00317545, 0.00209458, 0.0013353, 0.000773631, 0.00046874,
4460 0.000453118, 0.000828085, 0.00125195, 0.00202037, 0.00315857, 0.00489179, 0.0100004, 0.032045};
4461 TGraphErrors
gr(
n, angle, y, ex, ey);
4462 sigma =
gr.Eval(Ang[1]);
4471 double angle[
n] = {-0.65, -0.55, -0.45, -0.35, -0.25, -0.15, -0.05, 0.05, 0.15, 0.25, 0.35, 0.45, 0.55, 0.65};
4472 double y[
n] = {0.459771, 0.381421, 0.310736, 0.238213, 0.169008, 0.103486, 0.0461908,
4473 0.0453169, 0.103585, 0.166698, 0.240332, 0.3125, 0.37973, 0.462382};
4474 double *ex =
nullptr;
4475 double ey[
n] = {0.00685022, 0.00437997, 0.00320362, 0.00214694, 0.00136347, 0.00081222, 0.000440626,
4476 0.000435363, 0.000818715, 0.00128686, 0.00214114, 0.00313311, 0.00436737, 0.0071195};
4478 TGraphErrors
gr(
n, angle, y, ex, ey);
4479 sigma =
gr.Eval(Ang[0]);
4483 double angle[
n] = {-0.75, -0.65, -0.55, -0.45, -0.35, -0.25, -0.15, -0.05, 0.05, 0.15, 0.25, 0.35, 0.45, 0.55, 0.65, 0.75};
4484 double y[
n] = {0.543351, 0.449597, 0.376926, 0.299783, 0.234983, 0.165406, 0.105945, 0.0544188,
4485 0.0540844, 0.10723, 0.167146, 0.234566, 0.300303, 0.37238, 0.461751, 0.570197};
4486 double *ex =
nullptr;
4487 double ey[
n] = {0.0255211, 0.00933694, 0.00529557, 0.00317545, 0.00209458, 0.0013353, 0.000773631, 0.00046874,
4488 0.000453118, 0.000828085, 0.00125195, 0.00202037, 0.00315857, 0.00489179, 0.0100004, 0.032045};
4489 TGraphErrors
gr(
n, angle, y, ex, ey);
4490 sigma =
gr.Eval(Ang[1]);
4494 return sigma * sigma;
4497 double drho = l.
dr();
4498 double phi0 = l.
phi0();
4499 double s = (y - drho *
sin(phi0)) /
sin(phi0 - TMath::Pi() / 2);
4502float CgemLineFit::get_Time(CgemDigiCol::iterator iDigiCol) {
4504 float time = (*iDigiCol)->getTime_ns();
4506 float time_rising = get_TimeRising(iDigiCol);
4508 float time_walk = get_TimeWalk(iDigiCol);
4510 float time_reference = get_TimeReference(iDigiCol);
4512 float time_shift_custom = -35;
4514 time -= (time_rising + time_walk + time_reference + time_shift_custom);
4519float CgemLineFit::get_TimeRising(CgemDigiCol::iterator iDigiCol) {
4520 float time_rising = 0;
4522 const Identifier ident = (*iDigiCol)->identify();
4528 if (is_xstrip ==
true) view = 0;
4529 float charge = (*iDigiCol)->getCharge_fc();
4531 time_rising = myCgemCalibSvc->
getTimeRising(layerid, view, sheetid, stripid, charge, 0.);
4535float CgemLineFit::get_TimeWalk(CgemDigiCol::iterator iDigiCol) {
4536 float time_walk = 0;
4537 const Identifier ident = (*iDigiCol)->identify();
4543 if (is_xstrip ==
true) view = 0;
4544 float thr = lutreader->
Get_thr_T_fC(layerid, sheetid, view, stripid);
4545 float charge = (*iDigiCol)->getChargeChannel();
4546 time_walk = myCgemCalibSvc->
getTimeWalk(charge, thr);
4550float CgemLineFit::get_TimeReference(CgemDigiCol::iterator iDigiCol) {
4551 float time_reference = 0;
4552 const Identifier ident = (*iDigiCol)->identify();
4558 if (is_xstrip ==
true) view = 0;
4561 return time_reference;
double sin(const BesAngle a)
double cos(const BesAngle a)
vector< double > Vec_m_layer
vector< double > Vec_Virlayerid
vector< vector< double > > Vec_VstripQ
vector< int > Vec_x_stripsid
vector< double > Vec_flag
vector< vector< double > > Vec_VstripT
vector< double > Vec_x_stripsTf
vector< double > Vec_m_layerid
vector< vector< double > > Vec_XstripT
vector< double > Vec_m_phi
vector< vector< double > > Vec_VstripTf
vector< vector< int > > Vec_VstripID
vector< vector< double > > Vec_XstripTf
vector< double > Vec_v_stripsQ
vector< double > Vec_x_stripsT
vector< double > Vec_sheetid
vector< double > Vec_v_stripsTf
CgemGeoReadoutPlane * pl_00
vector< double > Vec_xCluSize
vector< int > Vec_v_stripsid
vector< double > Vec_vCluSize
vector< double > Vec_v_stripsT
vector< double > Vec_layer
vector< double > Vec_m_flag
vector< vector< double > > Vec_XstripQ
CgemGeoReadoutPlane * pl_20
vector< double > Vec_layerid
vector< double > Vec_x_stripsQ
vector< vector< int > > Vec_XstripID
CgemGeoReadoutPlane * pl_11
CgemGeoReadoutPlane * pl_10
CgemGeoReadoutPlane * pl_21
vector< double > Vec_m_sheetid
double arg(const EvtComplex &c)
double abs(const EvtComplex &c)
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
ObjectVector< RecMdcHit > RecMdcHitCol
ObjectVector< RecMdcTrack > RecMdcTrackCol
double getDx(int layer_vir)
double getRx(int layer_vir)
double getRy(int layer_vir)
double getRz(int layer_vir)
double getDz(int layer_vir)
HepPoint3D point_invTransform(int layer_vir, HepPoint3D pos)
double getDy(int layer_vir)
double getInnerROfAnodeCu1() const
int getNumberOfSheet() const
double getInnerROfAnodeCu2() const
double getVFromPhiZ(double phi, double z, bool checkRange=true) const
double getZFromPhiV(double phi, double V, int checkXRange=1) const
bool OnThePlane(double phi, double z) const
CgemGeoLayer * getCgemLayer(int i) const
double getLengthOfCgem() const
int getNumberOfCgemLayer() const
CgemGeoReadoutPlane * getReadoutPlane(int iLayer, int iSheet) const
CgemMidDriftPlane * getMidDriftPtr() const
CgemGeoAlign * getAlignPtr() const
static int strip(const Identifier &id)
static int sheet(const Identifier &id)
static int layer(const Identifier &id)
static bool is_xstrip(const Identifier &id)
float GetSignal_StartTime_ns(int ilayer, int isheet, int iview, int istrip)
float Get_thr_T_fC(int ilayer, int isheet, int iview, int istrip)
float GetSignal_FEBStartTime_ns(int ilayer, int isheet, int iview, int istrip)
static vector< int > GetNMaxQ(vector< double > Q_11, vector< int > L_11, int Nmax)
void Filter(int layerid, StraightLine *l1)
static double CalSigma2(double layerid, double flag, double x, double V, double z, StraightLine *cosmic_ray)
StraightLine * IniPar(double phi1, double z1, int i, double phi2, double z2, int j)
vector< double > Get4Par(HepLorentzVector p4, Hep3Vector bp)
double Min_dis_up(int R_id, double x, double z, StraightLine *l1)
CgemLineFit(const std::string &name, ISvcLocator *pSvcLocator)
int GetVirLay(int geolay, double phi)
void Fit_Clusters(double par[])
static void fcn2(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
void GetIntersection(StraightLine *line)
bool Layer_cross(int R_id, StraightLine *l1)
static vector< double > Trans(double par0, double par1, double par2, double par3)
double Min_dis_down(int R_id, double x, double z, StraightLine *l1)
static void fcn3(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
static void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
static void IncidentAngle(StraightLine *cosmic_ray, HepPoint3D cluster, double theta, double ang[])
static double dV(int layer, double R, double dr, double phi0, double z0, double tglam, double x, double V)
double Min_dis(int R_id, double x, double z, StraightLine *l1)
vector< double > MC_truth()
bool HitPos(HepLorentzVector p4, Hep3Vector bp)
static void to_0_2pi(double &arg)
TMinuit * Fit(StraightLine *l_outer, int sheetflag, int typ)
static double dx(double layerid, double R, double dr, double phi0, double z0, double tanl, double x)
void Get_OtherIniPar(int clst_0, int clst_1, int clst_2)
static double Min_diff(double arg1, double arg2)
void Store_Trk(TMinuit *fit, int trkid)
static double CalLineSAtY(StraightLine &l, double y)
double RealPhi(double SimuPhi)
vector< double > Get_Clusters(vector< double >Vec_truth)
StatusCode registerTrack(RecMdcTrackCol *&recMdcTrackCol, RecMdcHitCol *&recMdcHitCol)
bool getPointIdealGeom(int layer_vir, StraightLine pLine, HepPoint3D &posUp, HepPoint3D &posDown, double phiVUp[], double phiVDown[])
bool getPointAligned(int layer_vir, StraightLine pLine, HepPoint3D &posUp, HepPoint3D &posDown, double phiVUp[], double phiVDown[])
void setTrackId(const int trackId)
void setError(double err[15])
void setHelix(double helix[5])
void setChi2(const double chi)
virtual double getTimeRising(int layer, int xvFlag, int sheet, int stripID, double Q=100., double z=0.) const =0
virtual double getTimeWalk(int layer, int xvFlag, int sheet, int stripID, double Q) const =0
double getrecphi_mTPC(void) const
double getenergydeposit(void) const
double getRecZ(void) const
int getclusterid(void) const
double getrecv_mTPC(void) const
int getlayerid(void) const
int getclusterflagb(void) const
double getRecZ_mTPC(void) const
double getrecphi(void) const
double getrecv(void) const
int getsheetid(void) const
int getclusterflage(void) const
void setVecClusters(ClusterRefVec vecclusters)
void setNcluster(int ncluster)
HepPoint3D x(double s=0.) const
returns position after moving s in downwoards
double dr(void) const
returns an element of parameters.