13 #include "FairEventHeader.h"
14 #include "FairRootManager.h"
16 #include <TClonesArray.h>
17 #include <TGeoManager.h>
20 #include <TMatrixFLazy.h>
37 : FairTask(
"MuchFindVectors")
58 for (Int_t j = 0; j < nVecs; ++j)
63 for (map<Int_t, TDecompLU*>::iterator it =
fLus.begin(); it !=
fLus.end();
73 FairRootManager* ioman = FairRootManager::Instance();
74 if (ioman == NULL) Fatal(
"Init",
"RootManager not instantiated!");
77 fTrackArray =
static_cast<TClonesArray*
>(ioman->GetObject(
"MuchVector"));
79 fTrackArray =
new TClonesArray(
"CbmMuchTrack", 100);
80 ioman->Register(
"MuchVector",
"Much",
fTrackArray, kTRUE);
83 CbmMuchFindHitsStraws* hitFinder =
84 (CbmMuchFindHitsStraws*) FairRun::Instance()->GetTask(
85 "CbmMuchFindHitsStraws");
87 if (hitFinder == NULL)
return kSUCCESS;
89 fDiam = hitFinder->GetDiam(0);
91 fHits =
static_cast<TClonesArray*
>(ioman->GetObject(
"MuchStrawHit"));
92 fPoints =
static_cast<TClonesArray*
>(ioman->GetObject(
"MuchPoint"));
94 static_cast<TClonesArray*
>(ioman->GetObject(
"MuchStrawDigiMatch"));
98 for (Int_t
i = 0;
i < nSt; ++
i) {
108 for (Int_t lay = 0; lay < nLays; ++lay) {
110 Double_t phi = hitFinder->GetPhi(lay);
111 for (Int_t iside = 0; iside < 2; ++iside) {
113 Int_t plane = lay * 2 + iside;
117 fCosa[plane] = TMath::Cos(phi);
118 fSina[plane] = TMath::Sin(phi);
122 * TMath::Tan(TMath::ASin(
fSina[plane])
123 - TMath::ASin(
fSina[plane - 2]));
138 Double_t dzAbs[9] = {0}, zAbs[9] = {0}, radlAbs[9] = {0}, xyzl[3] = {0},
141 TGeoVolume* vol = 0x0;
142 for (Int_t
i = 1;
i < 10; ++
i) {
143 TString abso =
"muchabsorber0";
145 vol = gGeoManager->GetVolume(abso);
146 if (vol == 0x0)
break;
147 TString path =
"/cave_1/much_0/";
150 gGeoManager->cd(path);
151 gGeoManager->LocalToMaster(xyzl, xyzg);
152 zAbs[nAbs] = xyzg[2];
153 cout << vol->GetName() <<
" " << vol->GetShape()->GetName() <<
" "
154 << ((TGeoBBox*) vol->GetShape())->GetDZ() << endl;
156 dzAbs[nAbs] = ((TGeoBBox*) vol->GetShape())->GetDZ();
157 radlAbs[nAbs] = vol->GetMaterial()->GetRadLen();
158 fZabs0[nAbs][0] = zAbs[nAbs] - dzAbs[nAbs];
159 fZabs0[nAbs][1] = zAbs[nAbs] + dzAbs[nAbs];
160 fX0abs[nAbs] = radlAbs[nAbs];
164 cout <<
" \n !!! MUCH Absorbers: " << nAbs <<
"\n Zbeg, Zend, X0:";
165 for (Int_t j = 0; j < nAbs; ++j)
168 cout << endl << endl;
192 for (Int_t j = 0; j < nVecs; ++j)
216 Double_t err =
fErrU;
238 for (Int_t j = 0; j < nVecs; ++j)
243 for (map<Int_t, TDecompLU*>::iterator it =
fLus.begin(); it !=
fLus.end();
265 Int_t pattMax = 1 <<
fgkPlanes, nDouble = 0, nTot = 0;
268 for (Int_t ipat = 1; ipat < pattMax; ++ipat) {
278 if ((ipat & (3 << 6)) == 0) ++nDouble;
283 onoff[j] = (ipat & (1 << j));
287 if (!onoff[
i])
continue;
288 coef(0, 0) += cos2[
i];
289 coef(0, 1) += sincos[
i];
290 coef(0, 2) +=
fDz[
i] * cos2[
i];
291 coef(0, 3) +=
fDz[
i] * sincos[
i];
294 if (!onoff[
i])
continue;
295 coef(1, 0) += sincos[
i];
296 coef(1, 1) += sin2[
i];
297 coef(1, 2) +=
fDz[
i] * sincos[
i];
298 coef(1, 3) +=
fDz[
i] * sin2[
i];
301 if (!onoff[
i])
continue;
302 coef(2, 0) +=
fDz[
i] * cos2[
i];
303 coef(2, 1) +=
fDz[
i] * sincos[
i];
304 coef(2, 2) += dz2[
i] * cos2[
i];
305 coef(2, 3) += dz2[
i] * sincos[
i];
308 if (!onoff[
i])
continue;
309 coef(3, 0) +=
fDz[
i] * sincos[
i];
310 coef(3, 1) +=
fDz[
i] * sin2[
i];
311 coef(3, 2) += dz2[
i] * sincos[
i];
312 coef(3, 3) += dz2[
i] * sin2[
i];
315 TDecompLU* lu =
new TDecompLU(4);
317 lu->SetTol(0.1 * lu->GetTol());
319 fLus.insert(pair<Int_t, TDecompLU*>(ipat, lu));
321 cov.SetMatrixArray(coef.GetMatrixArray());
323 fMatr.insert(pair<Int_t, TMatrixDSym*>(ipat,
new TMatrixDSym(cov)));
326 buf += Bool_t(ipat & (1 << jp));
327 cout <<
" Determinant: " << buf <<
" " << ipat <<
" " << coef.Determinant()
331 cout <<
" Number of configurations: " << nTot << endl;
333 cov *= (0.02 * 0.02);
334 cout << TMath::Sqrt(cov(0, 0)) <<
" " << TMath::Sqrt(cov(1, 1)) <<
" "
335 << TMath::Sqrt(cov(2, 2)) <<
" " << TMath::Sqrt(cov(3, 3)) << endl;
344 for (Int_t ista = 0; ista <
fgkStat; ++ista) {
351 Int_t nHits =
fHits->GetEntriesFast(), nSelTu[
fgkStat] = {0}, sel = 0;
352 for (Int_t
i = 0;
i < nHits; ++
i) {
353 CbmMuchStrawHit* hit = (CbmMuchStrawHit*)
fHits->UncheckedAt(
i);
360 Int_t detId = hit->GetAddress();
370 Int_t plane = doublet * 2 + layer;
372 pair<Int_t, Int_t>(hit->GetTube() + 1000 * hit->GetSegment(),
i));
379 Int_t nlay2 =
fgkPlanes / 2, indx1, indx2, tube1, tube2, next1, next2;
380 CbmMuchStrawHit *hit1 = NULL, *hit2 = NULL;
382 for (Int_t ista = 0; ista <
fgkStat; ++ista) {
384 Int_t nSelDouble = 0;
386 for (Int_t i1 = 0; i1 < nlay2; ++i1) {
404 multimap<Int_t, Int_t>::iterator it1 =
fHitPl[ista][i1 * 2].begin(),
405 it2 =
fHitPl[ista][i1 * 2 + 1].begin();
406 multimap<Int_t, Int_t>::iterator it1end =
fHitPl[ista][i1 * 2].end(),
407 it2end =
fHitPl[ista][i1 * 2 + 1].end();
408 set<Int_t> tubeOk[2];
410 if (it1 == it1end) next1 = 0;
411 if (it2 == it2end) next2 = 0;
413 while (next1 || next2) {
417 hit1 = (CbmMuchStrawHit*)
fHits->UncheckedAt(indx1);
422 hit2 = (CbmMuchStrawHit*)
fHits->UncheckedAt(indx2);
426 if (it2 != it2end && tube2 < tube1 || it1 == it1end) {
428 if (tubeOk[1].find(tube2) == tubeOk[1].end()) {
431 if (sel)
fHit2d[ista][i1].push_back(pair<Int_t, Int_t>(-1, indx2));
432 tubeOk[1].insert(tube2);
437 if (it2 ==
fHitPl[ista][i1 * 2 + 1].end()) next2 = 0;
440 if (it1 != it1end && tube2 > tube1 + 1 || it2 == it2end) {
442 if (tubeOk[0].find(tube1) == tubeOk[0].end()) {
445 if (sel)
fHit2d[ista][i1].push_back(pair<Int_t, Int_t>(indx1, -1));
446 tubeOk[0].insert(tube1);
451 if (it1 ==
fHitPl[ista][i1 * 2].end()) next1 = 0;
457 if (sel)
fHit2d[ista][i1].push_back(pair<Int_t, Int_t>(indx1, indx2));
458 tubeOk[0].insert(tube1);
459 tubeOk[1].insert(tube2);
460 if (tube2 == tube1) {
464 if (it2 ==
fHitPl[ista][i1 * 2 + 1].end()) {
467 if (it1 ==
fHitPl[ista][i1 * 2].end()) next1 = 0;
473 if (it1 ==
fHitPl[ista][i1 * 2].end()) {
476 if (it2 ==
fHitPl[ista][i1 * 2 + 1].end()) next2 = 0;
482 cout <<
" Selected tubes: " << ista <<
" " << nSelTu[ista] << endl;
484 cout <<
" Selected doublets: " << ista <<
" " << nSelDouble << endl;
490 Bool_t CbmMuchFindVectors::SelectHitId(
const CbmMuchStrawHit* hit) {
493 Int_t nSel = 2, idSel[2] = {0, 1},
id = 0;
495 for (Int_t
i = 0;
i < nSel; ++
i) {
496 if (hit->GetFlag() % 2) {
504 for (Int_t ip = 0; ip < np; ++ip) {
507 id = point->GetTrackID();
508 if (
id == idSel[
i])
return kTRUE;
522 Int_t nId = 2, idSel[2] = {0, 1},
id = 0;
523 CbmMuchStrawHit* hit = NULL;
528 hit = (CbmMuchStrawHit*)
fHits->UncheckedAt(indx1);
529 if (hit->GetFlag() % 2 == 0) {
531 for (Int_t
i = 0;
i < nId; ++
i) {
534 for (Int_t ip = 0; ip < np; ++ip) {
537 id = point->GetTrackID();
538 if (
id == idSel[
i])
return kTRUE;
544 hit = (CbmMuchStrawHit*)
fHits->UncheckedAt(indx2);
545 if (hit->GetFlag() % 2 == 0) {
547 for (Int_t
i = 0;
i < nId; ++
i) {
550 for (Int_t ip = 0; ip < np; ++ip) {
553 id = point->GetTrackID();
554 if (
id == idSel[
i])
return kTRUE;
567 for (Int_t ista = 0; ista <
fgkStat; ++ista) {
569 for (Int_t j = 0; j < nvec; ++j)
572 Int_t lay2 = 0, patt = 0, flag = 0, ndoubl =
fHit2d[ista][lay2].size();
573 CbmMuchStrawHit* hit = NULL;
575 cout <<
" Doublets: " << ista <<
" " << ndoubl << endl;
576 for (Int_t
id = 0;
id < ndoubl; ++id) {
577 Int_t indx1 =
fHit2d[ista][lay2][id].first;
578 Int_t indx2 =
fHit2d[ista][lay2][id].second;
580 hit = (CbmMuchStrawHit*)
fHits->UncheckedAt(indx1);
581 fUz[lay2 * 2][0] = hit->GetU();
583 fUzi[lay2 * 2][0] = hit->GetSegment();
584 fUzi[lay2 * 2][1] = indx1;
585 fUzi[lay2 * 2][2] = hit->GetTube();
588 hit = (CbmMuchStrawHit*)
fHits->UncheckedAt(indx2);
589 fUz[lay2 * 2 + 1][0] = hit->GetU();
591 fUzi[lay2 * 2 + 1][0] = hit->GetSegment();
592 fUzi[lay2 * 2 + 1][1] = indx2;
593 fUzi[lay2 * 2 + 1][2] = hit->GetTube();
595 Bool_t ind1 = indx1 + 1;
596 Bool_t ind2 = indx2 + 1;
601 ista, lay2 + 1, patt, flag, hit->GetTube(), hit->GetSegment());
617 const Int_t dTubes2 = 30;
618 Double_t pars[4] = {0.0};
620 Int_t ndoubl =
fHit2d[ista][lay2].size();
622 for (Int_t
id = 0;
id < ndoubl; ++id) {
623 Int_t indx1 =
fHit2d[ista][lay2][id].first;
624 Int_t indx2 =
fHit2d[ista][lay2][id].second;
625 CbmMuchStrawHit* hit =
626 (CbmMuchStrawHit*)
fHits->UncheckedAt(TMath::Max(indx1, indx2));
627 Int_t segment = hit->GetSegment();
628 Int_t tube = hit->GetTube();
631 if (TMath::Abs(tube - tube0) >
fDtubes[ista][lay2 - 1])
636 for (Int_t il = 0; il < lay2; ++il) {
638 if (TMath::Abs(
fSina[pl] -
fSina[lay2 * 2]) < 0.01) {
640 Int_t seg =
fUzi[pl][0];
641 if (!(patt & (1 << pl))) seg =
fUzi[pl + 1][0];
642 if (segment != seg) {
647 Double_t z =
fDz[pl];
648 Int_t tu =
fUzi[pl][2];
649 if (!(patt & (1 << pl))) {
651 tu =
fUzi[pl + 1][2];
654 Double_t dzz = (hit->GetZ() - z) / z;
655 if (TMath::Abs(tube - tu - dzz * tu) > dTubes2) {
676 hit = (CbmMuchStrawHit*)
fHits->UncheckedAt(indx1);
677 fUz[lay2 * 2][0] = hit->GetU();
679 fUzi[lay2 * 2][0] = hit->GetSegment();
680 fUzi[lay2 * 2][1] = indx1;
681 fUzi[lay2 * 2][2] = hit->GetTube();
684 hit = (CbmMuchStrawHit*)
fHits->UncheckedAt(indx2);
685 fUz[lay2 * 2 + 1][0] = hit->GetU();
687 fUzi[lay2 * 2 + 1][0] = hit->GetSegment();
688 fUzi[lay2 * 2 + 1][1] = indx2;
689 fUzi[lay2 * 2 + 1][2] = hit->GetTube();
695 Bool_t ind1 = indx1 + 1;
696 Bool_t ind2 = indx2 + 1;
698 patt &= ~(1 << lay2 * 2);
699 patt &= ~(1 << lay2 * 2 + 1);
701 patt |= (ind1 << lay2 * 2);
702 patt |= (ind2 << lay2 * 2 + 1);
710 Double_t chi2 =
FindChi2(ista, patt, pars);
714 ista, patt, chi2, pars);
728 Int_t lay2 = curLay * 2;
729 if (indx1 < 0) ++lay2;
730 Double_t u2 =
fUz[lay2][0];
732 Int_t lay1 = curLay * 2 - 2;
733 if (!(patt & (1 << lay1))) ++lay1;
734 Double_t u1 =
fUz[lay1][0];
736 Double_t yint = u1 *
fCosa[lay2] - u2 *
fCosa[lay1];
738 if (TMath::Abs(yint) >
fRmax[ista] + 10.0)
743 Double_t v1 = -xint *
fSina[lay1] + yint *
fCosa[lay1];
744 Double_t v2 = -xint *
fSina[lay2] + yint *
fCosa[lay2];
746 cout << xint <<
" " << yint <<
" " << v1 <<
" " << v2 <<
" " <<
fUzi[lay1][0]
747 <<
" " <<
fUzi[lay2][0] << endl;
748 if (TMath::Abs(v1) > 10.0 && v1 *
fUzi[lay1][0] < 0)
749 cout <<
" Outside !!! " << endl;
750 if (TMath::Abs(v2) > 10.0 && v2 *
fUzi[lay2][0] < 0)
751 cout <<
" Outside !!! " << endl;
752 if (TMath::Abs(v1) > 30.0 && v1 *
fUzi[lay1][0] < 0)
return kFALSE;
753 if (TMath::Abs(v2) > 30.0 && v2 *
fUzi[lay2][0] < 0)
return kFALSE;
768 TMatrixDSym cov(*
fMatr[patt]);
772 FairTrackParam par(pars[0], pars[1],
fZ0[ista], pars[2], pars[3], 0.0, cov);
780 for (Int_t ipl = 0; ipl <
fgkPlanes; ++ipl) {
781 if (!(patt & (1 << ipl)))
continue;
783 if (lowRes)
continue;
785 CbmMuchStrawHit* hit = (CbmMuchStrawHit*)
fHits->UncheckedAt(
fUzi[ipl][1]);
786 hit->SetDphi(
fUz[ipl][0]);
802 map<Int_t, Int_t> ids;
805 for (Int_t ih = 0; ih < nhits; ++ih) {
806 CbmMuchStrawHit* hit =
808 if (hit->GetFlag() % 2) {
812 if (ids.find(
id) == ids.end())
813 ids.insert(pair<Int_t, Int_t>(
id, 1));
820 for (Int_t ip = 0; ip < np; ++ip) {
824 id = point->GetTrackID();
826 if (ids.find(
id) == ids.end())
827 ids.insert(pair<Int_t, Int_t>(
id, 1));
834 Int_t maxim = -1, idmax = -9;
835 for (map<Int_t, Int_t>::iterator it = ids.begin(); it != ids.end(); ++it) {
836 if (it->second > maxim) {
851 Bool_t ok = kFALSE, onoff;
854 onoff = patt & (1 <<
i);
855 if (!onoff)
continue;
863 TVectorD solve =
fLus[patt]->Solve(b, ok);
866 for (Int_t
i = 0;
i < 4; ++
i)
879 Double_t chi2 = 0,
x = 0,
y = 0, u = 0, errv = 1.;
880 if (
fErrU > 0.1) errv = 10;
881 static Int_t
first = 1;
901 onoff = patt & (1 <<
i);
902 if (!onoff)
continue;
903 x = pars[0] + pars[2] *
fDz[
i];
904 y = pars[1] + pars[3] *
fDz[
i];
906 Double_t du = (u -
fUz[
i][0]) /
fErrU, du2 = du * du;
908 multimap<Double_t, Int_t>::iterator it =
909 fChi2Map.insert(pair<Double_t, Int_t>(du2,
i));
914 Int_t iseg =
fUzi[
i][0];
918 if (TMath::Abs(
fUz[
i][0]) >
fRmin[ista] &&
v * iseg > 0)
continue;
920 if (TMath::Abs(
fUz[
i][0]) <
fRmin[ista]) {
924 if ((
v - v0) * iseg > 0)
continue;
926 Double_t dv = (
v - v0) / errv, dv2 = dv * dv;
929 fChi2Map.insert(pair<Double_t, Int_t>(du2 + dv2,
i));
941 Double_t cut[2] = {0.6, 0.7};
943 for (Int_t ista = 0; ista <
fgkStat; ++ista) {
946 for (Int_t iv = 0; iv < nvec; ++iv) {
949 Double_t dTx = params->GetTx() - params->GetX() / params->GetZ();
950 Double_t dTy = params->GetTy() - params->GetY() / params->GetZ();
951 if (TMath::Abs(dTx) > cut[0] || TMath::Abs(dTy) > cut[1])
955 for (Int_t iv = nvec - 1; iv >= 0; --iv) {
962 cout <<
" Vectors after parameter check in station " << ista <<
": " << nvec
963 <<
" " <<
fVectors[ista].size() << endl;
972 for (Int_t ista = 0; ista <
fgkStat; ++ista) {
975 for (Int_t iv = 0; iv < nvec; ++iv) {
981 for (Int_t ih = 0; ih < nhits; ++ih) {
982 CbmMuchStrawHit* hit =
986 Int_t plane = lay * 2 + side;
987 uu[plane][0] = hit->GetU();
988 uu[plane][1] = hit->GetDouble()[2];
989 patt |= (1 << plane);
990 fUzi[plane][0] = hit->GetSegment();
996 Int_t nCombs = (patt & 1) ? 2 : 1, flag = 1, nok = nCombs - 1;
999 for (Int_t icomb = -1; icomb < nCombs; icomb += 2) {
1000 fUz[0][0] = (nCombs == 2) ? uu[0][0] + uu[0][1] * icomb : 0.0;
1003 if (Int_t(
fVectorsHigh[ista].size()) > size0)
continue;
1020 Double_t uu[fgkPlanes][2]) {
1024 Double_t pars[4] = {0.0};
1025 const Double_t thresh = 10.0;
1028 Int_t nCombs = (patt & (1 << plane)) ? 2 : 1;
1029 nok += (nCombs - 1);
1031 for (Int_t icomb = -1; icomb < nCombs; icomb += 2) {
1032 fUz[plane][0] = (nCombs == 2) ? uu[plane][0] + uu[plane][1] * icomb : 0.0;
1035 Int_t patt1 = patt & ((1 << plane + 1) - 1);
1037 Double_t chi2 =
FindChi2(ista, patt1, pars);
1048 if (icomb > -1) flag = 0;
1060 for (Int_t j = 0; j <= plane; ++j) {
1061 if (!(patt1 & (1 << j)))
continue;
1062 if (
fUz[j][0] > uu[j][0]) lrbits |= (1 << j);
1065 pair<Int_t, multimap<Double_t, Int_t>>(lrbits,
fChi2Map));
1088 for (Int_t ista = 0; ista <
fgkStat; ++ista) {
1089 Int_t nVecs =
fVectors[ista].size();
1090 for (Int_t j = 0; j < nVecs; ++j)
1095 for (Int_t j = 0; j < nVecs; ++j)
1105 Int_t nthr = 4, planes[20];
1107 for (Int_t ista = 0; ista <
fgkStat; ++ista) {
1108 Int_t nvec =
fVectors[ista].size();
1111 multimap<Double_t, CbmMuchTrack*> qMap;
1112 multimap<Double_t, CbmMuchTrack*>::iterator it, it1;
1114 for (Int_t iv = 0; iv < nvec; ++iv) {
1118 qMap.insert(pair<Double_t, CbmMuchTrack*>(-qual, vec));
1121 for (it = qMap.begin(); it != qMap.end(); ++it) {
1128 for (Int_t ih = 0; ih < nhits; ++ih) {
1129 CbmMuchStrawHit* hit =
1138 for (++it1; it1 != qMap.end(); ++it1) {
1140 if (vec1->
GetChiSq() < 0)
continue;
1141 Int_t nsame = 0, same[
fgkPlanes / 2] = {0};
1146 for (Int_t ih = 0; ih < nhits1; ++ih) {
1147 CbmMuchStrawHit* hit =
1151 if (planes[lay * 2 + side] >= 0) {
1152 if (vec1->
GetHitIndex(ih) == planes[lay * 2 + side]) same[lay] = 1;
1156 for (Int_t lay = 0; lay <
fgkPlanes / 2; ++lay)
1159 if (nsame >= nthr) {
1162 if (nhits > nhits1 + 0) clone = 1;
1185 for (Int_t iv = nvec - 1; iv >= 0; --iv) {
1192 cout <<
" Vectors after clones removed: " << nvec <<
" "
1203 Int_t nshort =
fgkPlanes / 2, planes[20];
1205 for (Int_t ista = 0; ista <
fgkStat; ++ista) {
1206 Int_t nvec =
fVectors[ista].size();
1209 for (Int_t iv = 0; iv < nvec; ++iv) {
1213 if (nhits != nshort)
continue;
1218 for (Int_t ih = 0; ih < nhits; ++ih) {
1219 CbmMuchStrawHit* hit =
1226 for (Int_t iv1 = iv + 1; iv1 < nvec; ++iv1) {
1228 if (vec1->
GetChiSq() < 0)
continue;
1232 for (Int_t ih = 0; ih < nhits1; ++ih) {
1233 CbmMuchStrawHit* hit =
1237 if (vec1->
GetHitIndex(ih) == planes[lay * 2 + side]
1238 && planes[lay * 2 + side] >= 0)
1242 if (overlap.size() > 0) {
1251 for (Int_t iv = nvec - 1; iv >= 0; --iv) {
1258 cout <<
" Vectors after shorts removed: " << nvec <<
" "
1270 Int_t nHitsTot =
fHits->GetEntriesFast();
1272 for (Int_t ist = 0; ist <
fgkStat; ++ist) {
1273 set<Int_t> usedHits;
1276 for (Int_t iv = 0; iv < nvec; ++iv) {
1309 for (count = 0;
x; count++)
1319 const Int_t iabs = 3;
1322 TMatrixF matr = TMatrixF(5, 5);
1323 TMatrixF unit(TMatrixF::kUnit, matr);
1325 for (Int_t ista = 0; ista <
fgkStat; ++ista) {
1326 Int_t nvec =
fVectors[ista].size();
1329 for (Int_t iv = 0; iv < nvec; ++iv) {
1332 Double_t zbeg = parFirst.GetZ();
1333 Double_t dz =
fZabs0[iabs][0] - zbeg;
1335 parFirst.SetX(parFirst.GetX() + dz * parFirst.GetTx());
1336 parFirst.SetY(parFirst.GetY() + dz * parFirst.GetTy());
1337 parFirst.SetZ(parFirst.GetZ() + dz);
1339 parFirst.CovMatrix(cov);
1342 ff(2, 0) = ff(3, 1) = dz;
1343 TMatrixF cf(cov, TMatrixF::kMult, ff);
1344 TMatrixF fcf(ff, TMatrixF::kTransposeMult, cf);
1345 cov.SetMatrixArray(fcf.GetMatrixArray());
1348 ista + iabs * 2,
fZabs0[iabs],
fX0abs[iabs], parFirst, cov, 0);
1350 parFirst.SetCovMatrix(cov);
1355 Int_t ista0 = 0, ista1 = 1;
1356 vector<Int_t> matchOK[2];
1358 matchOK[0].assign(nvec0, -1);
1359 matchOK[1].assign(nvec1, -1);
1361 for (Int_t iv = 0; iv < nvec0; ++iv) {
1367 Float_t pars1[5] = {(Float_t) par1.GetX(),
1368 (Float_t) par1.GetY(),
1369 (Float_t) par1.GetTx(),
1370 (Float_t) par1.GetTy(),
1372 TMatrixF p1(5, 1, pars1);
1373 TMatrixF wp1(w1, TMatrixF::kTransposeMult, p1);
1375 for (Int_t iv1 = 0; iv1 < nvec1; ++iv1) {
1380 TMatrixFSym w20 = w2;
1381 Float_t pars2[5] = {(Float_t) par2.GetX(),
1382 (Float_t) par2.GetY(),
1383 (Float_t) par2.GetTx(),
1384 (Float_t) par2.GetTy(),
1386 TMatrixF p2(5, 1, pars2);
1387 TMatrixF wp2(w2, TMatrixF::kTransposeMult, p2);
1391 TMatrixF p12(w2, TMatrixF::kTransposeMult, wp2);
1394 TMatrixF p122 = p12;
1395 TMatrixF pMerge = p12;
1397 TMatrixF wDp1(w1, TMatrixF::kMult, p12);
1398 TMatrixF chi21(p12, TMatrixF::kTransposeMult, wDp1);
1400 TMatrixF wDp2(w20, TMatrixF::kMult, p122);
1401 TMatrixF chi22(p122, TMatrixF::kTransposeMult, wDp2);
1402 Double_t c2 = chi21(0, 0) + chi22(0, 0);
1404 if (c2 < 0 || c2 >
fCutChi2 * 2)
continue;
1405 matchOK[0][iv] = matchOK[1][iv1] = 1;
1407 parOk.SetX(pMerge(0, 0));
1408 parOk.SetY(pMerge(1, 0));
1409 parOk.SetZ(par2.GetZ());
1410 parOk.SetTx(pMerge(2, 0));
1411 parOk.SetTy(pMerge(3, 0));
1412 parOk.SetCovMatrix(w2);
1418 for (Int_t ista = 0; ista <
fgkStat; ++ista) {
1419 Int_t nvec =
fVectors[ista].size();
1421 for (Int_t iv = nvec - 1; iv >= 0; --iv) {
1422 if (matchOK[ista][iv] > 0)
continue;
1427 cout <<
" Vectors after matching: " <<
fVectors[0].size() <<
" "
1435 Double_t uu[fgkPlanes][2]) {
1439 const Double_t thresh = 6.0;
1440 Double_t qualmin = 99.0, qual = 0.0;
1441 multimap<Int_t, multimap<Double_t, Int_t>>::iterator mit =
fFailed.begin(),
1443 Int_t patt = patt0, pattmin = patt0;
1445 for (; mit !=
fFailed.end(); ++mit) {
1446 multimap<Double_t, Int_t>& chi2s = mit->second;
1447 Double_t c2sum = 0.0, outl = 0.0;
1450 for (multimap<Double_t, Int_t>::reverse_iterator rit = chi2s.rbegin();
1451 rit != chi2s.rend();
1453 if (rit->first <= thresh)
break;
1455 c2sum += rit->first;
1456 patt &= ~(1 << rit->second);
1460 for (Int_t j = 0; j <
fgkPlanes; j += 2)
1461 if (patt & (3 << j))
1466 qual = outl + TMath::Min(c2sum, 999.) / 1000;
1467 if (qual < qualmin) {
1474 if (Int_t(qualmin) > 3)
return;
1476 Int_t nCombs = (patt & 1) ? 2 : 1, flag = 1, nok = nCombs - 1;
1478 for (Int_t icomb = -1; icomb < nCombs; icomb += 2) {
1479 fUz[0][0] = (nCombs == 2) ? uu[0][0] + uu[0][1] * icomb : 0.0;