BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnSiliconTrackFinder.cxx
Go to the documentation of this file.
1// Author: Vasilisa Lenivenko (VBLHEP) <vasilisa@jinr.ru> 2019-07-18
2
3////////////////////////////////////////////////////////////////////////////////
4// //
5// BmnSiliconTrackFinder //
6// //
7// Implementation of an algorithm developed by //
8// V.Lenivenko and V.Paltchik //
9// to the BmnRoot software //
10// //
11// The algorithm serves for searching for track segments //
12// in the Silicon detectors of the BM@N experiment //
13// //
14////////////////////////////////////////////////////////////////////////////////
15
17
18#include "FairLogger.h"
19#include "FairMCPoint.h"
20#include "FairRootManager.h"
21#include "TFile.h"
22
23#include <TMath.h>
24#include <vector>
25
26static Double_t workTime = 0.0;
27// TList fhList;
28
29//----------------------------------------------------------------------
31{
32 if (!IsActive())
33 return;
34
35 clock_t tStart = clock();
37 if (fDebug)
38 cout << "\n======================== Silicon track finder exec started ===================\n" << endl;
39 if (fDebug)
40 cout << "Event number: " << fEventNo << endl;
41 fEventNo++;
42
43 //------------------------Digi-file reading---------------------------
44 if (expData)
46
47 if (fDebug)
48 cout << "------------Clustering----------------------" << endl;
49 if (expData)
51 NclustXp);
52
53 if (fDebug)
54 cout << "------------Coordinate Calculation----------" << endl;
58
59 Bool_t Skip = 0; // SkipEvent(NclustX, NclustXp, XCoord, XpCoord);
60 if (Skip)
61 return;
62 if (expData)
64
65 //----------------------------Tracking--------------------------------
66 if (fRunPeriod == 7) {
67 if (fDebug)
68 cout << "------------Case1: spatial track------------" << endl;
70 if (Nsp_st[1] > 0 && Nsp_st[2] > 0 && Nsp_st[3] > 0) {
74 }
79 if (fDebug)
80 cout << "------------Case1.--------------------------" << endl;
81
82 if (fDebug)
83 cout << "------------Case2: 2spatial points + XorX'---" << endl;
85 if (Nsp_st[3] > 0 && (Nsp_st[1] + Nsp_st[2]) > 0) {
86 for (Int_t Istn = 1; Istn < 3; ++Istn) {
96 }
97 }
98 if (fDebug)
99 cout << "------------Case2.--------------------------" << endl;
100
101 if (fDebug)
102 cout << "------------Case3:2spatial points + check to the vertex--" << endl;
104 if (Nsp_st[1] > 0 && Nsp_st[2] > 0) {
114 }
115 if (fDebug)
116 cout << "------------Case3.--------------------------" << endl;
117
118 if (fDebug)
119 cout << "------------Case4:1spatial point in 3st + X/X' in st 1&2-" << endl;
121 if (Nsp_st[3] > 0) {
122 for (Int_t Istn = 1; Istn < 3; ++Istn) {
132 }
133 }
134 if (fDebug)
135 cout << "-------------Case4.--------------------------" << endl;
139 } // run7
140 if (fRunPeriod == 8) {
141 return;
142 }
143
144 if (fDebug)
146
147 if (!expData)
149 if (fDebug)
150 cout << "---------------------------------------------" << endl;
151 //------Write all Silicon-hits & Tracks------
156
157 if (fDebug)
158 cout << endl;
159 if (fDebug)
160 cout << "======================== Silicon track finder exec finished ===================" << endl;
161 clock_t tFinish = clock();
162 workTime += ((Double_t)(tFinish - tStart)) / CLOCKS_PER_SEC;
163} // exec
164//----------------------------------------------------------------------
165
167{
168 if (fDebug)
169 cout << "--WriteSiliconTracks--" << endl;
170
171 Int_t Track_counter = 0;
172
173 for (size_t InIter = 0; InIter < Tr.size(); ++InIter) {
174
175 // Double_t Fit = Tr.at(InIter).param[2] * Tr.at(InIter).CoordZ[3] + Tr.at(InIter).param[3];
176 // if (fDebug && Fit > 2.) cout<<" Fit > 2. "<<Fit<<fEventNo<<endl;
177
178 Double_t z1 = Tr.at(InIter).CoordZ[1] + Zcentr;
179 Double_t x1 = Tr.at(InIter).param[0] * Tr.at(InIter).CoordZ[1] + Tr.at(InIter).param[1]; // ax(z)+bx
180 Double_t y1 = Tr.at(InIter).param[2] * Tr.at(InIter).CoordZ[1] + Tr.at(InIter).param[3]; // y
181 Double_t z3 = Tr.at(InIter).CoordZ[3] + Zcentr;
182 Double_t x3 = Tr.at(InIter).param[0] * Tr.at(InIter).CoordZ[3] + Tr.at(InIter).param[1]; // ax(z)+bx
183 Double_t y3 = Tr.at(InIter).param[2] * Tr.at(InIter).CoordZ[3] + Tr.at(InIter).param[3]; // y
184
185 // if(fDebug)cout<<" itr "<<InIter<<" ax "<<Tr.at(InIter).param[0]<<" bx "<<Tr.at(InIter).param[1]<<endl;
186
187 for (Int_t st = 1; st < fNstations; ++st) {
188 if (Tr.at(InIter).CoordX[st] < -900. && Tr.at(InIter).CoordXp[st] > -900.) {
189 Tr.at(InIter).CoordY[st] =
190 Tr.at(InIter).param[2] * Tr.at(InIter).CoordZ[st] + Tr.at(InIter).param[3]; // y
191 Tr.at(InIter).SigmaY[st] = 0.105581;
192 }
193
194 // if(fDebug)cout<<" itr "<<InIter<<" st "<<st<<" hit: X "<<Tr.at(InIter).CoordX[st]<<" Y
195 // "<<Tr.at(InIter).CoordY[st]<<" SigX "<<Tr.at(InIter).SigmaX[st]<<" SigY
196 // "<<Tr.at(InIter).SigmaY[st]<<endl;
197 BmnSiliconHit* hit = new ((*fBmnSiliconHitsArray)[Track_counter]) BmnSiliconHit(
198 0,
199 TVector3(Tr.at(InIter).CoordX[st] + Shift_toCenterOfMagnetX,
200 Tr.at(InIter).CoordY[st] + Shift_toCenterOfMagnetY, Tr.at(InIter).CoordZ[st] + Zcentr),
201 TVector3(Tr.at(InIter).SigmaX[st], Tr.at(InIter).SigmaY[st], -1), InIter);
202 Track_counter++;
203 hit->SetStation(st);
204 hit->SetModule(Tr.at(InIter).ModNum[st]);
205 hit->SetIndex(InIter);
206 }
207
208 FairTrackParam trackParamf;
209 trackParamf.SetPosition(TVector3(x1 + Shift_toCenterOfMagnetX, y1 + Shift_toCenterOfMagnetY, z1));
210 trackParamf.SetTx(Tr.at(InIter).param[0] + Shift_toCenterOfMagnetAX
211 + Shift_toCenterOfMagnetAX * Tr.at(InIter).param[0] * Tr.at(InIter).param[0]);
212 trackParamf.SetTy(Tr.at(InIter).param[2] + Shift_toCenterOfMagnetAY
213 + Shift_toCenterOfMagnetAY * Tr.at(InIter).param[2] * Tr.at(InIter).param[2]);
214
215 FairTrackParam trackParaml;
216 trackParaml.SetPosition(TVector3(x3 + Shift_toCenterOfMagnetX, y3 + Shift_toCenterOfMagnetY, z3));
217 trackParaml.SetTx(Tr.at(InIter).param[0] + Shift_toCenterOfMagnetAX
218 + Shift_toCenterOfMagnetAX * Tr.at(InIter).param[0] * Tr.at(InIter).param[0]);
219 trackParaml.SetTy(Tr.at(InIter).param[2] + Shift_toCenterOfMagnetAY
220 + Shift_toCenterOfMagnetAY * Tr.at(InIter).param[2] * Tr.at(InIter).param[2]);
221
222 // if(fDebug)cout<<" itr "<<InIter<<" ax "<<Tr.at(InIter).param[0]+ Shift_toCenterOfMagnetAX +
223 // Shift_toCenterOfMagnetAX * Tr.at(InIter).param[0]* Tr.at(InIter).param[0]<<" bx
224 // "<<x3+Shift_toCenterOfMagnetX<<" z "<<z3<<endl;
225 BmnTrack* track = new ((*fSiTracks)[fSiTracks->GetEntriesFast()]) BmnTrack();
226 track->SetChi2(Tr.at(InIter).Chi2);
227 track->SetNHits(Tr.at(InIter).Nhits);
228 track->SetFlag(InIter);
229 track->SetNDF(Tr.at(InIter).Pdg);
230 track->SetParamFirst(trackParamf);
231 track->SetParamLast(trackParaml);
232
233 } // InIter
234 //--------------------------------------------------------------------
235}
236
238 Int_t** NclustXp_,
239 Int_t** NhitsXYmod_,
240 Double_t*** XCoord_,
241 Double_t*** XClust_width_,
242 Double_t*** XClust_,
243 Double_t*** sumQx_,
244 Double_t*** XpCoord_,
245 Double_t*** XpClust_width_,
246 Double_t*** XpClust_,
247 Double_t*** sumQxp_,
248 Double_t*** XspCoord_,
249 Double_t*** YspCoord_,
250 Double_t*** XspClust_width_,
251 Double_t*** XpspClust_width_,
252 Double_t*** XspClust_,
253 Double_t*** XpspClust_,
254 Double_t*** sumQxsp_,
255 Double_t*** sumQxpsp_,
256 Double_t*** SigmaX_,
257 Double_t*** SigmaXp_,
258 Double_t*** SigmspX_,
259 Double_t*** SigmspXp_,
260 Double_t*** SigmspY_,
261 Int_t*** Sp_pdg_)
262{
263 Int_t countX = 0;
264 for (Int_t ist = 1; ist < fNstations; ist++) {
265 for (Int_t imod = 0; imod < fNmodules; imod++) {
266 if (ist == 1 && imod > 3)
267 continue;
268 if (ist == 2 && imod > 1)
269 continue;
270 for (Int_t cl = 0; cl < NclustX_[ist][imod]; cl++) {
271
272 if (XCoord_[ist][imod][cl] < -900.)
273 continue;
274 // if(fDebug)cout<<" st "<<ist<<" hit: X "<<XCoord[ist][imod][cl] <<" Y "<<-100.<<" SigX
275 // "<<SigmaX[ist][imod][cl]<<" SigY "<<-100.<<endl;
276 BmnSiliconHit* hit = new ((*fBmnSiliconHitsXArray)[countX]) BmnSiliconHit(
277 0, TVector3(XCoord_[ist][imod][cl] + Shift_toCenterOfMagnetX, -100., Zstation[ist][imod]),
278 TVector3(SigmaX_[ist][imod][cl], -100, -1), cl);
279 hit->SetStation(ist);
280 hit->SetModule(imod);
281 hit->SetIndex(countX);
282
283 countX++;
284 }
285 } // imod
286 } // ist
287
288 Int_t countXp = 0;
289 for (Int_t ist = 1; ist < fNstations; ist++) {
290 for (Int_t imod = 0; imod < fNmodules; imod++) {
291 if (ist == 1 && imod > 3)
292 continue;
293 if (ist == 2 && imod > 1)
294 continue;
295 for (Int_t cl = 0; cl < NclustXp_[ist][imod]; cl++) {
296
297 if (XpCoord_[ist][imod][cl] < -900.)
298 continue;
299 // if(fDebug)cout<<" st "<<ist<<" hit: X "<<XCoord_[ist][imod][cl] <<" Y "<<-100.<<" SigX
300 // "<<SigmaX_[ist][imod][cl]<<" SigY "<<-100.<<endl;
301 BmnSiliconHit* hit = new ((*fBmnSiliconHitsXpArray)[countXp]) BmnSiliconHit(
302 0, TVector3(XpCoord_[ist][imod][cl] + Shift_toCenterOfMagnetX, -100., Zstation[ist][imod]),
303 TVector3(SigmaXp_[ist][imod][cl], -100, -1), cl);
304 hit->SetStation(ist);
305 hit->SetModule(imod);
306 hit->SetIndex(countXp);
307
308 countXp++;
309 }
310 } // imod
311 } // ist
312
313 Int_t countXY = 0;
314 for (Int_t ist = 1; ist < fNstations; ist++) {
315 for (Int_t imod = 0; imod < fNmodules; imod++) {
316 if (ist == 1 && imod > 3)
317 continue;
318 if (ist == 2 && imod > 1)
319 continue;
320 for (Int_t cl = 0; cl < NhitsXYmod_[ist][imod]; cl++) {
321
322 if (fDebug)
323 cout << " st " << ist << " hit: X " << XspCoord_[ist][imod][cl] << " Y " << YspCoord_[ist][imod][cl]
324 << " pdg " << Sp_pdg_[ist][imod][cl] << endl;
325 if (XspCoord_[ist][imod][cl] < -900.)
326 continue;
327 BmnSiliconHit* hit = new ((*fBmnSiliconHitsXYArray)[countXY])
329 TVector3(XspCoord_[ist][imod][cl] + Shift_toCenterOfMagnetX,
330 YspCoord_[ist][imod][cl] + Shift_toCenterOfMagnetY, Zstation[ist][imod]),
331 TVector3(SigmspX_[ist][imod][cl], SigmspY_[ist][imod][cl], -1), cl);
332 hit->SetStation(ist);
333 hit->SetModule(imod);
334 hit->SetIndex(countXY);
335 hit->SetPdg(Sp_pdg_[ist][imod][cl]);
336 countXY++;
337 }
338 } // imod
339 } // ist
340}
341
342void BmnSiliconTrackFinder::MCefficiencyCalculation(vector<MC_points>& vec, vector<tracksX>& Tr)
343{
344
345 if (fDebug)
346 cout << " ---Silicon MC tracks association--" << endl;
347 // ax, bx, ay, by
348 Double_t delt[4] = {-999., -999., -999., -999.};
349 Double_t sig[4] = {0.04, 0.08, 0.05, 0.08};
350
351 Double_t dmatch = 0.;
352 Double_t dmc_match[kMaxMC];
353 Int_t mc_tr_assoc[kMaxMC];
354
355 for (Int_t j = 0; j < kMaxMC; j++) {
356 dmc_match[j] = 1000.;
357 mc_tr_assoc[j] = -1;
358 }
359
360 Double_t dax = -999.;
361 Double_t day = -999.;
362 Double_t dx = -999.;
363 Double_t dy = -999.;
364
365 if (fDebug)
366 cout << " Nmc " << vec.size() << " Nsi " << Tr.size() << endl;
367
368 Int_t Ngood_mc_tracks = 0;
369 Int_t Ngood_reco_tracks = 0;
370 Bool_t wasLi7 = 0;
371 Bool_t wasHe4 = 0;
372
373 for (size_t itr = 0; itr < vec.size(); itr++) { // mc_tr
374
375 //---MC Eff ---
376 //---Den
377 if (fDebug && vec.at(itr).Np >= 3 && vec.at(itr).wo3st == 0) {
378 hDen_mctrSi->Fill(0);
379 Ngood_mc_tracks++;
380 cout << " SiDen " << endl;
381 if (vec.at(itr).Pdg == PDG_Li7)
382 wasLi7 = 1;
383 if (vec.at(itr).Pdg == PDG_He4)
384 wasHe4 = 1;
385 }
386
387 for (size_t InIter = 0; InIter < Tr.size(); InIter++) { // reco_tr
388
389 delt[0] = vec.at(itr).param[0] - Tr.at(InIter).param[0];
390 delt[1] = vec.at(itr).param[1] - Tr.at(InIter).param[1];
391 delt[2] = vec.at(itr).param[2] - Tr.at(InIter).param[2];
392 delt[3] = vec.at(itr).param[3] - Tr.at(InIter).param[3];
393
394 if (fDebug) {
395 if (delt[0] > -900.)
396 hdAx_MC_tr_comb->Fill(dax);
397 if (delt[1] > -900.)
398 hdX_MC_tr_comb->Fill(dx);
399 if (delt[2] > -900.)
400 hdAy_MC_tr_comb->Fill(day);
401 if (delt[3] > -900.)
402 hdY_MC_tr_comb->Fill(dy);
403 }
404
405 dmatch = 0.;
406 dmatch = (delt[0] * delt[0]) / (sig[0] * sig[0]) + (delt[1] * delt[1]) / (sig[1] * sig[1])
407 + (delt[2] * delt[2]) / (sig[2] * sig[2]) + (delt[3] * delt[3]) / (sig[3] * sig[3]);
408
409 if (dmc_match[itr] > dmatch) {
410 dmc_match[itr] = dmatch;
411 mc_tr_assoc[itr] = InIter;
412 dax = delt[0];
413 dx = delt[1];
414 day = delt[2];
415 dy = delt[3];
416 }
417 } // reco
418
419 if (mc_tr_assoc[itr] > -1) {
420 // if (fDebug && dax < -.00017)
421 // cout<<"Siiiii fEventNo "<<fEventNo
422 if (fDebug)
423 cout << " itr " << itr << " Np " << vec.at(itr).Np << " mc_Id " << vec.at(itr).Id << " ax_mc "
424 << vec.at(itr).param[0] << " reco_ind " << mc_tr_assoc[itr] << " ax "
425 << Tr.at(mc_tr_assoc[itr]).param[0] << " dmc_match " << dmc_match[itr] << endl;
426 if (fDebug) {
427 if (dax > -900.)
428 hdAx_MC_tr->Fill(dax);
429 if (dx > -900.)
430 hdX_MC_tr->Fill(dx);
431 if (day > -900.)
432 hdAy_MC_tr->Fill(day);
433 if (dy > -900.)
434 hdY_MC_tr->Fill(dy);
435 }
436 }
437 } // mc_tr
438
439 if (wasLi7 && wasHe4) {
440 if (fDebug)
441 cout << " wasLi7 && wasHe4 " << wasLi7 << " " << wasHe4 << endl;
442 hDen_mcreaction->Fill(0);
443 }
444 Int_t Nassoc = 0;
445
446 if (fDebug)
447 cout << "Si reject poorly chosen association segments " << endl;
448 for (size_t itr = 0; itr < vec.size(); itr++) { // mc_tr
449 if (mc_tr_assoc[itr] == -1)
450 continue;
451
452 for (size_t itr2 = 0; itr2 < vec.size(); itr2++) { // mc_tr
453 if (itr2 == itr)
454 continue;
455 if (mc_tr_assoc[itr2] == -1)
456 continue;
457
458 if (mc_tr_assoc[itr] == mc_tr_assoc[itr2]) {
459 if (dmc_match[itr2] > 2 * dmc_match[itr])
460 mc_tr_assoc[itr2] = -1;
461 else {
462 // mc_tr_assoc[itr] = -1;
463 continue; // break;
464 }
465 }
466 } // itr2
467 //---MC Eff ---
468 //---Num
469 if (fDebug)
470 cout << " mc_Id " << vec.at(itr).Id << " assoc " << mc_tr_assoc[itr] << " pdg " << vec.at(itr).Pdg << endl;
471 if (fDebug && mc_tr_assoc[itr] > -1 && vec.at(itr).Np >= 3 && vec.at(itr).wo3st == 0) {
472 Nassoc++;
473 Ngood_reco_tracks++;
474 hNum_mctrSi->Fill(0);
475 cout << " Num " << endl;
476 }
477 } // itr
478
479 if (fDebug)
480 cout << " Nassoc " << Nassoc << endl;
481 if (Nassoc == 2 && wasLi7 && wasHe4) {
482 if (fDebug)
483 cout << " hNum_mcreaction " << endl;
484 hNum_mcreaction->Fill(0);
485 }
486 if (fDebug) {
487 hNtrsi_mc->Fill(Ngood_mc_tracks);
488 hNtrsi_reco->Fill(Ngood_reco_tracks);
489 hNtrsi_mc_vs_reco->Fill(Ngood_reco_tracks, Ngood_mc_tracks);
490 }
491
492 for (size_t InIter = 0; InIter < Tr.size(); InIter++) { // reco_tr
493 for (size_t itr = 0; itr < vec.size(); itr++) { // mc_tr
494 if (mc_tr_assoc[itr] == (Int_t)InIter) {
495 Tr.at(InIter).Pdg = vec.at(itr).Pdg;
496 }
497 }
498 }
499 for (size_t InIter = 0; InIter < Tr.size(); InIter++) { // reco_tr
500 if (fDebug)
501 cout << " InIter " << InIter << " Pdg " << Tr.at(InIter).Pdg << endl;
502 }
503}
504
505void BmnSiliconTrackFinder::StripsReading(Double_t*** DigitsArrayX_, Double_t*** DigitsArrayXp_)
506{
507
508 Int_t stat, mod, layer, strip, new_strip;
509 Double_t Ampl;
510 for (Int_t iDig = 0; iDig < fBmnSiDigitsArray->GetEntriesFast(); ++iDig) {
511 BmnSiliconDigit* digit = (BmnSiliconDigit*)fBmnSiDigitsArray->UncheckedAt(iDig);
512
513 stat = digit->GetStation() + 1;
514 mod = digit->GetModule();
515 layer = digit->GetStripLayer();
516 if ((strip = digit->GetStripNumber() - 2) < 0)
517 continue;
518 strip = digit->GetStripNumber() - 1; // Kapishin's digits start 1th strip & shift for src
519 Ampl = digit->GetStripSignal();
520 // if(fDebug) cout<<" stat "<< stat <<" mod "<< mod <<" layer "<<layer<< " strip "<<strip<<" Ampl "<<Ampl<<endl;
521 if (layer == 0) {
522 DigitsArrayX_[stat][mod][strip] = Ampl;
523 // if(fDebug) cout<<" DigitsArrayX["<<stat<<"]["<<mod<<"]["<<strip<<"] =
524 // "<<DigitsArrayX_[stat][mod][strip]<<endl;
525 }
526 if (layer == 1) {
527 if (fRunPeriod == 7 && stat == 1) {
528 new_strip = nstripXpsm - strip;
529 if (new_strip < 0)
530 continue;
531 DigitsArrayXp_[stat][mod][new_strip] = Ampl;
532 } else {
533 new_strip = nstripXp - strip;
534 if (new_strip < 0)
535 continue;
536 DigitsArrayXp_[stat][mod][new_strip] = Ampl;
537 } // else
538 // if (stat == 3){
539 // if (new_strip > 639) continue;
540 // DigitsArrayXp_[stat][mod][new_strip+1] = DigitsArrayXp_[stat][mod][new_strip];
541 // }
542 // if(fDebug) cout<<" DigitsArrayXp["<<stat<<"]["<<mod<<"]["<<new_strip<<"] =
543 // "<<DigitsArrayXp_[stat][mod][new_strip]<<endl;
544 } // layer == 1
545 } // iDig
546}
547
548//-------------------Spatial coordinate calculation---------------------
550 Int_t** NClXp,
551 Double_t*** XCoor,
552 Double_t*** XpCoor,
553 Double_t*** Xsp,
554 Double_t*** Xpsp,
555 Double_t*** Ysp,
556 Int_t** NXYsp,
557 Double_t*** SigmX,
558 Double_t*** SigmXp,
559 Double_t*** SigspX,
560 Double_t*** SigspXp,
561 Double_t*** SigspY,
562 Double_t*** XCl,
563 Double_t*** XCl_width,
564 Double_t*** sQx,
565 Double_t*** XpCl,
566 Double_t*** XpCl_width,
567 Double_t*** sQxp,
568 Double_t*** XspCl,
569 Double_t*** XspCl_width,
570 Double_t*** sQxsp,
571 Double_t*** XpspCl,
572 Double_t*** XpspCl_width,
573 Double_t*** sQxpsp)
574{
575
577
578 for (Int_t istat = 1; istat < fNstations; istat++) {
579 SensitiveAreaY[istat] = 2 * 6.0705 + 0.1148 + 0.2303;
580 }
581 if (fRunPeriod == 7) {
582 SensitiveAreaY[1] = 6.0705 + 0.1148;
583 }
584 SensitiveAreaY[0] = 0.;
585 Double_t YCoor_cand = -1.;
586
587 for (Int_t istat = 1; istat < fNstations; istat++) {
588 for (Int_t imod = 0; imod < fNmodules; imod++) {
589 NXYsp[istat][imod] = 0;
590
591 for (Int_t clx = 0; clx < NClX[istat][imod]; ++clx) {
592 for (Int_t clxp = 0; clxp < NClXp[istat][imod]; ++clxp) {
593 if (XCoor[istat][imod][clx] > -900. && XpCoor[istat][imod][clxp] > -900.) {
594 // if ( fabs(XpCoor[istat][imod][clxp] - XCoor[istat][imod][clx]) > 0.3 ) continue;//
595 // VP 11.11.2021
596
597 YCoor_cand = (XpCoor[istat][imod][clxp] - XCoor[istat][imod][clx]) / tg2_5;
598
599 // if ( fDebug ) cout<<" istat "<<istat<<" imod "<<imod<<" X "<<XCoor[istat][imod][clx]<<" Xp
600 // "<<XpCoor[istat][imod][clxp] <<" Ycand "<<YCoor_cand <<" SensitiveAreaY[istat]
601 // "<<SensitiveAreaY[istat]<<endl;
602
603 if (YCoor_cand >= 0.1148 && YCoor_cand <= SensitiveAreaY[istat])
604 { // if (YCoor_cand >= 0 && YCoor_cand <=
605 // SensitiveAreaY[istat]) {
606
607 if (fRunPeriod == 7 && istat > 1 && YCoor_cand > 6.0705 + 0.1148
608 && YCoor_cand < 6.0705 + 0.1148 + 0.2303)
609 continue;
610 // if (fRunPeriod == 7 && istat == 1)
611
612 if (fRunPeriod == 7 && istat > 1 && YCoor_cand <= half_module) {
613 YCoor_cand -= shift_after_zigzag;
614 }
615 // if ( fDebug ) cout<<" Y "<<YCoor_cand<<endl;
616 Xsp[istat][imod][NXYsp[istat][imod]] = XCoor[istat][imod][clx];
617 SigspX[istat][imod][NXYsp[istat][imod]] = SigmX[istat][imod][clx];
618 XspCl[istat][imod][NXYsp[istat][imod]] = XCl[istat][imod][clx];
619 XspCl_width[istat][imod][NXYsp[istat][imod]] = XCl_width[istat][imod][clx];
620 sQxsp[istat][imod][NXYsp[istat][imod]] = sQx[istat][imod][clx];
621
622 Xpsp[istat][imod][NXYsp[istat][imod]] = XpCoor[istat][imod][clxp];
623 SigspXp[istat][imod][NXYsp[istat][imod]] = SigmXp[istat][imod][clxp];
624 XpspCl[istat][imod][NXYsp[istat][imod]] = XpCl[istat][imod][clxp];
625 XpspCl_width[istat][imod][NXYsp[istat][imod]] = XpCl_width[istat][imod][clxp];
626 sQxpsp[istat][imod][NXYsp[istat][imod]] = sQxp[istat][imod][clxp];
627
628 Ysp[istat][imod][NXYsp[istat][imod]] = YCoor_cand;
629 SigspY[istat][imod][NXYsp[istat][imod]] =
630 sqrt(pow(SigmX[istat][imod][clx], 2) + pow(SigmXp[istat][imod][clxp], 2)) / tg2_5;
631 NXYsp[istat][imod]++;
632 }
633 // if (fDebug) cout<<" NXYsp["<<istat<<"]["<<imod<<"] "<<NXYsp[istat][imod]<<endl;
634
635 } // if X & Y > -900
636 } // NClXp
637 } // NClX
638 // cout<<" NXYsp= "<<NXYsp[istat]<<endl;
639 } // imod
640 } // istat
641 // if (fDebug) cout<<" end GetXYspatial "<<endl;
642} //
643//----------------------------------------------------------------------
644
645//------------------Cluster search function-----------------------------
646
648 Double_t*** DigitsArrayXp_,
649 Double_t*** XClust_,
650 Double_t*** XClust_width_,
651 Double_t*** sumQx_,
652 Int_t** NclustX_,
653 Double_t*** XpClust_,
654 Double_t*** XpClust_width_,
655 Double_t*** sumQxp_,
656 Int_t** NclustXp_)
657{
658 // if (fDebug) cout<<" start clustering "<<endl;
659 Double_t CoG;
660 // Int_t Strip_counterX;
661
662 /*
663 for (Int_t istat = 0; istat < fNstations; istat++) {
664 for (Int_t imod = 0; imod < fNmodules; imod++) {
665 // if (fDebug) cout<<" NclustX_["<<istat<<"]["<<imod<<"] "<<NclustX_[istat][imod]<<endl;
666 for (Int_t istr = 0; istr < fNstrips; istr++) {
667 if( DigitsArrayX_[istat][imod][istr] > 0.) printf("DigitsArrayX[%d][%d][%d] = %8.4f\n", istat, imod, istr,
668 DigitsArrayX_[istat][imod][istr]);
669 }
670 }
671 }
672 */
673
674 // Int_t counter_strx_mod=0;
675 // Int_t indX = 0;
676
677 for (Int_t istat = 1; istat < fNstations; istat++) {
678 for (Int_t imod = 0; imod < fNmodules; imod++) {
679 for (Int_t istr = 0; istr < fNstrips; istr++) {
680 if (istat == 1 && imod > 3)
681 continue;
682 if (istat == 2 && imod > 1)
683 continue;
684
685 if (fDebug && istat == 1 && DigitsArrayX_[istat][imod][istr] > 0.)
686 hoccupancyX1.at(imod)->Fill(istr);
687 if (fDebug && istat == 2 && DigitsArrayX_[istat][imod][istr] > 0.)
688 hoccupancyX2.at(imod)->Fill(istr);
689 if (fDebug && istat == 3 && DigitsArrayX_[istat][imod][istr] > 0.)
690 hoccupancyX3.at(imod)->Fill(istr);
691
692 if (fDebug && istat == 1 && DigitsArrayXp_[istat][imod][istr] > 0.)
693 hoccupancyXp1.at(imod)->Fill(istr);
694 if (fDebug && istat == 2 && DigitsArrayXp_[istat][imod][istr] > 0.)
695 hoccupancyXp2.at(imod)->Fill(istr);
696 if (fDebug && istat == 3 && DigitsArrayXp_[istat][imod][istr] > 0.)
697 hoccupancyXp3.at(imod)->Fill(istr);
698
699 if (DigitsArrayX_[istat][imod][istr] == 0. && DigitsArrayX_[istat][imod][istr - 1] > Cut_AmplX
700 && DigitsArrayX_[istat][imod][istr + 1] > Cut_AmplX)
701 DigitsArrayX_[istat][imod][istr] =
702 0.5 * (DigitsArrayX_[istat][imod][istr - 1] + DigitsArrayX_[istat][imod][istr + 1]);
703
704 if (istat == 1 && imod == 0) {
705 // dead zone 405-412 strips
706 if (DigitsArrayX_[istat][imod][404] > Cut_AmplX)
707 DigitsArrayX_[istat][imod][405] = 0.5 * DigitsArrayX_[istat][imod][404];
708 if (DigitsArrayX_[istat][imod][413] > Cut_AmplX)
709 DigitsArrayX_[istat][imod][412] = 0.5 * DigitsArrayX_[istat][imod][413];
710 }
711
712 if (DigitsArrayXp_[istat][imod][istr] == 0. && DigitsArrayXp_[istat][imod][istr - 1] > 120.
713 && DigitsArrayXp_[istat][imod][istr + 1] > 120.)
714 DigitsArrayXp_[istat][imod][istr] =
715 0.5 * (DigitsArrayXp_[istat][imod][istr - 1] + DigitsArrayXp_[istat][imod][istr + 1]);
716 }
717 }
718 }
719
720 Int_t NfirstX, NlastX, NfirstXp, NlastXp, ClusterSizeX, ClusterSizeXp;
721 Double_t SumAmpl, SumAmplXp;
722
723 for (Int_t istat = 1; istat < fNstations; istat++) {
724
725 for (Int_t imod = 0; imod < fNmodules; imod++) {
726 NfirstX = -1;
727 NlastX = -1;
728 ClusterSizeX = 0;
729 SumAmpl = 0.;
730 // Strip_counterX = 0;
731
732 // if ( fDebug) cout<<"----x-----"<<endl;
733 for (Int_t istr = 0; istr < fNstrips; istr++) {
734
735 // if ( fDebug && DigitsArrayX_[istat][imod][istr] > 0.) cout<<"
736 // DigitsArrayX_["<<istat<<"]["<<imod<<"]["<<istr<<"] "<<DigitsArrayX_[istat][imod][istr]<<endl;
737
738 // looking for start and end of cluster
739 if (NfirstX < 0 && DigitsArrayX_[istat][imod][istr] == 0.)
740 continue;
741 if (NfirstX < 0 && DigitsArrayX_[istat][imod][istr] > 0.)
742 NfirstX = istr;
743 if (NfirstX >= 0 && DigitsArrayX_[istat][imod][istr + 1] == 0.)
744 NlastX = istr;
745
746 if (NfirstX >= 0 && NlastX > 0) {
747 // if(fDebug) cout<<" NfirstX "<<NfirstX<<" NlastX "<<NlastX<<endl;
748 Int_t max_ampl_strip = -1, num_max_ampl_strip = -1,
749 // num_left_strip = 0,
750 // num_right_strip = 0,
751 num_centr_strip = -1;
752
753 ClusterSizeX = NlastX - NfirstX + 1;
754 // if ( fDebug) hClusterSizeX[istat][imod]->Fill(ClusterSizeX);
755 SumAmpl = 0.;
756 Int_t Counter_overflow = 0;
757
758 for (Int_t is = NfirstX; is < NlastX + 1; is++) {
759 Ampl_strX[is - NfirstX] = DigitsArrayX_[istat][imod][is];
760
761 if (DigitsArrayX_[istat][imod][is] > Cut_overflow)
762 Counter_overflow++;
763
764 if (DigitsArrayX_[istat][imod][is] > max_ampl_strip) {
765 max_ampl_strip = DigitsArrayX_[istat][imod][is];
766 num_max_ampl_strip = is;
767 }
768 // calculate center of cluster
769 CoG = FindClusterCenter(Ampl_strX, ClusterSizeX, SumAmpl);
770 // if(fDebug) cout<<" CoG "<<CoG <<endl;
771 }
772
773 for (Int_t is = NfirstX; is < NlastX + 1; is++) {
774 if (max_ampl_strip > 0) {
775
776 // Int_t dif_ampl = DigitsArrayX_[istat][imod][is] - max_ampl_strip;
777 Int_t dif_strip = is - num_max_ampl_strip;
778 if (dif_strip == 0)
779 num_centr_strip = is;
780 // if ( dif_strip == 1) num_right_strip = is;
781 // if ( dif_strip == -1) num_left_strip = is;
782 }
783 }
784
785 // if(fDebug) cout<<" ampl_centr strip "<<DigitsArrayX_[istat][imod][num_centr_strip]<<"
786 // Cut_AmplStripX "<<Cut_AmplStripX<<endl;
787 if (num_centr_strip > 0 && DigitsArrayX_[istat][imod][num_centr_strip] < Cut_AmplStripX) {
788 // if(fDebug) cout<<" num_centr_strip > Cut_AmplStripX "<<endl;
789 NfirstX = -1;
790 NlastX = -1;
791 continue;
792 }
793
794 if (SumAmpl < Cut_AmplX) {
795 NfirstX = -1;
796 NlastX = -1;
797 continue;
798 }
799
800 // if(fDebug) cout<<" NfirstX "<<NfirstX<<" CoG "<<CoG<<" NfirstX + CoG "<<NfirstX + CoG<<endl;
801
802 XClust_[istat][imod][NclustX_[istat][imod]] = NfirstX + CoG;
803 XClust_width_[istat][imod][NclustX_[istat][imod]] = ClusterSizeX;
804 sumQx_[istat][imod][NclustX_[istat][imod]] = SumAmpl;
805 // if(fDebug) cout<<" NclustX_["<<istat<<"]["<<imod<<"] "<<NclustX_[istat][imod]<<" NfX
806 // "<<NfirstX<<" NlX "<<NlastX<<" ClustSizeX "<<ClusterSizeX<<" XClust_
807 // "<<XClust_[istat][imod][NclustX_[istat][imod]]<<endl;
808
809 NclustX_[istat][imod]++;
810 // if(fDebug) cout<<" NclustX_["<<istat<<"]["<<imod<<"] "<<NclustX_[istat][imod]<<endl;
811
812 NfirstX = -1;
813 NlastX = -1;
814
815 // if ( fDebug) hNclustX[istat][imod]->Fill(NclustX_[istat][imod]);
816 } // if (NfirstX >= 0 && NlastX > 0){
817 } // end loop over X
818
819 if (NclustX_[istat][imod] == 0)
820 continue;
821
822 NfirstXp = -1;
823 NlastXp = -1;
824 ClusterSizeXp = 0;
825 SumAmplXp = 0.;
826 // if ( fDebug) cout<<"----xp-----"<<endl;
827 for (Int_t istr = 0; istr < fNstrips; istr++) {
828
829 // if ( fDebug && DigitsArrayXp_[istat][imod][istr] > 0.) cout<<"
830 // DigitsArrayXp_["<<istat<<"]["<<imod<<"]["<<istr<<"] "<<DigitsArrayXp_[istat][imod][istr]<<endl;
831
832 // looking for start and end of cluster
833 if (NfirstXp < 0 && DigitsArrayXp_[istat][imod][istr] == 0.)
834 continue;
835 if (NfirstXp < 0 && DigitsArrayXp_[istat][imod][istr] > 0.)
836 NfirstXp = istr;
837 if (NfirstXp >= 0 && DigitsArrayXp_[istat][imod][istr + 1] == 0.)
838 NlastXp = istr;
839
840 if (NfirstXp >= 0 && NlastXp > 0) {
841
842 Int_t max_ampl_strip = -1, num_max_ampl_strip = -1,
843 // num_left_strip = 0,
844 // num_right_strip = 0,
845 num_centr_strip = -1;
846
847 ClusterSizeXp = NlastXp - NfirstXp + 1;
848 // if ( fDebug) hClusterSizeXp[istat][imod]->Fill(ClusterSizeXp);
849 SumAmplXp = 0.;
850 Int_t Counter_overflow = 0;
851
852 for (Int_t is = NfirstXp; is < NlastXp + 1; is++) {
853 Ampl_strXp[is - NfirstXp] = DigitsArrayXp_[istat][imod][is];
854
855 if (DigitsArrayXp_[istat][imod][is] > Cut_overflow)
856 Counter_overflow++;
857
858 if (DigitsArrayXp_[istat][imod][is] > max_ampl_strip) {
859 max_ampl_strip = DigitsArrayXp_[istat][imod][is];
860 num_max_ampl_strip = is;
861 }
862
863 // calculate center of cluster
864 CoG = FindClusterCenter(Ampl_strXp, ClusterSizeXp, SumAmplXp);
865 }
866
867 for (Int_t is = NfirstX; is < NlastX + 1; is++) {
868 if (max_ampl_strip > 0) {
869 // Int_t dif_ampl = DigitsArrayXp_[istat][imod][is] - max_ampl_strip;
870 Int_t dif_strip = is - num_max_ampl_strip;
871 if (dif_strip == 0)
872 num_centr_strip = is;
873 // if ( dif_strip == 1) num_right_strip = is;
874 // if ( dif_strip == -1) num_left_strip = is;
875 }
876 }
877
878 // if ( fDebug) hsumQ_vs_clusterSize[istat][imod][1]->Fill(ClusterSizeXp, SumAmplXp);
879 // if ( fDebug && SumAmplXp > 0)
880 // hsumQ[istat][imod][1]->Fill(log10(float(SumAmplXp))/log10(float(2)));//Fill(SumAmplXp);
881
882 if (num_centr_strip > 0 && DigitsArrayXp_[istat][imod][num_centr_strip] < Cut_AmplStripXp) {
883 // if(fDebug) cout<<" num_centr_strip > Cut_AmplStripX "<<endl;
884 NfirstXp = -1;
885 NlastXp = -1;
886 continue;
887 }
888
889 if (SumAmplXp < Cut_AmplXp) {
890 NfirstXp = -1;
891 NlastXp = -1;
892 continue;
893 }
894 /*
895 if ( Counter_overflow >= 2 ) {
896 NfirstXp = -1;
897 NlastXp = -1;
898 continue;
899 }
900 */
901 // if(fDebug) cout<<" NfirstXp "<<NfirstXp<<" CoG "<<CoG<<" NfirstXp + CoG "<<NfirstXp + CoG<<endl;
902 XpClust_[istat][imod][NclustXp_[istat][imod]] = NfirstXp + CoG;
903 XpClust_width_[istat][imod][NclustXp_[istat][imod]] = ClusterSizeXp;
904 sumQxp_[istat][imod][NclustXp_[istat][imod]] = SumAmplXp;
905 NclustXp_[istat][imod]++;
906 // if ( fDebug) cout<<"NclustXp_["<<istat<<"]["<<imod<<"] "<<NclustXp_[istat][imod]<<endl;
907
908 NfirstXp = -1;
909 NlastXp = -1;
910 } // if (NfirstXp >= 0 && NlastXp > 0)
911 // if ( fDebug) hNclustXp[istat][imod]->Fill(NclustXp_[istat][imod]);
912 } // end loop over Xp
913 } // mod
914
915 } // end loop over station
916}
917//---clustering. -------------------------------------------------------
918
919//--------------CoordinateCalculation-----------------------------------
921 Int_t** NclustXp_,
922 Double_t*** XCoord_,
923 Double_t*** XpCoord_,
924 Double_t*** SigmaX_,
925 Double_t*** SigmaXp_,
926 Double_t*** XspCoord_,
927 Double_t*** XpspCoord_,
928 Double_t*** YspCoord_,
929 Double_t*** SigmspX_,
930 Double_t*** SigmspXp_,
931 Double_t*** SigmspY_,
932 Int_t** NhitsXYmod_,
933 Double_t*** XClust_,
934 Double_t*** XClust_width_,
935 Double_t*** sumQx_,
936 Double_t*** XpClust_,
937 Double_t*** XpClust_width_,
938 Double_t*** sumQxp_,
939 Double_t*** XspClust_,
940 Double_t*** XspClust_width_,
941 Double_t*** sumQxsp_,
942 Double_t*** XpspClust_,
943 Double_t*** XpspClust_width_,
944 Double_t*** sumQxpsp_,
945 vector<MC_points>& vec,
946 Int_t*** Sp_pdg_)
947{
948
949 if (expData) {
950 // move X and Xp coordinates on frame size
951 for (Int_t ist = 1; ist < fNstations; ist++) {
952 for (Int_t imod = 0; imod < fNmodules; imod++) {
953 if (ist == 1 && imod > 3)
954 continue;
955 if (ist == 2 && imod > 1)
956 continue;
957 // if(fDebug && NclustX_[ist][imod] > 0) cout<<" NclustX_["<<ist<<"]["<<imod<<"]
958 // "<<NclustX_[ist][imod]<<" NclustXp_["<<ist<<"]["<<imod<<"] "<<NclustXp_[ist][imod]<<endl;
959 for (Int_t cl = 0; cl < NclustX_[ist][imod]; cl++) {
960 XCoord_[ist][imod][cl] = deltaX * XClust_[ist][imod][cl]; // cm
961 if (XClust_width[ist][imod][cl] > 1)
962 SigmaX_[ist][imod][cl] = (XClust_width_[ist][imod][cl] * deltaX) / (2. * sq12); // VP empiric
963 else
964 SigmaX_[ist][imod][cl] = deltaX / sq12;
965 // SigmaX_[ist][imod][cl] = (XClust_width_[ist][imod][cl] * deltaX) / sq12;
966
967 // if(fDebug) cout<<" XCoord_["<<ist<<"]["<<imod<<"]["<<cl<<"] "<<XCoord_[ist][imod][cl]<<" Sigma
968 // "<<SigmaX_[ist][imod][cl]<<endl; if(fDebug) cout<<" XCoord_["<<ist<<"]["<<imod<<"]["<<cl<<"]
969 // "<<XCoord_[ist][imod][cl]<<endl;
970 }
971
972 for (Int_t cl = 0; cl < NclustXp_[ist][imod]; cl++) {
973 XpCoord_[ist][imod][cl] = deltaXp * XpClust_[ist][imod][cl]; // cm
974 if (XpClust_width[ist][imod][cl] > 1)
975 SigmaXp_[ist][imod][cl] =
976 (XpClust_width_[ist][imod][cl] * deltaXp) / (2. * sq12); // VP empiric
977 else
978 SigmaXp_[ist][imod][cl] = deltaXp / sq12;
979 // SigmaXp_[ist][imod][cl] = (XpClust_width_[ist][imod][cl] * deltaXp) / sq12;
980 // if(fDebug) cout<<"XpCoord_["<<ist<<"]["<<imod<<"]["<<cl<<"] "<<XpCoord_[ist][imod][cl]<<" Sigma
981 // "<<SigmaXp_[ist][imod][cl]<<endl;
982 // if(fDebug) cout<<"XpCoord_["<<ist<<"]["<<imod<<"]["<<cl<<"] "<<XpCoord_[ist][imod][cl]<<endl;
983 }
984 } // imod
985 // if(fDebug) cout<<endl;
986 } // ist
987
988 /*
989 if (fDebug) cout << endl;
990 for (Int_t ist = 1; ist < fNstations; ist++) {
991 if (fDebug) cout << " XCoord_[" << ist << "] ";
992 for (Int_t imod = 0; imod < fNmodules; imod++) {
993 for (Int_t cl = 0; cl < NclustX_[ist][imod]; cl++) {
994 if (fDebug) cout << XCoord_[ist][imod][cl] << " ";
995 }
996 }
997 if (fDebug) cout << endl;
998 }
999 if (fDebug) cout << endl;
1000 for (Int_t ist = 1; ist < fNstations; ist++) {
1001 if (fDebug) cout << " XpCoord_[" << ist << "] ";
1002 for (Int_t imod = 0; imod < fNmodules; imod++) {
1003 for (Int_t cl = 0; cl < NclustXp_[ist][imod]; cl++) {
1004 if (fDebug) cout << XpCoord_[ist][imod][cl] << " ";
1005 }
1006 }
1007 if (fDebug) cout << endl;
1008 }
1009
1010 if (fDebug) cout<<" GetXYspatial "<<endl;
1011 */
1012 GetXYspatial(NclustX_, NclustXp_, XCoord_, XpCoord_, XspCoord_, XpspCoord_, YspCoord_, NhitsXYmod_, SigmaX_,
1013 SigmaXp_, SigmspX_, SigmspXp_, SigmspY_, XClust_, XClust_width_, sumQx_, XpClust_, XpClust_width_,
1014 sumQxp_, XspClust_, XspClust_width_, sumQxsp_, XpspClust_, XpspClust_width_, sumQxpsp_);
1015
1016 /*
1017 for(Int_t ist = 1; ist < fNstations; ist++) {
1018 if(fDebug) cout<<" Xspatial["<<ist<<"] ";
1019 for (Int_t imod = 0; imod < fNmodules; imod++) {
1020 if (ist == 1 && imod > 3 ) continue;
1021 if (ist == 2 && imod > 1 ) continue;
1022
1023 for (Int_t cl = 0; cl < NhitsXYmod_[ist][imod]; cl++) {
1024 if(fDebug) cout<<XspCoord_[ist][imod][cl]<<" ";
1025 }
1026 }
1027 if(fDebug) cout<<endl;
1028 }
1029 if(fDebug) cout<<endl;
1030
1031 for(Int_t ist = 1; ist < fNstations; ist++) {
1032 if(fDebug) cout<<" Xpspatial["<<ist<<"] ";
1033 for (Int_t imod = 0; imod < fNmodules; imod++) {
1034 if (ist == 1 && imod > 3 ) continue;
1035 if (ist == 2 && imod > 1 ) continue;
1036
1037 for (Int_t cl = 0; cl < NhitsXYmod_[ist][imod]; cl++) {
1038 if(fDebug) cout<<XpspCoord_[ist][imod][cl]<<" ";
1039 }
1040 }
1041 if(fDebug) cout<<endl;
1042 }
1043 if(fDebug) cout<<endl;
1044
1045 for(Int_t ist = 1; ist < fNstations; ist++) {
1046 if(fDebug) cout<<" Yspatial["<<ist<<"] ";
1047 for (Int_t imod = 0; imod < fNmodules; imod++) {
1048 if (ist == 1 && imod > 3 ) continue;
1049 if (ist == 2 && imod > 1 ) continue;
1050
1051 for (Int_t cl = 0; cl < NhitsXYmod_[ist][imod]; cl++) {
1052 if(fDebug) cout<<YspCoord_[ist][imod][cl]<<" SigmspY_"<<SigmspY_[ist][imod][cl] <<" ";
1053 }
1054 }
1055 if(fDebug) cout<<endl;
1056 }
1057 if(fDebug) cout<<endl;
1058 */
1059
1060 } else { //--------------------MC------------------------------------------
1061
1062 MC_points tmpTr;
1063 if (fDebug)
1064 cout << " Sim: " << endl;
1065 for (Int_t iMC = 0; iMC < fBmnHitsArray2->GetEntriesFast(); ++iMC) {
1066 BmnSiliconHit* hit = (BmnSiliconHit*)fBmnHitsArray2->UncheckedAt(iMC);
1067
1068 Double_t x_MC = hit->GetX();
1069 Double_t xp_MC = hit->GetY();
1070 Double_t z_MC = hit->GetZ();
1071 Int_t Id = hit->GetIndex();
1072 Int_t st_mc = -1;
1073 Double_t sigx_MC = hit->GetDx();
1074 Double_t sigxp_MC = hit->GetDy();
1075
1076 if (sigx_MC < 0)
1077 sigx_MC = -sigx_MC;
1078 if (sigxp_MC < 0)
1079 sigxp_MC = -sigxp_MC;
1080
1081 if (z_MC > -320.) {
1082 st_mc = 3;
1083 if (fDebug)
1084 hSi_st3mc->Fill(x_MC, (xp_MC - x_MC) / tg2_5);
1085 }
1086 if (z_MC < -434. && z_MC > -436.) {
1087 st_mc = 2;
1088 if (fDebug)
1089 hSi_st2mc->Fill(x_MC, (xp_MC - x_MC) / tg2_5);
1090 }
1091 if (z_MC < -438.) {
1092 st_mc = 1;
1093 if (fDebug)
1094 hSi_st1mc->Fill(x_MC, (xp_MC - x_MC) / tg2_5);
1095 }
1096 int imod = 2;
1097 if (st_mc == 2)
1098 imod = 1;
1099
1100 XCoord_[st_mc][imod][NclustX[st_mc][imod]] = x_MC;
1101 XpCoord_[st_mc][imod][NclustXp[st_mc][imod]] = xp_MC;
1102 SigmaX_[st_mc][imod][NclustXp[st_mc][imod]] = sigx_MC;
1103 SigmaXp_[st_mc][imod][NclustXp[st_mc][imod]] = sigxp_MC;
1104 NclustX_[st_mc][imod]++;
1105 NclustXp_[st_mc][imod]++;
1106
1107 XspCoord_[st_mc][imod][NhitsXYmod[st_mc][imod]] = x_MC;
1108 if (xp_MC > -900.)
1109 XpspCoord_[st_mc][imod][NhitsXYmod[st_mc][imod]] = xp_MC;
1110 YspCoord_[st_mc][imod][NhitsXYmod[st_mc][imod]] = (xp_MC - x_MC) / tg2_5;
1111 Sp_pdg_[st_mc][imod][NhitsXYmod[st_mc][imod]] = hit->GetType();
1112 SigmspX_[st_mc][imod][NhitsXYmod[st_mc][imod]] = sigx_MC;
1113 SigmspXp_[st_mc][imod][NhitsXYmod[st_mc][imod]] = sigxp_MC;
1114 SigmspY_[st_mc][imod][NhitsXYmod[st_mc][imod]] = sqrt(pow(sigx_MC, 2) + pow(sigxp_MC, 2)) / tg2_5;
1115 if (fDebug)
1116 cout << " Id " << Id << " x " << x_MC << " xp " << xp_MC << " y "
1117 << YspCoord_[st_mc][imod][NhitsXYmod[st_mc][imod]] << " z_MC " << z_MC << " st_mc " << st_mc
1118 << " pdg " << hit->GetType() << endl;
1119
1120 NhitsXYmod_[st_mc][imod]++;
1121 // if (fDebug) cout<<" NhitsXYmod["<<st_mc<<"] "<<NhitsXYmod[st_mc][imod]<<endl;
1122 } // iMC
1123
1124 if (fDebug)
1125 cout << "True MC BmnSiliconHitClean" << endl;
1126 int tr_before = -1;
1127 int Nmc_tracks = -1;
1128
1129 int Nst_mc[kMaxMC];
1130 int Np_in_3st[kMaxMC];
1131 int mcTracksArray[kMaxMC];
1132 int mcPdgCode[kMaxMC];
1133 double Xmc[kMaxMC][fNstations];
1134 double Ymc[kMaxMC][fNstations];
1135 double Zmc[kMaxMC][fNstations];
1136 for (Int_t Id = 0; Id < kMaxMC; Id++) {
1137 Nst_mc[Id] = 0;
1138 Np_in_3st[Id] = 0;
1139 mcTracksArray[Id] = -1;
1140 mcPdgCode[Id] = 0;
1141 for (Int_t i = 0; i < fNstations; i++) {
1142 Xmc[Id][i] = -999.;
1143 Ymc[Id][i] = -999.;
1144 Zmc[Id][i] = -999.;
1145 }
1146 }
1147
1148 for (Int_t iMC = 0; iMC < fBmnHitsArray->GetEntriesFast(); ++iMC) {
1149 BmnSiliconHit* hit = (BmnSiliconHit*)fBmnHitsArray->UncheckedAt(iMC);
1150
1151 Double_t x_MC = hit->GetX();
1152 Double_t y_MC = hit->GetY();
1153 Double_t z_MC = hit->GetZ();
1154 Int_t trackId_MC = hit->GetIndex();
1155 Int_t st_mc = -1;
1156 Int_t pdgCode = hit->GetType(); // pdg
1157
1158 if (tr_before != trackId_MC) {
1159 Nmc_tracks++;
1160 mcTracksArray[Nmc_tracks] = trackId_MC;
1161 }
1162 tr_before = trackId_MC;
1163
1164 if (z_MC > -320.) {
1165 st_mc = 3;
1166 Np_in_3st[Nmc_tracks]++;
1167 }
1168 if (z_MC < -434. && z_MC > -436.)
1169 st_mc = 2;
1170 if (z_MC < -438.)
1171 st_mc = 1;
1172 if (fDebug)
1173 cout << " pdgId " << trackId_MC << " pdgCode " << pdgCode << " x " << x_MC << " y " << y_MC << " z "
1174 << z_MC << " st_mc " << st_mc << endl;
1175
1176 Xmc[Nmc_tracks][st_mc] = x_MC;
1177 Ymc[Nmc_tracks][st_mc] = y_MC;
1178 Zmc[Nmc_tracks][st_mc] = z_MC;
1179 mcPdgCode[Nmc_tracks] = pdgCode;
1180 Nst_mc[Nmc_tracks]++;
1181
1182 } // iMC
1183 Nmc_tracks++;
1184
1185 for (Int_t Id = 0; Id < kMaxMC; Id++) {
1186 if (Nst_mc[Id] > 0) {
1187 for (Int_t i = 0; i < fNstations; i++) {
1188 tmpTr.x[i] = Xmc[Id][i];
1189 tmpTr.y[i] = Ymc[Id][i];
1190 tmpTr.z[i] = Zmc[Id][i];
1191 }
1192 tmpTr.Id = mcTracksArray[Id];
1193 tmpTr.Np = Nst_mc[Id];
1194 tmpTr.Pdg = mcPdgCode[Id];
1195 if (Nst_mc[Id] >= 2 && Np_in_3st[Id] > 0)
1196 vec.push_back(tmpTr);
1197 }
1198 }
1199
1200 if (fDebug)
1201 cout << " vec_points.size() " << vec.size() << endl;
1202
1203 for (size_t itr = 0; itr < vec.size(); itr++) {
1204 // if (fDebug) cout<<" itr "<<itr<<" Pdg "<<vec.at(itr).Pdg<<endl;
1205 if (vec.at(itr).x[3] < -900.)
1206 vec.at(itr).wo3st = 1;
1207 if (vec.at(itr).x[1] > -900.) {
1208 vec.at(itr).param[0] = (vec.at(itr).x[1] - vec.at(itr).x[3]) / (vec.at(itr).z[1] - vec.at(itr).z[3]);
1209 vec.at(itr).param[1] = (vec.at(itr).x[1] + vec.at(itr).x[3]) * 0.5;
1210 vec.at(itr).param[2] = (vec.at(itr).y[1] - vec.at(itr).y[3]) / (vec.at(itr).z[1] - vec.at(itr).z[3]);
1211 vec.at(itr).param[3] = (vec.at(itr).y[1] + vec.at(itr).y[3]) * 0.5;
1212 } else {
1213 vec.at(itr).param[0] = (vec.at(itr).x[2] - vec.at(itr).x[3]) / (vec.at(itr).z[2] - vec.at(itr).z[3]);
1214 vec.at(itr).param[1] = (vec.at(itr).x[2] + vec.at(itr).x[3]) * 0.5;
1215 vec.at(itr).param[2] = (vec.at(itr).y[2] - vec.at(itr).y[3]) / (vec.at(itr).z[2] - vec.at(itr).z[3]);
1216 vec.at(itr).param[3] = (vec.at(itr).y[2] + vec.at(itr).y[3]) * 0.5;
1217 }
1218 if (fDebug)
1219 cout << " mcId " << vec.at(itr).Id << " Pdg " << vec.at(itr).Pdg << " Ax " << vec.at(itr).param[0]
1220 << " bx " << vec.at(itr).param[1] << " Ay " << vec.at(itr).param[2] << " by "
1221 << vec.at(itr).param[3] << " Np " << vec.at(itr).Np << endl;
1222 if (fDebug)
1223 cout << " Xt " << vec.at(itr).param[0] * (Z0_SRC_target - Zcentr) + vec.at(itr).param[1] << " Yt "
1224 << vec.at(itr).param[2] * (Z0_SRC_target - Zcentr) + vec.at(itr).param[3] << endl;
1225
1226 if (fDebug)
1227 hAxsi_mctrue->Fill(vec.at(itr).param[0]);
1228 if (fDebug)
1229 hAysi_mctrue->Fill(vec.at(itr).param[2]);
1230 if (fDebug)
1231 hBxsi_mctrue->Fill(vec.at(itr).param[1]);
1232 if (fDebug)
1233 hBysi_mctrue->Fill(vec.at(itr).param[3]);
1234 }
1235
1236 } // if(!expData)
1237}
1238//----------------------------------------------------------------------
1239
1240//-------------------Alignment------------------------------------------
1242 Double_t*** XspCoord_,
1243 Double_t*** XpspCoord_,
1244 Double_t*** YspCoord_,
1245 Int_t** NclustX_,
1246 Int_t** NclustXp_,
1247 Double_t*** XCoord_,
1248 Double_t*** XpCoord_)
1249{
1250 // if (fDebug) cout<<" Shift coordinates "<<endl;
1251
1252 for (Int_t ist = 1; ist < fNstations; ist++) {
1253 // if ( fDebug ) cout<<" shiftStXtoGlob["<<ist<<"]= "<<shiftStXtoGlob[ist]<<" Y "<< shiftStYtoGlob[ist]<<endl;
1254 for (Int_t imod = 0; imod < fNmodules; imod++) {
1255 // if ( fDebug ) cout<<" ist "<<ist<<" imod "<<imod<<endl;
1256 if (ist == 1 && imod > 3)
1257 continue;
1258 if (ist == 2 && imod > 1)
1259 continue;
1260 // if ( fDebug ) cout<<" shiftX["<<ist<<"]["<<imod<<"]= "<<shiftX[ist][imod]<<"
1261 // shiftY["<<ist<<"]["<<imod<<"]= "<<shiftY[ist][imod]<<endl;
1262 }
1263 }
1264
1265 if (fRunPeriod == 7) {
1266
1267 for (Int_t ist = 1; ist < fNstations; ist++) {
1268 for (Int_t imod = 0; imod < fNmodules; imod++) {
1269 if (ist == 1 && imod > 3)
1270 continue;
1271 if (ist == 2 && imod > 1)
1272 continue;
1273 for (Int_t cl = 0; cl < NhitsXYmod_[ist][imod]; cl++) {
1274
1275 if ((ist == 2 || ist == 3)) { // gap between Si planes
1276 if (YspCoord_[ist][imod][cl] > 0. && YspCoord_[ist][imod][cl] <= 0.1151)
1277 continue;
1278 if (YspCoord_[ist][imod][cl] < 0. && YspCoord_[ist][imod][cl] >= -0.1151)
1279 continue;
1280 if (YspCoord_[ist][imod][cl] > 0.)
1281 YspCoord_[ist][imod][cl] += 0.1151;
1282 }
1283 // rotate around X
1284 if ((ist == 1 && (imod == 1 || imod == 3)) || (ist == 2 && imod == 1)
1285 || (ist == 3 && (imod == 2 || imod == 3 || imod == 6 || imod == 7))
1286
1287 )
1288 {
1289 XspCoord_[ist][imod][cl] = -XspCoord_[ist][imod][cl];
1290 XpspCoord_[ist][imod][cl] = -XpspCoord_[ist][imod][cl];
1291 }
1292 // if(fDebug) cout<<" 2 "<<endl;
1293 // if(fDebug) cout<<" after X -> -X "<<endl;
1294 // if(fDebug) cout<<ist<<","<<imod<<" X "<<XspCoord_[ist][imod][cl] <<" Y
1295 // "<<YspCoord_[ist][imod][cl]<<endl;
1296
1297 // rotate around Y
1298 if ((ist == 1 && (imod == 2 || imod == 3)) || (ist == 3 && imod > 3)) {
1299 YspCoord_[ist][imod][cl] = -YspCoord_[ist][imod][cl];
1300 }
1301 // if(fDebug) cout<<" after Y -> -Y "<<endl;
1302 // if(fDebug) cout<<ist<<","<<imod<<" X "<<XspCoord_[ist][imod][cl] <<endl;
1303 // if(fDebug) cout<<" Y "<<YspCoord_[ist][imod][cl]<<endl;
1304 // if(fDebug) cout<<" shift "<<shiftX[ist][imod]<<endl;
1305 // if(fDebug) cout<<" 3 "<<endl;
1306
1307 XspCoord_[ist][imod][cl] += shiftX[ist][imod];
1308 YspCoord_[ist][imod][cl] += shiftY[ist][imod];
1309
1310 // change the sign to global coord
1311 XspCoord_[ist][imod][cl] = -XspCoord_[ist][imod][cl];
1312 // if(fDebug) hXYspatial[ist]->Fill(XspCoord_[ist][imod][cl], YspCoord_[ist][imod][cl]);
1313 // if(fDebug) cout<<" 4 "<<endl;
1314 //--shift Xp---
1315 // shift from Zubarev
1316 XpspCoord_[ist][imod][cl] += shiftY[ist][imod] * (-Angle(ist, imod)) * tg2_5 + shiftX[ist][imod];
1317 // change global X
1318 XpspCoord_[ist][imod][cl] = -XpspCoord_[ist][imod][cl];
1319 // shift from Kolesnikov
1320 XpspCoord_[ist][imod][cl] += shiftStYtoGlob[ist] * (Angle(ist, imod))*tg2_5 + shiftStXtoGlob[ist];
1321 // if(fDebug) cout<<" 5 "<<endl;
1322 //---shift X Y to global---
1323 XspCoord_[ist][imod][cl] += shiftStXtoGlob[ist];
1324 YspCoord_[ist][imod][cl] += shiftStYtoGlob[ist];
1325
1326 // if(fDebug){
1327 // hYspatialst[ist]-> Fill( YspCoord_[ist][imod][cl]);
1328 // cout<<" after shift in the end"<<endl;
1329 // cout<<" X "<<XspCoord_[ist][imod][cl] <<" Y "<<YspCoord_[ist][imod][cl]<<endl;
1330 // }
1331 } // cl
1332 } // imod
1333 } // ist
1334
1335 for (Int_t ist = 1; ist < fNstations; ist++) {
1336 for (Int_t imod = 0; imod < fNmodules; imod++) {
1337 if (ist == 1 && imod > 3)
1338 continue;
1339 if (ist == 2 && imod > 1)
1340 continue;
1341
1342 for (Int_t cl = 0; cl < NclustX_[ist][imod]; cl++) {
1343 if ((ist == 1 && (imod == 1 || imod == 3)) || (ist == 2 && imod == 1)
1344 || (ist == 3 && (imod == 2 || imod == 3 || imod == 6 || imod == 7)))
1345 {
1346 XCoord_[ist][imod][cl] = -XCoord_[ist][imod][cl];
1347 }
1348 XCoord_[ist][imod][cl] += shiftX[ist][imod];
1349
1350 // change the sign to global coord
1351 XCoord_[ist][imod][cl] = -XCoord_[ist][imod][cl];
1352 XCoord_[ist][imod][cl] += shiftStXtoGlob[ist];
1353 } // xcl
1354
1355 for (Int_t cl = 0; cl < NclustXp_[ist][imod]; cl++) {
1356 // rotate around X
1357 if ((ist == 1 && (imod == 1 || imod == 3)) || (ist == 2 && imod == 1)
1358 || (ist == 3 && (imod == 2 || imod == 3 || imod == 6 || imod == 7)))
1359 {
1360 XpCoord_[ist][imod][cl] = -XpCoord_[ist][imod][cl];
1361 }
1362 // if(fDebug) cout<<" after Xp -> -Xp "<<endl;
1363 // if(fDebug) cout<<ist<<","<<imod<<" Xp "<<XpCoord_[ist][imod][cl] <<endl;
1364 XpCoord_[ist][imod][cl] += shiftY[ist][imod] * (-Angle(ist, imod)) * tg2_5 + shiftX[ist][imod];
1365 // if(fDebug) cout<<" after shift "<<endl;
1366 // if(fDebug) cout<<ist<<","<<imod<<" Xp "<<XpCoord_[ist][imod][cl] <<endl;
1367
1368 // change the sign to global coord
1369 XpCoord_[ist][imod][cl] = -XpCoord_[ist][imod][cl];
1370 // if(fDebug) cout<<"change the sign to global coord"<<endl;
1371 // if(fDebug) cout<<ist<<","<<imod<<" Xp "<<XpCoord_[ist][imod][cl] <<endl;
1372 XpCoord_[ist][imod][cl] += shiftStYtoGlob[ist] * (Angle(ist, imod))*tg2_5 + shiftStXtoGlob[ist];
1373 } // xp cl
1374 } // imod
1375 } // ist
1376
1377 } // fRunPeriod == 7
1378
1379 if (fRunPeriod == 8) {
1380 Double_t Xtmp;
1381 //--Shift X & Y spatial coordinates--
1382 for (Int_t ist = 1; ist < fNstations; ist++) {
1383 for (Int_t imod = 0; imod < fNmodules; imod++) {
1384 for (Int_t cl = 0; cl < NhitsXYmod_[ist][imod]; cl++) {
1385
1386 // rotate around X
1387 if (imod == 1) {
1388 XspCoord_[ist][imod][cl] = -XspCoord_[ist][imod][cl];
1389 XpspCoord_[ist][imod][cl] = -XpspCoord_[ist][imod][cl];
1390 }
1391 // if(fDebug) cout<<" after X -> -X "<<endl;
1392 // if(fDebug) cout<<ist<<","<<imod<<" X "<<XspCoord_[ist][imod][cl] <<" Y
1393 // "<<YspCoord_[ist][imod][cl]<<endl;
1394
1395 // rotate around Y -> the start of counting strips is at the top
1396 YspCoord_[ist][imod][cl] = -YspCoord_[ist][imod][cl];
1397
1398 // if(fDebug) cout<<" after Y -> -Y "<<endl;
1399 // if(fDebug) cout<<ist<<","<<imod<<" X "<<XspCoord_[ist][imod][cl] <<endl;
1400 // if(fDebug) cout<<" Y "<<YspCoord_[ist][imod][cl]<<endl;
1401
1402 XspCoord_[ist][imod][cl] += shiftX[ist][imod];
1403 YspCoord_[ist][imod][cl] += shiftY[ist][imod];
1404 XpspCoord_[ist][imod][cl] += shiftY[ist][imod] * (-Angle(ist, imod)) * tg2_5 + shiftX[ist][imod];
1405 // if(fDebug) hXYspatial[ist]->Fill(XspCoord_[ist][imod][cl], YspCoord_[ist][imod][cl]);
1406
1407 // shift from Zubarev to Global orientation
1408 if (ist == 1 || ist == 3) {
1409 Xtmp = XspCoord_[ist][imod][cl];
1410 XspCoord_[ist][imod][cl] = YspCoord_[ist][imod][cl];
1411 YspCoord_[ist][imod][cl] = Xtmp;
1412 }
1413 if (ist == 2 || ist == 4) {
1414 XspCoord_[ist][imod][cl] = -XspCoord_[ist][imod][cl];
1415 YspCoord_[ist][imod][cl] = -YspCoord_[ist][imod][cl];
1416 }
1417
1418 //---shift X Y to global---to beam line axis
1419 XspCoord_[ist][imod][cl] += shiftStXtoGlob[ist];
1420 YspCoord_[ist][imod][cl] += shiftStYtoGlob[ist];
1421 XpspCoord_[ist][imod][cl] += shiftStYtoGlob[ist] * (Angle(ist, imod))*tg2_5 + shiftStXtoGlob[ist];
1422
1423 // if(fDebug){
1424 // hYspatialst[ist]-> Fill( YspCoord_[ist][imod][cl]);
1425 // cout<<" after shift in the end"<<endl;
1426 // cout<<" X "<<XspCoord_[ist][imod][cl] <<" Y "<<YspCoord_[ist][imod][cl]<<endl;
1427 // }
1428 } // cl
1429 } // imod
1430 } // ist
1431
1432 //--Shift X & X' coordinates--
1433 for (Int_t ist = 1; ist < fNstations; ist++) {
1434 for (Int_t imod = 0; imod < fNmodules; imod++) {
1435 for (Int_t cl = 0; cl < NclustX_[ist][imod]; cl++) {
1436 if (imod == 1) {
1437 XCoord_[ist][imod][cl] = -XCoord_[ist][imod][cl];
1438 }
1439 XCoord_[ist][imod][cl] += shiftX[ist][imod];
1440 // if ist == 1 || ist == 3 -> Y
1441 if (ist == 2 || ist == 4) {
1442 XCoord_[ist][imod][cl] = -XCoord_[ist][imod][cl];
1443 }
1444 XCoord_[ist][imod][cl] += shiftStXtoGlob[ist];
1445 } // xcl
1446
1447 for (Int_t cl = 0; cl < NclustXp_[ist][imod]; cl++) {
1448 // rotate around X
1449 if (imod == 1) {
1450 XpCoord_[ist][imod][cl] = -XpCoord_[ist][imod][cl];
1451 }
1452 // if(fDebug) cout<<" after Xp -> -Xp "<<endl;
1453 // if(fDebug) cout<<ist<<","<<imod<<" Xp "<<XpCoord_[ist][imod][cl] <<endl;
1454 XpCoord_[ist][imod][cl] += shiftY[ist][imod] * (-Angle(ist, imod)) * tg2_5 + shiftX[ist][imod];
1455 // if ist == 1 || ist == 3 -> Yp
1456 if (ist == 2 || ist == 4) {
1457 XpCoord_[ist][imod][cl] = -XpCoord_[ist][imod][cl];
1458 }
1459 // if(fDebug) cout<<" after shift "<<endl;
1460 // if(fDebug) cout<<ist<<","<<imod<<" Xp "<<XpCoord_[ist][imod][cl] <<endl;
1461 XpCoord_[ist][imod][cl] += shiftStYtoGlob[ist] * (Angle(ist, imod))*tg2_5 + shiftStXtoGlob[ist];
1462 } // xp cl
1463 } // imod
1464 } // ist
1465
1466 } // RUN8
1467
1468 if (fDebug)
1469 cout << " --after shift-- " << endl;
1470
1471 for (Int_t ist = 1; ist < fNstations; ist++) {
1472 if (fDebug)
1473 cout << " XCoord_[" << ist << "] ";
1474 for (Int_t imod = 0; imod < fNmodules; imod++) {
1475 for (Int_t cl = 0; cl < NclustX_[ist][imod]; cl++) {
1476 if (fDebug)
1477 cout << XCoord_[ist][imod][cl] << " ";
1478 }
1479 }
1480 if (fDebug)
1481 cout << endl;
1482 }
1483 if (fDebug)
1484 cout << endl;
1485 for (Int_t ist = 1; ist < fNstations; ist++) {
1486 if (fDebug)
1487 cout << " XpCoord_[" << ist << "] ";
1488 for (Int_t imod = 0; imod < fNmodules; imod++) {
1489 for (Int_t cl = 0; cl < NclustXp_[ist][imod]; cl++) {
1490 if (fDebug)
1491 cout << XpCoord_[ist][imod][cl] << " ";
1492 }
1493 }
1494 if (fDebug)
1495 cout << endl;
1496 }
1497 if (fDebug)
1498 cout << " --spatial-- " << endl;
1499
1500 for (Int_t ist = 1; ist < fNstations; ist++) {
1501 if (fDebug)
1502 cout << " Xspatial[" << ist << "] ";
1503 for (Int_t imod = 0; imod < fNmodules; imod++) {
1504 if (ist == 1 && imod > 3)
1505 continue;
1506 if (ist == 2 && imod > 1)
1507 continue;
1508
1509 for (Int_t cl = 0; cl < NhitsXYmod_[ist][imod]; cl++) {
1510 if (fDebug)
1511 cout << XspCoord_[ist][imod][cl] << " ";
1512 }
1513 }
1514 if (fDebug)
1515 cout << endl;
1516 }
1517 if (fDebug)
1518 cout << endl;
1519
1520 for (Int_t ist = 1; ist < fNstations; ist++) {
1521 if (fDebug)
1522 cout << " Xpspatial[" << ist << "] ";
1523 for (Int_t imod = 0; imod < fNmodules; imod++) {
1524 if (ist == 1 && imod > 3)
1525 continue;
1526 if (ist == 2 && imod > 1)
1527 continue;
1528
1529 for (Int_t cl = 0; cl < NhitsXYmod_[ist][imod]; cl++) {
1530 if (fDebug)
1531 cout << XpspCoord_[ist][imod][cl] << " ";
1532 }
1533 }
1534 if (fDebug)
1535 cout << endl;
1536 }
1537 if (fDebug)
1538 cout << endl;
1539
1540 for (Int_t ist = 1; ist < fNstations; ist++) {
1541 if (fDebug)
1542 cout << " Yspatial[" << ist << "] ";
1543 for (Int_t imod = 0; imod < fNmodules; imod++) {
1544 if (ist == 1 && imod > 3)
1545 continue;
1546 if (ist == 2 && imod > 1)
1547 continue;
1548 for (Int_t cl = 0; cl < NhitsXYmod_[ist][imod]; cl++) {
1549 if (fDebug)
1550 cout << YspCoord_[ist][imod][cl] << " ";
1551 }
1552 }
1553 if (fDebug)
1554 cout << endl;
1555 }
1556 if (fDebug)
1557 cout << endl;
1558
1559 for (Int_t ist = 1; ist < fNstations; ist++) {
1560 for (Int_t imod = 0; imod < fNmodules; imod++) {
1561 if (ist == 1 && imod > 3)
1562 continue;
1563 if (ist == 2 && imod > 1)
1564 continue;
1565 for (Int_t cl = 0; cl < NhitsXYmod_[ist][imod]; cl++) {
1566 if (fDebug && ist == 1)
1567 hY_XSisp1bef->Fill(XspCoord_[ist][imod][cl], YspCoord_[ist][imod][cl]);
1568 if (fDebug && ist == 2)
1569 hY_XSisp2bef->Fill(XspCoord_[ist][imod][cl], YspCoord_[ist][imod][cl]);
1570 }
1571 }
1572 }
1573}
1574//----------------------------------------------------------------------
1575
1576//----------------------------------------------------------------------
1578{
1579 if (fDebug)
1580 cout << " CountSpatialPoints " << endl;
1581
1582 for (Int_t st = 1; st < fNstations; ++st) {
1583 Nsp_st_[st] = 0;
1584 for (Int_t imod = 0; imod < fNmodules; imod++) {
1585 // if ( fDebug) cout<<" Nleftoversp_["<<st<<"]["<<imod<<"] "<<Nleftoversp_[st][imod]<<endl;
1586 Nsp_st_[st] += Nleftoversp_[st][imod];
1587 }
1588 }
1589 if (fDebug)
1590 cout << " next case? Nsp_st[1] " << Nsp_st[1] << " Nsp_st[2] " << Nsp_st[2] << " Nsp_st[3] " << Nsp_st[3]
1591 << endl;
1592}
1593//----------------------------------------------------------------------
1594
1595//----------------------------------------------------------------------
1596Bool_t BmnSiliconTrackFinder::SkipEvent(Int_t** NclustX_, Int_t** NclustXp_, Double_t*** XCoord_, Double_t*** XpCoord_)
1597{
1598 Bool_t skip = 0;
1599
1600 Int_t NfithitsX[fNstations], NfithitsXp[fNstations];
1601 for (Int_t ist = 0; ist < fNstations; ist++) {
1602 NfithitsX[ist] = 0;
1603 NfithitsXp[ist] = 0;
1604 }
1605
1606 for (Int_t ist = 1; ist < fNstations; ist++) {
1607 for (Int_t imod = 0; imod < fNmodules; imod++) {
1608 if (ist == 1 && imod > 3)
1609 continue;
1610 if (ist == 2 && imod > 1)
1611 continue;
1612
1613 for (Int_t cl = 0; cl < NclustX_[ist][imod]; cl++) {
1614 NfithitsX[ist]++;
1615 } // xcl
1616
1617 for (Int_t cl = 0; cl < NclustXp_[ist][imod]; cl++) {
1618 NfithitsXp[ist]++;
1619 } // xp cl
1620 } // imod
1621 } // ist
1622
1623 if (fDebug) {
1624 cout << " Number of hits: " << endl;
1625 for (Int_t ist = 1; ist < fNstations; ist++) {
1626 cout << " NfithitsX[" << ist << "] " << NfithitsX[ist] << " NfithitsXp[" << ist << "] " << NfithitsXp[ist]
1627 << endl;
1628 }
1629 cout << endl;
1630 }
1631 //---------Skip event!!!!! with high Si-hits multiplicity ------------
1632
1633 if ((NfithitsX[1] + NfithitsX[2] + NfithitsX[3]) > 39 && (NfithitsXp[1] + NfithitsXp[2] + NfithitsXp[3]) > 36) {
1634 if (fDebug)
1635 cout << " --Skip event!!!!! with high Si-hits multiplicity --" << endl;
1636 skip = 1;
1637 }
1638 if ((NfithitsX[1] + NfithitsX[2] + NfithitsX[3]) > 51) {
1639 if (fDebug)
1640 cout << " --Skip event!!!!! with high Si-hits multiplicity --" << endl;
1641 skip = 1;
1642 }
1643 return (skip);
1644}
1645//----------------------------------------------------------------------
1646
1647//----------------------------------------------------------------------
1648void BmnSiliconTrackFinder::RecordingTracksAfterSpatialPoints(vector<tracksX>& vec_tracks_, vector<tracksX>& CleanTr_)
1649{
1650
1651 if (fDebug)
1652 cout << endl;
1653 if (fDebug)
1654 cout << " RecordingTracksAfterSpatialPoints size:" << vec_tracks_.size() << endl;
1655 for (size_t itr = 0; itr < vec_tracks_.size(); ++itr) {
1656 CleanTr_.push_back(vec_tracks_.at(itr));
1657
1658 if (fDebug)
1659 cout << " itr " << itr << " Chi2 " << CleanTr_.at(itr).Chi2 << " Nhits " << CleanTr_.at(itr).Nhits << " Xv "
1660 << CleanTr_.at(itr).Xv << " Yv " << CleanTr_.at(itr).Yv << endl;
1661 for (Int_t st = 1; st < fNstations; ++st) {
1662 if (fDebug)
1663 cout << " CleanTr_.at(" << itr << ").CoordX[" << st << "] " << CleanTr_.at(itr).CoordX[st] << " Xp "
1664 << CleanTr_.at(itr).CoordXp[st] << endl;
1665 }
1666 } // itr
1667 if (fDebug)
1668 cout << " CleanTr_.size() " << CleanTr_.size() << endl;
1669 if (fDebug)
1670 cout << endl;
1671
1672 // sorting vector
1673 sort(CleanTr_.begin(), CleanTr_.end(), compareSegments);
1674 if (fDebug)
1675 cout << " sorting vector" << endl;
1676 for (size_t itr = 0; itr < CleanTr_.size(); ++itr) {
1677 if (fDebug)
1678 cout << " itr " << itr << " Chi2 " << CleanTr_.at(itr).Chi2 << endl;
1679 }
1680 for (size_t itr = 0; itr < CleanTr_.size(); ++itr) {
1681 for (Int_t st = 1; st < fNstations; ++st) {
1682 if (fDebug)
1683 cout << " st " << st << " Z " << CleanTr_.at(itr).CoordZ[st] << endl;
1684 if (fDebug)
1685 cout << " CleanTr.CoordX[" << st << "] " << CleanTr_.at(itr).CoordX[st] << " strip "
1686 << CleanTr_.at(itr).StripNumX[st] << " Clsize " << CleanTr_.at(itr).ClSizeX[st] << " Q "
1687 << CleanTr_.at(itr).SumQX[st] << endl;
1688 if (fDebug)
1689 cout << " CleanTr.CoordXp[" << st << "] " << CleanTr_.at(itr).CoordXp[st] << " strip "
1690 << CleanTr_.at(itr).StripNumXp[st] << " Clsize " << CleanTr_.at(itr).ClSizeXp[st] << " Q "
1691 << CleanTr_.at(itr).SumQXp[st] << endl;
1692 } // st
1693 }
1694 vec_tracks_.clear();
1695}
1696//----------------------------------------------------------------------
1697
1698//----------------------------------------------------------------------
1699void BmnSiliconTrackFinder::RecordingTracks(vector<tracksX>& vec_tracks_, vector<tracksX>& CleanTr_)
1700{
1701 if (fDebug)
1702 cout << endl;
1703 if (fDebug)
1704 cout << " RecordingTracks size:" << vec_tracks_.size() << endl;
1705 if (fDebug)
1706 cout << " CleanTr size: " << CleanTr_.size() << endl;
1707 Double_t ZposC[fNstations];
1708 ZposC[0] = 0.;
1709 ZposC[1] = 213.999 + 0.03 - 6.9;
1710 ZposC[2] = 213.999 + 0.03 - 6.9;
1711 ZposC[3] = 327.130 + 0.03;
1712
1713 for (Int_t is = 1; is < fNstations; is++) {
1714 ZposC[is] += Z0_SRC_target;
1715 }
1716 for (size_t itr = 0; itr < vec_tracks_.size(); ++itr) {
1717
1718 Double_t X1_cand = vec_tracks_.at(itr).param[0] * (ZposC[1] - Zcentr) + vec_tracks_.at(itr).param[1];
1719 Double_t Y1_cand = vec_tracks_.at(itr).param[2] * (ZposC[1] - Zcentr) + vec_tracks_.at(itr).param[3];
1720
1721 Double_t X3_cand = vec_tracks_.at(itr).param[0] * (ZposC[3] - Zcentr) + vec_tracks_.at(itr).param[1];
1722 Double_t Y3_cand = vec_tracks_.at(itr).param[2] * (ZposC[3] - Zcentr) + vec_tracks_.at(itr).param[3];
1723
1724 Bool_t Cross_6p = 0;
1725
1726 for (size_t InIter = 0; InIter < CleanTr_.size(); ++InIter) {
1727
1728 Double_t X1_tr = CleanTr_.at(InIter).param[0] * (ZposC[1] - Zcentr) + CleanTr_.at(InIter).param[1];
1729 Double_t Y1_tr = CleanTr_.at(InIter).param[2] * (ZposC[1] - Zcentr) + CleanTr_.at(InIter).param[3];
1730
1731 Double_t X3_tr = CleanTr_.at(InIter).param[0] * (ZposC[3] - Zcentr) + CleanTr_.at(InIter).param[1];
1732 Double_t Y3_tr = CleanTr_.at(InIter).param[2] * (ZposC[3] - Zcentr) + CleanTr_.at(InIter).param[3];
1733
1734 if (X1_cand < X1_tr && X3_cand > X3_tr) {
1735 Cross_6p = 1;
1736 break;
1737 }
1738 if (Y1_cand < Y1_tr && Y3_cand > Y3_tr) {
1739 Cross_6p = 1;
1740 break;
1741 }
1742 if (X1_cand > X1_tr && X3_cand < X3_tr) {
1743 Cross_6p = 1;
1744 break;
1745 }
1746 if (Y1_cand > Y1_tr && Y3_cand < Y3_tr) {
1747 Cross_6p = 1;
1748 break;
1749 }
1750 }
1751
1752 if (!Cross_6p) {
1753 if (fDebug)
1754 cout << " itr " << itr << " CleanTr size: " << CleanTr_.size() << endl;
1755 CleanTr_.push_back(vec_tracks_.at(itr));
1756
1757 if (fDebug)
1758 cout << " itr " << itr << " Chi2 " << vec_tracks_.at(itr).Chi2 << " Nhits " << vec_tracks_.at(itr).Nhits
1759 << " Xv " << vec_tracks_.at(itr).Xv << " Yv " << vec_tracks_.at(itr).Yv << endl;
1760 for (Int_t st = 1; st < fNstations; ++st) {
1761 if (fDebug) {
1762 cout << " st " << st << " Z " << vec_tracks_.at(itr).CoordZ[st] << endl;
1763 cout << " CleanTr.CoordX[" << st << "] " << vec_tracks_.at(itr).CoordX[st] << " strip "
1764 << vec_tracks_.at(itr).StripNumX[st] << " Clsize " << vec_tracks_.at(itr).ClSizeX[st] << " Q "
1765 << vec_tracks_.at(itr).SumQX[st] << endl;
1766 cout << " CleanTr.CoordXp[" << st << "] " << vec_tracks_.at(itr).CoordXp[st] << " strip "
1767 << vec_tracks_.at(itr).StripNumXp[st] << " Clsize " << vec_tracks_.at(itr).ClSizeXp[st]
1768 << " Q " << vec_tracks_.at(itr).SumQXp[st] << endl;
1769 }
1770 } // st
1771 } // Cross
1772 } // itr
1773 if (fDebug)
1774 cout << endl;
1775 if (fDebug)
1776 cout << " now CleanTr.size() " << CleanTr_.size() << endl;
1777 if (fDebug)
1778 cout << endl;
1779 vec_tracks_.clear();
1780}
1781//----------------------------------------------------------------------
1782
1783void BmnSiliconTrackFinder::RecordingTracks_case3(vector<tracksX>& vec_tracks_, vector<tracksX>& CleanTr_)
1784{
1785 if (fDebug)
1786 cout << endl;
1787 if (fDebug)
1788 cout << " RecordingTracks size:" << vec_tracks_.size() << endl;
1789 Double_t ZposC[fNstations];
1790 ZposC[0] = 0.;
1791 ZposC[1] = 213.999 + 0.03 - 6.9;
1792 ZposC[2] = 213.999 + 0.03 - 6.9;
1793 ZposC[3] = 327.130 + 0.03;
1794
1795 if (fDebug)
1796 cout << " after case 3 write cand: " << vec_tracks_.size() << endl;
1797 //---write candidate and check crossing---
1798
1799 Double_t sigma_y = 0.1; // cm//only case3
1800 for (size_t itr = 0; itr < vec_tracks_.size(); ++itr) {
1801
1802 Double_t X1_cand = vec_tracks_.at(itr).param[0] * (ZposC[1] - Zcentr) + vec_tracks_.at(itr).param[1];
1803 Double_t Y1_cand = vec_tracks_.at(itr).param[2] * (ZposC[1] - Zcentr) + vec_tracks_.at(itr).param[3];
1804
1805 Double_t X3_cand = vec_tracks_.at(itr).param[0] * (ZposC[3] - Zcentr) + vec_tracks_.at(itr).param[1];
1806 Double_t Y3_cand = vec_tracks_.at(itr).param[2] * (ZposC[3] - Zcentr) + vec_tracks_.at(itr).param[3];
1807
1808 // if (fDebug) cout<<" X1_cand "<<X1_cand<<" X3_cand "<<X3_cand<<endl;
1809 // if (fDebug) cout<<" Y1_cand "<<Y1_cand<<" Y3_cand "<<Y3_cand<<endl;
1810
1811 Bool_t Cross_6p = 0, rej_cand = 0;
1812
1813 for (size_t InIter = 0; InIter < CleanTr_.size(); ++InIter) {
1814
1815 Double_t X1_tr = CleanTr_.at(InIter).param[0] * (ZposC[1] - Zcentr) + CleanTr_.at(InIter).param[1];
1816 Double_t Y1_tr = CleanTr_.at(InIter).param[2] * (ZposC[1] - Zcentr) + CleanTr_.at(InIter).param[3];
1817
1818 Double_t X3_tr = CleanTr_.at(InIter).param[0] * (ZposC[3] - Zcentr) + CleanTr_.at(InIter).param[1];
1819 Double_t Y3_tr = CleanTr_.at(InIter).param[2] * (ZposC[3] - Zcentr) + CleanTr_.at(InIter).param[3];
1820
1821 // if (fDebug) cout<<" X1_tr "<<X1_tr<<" X3_tr "<<X3_tr<<endl;
1822 // if (fDebug) cout<<" Y1_tr "<<Y1_tr<<" Y3_tr "<<Y3_tr<<endl;
1823
1824 if (X1_cand < X1_tr && X3_cand > X3_tr) {
1825 Cross_6p = 1;
1826 }
1827 if (Y1_cand < Y1_tr && (Y3_cand - sigma_y) > Y3_tr) {
1828 Cross_6p = 1;
1829 }
1830
1831 if (X1_cand > X1_tr && X3_cand < X3_tr) {
1832 Cross_6p = 1;
1833 }
1834 if (Y1_cand > Y1_tr && (Y3_cand + sigma_y) < Y3_tr) {
1835 Cross_6p = 1;
1836 }
1837
1838 if (Cross_6p) {
1839 if (CleanTr_.at(InIter).Nhits > vec_tracks_.at(itr).Nhits) {
1840 rej_cand = 1;
1841
1842 // if (fDebug) cout<<" rej itr "<<itr<<" rej_cand "<<rej_cand<<" Cross_6p "<<Cross_6p<<endl;
1843 }
1844 if (!rej_cand && CleanTr_.at(InIter).Nhits < vec_tracks_.at(itr).Nhits) {
1845 rej_cand = 0;
1846 Cross_6p = 0;
1847 CleanTr_.erase(CleanTr_.begin() + InIter); // reject clean track
1848 // if (fDebug) cout<<" rej Clean "<<InIter<<" rej_cand "<<rej_cand<<" Cross_6p "<<Cross_6p<<endl;
1849 }
1850 if (!rej_cand && Cross_6p) {
1851 if (CleanTr_.at(InIter).Nhits == vec_tracks_.at(itr).Nhits && CleanTr_.at(InIter).Nhits == 4) {
1852 rej_cand = 1;
1853 // if (fDebug) cout<<" rej itr "<<itr<<" rej_cand "<<rej_cand<<" Cross_6p "<<Cross_6p<<endl;
1854 }
1855 }
1856 if (Cross_6p) {
1857 if (CleanTr_.at(InIter).Nhits == vec_tracks_.at(itr).Nhits && CleanTr_.at(InIter).Nhits > 4) {
1858 if (CleanTr_.at(InIter).Chi2 < vec_tracks_.at(itr).Chi2)
1859 rej_cand = 1;
1860 if (CleanTr_.at(InIter).Chi2 > vec_tracks_.at(itr).Chi2) {
1861 CleanTr_.erase(CleanTr_.begin() + InIter);
1862 Cross_6p = 0;
1863 rej_cand = 0;
1864 // if (fDebug) cout<<" rej Clean "<<InIter<<" rej_cand "<<rej_cand<<" Cross_6p
1865 // "<<Cross_6p<<endl;
1866 }
1867 }
1868 }
1869 } // if ( Cross_6p)
1870
1871 } // CleanTr_.size
1872
1873 if (!Cross_6p && !rej_cand) {
1874 if (fDebug)
1875 cout << " write good itr " << itr << endl;
1876 CleanTr_.push_back(vec_tracks_.at(itr));
1877 if (fDebug)
1878 cout << " push good itr " << itr << endl;
1879
1880 if (fDebug)
1881 cout << " itr " << itr << " Chi2 " << vec_tracks_.at(itr).Chi2 << " Nhits " << vec_tracks_.at(itr).Nhits
1882 << " Xv " << vec_tracks_.at(itr).Xv << " Yv " << vec_tracks_.at(itr).Xv << endl;
1883 for (Int_t st = 1; st < fNstations; ++st) {
1884 if (fDebug)
1885 cout << " st " << st << " Z " << CleanTr_.at(itr).CoordZ[st] << endl;
1886 if (fDebug)
1887 cout << " CleanTr.CoordX[" << st << "] " << vec_tracks_.at(itr).CoordX[st] << " strip "
1888 << vec_tracks_.at(itr).StripNumX[st] << " Clsize " << vec_tracks_.at(itr).ClSizeX[st] << " Q "
1889 << vec_tracks_.at(itr).SumQX[st] << endl;
1890 if (fDebug)
1891 cout << " CleanTr.CoordXp[" << st << "] " << vec_tracks_.at(itr).CoordXp[st] << " strip "
1892 << vec_tracks_.at(itr).StripNumXp[st] << " Clsize " << vec_tracks_.at(itr).ClSizeXp[st]
1893 << " Q " << vec_tracks_.at(itr).SumQXp[st] << endl;
1894 }
1895
1896 } // if ( !Cross_6p && !rej_cand )
1897 } // itr
1898 if (fDebug)
1899 cout << endl;
1900 if (fDebug)
1901 cout << " now CleanTr_.size() " << CleanTr_.size() << endl;
1902 if (fDebug)
1903 cout << endl;
1904 vec_tracks_.clear();
1905 //--write candidate and check crossing.--
1906}
1907//----------------------------------------------------------------------
1908
1909//-----------------------Tracking:Case1---------------------------------
1911 Double_t*** XspCoord_,
1912 Double_t*** XpspCoord_,
1913 Double_t*** YspCoord_,
1914 Double_t*** SigmspX_,
1915 Double_t*** SigmspXp_,
1916 Double_t*** SigmspY_,
1917 vector<tracksX>& out_tracks,
1918 Double_t*** XspClust_,
1919 Double_t*** XspClust_width_,
1920 Double_t*** sumQxsp_,
1921 Double_t*** XpspClust_,
1922 Double_t*** XpspClust_width_,
1923 Double_t*** sumQxpsp_)
1924{
1925 tracksX tmpTr;
1926 Int_t NpX_in_line = 0;
1927 Double_t dminx1_x2 = 999.;
1928 // Double_t dminx1_x3 = 999.;
1929 // Double_t dminx3_xp3 = 999.;
1930 // Double_t dminx1_xp1 = 999.;
1931 // Double_t dminx2_xp2 = 999.;
1932
1933 for (Int_t i = 1; i < fNstations; ++i) {
1934 iClustXMod[i] = -1; // reset pointers
1935 iModX[i] = -1;
1936 }
1937
1938 Double_t bx_candidate = 999., by_candidate = 999.;
1939 Int_t iClustXMod_candidate = -1, iModX_candidate = -1;
1940 Double_t dxV_thr = .2, dyV_thr = .4;
1941
1942 if (fDebug)
1943 cout << endl;
1944 //----Spatial track----
1945 if (fDebug)
1946 cout << " case1: Spatial track " << endl;
1947
1948 for (Int_t imod1 = 0; imod1 < fNmodules1; imod1++) {
1949 if (fDebug && NhitsXYmod_[1][imod1] > 0)
1950 cout << " NhitsXYmod_[1][" << imod1 << "] " << NhitsXYmod_[1][imod1] << endl;
1951 for (Int_t cl1 = 0; cl1 < NhitsXYmod_[1][imod1]; cl1++) {
1952 dminx1_x2 = 999.;
1953
1954 for (Int_t imod2 = 0; imod2 < fNmodules2; imod2++) {
1955 if (fDebug && NhitsXYmod_[2][imod2])
1956 cout << " NhitsXYmod_[2][" << imod2 << "] " << NhitsXYmod_[2][imod2] << endl;
1957 for (Int_t cl2 = 0; cl2 < NhitsXYmod_[2][imod2]; cl2++) {
1958
1959 NpX_in_line = 0;
1960 // if(fDebug){
1961 // cout<<" dX(1-2) ("<<half_roadX1_X2<<") "<<XspCoord_[1][imod1][cl1] -
1962 // XspCoord_[2][imod2][cl2]<<endl; cout<<" X1 -X1p ("<<half_roadX1_Xp1<<")
1963 // "<<XspCoord_[1][imod1][cl1] - XpspCoord_[1][imod1][cl1]<<endl; cout<<" X2_Xp2
1964 // ("<<half_roadX2_Xp2<<") "<<XspCoord_[2][imod2][cl2] - XpspCoord_[2][imod2][cl2]<<endl; cout<< "
1965 // Y1_Y2 ("<<half_roadY1_Y2<<") "<<YspCoord_[1][imod1][cl1] - YspCoord_[2][imod2][cl2] <<endl;
1966 // }
1967
1968 if (fabs(XspCoord_[1][imod1][cl1] - XspCoord_[2][imod2][cl2]) > half_roadX1_X2)
1969 continue; // X1-X2
1970 if (fabs(XspCoord_[1][imod1][cl1] - XpspCoord_[1][imod1][cl1]) > half_roadX1_Xp1)
1971 continue; // X1-Xp1
1972 if (fabs(XspCoord_[2][imod2][cl2] - XpspCoord_[2][imod2][cl2]) > half_roadX2_Xp2)
1973 continue; // X2-Xp2
1974 if (fabs(YspCoord_[1][imod1][cl1] - YspCoord_[2][imod2][cl2]) > half_roadY1_Y2)
1975 continue; // Y1-Y2
1976
1977 // if(fDebug) cout<<" aft. hrd "<<endl;
1978
1979 // if(fDebug) cout<<" dX(1-2) "<<XspCoord_[1][imod1][cl1] - XspCoord_[2][imod2][cl2]<<endl;
1980 if (dminx1_x2 > fabs(XspCoord_[1][imod1][cl1] - XspCoord_[2][imod2][cl2])) {
1981 dminx1_x2 = fabs(XspCoord_[1][imod1][cl1] - XspCoord_[2][imod2][cl2]);
1982 iClustXMod[1] = cl1;
1983 iClustXMod[2] = cl2;
1984 iModX[1] = imod1;
1985 iModX[2] = imod2;
1986 NpX_in_line = 2;
1987 }
1988
1989 if (NpX_in_line < 2)
1990 continue;
1991
1992 Bool_t was_candidate = 0;
1993 bx_candidate = 999., by_candidate = 999.;
1994 // Int_t Imod1_candidate = -1, Imod2_candidate = -1;
1995 // Int_t iCl1_candidate = -1, iCl2_candidate = -1;
1996
1997 for (Int_t imod3 = 0; imod3 < fNmodules3; imod3++) {
1998 if (fDebug && NhitsXYmod_[3][imod3] > 0)
1999 cout << " NhitsXYmod_[3][" << imod3 << "] " << NhitsXYmod_[3][imod3] << endl;
2000 for (Int_t cl3 = 0; cl3 < NhitsXYmod_[3][imod3]; cl3++) {
2001
2002 // if(fDebug) cout<<" X3 -X3p "<<XspCoord_[3][imod3][cl3] - XpspCoord_[3][imod3][cl3]<<"
2003 // half_roadX3_Xp3 "<<half_roadX3_Xp3<<endl; if(fDebug) cout<<" X3
2004 // "<<XspCoord_[3][imod3][cl3]<<endl;
2005
2006 if (fabs(XspCoord_[3][imod3][cl3] - XpspCoord_[3][imod3][cl3]) > half_roadX3_Xp3)
2007 continue;
2008 /*
2009 Double_t x1_2 = 0.5 * ( XspCoord_[1][imod1][cl1] + XspCoord_[2][imod2][cl2] );
2010 Double_t y1_2 = 0.5 * ( YspCoord_[1][imod1][cl1] + YspCoord_[2][imod2][cl2] );
2011 Double_t z1_2 = 0.5 * ( Zstation[1][imod1] + Zstation[2][imod2]);
2012
2013 Double_t ax_target_region = (XspCoord_[3][imod3][cl3] - x1_2 ) / (Zstation[3][imod3] - z1_2 );
2014 Double_t bx_target_region = ax_target_region * ( Z0_SRC_target - Zstation[3][imod3] ) +
2015 XspCoord_[3][imod3][cl3];//Zcentr ??????
2016
2017 Double_t ay_target_region = (YspCoord_[3][imod3][cl3] - y1_2 ) / (Zstation[3][imod3] - z1_2 );
2018 Double_t by_target_region = ay_target_region * ( Z0_SRC_target - Zstation[3][imod3] ) +
2019 YspCoord_[3][imod3][cl3];
2020
2021*/
2022 Double_t ax = (XspCoord_[3][imod3][cl3] - XspCoord_[1][imod1][cl1])
2023 / (Zstation[3][imod3] - Zstation[1][imod1]);
2024 Double_t bx_target_region =
2025 ax * (Z0_SRC_target - Zstation[3][imod3]) + XspCoord_[3][imod3][cl3];
2026
2027 Double_t ay = (YspCoord_[3][imod3][cl3] - YspCoord_[1][imod1][cl1])
2028 / (Zstation[3][imod3] - Zstation[1][imod1]);
2029 Double_t by_target_region =
2030 ay * (Z0_SRC_target - Zstation[3][imod3]) + YspCoord_[3][imod3][cl3];
2031
2032 if (fDebug)
2033 cout << " X1 " << XspCoord_[1][imod1][cl1] << " X2 " << XspCoord_[2][imod2][cl2]
2034 << " X3 " << XspCoord_[3][imod3][cl3] << " was_candidate " << was_candidate
2035 << " ax " << ax << " ay " << ay << " Z1 " << Zstation[1][imod1] << " Z3 "
2036 << Zstation[3][imod1] <<
2037 // " x_candidate "<<bx_candidate<<" x_target_region ("<<half_target_regionX <<")
2038 // "<<bx_target_region<<" y_target_region ("<<half_target_regionY<<") "<<
2039 // by_target_region<<
2040 endl;
2041
2042 if (fDebug)
2043 cout << " bx_target_region " << bx_target_region << " half_target_regionX "
2044 << half_target_regionX << endl;
2045 if (fabs(kX_target - bx_target_region) > half_target_regionX)
2046 continue;
2047 if (fDebug)
2048 cout << " by_target_region " << by_target_region << " half_target_regionY "
2049 << half_target_regionY << endl;
2050 if (fabs(kY_target - by_target_region) > half_target_regionY)
2051 continue;
2052
2053 if (was_candidate == 0) {
2054 bx_candidate = bx_target_region;
2055 by_candidate = by_target_region;
2056 iModX_candidate = imod3;
2057 iClustXMod_candidate = cl3;
2058 was_candidate = 1;
2059 if (fDebug)
2060 cout << " write candidate: bx_target_region " << bx_target_region
2061 << " bx_candidate " << bx_candidate << " by_target_region " << by_target_region
2062 << " by_candidate " << by_candidate << endl;
2063 } else {
2064 // if (fDebug) cout<<" bx_target_region "<<bx_target_region<<" bx_candidate "<<"
2065 // by_target_region "<<by_target_region<<" by_candidate "<<by_candidate<<endl;
2066 if (iModX_candidate == imod3 && iClustXMod_candidate == cl3) {
2067 if (fDebug)
2068 cout << " 1" << endl;
2069 continue;
2070 }
2071 if (fabs(kX_target - bx_target_region) > (fabs(kX_target - bx_candidate) + dxV_thr)) {
2072 if (fDebug)
2073 cout << " 2" << endl;
2074 continue;
2075 } // 0.2
2076
2077 if (fabs(kY_target - by_target_region) > (fabs(kY_target - by_candidate) + dyV_thr)) {
2078 if (fDebug)
2079 cout << " 3" << endl;
2080 continue;
2081 } // 0.4
2082 // if ( fabs(by_target_region) > (fabs(by_candidate) + dyV_thr) ) {if (fDebug) cout<<"
2083 // 3"<<endl; continue;}//0.4 if (fDebug) cout<<" left = "<<fabs(bx_target_region) +
2084 // 0.55*fabs(by_target_region)<<" right = "<<fabs(bx_candidate) +
2085 // 0.25*fabs(by_candidate)<<endl;
2086
2087 if ((fabs(kX_target - bx_target_region) + 0.25 * fabs(kY_target - by_target_region))
2088 > (fabs(kX_target - bx_candidate) + 0.25 * fabs(kY_target - by_candidate)))
2089 {
2090 if (fDebug)
2091 cout << " 4" << endl;
2092 continue;
2093 } // v2 closed to v1
2094
2095 bx_candidate = bx_target_region;
2096 by_candidate = by_target_region;
2097 iModX_candidate = imod3; // iModX[3];
2098 iClustXMod_candidate = cl3; // iClustXMod[3];
2099 if (fDebug)
2100 cout << " re - write " << endl;
2101 }
2102
2103 } // imod3
2104 } // cl3;
2105
2106 if (bx_candidate > 900.)
2107 continue;
2108
2109 if (tmpTr.CoordX[3] == XspCoord_[3][iModX_candidate][iClustXMod_candidate])
2110 continue;
2111 if (tmpTr.CoordXp[3] == XpspCoord_[3][iModX_candidate][iClustXMod_candidate])
2112 continue;
2113 // if(fDebug) cout<<" X used "<<Xforglfit[3][iModX[3]]<<" X cand "<<
2114 // XspCoord_[3][iModX_candidate][iClustXMod_candidate] <<endl;
2115
2116 if (iModX_candidate > -1) {
2117 iModX[3] = iModX_candidate;
2118 iClustXMod[3] = iClustXMod_candidate;
2119 }
2120
2121 // if(fDebug) cout<<"end 3st: X1 "<< XspCoord_[1][iModX[1]][iClustXMod[1]]<<" X2 "<<
2122 // XspCoord_[2][iModX[2]][iClustXMod[2]]<<
2123 // "X3 "<< XspCoord_[3][iModX_candidate][iClustXMod_candidate]<<" Xp3 "<<
2124 // XpspCoord_[3][iModX_candidate][iClustXMod_candidate]<< " Xv_candidate "<<bx_candidate<<"
2125 // Yv_candidate "<<by_candidate<<endl;
2126
2127 for (Int_t ist = 1; ist < fNstations; ++ist) {
2128 for (Int_t imod = 0; imod < fNmodules; imod++) {
2129 Xforglfit[ist][imod] = -999.;
2130 Xpforglfit[ist][imod] = -999.;
2131 SigmXforglfit[ist][imod] = -999.;
2132 SigmXpforglfit[ist][imod] = -999.;
2133 }
2134 }
2135
2136 for (Int_t idx = 1; idx < fNstations; ++idx) {
2137 if (iClustXMod[idx] < 0)
2138 continue;
2139 // if(fDebug) cout<<" idx" <<idx<<" iModX "<<iModX[idx]<<" iCl "<<iClustXMod[idx]<<"
2140 // X["<<idx<<"]["<<iClustXMod[idx]<<"] "<<XspCoord_[idx][iModX[idx]][iClustXMod[idx]]<<"
2141 // Xp["<<idx<<"]["<<iClustXMod[idx]<<"] "<<XpspCoord_[idx][iModX[idx]][iClustXMod[idx]]<<" Z
2142 // "<<Zstation[idx][iModX[idx]]<<" sigmaX "<<SigmspX_[idx][iModX[idx]][iClustXMod[idx]]<<"
2143 // sigmaXp "<<SigmspXp_[idx][iModX[idx]][iClustXMod[idx]]<<endl;
2144
2145 Xforglfit[idx][iModX[idx]] = XspCoord_[idx][iModX[idx]][iClustXMod[idx]];
2146 SigmXforglfit[idx][iModX[idx]] = SigmspX_[idx][iModX[idx]][iClustXMod[idx]];
2147
2148 Xpforglfit[idx][iModX[idx]] = XpspCoord_[idx][iModX[idx]][iClustXMod[idx]];
2149 SigmXpforglfit[idx][iModX[idx]] = SigmspXp_[idx][iModX[idx]][iClustXMod[idx]];
2150
2151 Yforglfit[idx][iModX[idx]] = YspCoord_[idx][iModX[idx]][iClustXMod[idx]];
2152 SigmYforglfit[idx][iModX[idx]] = SigmspY_[idx][iModX[idx]][iClustXMod[idx]];
2153 } // idx
2154
2155 //--------------------------- GlobalFit---------------------------------
2156 Int_t TotalNumberOfHits = 0;
2157 Double_t ChiSquareNdf = 0.;
2158 ChiSquare = 0.;
2159 /*line[4];
2160
2161 for (Int_t coeff = 0; coeff < 4; ++coeff) {
2162 line[coeff] = 0.;
2163 }*/
2164
2166 ChiSquare, line);
2167
2168 TotalNumberOfHits = 6;
2169 ChiSquareNdf = ChiSquare / (TotalNumberOfHits - 4);
2170
2171 if (fDebug)
2172 cout << " before cut ChiSquareNDF " << ChiSquareNdf << " Chi2_Globcut " << Chi2_Globcut
2173 << " TotalNumberOfHits " << TotalNumberOfHits << endl;
2174 if (fDebug)
2175 cout << endl;
2176
2177 if (ChiSquareNdf > Chi2_Globcut)
2178 continue;
2179 /*
2180 if ( fabs(line[2] * ( Z0_SRC_target - Zcentr ) + line[3]) > half_target_regionY){
2181 if (fDebug) cout<<" case1:--------half_target_regionY cut: "<<half_target_regionY<<" Yv "<<fabs(line[2] * (
2182 Z0_SRC_target - Zcentr ) + line[3])<<endl; ChiSquareNdf = 999.; continue;
2183 }
2184 */
2185 if (TotalNumberOfHits == 6) {
2186
2187 for (size_t itr = 0; itr < out_tracks.size(); ++itr) {
2188 // deleting randomly recorded tracks
2189 if ((out_tracks.at(itr).CoordX[1] == Xforglfit[1][iModX[1]]
2190 && out_tracks.at(itr).CoordXp[1] == Xpforglfit[1][iModX[1]])
2191 || (out_tracks.at(itr).CoordX[2] == Xforglfit[2][iModX[2]]
2192 && out_tracks.at(itr).CoordXp[2] == Xpforglfit[2][iModX[2]])
2193 || (out_tracks.at(itr).CoordX[3] == Xforglfit[3][iModX[3]]
2194 && out_tracks.at(itr).CoordXp[3] == Xpforglfit[3][iModX[3]]))
2195 {
2196 if (out_tracks.at(itr).Chi2 > ChiSquareNdf)
2197 out_tracks.erase(out_tracks.begin() + itr);
2198 else
2199 ChiSquareNdf = 999.;
2200 } // if
2201 } // itr
2202
2203 if (ChiSquareNdf > Chi2_Globcut)
2204 continue;
2205 // write candidate to tmp vector
2206 tmpTr.Chi2 = ChiSquareNdf;
2207 tmpTr.Nhits = TotalNumberOfHits;
2208 tmpTr.Xv = bx_candidate;
2209 tmpTr.Yv = by_candidate;
2210 tmpTr.param[0] = line[0];
2211 tmpTr.param[1] = line[1];
2212 tmpTr.param[2] = line[2];
2213 tmpTr.param[3] = line[3];
2214
2215 if (fDebug)
2216 cout << " Xv_candidate " << bx_candidate << " Yv_candidate " << by_candidate << endl;
2217 for (Int_t st = 1; st < fNstations; ++st) {
2218 if (iModX[st] < 0)
2219 continue;
2220
2221 tmpTr.ModNum[st] = iModX[st];
2222 tmpTr.CoordX[st] = Xforglfit[st][iModX[st]];
2223 tmpTr.CoordY[st] = Yforglfit[st][iModX[st]];
2224 tmpTr.CoordXp[st] = Xpforglfit[st][iModX[st]];
2225 tmpTr.SigmaX[st] = SigmXforglfit[st][iModX[st]];
2226 tmpTr.SigmaY[st] = SigmYforglfit[st][iModX[st]];
2227 tmpTr.SigmaXp[st] = SigmXpforglfit[st][iModX[st]];
2228 tmpTr.CoordZ[st] = ZstnCforglfit[st][iModX[st]];
2229
2230 tmpTr.StripNumX[st] = XspClust_[st][iModX[st]][iClustXMod[st]];
2231 tmpTr.StripNumXp[st] = XpspClust_[st][iModX[st]][iClustXMod[st]];
2232 tmpTr.ClSizeX[st] = XspClust_width_[st][iModX[st]][iClustXMod[st]];
2233 tmpTr.ClSizeXp[st] = XpspClust_width_[st][iModX[st]][iClustXMod[st]];
2234 tmpTr.SumQX[st] = sumQxsp_[st][iModX[st]][iClustXMod[st]];
2235 tmpTr.SumQXp[st] = sumQxpsp_[st][iModX[st]][iClustXMod[st]];
2236
2237 if (fDebug)
2238 cout << " st " << st << " Z " << tmpTr.CoordZ[st] << endl;
2239 if (fDebug)
2240 cout << " CoordX[" << st << "] " << tmpTr.CoordX[st] << " strip "
2241 << tmpTr.StripNumX[st] << " Clsize " << tmpTr.ClSizeX[st] << " Q "
2242 << tmpTr.SumQX[st] << endl;
2243 if (fDebug)
2244 cout << " CoordXp[" << st << "] " << tmpTr.CoordXp[st] << " strip "
2245 << tmpTr.StripNumXp[st] << " Clsize " << tmpTr.ClSizeXp[st] << " Q "
2246 << tmpTr.SumQXp[st] << endl;
2247 } // st
2248
2249 out_tracks.push_back(tmpTr);
2250
2251 if (fDebug)
2252 cout << " ax " << tmpTr.param[0] << " bx " << tmpTr.param[1] << " ay " << tmpTr.param[2]
2253 << " by " << tmpTr.param[3] << " Chi2 " << tmpTr.Chi2 << endl;
2254 if (fDebug)
2255 cout << " write " << out_tracks.size() << endl;
2256 } // if 6 points
2257 } // 2
2258 } // 2
2259 } // 1
2260 } // 1
2261}
2262//----------------------------------------------------------------------
2263
2264//----------------------------------------------------------------------
2266 Int_t** NclustXp_,
2267 Double_t*** XCoord_,
2268 Double_t*** XpCoord_,
2269 Double_t*** SigmaX_,
2270 Double_t*** SigmaXp_,
2271 Double_t*** XspCoord_,
2272 Double_t*** XpspCoord_,
2273 Double_t*** YspCoord_,
2274 Double_t*** SigmspX_,
2275 Double_t*** SigmspXp_,
2276 Double_t*** SigmspY_,
2277 Int_t** NhitsXYmod_,
2278 vector<tracksX>& tracks,
2279 Int_t** Nspatial,
2280 Int_t** NpointsX,
2281 Int_t** NpointsXp,
2282 Double_t*** pointsXsp,
2283 Double_t*** pointsXpsp,
2284 Double_t*** pointsYsp,
2285 Double_t*** pointsXsigsp,
2286 Double_t*** pointsXpsigsp,
2287 Double_t*** pointsYsigsp,
2288 Double_t*** pointsX,
2289 Double_t*** pointsXp,
2290 Double_t*** pointsXsig,
2291 Double_t*** pointsXpsig)
2292{
2293
2294 if (fDebug)
2295 cout << " CheckPoints " << endl;
2296
2297 for (Int_t st = 0; st < fNstations; ++st) {
2298 for (Int_t imod = 0; imod < fNmodules; imod++) {
2299 Nspatial[st][imod] = 0;
2300 NpointsX[st][imod] = 0;
2301 NpointsXp[st][imod] = 0;
2302 for (Int_t j = 0; j < kBig; j++) {
2303 pointsXsp[st][imod][j] = -999.;
2304 pointsXpsp[st][imod][j] = -999.;
2305 pointsYsp[st][imod][j] = -999.;
2306 pointsXsigsp[st][imod][j] = -999.;
2307 pointsXpsigsp[st][imod][j] = -999.;
2308 pointsYsigsp[st][imod][j] = -999.;
2309 pointsX[st][imod][j] = -999.;
2310 pointsXp[st][imod][j] = -999.;
2311 pointsXsig[st][imod][j] = -999.;
2312 pointsXpsig[st][imod][j] = -999.;
2313 }
2314 }
2315 }
2316 //--spatial points---
2317 for (Int_t st = 1; st < fNstations; ++st) {
2318 for (Int_t imod = 0; imod < fNmodules; imod++) {
2319
2320 for (Int_t cl = 0; cl < NhitsXYmod_[st][imod]; cl++) { // spatial points
2321 Int_t clux = -1;
2322 for (size_t itr = 0; itr < tracks.size(); ++itr) {
2323
2324 if (XspCoord[st][imod][cl] == tracks.at(itr).CoordX[st]) {
2325 clux = cl;
2326 continue;
2327 }
2328 if (XpspCoord[st][imod][cl] == tracks.at(itr).CoordXp[st]) {
2329 clux = cl;
2330 continue;
2331 }
2332 } // tr
2333 if (clux > -1)
2334 continue;
2335 pointsXsp[st][imod][Nspatial[st][imod]] = XspCoord[st][imod][cl];
2336 pointsXpsp[st][imod][Nspatial[st][imod]] = XpspCoord[st][imod][cl];
2337 pointsYsp[st][imod][Nspatial[st][imod]] = YspCoord[st][imod][cl];
2338 pointsXsigsp[st][imod][Nspatial[st][imod]] = SigmspX[st][imod][cl];
2339 pointsXpsigsp[st][imod][Nspatial[st][imod]] = SigmspXp[st][imod][cl];
2340 pointsYsigsp[st][imod][Nspatial[st][imod]] = SigmspY[st][imod][cl];
2341 Nspatial[st][imod]++;
2342
2343 } // cl
2344 } // mod
2345 } // st
2346 //----line points---
2347 for (Int_t st = 1; st < fNstations; ++st) {
2348 for (Int_t imod = 0; imod < fNmodules; imod++) {
2349 for (Int_t cl = 0; cl < NclustX[st][imod]; cl++) { // Xpoints
2350 Int_t clux = -1;
2351 for (size_t itr = 0; itr < tracks.size(); ++itr) {
2352 if (XCoord[st][imod][cl] == tracks.at(itr).CoordX[st]) {
2353 clux = cl;
2354 continue;
2355 }
2356 } // tr
2357 if (clux > -1)
2358 continue;
2359 pointsX[st][imod][NpointsX[st][imod]] = XCoord[st][imod][cl];
2360 pointsXsig[st][imod][NpointsX[st][imod]] = SigmaX[st][imod][cl];
2361 NpointsX[st][imod]++;
2362 } // cl
2363
2364 for (Int_t cl = 0; cl < NclustXp[st][imod]; cl++) { // Xp points
2365 Int_t clux = -1;
2366 for (size_t itr = 0; itr < tracks.size(); ++itr) {
2367 if (XpCoord[st][imod][cl] == tracks.at(itr).CoordXp[st]) {
2368 clux = cl;
2369 continue;
2370 }
2371 } // tr
2372 if (clux > -1)
2373 continue;
2374 pointsXp[st][imod][NpointsXp[st][imod]] = XpCoord[st][imod][cl];
2375 pointsXpsig[st][imod][NpointsX[st][imod]] = SigmaXp[st][imod][cl];
2376 NpointsXp[st][imod]++;
2377 } // cl
2378 } // mod
2379 } // st
2380
2381 if (fDebug)
2382 cout << " after rejection " << endl;
2383
2384 for (Int_t ist = 1; ist < fNstations; ist++) {
2385 if (fDebug)
2386 cout << " pointsXsp[" << ist << "] ";
2387 for (Int_t imod = 0; imod < fNmodules; imod++) {
2388 for (Int_t cl = 0; cl < Nspatial[ist][imod]; cl++) {
2389 if (fDebug)
2390 cout << pointsXsp[ist][imod][cl] << " ";
2391 }
2392 }
2393 if (fDebug)
2394 cout << endl;
2395 }
2396 if (fDebug)
2397 cout << endl;
2398
2399 for (Int_t ist = 1; ist < fNstations; ist++) {
2400 if (fDebug)
2401 cout << " pointsX[" << ist << "] ";
2402 for (Int_t imod = 0; imod < fNmodules; imod++) {
2403 for (Int_t cl = 0; cl < NpointsX[ist][imod]; cl++) {
2404 if (fDebug)
2405 cout << pointsX[ist][imod][cl] << " ";
2406 }
2407 }
2408 if (fDebug)
2409 cout << endl;
2410 }
2411 if (fDebug)
2412 cout << endl;
2413
2414 for (Int_t ist = 1; ist < fNstations; ist++) {
2415 if (fDebug)
2416 cout << " pointsXp[" << ist << "] ";
2417 for (Int_t imod = 0; imod < fNmodules; imod++) {
2418 for (Int_t cl = 0; cl < NpointsXp[ist][imod]; cl++) {
2419 if (fDebug)
2420 cout << pointsXp[ist][imod][cl] << " ";
2421 }
2422 }
2423 if (fDebug)
2424 cout << endl;
2425 }
2426 if (fDebug)
2427 cout << endl;
2428}
2429//----------------------------------------------------------------------
2430
2431//----------------------------------------------------------------------
2433 Int_t** NpointsX,
2434 Int_t** NpointsXp,
2435 Double_t*** pointsXsp,
2436 Double_t*** pointsXpsp,
2437 Double_t*** pointsYsp,
2438 Double_t*** pointsXsigsp,
2439 Double_t*** pointsXpsigsp,
2440 Double_t*** pointsYsigsp,
2441 Double_t*** pointsX,
2442 Double_t*** pointsXp,
2443 Double_t*** pointsXsig,
2444 Double_t*** pointsXpsig,
2445 vector<tracksX>& CleanTr_,
2446 Int_t** NhitsXYmod_,
2447 Double_t*** XspCoord_,
2448 Double_t*** YspCoord_,
2449 Double_t*** SigmspX_,
2450 Double_t*** SigmspY_)
2451{
2452
2453 if (fDebug)
2454 cout << " CheckLeftover" << endl;
2455 bool woSp[fNstations];
2456 for (Int_t st = 0; st < fNstations; ++st) {
2457 woSp[st] = 0;
2458 }
2459 // adding a hit from a track. the case when the plane didn't work
2460 if (fDebug)
2461 cout << endl;
2462 if (fDebug && CleanTr_.size() > 0)
2463 cout << "track was but: " << endl;
2464
2465 for (size_t InIter = 0; InIter < CleanTr_.size(); ++InIter) {
2466 // only for 5 point tracks
2467 if (CleanTr_.at(InIter).Nhits < 5 || CleanTr_.at(InIter).Nhits == 6)
2468 continue;
2469
2470 if (fDebug)
2471 cout << " itr " << InIter << " if Nhits = 5: " << CleanTr_.at(InIter).Nhits << endl;
2472 for (Int_t st = 1; st < fNstations - 1; ++st) {
2473 woSp[st] = 0;
2474
2475 // if the track has no point in 1 or 2 stations
2476 if (CleanTr_.at(InIter).CoordX[st] < -900.) {
2477
2478 if (fDebug)
2479 cout << "no X[" << st << "]: " << CleanTr_.at(InIter).CoordX[st] << endl;
2480 if (fDebug)
2481 cout << " was sp points? " << endl;
2482 for (Int_t imod = 0; imod < fNmodules; imod++) {
2483 if (st == 1 && imod > 3)
2484 continue;
2485 if (st == 2 && imod > 1)
2486 continue;
2487
2488 if (fDebug)
2489 cout << " Nspatial[" << st << "]= " << NhitsXYmod_[st][imod] << endl;
2490 // checking the number of spatial points in 1 or 2 stations
2491 if (NhitsXYmod_[st][imod] > 0)
2492 woSp[st] = 1;
2493
2494 for (Int_t cl = 0; cl < NhitsXYmod_[st][imod]; cl++) {
2495 if (fDebug)
2496 cout << "st[" << st << "] " << " X " << XspCoord_[st][imod][cl] << endl;
2497 }
2498
2499 } // mod
2500 Double_t FitX =
2501 CleanTr_.at(InIter).param[0] * CleanTr_.at(InIter).CoordZ[st] + CleanTr_.at(InIter).param[1];
2502 Double_t FitY =
2503 CleanTr_.at(InIter).param[2] * CleanTr_.at(InIter).CoordZ[st] + CleanTr_.at(InIter).param[3];
2504
2505 // adding a spatial point from the track if there is no point
2506 if (woSp[st] == 0) {
2507 if (fDebug)
2508 cout << " woSp[" << st << "] " << woSp[st] << "-> FitX " << FitX << " FitY " << FitY << endl;
2509 XspCoord_[st][1][NhitsXYmod_[st][1]] = FitX;
2510 YspCoord_[st][1][NhitsXYmod_[st][1]] = FitY;
2511 SigmspX_[st][1][NhitsXYmod_[st][1]] = 0.0060;
2512 SigmspY_[st][1][NhitsXYmod_[st][1]] = 0.2;
2513 NhitsXYmod_[st][1]++;
2514 } // woSp[st] == 1
2515
2516 } // CoordX[st] < -900.
2517
2518 if (CleanTr_.at(InIter).CoordY[st] < -900.) {
2519 if (fDebug)
2520 cout << "no Y[" << st << "] " << CleanTr_.at(InIter).CoordY[st] << endl;
2521 for (Int_t imod = 0; imod < fNmodules; imod++) {
2522 if (st == 1 && imod > 3)
2523 continue;
2524 if (st == 2 && imod > 1)
2525 continue;
2526
2527 if (fDebug)
2528 cout << " Nspatial = " << NhitsXYmod_[st][imod] << endl;
2529 // checking the number of spatial points in 1 or 2 stations
2530 if (NhitsXYmod_[st][imod] > 0)
2531 woSp[st] = 1;
2532
2533 for (Int_t cl = 0; cl < NhitsXYmod_[st][imod]; cl++) {
2534 if (fDebug)
2535 cout << "st[" << st << "] " << " Y " << YspCoord_[st][imod][cl] << endl;
2536 }
2537 } // mod
2538 Double_t FitX =
2539 CleanTr_.at(InIter).param[0] * CleanTr_.at(InIter).CoordZ[st] + CleanTr_.at(InIter).param[1];
2540 Double_t FitY =
2541 CleanTr_.at(InIter).param[2] * CleanTr_.at(InIter).CoordZ[st] + CleanTr_.at(InIter).param[3];
2542
2543 if (woSp[st] == 0) {
2544 if (fDebug)
2545 cout << " woSp[" << st << "] " << woSp[st] << "-> FitX " << FitX << " FitY " << FitY << endl;
2546 XspCoord_[st][1][NhitsXYmod_[st][1]] = FitX;
2547 YspCoord_[st][1][NhitsXYmod_[st][1]] = FitY;
2548 SigmspX_[st][1][NhitsXYmod_[st][1]] = 0.0060;
2549 SigmspY_[st][1][NhitsXYmod_[st][1]] = 0.2;
2550 NhitsXYmod_[st][1]++;
2551 } // woSp[st] == 1
2552
2553 } // CoordXp[st] < -900.
2554 } // st
2555 // NhitsXYmod_[ist][imod]
2556 } // CleanTr_.size()
2557 // adding a hit from a track.
2558
2559 // print all unused hits
2560 for (Int_t ist = 1; ist < fNstations; ist++) {
2561 if (fDebug)
2562 cout << " pointsXsp[" << ist << "] ";
2563 for (Int_t imod = 0; imod < fNmodules; imod++) {
2564 for (Int_t cl = 0; cl < Nspatial[ist][imod]; cl++) {
2565 if (fDebug)
2566 cout << pointsXsp[ist][imod][cl] << " ";
2567 }
2568 }
2569 if (fDebug)
2570 cout << endl;
2571 }
2572 if (fDebug)
2573 cout << endl;
2574
2575 for (Int_t ist = 1; ist < fNstations; ist++) {
2576 if (fDebug)
2577 cout << " pointsXpsp[" << ist << "] ";
2578 for (Int_t imod = 0; imod < fNmodules; imod++) {
2579 for (Int_t cl = 0; cl < Nspatial[ist][imod]; cl++) {
2580 if (fDebug)
2581 cout << pointsXpsp[ist][imod][cl] << " ";
2582 }
2583 }
2584 if (fDebug)
2585 cout << endl;
2586 }
2587 if (fDebug)
2588 cout << endl;
2589 for (Int_t ist = 1; ist < fNstations; ist++) {
2590 if (fDebug)
2591 cout << " pointsX[" << ist << "] ";
2592 for (Int_t imod = 0; imod < fNmodules; imod++) {
2593 for (Int_t cl = 0; cl < NpointsX[ist][imod]; cl++) {
2594 if (fDebug)
2595 cout << pointsX[ist][imod][cl] << " ";
2596 }
2597 }
2598 if (fDebug)
2599 cout << endl;
2600 }
2601 for (Int_t ist = 1; ist < fNstations; ist++) {
2602 if (fDebug)
2603 cout << " pointsXp[" << ist << "] ";
2604 for (Int_t imod = 0; imod < fNmodules; imod++) {
2605 for (Int_t cl = 0; cl < NpointsXp[ist][imod]; cl++) {
2606 if (fDebug)
2607 cout << pointsXp[ist][imod][cl] << " ";
2608 }
2609 }
2610 if (fDebug)
2611 cout << endl;
2612 }
2613
2614 // recording points from crossed planes
2615 for (Int_t ist = 1; ist < fNstations - 1; ist++) {
2616 for (Int_t imod = 0; imod < fNmodules; imod++) {
2617 if (ist == 1 && imod > 3)
2618 continue;
2619 if (ist == 2 && imod > 1)
2620 continue;
2621 woSp[ist] = 0;
2622
2623 if (NhitsXYmod_[ist][imod] > 0)
2624 woSp[ist] = 1;
2625 }
2626 for (Int_t imod = 0; imod < fNmodules; imod++) {
2627 if (woSp[ist] == 1)
2628 continue;
2629 if (fDebug)
2630 cout << " woSp[" << ist << "] " << woSp[ist] << endl;
2631
2632 for (Int_t cl = 0; cl < NpointsX[ist][imod]; cl++) {
2633 for (Int_t is = 1; is < fNstations - 1; is++) {
2634 for (Int_t im = 0; im < fNmodules; im++) {
2635 if (is == 1 && im > 3)
2636 continue;
2637 if (is == 2 && im > 1)
2638 continue;
2639
2640 for (Int_t clp = 0; clp < NpointsXp[is][im]; clp++) {
2641 if (ist == 1 && is == 2) {
2642 if (fDebug)
2643 cout << " X[" << ist << "] " << pointsX[ist][imod][cl] << " Xp[" << is << "] "
2644 << pointsXp[is][im][clp] << " XXp "
2645 << pointsX[ist][imod][cl] - pointsXp[is][im][clp] << endl;
2646 if (fDebug && fabs(pointsX[ist][imod][cl] - pointsXp[is][im][clp]) > 0.)
2647 hXXp12CheckLeftover->Fill(pointsX[ist][imod][cl] - pointsXp[is][im][clp]);
2648 if (fDebug && fabs(pointsX[ist][imod][cl] - pointsXp[is][im][clp]) > 0.
2649 && fabs(pointsX[ist][imod][cl] - pointsXp[is][im][clp]) < 0.2)
2650 {
2651 hXXp12CheckLeftover03->Fill(pointsX[ist][imod][cl] - pointsXp[is][im][clp]);
2652
2653 XspCoord_[ist][imod][NhitsXYmod_[ist][imod]] = pointsX[ist][imod][cl];
2654 YspCoord_[ist][imod][NhitsXYmod_[ist][imod]] =
2655 (pointsX[ist][imod][cl] - pointsXp[is][im][clp]) / tg2_5;
2656 SigmspX_[ist][imod][NhitsXYmod_[ist][imod]] = pointsXsig[ist][imod][cl];
2657 SigmspY_[ist][imod][NhitsXYmod_[ist][imod]] = 0.2;
2658 if (fDebug)
2659 cout << " Ysp " << (pointsX[ist][imod][cl] - pointsXp[is][im][clp]) / tg2_5
2660 << endl;
2661 NhitsXYmod_[ist][imod]++;
2662 }
2663 }
2664 }
2665 }
2666 }
2667 }
2668 }
2669 }
2670 if (fDebug)
2671 cout << endl;
2672
2673 for (Int_t ist = 1; ist < fNstations - 1; ist++) {
2674 for (Int_t imod = 0; imod < fNmodules; imod++) {
2675 if (ist == 1 && imod > 3)
2676 continue;
2677 if (ist == 2 && imod > 1)
2678 continue;
2679 woSp[ist] = 0;
2680
2681 // checking the number of spatial points in 1 or 2 stations
2682 if (NhitsXYmod_[ist][imod] > 0)
2683 woSp[ist] = 1;
2684 }
2685 for (Int_t imod = 0; imod < fNmodules; imod++) {
2686 if (woSp[ist] == 1)
2687 continue;
2688 if (fDebug)
2689 cout << " woSp[" << ist << "] " << woSp[ist] << endl;
2690
2691 for (Int_t cl = 0; cl < NpointsXp[ist][imod]; cl++) {
2692 for (Int_t is = 1; is < fNstations - 1; is++) {
2693 for (Int_t im = 0; im < fNmodules; im++) {
2694 if (is == 1 && im > 3)
2695 continue;
2696 if (is == 2 && im > 1)
2697 continue;
2698
2699 for (Int_t clp = 0; clp < NpointsX[is][im]; clp++) {
2700 if (ist == 1 && is == 2) {
2701 if (fDebug)
2702 cout << " Xp[" << ist << "] " << pointsXp[ist][imod][cl] << " X[" << is << "] "
2703 << pointsX[is][im][clp] << " XXp "
2704 << pointsXp[ist][imod][cl] - pointsX[is][im][clp] << endl;
2705 if (fDebug && fabs(pointsXp[ist][imod][cl] - pointsX[is][im][clp]) > 0.)
2706 hXXp12CheckLeftover->Fill(pointsXp[ist][imod][cl] - pointsX[is][im][clp]);
2707 if (fDebug && fabs(pointsXp[ist][imod][cl] - pointsX[is][im][clp]) > 0.
2708 && fabs(pointsXp[ist][imod][cl] - pointsX[is][im][clp]) < 0.3)
2709 {
2710 hXXp12CheckLeftover03->Fill(pointsXp[ist][imod][cl] - pointsX[is][im][clp]);
2711
2712 XspCoord_[ist][imod][NhitsXYmod_[ist][imod]] = pointsX[is][im][clp];
2713 YspCoord_[ist][imod][NhitsXYmod_[ist][imod]] =
2714 (pointsX[is][im][clp] - pointsXp[ist][imod][cl]) / tg2_5;
2715 SigmspX_[ist][imod][NhitsXYmod_[ist][imod]] = pointsXsig[is][im][clp];
2716 SigmspY_[ist][imod][NhitsXYmod_[ist][imod]] = 0.2;
2717 if (fDebug)
2718 cout << " Ysp " << (pointsX[is][im][clp] - pointsXp[ist][imod][cl]) / tg2_5
2719 << endl;
2720 NhitsXYmod_[ist][imod]++;
2721 }
2722 }
2723 }
2724 }
2725 }
2726 }
2727 }
2728 }
2729
2730 for (Int_t is = 1; is < fNstations - 1; is++) {
2731 for (Int_t im = 0; im < fNmodules; im++) {
2732 if (is == 1 && im > 3)
2733 continue;
2734 if (is == 2 && im > 1)
2735 continue;
2736 // if (fDebug) cout<< " NhitsXYmod_["<<is<<"]["<<im<<"] "<< NhitsXYmod_[is][im]<<endl;
2737 for (Int_t icl = 0; icl < NhitsXYmod_[is][im]; icl++) {
2738 // if (fDebug) cout<< " Xsp "<< XspCoord_[is][im][icl]<<endl;
2739 }
2740 }
2741 }
2742
2743 for (Int_t ist = 1; ist < fNstations; ist++) {
2744 for (Int_t imod = 0; imod < fNmodules; imod++) {
2745 if (ist == 1 && imod > 3)
2746 continue;
2747 if (ist == 2 && imod > 1)
2748 continue;
2749 for (Int_t cl = 0; cl < NhitsXYmod_[ist][imod]; cl++) {
2750 if (fDebug && ist == 1)
2751 hY_XSisp1->Fill(XspCoord_[ist][imod][cl], YspCoord_[ist][imod][cl]);
2752 if (fDebug && ist == 2)
2753 hY_XSisp2->Fill(XspCoord_[ist][imod][cl], YspCoord_[ist][imod][cl]);
2754 }
2755 }
2756 }
2757}
2758//----------------------------------------------------------------------
2759
2760//----------------------------------------------------------------------
2761void BmnSiliconTrackFinder::PrintAllTracks(vector<tracksX>& CleanTr_)
2762{
2763 cout << endl;
2764 cout << "-----end of track finding ------ Ntr " << CleanTr_.size() << endl;
2765 Double_t ver_averx = 0., ver_avery = 0., sum_xv = 0., sum_yv = 0.;
2766 hNtracks->Fill(CleanTr_.size());
2767 for (size_t InIter = 0; InIter < CleanTr_.size(); ++InIter) {
2768
2769 hNpoint->Fill(CleanTr_.at(InIter).Nhits);
2770 hAxglob->Fill(CleanTr_.at(InIter).param[0]);
2771 hBxglob->Fill(CleanTr_.at(InIter).param[1]);
2772 hAyglob->Fill(CleanTr_.at(InIter).param[2]);
2773 hByglob->Fill(CleanTr_.at(InIter).param[3]);
2774
2775 // if (CleanTr_.at(InIter).param[3] < -4.) cout<<" !!!!! -4. "<<endl;
2776 hChiSquareNdf->Fill(CleanTr_.at(InIter).Chi2);
2777 if (InIter == 0)
2778 hAx_first_tr->Fill(CleanTr_.at(InIter).param[0]);
2779 else
2780 hAx_more_first_tr->Fill(CleanTr_.at(InIter).param[0]);
2781 hvertexXY->Fill(CleanTr_.at(InIter).Xv, CleanTr_.at(InIter).Yv);
2782
2783 sum_xv += CleanTr_.at(InIter).Xv;
2784 sum_yv += CleanTr_.at(InIter).Yv;
2785 // for Run8
2786 Double_t Z1 = Z0_SRC_target + 126.;
2787 Double_t Z2 = Z0_SRC_target + 176.;
2788
2789 Double_t X1 = CleanTr_.at(InIter).param[0] * (Z1 - Zcentr) + CleanTr_.at(InIter).param[1];
2790 Double_t Y1 = CleanTr_.at(InIter).param[2] * (Z1 - Zcentr) + CleanTr_.at(InIter).param[3];
2791
2792 Double_t X2 = CleanTr_.at(InIter).param[0] * (Z2 - Zcentr) + CleanTr_.at(InIter).param[1];
2793 Double_t Y2 = CleanTr_.at(InIter).param[2] * (Z2 - Zcentr) + CleanTr_.at(InIter).param[3];
2794
2795 hYXSi1_run8->Fill(X1, Y1);
2796 hYXSi2_run8->Fill(X2, Y2);
2797 hXSi1_run8->Fill(X1);
2798 hYSi1_run8->Fill(Y1);
2799 hXSi2_run8->Fill(X2);
2800 hYSi2_run8->Fill(Y2);
2801
2802 cout << endl;
2803 cout << " ---iTr " << InIter << " Nhits " << CleanTr_.at(InIter).Nhits << " ax " << CleanTr_.at(InIter).param[0]
2804 << " bx " << CleanTr_.at(InIter).param[1] << " ay " << CleanTr_.at(InIter).param[2] << " by "
2805 << CleanTr_.at(InIter).param[3] << " Chi2 " << CleanTr_.at(InIter).Chi2 << endl;
2806 cout << " Xv " << CleanTr_.at(InIter).Xv << " Yv " << CleanTr_.at(InIter).Yv << endl;
2807 cout << " --X--" << endl;
2808 Double_t X1_0 = 999., X1_1 = 999., X1_2 = 999., X1_3 = 999., X2_0 = 999., X2_1 = 999., X3_1 = 999., X3_2 = 999.;
2809 //-------X--------
2810 for (Int_t st = 1; st < fNstations; ++st) {
2811 if (CleanTr_.at(InIter).CoordX[st] < -900.)
2812 continue;
2813 Double_t Hit = CleanTr_.at(InIter).CoordX[st];
2814 Double_t Fit = CleanTr_.at(InIter).param[0] * CleanTr_.at(InIter).CoordZ[st] + CleanTr_.at(InIter).param[1];
2815 cout << " st " << st << " mod " << CleanTr_.at(InIter).ModNum[st] << " Xhit " << Hit << " Xfit " << Fit
2816 << " dX " << Hit - Fit << " Z " << CleanTr_.at(InIter).CoordZ[st] << " strip "
2817 << CleanTr_.at(InIter).StripNumX[st] << " Clsize " << CleanTr_.at(InIter).ClSizeX[st] << " Q "
2818 << CleanTr_.at(InIter).SumQX[st] << endl;
2819
2820 if (st == 1) {
2821 hX_st_1->Fill(CleanTr_.at(InIter).CoordX[st]);
2822 hdXvsXst_1->Fill(Hit, Hit - Fit);
2823 hdX_st_1->Fill(Hit - Fit);
2824 if (CleanTr_.at(InIter).ModNum[st] == 0) {
2825 X1_0 = CleanTr_.at(InIter).CoordX[1];
2826 hdXvsXst1_0->Fill(CleanTr_.at(InIter).CoordX[1], CleanTr_.at(InIter).CoordX[1] - Fit);
2827 }
2828 if (CleanTr_.at(InIter).ModNum[st] == 1) {
2829 X1_1 = CleanTr_.at(InIter).CoordX[1];
2830 hdXvsXst1_1->Fill(CleanTr_.at(InIter).CoordX[1], CleanTr_.at(InIter).CoordX[1] - Fit);
2831 }
2832 if (CleanTr_.at(InIter).ModNum[st] == 2) {
2833 X1_2 = CleanTr_.at(InIter).CoordX[1];
2834 hdXvsXst1_2->Fill(CleanTr_.at(InIter).CoordX[1], CleanTr_.at(InIter).CoordX[1] - Fit);
2835 }
2836 if (CleanTr_.at(InIter).ModNum[st] == 3) {
2837 X1_3 = CleanTr_.at(InIter).CoordX[1];
2838 hdXvsXst1_3->Fill(CleanTr_.at(InIter).CoordX[1], CleanTr_.at(InIter).CoordX[1] - Fit);
2839 }
2840 }
2841 if (st == 2) {
2842 hX_st_2->Fill(CleanTr_.at(InIter).CoordX[st]);
2843 hdXvsXst_2->Fill(Hit, Hit - Fit);
2844 hdX_st_2->Fill(Hit - Fit);
2845 if (CleanTr_.at(InIter).ModNum[2] == 0) {
2846 X2_0 = CleanTr_.at(InIter).CoordX[2];
2847 hdXvsXst2_0->Fill(CleanTr_.at(InIter).CoordX[2], CleanTr_.at(InIter).CoordX[2] - Fit);
2848 }
2849 if (CleanTr_.at(InIter).ModNum[2] == 1) {
2850 X2_1 = CleanTr_.at(InIter).CoordX[2];
2851 hdXvsXst2_1->Fill(CleanTr_.at(InIter).CoordX[2], CleanTr_.at(InIter).CoordX[2] - Fit);
2852 }
2853 }
2854 if (st == 3) {
2855 hX_st_3->Fill(CleanTr_.at(InIter).CoordX[st]);
2856 hdXvsXst_3->Fill(Hit, Hit - Fit);
2857 hdX_st_3->Fill(Hit - Fit);
2858 if (CleanTr_.at(InIter).ModNum[3] == 1) {
2859 X3_1 = CleanTr_.at(InIter).CoordX[3];
2860 hdXvsXst3_1->Fill(CleanTr_.at(InIter).CoordX[3], CleanTr_.at(InIter).CoordX[3] - Fit);
2861 hdXXp3_mod1->Fill(CleanTr_.at(InIter).CoordX[st] - CleanTr_.at(InIter).CoordXp[st]);
2862 }
2863 if (CleanTr_.at(InIter).ModNum[3] == 2) {
2864 X3_2 = CleanTr_.at(InIter).CoordX[3];
2865 hdXvsXst3_2->Fill(CleanTr_.at(InIter).CoordX[3], CleanTr_.at(InIter).CoordX[3] - Fit);
2866 hdXXp3_mod2->Fill(CleanTr_.at(InIter).CoordX[st] - CleanTr_.at(InIter).CoordXp[st]);
2867 }
2868 }
2869 } // st
2870 if (X1_0 < 900. && X2_0 < 900.)
2871 hdXst1_0_st2_0->Fill(X1_0 - X2_0);
2872 if (X1_0 < 900. && X2_1 < 900.)
2873 hdXst1_0_st2_1->Fill(X1_0 - X2_1);
2874 if (X1_1 < 900. && X2_0 < 900.)
2875 hdXst1_1_st2_0->Fill(X1_1 - X2_0);
2876 if (X1_1 < 900. && X2_1 < 900.)
2877 hdXst1_1_st2_1->Fill(X1_1 - X2_1);
2878 if (X1_2 < 900. && X2_0 < 900.)
2879 hdXst1_2_st2_0->Fill(X1_2 - X2_0);
2880 if (X1_2 < 900. && X2_1 < 900.)
2881 hdXst1_2_st2_1->Fill(X1_2 - X2_1);
2882 if (X1_3 < 900. && X2_0 < 900.)
2883 hdXst1_3_st2_0->Fill(X1_3 - X2_0);
2884 if (X1_3 < 900. && X2_1 < 900.)
2885 hdXst1_3_st2_1->Fill(X1_3 - X2_1);
2886 if (X2_0 < 900. && X3_1 < 900.)
2887 hdXst2_0_st3_1->Fill(X2_0 - X3_1);
2888 if (X2_0 < 900. && X3_2 < 900.)
2889 hdXst2_0_st3_2->Fill(X2_0 - X3_2);
2890 if (X2_1 < 900. && X3_1 < 900.)
2891 hdXst2_1_st3_1->Fill(X2_1 - X3_1);
2892 if (X2_1 < 900. && X3_2 < 900.)
2893 hdXst2_1_st3_2->Fill(X2_1 - X3_2);
2894
2895 if (CleanTr_.at(InIter).Nhits == 6) {
2896 Double_t Ax = (CleanTr_.at(InIter).CoordX[1] - CleanTr_.at(InIter).CoordX[3])
2897 / (CleanTr_.at(InIter).CoordZ[1] - CleanTr_.at(InIter).CoordZ[3]);
2898 if (X2_0 < 900.)
2899 hX13_X2_m0->Fill(X2_0
2900 - (Ax * (CleanTr_.at(InIter).CoordZ[2] - CleanTr_.at(InIter).CoordZ[1])
2901 + CleanTr_.at(InIter).CoordX[1]));
2902 if (X2_1 < 900.)
2903 hX13_X2_m1->Fill(X2_1
2904 - (Ax * (CleanTr_.at(InIter).CoordZ[2] - CleanTr_.at(InIter).CoordZ[1])
2905 + CleanTr_.at(InIter).CoordX[1]));
2906 }
2907 hdX_st1_st2->Fill(CleanTr_.at(InIter).CoordX[1] - CleanTr_.at(InIter).CoordX[2]);
2908 hdX_st2_st3->Fill(CleanTr_.at(InIter).CoordX[2] - CleanTr_.at(InIter).CoordX[3]);
2909 hdX_st1_st3->Fill(CleanTr_.at(InIter).CoordX[1] - CleanTr_.at(InIter).CoordX[3]);
2910
2911 //-------Xp--------
2912 cout << " --Xp--" << endl;
2913 Double_t Xp2_0 = 999., Xp2_1 = 999.;
2914 for (Int_t st = 1; st < fNstations; ++st) {
2915 if (CleanTr_.at(InIter).CoordXp[st] < -900.)
2916 continue;
2917 Double_t Hit = CleanTr_.at(InIter).CoordXp[st];
2918 Double_t Fit =
2919 (CleanTr_.at(InIter).param[0] * CleanTr_.at(InIter).CoordZ[st] + CleanTr_.at(InIter).param[1])
2920 + (CleanTr_.at(InIter).param[2] * CleanTr_.at(InIter).CoordZ[st] + CleanTr_.at(InIter).param[3])
2921 * Angle(st, CleanTr_.at(InIter).ModNum[st]) * tg2_5;
2922 // x' = x + y*tg
2923 hdXp_st_1->Fill(Hit - Fit);
2924 cout << " st " << st << " Xphit " << Hit << " Xpfit " << Fit << " dXp " << Hit - Fit << " Z "
2925 << CleanTr_.at(InIter).CoordZ[st] << " strip " << CleanTr_.at(InIter).StripNumXp[st] << " Clsize "
2926 << CleanTr_.at(InIter).ClSizeXp[st] << " Q " << CleanTr_.at(InIter).SumQXp[st] << endl;
2927 if (st == 2) {
2928 hdXp_st_2->Fill(Hit - Fit);
2929 if (CleanTr_.at(InIter).ModNum[2] == 0) {
2930 Xp2_0 = CleanTr_.at(InIter).CoordXp[2];
2931 }
2932 if (CleanTr_.at(InIter).ModNum[2] == 1) {
2933 Xp2_1 = CleanTr_.at(InIter).CoordXp[2];
2934 }
2935 }
2936 if (st == 3) {
2937 hdXp_st_3->Fill(Hit - Fit);
2938 if (CleanTr_.at(InIter).ModNum[3] == 1) {
2939 hdXp3_mod1->Fill(Hit - Fit);
2940 }
2941 if (CleanTr_.at(InIter).ModNum[3] == 2) {
2942 hdXp3_mod2->Fill(Hit - Fit);
2943 }
2944 }
2945 }
2946 if (CleanTr_.at(InIter).Nhits == 6) {
2947 Double_t Axp = (CleanTr_.at(InIter).CoordXp[1] - CleanTr_.at(InIter).CoordXp[3])
2948 / (CleanTr_.at(InIter).CoordZ[1] - CleanTr_.at(InIter).CoordZ[3]);
2949 if (Xp2_0 < 900.)
2950 hXp13_Xp2_m0->Fill(Xp2_0
2951 - (Axp * (CleanTr_.at(InIter).CoordZ[2] - CleanTr_.at(InIter).CoordZ[1])
2952 + CleanTr_.at(InIter).CoordXp[1]));
2953 if (Xp2_1 < 900.)
2954 hXp13_Xp2_m1->Fill(Xp2_1
2955 - (Axp * (CleanTr_.at(InIter).CoordZ[2] - CleanTr_.at(InIter).CoordZ[1])
2956 + CleanTr_.at(InIter).CoordXp[1]));
2957 }
2958
2959 if (fDebug)
2960 cout << " --Y--" << endl;
2961 Double_t Y1_0 = 999., Y1_1 = 999., Y1_2 = 999., Y1_3 = 999., Y2_0 = 999., Y2_1 = 999., Y3_1 = 999., Y3_2 = 999.;
2962 //-------Y--------
2963 for (Int_t st = 1; st < fNstations; ++st) {
2964 if (CleanTr_.at(InIter).CoordY[st] < -900.)
2965 continue;
2966 Double_t Hit = CleanTr_.at(InIter).CoordY[st];
2967 Double_t Fit = CleanTr_.at(InIter).param[2] * CleanTr_.at(InIter).CoordZ[st] + CleanTr_.at(InIter).param[3];
2968 cout << " st " << st << " Yhit " << Hit << " Yfit " << Fit << " dY " << Hit - Fit << " Z "
2969 << CleanTr_.at(InIter).CoordZ[st] << endl;
2970
2971 if (st == 1) {
2972 hY_st_1->Fill(CleanTr_.at(InIter).CoordY[st]);
2973 hdYvsYst_1->Fill(Hit, Hit - Fit);
2974 hdY_st_1->Fill(Hit - Fit);
2975 }
2976 if (st == 2) {
2977 hY_st_2->Fill(CleanTr_.at(InIter).CoordY[st]);
2978 hdYvsYst_2->Fill(Hit, Hit - Fit);
2979 hdY_st_2->Fill(Hit - Fit);
2980 }
2981 if (st == 3) {
2982 hY_st_3->Fill(CleanTr_.at(InIter).CoordY[st]);
2983 hdYvsYst_3->Fill(CleanTr_.at(InIter).CoordY[3], CleanTr_.at(InIter).CoordY[3] - Fit);
2984 hdY_st_3->Fill(CleanTr_.at(InIter).CoordY[3] - Fit);
2985 if (fabs(Hit - Fit) > 0.1)
2986 cout << " > 0.1 " << endl;
2987 }
2988
2989 if (st == 1) {
2990 if (CleanTr_.at(InIter).ModNum[1] == 0) {
2991 hdYvsYst1_mod0->Fill(Hit, Hit - Fit);
2992 Y1_0 = CleanTr_.at(InIter).CoordY[st];
2993 }
2994 if (CleanTr_.at(InIter).ModNum[1] == 1) {
2995 hdYvsYst1_mod1->Fill(Hit, Hit - Fit);
2996 Y1_1 = CleanTr_.at(InIter).CoordY[st];
2997 }
2998 if (CleanTr_.at(InIter).ModNum[1] == 2) {
2999 hdYvsYst1_mod2->Fill(Hit, Hit - Fit);
3000 Y1_2 = CleanTr_.at(InIter).CoordY[st];
3001 }
3002 if (CleanTr_.at(InIter).ModNum[1] == 3) {
3003 hdYvsYst1_mod3->Fill(Hit, Hit - Fit);
3004 Y1_3 = CleanTr_.at(InIter).CoordY[st];
3005 }
3006 }
3007 if (st == 2) {
3008 if (CleanTr_.at(InIter).ModNum[2] == 0) {
3009 hdYvsYst2_mod0->Fill(Hit, Hit - Fit);
3010 Y2_0 = CleanTr_.at(InIter).CoordY[st];
3011 }
3012 if (CleanTr_.at(InIter).ModNum[2] == 1) {
3013 hdYvsYst2_mod1->Fill(Hit, Hit - Fit);
3014 Y2_1 = CleanTr_.at(InIter).CoordY[st];
3015 }
3016 }
3017 if (st == 3) {
3018 if (CleanTr_.at(InIter).ModNum[3] == 1) {
3019 hdYvsYst3_mod1->Fill(Hit, Hit - Fit);
3020 Y3_1 = CleanTr_.at(InIter).CoordY[st];
3021 }
3022 if (CleanTr_.at(InIter).ModNum[3] == 2) {
3023 hdYvsYst3_mod2->Fill(Hit, Hit - Fit);
3024 Y3_2 = CleanTr_.at(InIter).CoordY[st];
3025 }
3026 }
3027 } // st
3028
3029 double Ay_pr = -999.;
3030 double Y_pr = -999.;
3031 if (CleanTr_.at(InIter).CoordY[1] > -900. && CleanTr_.at(InIter).CoordY[3] > -900.) {
3032 Ay_pr = (CleanTr_.at(InIter).CoordY[1] - CleanTr_.at(InIter).Yv)
3033 / (CleanTr_.at(InIter).CoordZ[1] - Z0_SRC_target);
3034 Y_pr =
3035 Ay_pr * (CleanTr_.at(InIter).CoordZ[3] - CleanTr_.at(InIter).CoordZ[1]) + CleanTr_.at(InIter).CoordY[1];
3036 }
3037 if (CleanTr_.at(InIter).CoordY[2] > -900. && CleanTr_.at(InIter).CoordY[3] > -900.) {
3038 Ay_pr = (CleanTr_.at(InIter).CoordY[2] - CleanTr_.at(InIter).Yv)
3039 / (CleanTr_.at(InIter).CoordZ[2] - Z0_SRC_target);
3040 Y_pr =
3041 Ay_pr * (CleanTr_.at(InIter).CoordZ[3] - CleanTr_.at(InIter).CoordZ[2]) + CleanTr_.at(InIter).CoordY[2];
3042 }
3043 cout << " Y3 predicted " << Y_pr << " Y " << CleanTr_.at(InIter).CoordY[3] << endl;
3044
3045 hdY_st1_st2->Fill(CleanTr_.at(InIter).CoordY[1] - CleanTr_.at(InIter).CoordY[2]);
3046 hdY_st2_st3->Fill(CleanTr_.at(InIter).CoordY[2] - CleanTr_.at(InIter).CoordY[3]);
3047 hdY_st1_st3->Fill(CleanTr_.at(InIter).CoordY[1] - CleanTr_.at(InIter).CoordY[3]);
3048
3049 if (Y1_0 < 900. && Y2_0 < 900.)
3050 hdYst1_0_st2_0->Fill(Y1_0 - Y2_0);
3051 if (Y1_0 < 900. && Y2_1 < 900.)
3052 hdYst1_0_st2_1->Fill(Y1_0 - Y2_1);
3053 if (Y1_1 < 900. && Y2_0 < 900.)
3054 hdYst1_1_st2_0->Fill(Y1_1 - Y2_0);
3055 if (Y1_1 < 900. && Y2_1 < 900.)
3056 hdYst1_1_st2_1->Fill(Y1_1 - Y2_1);
3057 if (Y1_2 < 900. && Y2_0 < 900.)
3058 hdYst1_2_st2_0->Fill(Y1_2 - Y2_0);
3059 if (Y1_2 < 900. && Y2_1 < 900.)
3060 hdYst1_2_st2_1->Fill(Y1_2 - Y2_1);
3061 if (Y1_3 < 900. && Y2_0 < 900.)
3062 hdYst1_3_st2_0->Fill(Y1_3 - Y2_0);
3063 if (Y1_3 < 900. && Y2_1 < 900.)
3064 hdYst1_3_st2_1->Fill(Y1_3 - Y2_1);
3065 if (Y2_0 < 900. && Y3_1 < 900.)
3066 hdYst2_0_st3_1->Fill(Y2_0 - Y3_1);
3067 if (Y2_0 < 900. && Y3_2 < 900.)
3068 hdYst2_0_st3_2->Fill(Y2_0 - Y3_2);
3069 if (Y2_1 < 900. && Y3_1 < 900.)
3070 hdYst2_1_st3_1->Fill(Y2_1 - Y3_1);
3071 if (Y2_1 < 900. && Y3_2 < 900.)
3072 hdYst2_1_st3_2->Fill(Y2_1 - Y3_2);
3073
3074 if (CleanTr_.at(InIter).Nhits == 6) {
3075 Double_t Ax = (CleanTr_.at(InIter).CoordY[1] - CleanTr_.at(InIter).CoordY[3])
3076 / (CleanTr_.at(InIter).CoordZ[1] - CleanTr_.at(InIter).CoordZ[3]);
3077 Double_t Ax23 = (CleanTr_.at(InIter).CoordY[2] - CleanTr_.at(InIter).CoordY[3])
3078 / (CleanTr_.at(InIter).CoordZ[2] - CleanTr_.at(InIter).CoordZ[3]);
3079
3080 if (Y1_0 < 900.)
3081 hY1m0_Y23->Fill(Y1_0
3082 - (Ax23 * (CleanTr_.at(InIter).CoordZ[1] - CleanTr_.at(InIter).CoordZ[2])
3083 + CleanTr_.at(InIter).CoordY[2]));
3084 if (Y1_1 < 900.)
3085 hY1m1_Y23->Fill(Y1_1
3086 - (Ax23 * (CleanTr_.at(InIter).CoordZ[1] - CleanTr_.at(InIter).CoordZ[2])
3087 + CleanTr_.at(InIter).CoordY[2]));
3088 if (Y1_2 < 900.)
3089 hY1m2_Y23->Fill(Y1_2
3090 - (Ax23 * (CleanTr_.at(InIter).CoordZ[1] - CleanTr_.at(InIter).CoordZ[2])
3091 + CleanTr_.at(InIter).CoordY[2]));
3092 if (Y1_3 < 900.)
3093 hY1m3_Y23->Fill(Y1_3
3094 - (Ax23 * (CleanTr_.at(InIter).CoordZ[1] - CleanTr_.at(InIter).CoordZ[2])
3095 + CleanTr_.at(InIter).CoordY[2]));
3096
3097 if (Y2_0 < 900.)
3098 hY13_Y2_m0->Fill(Y2_0
3099 - (Ax * (CleanTr_.at(InIter).CoordZ[2] - CleanTr_.at(InIter).CoordZ[1])
3100 + CleanTr_.at(InIter).CoordY[1]));
3101 if (Y2_1 < 900.)
3102 hY13_Y2_m1->Fill(Y2_1
3103 - (Ax * (CleanTr_.at(InIter).CoordZ[2] - CleanTr_.at(InIter).CoordZ[1])
3104 + CleanTr_.at(InIter).CoordY[1]));
3105 }
3106
3107 double z_cnt = 0;
3108 if (CleanTr_.at(InIter).CoordX[1] > -900. || CleanTr_.at(InIter).CoordXp[1] > -900.)
3109 hprofile_beam_z1->Fill(
3110 CleanTr_.at(InIter).param[0] * (CleanTr_.at(InIter).CoordZ[1] - z_cnt) + CleanTr_.at(InIter).param[1],
3111 CleanTr_.at(InIter).param[2] * (CleanTr_.at(InIter).CoordZ[1] - z_cnt) + CleanTr_.at(InIter).param[3]);
3112 if (CleanTr_.at(InIter).CoordX[2] > -900. || CleanTr_.at(InIter).CoordXp[2] > -900.)
3113 hprofile_beam_z2->Fill(
3114 CleanTr_.at(InIter).param[0] * (CleanTr_.at(InIter).CoordZ[2] - z_cnt) + CleanTr_.at(InIter).param[1],
3115 CleanTr_.at(InIter).param[2] * (CleanTr_.at(InIter).CoordZ[2] - z_cnt) + CleanTr_.at(InIter).param[3]);
3116 hprofile_beam_z3->Fill(
3117 CleanTr_.at(InIter).param[0] * (CleanTr_.at(InIter).CoordZ[3] - z_cnt) + CleanTr_.at(InIter).param[1],
3118 CleanTr_.at(InIter).param[2] * (CleanTr_.at(InIter).CoordZ[3] - z_cnt) + CleanTr_.at(InIter).param[3]);
3119
3120 for (Int_t st = 1; st < fNstations; ++st) {
3121
3122 if (CleanTr_.at(InIter).Nhits == N_min_points) {
3123 if (CleanTr_.at(InIter).CoordX[st] < -900.)
3124 D_eff->Fill(2 * st - 1);
3125 if (CleanTr_.at(InIter).CoordXp[st] < -900.)
3126 D_eff->Fill(2 * st);
3127 }
3128 if (CleanTr_.at(InIter).Nhits > N_min_points) {
3129 D_eff->Fill(2 * st - 1);
3130 D_eff->Fill(2 * st);
3131 if (CleanTr_.at(InIter).CoordX[st] > -900.)
3132 N_eff->Fill(2 * st - 1);
3133 if (CleanTr_.at(InIter).CoordXp[st] > -900.)
3134 N_eff->Fill(2 * st);
3135 }
3136 } // st
3137
3138 } // InIter
3139
3140 if (CleanTr_.size() > 0) {
3141 ver_averx = sum_xv / CleanTr_.size();
3142 ver_avery = sum_yv / CleanTr_.size();
3143 hvertex_aver_XY->Fill(ver_averx, ver_avery);
3144 }
3145 cout << "-----end find tracks ------ Ntr " << CleanTr_.size() << endl;
3146}
3147//----------------------------------------------------------------------
3148
3149//--------------------Tracking:Case2------------------------------------
3151 Int_t** Nleftoversp_,
3152 Double_t*** leftoverXsp_,
3153 Double_t*** leftoverXpsp_,
3154 Double_t*** leftoverYsp_,
3155 Double_t*** leftoverXsigsp_,
3156 Double_t*** leftoverXpsigsp_,
3157 Double_t*** leftoverYsigsp_,
3158 Int_t** NleftoverX_,
3159 Int_t** NleftoverXp_,
3160 Double_t*** leftoverX_,
3161 Double_t*** leftoverXp_,
3162 Double_t*** leftoverXsig_,
3163 Double_t*** leftoverXpsig_,
3164 vector<tracksX>& vec_tracks_,
3165 Double_t*** XClust_,
3166 Double_t*** XClust_width_,
3167 Double_t*** sumQx_,
3168 Double_t*** XpClust_,
3169 Double_t*** XpClust_width_,
3170 Double_t*** sumQxp_,
3171 Double_t*** XspClust_,
3172 Double_t*** XspClust_width_,
3173 Double_t*** sumQxsp_,
3174 Double_t*** XpspClust_,
3175 Double_t*** XpspClust_width_,
3176 Double_t*** sumQxpsp_)
3177{
3178
3179 if (fDebug)
3180 cout << " case2:" << Fi_St << "time " << endl;
3181
3182 tracksX tmpTr;
3183
3184 Double_t xv_candidate = 999., yv_candidate = 999., ax_candidate = 999., ay_candidate = 999.;
3185 Int_t iClustXMod_candidate = -1, iModX_candidate = -1;
3186 Double_t dxV_thr = .2, dyV_thr = .4;
3187 Int_t Npoint = 0;
3188 Int_t TotalNumberOfHits = 0;
3189 Double_t ChiSquareNdf = 0.;
3190
3191 Bool_t x5_exist = 0;
3192 Bool_t xp5_exist = 0;
3193 Int_t Nmod_Fi = fNmodules1;
3194 Int_t Nmod_Sec = fNmodules2;
3195 Int_t Sec_St = 2;
3196
3197 if (Fi_St == 2) {
3198 Nmod_Fi = fNmodules2;
3199 Nmod_Sec = fNmodules1;
3200 Sec_St = 1;
3201 }
3202
3203 for (Int_t imod1 = 0; imod1 < Nmod_Fi; imod1++) {
3204 for (Int_t cl1 = 0; cl1 < Nleftoversp_[Fi_St][imod1]; cl1++) {
3205
3206 Double_t ax_target_region = -999., bx_target_region = -999., ay_target_region = -999.,
3207 by_target_region = -999.;
3208 Bool_t was_candidate = 0;
3209 ax_candidate = 999., ay_candidate = 999., xv_candidate = 999., yv_candidate = 999.;
3210 x5_exist = 0;
3211 xp5_exist = 0;
3212 ChiSquareNdf = 0.;
3213 Npoint = 0;
3214
3215 for (Int_t imod3 = 0; imod3 < fNmodules3; imod3++) {
3216 for (Int_t cl3 = 0; cl3 < Nleftoversp_[3][imod3]; cl3++) {
3217
3218 for (Int_t i = 1; i < fNstations; ++i) {
3219 iClustXMod[i] = -1; // reset pointers
3220 iModX[i] = -1;
3221 }
3222
3223 ax_target_region = (leftoverXsp_[3][imod3][cl3] - leftoverXsp_[Fi_St][imod1][cl1])
3224 / (Zstation[3][imod3] - Zstation[Fi_St][imod1]);
3225 bx_target_region =
3226 -ax_target_region * (Zstation[3][imod3] - Z0_SRC_target) + leftoverXsp_[3][imod3][cl3];
3227
3228 ay_target_region = (leftoverYsp_[3][imod3][cl3] - leftoverYsp_[Fi_St][imod1][cl1])
3229 / (Zstation[3][imod3] - Zstation[Fi_St][imod1]);
3230 by_target_region =
3231 -ay_target_region * (Zstation[3][imod3] - Z0_SRC_target) + leftoverYsp_[3][imod3][cl3];
3232
3233 if (fDebug)
3234 cout << " bx_target_region " << bx_target_region << " by_target_region " << by_target_region
3235 << endl;
3236
3237 if (fabs(bx_target_region) > half_target_regionX)
3238 continue;
3239 if (fabs(by_target_region) > half_target_regionY)
3240 continue;
3241
3242 if (was_candidate == 0) {
3243
3244 xv_candidate = bx_target_region;
3245 yv_candidate = by_target_region;
3246 ax_candidate = ax_target_region;
3247 ay_candidate = ay_target_region;
3248 iModX_candidate = imod3;
3249 iClustXMod_candidate = cl3;
3250 was_candidate = 1;
3251 // if (fDebug) cout<<" write candidate "<<endl;
3252 } else {
3253 if (fabs(bx_target_region) > (fabs(xv_candidate) + dxV_thr))
3254 continue; // 0.2
3255 if (fabs(by_target_region) > (fabs(yv_candidate) + dyV_thr))
3256 continue; // 0.4
3257 if ((fabs(bx_target_region) + 0.5 * fabs(by_target_region))
3258 > (fabs(xv_candidate) + 0.25 * fabs(yv_candidate)))
3259 continue; // v2 closed to v1
3260
3261 xv_candidate = bx_target_region;
3262 yv_candidate = by_target_region;
3263 ax_candidate = ax_target_region;
3264 ay_candidate = ay_target_region;
3265
3266 iModX_candidate = imod3;
3267 iClustXMod_candidate = cl3;
3268 // if (fDebug) cout<<" re - write. xv_candidate "<<xv_candidate<<endl;
3269 }
3270
3271 Npoint = 4;
3272
3273 } // cl3
3274 } // st3
3275
3276 if (fDebug)
3277 cout << " aft.st3 cycle: xv_candidate " << xv_candidate << " by_cand " << yv_candidate
3278 << " was_candidate " << was_candidate << endl;
3279 if (xv_candidate > 900.)
3280 continue;
3281
3282 for (Int_t ist = 1; ist < fNstations; ++ist) {
3283 for (Int_t imod = 0; imod < fNmodules; imod++) {
3284 Xforglfit[ist][imod] = -999.;
3285 Yforglfit[ist][imod] = -999.;
3286 Xpforglfit[ist][imod] = -999.;
3287 SigmYforglfit[ist][imod] = -999.;
3288 SigmXforglfit[ist][imod] = -999.;
3289 SigmXpforglfit[ist][imod] = -999.;
3290 }
3291 }
3292
3293 if (iModX_candidate > -1) {
3294 iModX[Fi_St] = imod1;
3295 iModX[3] = iModX_candidate;
3296 iClustXMod[Fi_St] = cl1;
3297 iClustXMod[3] = iClustXMod_candidate;
3298 }
3299
3300 for (Int_t ist = 1; ist < fNstations; ++ist) {
3301 if (ist == Sec_St)
3302 continue;
3303 Xforglfit[ist][iModX[ist]] = leftoverXsp_[ist][iModX[ist]][iClustXMod[ist]];
3304 SigmXforglfit[ist][iModX[ist]] = leftoverXsigsp_[ist][iModX[ist]][iClustXMod[ist]];
3305 Xpforglfit[ist][iModX[ist]] = leftoverXpsp_[ist][iModX[ist]][iClustXMod[ist]];
3306 SigmXpforglfit[ist][iModX[ist]] = leftoverXpsigsp_[ist][iModX[ist]][iClustXMod[ist]];
3307 Yforglfit[ist][iModX[ist]] = leftoverYsp_[ist][iModX[ist]][iClustXMod[ist]];
3308 SigmYforglfit[ist][iModX[ist]] = leftoverYsigsp_[ist][iModX[ist]][iClustXMod[ist]];
3309 }
3310 //--search iside 2nd station--
3311 //--search 5p in X line--
3312 if (fDebug)
3313 cout << " try to search 5th p. Sec_St " << Sec_St << " Nmod_Sec " << Nmod_Sec << endl;
3314 for (Int_t imod2 = 0; imod2 < Nmod_Sec; imod2++) {
3315
3316 // if ( fDebug) cout<< " imod2 "<<imod2 <<endl;
3317 if (x5_exist) {
3318 Npoint = 5;
3319 break;
3320 }
3321
3322 for (Int_t clx2 = 0; clx2 < NleftoverX_[Sec_St][imod2]; clx2++) {
3323 // if ( fDebug) cout<< " clx2 "<<clx2 <<endl;
3324
3325 iModX[Sec_St] = -1;
3326 iClustXMod[Sec_St] = -1;
3327 Xforglfit[Sec_St][iModX[Sec_St]] = -999.;
3328 SigmXforglfit[Sec_St][iModX[Sec_St]] = -999.;
3329 Xpforglfit[Sec_St][iModX[Sec_St]] = -999.;
3330 SigmXpforglfit[Sec_St][iModX[Sec_St]] = -999.;
3331
3332 if (fDebug)
3333 cout << "search 5p in X. tmp x1 " << leftoverXsp_[Fi_St][imod1][cl1] << " x2 "
3334 << leftoverX_[Sec_St][imod2][clx2] << " hrd " << half_roadX1_X2 << endl;
3335 if (fabs(leftoverXsp_[Fi_St][imod1][cl1] - leftoverX_[Sec_St][imod2][clx2]) > half_roadX1_X2)
3336 continue;
3337 if (fDebug)
3338 cout << "found 5th p in X" << Sec_St << " " << leftoverX_[Sec_St][imod2][clx2] << endl;
3339
3340 Npoint = 5;
3341 // -- special case for neibour points --
3342 if (clx2 < (NleftoverX_[Sec_St][imod2] - 1)) {
3343 if (fabs(leftoverXsp_[Fi_St][imod1][cl1] - leftoverX_[Sec_St][imod2][clx2])
3344 > fabs(leftoverXsp_[Fi_St][imod1][cl1] - leftoverX_[Sec_St][imod2][clx2 + 1]))
3345 continue;
3346 }
3347
3348 iModX[Sec_St] = imod2;
3349 iClustXMod[Sec_St] = clx2;
3350 Xforglfit[Sec_St][iModX[Sec_St]] = leftoverX_[Sec_St][iModX[Sec_St]][clx2];
3351 SigmXforglfit[Sec_St][iModX[Sec_St]] = leftoverXsig_[Sec_St][iModX[Sec_St]][clx2];
3352 Xpforglfit[Sec_St][iModX[Sec_St]] = -999.;
3353 SigmXpforglfit[Sec_St][iModX[Sec_St]] = -999.;
3354
3355 //--------------------------- GlobalFit---------------------------------
3356 TotalNumberOfHits = 0;
3357 ChiSquareNdf = 0.;
3358 ChiSquare = 0.;
3359
3360 for (Int_t coeff = 0; coeff < 4; ++coeff) {
3361 line[coeff] = 0.;
3362 }
3363
3365 ChiSquare, line);
3366
3367 TotalNumberOfHits = Npoint;
3368 if (Npoint > 4)
3369 ChiSquareNdf = ChiSquare / (TotalNumberOfHits - 4);
3370 else
3371 ChiSquareNdf = ChiSquare;
3372
3373 if (fDebug)
3374 cout << " before cut ChiSquareNDF " << ChiSquareNdf << " TotalNumberOfHits "
3375 << TotalNumberOfHits << endl;
3376 if (fDebug)
3377 cout << endl;
3378
3379 if (ChiSquareNdf > Chi2_Globcut) {
3380 Npoint = 4;
3381 iModX[Sec_St] = -1;
3382 iClustXMod[Sec_St] = -1;
3383 Xforglfit[Sec_St][iModX[Sec_St]] = -999.;
3384 SigmXforglfit[Sec_St][iModX[Sec_St]] = -999.;
3385 Xpforglfit[Sec_St][imod2] = -999.;
3386 SigmXpforglfit[Sec_St][imod2] = -999.;
3387 x5_exist = 0;
3388 continue;
3389 }
3390
3391 x5_exist = 1;
3392 if (fDebug)
3393 cout << " case2: x5_exist " << endl;
3394 if (fDebug)
3395 cout << " X " << Xforglfit[Sec_St][iModX[Sec_St]] << " strip "
3396 << XClust_[Sec_St][iModX[Sec_St]][iClustXMod[Sec_St]] << " Q "
3397 << sumQx_[Sec_St][iModX[Sec_St]][iClustXMod[Sec_St]] << endl;
3398
3399 break; // goto next iMod of 2-nd st
3400 } // clx2
3401
3402 // --try to search 5th xp--
3403 if (x5_exist)
3404 continue;
3405
3406 xp5_exist = 0;
3407 for (Int_t clxp2 = 0; clxp2 < NleftoverXp_[Sec_St][imod2]; clxp2++) {
3408 if (xp5_exist) {
3409 Npoint = 5;
3410 break;
3411 }
3412
3413 iModX[Sec_St] = -1;
3414 iClustXMod[Sec_St] = -1;
3415 Xforglfit[Sec_St][iModX[Sec_St]] = -999.;
3416 SigmXforglfit[Sec_St][iModX[Sec_St]] = -999.;
3417 Xpforglfit[Sec_St][imod2] = -999.;
3418 SigmXpforglfit[Sec_St][imod2] = -999.;
3419
3420 Int_t st1 = Fi_St;
3421 Int_t st2 = Sec_St;
3422 Int_t sign1 = Angle(st1, imod1);
3423 Int_t sign2 = Angle(st2, imod2);
3424 if (fDebug)
3425 cout << " sign1 " << sign1 << " sign2 " << sign2 << endl;
3426
3427 if ((sign1 == sign2)
3428 && (fabs(leftoverXpsp_[Fi_St][imod1][cl1] - leftoverXp_[Sec_St][imod2][clxp2])
3430 continue;
3431 if ((sign1 != sign2)
3432 && (fabs(leftoverXpsp_[Fi_St][imod1][cl1] - leftoverXp_[Sec_St][imod2][clxp2])
3434 continue;
3435 if (fDebug)
3436 cout << " --Xp1 " << leftoverXpsp_[Fi_St][imod1][cl1] << " Xp2 "
3437 << leftoverXp_[Sec_St][imod2][clxp2] << " dXp "
3438 << leftoverXpsp_[Fi_St][imod1][cl1] - leftoverXp_[Sec_St][imod2][clxp2] << endl;
3439
3440 Npoint = 5;
3441
3442 iModX[Sec_St] = imod2;
3443 iClustXMod[Sec_St] = clxp2;
3444 Xforglfit[Sec_St][iModX[Sec_St]] = -999.;
3445 SigmXforglfit[Sec_St][iModX[Sec_St]] = -999.;
3446 Xpforglfit[Sec_St][imod2] = leftoverXp_[Sec_St][iModX[Sec_St]][clxp2];
3447 SigmXpforglfit[Sec_St][imod2] = leftoverXpsig_[Sec_St][iModX[Sec_St]][clxp2];
3448
3449 //---------------------------GlobalFit---------------------------------
3450 TotalNumberOfHits = 0;
3451 ChiSquareNdf = 0.;
3452 ChiSquare = 0.;
3453
3454 for (Int_t coeff = 0; coeff < 4; ++coeff) {
3455 line[coeff] = 0.;
3456 }
3457
3459 ChiSquare, line);
3460
3461 TotalNumberOfHits = Npoint;
3462 if (Npoint > 4)
3463 ChiSquareNdf = ChiSquare / (TotalNumberOfHits - 4);
3464 else
3465 ChiSquareNdf = ChiSquare;
3466
3467 if (fDebug)
3468 cout << " before cut ChiSquareNDF " << ChiSquareNdf << " TotalNumberOfHits "
3469 << TotalNumberOfHits << endl;
3470 if (fDebug)
3471 cout << endl;
3472
3473 if (ChiSquareNdf > Chi2_Globcut) {
3474 Npoint = 4;
3475 iModX[Sec_St] = -1;
3476 iClustXMod[Sec_St] = -1;
3477 Xforglfit[Sec_St][iModX[Sec_St]] = -999.;
3478 SigmXforglfit[Sec_St][iModX[Sec_St]] = -999.;
3479 Xpforglfit[Sec_St][imod2] = -999.;
3480 SigmXpforglfit[Sec_St][imod2] = -999.;
3481 xp5_exist = 0;
3482 continue;
3483 }
3484
3485 xp5_exist = 1;
3486 if (fDebug)
3487 cout << " case2: xp5_exist " << xp5_exist << endl;
3488 if (fDebug)
3489 cout << " Xp " << Xpforglfit[Sec_St][iModX[Sec_St]] << " strip "
3490 << XpClust_[Sec_St][iModX[Sec_St]][iClustXMod[Sec_St]] << " Q "
3491 << sumQxp_[Sec_St][iModX[Sec_St]][iClustXMod[Sec_St]] << endl;
3492
3493 break;
3494 } // clxp2
3495 if (xp5_exist)
3496 break;
3497 } // imod2
3498 // try find 5th xp.
3499
3500 if (fDebug)
3501 cout << " case2: end search ------------" << endl;
3502 if (fDebug)
3503 cout << " Npoint " << Npoint << " ChiSquareNdf " << ChiSquareNdf << " x5_exist " << x5_exist
3504 << " xp5_exist " << xp5_exist << endl;
3505
3506 TotalNumberOfHits = Npoint;
3507 Int_t Mod_cand[fNstations];
3508 Double_t X_cand[fNstations], Xp_cand[fNstations], Y_cand[fNstations], SigX_cand[fNstations],
3509 SigXp_cand[fNstations], SigY_cand[fNstations], Chi2_cand = 999., line_cand[4];
3510
3511 for (Int_t coeff = 0; coeff < 4; ++coeff) {
3512 line_cand[coeff] = 0.;
3513 }
3514
3515 for (Int_t st = 1; st < fNstations; ++st) {
3516 Mod_cand[st] = -1;
3517 X_cand[st] = -999.;
3518 Xp_cand[st] = -999.;
3519 Y_cand[st] = -999.;
3520 SigX_cand[st] = -999.;
3521 SigXp_cand[st] = -999.;
3522 SigY_cand[st] = -999.;
3523 }
3524
3525 if (TotalNumberOfHits > 4 && ChiSquareNdf < Chi2_cand && ChiSquareNdf < Chi2_Globcut) {
3526
3527 Chi2_cand = ChiSquareNdf;
3528 line_cand[0] = line[0];
3529 line_cand[1] = line[1];
3530 line_cand[2] = line[2];
3531 line_cand[3] = line[3];
3532
3533 if (fDebug)
3534 cout << " case2 5p cand Chi2Ndf " << Chi2_cand << endl;
3535
3536 for (Int_t st = 1; st < fNstations; ++st) {
3537 if (iModX[st] < 0)
3538 continue;
3539
3540 Mod_cand[st] = iModX[st];
3541 X_cand[st] = Xforglfit[st][iModX[st]];
3542 Y_cand[st] = Yforglfit[st][iModX[st]];
3543 Xp_cand[st] = Xpforglfit[st][iModX[st]];
3544 SigX_cand[st] = SigmXforglfit[st][iModX[st]];
3545 SigY_cand[st] = SigmYforglfit[st][iModX[st]];
3546 SigXp_cand[st] = SigmXpforglfit[st][iModX[st]];
3547
3548 if (fDebug)
3549 cout << " X_cand[" << st << "] " << X_cand[st] << " Xp_cand[" << st << "] " << Xp_cand[st]
3550 << " iModX " << iModX[st] << endl;
3551 }
3552 } // 5 points
3553
3554 if (TotalNumberOfHits == 4) {
3555 if (fDebug)
3556 cout << "TotalNumberOfHits == 4" << endl;
3557
3558 Chi2_cand = 0.;
3559
3560 line_cand[0] = ax_candidate;
3561 line_cand[1] = xv_candidate + ax_candidate * (Zcentr - Z0_SRC_target); // fix me!
3562 line_cand[2] = ay_candidate;
3563 line_cand[3] = yv_candidate + ay_candidate * (Zcentr - Z0_SRC_target);
3564
3565 if (fDebug)
3566 cout << " case2 4p cand Xv " << xv_candidate << " Yv " << yv_candidate << endl;
3567 if (fDebug)
3568 cout << " ax " << line_cand[0] << " bx " << line_cand[1] << " ay " << line_cand[2] << " by "
3569 << line_cand[3] << endl;
3570
3571 for (Int_t st = 1; st < fNstations; ++st) {
3572 if (iModX[st] < 0)
3573 continue;
3574
3575 Mod_cand[st] = iModX[st];
3576 X_cand[st] = Xforglfit[st][iModX[st]];
3577 Y_cand[st] = Yforglfit[st][iModX[st]];
3578 Xp_cand[st] = Xpforglfit[st][iModX[st]];
3579 SigX_cand[st] = SigmXforglfit[st][iModX[st]];
3580 SigY_cand[st] = SigmYforglfit[st][iModX[st]];
3581 SigXp_cand[st] = SigmXpforglfit[st][iModX[st]];
3582
3583 if (fDebug)
3584 cout << " X_cand[" << st << "] " << X_cand[st] << " Xp_cand[" << st << "] " << Xp_cand[st]
3585 << " iModX " << iModX[st] << endl;
3586
3587 } // st
3588 } // 4points
3589
3590 // --write best 4p or 5p tracks--
3591 if (TotalNumberOfHits >= 4 && Chi2_cand < Chi2_Globcut) {
3592
3593 if (fDebug) {
3594 cout << "case2: before writing: " << endl;
3595 for (Int_t st = 1; st < fNstations; ++st) {
3596 cout << " st " << st << " X_cand " << X_cand[st] << " Xp_cand " << Xp_cand[st]
3597 << endl;
3598 }
3599 }
3600
3601 if (fabs(line_cand[2] * (Z0_SRC_target - Zcentr) + line_cand[3]) > half_target_regionY) {
3602 if (fDebug)
3603 cout << " case2:--------half_target_regionY cut: " << half_target_regionY << " Yv "
3604 << fabs(line_cand[2] * (Z0_SRC_target - Zcentr) + line_cand[3]) << endl;
3605 ChiSquareNdf = 999.;
3606 continue;
3607 }
3608
3609 for (size_t itr = 0; itr < vec_tracks_.size(); ++itr) {
3610 // deleting randomly recorded tracks
3611 if (fDebug) {
3612 for (Int_t st = 1; st < fNstations; ++st) {
3613 cout << " itr " << itr << " st " << st << " X_tr " << vec_tracks_.at(itr).CoordX[st]
3614 << " Xp_tr " << vec_tracks_.at(itr).CoordXp[st] << endl;
3615 }
3616 }
3617 if (((vec_tracks_.at(itr).CoordX[1] == X_cand[1] && X_cand[1] > -900.)
3618 || (vec_tracks_.at(itr).CoordXp[1] == Xp_cand[1] && Xp_cand[1] > -900.))
3619 || ((vec_tracks_.at(itr).CoordX[2] == X_cand[2] && X_cand[2] > -900.)
3620 || (vec_tracks_.at(itr).CoordXp[2] == Xp_cand[2] && Xp_cand[2] > -900.))
3621 || ((vec_tracks_.at(itr).CoordX[3] == X_cand[3] && X_cand[3] > -900.)
3622 || (vec_tracks_.at(itr).CoordXp[3] == Xp_cand[3] && Xp_cand[3] > -900.))
3623
3624 )
3625 {
3626 if (fDebug)
3627 cout << " TotalNumberOfHits " << TotalNumberOfHits << " Nhits[" << itr << "] "
3628 << vec_tracks_.at(itr).Nhits << endl;
3629 if (vec_tracks_.at(itr).Nhits < TotalNumberOfHits) {
3630 vec_tracks_.erase(vec_tracks_.begin() + itr);
3631 continue;
3632 }
3633 if (vec_tracks_.at(itr).Nhits > TotalNumberOfHits) {
3634 if (fDebug)
3635 cout << " Nhits > TotalNumberOfHits . Reject cand " << endl;
3636 Chi2_cand = 999.;
3637 continue;
3638 }
3639
3640 if (vec_tracks_.at(itr).Nhits == TotalNumberOfHits && TotalNumberOfHits == 4) {
3641 if (fDebug)
3642 cout << " Nhits " << vec_tracks_.at(itr).Nhits << " X1 "
3643 << vec_tracks_.at(itr).CoordX[1] << " X2 " << vec_tracks_.at(itr).CoordX[2]
3644 << endl;
3645
3646 if ((fabs(vec_tracks_.at(itr).Xv) + 0.25 * fabs(vec_tracks_.at(itr).Yv))
3647 > (fabs(xv_candidate) + 0.25 * fabs(yv_candidate)))
3648 { // v2 closed to v1
3649 vec_tracks_.erase(vec_tracks_.begin() + itr);
3650 continue;
3651 } else {
3652 if (fDebug)
3653 cout << " Nhits == TotalNumberOfHits == 4 . Reject cand " << endl;
3654 Chi2_cand = 999.;
3655 continue;
3656 }
3657 }
3658
3659 if (vec_tracks_.at(itr).Nhits == TotalNumberOfHits && TotalNumberOfHits == 5) {
3660 if (vec_tracks_.at(itr).Chi2 > Chi2_cand) {
3661 vec_tracks_.erase(vec_tracks_.begin() + itr);
3662 continue;
3663 } else {
3664 if (fDebug)
3665 cout << " Nhits == TotalNumberOfHits == 5 . Reject cand ??? " << endl;
3666 Chi2_cand = 999.;
3667 continue;
3668 }
3669 }
3670 if (vec_tracks_.at(itr).Nhits > TotalNumberOfHits) {
3671 if (fDebug)
3672 cout << " Nhits=5 > TotalNumberOfHits=4 . Reject cand ??? " << endl;
3673 Chi2_cand = 999.;
3674 }
3675 } // if
3676 } // itr
3677
3678 if (fDebug)
3679 cout << " Chi2_cand " << Chi2_cand << endl;
3680 if (Chi2_cand > Chi2_Globcut)
3681 continue;
3682
3683 tmpTr.Chi2 = Chi2_cand;
3684 tmpTr.Nhits = TotalNumberOfHits;
3685 tmpTr.Xv = xv_candidate;
3686 tmpTr.Yv = yv_candidate;
3687 tmpTr.param[0] = line_cand[0];
3688 tmpTr.param[1] = line_cand[1];
3689 tmpTr.param[2] = line_cand[2];
3690 tmpTr.param[3] = line_cand[3];
3691
3692 if (fDebug)
3693 cout << " Xv_candidate " << xv_candidate << " Yv_candidate " << yv_candidate << " ChiNdf "
3694 << Chi2_cand << endl;
3695 for (Int_t st = 1; st < fNstations; ++st) {
3696 if (Mod_cand[st] < 0)
3697 continue;
3698
3699 tmpTr.ModNum[st] = iModX[st];
3700 tmpTr.CoordX[st] = X_cand[st];
3701 tmpTr.CoordXp[st] = Xp_cand[st];
3702 tmpTr.SigmaX[st] = SigX_cand[st];
3703 tmpTr.SigmaXp[st] = SigXp_cand[st];
3704 tmpTr.CoordZ[st] = ZstnCforglfit[st][Mod_cand[st]];
3705 tmpTr.CoordY[st] = Y_cand[st];
3706 tmpTr.SigmaY[st] = SigY_cand[st];
3707
3708 if (st == Sec_St) {
3709 tmpTr.StripNumX[st] = XClust_[st][iModX[st]][iClustXMod[st]];
3710 tmpTr.StripNumXp[st] = XpClust_[st][iModX[st]][iClustXMod[st]];
3711 tmpTr.ClSizeX[st] = XClust_width_[st][iModX[st]][iClustXMod[st]];
3712 tmpTr.ClSizeXp[st] = XpClust_width_[st][iModX[st]][iClustXMod[st]];
3713 tmpTr.SumQX[st] = sumQx_[st][iModX[st]][iClustXMod[st]];
3714 tmpTr.SumQXp[st] = sumQxp_[st][iModX[st]][iClustXMod[st]];
3715
3716 } else {
3717 tmpTr.StripNumX[st] = XspClust_[st][iModX[st]][iClustXMod[st]];
3718 tmpTr.StripNumXp[st] = XpspClust_[st][iModX[st]][iClustXMod[st]];
3719 tmpTr.ClSizeX[st] = XspClust_width_[st][iModX[st]][iClustXMod[st]];
3720 tmpTr.ClSizeXp[st] = XpspClust_width_[st][iModX[st]][iClustXMod[st]];
3721 tmpTr.SumQX[st] = sumQxsp_[st][iModX[st]][iClustXMod[st]];
3722 tmpTr.SumQXp[st] = sumQxpsp_[st][iModX[st]][iClustXMod[st]];
3723 }
3724 if (fDebug)
3725 cout << " st " << st << " Z " << tmpTr.CoordZ[st] << endl;
3726 if (fDebug)
3727 cout << " tmpTr.CoordX[" << st << "] " << tmpTr.CoordX[st] << " strip " << tmpTr.StripNumX[st]
3728 << " Clsize " << tmpTr.ClSizeX[st] << " Q " << tmpTr.SumQX[st] << endl;
3729 if (fDebug)
3730 cout << " tmpTr.CoordXp[" << st << "] " << tmpTr.CoordXp[st] << " strip "
3731 << tmpTr.StripNumXp[st] << " Clsize " << tmpTr.ClSizeXp[st] << " Q " << tmpTr.SumQXp[st]
3732 << endl;
3733 } // st
3734
3735 vec_tracks_.push_back(tmpTr);
3736 if (fDebug)
3737 cout << " tmpTr.Xv " << tmpTr.Xv << " tmpTr.Yv " << tmpTr.Yv << endl;
3738 } // chi2
3739
3740 } // cl1
3741 } // st1
3742}
3743//----------------------------------------------------------------------
3744
3745//----------------------------------------------------------------------
3747 Double_t*** leftoverXsp_,
3748 Double_t*** leftoverXpsp_,
3749 Double_t*** leftoverYsp_,
3750 Double_t*** leftoverXsigsp_,
3751 Double_t*** leftoverXpsigsp_,
3752 Double_t*** leftoverYsigsp_,
3753 Int_t** NleftoverX_,
3754 Int_t** NleftoverXp_,
3755 Double_t*** leftoverX_,
3756 Double_t*** leftoverXp_,
3757 Double_t*** leftoverXsig_,
3758 Double_t*** leftoverXpsig_,
3759 vector<tracksX>& vec_tracks_,
3760 Double_t*** XClust_,
3761 Double_t*** XClust_width_,
3762 Double_t*** sumQx_,
3763 Double_t*** XpClust_,
3764 Double_t*** XpClust_width_,
3765 Double_t*** sumQxp_,
3766 Double_t*** XspClust_,
3767 Double_t*** XspClust_width_,
3768 Double_t*** sumQxsp_,
3769 Double_t*** XpspClust_,
3770 Double_t*** XpspClust_width_,
3771 Double_t*** sumQxpsp_)
3772{
3773 tracksX tmpTr;
3774
3775 if (fDebug)
3776 cout << " case3 " << endl;
3777
3778 Bool_t x5_exist = 0; //, xp5_exist = 0;
3779 Int_t Npoint = 0;
3780 Double_t TotalNumberOfHits = 0;
3781 Double_t ChiSquareNdf = 999.;
3782 Double_t hrd_case3 = 0.7; // 0.5;
3783
3784 for (Int_t imod1 = 0; imod1 < fNmodules1; imod1++) {
3785 for (Int_t cl1 = 0; cl1 < Nleftoversp_[1][imod1]; cl1++) {
3786
3787 for (Int_t imod2 = 0; imod2 < fNmodules2; imod2++) {
3788 for (Int_t cl2 = 0; cl2 < Nleftoversp_[2][imod2]; cl2++) {
3789
3790 Bool_t was_candidate = 0;
3791 Int_t iClustXMod_candidate = -1, iModX_candidate = -1;
3792 Double_t ax12_from_target = 999., x_ex3 = 999., ay12_from_target = 999., y_ex3 = 999.;
3793 Double_t /*y1_2_cand = 999, */ ay1_2_cand = 999;
3794 Double_t bx_candidate = 999., by_candidate = 999.;
3795
3796 for (Int_t i = 1; i < fNstations; ++i) {
3797 iClustXMod[i] = -1; // reset pointers
3798 iModX[i] = -1;
3799 }
3800
3801 if (fabs(leftoverXsp_[1][imod1][cl1] - leftoverXsp_[2][imod2][cl2]) > half_roadX1_X2)
3802 continue;
3803 if (fabs(leftoverXsp_[1][imod1][cl1] - leftoverXpsp_[1][imod1][cl1]) > half_roadX1_Xp1)
3804 continue;
3805 if (fabs(leftoverXsp_[2][imod2][cl2] - leftoverXpsp_[2][imod2][cl2]) > half_roadX2_Xp2)
3806 continue;
3807 if (fabs(leftoverYsp_[1][imod1][cl1] - leftoverYsp_[2][imod2][cl2]) > half_roadY1_Y2)
3808 continue;
3809
3810 iClustXMod[1] = cl1;
3811 iClustXMod[2] = cl2;
3812 iModX[1] = imod1;
3813 iModX[2] = imod2;
3814
3815 if (fDebug)
3816 cout << "case3: iModX[1] " << iModX[1] << " iCl " << iClustXMod[1] << " iModX[2] " << iModX[2]
3817 << " iCl " << iClustXMod[2] << endl;
3818
3819 Double_t z1_2 = 0.5 * (Zstation[1][imod1] + Zstation[2][imod2]);
3820 Double_t y1_2 = 0.5 * (leftoverYsp_[1][imod1][cl1] + leftoverYsp_[2][imod2][cl2]);
3821 ax12_from_target = (Xv_av - leftoverXsp_[1][imod1][cl1]) / (Z0_SRC_target - Zstation[1][imod1]);
3822 ay12_from_target = (Yv_av - y1_2) / (Z0_SRC_target - z1_2);
3823
3824 if (fDebug)
3825 cout << " ax12_from_target " << ax12_from_target << " Xv_av " << Xv_av << " Yv_av " << Yv_av
3826 << endl;
3827
3828 for (Int_t ist = 1; ist < fNstations; ++ist) {
3829 for (Int_t imod = 0; imod < fNmodules; imod++) {
3830 Xforglfit[ist][imod] = -999.;
3831 Yforglfit[ist][imod] = -999.;
3832 Xpforglfit[ist][imod] = -999.;
3833 SigmYforglfit[ist][imod] = -999.;
3834 SigmXforglfit[ist][imod] = -999.;
3835 SigmXpforglfit[ist][imod] = -999.;
3836 }
3837 }
3838
3839 for (Int_t ist = 1; ist < fNstations; ++ist) {
3840 if (ist > 2)
3841 continue;
3842 Xforglfit[ist][iModX[ist]] = leftoverXsp_[ist][iModX[ist]][iClustXMod[ist]];
3843 SigmXforglfit[ist][iModX[ist]] = leftoverXsigsp_[ist][iModX[ist]][iClustXMod[ist]];
3844 Xpforglfit[ist][iModX[ist]] = leftoverXpsp_[ist][iModX[ist]][iClustXMod[ist]];
3845 SigmXpforglfit[ist][iModX[ist]] = leftoverXpsigsp_[ist][iModX[ist]][iClustXMod[ist]];
3846 Yforglfit[ist][iModX[ist]] = leftoverYsp_[ist][iModX[ist]][iClustXMod[ist]];
3847 SigmYforglfit[ist][iModX[ist]] = leftoverYsigsp_[ist][iModX[ist]][iClustXMod[ist]];
3848 }
3849 // --start look 3st---
3850 for (Int_t imod3 = 0; imod3 < fNmodules3; imod3++) {
3851 for (Int_t clx3 = 0; clx3 < NleftoverX_[3][imod3]; clx3++) {
3852
3853 x_ex3 = ax12_from_target * (Zstation[3][imod3] - Z0_SRC_target) + Xv_av;
3854 y_ex3 = ay12_from_target * (Zstation[3][imod3] - Z0_SRC_target) + Yv_av;
3855
3856 if (fDebug)
3857 cout << " X1 " << leftoverXsp_[1][imod1][cl1] << " X2 " << leftoverXsp_[2][imod2][cl2]
3858 << " x_ex3 " << x_ex3 << endl;
3859 if (fDebug)
3860 cout << " Y1 " << leftoverYsp_[1][imod1][cl1] << " Y2 " << leftoverYsp_[2][imod2][cl2]
3861 << " y_ex3 " << y_ex3 << endl;
3862
3863 if (fabs(x_ex3 - leftoverX_[3][imod3][clx3]) > hrd_case3)
3864 continue;
3865
3866 if (!was_candidate) {
3867
3868 iModX_candidate = imod3;
3869 iClustXMod_candidate = clx3;
3870 was_candidate = 1;
3871
3872 // y1_2_cand = y1_2;
3873 ay1_2_cand = ay12_from_target;
3874 if (fDebug)
3875 cout << " write candidate3 x3 = " << leftoverX_[3][imod3][clx3] << endl;
3876 } else {
3877 if ((x_ex3 - leftoverX_[3][imod3][clx3])
3878 < (x_ex3 - leftoverX_[3][iModX_candidate][iClustXMod_candidate]))
3879 {
3880 iModX_candidate = imod3;
3881 iClustXMod_candidate = clx3;
3882 // y1_2_cand = y1_2;
3883 ay1_2_cand = ay12_from_target;
3884 if (fDebug)
3885 cout << " re-write cand3 x3 = " << leftoverX_[3][imod3][clx3] << endl;
3886 }
3887 } // else
3888
3889 if (was_candidate)
3890 Npoint = 5;
3891
3892 } // clx3
3893 } // st3
3894
3895 if (was_candidate) {
3896 iModX[3] = iModX_candidate;
3897 iClustXMod[3] = iClustXMod_candidate;
3898 Xforglfit[3][iModX_candidate] = leftoverX_[3][iModX_candidate][iClustXMod_candidate];
3899 SigmXforglfit[3][iModX_candidate] = leftoverXsig[3][iModX_candidate][iClustXMod_candidate];
3900 Xpforglfit[3][iModX_candidate] = -999.;
3901 SigmXpforglfit[3][iModX_candidate] = -999.;
3902 Yforglfit[3][iModX_candidate] = -999.;
3903 SigmYforglfit[3][iModX_candidate] = -999.;
3904
3905 //--------------------------- GlobalFit 5p --------------------------------
3906
3907 for (Int_t coeff = 0; coeff < 4; ++coeff) {
3908 line[coeff] = 0.;
3909 }
3910
3912 ChiSquare, line);
3913
3914 TotalNumberOfHits = Npoint;
3915 if (Npoint > 4)
3916 ChiSquareNdf = ChiSquare / (TotalNumberOfHits - 4);
3917 else
3918 ChiSquareNdf = ChiSquare;
3919
3920 if (fDebug)
3921 cout << " case3 x: before cut ChiSquareNDF " << ChiSquareNdf << " TotalNumberOfHits "
3922 << TotalNumberOfHits << " fitted line par " << line[0] << " " << line[1] << " "
3923 << line[2] << " " << line[3] << endl;
3924 if (fDebug)
3925 cout << endl;
3926
3927 } // if ( was_candidate )
3928 if (ChiSquareNdf < Chi2_Globcut) {
3929
3930 x5_exist = 1;
3931 line[2] = ay1_2_cand;
3932 line[3] = Yv_av - line[2] * (Z0_SRC_target - Zcentr);
3933 if (fDebug)
3934 cout << " replace to Yv-Y12 line par " << line[2] << " " << line[3] << endl;
3935
3936 } else {
3937 Npoint = 0;
3938 iModX[3] = -1;
3939 iClustXMod[3] = -1;
3940 Xforglfit[3][iModX[3]] = -999.;
3941 SigmXforglfit[3][iModX[3]] = -999.;
3942 Xpforglfit[3][iModX[3]] = -999.;
3943 SigmXpforglfit[3][iModX[3]] = -999.;
3944 iClustXMod_candidate = -1;
3945 x5_exist = 0;
3946 }
3947 if (fDebug)
3948 cout << "---x.----" << endl;
3949 if (fDebug)
3950 cout << "case3: end 3x st: iModX[1] " << iModX[1] << " iCl " << iClustXMod[1] << " iModX[2] "
3951 << iModX[2] << " iCl " << iClustXMod[2] << endl;
3952 // --try to search 5th xp--
3953 //---xp----
3954 // xp5_exist = 0;
3955 if (!x5_exist) {
3956
3957 was_candidate = 0;
3958 for (Int_t imod3 = 0; imod3 < fNmodules3; imod3++) {
3959 for (Int_t clxp3 = 0; clxp3 < NleftoverXp_[3][imod3]; clxp3++) {
3960 was_candidate = 0;
3961 iModX[3] = -1;
3962 iClustXMod[3] = -1;
3963 Xforglfit[3][iModX[3]] = -999.;
3964 SigmXforglfit[3][iModX[3]] = -999.;
3965 Xpforglfit[3][iModX[3]] = -999.;
3966 SigmXpforglfit[3][iModX[3]] = -999.;
3967
3968 x_ex3 = ax12_from_target * (Zstation[3][imod3] - Z0_SRC_target) + Xv_av;
3969 y_ex3 = ay12_from_target * (Zstation[3][imod3] - Z0_SRC_target) + Yv_av;
3970
3971 if (fDebug)
3972 cout << " X1 " << leftoverXsp_[1][imod1][cl1] << " X2 "
3973 << leftoverXsp_[2][imod2][cl2] << " x_ex3 " << x_ex3 << endl;
3974 if (fDebug)
3975 cout << " Y1 " << leftoverYsp_[1][imod1][cl1] << " Y2 "
3976 << leftoverYsp_[2][imod2][cl2] << " y_ex3 " << y_ex3 << endl;
3977
3978 Int_t st3 = 3;
3979 Double_t xp_ex3 = y_ex3 * (Angle(st3, imod3))*tg2_5 + x_ex3;
3980 if (fabs(xp_ex3 - leftoverXp_[3][imod3][clxp3]) > hrd_case3)
3981 continue;
3982
3983 if (!was_candidate) {
3984 iModX_candidate = imod3;
3985 iClustXMod_candidate = clxp3;
3986 was_candidate = 1;
3987 if (fDebug)
3988 cout << " write candidate3 xp3 = " << leftoverXp_[3][imod3][clxp3] << " xp_ex3 "
3989 << xp_ex3 << endl;
3990 } else {
3991 if (fabs(xp_ex3 - leftoverXp_[3][imod3][clxp3])
3992 < fabs(xp_ex3 - leftoverXp_[3][iModX_candidate][iClustXMod_candidate]))
3993 {
3994
3995 iModX_candidate = imod3;
3996 iClustXMod_candidate = clxp3;
3997 if (fDebug)
3998 cout << " re-write cand3 xp3 = " << leftoverXp_[3][imod3][clxp3]
3999 << " xp_ex3 " << xp_ex3 << endl;
4000 }
4001 } // else
4002
4003 if (was_candidate)
4004 Npoint = 5;
4005
4006 } // clxp3
4007 } // st3
4008
4009 if (was_candidate) {
4010 iModX[3] = iModX_candidate;
4011 iClustXMod[3] = iClustXMod_candidate;
4012 Xforglfit[3][iModX_candidate] = -999.;
4013 SigmXforglfit[3][iModX_candidate] = -999.;
4014 Xpforglfit[3][iModX_candidate] = leftoverXp_[3][iModX_candidate][iClustXMod_candidate];
4015 SigmXpforglfit[3][iModX_candidate] =
4016 leftoverXpsig[3][iModX_candidate][iClustXMod_candidate];
4017 Yforglfit[3][iModX_candidate] = -999.;
4018 SigmYforglfit[3][iModX_candidate] = -999.;
4019
4020 //--------------------------- GlobalFit---------------------------------
4021 TotalNumberOfHits = 0;
4022 ChiSquareNdf = 999.;
4023 ChiSquare = 999.;
4024
4025 for (Int_t coeff = 0; coeff < 4; ++coeff) {
4026 line[coeff] = 0.;
4027 }
4028
4030 ChiSquare, line);
4031
4032 TotalNumberOfHits = Npoint;
4033 if (Npoint > 4)
4034 ChiSquareNdf = ChiSquare / (TotalNumberOfHits - 4);
4035 else
4036 ChiSquareNdf = ChiSquare;
4037
4038 if (fDebug)
4039 cout << " case3 xp: before cut ChiSquareNDF " << ChiSquareNdf << " TotalNumberOfHits "
4040 << TotalNumberOfHits << " fitted line par " << line[0] << " " << line[1] << " "
4041 << line[2] << " " << line[3] << endl;
4042 if (fDebug)
4043 cout << endl;
4044 if (fDebug)
4045 cout << " ChiSquareNdf " << ChiSquareNdf << endl;
4046
4047 } // if (was_candidate > 0 ){
4048 if (fDebug)
4049 cout << " ChiSquareNdf " << ChiSquareNdf << endl;
4050
4051 if (ChiSquareNdf < Chi2_Globcut) {
4052
4053 if (fabs(line[2] * (Z0_SRC_target - Zcentr) + line[3]) > half_target_regionY) {
4054 line[2] = ay12_from_target;
4055 line[3] = Yv_av - line[2] * (Z0_SRC_target - Zcentr);
4056 if (fDebug)
4057 cout << " xp replace to Yv-Y12 line par " << line[2] << " " << line[3]
4058 << endl;
4059 }
4060
4061 // xp5_exist = 1;
4062 if (fDebug)
4063 cout << "xp5_exist" << endl;
4064
4065 } else {
4066 Npoint = 0;
4067 iModX[3] = -1;
4068 iClustXMod[3] = -1;
4069 Xforglfit[3][iModX[3]] = -999.;
4070 SigmXforglfit[3][iModX[3]] = -999.;
4071 Xpforglfit[3][iModX[3]] = -999.;
4072 SigmXpforglfit[3][iModX[3]] = -999.;
4073 // xp5_exist = 0;
4074 }
4075
4076 } // if ( !x5_exist){
4077 if (fDebug)
4078 cout << "---xp.----" << endl;
4079 if (fDebug)
4080 cout << " was_candidate " << was_candidate << endl;
4081 if (fDebug)
4082 cout << "case3: end 3xp st: iModX[1] " << iModX[1] << " iCl " << iClustXMod[1] << " iModX[2] "
4083 << iModX[2] << " iCl " << iClustXMod[2] << endl;
4084 if (fDebug)
4085 cout << " TotalNumberOfHits " << TotalNumberOfHits << " ChiSquareNdf " << ChiSquareNdf << endl;
4086 // Xpforglfit - > Xp_cand
4087
4088 Int_t Mod_cand[fNstations], iCl_cand[fNstations];
4089 Double_t X_cand[fNstations], Xp_cand[fNstations], Y_cand[fNstations], SigX_cand[fNstations],
4090 SigXp_cand[fNstations], SigY_cand[fNstations], Chi2_cand = 999., line_cand[4];
4091
4092 for (Int_t coeff = 0; coeff < 4; ++coeff) {
4093 line_cand[coeff] = 0.;
4094 }
4095
4096 for (Int_t st = 1; st < fNstations; ++st) {
4097 Mod_cand[st] = -1;
4098 iCl_cand[st] = -1;
4099 X_cand[st] = -999.;
4100 Xp_cand[st] = -999.;
4101 Y_cand[st] = -999.;
4102 SigX_cand[st] = -999.;
4103 SigXp_cand[st] = -999.;
4104 SigY_cand[st] = -999.;
4105 }
4106
4107 if (fDebug)
4108 cout << " TotalNumberOfHits " << TotalNumberOfHits << " ChiSquareNdf " << ChiSquareNdf
4109 << " Chi2_Globcut " << Chi2_Globcut << endl;
4110
4111 if (TotalNumberOfHits > 4) {
4112 if (fabs(line[0] * (Z0_SRC_target - Zcentr) + line[1]) > half_target_regionX) {
4113 if (fDebug)
4114 cout << " half_target_regionX cut: " << half_target_regionX << " Xv "
4115 << fabs(line[0] * (Z0_SRC_target - Zcentr) + line[1]) << endl;
4116 ChiSquareNdf = 999.;
4117 continue;
4118 }
4119 }
4120
4121 if (TotalNumberOfHits > 4 && ChiSquareNdf < Chi2_cand && ChiSquareNdf < Chi2_Globcut
4122 && was_candidate)
4123 {
4124 if (fDebug)
4125 cout << " TotalNumberOfHits " << TotalNumberOfHits << " ChiSquareNdf " << ChiSquareNdf
4126 << endl;
4127 Chi2_cand = ChiSquareNdf;
4128 line_cand[0] = line[0];
4129 line_cand[1] = line[1];
4130 line_cand[2] = line[2];
4131 line_cand[3] = line[3];
4132
4133 for (Int_t st = 1; st < fNstations; ++st) {
4134 if (iModX[st] < 0)
4135 continue;
4136
4137 Mod_cand[st] = iModX[st];
4138 iCl_cand[st] = iClustXMod[st];
4139 X_cand[st] = Xforglfit[st][iModX[st]];
4140 Y_cand[st] = Yforglfit[st][iModX[st]];
4141 Xp_cand[st] = Xpforglfit[st][iModX[st]];
4142 SigX_cand[st] = SigmXforglfit[st][iModX[st]];
4143 SigY_cand[st] = SigmYforglfit[st][iModX[st]];
4144 SigXp_cand[st] = SigmXpforglfit[st][iModX[st]];
4145
4146 if (fDebug)
4147 cout << " X_cand[" << st << "] " << X_cand[st] << " Xp_cand[" << st << "] "
4148 << Xp_cand[st] << " iMod " << iModX[st] << " iCl " << iClustXMod[st]
4149 << " ClSizeXp " << XpspClust_width_[st][Mod_cand[st]][iClustXMod[st]] << endl;
4150 }
4151 } // 5 points
4152
4153 if (TotalNumberOfHits > 4 && Chi2_cand < Chi2_Globcut && was_candidate)
4154 { // ChiSquareNdf < Chi2_Globcut
4155
4156 for (size_t itr = 0; itr < vec_tracks_.size(); ++itr) {
4157 // deleting randomly recorded tracks
4158 if (((vec_tracks_.at(itr).CoordX[1] == X_cand[1] && X_cand[1] > -900.)
4159 || (vec_tracks_.at(itr).CoordXp[1] == Xp_cand[1] && Xp_cand[1] > -900.))
4160 || ((vec_tracks_.at(itr).CoordX[2] == X_cand[2] && X_cand[2] > -900.)
4161 || (vec_tracks_.at(itr).CoordXp[2] == Xp_cand[2] && Xp_cand[2] > -900.))
4162 || ((vec_tracks_.at(itr).CoordX[3] == X_cand[3] && X_cand[3] > -900.)
4163 || (vec_tracks_.at(itr).CoordXp[3] == Xp_cand[3] && Xp_cand[3] > -900.))
4164
4165 )
4166 {
4167 if (vec_tracks_.at(itr).Chi2 > Chi2_cand) {
4168 vec_tracks_.erase(vec_tracks_.begin() + itr);
4169 continue;
4170 } else {
4171 Chi2_cand = 999.;
4172 continue;
4173 }
4174 } // if
4175 } // itr
4176
4177 if (Chi2_cand > Chi2_Globcut)
4178 continue;
4179
4180 tmpTr.Chi2 = Chi2_cand;
4181 tmpTr.Nhits = TotalNumberOfHits;
4182 bx_candidate = line_cand[0] * (Z0_SRC_target - Zcentr) + line_cand[1];
4183 by_candidate = line_cand[2] * (Z0_SRC_target - Zcentr) + line_cand[3];
4184 tmpTr.Xv = bx_candidate;
4185 tmpTr.Yv = by_candidate;
4186 tmpTr.param[0] = line_cand[0];
4187 tmpTr.param[1] = line_cand[1];
4188 tmpTr.param[2] = line_cand[2];
4189 tmpTr.param[3] = line_cand[3];
4190
4191 if (fDebug)
4192 cout << " Xv_candidate " << bx_candidate << " Yv_candidate " << by_candidate
4193 << " ChiSquareNdf " << ChiSquareNdf << endl;
4194 for (Int_t st = 1; st < fNstations; ++st) {
4195 if (Mod_cand[st] < 0)
4196 continue;
4197
4198 tmpTr.ModNum[st] = iModX[st];
4199 tmpTr.CoordX[st] = X_cand[st];
4200 tmpTr.CoordXp[st] = Xp_cand[st];
4201 tmpTr.SigmaX[st] = SigX_cand[st];
4202 tmpTr.SigmaXp[st] = SigXp_cand[st];
4203 tmpTr.CoordZ[st] = ZstnCforglfit[st][Mod_cand[st]];
4204 tmpTr.CoordY[st] = Y_cand[st];
4205 tmpTr.SigmaY[st] = SigY_cand[st];
4206
4207 if (st < 3) {
4208 tmpTr.StripNumX[st] = XspClust_[st][Mod_cand[st]][iCl_cand[st]];
4209 tmpTr.StripNumXp[st] = XpspClust_[st][Mod_cand[st]][iCl_cand[st]];
4210 tmpTr.ClSizeX[st] = XspClust_width_[st][Mod_cand[st]][iCl_cand[st]];
4211 tmpTr.ClSizeXp[st] = XpspClust_width_[st][Mod_cand[st]][iCl_cand[st]];
4212 tmpTr.SumQX[st] = sumQxsp_[st][Mod_cand[st]][iCl_cand[st]];
4213 tmpTr.SumQXp[st] = sumQxpsp_[st][Mod_cand[st]][iCl_cand[st]];
4214 } else {
4215 tmpTr.StripNumX[st] = XClust_[st][iModX[st]][iClustXMod_candidate];
4216 tmpTr.StripNumXp[st] = XpClust_[st][iModX[st]][iClustXMod_candidate];
4217 tmpTr.ClSizeX[st] = XClust_width_[st][iModX[st]][iClustXMod_candidate];
4218 tmpTr.ClSizeXp[st] = XpClust_width_[st][iModX[st]][iClustXMod_candidate];
4219 tmpTr.SumQX[st] = sumQx_[st][iModX[st]][iClustXMod_candidate];
4220 tmpTr.SumQXp[st] = sumQxp_[st][iModX[st]][iClustXMod_candidate];
4221 }
4222
4223 if (fDebug)
4224 cout << " st " << st << " Z " << tmpTr.CoordZ[st] << endl;
4225 if (fDebug)
4226 cout << " tmpTr.CoordX[" << st << "] " << tmpTr.CoordX[st] << " strip "
4227 << tmpTr.StripNumX[st] << " Clsize " << tmpTr.ClSizeX[st] << " Q "
4228 << tmpTr.SumQX[st] << endl;
4229 if (fDebug)
4230 cout << " tmpTr.CoordXp[" << st << "] " << tmpTr.CoordXp[st] << " strip "
4231 << tmpTr.StripNumXp[st] << " Clsize " << tmpTr.ClSizeXp[st] << " Q "
4232 << tmpTr.SumQXp[st] << endl;
4233 } // st
4234
4235 vec_tracks_.push_back(tmpTr);
4236 } // chi2
4237
4238 } // cl2
4239 } // st2
4240 } // cl1
4241 } // st1
4242 if (fDebug)
4243 cout << endl;
4244 if (fDebug)
4245 cout << " after second case 3 write cand: " << vec_tracks_.size() << endl;
4246}
4247//----------------case3.-----------------------------------------------
4248
4249//----------------------------------------------------------------------
4251 Int_t** Nleftoversp_,
4252 Double_t*** leftoverXsp_,
4253 Double_t*** leftoverXpsp_,
4254 Double_t*** leftoverYsp_,
4255 Double_t*** leftoverXsigsp_,
4256 Double_t*** leftoverXpsigsp_,
4257 Double_t*** leftoverYsigsp_,
4258 Int_t** NleftoverX_,
4259 Int_t** NleftoverXp_,
4260 Double_t*** leftoverX_,
4261 Double_t*** leftoverXp_,
4262 Double_t*** leftoverXsig_,
4263 Double_t*** leftoverXpsig_,
4264 vector<tracksX>& vec_tracks_,
4265 Double_t*** XClust_,
4266 Double_t*** XClust_width_,
4267 Double_t*** sumQx_,
4268 Double_t*** XpClust_,
4269 Double_t*** XpClust_width_,
4270 Double_t*** sumQxp_,
4271 Double_t*** XspClust_,
4272 Double_t*** XspClust_width_,
4273 Double_t*** sumQxsp_,
4274 Double_t*** XpspClust_,
4275 Double_t*** XpspClust_width_,
4276 Double_t*** sumQxpsp_)
4277{
4278
4279 tracksX tmpTr;
4280
4281 Int_t Nmod_Fi = fNmodules1;
4282 Int_t Nmod_Sec = fNmodules2;
4283 Int_t Sec_St = 2;
4284
4285 if (Fi_St == 2) {
4286 Nmod_Fi = fNmodules2;
4287 Nmod_Sec = fNmodules1;
4288 Sec_St = 1;
4289 }
4290
4291 Int_t Mod_cand[fNstations], iCl_cand[fNstations];
4292 Double_t X_cand[fNstations], Xp_cand[fNstations], Y_cand[fNstations], SigX_cand[fNstations], SigXp_cand[fNstations],
4293 SigY_cand[fNstations], Chi2_cand = 999., line_cand[4];
4294
4295 for (Int_t coeff = 0; coeff < 4; ++coeff) {
4296 line_cand[coeff] = 0.;
4297 }
4298
4299 for (Int_t st = 1; st < fNstations; ++st) {
4300 Mod_cand[st] = -1;
4301 iCl_cand[st] = -1;
4302 X_cand[st] = -999.;
4303 Xp_cand[st] = -999.;
4304 Y_cand[st] = -999.;
4305 SigX_cand[st] = -999.;
4306 SigXp_cand[st] = -999.;
4307 SigY_cand[st] = -999.;
4308 }
4309
4310 Double_t bx_candidate = 999., by_candidate = 999.;
4311 // st 3 best Xv Yv
4312 // spatial points in 3 st
4313 for (Int_t imod3 = 0; imod3 < fNmodules3; imod3++) {
4314 for (Int_t cl3 = 0; cl3 < Nleftoversp_[3][imod3]; cl3++) {
4315
4316 Double_t Xv_min = 2.5, Yv_min = 2.5;
4317 // Bool_t was_candidate = 0;
4318 // points in 1 or 2 st
4319 for (Int_t imod1 = 0; imod1 < Nmod_Fi; imod1++) {
4320 for (Int_t cl1 = 0; cl1 < NleftoverX[Fi_St][imod1]; cl1++) {
4321
4322 Double_t ax_target_region = -999., ay_target_region = -999.;
4323 // Double_t ax_candidate = 999., ay_candidate = 999.;
4324
4325 for (Int_t imod2 = 0; imod2 < Nmod_Sec; imod2++) {
4326 for (Int_t cl2 = 0; cl2 < NleftoverXp_[Sec_St][imod2]; cl2++) {
4327
4328 if (fabs(leftoverX_[Fi_St][imod1][cl1] - leftoverXp_[Sec_St][imod2][cl2]) > half_roadX1_Xp2)
4329 continue;
4330
4331 Double_t z1_2 = 0.5 * (Zstation[1][imod1] + Zstation[2][imod2]);
4332 Double_t Y_1_2 = GetXYspatial_station1_2(Fi_St, imod2, leftoverX_[Fi_St][imod1][cl1],
4333 leftoverXp_[Sec_St][imod2][cl2]);
4334
4335 if (fDebug)
4336 cout << " Fi_St " << Fi_St << " X " << leftoverX_[Fi_St][imod1][cl1] << " Xp "
4337 << leftoverXp_[Sec_St][imod2][cl2] << " new Y " << Y_1_2 << endl;
4338
4339 ax_target_region = (leftoverX_[Fi_St][imod1][cl1] - leftoverXsp_[3][imod3][cl3])
4340 / (Zstation[Fi_St][imod1] - Zstation[3][imod3]);
4341 ay_target_region = (Y_1_2 - leftoverYsp_[3][imod3][cl3]) / (z1_2 - Zstation[3][imod3]);
4342
4343 Double_t Xv_cand =
4344 ax_target_region * (-z1_2 + Z0_SRC_target) + leftoverX_[Fi_St][imod1][cl1];
4345 Double_t Yv_cand = ay_target_region * (-z1_2 + Z0_SRC_target) + Y_1_2;
4346
4347 if (fabs(Xv_cand) > half_target_regionX)
4348 continue;
4349 if (fabs(Yv_cand) > half_target_regionY)
4350 continue;
4351
4352 if ((fabs(Xv_min) + 0.25 * fabs(Yv_min)) < (fabs(Xv_cand) + 0.25 * fabs(Yv_cand)))
4353 continue;
4354
4355 if (fDebug)
4356 cout << " Xv_cand " << Xv_cand << " Yv_cand " << Yv_cand << endl;
4357
4358 // was_candidate = 1;
4359
4360 Chi2_cand = 0.;
4361 bx_candidate = Xv_cand;
4362 by_candidate = Yv_cand;
4363
4364 line_cand[0] = ax_target_region;
4365 line_cand[1] = Xv_cand + ax_target_region * (Zcentr - Z0_SRC_target);
4366 line_cand[2] = ay_target_region;
4367 line_cand[3] = Yv_cand + ay_target_region * (Zcentr - Z0_SRC_target);
4368
4369 Mod_cand[Fi_St] = imod1;
4370 iCl_cand[Fi_St] = cl1;
4371 X_cand[Fi_St] = leftoverX_[Fi_St][imod1][cl1];
4372 Xp_cand[Fi_St] = -999.;
4373 Y_cand[Fi_St] = -999.;
4374 SigX_cand[Fi_St] = 1.;
4375 SigXp_cand[Fi_St] = 1.;
4376 SigY_cand[Fi_St] = 1.;
4377
4378 Mod_cand[Sec_St] = imod2;
4379 iCl_cand[Sec_St] = cl2;
4380 X_cand[Sec_St] = -999.;
4381 Xp_cand[Sec_St] = leftoverXp_[Sec_St][imod2][cl2];
4382 Y_cand[Sec_St] = -999.;
4383 SigX_cand[Sec_St] = 1.;
4384 SigXp_cand[Sec_St] = 1.;
4385 SigY_cand[Sec_St] = 1.;
4386
4387 Mod_cand[3] = imod3;
4388 iCl_cand[3] = cl3;
4389 X_cand[3] = leftoverXsp_[3][imod3][cl3];
4390 Xp_cand[3] = leftoverXpsp_[3][imod3][cl3];
4391 Y_cand[3] = leftoverYsp_[3][imod3][cl3];
4392 SigX_cand[3] = leftoverXsigsp_[3][imod3][cl3];
4393 SigXp_cand[3] = leftoverXpsigsp_[3][imod3][cl3];
4394 SigY_cand[3] = leftoverYsigsp_[3][imod3][cl3];
4395 }
4396 } // 2st
4397 }
4398 } // 1st
4399
4400 for (size_t itr = 0; itr < vec_tracks.size(); ++itr) {
4401 // deleting randomly recorded tracks
4402 if (((vec_tracks.at(itr).CoordX[1] == X_cand[1] && X_cand[1] > -900.)
4403 || (vec_tracks.at(itr).CoordXp[1] == Xp_cand[1] && Xp_cand[1] > -900.))
4404 || ((vec_tracks.at(itr).CoordX[2] == X_cand[2] && X_cand[2] > -900.)
4405 || (vec_tracks.at(itr).CoordXp[2] == Xp_cand[2] && Xp_cand[2] > -900.))
4406 || ((vec_tracks.at(itr).CoordX[3] == X_cand[3] && X_cand[3] > -900.)
4407 || (vec_tracks.at(itr).CoordXp[3] == Xp_cand[3] && Xp_cand[3] > -900.)))
4408 {
4409 if ((fabs(vec_tracks.at(itr).Xv) + 0.25 * fabs(vec_tracks.at(itr).Yv))
4410 > (fabs(bx_candidate) + 0.25 * fabs(by_candidate)))
4411 { // v2 closed to v1
4412 vec_tracks.erase(vec_tracks.begin() + itr);
4413 continue;
4414 } else {
4415 Chi2_cand = 999.;
4416 continue;
4417 }
4418 } // if
4419 } // itr
4420
4421 if (Chi2_cand > Chi2_Globcut)
4422 continue;
4423
4424 tmpTr.Chi2 = Chi2_cand;
4425 tmpTr.Nhits = 4;
4426 tmpTr.Xv = bx_candidate;
4427 tmpTr.Yv = by_candidate;
4428 tmpTr.param[0] = line_cand[0];
4429 tmpTr.param[1] = line_cand[1];
4430 tmpTr.param[2] = line_cand[2];
4431 tmpTr.param[3] = line_cand[3];
4432
4433 if (fDebug)
4434 cout << endl;
4435 if (fDebug)
4436 cout << " Xv_candidate " << bx_candidate << " Yv_candidate " << by_candidate << " Nhits "
4437 << tmpTr.Nhits << endl;
4438 for (Int_t st = 1; st < fNstations; ++st) {
4439 if (Mod_cand[st] < 0)
4440 continue;
4441
4442 tmpTr.ModNum[st] = iModX[st];
4443 tmpTr.CoordX[st] = X_cand[st];
4444 tmpTr.CoordXp[st] = Xp_cand[st];
4445 tmpTr.SigmaX[st] = SigX_cand[st];
4446 tmpTr.SigmaXp[st] = SigXp_cand[st];
4447 tmpTr.CoordZ[st] = ZstnCforglfit[st][Mod_cand[st]];
4448 tmpTr.CoordY[st] = Y_cand[st];
4449 tmpTr.SigmaY[st] = SigY_cand[st];
4450
4451 if (st > 3) {
4452 tmpTr.StripNumX[st] = XClust_[st][Mod_cand[st]][iCl_cand[st]];
4453 tmpTr.StripNumXp[st] = XpClust_[st][Mod_cand[st]][iCl_cand[st]];
4454 tmpTr.ClSizeX[st] = XClust_width_[st][Mod_cand[st]][iCl_cand[st]];
4455 tmpTr.ClSizeXp[st] = XpClust_width_[st][Mod_cand[st]][iCl_cand[st]];
4456 tmpTr.SumQX[st] = sumQx_[st][Mod_cand[st]][iCl_cand[st]];
4457 tmpTr.SumQXp[st] = sumQxp_[st][Mod_cand[st]][iCl_cand[st]];
4458 } else {
4459 tmpTr.StripNumX[st] = XspClust_[st][Mod_cand[st]][iCl_cand[st]];
4460 tmpTr.StripNumXp[st] = XpspClust_[st][Mod_cand[st]][iCl_cand[st]];
4461 tmpTr.ClSizeX[st] = XspClust_width_[st][Mod_cand[st]][iCl_cand[st]];
4462 tmpTr.ClSizeXp[st] = XpspClust_width_[st][Mod_cand[st]][iCl_cand[st]];
4463 tmpTr.SumQX[st] = sumQxsp_[st][Mod_cand[st]][iCl_cand[st]];
4464 tmpTr.SumQXp[st] = sumQxpsp_[st][Mod_cand[st]][iCl_cand[st]];
4465 }
4466
4467 if (fDebug)
4468 cout << " st " << st << " Z " << tmpTr.CoordZ[st] << endl;
4469 if (fDebug)
4470 cout << " tmpTr.CoordX[" << st << "] " << tmpTr.CoordX[st] << " strip " << tmpTr.StripNumX[st]
4471 << " Clsize " << tmpTr.ClSizeX[st] << " Q " << tmpTr.SumQX[st] << endl;
4472 if (fDebug)
4473 cout << " tmpTr.CoordXp[" << st << "] " << tmpTr.CoordXp[st] << " strip " << tmpTr.StripNumXp[st]
4474 << " Clsize " << tmpTr.ClSizeXp[st] << " Q " << tmpTr.SumQXp[st] << endl;
4475
4476 } // st
4477
4478 vec_tracks.push_back(tmpTr);
4479 if (fDebug)
4480 cout << " tmpTr.Xv " << tmpTr.Xv << " tmpTr.Yv " << tmpTr.Yv << endl;
4481 if (fDebug)
4482 cout << endl;
4483 }
4484 } // 3st sp
4485}
4486//----------------------------------------------------------------------
4487
4488//----------------------------------------------------------------------
4490{
4491
4492 // Int_t Nmod_Fi = fNmodules1;
4493 // Int_t Nmod_Sec = fNmodules2;
4494 Int_t Sec_St = 2;
4495 Double_t Ysp_1_2 = -999.0;
4496 Double_t YCoor_cand;
4497
4498 if (Fi_St == 2) {
4499 // Nmod_Fi = fNmodules2;
4500 // Nmod_Sec = fNmodules1;
4501 Sec_St = 1;
4502 }
4503
4504 if (XCoor > -900. && XpCoor > -900.) {
4505 YCoor_cand = (XpCoor - XCoor) / tg2_5;
4506
4507 if (YCoor_cand >= shiftY[Sec_St][imod] - 0.5 && YCoor_cand <= shiftY[Sec_St][imod] + 12. + 0.5) {
4508 Ysp_1_2 = YCoor_cand;
4509 }
4510 }
4511 return (Ysp_1_2);
4512}
4513
4514//----------------------------------------------------------------------
4516 Double_t** Xpforglfit_,
4517 Double_t** SigmXforglfit_,
4518 Double_t** SigmXpforglfit_,
4519 Int_t* iClustXMod_,
4520 Int_t* iModX_,
4521 Double_t& ChiSquare_,
4522 Double_t* line_)
4523{
4524
4525 //---------------------------GlobalFit---------------------------------
4526 ChiSquare_ = 0.;
4527 if (fDebug)
4528 cout << endl;
4529 if (fDebug)
4530 cout << "--GlobalFit--" << endl;
4531 // setting global fit matrices to zero
4532
4533 for (Int_t i = 0; i < 4; ++i) {
4534 for (Int_t j = 0; j < 4; ++j) {
4535 Amatr[i][j] = 0.;
4536 }
4537 }
4538 for (Int_t i = 0; i < 4; ++i) {
4539 rhs[i] = 0;
4540 line_[i] = 0;
4541 }
4542 for (Int_t i = 0; i < 16; ++i) {
4543 AmatrArray[i] = 0;
4544 }
4545 for (Int_t i = 0; i < 16; ++i) {
4546 AmatrInverted[i] = 0;
4547 }
4548
4549 GlobalFit(Xforglfit_, Xpforglfit_, ZstnCforglfit, SigmXforglfit_, SigmXpforglfit_, Amatr, rhs);
4550
4551 // here we do smth with Amatr & rhs (solving)
4552 // Amatr is row-major
4553 for (Int_t row = 0; row < 4; ++row) {
4554 for (Int_t col = 0; col < 4; ++col) {
4555 AmatrArray[4 * col + row] = Amatr[row][col];
4556 }
4557 } // AmatrArray is col-major
4558
4559 bool ifSuccess = InvertMatrix(AmatrArray, AmatrInverted);
4560
4561 if (!ifSuccess) {
4562 cout << "???? InvertMatrix is unsuccessfull ????" << endl;
4563 }
4564 if (!ifSuccess) {
4565 cout << "???? InvertMatrix is unsuccessfull ????" << endl;
4566 return;
4567 } // continue; } //FIXME: what does this mean?
4568
4569 for (Int_t coeff = 0; coeff < 4; ++coeff) {
4570 for (Int_t iCol = 0; iCol < 4; ++iCol) {
4571 line_[coeff] += AmatrInverted[4 * iCol + coeff] * rhs[iCol];
4572 }
4573 }
4574 // line_ = { ax, bx, ay, by}
4575 if (fDebug)
4576 cout << " ax " << line_[0] << " bx " << line_[1] << " ay " << line_[2] << " by " << line_[3] << endl;
4577
4578 //---------------------------Chi2---------------------------------
4579 if (fDebug)
4580 cout << "ChiSquare_ " << ChiSquare_ << endl;
4581 for (Int_t ist = 1; ist < fNstations; ++ist) {
4582 if (Xforglfit_[ist][iModX_[ist]] < -900.)
4583 continue;
4584
4585 Double_t hit = Xforglfit_[ist][iModX_[ist]];
4586 Double_t fit = line_[0] * ZstnCforglfit[ist][iModX_[ist]] + line_[1];
4587
4588 Double_t sigmaX_2 = SigmXforglfit_[ist][iModX_[ist]] * SigmXforglfit_[ist][iModX_[ist]];
4589 ChiSquare_ += ((hit - fit) * (hit - fit)) / (sigmaX_2);
4590 if (fDebug)
4591 cout << " ist " << ist << " hitx " << hit << " dx " << hit - fit << " Z "
4592 << ZstnCforglfit[ist][iModX_[ist]] << " sigma " << SigmXforglfit_[ist][iModX_[ist]] << " ChiSquare_ "
4593 << ChiSquare_ << endl;
4594 }
4595 for (Int_t ist = 1; ist < fNstations; ++ist) {
4596 if (Xpforglfit_[ist][iModX_[ist]] < -900.)
4597 continue;
4598
4599 Double_t hit = Xpforglfit_[ist][iModX_[ist]];
4600 Double_t fit = (line_[0] * ZstnCforglfit[ist][iModX_[ist]] + line_[1])
4601 + (line_[2] * ZstnCforglfit[ist][iModX_[ist]] + line_[3]) * Angle(ist, iModX_[ist])
4602 * tg2_5; // x' = x + y*tg //x*cos + y*sin
4603
4604 Double_t sigmaXp_2 = SigmXpforglfit_[ist][iModX_[ist]] * SigmXpforglfit_[ist][iModX_[ist]];
4605 ChiSquare_ += ((hit - fit) * (hit - fit)) / (sigmaXp_2);
4606 if (fDebug)
4607 cout << " ist " << ist << " hitxp " << hit << " dxp " << hit - fit << " Z "
4608 << ZstnCforglfit[ist][iModX_[ist]] << " sigma " << SigmXpforglfit_[ist][iModX_[ist]] << " ChiSquare_ "
4609 << ChiSquare_ << endl;
4610 } // ist
4611}
4612//----------------------------------------------------------------------
4613
4614//----function to calculate angle in modules----------------------------
4616{
4617
4618 Int_t sign = 0;
4619 if (st == 1 && Mod == 0)
4620 sign = -1;
4621 if (st == 1 && Mod == 1)
4622 sign = 1;
4623 if (st == 1 && Mod == 2)
4624 sign = 1;
4625 if (st == 1 && Mod == 3)
4626 sign = -1;
4627
4628 if (st == 2 && Mod == 0)
4629 sign = -1;
4630 if (st == 2 && Mod == 1)
4631 sign = 1;
4632
4633 if (st == 3 && Mod == 0)
4634 sign = -1;
4635 if (st == 3 && Mod == 1)
4636 sign = -1;
4637 if (st == 3 && Mod == 2)
4638 sign = 1;
4639 if (st == 3 && Mod == 3)
4640 sign = 1;
4641 if (st == 3 && Mod == 4)
4642 sign = 1;
4643 if (st == 3 && Mod == 5)
4644 sign = 1;
4645 if (st == 3 && Mod == 6)
4646 sign = -1;
4647 if (st == 3 && Mod == 7)
4648 sign = -1;
4649
4650 return (sign);
4651}
4652//----------------------------------------------------------------------
4653
4654//--------------------Matrix Coefficients Calculation--------------
4656{
4657 Double_t inv[16], det;
4658 int i;
4659
4660 inv[0] = m[5] * m[10] * m[15] - m[5] * m[11] * m[14] - m[9] * m[6] * m[15] + m[9] * m[7] * m[14]
4661 + m[13] * m[6] * m[11] - m[13] * m[7] * m[10];
4662 inv[4] = -m[4] * m[10] * m[15] + m[4] * m[11] * m[14] + m[8] * m[6] * m[15] - m[8] * m[7] * m[14]
4663 - m[12] * m[6] * m[11] + m[12] * m[7] * m[10];
4664 inv[8] = m[4] * m[9] * m[15] - m[4] * m[11] * m[13] - m[8] * m[5] * m[15] + m[8] * m[7] * m[13]
4665 + m[12] * m[5] * m[11] - m[12] * m[7] * m[9];
4666 inv[12] = -m[4] * m[9] * m[14] + m[4] * m[10] * m[13] + m[8] * m[5] * m[14] - m[8] * m[6] * m[13]
4667 - m[12] * m[5] * m[10] + m[12] * m[6] * m[9];
4668 inv[1] = -m[1] * m[10] * m[15] + m[1] * m[11] * m[14] + m[9] * m[2] * m[15] - m[9] * m[3] * m[14]
4669 - m[13] * m[2] * m[11] + m[13] * m[3] * m[10];
4670 inv[5] = m[0] * m[10] * m[15] - m[0] * m[11] * m[14] - m[8] * m[2] * m[15] + m[8] * m[3] * m[14]
4671 + m[12] * m[2] * m[11] - m[12] * m[3] * m[10];
4672 inv[9] = -m[0] * m[9] * m[15] + m[0] * m[11] * m[13] + m[8] * m[1] * m[15] - m[8] * m[3] * m[13]
4673 - m[12] * m[1] * m[11] + m[12] * m[3] * m[9];
4674 inv[13] = m[0] * m[9] * m[14] - m[0] * m[10] * m[13] - m[8] * m[1] * m[14] + m[8] * m[2] * m[13]
4675 + m[12] * m[1] * m[10] - m[12] * m[2] * m[9];
4676 inv[2] = m[1] * m[6] * m[15] - m[1] * m[7] * m[14] - m[5] * m[2] * m[15] + m[5] * m[3] * m[14] + m[13] * m[2] * m[7]
4677 - m[13] * m[3] * m[6];
4678 inv[6] = -m[0] * m[6] * m[15] + m[0] * m[7] * m[14] + m[4] * m[2] * m[15] - m[4] * m[3] * m[14]
4679 - m[12] * m[2] * m[7] + m[12] * m[3] * m[6];
4680 inv[10] = m[0] * m[5] * m[15] - m[0] * m[7] * m[13] - m[4] * m[1] * m[15] + m[4] * m[3] * m[13]
4681 + m[12] * m[1] * m[7] - m[12] * m[3] * m[5];
4682 inv[14] = -m[0] * m[5] * m[14] + m[0] * m[6] * m[13] + m[4] * m[1] * m[14] - m[4] * m[2] * m[13]
4683 - m[12] * m[1] * m[6] + m[12] * m[2] * m[5];
4684 inv[3] = -m[1] * m[6] * m[11] + m[1] * m[7] * m[10] + m[5] * m[2] * m[11] - m[5] * m[3] * m[10] - m[9] * m[2] * m[7]
4685 + m[9] * m[3] * m[6];
4686 inv[7] = m[0] * m[6] * m[11] - m[0] * m[7] * m[10] - m[4] * m[2] * m[11] + m[4] * m[3] * m[10] + m[8] * m[2] * m[7]
4687 - m[8] * m[3] * m[6];
4688 inv[11] = -m[0] * m[5] * m[11] + m[0] * m[7] * m[9] + m[4] * m[1] * m[11] - m[4] * m[3] * m[9] - m[8] * m[1] * m[7]
4689 + m[8] * m[3] * m[5];
4690 inv[15] = m[0] * m[5] * m[10] - m[0] * m[6] * m[9] - m[4] * m[1] * m[10] + m[4] * m[2] * m[9] + m[8] * m[1] * m[6]
4691 - m[8] * m[2] * m[5];
4692 det = m[0] * inv[0] + m[1] * inv[4] + m[2] * inv[8] + m[3] * inv[12];
4693
4694 if (det == 0)
4695 return false;
4696 det = 1.0 / det;
4697 for (i = 0; i < 16; i++)
4698 invOut[i] = inv[i] * det;
4699 return true;
4700}
4701//----------------------------------------------------------------------
4702
4703//-------------Function to calculate fit parameters---------------------
4705 Double_t** XpHits,
4706 Double_t** ZHits,
4707 Double_t** SigmaXHits,
4708 Double_t** SigmaXpHits,
4709 Double_t** Amatr_,
4710 Double_t* rhs_)
4711{
4712 // if ( fDebug ) cout<<endl;
4713 // if ( fDebug ) cout<<"in GlobalFit "<<endl;
4714
4715 Double_t Z = 0.;
4716 Double_t X = -999;
4717 Double_t U = -999.;
4718 Double_t V = -999.;
4719 Double_t sigmaX_2 = 0.;
4720 Double_t sigmaU_2 = 0.;
4721 Double_t sigmaV_2 = 0.;
4722
4723 for (Int_t iSt = 1; iSt < fNstations; ++iSt) {
4724 for (Int_t imod = 0; imod < fNmodules; ++imod) {
4725
4726 if (iSt == 1 && imod > 3)
4727 continue;
4728 if (iSt == 2 && imod > 1)
4729 continue;
4730
4731 Z = ZHits[iSt][imod];
4732 // if ( fDebug ) cout<<" Z "<<Z<<endl;
4733
4734 if (XHits[iSt][imod] > -900.) { // Amatr[0][0] : d/dax, ax; Amatr[0][1] : d/dax, bx ...
4735
4736 sigmaX_2 = SigmaXHits[iSt][imod] * SigmaXHits[iSt][imod];
4737 X = XHits[iSt][imod];
4738 // if ( fDebug ) cout<<" X "<<X<<endl;
4739
4740 Amatr_[0][0] += 2 * Z * Z / sigmaX_2;
4741 Amatr_[0][1] += 2 * Z / sigmaX_2;
4742 rhs_[0] += 2 * Z * X / sigmaX_2;
4743 Amatr_[1][0] += 2 * Z / sigmaX_2;
4744 Amatr_[1][1] += 2 / sigmaX_2;
4745 rhs_[1] += 2 * X / sigmaX_2;
4746 }
4747
4748 if (XpHits[iSt][imod] > -900.) {
4749
4750 if (Angle(iSt, imod) > 0) { // +
4751 // if ( fDebug ) cout<< "found x+ hit in station " << iSt << " V = " << XpHitsTry[iSt] << "\n";
4752
4753 sigmaU_2 = SigmaXpHits[iSt][imod] * SigmaXpHits[iSt][imod];
4754 U = XpHits[iSt][imod];
4755 // if ( fDebug ) cout<<" U "<<U<<endl;
4756
4757 Amatr_[0][0] += 2 * Z * Z * cos2_5 * cos2_5 / sigmaU_2;
4758 Amatr_[0][1] += 2 * Z * cos2_5 * cos2_5 / sigmaU_2;
4759 Amatr_[0][2] += 2 * Z * Z * cos2_5 * sin2_5 / sigmaU_2;
4760 Amatr_[0][3] += 2 * Z * cos2_5 * sin2_5 / sigmaU_2;
4761 rhs_[0] += 2 * Z * cos2_5 * U / sigmaU_2;
4762
4763 Amatr_[1][0] += 2 * Z * cos2_5 * cos2_5 / sigmaU_2;
4764 Amatr_[1][1] += 2 * cos2_5 * cos2_5 / sigmaU_2;
4765 Amatr_[1][2] += 2 * Z * cos2_5 * sin2_5 / sigmaU_2;
4766 Amatr_[1][3] += 2 * cos2_5 * sin2_5 / sigmaU_2;
4767 rhs_[1] += 2 * cos2_5 * U / sigmaU_2;
4768
4769 Amatr_[2][0] += 2 * Z * Z * cos2_5 * sin2_5 / sigmaU_2;
4770 Amatr_[2][1] += 2 * Z * cos2_5 * sin2_5 / sigmaU_2;
4771 Amatr_[2][2] += 2 * Z * Z * sin2_5 * sin2_5 / sigmaU_2;
4772 Amatr_[2][3] += 2 * Z * sin2_5 * sin2_5 / sigmaU_2;
4773 rhs_[2] += 2 * Z * sin2_5 * U / sigmaU_2;
4774
4775 Amatr_[3][0] += 2 * Z * cos2_5 * sin2_5 / sigmaU_2;
4776 Amatr_[3][1] += 2 * cos2_5 * sin2_5 / sigmaU_2;
4777 Amatr_[3][2] += 2 * Z * sin2_5 * sin2_5 / sigmaU_2;
4778 Amatr_[3][3] += 2 * sin2_5 * sin2_5 / sigmaU_2;
4779 rhs_[3] += 2 * sin2_5 * U / sigmaU_2;
4780
4781 } //+
4782 else
4783 { // -
4784 // if ( fDebug ) cout<< "found x- hit in station " << iSt << " V = " << XpHitsTry[iSt] << "\n";
4785
4786 sigmaV_2 = SigmaXpHits[iSt][imod] * SigmaXpHits[iSt][imod];
4787
4788 V = XpHits[iSt][imod];
4789 // if ( fDebug ) cout<<" V "<<V<<endl;
4790
4791 Amatr_[0][0] += 2 * Z * Z * cos2_5 * cos2_5 / sigmaV_2;
4792 Amatr_[0][1] += 2 * Z * cos2_5 * cos2_5 / sigmaV_2;
4793 Amatr_[0][2] += -2 * Z * Z * cos2_5 * sin2_5 / sigmaV_2;
4794 Amatr_[0][3] += -2 * Z * cos2_5 * sin2_5 / sigmaV_2;
4795 rhs_[0] += 2 * Z * cos2_5 * V / sigmaV_2;
4796
4797 Amatr_[1][0] += 2 * Z * cos2_5 * cos2_5 / sigmaV_2;
4798 Amatr_[1][1] += 2 * cos2_5 * cos2_5 / sigmaV_2;
4799 Amatr_[1][2] += -2 * Z * cos2_5 * sin2_5 / sigmaV_2;
4800 Amatr_[1][3] += -2 * cos2_5 * sin2_5 / sigmaV_2;
4801 rhs_[1] += 2 * cos2_5 * V / sigmaV_2;
4802
4803 Amatr_[2][0] += -2 * Z * Z * cos2_5 * sin2_5 / sigmaV_2;
4804 Amatr_[2][1] += -2 * Z * cos2_5 * sin2_5 / sigmaV_2;
4805 Amatr_[2][2] += 2 * Z * Z * sin2_5 * sin2_5 / sigmaV_2;
4806 Amatr_[2][3] += 2 * Z * sin2_5 * sin2_5 / sigmaV_2;
4807 rhs_[2] += -2 * Z * sin2_5 * V / sigmaV_2;
4808
4809 Amatr_[3][0] += -2 * Z * cos2_5 * sin2_5 / sigmaV_2;
4810 Amatr_[3][1] += -2 * cos2_5 * sin2_5 / sigmaV_2;
4811 Amatr_[3][2] += 2 * Z * sin2_5 * sin2_5 / sigmaV_2;
4812 Amatr_[3][3] += 2 * sin2_5 * sin2_5 / sigmaV_2;
4813 rhs_[3] += -2 * sin2_5 * V / sigmaV_2;
4814 } // -
4815 } // xp_exist
4816 /*
4817 for (Int_t coeff = 0; coeff < 4; ++coeff) {
4818 for (Int_t iCol = 0; iCol < 4; ++iCol) {
4819 if ( fDebug ) cout << "GLOBALFIT: station = " << iSt << " " << "Amatr[" << coeff << "][" << iCol << "] = " <<
4820 Amatr[coeff][iCol] << "\n";
4821 }
4822 if ( fDebug ) cout<<" rhs["<<i<<"] "<< rhs[coeff]<<endl;
4823 }
4824 */
4825 } // imod
4826 } // st
4827
4828} // global fit
4829//----------------------------------------------------------------------
4830
4831//---------------Find Cluster Center------------------------------------
4833{
4834 Double_t XQ = 0.;
4835 Double_t Q = 0.;
4836
4837 for (Int_t i = 0; i < nElements; ++i) {
4838 Q += Ampl[i];
4839 // if (fDebug) cout<<" Ampl["<<i<<"] ="<<Ampl[i]<<endl;
4840 XQ += Double_t(i + 0.5) * Ampl[i];
4841 }
4842 SumAmpll = Q;
4843 Double_t CoG = XQ / Q;
4844 // if (fDebug) cout << "ClasterSize = " << nElements << "; Q = " << Q << "; Q/size = " << Q/nElements << endl;
4845 return (CoG);
4846}
4847//----------------------------------------------------------------------
4848
4849//----------------------------------------------------------------------
4851{
4852 if (!expData) {
4853 fInputBranchName = "BmnSiliconHitClean";
4854 fInputBranchName2 = "BmnSiliconHitSim";
4855 fRunNumber = 0001;
4856 }
4857
4858 if (fRunPeriod == 7) {
4859 fNstations = 4;
4860 fNmodules = 8;
4861 fNmodules1 = 4;
4862 fNmodules2 = 2;
4863 fNmodules3 = 8;
4864 }
4865 if (fRunPeriod == 8) {
4866 fNstations = 5;
4867 fNmodules = 2;
4868 fNmodules1 = 2;
4869 fNmodules2 = 2;
4870 fNmodules3 = 2;
4871 }
4872
4873 //--some hists--
4874 if (fDebug) {
4875
4876 hNpoint = new TH1D("Npoint", "Npoints: X+ X'; Npoints; Events", 7, 1, 8);
4877 fList.Add(hNpoint);
4878 hChiSquareNdf = new TH1D("ChiSquareNdf", "ChiSquareNdf", 200, 0, Chi2_Globcut);
4879 fList.Add(hChiSquareNdf);
4880 hNtracks = new TH1D("Ntracks", "Ntracks; Ntracks; Events", 10, 0, 10);
4881 fList.Add(hNtracks);
4882 hAxglob = new TH1D("Axglob", "AngleX; tgX[rad]; Events", 200, -.1, .1);
4883 fList.Add(hAxglob);
4884 hBxglob = new TH1D("Bxglob", "Bx; [cm]; Events", 200, -10, 10);
4885 fList.Add(hBxglob);
4886 hAyglob = new TH1D("Ayglob", "AngleY; tgY[rad]; Events", 200, -.1, .1);
4887 fList.Add(hAyglob);
4888 hByglob = new TH1D("Byglob", "By; [cm]; Events", 200, -10, 10);
4889 fList.Add(hByglob);
4890 hvertexXY = new TH2D("vertexXY", "vertexXY", 100, -5, 5, 100, -10, 5);
4891 fList.Add(hvertexXY);
4892 hvertex_aver_XY = new TH2D("vertex_aver_XY", "vertex_aver_XY", 100, -5, 5, 100, -10, 5);
4894 hprofile_beam_z1 = new TH2D("profile_beam_z1", "beam_profile_Siz1; [cm];[cm]", 100, -10, 10, 100, -15, 5);
4896 hprofile_beam_z2 = new TH2D("profile_beam_z2", "beam_profile_Siz2; [cm];[cm]", 100, -10, 10, 100, -15, 5);
4898 hprofile_beam_z3 = new TH2D("profile_beam_z3", "beam_profile_Siz3; [cm];[cm]", 100, -15, 15, 100, -20, 5);
4900 hAx_first_tr = new TH1D("Ax_first_tr", "Ax_first_tr; AngleX[mrad]; Events", 200, -.1, .1);
4901 fList.Add(hAx_first_tr);
4902 hAx_more_first_tr = new TH1D("Ax_more_first_tr", "Ax_more_first_tr; AngleX[mrad]; Events", 200, -.1, .1);
4904 hYXSi1_run8 = new TH2D("hYXSi1_run8", "YXSi1_run8", 100, -15, 15, 100, -15, 15);
4905 fList.Add(hYXSi1_run8);
4906 hYXSi2_run8 = new TH2D("hYXSi2_run8", "YXSi2_run8", 100, -15, 15, 100, -15, 15);
4907 fList.Add(hYXSi2_run8);
4908 hXSi1_run8 = new TH1D("XSi1_run8", "XSi1; [cm]; Events", 200, -10, 10);
4909 fList.Add(hXSi1_run8);
4910 hYSi1_run8 = new TH1D("YSi1_run8", "YSi1; [cm]; Events", 200, -10, 10);
4911 fList.Add(hYSi1_run8);
4912 hXSi2_run8 = new TH1D("XSi2_run8", "XSi2; [cm]; Events", 200, -10, 10);
4913 fList.Add(hXSi2_run8);
4914 hYSi2_run8 = new TH1D("YSi2_run8", "YSi2; [cm]; Events", 200, -10, 10);
4915 fList.Add(hYSi2_run8);
4916
4917 hdX_st1_st2 = new TH1D("X_st1_st2", "X (st1-st2)", 100, -0.1, 0.1);
4918 fList.Add(hdX_st1_st2);
4919 hdX_st2_st3 = new TH1D("X_st2_st3", "X (st2-st3)", 100, -5., 5.);
4920 fList.Add(hdX_st2_st3);
4921 hdX_st1_st3 = new TH1D("X_st1_st3", "X (st1-st3)", 100, -5., 5.);
4922 fList.Add(hdX_st1_st3);
4923
4924 hdY_st1_st2 = new TH1D("Y_st1_st2", "Y (st1-st2)", 100, -1, 1);
4925 fList.Add(hdY_st1_st2);
4926 hdY_st2_st3 = new TH1D("Y_st2_st3", "Y (st2-st3)", 100, -5., 5.);
4927 fList.Add(hdY_st2_st3);
4928 hdY_st1_st3 = new TH1D("Y_st1_st3", "Y (st1-st3)", 100, -5., 5.);
4929 fList.Add(hdY_st1_st3);
4930
4931 hX_st_1 = new TH1D("X_st_1", "X_st_1", 100, -6, 6);
4932 fList.Add(hX_st_1);
4933 hX_st_2 = new TH1D("X_st_2", "X_st_2", 100, -6, 6);
4934 fList.Add(hX_st_2);
4935 hX_st_3 = new TH1D("X_st_3", "X_st_3", 100, -6, 6);
4936 fList.Add(hX_st_3);
4937
4938 hdX_st_1 = new TH1D("dX_st_1", "dX_st_1", 100, -0.02, 0.02);
4939 fList.Add(hdX_st_1);
4940 hdX_st_2 = new TH1D("dX_st_2", "dX_st_2", 100, -0.02, 0.02);
4941 fList.Add(hdX_st_2);
4942 hdX_st_3 = new TH1D("dX_st_3", "dX_st_3", 100, -0.002, 0.002);
4943 fList.Add(hdX_st_3);
4944
4945 hdXp_st_1 = new TH1D("dXp_st_1", "dXp_st_1", 100, -0.02, 0.02);
4946 fList.Add(hdXp_st_1);
4947 hdXp_st_2 = new TH1D("dXp_st_2", "dXp_st_2", 100, -0.02, 0.02);
4948 fList.Add(hdXp_st_2);
4949 hdXp_st_3 = new TH1D("dXp_st_3", "dXp_st_3", 100, -0.02, 0.02);
4950 fList.Add(hdXp_st_3);
4951
4952 hdXvsXst_1 = new TH2D("dXvsXst_1", "dXvsXst_1;XSi[cm];hit-fit[cm]", 100, -6, 6, 100, -0.03, 0.03);
4953 fList.Add(hdXvsXst_1);
4954 hdXvsXst_2 = new TH2D("dXvsXst_2", "dXvsXst_2;XSi[cm];hit-fit[cm]", 100, -6, 6, 100, -0.03, 0.03);
4955 fList.Add(hdXvsXst_2);
4956 hdXvsXst_3 = new TH2D("dXvsXst_3", "dXvsXst_3;XSi[cm];hit-fit[cm]", 100, -6, 6, 100, -0.0005, 0.0005);
4957 fList.Add(hdXvsXst_3);
4958
4959 hX13_X2_m0 = new TH1D("X13_X2_m0", "X2_X13_m0", 200, -0.05, 0.05);
4960 fList.Add(hX13_X2_m0);
4961 hX13_X2_m1 = new TH1D("X13_X2_m1", "X2_X13_m1", 200, -0.05, 0.05);
4962 fList.Add(hX13_X2_m1);
4963
4964 hXp13_Xp2_m0 = new TH1D("Xp13_Xp2_m0", "Xp2_Xp13__m0", 200, -0.4, 0.4);
4965 fList.Add(hXp13_Xp2_m0);
4966 hXp13_Xp2_m1 = new TH1D("Xp13_Xp2_m1", "Xp2_Xp13__m1", 200, -0.4, 0.4);
4967 fList.Add(hXp13_Xp2_m1);
4968
4969 hY13_Y2_m0 = new TH1D("Y13_Y2_m0", "Y2_Y13_m0", 200, -1, 1);
4970 fList.Add(hY13_Y2_m0);
4971 hY13_Y2_m1 = new TH1D("Y13_Y2_m1", "Y2_Y13_m1", 200, -1, 1);
4972 fList.Add(hY13_Y2_m1);
4973
4974 hY1m0_Y23 = new TH1D("Y1m0_Y23", "Y1m0_Y23", 200, -1, 1);
4975 fList.Add(hY1m0_Y23);
4976 hY1m1_Y23 = new TH1D("Y1m1_Y23", "Y1m1_Y23", 200, -1, 1);
4977 fList.Add(hY1m1_Y23);
4978 hY1m2_Y23 = new TH1D("Y1m2_Y23", "Y1m2_Y23", 200, -1, 1);
4979 fList.Add(hY1m2_Y23);
4980 hY1m3_Y23 = new TH1D("Y1m3_Y23", "Y1m3_Y23", 200, -1, 1);
4981 fList.Add(hY1m3_Y23);
4982
4983 hY_st_1 = new TH1D("Y_st_1", "Y_st_1", 100, -6, 6);
4984 fList.Add(hY_st_1);
4985 hY_st_2 = new TH1D("Y_st_2", "Y_st_2", 100, -6, 6);
4986 fList.Add(hY_st_2);
4987 hY_st_3 = new TH1D("Y_st_3", "Y_st_3", 100, -6, 6);
4988 fList.Add(hY_st_3);
4989
4990 hdY_st_1 = new TH1D("dY_st_1", "dY_st_1", 100, -0.6, 0.6);
4991 fList.Add(hdY_st_1);
4992 hdY_st_2 = new TH1D("dY_st_2", "dY_st_2", 100, -0.6, 0.6);
4993 fList.Add(hdY_st_2);
4994 hdY_st_3 = new TH1D("dY_st_3", "dY_st_3", 100, -0.6, 0.6);
4995 fList.Add(hdY_st_3);
4996
4997 hdYvsYst_1 = new TH2D("dYvsYst_1", "dYvsYst_1;YSi[cm];hit-fit[cm]", 100, -6, 6, 100, -0.6, 0.6);
4998 fList.Add(hdYvsYst_1);
4999 hdYvsYst_2 = new TH2D("dYvsYst_2", "dYvsYst_2;YSi[cm];hit-fit[cm]", 100, -6, 6, 100, -0.6, 0.6);
5000 fList.Add(hdYvsYst_2);
5001 hdYvsYst_3 = new TH2D("dYvsYst_3", "dYvsYst_3;YSi[cm];hit-fit[cm]", 100, -6, 6, 100, -0.4, 0.4);
5002 fList.Add(hdYvsYst_3);
5003
5004 hdXst1_0_st2_0 = new TH1D("dXst1_0_st2_0", "dXst1_0_st2_0", 100, -0.1, 0.1);
5005 hdXst1_0_st2_1 = new TH1D("dXst1_0_st2_1", "dXst1_0_st2_1", 100, -0.1, 0.1);
5006 hdXst1_1_st2_0 = new TH1D("dXst1_1_st2_0", "dXst1_1_st2_0", 100, -0.1, 0.1);
5007 hdXst1_1_st2_1 = new TH1D("dXst1_1_st2_1", "dXst1_1_st2_1", 100, -0.1, 0.1);
5008 hdXst1_2_st2_0 = new TH1D("dXst1_2_st2_0", "dXst1_2_st2_0", 100, -0.1, 0.1);
5009 hdXst1_2_st2_1 = new TH1D("dXst1_2_st2_1", "dXst1_2_st2_1", 100, -0.1, 0.1);
5010 hdXst1_3_st2_0 = new TH1D("dXst1_3_st2_0", "dXst1_3_st2_0", 100, -0.1, 0.1);
5011 hdXst1_3_st2_1 = new TH1D("dXst1_3_st2_1", "dXst1_3_st2_1", 100, -0.1, 0.1);
5012 hdXst2_0_st3_1 = new TH1D("dXst2_0_st3_1", "dXst2_0_st3_1", 100, -3, 3);
5013 hdXst2_0_st3_2 = new TH1D("dXst2_0_st3_2", "dXst2_0_st3_2", 100, -3, 3);
5014 hdXst2_1_st3_1 = new TH1D("dXst2_1_st3_1", "dXst2_1_st3_1", 100, -3, 3);
5015 hdXst2_1_st3_2 = new TH1D("dXst2_1_st3_2", "dXst2_1_st3_2", 100, -3, 3);
5016 fList.Add(hdXst1_0_st2_0);
5017 fList.Add(hdXst1_1_st2_0);
5018 fList.Add(hdXst1_2_st2_0);
5019 fList.Add(hdXst1_3_st2_0);
5020 fList.Add(hdXst1_0_st2_1);
5021 fList.Add(hdXst1_1_st2_1);
5022 fList.Add(hdXst1_2_st2_1);
5023 fList.Add(hdXst1_3_st2_1);
5024 fList.Add(hdXst2_0_st3_1);
5025 fList.Add(hdXst2_0_st3_2);
5026 fList.Add(hdXst2_1_st3_1);
5027 fList.Add(hdXst2_1_st3_2);
5028
5029 hdXp3_mod1 = new TH1D("hdXp3_mod1", "hdXp3_mod1", 100, -0.02, 0.02);
5030 fList.Add(hdXp3_mod1);
5031 hdXp3_mod2 = new TH1D("hdXp3_mod2", "hdXp3_mod2", 100, -0.02, 0.02);
5032 fList.Add(hdXp3_mod2);
5033 hdXXp3_mod1 = new TH1D("hdXXp3_mod1", "hdXXp3_mod1", 100, -0.5, 0.5);
5034 fList.Add(hdXXp3_mod1);
5035 hdXXp3_mod2 = new TH1D("hdXXp3_mod2", "hdXXp3_mod2", 100, -0.5, 0.5);
5036 fList.Add(hdXXp3_mod2);
5037 hXXp12CheckLeftover = new TH1D("hXXp12CheckLeftover", "hXXp12CheckLeftover", 200, -1, 1);
5039 hXXp12CheckLeftover03 = new TH1D("hXXp12CheckLeftover03", "hXXp12CheckLeftover03", 900, -0.15, 0.15);
5041
5042 hdXvsXst1_0 = new TH2D("dXvsXst1_0", "dXvsXst1_0", 100, -6, 6, 100, -0.05, 0.05);
5043 fList.Add(hdXvsXst1_0);
5044 hdXvsXst1_1 = new TH2D("dXvsXst1_1", "dXvsXst1_1", 100, -6, 6, 100, -0.05, 0.05);
5045 fList.Add(hdXvsXst1_1);
5046 hdXvsXst1_2 = new TH2D("dXvsXst1_2", "dXvsXst1_2", 100, -6, 6, 100, -0.05, 0.05);
5047 fList.Add(hdXvsXst1_2);
5048 hdXvsXst1_3 = new TH2D("dXvsXst1_3", "dXvsXst1_3", 100, -6, 6, 100, -0.05, 0.05);
5049 fList.Add(hdXvsXst1_3);
5050 hdXvsXst2_0 = new TH2D("dXvsXst2_0", "dXvsXst2_0", 100, -6, 6, 100, -0.05, 0.05);
5051 fList.Add(hdXvsXst2_0);
5052 hdXvsXst2_1 = new TH2D("dXvsXst2_1", "dXvsXst2_1", 100, -6, 6, 100, -0.05, 0.05);
5053 fList.Add(hdXvsXst2_1);
5054 hdXvsXst3_1 = new TH2D("dXvsXst3_1", "dXvsXst3_1", 100, -6, 6, 100, -0.001, 0.001);
5055 fList.Add(hdXvsXst3_1);
5056 hdXvsXst3_2 = new TH2D("dXvsXst3_2", "dXvsXst3_2", 100, -6, 6, 100, -0.001, 0.001);
5057 fList.Add(hdXvsXst3_2);
5058
5059 hdYvsYst1_mod0 = new TH2D("dYvsYst1_mod0", "dYvsYst1_mod0", 100, -6, 6, 100, -0.6, 0.6);
5060 fList.Add(hdYvsYst1_mod0);
5061 hdYvsYst1_mod1 = new TH2D("dYvsYst1_mod1", "dYvsYst1_mod1", 100, -6, 6, 100, -0.6, 0.6);
5062 fList.Add(hdYvsYst1_mod1);
5063 hdYvsYst1_mod2 = new TH2D("dYvsYst1_mod2", "dYvsYst1_mod2", 100, -6, 6, 100, -0.6, 0.6);
5064 fList.Add(hdYvsYst1_mod2);
5065 hdYvsYst1_mod3 = new TH2D("dYvsYst1_mod3", "dYvsYst1_mod3", 100, -6, 6, 100, -0.6, 0.6);
5066 fList.Add(hdYvsYst1_mod3);
5067 hdYvsYst2_mod0 = new TH2D("dYvsYst2_mod0", "dYvsYst2_mod0", 100, -6, 6, 100, -0.6, 0.6);
5068 fList.Add(hdYvsYst2_mod0);
5069 hdYvsYst2_mod1 = new TH2D("dYvsYst2_mod1", "dYvsYst2_mod1", 100, -6, 6, 100, -0.6, 0.6);
5070 fList.Add(hdYvsYst2_mod1);
5071 hdYvsYst3_mod1 = new TH2D("dYvsYst3_mod1", "dYvsYst3_mod1", 100, -6, 6, 100, -0.2, 0.2);
5072 fList.Add(hdYvsYst3_mod1);
5073 hdYvsYst3_mod2 = new TH2D("dYvsYst3_mod2", "dYvsYst3_mod2", 100, -6, 6, 100, -0.2, 0.2);
5074 fList.Add(hdYvsYst3_mod2);
5075
5076 hdYst1_0_st2_0 = new TH1D("dYst1_0_st2_0", "dYst1_0_st2_0", 100, -1, 1);
5077 hdYst1_0_st2_1 = new TH1D("dYst1_0_st2_1", "dYst1_0_st2_1", 100, -1, 1);
5078 hdYst1_1_st2_0 = new TH1D("dYst1_1_st2_0", "dYst1_1_st2_0", 100, -1, 1);
5079 hdYst1_1_st2_1 = new TH1D("dYst1_1_st2_1", "dYst1_1_st2_1", 100, -1, 1);
5080 hdYst1_2_st2_0 = new TH1D("dYst1_2_st2_0", "dYst1_2_st2_0", 100, -1, 1);
5081 hdYst1_2_st2_1 = new TH1D("dYst1_2_st2_1", "dYst1_2_st2_1", 100, -1, 1);
5082 hdYst1_3_st2_0 = new TH1D("dYst1_3_st2_0", "dYst1_3_st2_0", 100, -1, 1);
5083 hdYst1_3_st2_1 = new TH1D("dYst1_3_st2_1", "dYst1_3_st2_1", 100, -1, 1);
5084 hdYst2_0_st3_1 = new TH1D("dYst2_0_st3_1", "dYst2_0_st3_1", 100, -3, 3);
5085 hdYst2_0_st3_2 = new TH1D("dYst2_0_st3_2", "dYst2_0_st3_2", 100, -3, 3);
5086 hdYst2_1_st3_1 = new TH1D("dYst2_1_st3_1", "dYst2_1_st3_1", 100, -3, 3);
5087 hdYst2_1_st3_2 = new TH1D("dYst2_1_st3_2", "dYst2_1_st3_2", 100, -3, 3);
5088 fList.Add(hdYst1_0_st2_0);
5089 fList.Add(hdYst1_1_st2_0);
5090 fList.Add(hdYst1_2_st2_0);
5091 fList.Add(hdYst1_3_st2_0);
5092 fList.Add(hdYst1_0_st2_1);
5093 fList.Add(hdYst1_1_st2_1);
5094 fList.Add(hdYst1_2_st2_1);
5095 fList.Add(hdYst1_3_st2_1);
5096 fList.Add(hdYst2_0_st3_1);
5097 fList.Add(hdYst2_0_st3_2);
5098 fList.Add(hdYst2_1_st3_1);
5099 fList.Add(hdYst2_1_st3_2);
5100
5101 hY_XSisp1 = new TH2D("hY_XSisp1", "hY_XSisp1", 100, -10, 10, 100, -10, 10);
5102 fList.Add(hY_XSisp1);
5103 hY_XSisp2 = new TH2D("hY_XSisp2", "hY_XSisp2", 100, -10, 10, 100, -10, 10);
5104 fList.Add(hY_XSisp2);
5105 hY_XSisp3 = new TH2D("hY_XSisp3", "hY_XSisp3", 100, -10, 10, 100, -20, 0);
5106 fList.Add(hY_XSisp3);
5107
5108 hY_XSisp1bef = new TH2D("hY_XSisp1bef", "hY_XSisp1bef", 100, -10, 10, 100, -10, 10);
5109 fList.Add(hY_XSisp1bef);
5110 hY_XSisp2bef = new TH2D("hY_XSisp2bef", "hY_XSisp2bef", 100, -10, 10, 100, -10, 10);
5111 fList.Add(hY_XSisp2bef);
5112
5113 N_eff = new TH1D("N_eff", "N_eff", 6, 1, 7);
5114 fList.Add(N_eff);
5115 D_eff = new TH1D("D_eff", "D_eff", 6, 1, 7);
5116 fList.Add(D_eff);
5117 E_eff = new TH1D("E_eff", "Hit Efficiency per Layer on Track", 6, 1, 7);
5118 fList.Add(E_eff);
5119 E_eff->Sumw2();
5120
5121 hdAx_MC_tr = new TH1D("dAx_MC_tr", "dAx_MC_tr;[rad]", 200, -.001, .001);
5122 fList.Add(hdAx_MC_tr);
5123 hdAy_MC_tr = new TH1D("dAy_MC_tr", "dAy_MC_tr;[rad]", 200, -.01, .01);
5124 fList.Add(hdAy_MC_tr);
5125 hdX_MC_tr = new TH1D("dX_MC_tr", "dX_MC_tr;[cm]", 200, -2, 2);
5126 fList.Add(hdX_MC_tr);
5127 hdY_MC_tr = new TH1D("dY_MC_tr", "dY_MC_tr;[cm]", 200, -2, 2);
5128 fList.Add(hdY_MC_tr);
5129
5130 hAxsi_mctrue = new TH1D("Axsi_mctrue", "Ax_mctrueX; tgX[rad]; Events", 200, -.1, .1);
5131 fList.Add(hAxsi_mctrue);
5132 hBxsi_mctrue = new TH1D("Bxsi_mctrue", "Bx_mctrue; [cm]; Events", 200, -10, 10);
5133 fList.Add(hBxsi_mctrue);
5134 hAysi_mctrue = new TH1D("Aysi_mctrue", "Ay_mctrue; tgY[rad]; Events", 200, -.1, .1);
5135 fList.Add(hAysi_mctrue);
5136 hBysi_mctrue = new TH1D("Bysi_mctrue", "By_mctrue; [cm]; Events", 200, -10, 10);
5137 fList.Add(hBysi_mctrue);
5138
5139 hSi_st1mc = new TH2D("Si_st1mc", "beam_profileSi_st1mc smeared; [cm];[cm]", 100, -10, 10, 100, -15, 5);
5140 fList.Add(hSi_st1mc);
5141 hSi_st2mc = new TH2D("Si_st2mc", "beam_profileSi_st2mc smeared; [cm];[cm]", 100, -10, 10, 100, -15, 5);
5142 fList.Add(hSi_st2mc);
5143 hSi_st3mc = new TH2D("Si_st3mc", "beam_profileSi_st3mc smeared; [cm];[cm]", 100, -15, 15, 100, -25, 5);
5144 fList.Add(hSi_st3mc);
5145
5146 hdAx_MC_tr_comb = new TH1D("dAx_MC_tr_comb", "dAx_MC_tr_comb;[rad]", 200, -.005, .005);
5148 hdAy_MC_tr_comb = new TH1D("dAy_MC_tr_comb", "dAy_MC_tr_comb;[rad]", 200, -.005, .005);
5150 hdX_MC_tr_comb = new TH1D("dX_MC_tr_comb", "dX_MC_tr_comb;[cm]", 200, -2, 2);
5151 fList.Add(hdX_MC_tr_comb);
5152 hdY_MC_tr_comb = new TH1D("dY_MC_tr_comb", "dY_MC_tr_comb;[cm]", 200, -2, 2);
5153 fList.Add(hdY_MC_tr_comb);
5154
5155 hDen_mctrSi = new TH1D("hDen_mctrSi", "Den_mctrSi", 1, 0, 1);
5156 fList.Add(hDen_mctrSi);
5157 hNum_mctrSi = new TH1D("hNum_mctrSi", "Num_mctrSi", 1, 0, 1);
5158 fList.Add(hNum_mctrSi);
5159 hEff_mctrSi = new TH1D("hEff_mctrSi", "Eff_mctrSi", 1, 0, 1);
5160 fList.Add(hEff_mctrSi);
5161
5162 hDen_mcreaction = new TH1D("hDen_mcreaction", "hDen_mcreaction", 1, 0, 1);
5164 hNum_mcreaction = new TH1D("hNum_mcreaction", "hNum_mcreaction", 1, 0, 1);
5166 hEff_mcreaction = new TH1D("hEff_mcreaction", "hEff_mcreaction", 1, 0, 1);
5168
5169 hNtrsi_mc = new TH1D("Ntrsi_mc", ";N of Si-tr mc", 10, 0, 10);
5170 fList.Add(hNtrsi_mc);
5171 hNtrsi_reco = new TH1D("Ntrsi_reco", ";N of Si-tr reco", 10, 0, 10);
5172 fList.Add(hNtrsi_reco);
5173 hNtrsi_mc_vs_reco = new TH2D("hNtr_mc_vs_reco", "hNtr_mc_vs_reco", 10, 0, 10, 10, 0, 10);
5175
5176 TH1D* h;
5177 for (Int_t imod = 0; imod < fNmodules; imod++) {
5178 if (imod > 3)
5179 continue;
5180 h = new TH1D(Form("hoccupancyX1_mod%d", imod), Form("hoccupancyX1_mod%d", imod), fNstrips + 1, 0.,
5181 fNstrips + 1);
5182 fList.Add(h);
5183 hoccupancyX1.push_back(h);
5184 }
5185 for (Int_t imod = 0; imod < fNmodules; imod++) {
5186 if (imod > 1)
5187 continue;
5188 h = new TH1D(Form("hoccupancyX2_mod%d", imod), Form("hoccupancyX2_mod%d", imod), fNstrips + 1, 0.,
5189 fNstrips + 1);
5190 fList.Add(h);
5191 hoccupancyX2.push_back(h);
5192 }
5193 for (Int_t imod = 0; imod < fNmodules; imod++) {
5194 h = new TH1D(Form("hoccupancyX3_mod%d", imod), Form("hoccupancyX3_mod%d", imod), fNstrips + 1, 0.,
5195 fNstrips + 1);
5196 fList.Add(h);
5197 hoccupancyX3.push_back(h);
5198 }
5199
5200 for (Int_t imod = 0; imod < fNmodules; imod++) {
5201 if (imod > 3)
5202 continue;
5203 h = new TH1D(Form("hoccupancyXp1_mod%d", imod), Form("hoccupancyXp1_mod%d", imod), fNstrips + 1, 0.,
5204 fNstrips + 1);
5205 fList.Add(h);
5206 hoccupancyXp1.push_back(h);
5207 }
5208 for (Int_t imod = 0; imod < fNmodules; imod++) {
5209 if (imod > 1)
5210 continue;
5211 h = new TH1D(Form("hoccupancyXp2_mod%d", imod), Form("hoccupancyXp2_mod%d", imod), fNstrips + 1, 0.,
5212 fNstrips + 1);
5213 fList.Add(h);
5214 hoccupancyXp2.push_back(h);
5215 }
5216 for (Int_t imod = 0; imod < fNmodules; imod++) {
5217 h = new TH1D(Form("hoccupancyXp3_mod%d", imod), Form("hoccupancyXp3_mod%d", imod), fNstrips + 1, 0.,
5218 fNstrips + 1);
5219 fList.Add(h);
5220 hoccupancyXp3.push_back(h);
5221 }
5222
5223 } // if (fDebug)
5224
5225 //--Some Arrays--
5226 AmatrInverted = new Double_t[16];
5227 rhs = new Double_t[4];
5228 AmatrArray = new Double_t[16];
5229 Amatr = new Double_t*[4];
5230 line = new Double_t[4];
5231 for (Int_t i = 0; i < 4; i++) {
5232 Amatr[i] = new Double_t[4];
5233 }
5236 Nsp_st = new Int_t[fNstations];
5238 NleftoverX = new Int_t*[fNstations];
5241 iModX = new Int_t[fNstations];
5244 shiftX = new Double_t*[fNstations];
5245 shiftY = new Double_t*[fNstations];
5249 NclustX = new Int_t*[fNstations];
5250 NclustXp = new Int_t*[fNstations];
5251 NhitsXYmod = new Int_t*[fNstations];
5259 XCoord = new Double_t**[fNstations];
5260 XpCoord = new Double_t**[fNstations];
5261 XspCoord = new Double_t**[fNstations];
5262 XpspCoord = new Double_t**[fNstations];
5263 YspCoord = new Double_t**[fNstations];
5264 Sp_pdg = new Int_t**[fNstations];
5265 SigmaX = new Double_t**[fNstations];
5266 SigmaXp = new Double_t**[fNstations];
5267 SigmspX = new Double_t**[fNstations];
5268 SigmspXp = new Double_t**[fNstations];
5269 SigmspY = new Double_t**[fNstations];
5272 XClust = new Double_t**[fNstations];
5273 XpClust = new Double_t**[fNstations];
5276 sumQx = new Double_t**[fNstations];
5277 sumQxp = new Double_t**[fNstations];
5278 XspClust = new Double_t**[fNstations];
5279 XpspClust = new Double_t**[fNstations];
5282 sumQxsp = new Double_t**[fNstations];
5283 sumQxpsp = new Double_t**[fNstations];
5290 leftoverX = new Double_t**[fNstations];
5294
5295 for (Int_t istat = 0; istat < fNstations; istat++) {
5296 Nleftoversp[istat] = new Int_t[fNmodules];
5297 NleftoverX[istat] = new Int_t[fNmodules];
5298 NleftoverXp[istat] = new Int_t[fNmodules];
5299 leftoverXsp[istat] = new Double_t*[fNmodules];
5300 leftoverXpsp[istat] = new Double_t*[fNmodules];
5301 leftoverYsp[istat] = new Double_t*[fNmodules];
5302 leftoverXsigsp[istat] = new Double_t*[fNmodules];
5303 leftoverXpsigsp[istat] = new Double_t*[fNmodules];
5304 leftoverYsigsp[istat] = new Double_t*[fNmodules];
5305 leftoverX[istat] = new Double_t*[fNmodules];
5306 leftoverXp[istat] = new Double_t*[fNmodules];
5307 leftoverXsig[istat] = new Double_t*[fNmodules];
5308 leftoverXpsig[istat] = new Double_t*[fNmodules];
5309 shiftX[istat] = new Double_t[fNmodules];
5310 shiftY[istat] = new Double_t[fNmodules];
5311 shiftYbelow[istat] = new Double_t[fNmodules];
5312 Zstation[istat] = new Double_t[fNmodules];
5313 NclustX[istat] = new Int_t[fNmodules];
5314 NclustXp[istat] = new Int_t[fNmodules];
5315 NhitsXYmod[istat] = new Int_t[fNmodules];
5316 SigmXforglfit[istat] = new Double_t[fNmodules];
5317 SigmXpforglfit[istat] = new Double_t[fNmodules];
5318 SigmYforglfit[istat] = new Double_t[fNmodules];
5319 ZstnCforglfit[istat] = new Double_t[fNmodules];
5320 Xforglfit[istat] = new Double_t[fNmodules];
5321 Xpforglfit[istat] = new Double_t[fNmodules];
5322 Yforglfit[istat] = new Double_t[fNmodules];
5323 XCoord[istat] = new Double_t*[fNmodules];
5324 XpCoord[istat] = new Double_t*[fNmodules];
5325 XspCoord[istat] = new Double_t*[fNmodules];
5326 XpspCoord[istat] = new Double_t*[fNmodules];
5327 YspCoord[istat] = new Double_t*[fNmodules];
5328 Sp_pdg[istat] = new Int_t*[fNmodules];
5329 SigmaX[istat] = new Double_t*[fNmodules];
5330 SigmaXp[istat] = new Double_t*[fNmodules];
5331 SigmspX[istat] = new Double_t*[fNmodules];
5332 SigmspXp[istat] = new Double_t*[fNmodules];
5333 SigmspY[istat] = new Double_t*[fNmodules];
5334 DigitsArrayX[istat] = new Double_t*[fNmodules];
5335 DigitsArrayXp[istat] = new Double_t*[fNmodules];
5336 XClust[istat] = new Double_t*[fNmodules];
5337 XpClust[istat] = new Double_t*[fNmodules];
5338 XClust_width[istat] = new Double_t*[fNmodules];
5339 XpClust_width[istat] = new Double_t*[fNmodules];
5340 sumQx[istat] = new Double_t*[fNmodules];
5341 sumQxp[istat] = new Double_t*[fNmodules];
5342 XspClust[istat] = new Double_t*[fNmodules];
5343 XpspClust[istat] = new Double_t*[fNmodules];
5344 XspClust_width[istat] = new Double_t*[fNmodules];
5345 XpspClust_width[istat] = new Double_t*[fNmodules];
5346 sumQxsp[istat] = new Double_t*[fNmodules];
5347 sumQxpsp[istat] = new Double_t*[fNmodules];
5348
5349 for (Int_t im = 0; im < fNmodules; im++) {
5350 leftoverXsp[istat][im] = new Double_t[kBig];
5351 leftoverXpsp[istat][im] = new Double_t[kBig];
5352 leftoverYsp[istat][im] = new Double_t[kBig];
5353 leftoverXsigsp[istat][im] = new Double_t[kBig];
5354 leftoverXpsigsp[istat][im] = new Double_t[kBig];
5355 leftoverYsigsp[istat][im] = new Double_t[kBig];
5356 leftoverX[istat][im] = new Double_t[kBig];
5357 leftoverXp[istat][im] = new Double_t[kBig];
5358 leftoverXsig[istat][im] = new Double_t[kBig];
5359 leftoverXpsig[istat][im] = new Double_t[kBig];
5360 XCoord[istat][im] = new Double_t[kBig];
5361 XpCoord[istat][im] = new Double_t[kBig];
5362 XspCoord[istat][im] = new Double_t[kBig];
5363 XpspCoord[istat][im] = new Double_t[kBig];
5364 YspCoord[istat][im] = new Double_t[kBig];
5365 Sp_pdg[istat][im] = new Int_t[kBig];
5366 SigmaX[istat][im] = new Double_t[kBig];
5367 SigmaXp[istat][im] = new Double_t[kBig];
5368 SigmspX[istat][im] = new Double_t[kBig];
5369 SigmspXp[istat][im] = new Double_t[kBig];
5370 SigmspY[istat][im] = new Double_t[kBig];
5371 DigitsArrayX[istat][im] = new Double_t[fNstrips];
5372 DigitsArrayXp[istat][im] = new Double_t[fNstrips];
5373 XClust[istat][im] = new Double_t[fNstrips];
5374 XpClust[istat][im] = new Double_t[fNstrips];
5375 XClust_width[istat][im] = new Double_t[fNstrips];
5376 XpClust_width[istat][im] = new Double_t[fNstrips];
5377 sumQx[istat][im] = new Double_t[fNstrips];
5378 sumQxp[istat][im] = new Double_t[fNstrips];
5379 XspClust[istat][im] = new Double_t[fNstrips];
5380 XpspClust[istat][im] = new Double_t[fNstrips];
5381 XspClust_width[istat][im] = new Double_t[fNstrips];
5382 XpspClust_width[istat][im] = new Double_t[fNstrips];
5383 sumQxsp[istat][im] = new Double_t[fNstrips];
5384 sumQxpsp[istat][im] = new Double_t[fNstrips];
5385 }
5386 }
5387
5388 if (fVerbose)
5389 cout << "BmnSiliconTrackFinder::Init()" << endl;
5390 FairRootManager* ioman = FairRootManager::Instance();
5391
5392 if (expData) {
5393 if (fDebug)
5394 cout << " expData " << endl;
5395 fBmnSiDigitsArray = (TClonesArray*)ioman->GetObject("SILICON");
5396 if (!fBmnSiDigitsArray) {
5397 if (fDebug)
5398 cout << "fBmnSiDigitsArray::Init(): branch " << " not found! Task will be deactivated" << endl;
5399 SetActive(kFALSE);
5400 return kERROR;
5401 }
5402 } else {
5403 if (fDebug)
5404 cout << " !expData BmnSiliconTrackFinder::Init()" << endl;
5405 fBmnHitsArray = (TClonesArray*)ioman->GetObject(fInputBranchName);
5406 if (fDebug)
5407 cout << "fInputBranchName = " << fInputBranchName << "\n";
5408 if (!fBmnHitsArray) {
5409 cout << "BmnSiliconTrackFinder::Init(): branch " << fInputBranchName
5410 << " not found! Task will be deactivated" << endl;
5411 SetActive(kFALSE);
5412 return kERROR;
5413 }
5414 fBmnHitsArray2 = (TClonesArray*)ioman->GetObject(fInputBranchName2);
5415 if (fDebug)
5416 cout << "fInputBranchName2 = " << fInputBranchName2 << "\n";
5417 if (!fBmnHitsArray2) {
5418 cout << "BmnSiliconTrackFinder::Init(): branch " << fInputBranchName2
5419 << " not found! Task will be deactivated" << endl;
5420 SetActive(kFALSE);
5421 return kERROR;
5422 }
5423 }
5424
5425 kX_target = 0;
5426 kY_target = 0;
5428 half_target_regionY = 5.5; // !
5429
5430 //--cm--
5431 if (expData) {
5432 // cut for cluster charge
5433 Cut_AmplX = 120.;
5434 Cut_AmplXp = 120.;
5435 Cut_overflow = 1800.;
5436 // cut for strip charge
5437 Cut_AmplStripX = 120.;
5438 Cut_AmplStripXp = 120.;
5439 Chi2_Globcut = 80.; // 20.;
5440 N_min_points = 4;
5441
5442 if (fRunPeriod == 7) {
5443 kX_target = 0.5;
5444 kY_target = -4.5;
5445 Z0_SRC_target = -645.191;
5446 Zcentr = -392.524; // Zc = Zi/3
5450 Shift_toCenterOfMagnetAY = 0.0024;
5451 //--X--
5452 shiftX[1][0] = -6.4 + 0.1148 + 0.0026;
5453 shiftX[2][0] = -5.9 + .1148 + 0.0075;
5454 shiftX[3][0] = -12.15 + 0.1148;
5455 shiftX[3][4] = -12.15 + 0.1148;
5456 shiftX[1][1] = 5.9 - 0.1148 + 0.0085;
5457 shiftX[2][1] = 6.4 - .1148 + 0.009;
5458 shiftX[3][1] = -6.15 + 0.1148;
5459 shiftX[3][5] = -6.15 + 0.1148;
5460 shiftX[1][2] = -5.9 + 0.1148 + 0.011;
5461 shiftX[3][2] = 6.15 - 0.1148;
5462 shiftX[3][6] = 6.15 - 0.1148;
5463 shiftX[1][3] = 6.4 - 0.1148 + 0.019;
5464 shiftX[3][3] = 12.15 - 0.1148;
5465 shiftX[3][7] = 12.15 - 0.1148;
5466
5467 //--Y--
5468 shiftY[1][0] = -0.4 - 0.08;
5469 shiftY[2][0] = -6.22 - 0.02;
5470 shiftY[3][0] = -0.15;
5471 shiftY[3][4] = 0.15;
5472 shiftY[1][1] = 0.1 - 0.06;
5473 shiftY[2][1] = -6.72;
5474 shiftY[3][1] = -0.15 - 0.25;
5475 shiftY[3][5] = 0.15;
5476 shiftY[1][2] = -0.2 - 0.05;
5477 shiftY[3][2] = -0.15 - 0.4;
5478 shiftY[3][6] = 0.15;
5479 shiftY[1][3] = 0.4 - 0.16;
5480 shiftY[3][3] = -0.15;
5481 shiftY[3][7] = 0.15;
5482
5483 Zstation[1][0] = 1.44 + 0.5 * 0.003;
5484 Zstation[2][0] = 4.71 + 0.5 * 0.003;
5485 Zstation[3][0] = 3.51 + 0.5 * 0.003;
5486 Zstation[3][4] = 2.25 + 0.5 * 0.003;
5487 Zstation[1][1] = 2.17 + 0.5 * 0.003;
5488 Zstation[2][1] = 5.44 + 0.5 * 0.003;
5489 Zstation[3][1] = 1.98 + 0.5 * 0.003 - .08;
5490 Zstation[3][5] = 3.78 + 0.5 * 0.003;
5491 Zstation[1][2] = 1.44 + 0.5 * 0.003;
5492 Zstation[3][2] = 3.29 + 0.5 * 0.003 + .08;
5493 Zstation[3][6] = 2.47 + 0.5 * 0.003;
5494 Zstation[1][3] = 2.17 + 0.5 * 0.003;
5495 Zstation[3][3] = 1.76 + 0.5 * 0.003;
5496 Zstation[3][7] = 4.00 + 0.5 * 0.003;
5497
5498 //--cm-- Shift
5499 shiftStXtoGlob[0] = 0.;
5500 shiftStYtoGlob[0] = 0.;
5501 Zposition[0] = 0.;
5502 shiftStXtoGlob[1] = 0.149;
5503 shiftStYtoGlob[1] = 0.096 + .191;
5504 Zposition[1] = 213.999 - 6.87;
5505 shiftStXtoGlob[2] = 0.149;
5506 shiftStYtoGlob[2] = 0.096 + .151;
5507 Zposition[2] = 213.999 - 6.87;
5508 shiftStXtoGlob[3] = 0.047;
5509 shiftStYtoGlob[3] = -6.274 + .174;
5510 Zposition[3] = 327.130 + 0.03;
5511 }
5512 if (fRunPeriod == 8) {
5513 kX_target = 0.; //??
5514 kY_target = 0.; //??
5515 Z0_SRC_target = -574.91;
5516 Zcentr = -423.23; // Zc = Zi/4
5517
5518 //--X--
5519 shiftX[1][0] = -6.150 + 0.1148;
5520 shiftX[2][0] = -6.130 + 0.1148;
5521 shiftX[3][0] = -6.160 + 0.1148;
5522 shiftX[4][0] = -6.158 + 0.1148;
5523 shiftX[1][1] = 6.470 - 0.1148;
5524 shiftX[2][1] = 6.170 - 0.1148;
5525 shiftX[3][1] = 6.122 - 0.1148;
5526 shiftX[4][1] = 6.129 - 0.1148;
5527
5528 //--Y--
5529 // up parts
5530 shiftY[1][0] = 6.203;
5531 shiftY[2][0] = 6.218;
5532 shiftY[3][0] = 6.206;
5533 shiftY[4][0] = 6.209;
5534 shiftY[1][1] = 6.193;
5535 shiftY[2][1] = 6.199;
5536 shiftY[3][1] = 6.197;
5537 shiftY[4][1] = 6.213;
5538 // below parts
5539 shiftYbelow[1][0] = -0.098;
5540 shiftYbelow[2][0] = -0.084;
5541 shiftYbelow[3][0] = -0.094;
5542 shiftYbelow[4][0] = -0.091;
5543 shiftYbelow[1][1] = -0.104;
5544 shiftYbelow[2][1] = -0.097;
5545 shiftYbelow[3][1] = -0.102;
5546 shiftYbelow[4][0] = -0.089;
5547
5548 Zstation[1][0] = -1.14 - 1.3;
5549 Zstation[2][0] = 1.145 + 1.3;
5550 Zstation[3][0] = -1.095 - 1.3;
5551 Zstation[4][0] = 1.140 + 1.3;
5552 Zstation[1][1] = -1.85 - 1.3;
5553 Zstation[2][1] = 1.870 + 1.3;
5554 Zstation[3][1] = -1.850 - 1.3;
5555 Zstation[4][1] = 1.875 + 1.3;
5556
5557 //--cm-- Shift
5558 shiftStXtoGlob[1] = 0.193;
5559 shiftStYtoGlob[1] = 0.153;
5560 Zposition[1] = 124.779;
5561 shiftStXtoGlob[2] = 0.193;
5562 shiftStYtoGlob[2] = 0.153;
5563 Zposition[2] = 126.679;
5564 shiftStXtoGlob[3] = 0.193;
5565 shiftStYtoGlob[3] = 0.153;
5566 Zposition[3] = 176.679;
5567 shiftStXtoGlob[4] = 0.193;
5568 shiftStYtoGlob[4] = 0.153;
5569 Zposition[4] = 178.679;
5570
5575 }
5576 }
5577 if (!expData) {
5578
5579 kX_target = 0.5;
5580 kY_target = -4.5;
5581 // cut for cluster charge
5582 Cut_AmplX = 0.;
5583 Cut_AmplXp = 0.;
5584 Cut_overflow = 1800.;
5585 // cut for strip charge
5586 Cut_AmplStripX = 0.;
5587 Cut_AmplStripXp = 0.;
5588 Chi2_Globcut = 80.; // 20.;
5589 N_min_points = 4;
5590
5595
5596 //--X--
5597 shiftX[1][0] = -6.4 + 0.1148;
5598 shiftX[2][0] = -5.9 + .1148;
5599 shiftX[3][0] = -12.15 + 0.1148;
5600 shiftX[3][4] = -12.15 + 0.1148;
5601 shiftX[1][1] = 5.9 - 0.1148;
5602 shiftX[2][1] = 6.4 - .1148;
5603 shiftX[3][1] = -6.15 + 0.1148;
5604 shiftX[3][5] = -6.15 + 0.1148;
5605 shiftX[1][2] = -5.9 + 0.1148;
5606 shiftX[3][2] = 6.15 - 0.1148;
5607 shiftX[3][6] = 6.15 - 0.1148;
5608 shiftX[1][3] = 6.4 - 0.1148;
5609 shiftX[3][3] = 12.15 - 0.1148;
5610 shiftX[3][7] = 12.15 - 0.1148;
5611
5612 //--Y--
5613 shiftY[1][0] = -0.4;
5614 shiftY[2][0] = -6.22;
5615 shiftY[3][0] = -0.15;
5616 shiftY[3][4] = 0.15;
5617 shiftY[1][1] = 0.1;
5618 shiftY[2][1] = -6.72;
5619 shiftY[3][1] = -0.15;
5620 shiftY[3][5] = 0.15;
5621 shiftY[1][2] = -0.2;
5622 shiftY[3][2] = -0.15;
5623 shiftY[3][6] = 0.15;
5624 shiftY[1][3] = 0.4;
5625 shiftY[3][3] = -0.15;
5626 shiftY[3][7] = 0.15;
5627
5628 shiftStXtoGlob[0] = 0.;
5629 shiftStYtoGlob[0] = 0.;
5630 shiftStXtoGlob[1] = 0.;
5631 shiftStYtoGlob[1] = 0.;
5632 shiftStXtoGlob[2] = 0.;
5633 shiftStYtoGlob[2] = 0.;
5634 shiftStXtoGlob[3] = 0.;
5635 shiftStYtoGlob[3] = 0.;
5636
5637 Zposition[0] = 0.;
5638 Zposition[1] = 213.999 - 6.9 + 0.03;
5639 Zposition[2] = 213.999 - 6.9 + 0.03;
5640 Zposition[3] = 327.130 + 0.03;
5641
5642 Zstation[1][0] = 1.44 + 0.5 * 0.003;
5643 Zstation[2][0] = 4.71 + 0.5 * 0.003;
5644 Zstation[3][0] = 3.51 + 0.5 * 0.003;
5645 Zstation[3][4] = 2.25 + 0.5 * 0.003;
5646 Zstation[1][1] = 2.17 + 0.5 * 0.003;
5647 Zstation[2][1] = 5.44 + 0.5 * 0.003;
5648 Zstation[3][1] = 1.98 + 0.5 * 0.003 - .08;
5649 Zstation[3][5] = 3.78 + 0.5 * 0.003;
5650 Zstation[1][2] = 1.44 + 0.5 * 0.003;
5651 Zstation[3][2] = 3.29 + 0.5 * 0.003 + .08;
5652 Zstation[3][6] = 2.47 + 0.5 * 0.003;
5653 Zstation[1][3] = 2.17 + 0.5 * 0.003;
5654 Zstation[3][3] = 1.76 + 0.5 * 0.003;
5655 Zstation[3][7] = 4.00 + 0.5 * 0.003;
5656
5657 } // if(!expData)
5658
5659 for (Int_t is = 1; is < fNstations; is++) {
5660 for (int im = 0; im < fNmodules; im++) {
5661 if (fRunPeriod == 7 && is == 1 && im > 3)
5662 continue;
5663 if (fRunPeriod == 7 && is == 2 && im > 1)
5664 continue;
5665 Zstation[is][im] += Zposition[is];
5666 Zstation[is][im] += Z0_SRC_target; // coordinate system reference bm@n
5667 // if (fDebug) cout<<" is "<<is<<" im "<<im<<" Z "<<Zstation[is][im]<<endl;
5668
5669 ZstnCforglfit[is][im] = Zstation[is][im] - Zcentr;
5670 }
5671 }
5672
5673 for (Int_t ist = 1; ist < fNstations; ist++) {
5674 // if ( fDebug ) cout<<" shiftStXtoGlob["<<ist<<"]= "<<shiftStXtoGlob[ist]<<" Y "<< shiftStYtoGlob[ist]<<endl;
5675 for (Int_t imod = 0; imod < fNmodules; imod++) {
5676 if (ist == 1 && imod > 3)
5677 continue;
5678 if (ist == 2 && imod > 1)
5679 continue;
5680 // if ( fDebug ) cout<<" shiftX["<<ist<<"]["<<imod<<"]= "<<shiftX[ist][imod]<<"
5681 // shiftY["<<ist<<"]["<<imod<<"]= "<<shiftY[ist][imod]<<endl;
5682 }
5683 }
5684
5685 //--------------------------------------------------------------------
5686 // Create and register hits arrays
5688 ioman->Register("BmnSiliconHits", "SI", fBmnSiliconHitsArray, kTRUE);
5689 //--XHits--
5691 ioman->Register("BmnSiliconHitsX", "SI", fBmnSiliconHitsXArray, kTRUE);
5692 //--XpHits--
5694 ioman->Register("BmnSiliconHitsXp", "SI", fBmnSiliconHitsXpArray, kTRUE);
5695 //--XYHits--
5697 ioman->Register("BmnSiliconHitsXY", "SI", fBmnSiliconHitsXYArray, kTRUE);
5698
5699 // Create and register track arrays
5700 fSiTracks = new TClonesArray("BmnSiliconTrack");
5701 ioman->Register("BmnSiliconTrack", "SI", fSiTracks, kTRUE);
5702
5703 return kSUCCESS;
5704}
5705//----------------------------------------------------------------------
5706
5707//---------------------Initialisation-----------------------------------
5709{
5710 fSiTracks->Clear();
5711 fBmnSiliconHitsArray->Delete();
5712 fBmnSiliconHitsXArray->Delete();
5713 fBmnSiliconHitsXpArray->Delete();
5714 fBmnSiliconHitsXYArray->Delete();
5715 CleanTr.clear();
5716 vec_tracks.clear();
5717 vec_points.clear();
5718
5719 for (Int_t istat = 0; istat < fNstations; istat++) {
5720 Nsp_st[istat] = 0;
5721
5722 for (Int_t im = 0; im < fNmodules; im++) {
5723
5724 Nleftoversp[istat][im] = 0;
5725 NleftoverX[istat][im] = 0;
5726 NleftoverXp[istat][im] = 0;
5727 NclustX[istat][im] = 0;
5728 NclustXp[istat][im] = 0;
5729 NhitsXYmod[istat][im] = 0;
5730 Xforglfit[istat][im] = -999.;
5731 Xpforglfit[istat][im] = -999.;
5732 Yforglfit[istat][im] = -999.;
5733 SigmXforglfit[istat][im] = -999.;
5734 SigmXpforglfit[istat][im] = -999.;
5735 SigmYforglfit[istat][im] = -999.;
5736
5737 for (Int_t ii = 0; ii < fNstrips; ii++) {
5738 Ampl_strX[ii] = 0.;
5739 Ampl_strXp[ii] = 0.;
5740 DigitsArrayX[istat][im][ii] = 0.;
5741 DigitsArrayXp[istat][im][ii] = 0.;
5742 }
5743
5744 for (Int_t ii = 0; ii < kBig; ii++) {
5745 leftoverXsp[istat][im][ii] = -999.;
5746 leftoverXpsp[istat][im][ii] = -999.;
5747 leftoverYsp[istat][im][ii] = -999.;
5748 leftoverXsigsp[istat][im][ii] = -999.;
5749 leftoverXpsigsp[istat][im][ii] = -999.;
5750 leftoverYsigsp[istat][im][ii] = -999.;
5751 leftoverX[istat][im][ii] = -999.;
5752 leftoverXp[istat][im][ii] = -999.;
5753 leftoverXsig[istat][im][ii] = -999.;
5754 leftoverXpsig[istat][im][ii] = -999.;
5755 XCoord[istat][im][ii] = -999.;
5756 XpCoord[istat][im][ii] = -999.;
5757 XspCoord[istat][im][ii] = -999.;
5758 XpspCoord[istat][im][ii] = -999.;
5759 YspCoord[istat][im][ii] = -999.;
5760 Sp_pdg[istat][im][ii] = -1;
5761 SigmaX[istat][im][ii] = -999.;
5762 SigmaXp[istat][im][ii] = -999.;
5763 SigmspX[istat][im][ii] = -999.;
5764 SigmspXp[istat][im][ii] = -999.;
5765 SigmspY[istat][im][ii] = -999.;
5766 XClust[istat][im][ii] = 0.;
5767 XpClust[istat][im][ii] = 0.;
5768 XClust_width[istat][im][ii] = 0.;
5769 XpClust_width[istat][im][ii] = 0.;
5770 sumQx[istat][im][ii] = 0.;
5771 sumQxp[istat][im][ii] = 0.;
5772 XspClust[istat][im][ii] = 0.;
5773 XpspClust[istat][im][ii] = 0.;
5774 XspClust_width[istat][im][ii] = 0.;
5775 XpspClust_width[istat][im][ii] = 0.;
5776 sumQxsp[istat][im][ii] = 0.;
5777 sumQxpsp[istat][im][ii] = 0.;
5778 }
5779 }
5780 }
5781}
5782//----------------------------------------------------------------------
5783
5784//-------------------------empty constructor----------------------------
5789
5790//-------------------------constructor----------------------------------
5792{
5793
5794 fRunNumber = runNumber;
5795 expData = isExp;
5796 fRunPeriod = RunPeriod;
5797 fOutputHitsBranchName = "BmnSiliconHit";
5798}
5799//----------------------------------------------------------------------
5800
5801//-------------------Destructor-----------------------------------------
5803{
5804
5805 for (Int_t istat = 0; istat < fNstations; istat++) {
5806
5807 for (Int_t im = 0; im < fNmodules; im++) {
5808 delete[] XCoord[istat][im];
5809 delete[] XpCoord[istat][im];
5810 delete[] XspCoord[istat][im];
5811 delete[] XpspCoord[istat][im];
5812 delete[] YspCoord[istat][im];
5813 delete[] Sp_pdg[istat][im];
5814 delete[] SigmaX[istat][im];
5815 delete[] SigmaXp[istat][im];
5816 delete[] SigmspX[istat][im];
5817 delete[] SigmspXp[istat][im];
5818 delete[] SigmspY[istat][im];
5819 delete[] leftoverXsp[istat][im];
5820 delete[] leftoverXpsp[istat][im];
5821 delete[] leftoverYsp[istat][im];
5822 delete[] leftoverXsigsp[istat][im];
5823 delete[] leftoverXpsigsp[istat][im];
5824 delete[] leftoverYsigsp[istat][im];
5825 delete[] leftoverX[istat][im];
5826 delete[] leftoverXp[istat][im];
5827 delete[] leftoverXsig[istat][im];
5828 delete[] leftoverXpsig[istat][im];
5829 delete[] DigitsArrayX[istat][im];
5830 delete[] DigitsArrayXp[istat][im];
5831 delete[] XClust[istat][im];
5832 delete[] XpClust[istat][im];
5833 delete[] XClust_width[istat][im];
5834 delete[] XpClust_width[istat][im];
5835 delete[] sumQx[istat][im];
5836 delete[] sumQxp[istat][im];
5837 delete[] XspClust[istat][im];
5838 delete[] XpspClust[istat][im];
5839 delete[] XspClust_width[istat][im];
5840 delete[] XpspClust_width[istat][im];
5841 delete[] sumQxsp[istat][im];
5842 delete[] sumQxpsp[istat][im];
5843 }
5844
5845 delete[] NclustX[istat];
5846 delete[] NclustXp[istat];
5847 delete[] NhitsXYmod[istat];
5848 delete[] XCoord[istat];
5849 delete[] XpCoord[istat];
5850 delete[] XspCoord[istat];
5851 delete[] XpspCoord[istat];
5852 delete[] YspCoord[istat];
5853 delete[] Sp_pdg[istat];
5854 delete[] SigmaX[istat];
5855 delete[] SigmaXp[istat];
5856 delete[] SigmspX[istat];
5857 delete[] SigmspXp[istat];
5858 delete[] SigmspY[istat];
5859 delete[] Xforglfit[istat];
5860 delete[] Xpforglfit[istat];
5861 delete[] Yforglfit[istat];
5862 delete[] SigmXforglfit[istat];
5863 delete[] SigmXpforglfit[istat];
5864 delete[] SigmYforglfit[istat];
5865 delete[] ZstnCforglfit[istat];
5866 delete[] shiftX[istat];
5867 delete[] shiftY[istat];
5868 delete[] shiftYbelow[istat];
5869 delete[] Zstation[istat];
5870 delete[] Nleftoversp[istat];
5871 delete[] NleftoverX[istat];
5872 delete[] NleftoverXp[istat];
5873 delete[] leftoverXsp[istat];
5874 delete[] leftoverXpsp[istat];
5875 delete[] leftoverYsp[istat];
5876 delete[] leftoverXsigsp[istat];
5877 delete[] leftoverXpsigsp[istat];
5878 delete[] leftoverYsigsp[istat];
5879 delete[] leftoverX[istat];
5880 delete[] leftoverXp[istat];
5881 delete[] leftoverXsig[istat];
5882 delete[] leftoverXpsig[istat];
5883
5884 delete[] DigitsArrayX[istat];
5885 delete[] DigitsArrayXp[istat];
5886 delete[] XClust[istat];
5887 delete[] XpClust[istat];
5888 delete[] XClust_width[istat];
5889 delete[] XpClust_width[istat];
5890 delete[] sumQx[istat];
5891 delete[] sumQxp[istat];
5892 delete[] XspClust[istat];
5893 delete[] XpspClust[istat];
5894 delete[] XspClust_width[istat];
5895 delete[] XpspClust_width[istat];
5896 delete[] sumQxsp[istat];
5897 delete[] sumQxpsp[istat];
5898 }
5899
5900 delete[] NclustX;
5901 delete[] NclustXp;
5902 delete[] NhitsXYmod;
5903 delete[] XCoord;
5904 delete[] XpCoord;
5905 delete[] XspCoord;
5906 delete[] XpspCoord;
5907 delete[] YspCoord;
5908 delete[] Sp_pdg;
5909 delete[] SigmaX;
5910 delete[] SigmaXp;
5911 delete[] SigmspX;
5912 delete[] SigmspXp;
5913 delete[] SigmspY;
5914 delete[] Xforglfit;
5915 delete[] Xpforglfit;
5916 delete[] Yforglfit;
5917 delete[] SigmXforglfit;
5918 delete[] SigmXpforglfit;
5919 delete[] SigmYforglfit;
5920 delete[] ZstnCforglfit;
5921 delete[] shiftStXtoGlob;
5922 delete[] shiftStYtoGlob;
5923 delete[] shiftX;
5924 delete[] shiftY;
5925 delete[] shiftYbelow;
5926 delete[] Zstation;
5927 delete[] Zposition;
5928 delete[] Nleftoversp;
5929 delete[] NleftoverX;
5930 delete[] NleftoverXp;
5931 delete[] leftoverXsp;
5932 delete[] leftoverXpsp;
5933 delete[] leftoverYsp;
5934 delete[] leftoverXsigsp;
5935 delete[] leftoverXpsigsp;
5936 delete[] leftoverYsigsp;
5937 delete[] leftoverX;
5938 delete[] leftoverXp;
5939 delete[] leftoverXsig;
5940 delete[] leftoverXpsig;
5941 delete[] Nsp_st;
5942 delete[] iClustXMod;
5943 delete[] iModX;
5944 delete[] Ampl_strX;
5945 delete[] Ampl_strXp;
5946 delete[] DigitsArrayX;
5947 delete[] DigitsArrayXp;
5948 delete[] XClust;
5949 delete[] XpClust;
5950 delete[] XClust_width;
5951 delete[] XpClust_width;
5952 delete[] sumQx;
5953 delete[] sumQxp;
5954 delete[] XspClust;
5955 delete[] XpspClust;
5956 delete[] XspClust_width;
5957 delete[] XpspClust_width;
5958 delete[] sumQxsp;
5959 delete[] sumQxpsp;
5960
5961 for (Int_t i = 0; i < 4; i++) {
5962 delete[] Amatr[i];
5963 }
5964 delete[] AmatrInverted;
5965 delete[] rhs;
5966 delete[] AmatrArray;
5967 delete[] Amatr;
5968 delete[] line;
5969}
5970//----------------------------------------------------------------------
5971
5972//----------------------------------------------------------------------
5974{
5975
5976 if (fDebug) {
5977
5978 E_eff->Divide(N_eff, D_eff, 1, 1);
5979 hEff_mctrSi->Divide(hNum_mctrSi, hDen_mctrSi, 1, 1);
5981
5982 printf("BmnSiliconTrackFinder: write hists to file... ");
5983 fOutputFileName = Form("hSiliconTracks_run%d.root", fRunNumber);
5984 cout << fOutputFileName << endl;
5985 TFile file(fOutputFileName, "RECREATE");
5986 fList.Write();
5987 file.Close();
5988 }
5989
5990 cout << "Work time of the SI track finder: " << workTime << " s" << endl;
5991}
5992//----------------------------------------------------------------------
static Double_t workTime
friend F32vec4 fabs(const F32vec4 &a)
Definition P4_F32vec4.h:52
int i
Definition P4_F32vec4.h:22
__m128 m
Definition P4_F32vec4.h:27
bool Bool_t
int Int_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
const char Option_t
char * Form(const char *fmt,...)
Int_t GetType()
Definition BmnHit.h:37
Int_t GetIndex() const
Definition BmnHit.h:32
void SetModule(Int_t mod)
Definition BmnHit.h:53
void SetIndex(Int_t id)
Definition BmnHit.h:49
void SetStation(Short_t st)
Definition BmnHit.h:52
void SetPdg(Int_t cPdg)
void Case3(Int_t **, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Int_t **, Int_t **, Double_t ***, Double_t ***, Double_t ***, Double_t ***, vector< tracksX > &, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***)
void GetXYspatial(Int_t **NClX, Int_t **NClXp, Double_t ***XCoor, Double_t ***XpCoor, Double_t ***Xsp, Double_t ***Xpsp, Double_t ***Ysp, Int_t **NXYsp, Double_t ***SigmX, Double_t ***SigmXp, Double_t ***SigspX, Double_t ***SigspXp, Double_t ***SigspY, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***)
void CoordinateAlignment(Int_t **, Double_t ***, Double_t ***, Double_t ***, Int_t **, Int_t **, Double_t ***, Double_t ***)
virtual void Exec(Option_t *opt)
void WriteSiliconHits(Int_t **, Int_t **, Int_t **, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Int_t ***)
void CoordinateCalculation(Int_t **, Int_t **, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Int_t **, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, vector< MC_points > &, Int_t ***)
void PrintAllTracks(vector< tracksX > &)
void CountSpatialPoints(Int_t **, Int_t *)
void Clustering(Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Int_t **, Double_t ***, Double_t ***, Double_t ***, Int_t **)
void WriteSiliconTracks(vector< tracksX > &)
Bool_t SkipEvent(Int_t **, Int_t **, Double_t ***, Double_t ***)
Double_t GetXYspatial_station1_2(Int_t &, Int_t &, Double_t &, Double_t &)
void Case2(Int_t &, Int_t **, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Int_t **, Int_t **, Double_t ***, Double_t ***, Double_t ***, Double_t ***, vector< tracksX > &, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***)
Double_t FindClusterCenter(Double_t *, Int_t, Double_t &)
void MCefficiencyCalculation(vector< MC_points > &, vector< tracksX > &)
vector< MC_points > vec_points
void StripsReading(Double_t ***, Double_t ***)
void Case4(Int_t &, Int_t **, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Int_t **, Int_t **, Double_t ***, Double_t ***, Double_t ***, Double_t ***, vector< tracksX > &, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***)
bool InvertMatrix(Double_t *, Double_t *)
void RecordingTracks(vector< tracksX > &, vector< tracksX > &)
const Double_t half_roadXp1_Xp2_diff_sign
void RecordingTracksAfterSpatialPoints(vector< tracksX > &, vector< tracksX > &)
TClonesArray * fBmnSiliconHitsXpArray
Int_t Angle(Int_t &, Int_t &)
static bool compareSegments(const tracksX &a, const tracksX &b)
void calculationOfChi2(Double_t **, Double_t **, Double_t **, Double_t **, Int_t *, Int_t *, Double_t &, Double_t *)
void CheckPoints(Int_t **, Int_t **, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Int_t **, vector< tracksX > &, Int_t **, Int_t **, Int_t **, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***)
TString fOutputHitsBranchName
Output array of Silicon Hits.
TClonesArray * fBmnSiliconHitsXYArray
void RecordingTracks_case3(vector< tracksX > &, vector< tracksX > &)
void CheckLeftover(Int_t **, Int_t **, Int_t **, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, vector< tracksX > &, Int_t **, Double_t ***, Double_t ***, Double_t ***, Double_t ***)
void GlobalFit(Double_t **, Double_t **, Double_t **, Double_t **, Double_t **, Double_t **, Double_t *)
void Case1(Int_t **, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, vector< tracksX > &, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***, Double_t ***)
Int_t GetStripNumber()
Int_t GetStripLayer()
Int_t GetStation()
Double_t GetStripSignal()
Int_t GetModule()
void SetChi2(Double_t chi2)
Definition BmnTrack.h:76
void SetParamLast(FairTrackParam &par)
Definition BmnTrack.h:72
void SetFlag(Int_t flag)
Definition BmnTrack.h:74
void SetNHits(Int_t n)
Definition BmnTrack.h:80
void SetParamFirst(FairTrackParam &par)
Modifiers.
Definition BmnTrack.h:70
void SetNDF(Int_t ndf)
Definition BmnTrack.h:78
void Close(Option_t *option="") override
RVec< PromoteTypes< T0, T1 > > pow(const RVec< T0 > &v, const T1 &y)
RVec< PromoteType< T > > sqrt(const RVec< T > &v)
Double_t SumQX[4]
Double_t SigmaX[4]
Double_t CoordZ[4]
Double_t SigmaXp[4]
Double_t CoordX[4]
Double_t CoordY[4]
Double_t SigmaY[4]
Double_t StripNumX[4]
Double_t param[4]
Double_t StripNumXp[4]
Double_t ClSizeX[4]
Double_t SumQXp[4]
Double_t CoordXp[4]
Double_t ClSizeXp[4]