9#include "CbmStsCluster.h"
10#include "CbmStsDigiMatch.h"
11#include "CbmStsDigiScheme.h"
13#include "CbmStsPoint.h"
14#include "CbmStsSector.h"
15#include "CbmStsStation.h"
16#include "CbmStsTrack.h"
17#include "FairRootManager.h"
18#include "FairRunAna.h"
19#include "TMVA/Tools.h"
21#include <TClonesArray.h>
37#include <TStopwatch.h>
41static Double_t workTime = 0.0;
45 : FairTask(
"STS Vector Finder")
58 , fMatBudgetFileName(
"")
65 for (
int j = 0; j < 4; ++j)
66 fClusArray[j] =
nullptr;
74 fVectorArray->Delete();
85 FairRootManager* ioman = FairRootManager::Instance();
87 cout <<
"-E- BmnStsVectorFinder::Init: "
88 <<
"RootManager not instantiated!" << endl;
93 fClusArray[0] = (TClonesArray*)ioman->GetObject(
"StsCluster");
98 fClusArray[0] = (TClonesArray*)ioman->GetObject(
"BmnSiliconUpperCluster");
99 fClusArray[1] = (TClonesArray*)ioman->GetObject(
"BmnSiliconLowerCluster");
100 fClusArray[2] = (TClonesArray*)ioman->GetObject(
"BmnGemUpperCluster");
101 fClusArray[3] = (TClonesArray*)ioman->GetObject(
"BmnGemLowerCluster");
102 for (
int j = 0; j < 4; ++j) {
104 if (!fClusArray[0] && !fClusArray[2]) {
105 cout <<
"-W- BmnStsVectorFinder::Init: "
106 <<
"No BmnCluster array!" << j << endl;
112 fHitArray = (TClonesArray*)ioman->GetObject(
"StsHit");
119 fTrackArray = (TClonesArray*)ioman->GetObject(
"StsTrack");
126 fDigiMatches = (TClonesArray*)ioman->GetObject(
"StsDigiMatch");
133 fStsPoints = (TClonesArray*)ioman->GetObject(
"StsPoint");
139 fSilPoints = (TClonesArray*)ioman->GetObject(
"SiliconPoint");
145 fVectorArray =
new TClonesArray(
"CbmStsTrack");
146 ioman->Register(
"StsVector",
"STS", fVectorArray, kTRUE);
150 fMap3OutPtr = &fMap3Out;
151 ioman->RegisterAny(
"Triplets", fMap3OutPtr, kTRUE);
153 if (fOut && fOut % 2 == 0) {
155 fMap2OutPtr = &fMap2Out;
156 ioman->RegisterAny(
"Doublets", fMap2OutPtr, kTRUE);
169 static Int_t nHitsMin[20] = {7, 5, 4, 4};
172 static Double_t dTanX[20] = {0.002, 0.003, 0.002, 0.008};
173 static Double_t dTanXTMVA[20] = {0.003, 0.0045, 0.003, 0.012};
174 static Double_t dTanXB0[20] = {0.001, 0.002, 0.002, 0.002};
176 static Double_t dTanY[20] = {0.01, 0.02, 0.02, 0.03};
177 static Double_t dTanYTMVA[20] = {0.015, 0.03, 0.03, 0.045};
178 static Double_t dTanYB0[20] = {0.01, 0.02, 0.02, 0.02};
179 static Double_t dTanY3[20] = {0.01, 0.02, 0.02, 0.03};
180 static Double_t dTanY3TMVA[20] = {0.015, 0.03, 0.03, 0.045};
181 static Double_t dTanY3B0[20] = {0.01, 0.02, 0.02, 0.02};
182 static Double_t dTanXzero[20] = {0.01, 0.02, 0.02, 0.02};
185 static Double_t ptCut[20] = {1.0, 0.3, 0.7, 0.1};
186 static Double_t ptCutB0[20] = {1., 1., 1., 1.};
188 static Double_t curvSta[20] = {
189 12.0, 12.0, 12.0, 7.5, 5.5,
190 4.5, 3.6, 3.0, 3.0, 3.0};
193 static Double_t phiXZ[20] = {0.76, 0.69, 0.69, 0.95, 0.74, 0.60, 0.51, 0.44, 0.39, 0.35};
197 static Double_t phiXZ4[20] = {0.60, 0.63, 0.61, 0.62, 0.95, 0.74,
198 0.60, 0.51, 0.44, 0.39, 0.35};
199 static Double_t tanXmax[20] = {0.95, 0.83, 0.83, 1.40, 0.91,
200 0.68, 0.56, 0.47, 0.41, 0.37};
203 static Double_t tanXmax4[20] = {0.68, 0.73, 0.69, 0.71, 1.40, 0.91,
204 0.68, 0.56, 0.47, 0.41, 0.37};
205 static Double_t zMean[20] = {18.5, 27.2, 35.8, 60.9, 91.7,
206 123.4, 154.0, 185.8, 216.5, 248.0};
210 static Double_t zMean4[20] = {17.6, 26.4, 35.1, 43.7, 63.6, 94.2,
211 126.5, 156.8, 189.0, 219.2, 251.4};
214 FairField* magField = FairRunAna::Instance()->GetField();
215 fBy = TMath::Abs(magField->GetBy(0.0, 0.0, 135.0)) / 10;
217 fNhitsMin = nHitsMin;
218 fdTanX = (fUseTMVA) ? dTanXTMVA : dTanX;
219 fdTanY = (fUseTMVA) ? dTanYTMVA : dTanY;
220 fdTanY3 = (fUseTMVA) ? dTanY3TMVA : dTanY3;
229 fdTanXB0 = dTanXzero;
230 fPhiXZ = (fNSi == 4) ? phiXZ4 : phiXZ;
231 fTanXmax = (fNSi == 4) ? tanXmax4 : tanXmax;
232 fZmean = (fNSi == 4) ? zMean4 : zMean;
236 for (
int j = 0; j < 20; ++j)
237 if (fPTcut[j] > 0.001)
238 fPTcut[j] = 1 / fPTcut[j];
248 for (Int_t j = 0; j < 20; ++j) {
257 for (
int j = 0; j < 20; ++j)
258 fCurvSta[j] *= (0.8 / fBy);
261 if (fMatBudgetFileName !=
"")
289 Fatal(
"Exec",
"No StsHit array");
291 fVectorArray->Delete();
295 for (Int_t j = 0; j < 19; ++j) {
298 fCandCodes[j].clear();
305 nTracks = fTrackArray->GetEntriesFast();
310 const Int_t nPass = 4;
312 for (Int_t j = 0; j < nPass; ++j)
313 fNskips[j] = nsta - fNhitsMin[j];
315 Int_t nHits0 = fHitArray->GetEntriesFast(), idmaxP = 0;
319 fClusMaps[0].clear();
320 fClusMaps[1].clear();
323 for (Int_t ihit = 0; ihit < nHits0; ++ihit) {
325 if (hit->GetZ() > 400.0)
327 Int_t iclusF = hit->
GetDigi(0);
328 Int_t iclusB = hit->
GetDigi(1);
329 fClusMaps[0].insert(pair<Int_t, Int_t>(iclusF, ihit));
330 fClusMaps[1].insert(pair<Int_t, Int_t>(iclusB, ihit));
332 fNsta = TMath::Max(fNsta, ista);
335 set<Int_t> idset = GetHitId(hit, idmaxP);
336 for (set<Int_t>::iterator sit = idset.begin(); sit != idset.end(); ++sit)
337 fHit2id.insert(pair<Int_t, Int_t>(ihit, *sit));
345 for (Int_t ipass = 0; ipass < nPass; ++ipass) {
350 Int_t minHits = (ipass == 0) ? 15 : -fNhitsMin[ipass - 1];
351 TClonesArray* trArray = (ipass == 0) ? fTrackArray : fVectorArray;
352 nHitsOut += ExcludeHits(minHits, trArray);
355 cout <<
"-I- BmnStsVectorFinder: start - " << nHits0 <<
", end - " << nHits0 - nHitsOut << endl;
358 Int_t ntr0 = fVectorArray->GetEntriesFast();
376 cout <<
"\n ***** Pass " << ipass <<
": Number of found tracks = " << fVectorArray->GetEntriesFast() - ntr0
377 <<
" " << fVectorArray->GetEntriesFast() <<
"\n"
383 cout <<
"discarded " << discarded <<
" track candidates" << endl;
389 workTime += sw.RealTime();
394Int_t BmnStsVectorFinder::ExcludeHits(Int_t minHits, TClonesArray* trArray)
401 nTracks = trArray->GetEntriesFast();
408 unordered_multimap<Int_t, Int_t>::iterator mit;
409 pair<unordered_multimap<Int_t, Int_t>::iterator, unordered_multimap<Int_t, Int_t>::iterator> ret;
411 for (Int_t itra = 0; itra < nTracks; ++itra) {
414 trArray->Remove(track);
420 for (Int_t ihit = 0; ihit < nHitsTr; ++ihit) {
427 if (fNhitsMin[fPass] < -5) {
430 Int_t iclusF = hit->
GetDigi(0);
431 ret = fClusMaps[0].equal_range(iclusF);
432 for (mit = ret.first; mit != ret.second; ++mit) {
434 if (hit1->GetUniqueID() == 0)
436 hit1->SetUniqueID(1);
438 fmapHits[mit->second].used = 1;
440 Int_t iclusB = hit->
GetDigi(1);
441 ret = fClusMaps[1].equal_range(iclusB);
442 for (mit = ret.first; mit != ret.second; ++mit) {
444 if (hit1->GetUniqueID() == 0)
446 hit1->SetUniqueID(1);
448 fmapHits[mit->second].used = 1;
451 if (hit->GetUniqueID() == 0)
455 fmapHits[indx].used = 1;
460 ret = fMap2[ista].equal_range(indx);
461 fMap2[ista].erase(ret.first, ret.second);
463 ret = fMap3[ista].equal_range(indx);
464 for (mit = ret.first; mit != ret.second; ++mit) {
465 candvec cand = fCandVec3[ista][mit->second];
466 string code = MakeCode(cand);
467 fMapCode3[ista].erase(code);
469 fMap3[ista].erase(ret.first, ret.second);
480set<Int_t> BmnStsVectorFinder::GetHitId(
CbmStsHit* hit, Int_t& idmaxP)
486 return GetHitIdBmn(hit, idmaxP);
491 Int_t iclusF = hit->
GetDigi(0);
492 Int_t iclusB = hit->
GetDigi(1);
496 map<Int_t, Double_t> indF, indB;
502 for (Int_t j = 0; j < nDigis; ++j) {
504 for (Int_t j1 = 0; j1 < 3; ++j1) {
510 indF[p->GetTrackID()] = mom3.Mag();
516 for (Int_t j = 0; j < nDigis; ++j) {
518 for (Int_t j1 = 0; j1 < 3; ++j1) {
524 indB[p->GetTrackID()] = 1.0;
530 for (map<Int_t, Double_t>::iterator mit = indF.begin(); mit != indF.end(); ++mit) {
531 Int_t
id = (indB.count(mit->first) == 0) ? -mit->first : mit->first;
533 if (
id >= 0 && mit->second > pmax) {
540 if (hit->GetRefIndex() >= 0) {
542 idmaxP = p->GetTrackID();
546 for (map<Int_t, Double_t>::iterator mit = indB.begin(); mit != indB.end(); ++mit) {
547 if (ids.count(mit->first) > 0)
549 ids.insert(-mit->first);
557set<Int_t> BmnStsVectorFinder::GetHitIdBmn(
CbmStsHit* hit, Int_t& idmaxP)
565 if (hit->GetRefIndex() == -1 || fStsPoints ==
nullptr || fSilPoints ==
nullptr)
569 FairMCPoint* p =
nullptr;
571 p = (FairMCPoint*)fStsPoints->UncheckedAt(hit->GetRefIndex());
573 p = (FairMCPoint*)fSilPoints->UncheckedAt(hit->GetRefIndex());
574 ids.insert(p->GetTrackID());
576 idmaxP = *ids.begin();
582void BmnStsVectorFinder::BuildTrackCand()
586 for (Int_t ist = 0; ist < fNsta; ++ist) {
587 fmapPhx[ist].clear();
591 fSeedVec[ist].clear();
592 fCandVec[ist].clear();
595 fCandVec2[ist].clear();
597 fCandVec3[ist].clear();
599 fMapCode3[ist].clear();
603 Int_t nHits = fHitArray->GetEntriesFast(), idmaxP = 0;
605 cout <<
"nHits " << nHits << endl;
608 for (Int_t ih = 0; ih < nHits; ++ih) {
610 if (hit->GetUniqueID())
612 if (hit->GetZ() > 400.0)
631 if (fExactSel >= 0) {
633 set<Int_t> ids = GetHitId(hit, idmaxP);
634 if (ids.count(fExactSel) == 0)
639 set<Int_t> ids = GetHitId(hit, idmaxP);
649 Double_t dx = hit->GetX() - fXyzv[0];
650 Double_t dy = hit->GetY() - fXyzv[1];
651 Double_t dz = hit->GetZ() - fXyzv[2];
652 Double_t by = (fBy < 0.2) ? 0.8 : fBy;
658 fmapHits[ih] = hitinfo(pos, TMath::ATan2(dx, dz) / fPhiXZ[ista] / fZmean[ista] / by,
659 dx / dz / fTanXmax[ista], dy / dz / fTanXmax[ista]);
660 fmapX[ista].insert(pair<Double_t, Int_t>(pos[0], ih));
661 fmapY[ista].insert(pair<Double_t, Int_t>(pos[1], ih));
662 fmapPhx[ista].insert(pair<Double_t, Int_t>(fmapHits[ih].phx, ih));
663 fmapTy[ista].insert(pair<Double_t, Int_t>(fmapHits[ih].ty, ih));
668 Int_t stastop = fNsta - 1 - fNskips[fPass];
672 cout <<
"fNskips fPass " << fNskips[fPass] <<
" " << fPass <<
" stastop " << stastop <<
" fNsta-1 " << fNsta - 1
675 for (Int_t ista = fNsta - 1; ista >= stastop; --ista) {
677 cout <<
"xmapsize " << fmapX[ista].size() << endl;
678 for (multimap<Double_t, Int_t>::iterator mit = fmapX[ista].begin(); mit != fmapX[ista].end(); ++mit) {
683 aaa.stahit[ista] = mit->second;
684 aaa.code =
"-" +
to_string(aaa.stahit[ista]) +
"-";
687 set<Int_t> ids = GetHitId(mit->second, idmaxP);
691 fSeedVec[ista].push_back(aaa);
694 Int_t ncand = fSeedVec[ista].size();
695 cout <<
" Vector stat: " << ista <<
" " << ncand;
697 pair<unordered_multimap<Int_t, Int_t>::iterator, unordered_multimap<Int_t, Int_t>::iterator>
700 for (Int_t j = 0; j < ncand; ++j) {
701 Int_t ih = fSeedVec[ista][j].stahit[ista];
702 ret = fHit2id.equal_range(ih);
703 cout <<
" (" << ih <<
"*";
705 for (unordered_multimap<Int_t, Int_t>::iterator mit = ret.first; mit != ret.second; ++mit)
707 if (mit != ret.first)
723void BmnStsVectorFinder::BuildDoublets()
729 for (Int_t ist = 0; ist < fNsta; ++ist) {
730 fCandVec[ist].clear();
731 fCandVec2[ist].clear();
733 fCandVec3[ist].clear();
735 fMapCode3[ist].clear();
751 for (Int_t ista = 0; ista < fNsta - 1; ++ista) {
752 Int_t nTra = fSeedVec[ista].size();
757 for (
int istanext = ista + 1; istanext < ista + 3; ++istanext) {
759 if (istanext > fNsta - 1)
761 if (fSeedVec[istanext].size() == 0)
763 Double_t dty = fdTanY[fPass], dphx = fdTanX[fPass];
766 int nskips = istanext - (ista + 1);
768 for (Int_t itra = 0; itra < nTra; ++itra) {
769 candvec& aaa = fSeedVec[ista][itra];
770 Int_t ih = aaa.stahit[ista];
771 if (fmapHits[ih].used)
774 Double_t phx = fmapHits[ih].phx;
775 phx *= (fPhiXZ[ista] * fZmean[ista]);
776 phx /= (fPhiXZ[istanext] * fZmean[istanext]);
777 Double_t ty = fmapHits[ih].ty;
778 ty *= (fTanXmax[ista] / fTanXmax[istanext]);
781 Double_t tx = fmapHits[ih].tx;
782 tx *= (fTanXmax[ista] / fTanXmax[istanext]);
783 multimap<Double_t, candvec> mapDoublets;
786 multimap<Double_t, Int_t>::iterator mityb = fmapTy[istanext].lower_bound(ty - dty);
787 multimap<Double_t, Int_t>::iterator mitye = fmapTy[istanext].upper_bound(ty + dty);
788 multimap<Double_t, Int_t>::iterator mitxb = fmapPhx[istanext].lower_bound(phx - dphx);
789 multimap<Double_t, Int_t>::iterator mitxe = fmapPhx[istanext].upper_bound(phx + dphx);
791 set<Int_t> setTx, setTy, intersect;
792 for (multimap<Double_t, Int_t>::iterator mit = mitxb; mit != mitxe; ++mit)
793 if (fmapHits[mit->second].used == 0)
794 setTx.insert(mit->second);
795 for (multimap<Double_t, Int_t>::iterator mit = mityb; mit != mitye; ++mit)
796 if (fmapHits[mit->second].used == 0)
797 setTy.insert(mit->second);
798 set_intersection(setTx.begin(), setTx.end(), setTy.begin(), setTy.end(),
799 std::inserter(intersect, intersect.begin()));
802 Double_t xp = fmapHits[ih].xyz[0];
803 Double_t zp = fmapHits[ih].xyz[2];
806 for (set<Int_t>::iterator sit = intersect.begin(); sit != intersect.end(); ++sit) {
808 if (hit->GetUniqueID())
810 if (fmapHits[*sit].used)
812 if (fBy < 0.2 && TMath::Abs(tx - fmapHits[*sit].tx) > fdTanXB0[fPass])
816 set<Int_t> ids = GetHitId(*sit, idmaxP);
818 if (idmaxP != aaa.idmaxP)
823 aaa1.stahit[istanext] = *sit;
825 Double_t dx = xp - fmapHits[*sit].xyz[0];
826 Double_t dz = zp - fmapHits[*sit].xyz[2];
827 aaa1.lengxz = TMath::Sqrt(dx * dx + dz * dz);
832 Curv3(aaa1, aaa1, aaa1, 0);
834 && (TMath::Abs(aaa1.momxz) > fPTcut[fPass] || TMath::Abs(aaa1.momxz) > fCurvSta[ista]))
836 else if (fBy < 0.2 && TMath::Abs(aaa1.momxz) / fZmean[1] * fZmean[istanext] > fPTcut[fPass])
839 aaa1.ty = ty - fmapHits[*sit].ty;
840 aaa1.tx = tx - fmapHits[*sit].tx;
844 if (fOut && fOut % 2 == 0) {
846 if (fMap2Out.find(code) == fMap2Out.end())
847 fMap2Out[
code] = fPass;
851 Double_t tmvaOut = 9.9;
853 tmvaOut = TMVAOutput2(aaa1);
858 aaa1.nskips = nskips;
860 mapDoublets.insert(pair<Double_t, candvec>(-tmvaOut, aaa1));
864 int n2tot = 0, n2max = (fUseTMVA == 2) ? fNbranches * 2 : 999;
866 for (
auto ait = mapDoublets.begin(); ait != mapDoublets.end(); ++ait) {
867 fCandVec2[ista].push_back(ait->second);
868 fMap2[ista].insert(pair<int, int>(ih, fCandVec2[ista].size() - 1));
878 Int_t ncand = fCandVec2[ista].size();
880 cout <<
" Doublet stat: " << ista <<
" " << ncand << endl;
886Bool_t BmnStsVectorFinder::CheckVarx(Double_t dx, Double_t dz, Double_t tx, Double_t distxz, Double_t& varx)
890 varx = (dx / dz - tx) / distxz;
897void BmnStsVectorFinder::BuildTriplets()
905 pair<unordered_multimap<Int_t, int>::iterator, unordered_multimap<Int_t, int>::iterator> ret;
906 unordered_multimap<Int_t, int>::iterator mit, mit1;
907 Double_t pxzCut = (fUseTMVA) ? 0.3 : 0.2;
910 for (Int_t ista = 0; ista < fNsta - 2; ++ista) {
912 Int_t nTra = fCandVec2[ista].size();
918 for (mit = fMap2[ista].begin(); mit != fMap2[ista].end(); ++mit) {
919 candvec& aaa = fCandVec2[ista][mit->second];
920 Int_t istanext = ista + 1 + aaa.nskips;
921 if (fCandVec2[istanext].size() == 0)
925 Double_t tany = aaa.ty;
926 Double_t tanx = aaa.tx;
928 ret = fMap2[istanext].equal_range(aaa.stahit.rbegin()->second);
929 multimap<Double_t, candvec> mapDoublets;
930 int nbr = 0, newtr = 0, newtr3 = 0;
931 Double_t c2max = 999.0;
933 for (mit1 = ret.first; mit1 != ret.second; ++mit1) {
939 candvec& aaa2 = fCandVec2[istanext][mit1->second];
942 if (aaa.idmaxP != aaa2.idmaxP)
951 if (TMath::Abs(tany - aaa2.ty) > fdTanY3[fPass])
953 if (fBy < 0.2 && TMath::Abs(tanx - aaa2.tx) > fdTanXB0[fPass])
958 +
"-" +
to_string(aaa2.stahit.rbegin()->second);
959 if (fMap3Out.find(code) == fMap3Out.end())
960 fMap3Out[
code] = fPass;
964 && TMath::Abs(aaa.momxz - aaa2.momxz)
965 / (TMath::Abs(aaa.momxz) + TMath::Abs(aaa2.momxz))
967 * TMath::Sqrt(aaa.lengxz + aaa2.lengxz) / 10
973 aaa1.stahit[aaa2.stahit.rbegin()->first] = aaa2.stahit.rbegin()->second;
975 Double_t tmvaOut = 9.9;
977 tmvaOut = TMVAOutput3(aaa1, aaa2);
982 map<Int_t, Int_t>& hitMap = aaa1.stahit;
991 for (map<Int_t, Int_t>::iterator mit2 = hitMap.begin(); mit2 != hitMap.end(); ++mit2) {
992 hits[indx++] = mit2->second;
993 hit = (
CbmStsHit*)fHitArray->UncheckedAt(mit2->second);
996 hit->SetDx(0.08 / TMath::Sqrt(12.0) * 1.2);
1002 hit->SetDx(0.02 / TMath::Sqrt(12.0));
1015 Double_t ty = aaa.ty;
1017 float chi2 = LinearFit(aaa, aaa2, &track, newtr, ty) / hit->GetDy() / hit->GetDy();
1033 aaa1.momxz = Curv3(aaa, aaa2, aaa1, newtr3);
1038 if (TMath::Abs(aaa1.momxz) > fPTcut[fPass]) {
1056 if (-tmvaOut > c2max && nbr >= fNbranches)
1058 }
else if (chi2 > c2max && nbr >= fNbranches)
1061 Double_t qual = (fUseTMVA) ? -tmvaOut : chi2;
1062 aaa1.nskips = aaa.nskips + aaa2.nskips;
1064 mapDoublets.insert(pair<Double_t, candvec>(qual, aaa1));
1066 nbr = mapDoublets.size();
1068 if (nbr > fNbranches) {
1069 multimap<Double_t, candvec>::iterator mit0 = mapDoublets.end();
1071 mapDoublets.erase(mit0);
1073 c2max = mapDoublets.rbegin()->first;
1078 for (multimap<Double_t, candvec>::iterator it = mapDoublets.begin(); it != mapDoublets.end(); ++it) {
1079 if (nok >= fNbranches)
1082 fCandVec3[ista].push_back(it->second);
1083 fMap3[ista].insert(pair<Int_t, int>(mit->first, fCandVec3[ista].size() - 1));
1084 map<Int_t, Int_t>& hitMap = it->second.stahit;
1086 for (map<Int_t, Int_t>::iterator mitr = hitMap.begin(); mitr != hitMap.end(); ++mitr)
1087 code += (
to_string(mitr->second) +
"-");
1088 fMapCode3[ista][
code] = fCandVec3[ista].size() - 1;
1093 Int_t ncand = fCandVec3[ista].size();
1095 cout <<
" Triplet stat: " << ista <<
" " << ncand <<
" " << discarded << endl;
1101void BmnStsVectorFinder::BuildTracks()
1105 int istaEnd = fNsta - fNhitsMin[fPass] + 1;
1106 istaEnd = TMath::Min(istaEnd, fNsta - 3);
1112 for (Int_t ista = 0; ista < istaEnd; ++ista) {
1116 std::unordered_multimap<Int_t, int>* candMap = &fMap3[ista];
1117 vector<candvec>* candVec = &fCandVec3[ista];
1118 Int_t nTra = candMap->size();
1125 for (unordered_multimap<Int_t, int>::iterator mit = candMap->begin(); mit != candMap->end(); ++mit) {
1126 candvec& cand = (*candVec)[mit->second];
1127 if (fPass == 0 && cand.nskips > 0)
1129 map<int, int>::iterator it = cand.stahit.begin();
1130 int ista0 = it->first;
1132 int ista1 = it->first;
1133 if (ista1 - ista0 > 1)
1142void BmnStsVectorFinder::ExtendTrack(candvec cand)
1146 const Double_t c2ndfMax = 30.0;
1147 Double_t pxzCut = 0.3;
1150 Int_t nTra = 0, ista = cand.stahit.rbegin()->first;
1154 if (ista == fNsta-2) {
1155 cand.stahit.erase(cand.stahit.rbegin()->first);
1156 ista = cand.stahit.rbegin()->first;
1165 std::unordered_multimap<Int_t, int>* pCandMap =
1166 (ista == fNsta - 2) ? &fMap2[ista] : &fMap2[ista];
1167 vector<candvec>* pCandVec = (ista == fNsta - 2) ? &fCandVec2[ista] : &fCandVec2[ista];
1169 unordered_multimap<Int_t, int>& candMap = *pCandMap;
1170 vector<candvec>& candVec = *pCandVec;
1172 if (ista < fNsta - 1) {
1180 nTra = candMap.count(cand.stahit.rbegin()->second);
1186 if ((Int_t)cand.stahit.size() < fNhitsMin[fPass])
1191 for (map<int, int>::iterator it = cand.stahit.begin(); it != cand.stahit.end(); ++it)
1194 if (fCandCodes[cand.stahit.size()].find(code) == fCandCodes[cand.stahit.size()].end()) {
1195 fCandCodes[cand.stahit.size()].insert(code);
1200 if ((Int_t)cand.stahit.size() >= fNhitsMin[fPass] && cand.stahit.rbegin()->first != ista
1201 && FitTrack(cand) > c2ndfMax)
1204 fCandVec[cand.stahit.begin()->first].push_back(cand);
1211 unordered_multimap<Int_t, int>::iterator mit;
1212 pair<unordered_multimap<Int_t, int>::iterator, unordered_multimap<Int_t, int>::iterator> ret;
1213 ret = candMap.equal_range(cand.stahit.rbegin()->second);
1224 for (mit = ret.first; mit != ret.second; ++mit) {
1226 candvec aaa = candVec[mit->second];
1227 if (fExact && aaa.idmaxP != cand.idmaxP)
1229 if (fPass == 0 && aaa.nskips > 0)
1236 map<Int_t, Int_t>::iterator mitr = aaa.stahit.begin();
1238 if (
code.size() == 1) {
1239 map<Int_t, Int_t>::reverse_iterator mit1 = cand.stahit.rbegin();
1241 istaMid = mit1->first;
1248 int pos =
code.rfind(
"-",
code.size() - 2);
1255 if (fMapCode3[istaMid].find(code) == fMapCode3[istaMid].end())
1259 candvec* bbb =
nullptr;
1261 bbb = &fCandVec3[istaMid][fMapCode3[istaMid][
code]];
1267 if ((fPass == 0 && bbb->nskips > 0) || (cand.nskips + bbb->nskips > 2))
1269 if (ok && cand.stahit.size() > 2) {
1270 Double_t dp = TMath::Abs(cand.momxz - bbb->momxz);
1274 if (TMath::Abs(fBy) > 0.2 && dp / (TMath::Abs(cand.momxz) + TMath::Abs(bbb->momxz)) > pxzCut)
1282 if ((fPass == 0 && aaa.nskips > 0) || (cand.nskips + aaa.nskips > 2))
1284 if (aaa.stahit.size() == 3) {
1287 Double_t dp = TMath::Abs(cand.momxz - aaa.momxz);
1291 if (TMath::Abs(fBy) > 0.2 && dp / (TMath::Abs(cand.momxz) + TMath::Abs(aaa.momxz)) > pxzCut)
1301 if ((Int_t)cand.stahit.size() < fNhitsMin[fPass])
1304 string codeVec(
"-");
1305 for (map<int, int>::iterator it = cand.stahit.begin(); it != cand.stahit.end(); ++it)
1306 codeVec += (
to_string(it->second) +
"-");
1307 if (fCandCodes[cand.stahit.size()].find(codeVec) == fCandCodes[cand.stahit.size()].end()) {
1308 fCandCodes[cand.stahit.size()].insert(codeVec);
1309 if (cand.stahit.size() >= 4) {
1311 if (cand.stahit.rbegin()->first == ista)
1313 Double_t chi2 = FitTrack(cand);
1315 if (chi2 > c2ndfMax)
1319 fCandVec[cand.stahit.begin()->first].push_back(cand);
1325 candvec candext = cand;
1326 if (cand.stahit.size() < 3)
1327 candext.momxz = bbb->momxz;
1330 for (mitr = aaa.stahit.begin(); mitr != aaa.stahit.end(); ++mitr)
1331 candext.stahit[mitr->first] = mitr->second;
1332 candext.nskips += aaa.nskips;
1336 if (aaa.idmaxP != cand.idmaxP)
1337 candext.idmaxP = -1;
1339 if (candext.stahit.size() >= 4) {
1340 Double_t chi2ndf = FitTrack(candext);
1342 if (chi2ndf > c2ndfMax)
1352 ExtendTrack(candext);
1358Double_t BmnStsVectorFinder::FitTrack(candvec& cand)
1362 const Int_t gkChi2Cut = 5.0;
1368 MakeStsTrack(cand, hitcode, track);
1370 if (fCandSet[nhits].find(hitcode) != fCandSet[nhits].end())
1375 fitter.
DoFit(&track);
1377 FilterHit(cand, track);
1389 int ndf = TMath::Max(track.
GetNDF(), 1);
1390 Double_t chi2ndf = track.
GetChi2() / ndf;
1393 if (chi2ndf < gkChi2Cut && nhits >= fNhitsMin[fPass]) {
1397 if (track.
GetChi2() / ndf > gkChi2Cut) {
1403 Double_t qual = nhits;
1404 qual += (100.0 - TMath::Min(TMath::Abs(track.
GetChi2()), 100.0)) / 101.0;
1405 fTracks.insert(pair<Double_t, CbmStsTrack>(-qual, track));
1406 fCandSet[nhits].insert(hitcode);
1415Double_t BmnStsVectorFinder::FilterHit(candvec& cand,
CbmStsTrack& track)
1427 Int_t nhits = cand.stahit.size();
1438 Bool_t downstream = kTRUE;
1451 Bool_t err = kFALSE;
1454 h = kftr.
GetHit(nhits - 1);
1455 err = err || h->
Filter(kftr, downstream, qp0);
1460 track.
SetNDF(2 * nhits - 5);
1485void BmnStsVectorFinder::MakeStsTrack(candvec& cand,
string& hitcode,
CbmStsTrack& track)
1489 map<Int_t, Int_t>& hitMap = cand.stahit;
1492 hits.Set(hitMap.size());
1497 for (map<Int_t, Int_t>::iterator mit2 = hitMap.begin(); mit2 != hitMap.end(); ++mit2) {
1498 hits[indx++] = mit2->second;
1499 hit = (
CbmStsHit*)fHitArray->UncheckedAt(mit2->second);
1501 hit->SetDx(0.08 / TMath::Sqrt(12.0));
1507 hit->SetDx(0.02 / TMath::Sqrt(12.0));
1517 hit->SetDx(dx / TMath::Sqrt(12.0));
1520 hitcode += (
to_string(mit2->second) +
"-");
1525 cand.code = hitcode;
1530void BmnStsVectorFinder::ExtendTracks(Int_t ista)
1558 printf(
"Work time of BmnStsVectorFinder: %4.2f sec.\n", workTime);
1563TVector3 BmnStsVectorFinder::Parabola(TVector3& pos0, TVector3& pos1, TVector3& pos2)
1568 Double_t x[3] = {pos0[2] - fXyzv[2], pos1[2] - fXyzv[2], pos2[2] - fXyzv[2]};
1569 Double_t y[3] = {pos0[0] - fXyzv[0], pos1[0] - fXyzv[0], pos2[0] - fXyzv[0]};
1571 Double_t denom = (x[0] - x[1]) * (x[0] - x[2]) * (x[1] - x[2]);
1572 Double_t dy10 = y[1] - y[0];
1573 Double_t dy02 = y[0] - y[2];
1574 Double_t dy21 = y[2] - y[1];
1576 Double_t a = x[2] * dy10 + x[1] * dy02 + x[0] * dy21;
1580 Double_t b = -x[0] * x[0] * dy21 - x[2] * x[2] * dy10 - x[1] * x[1] * dy02;
1582 Double_t c = x[1] * x[1] * (x[2] * y[0] - x[0] * y[2]) + x[1] * (x[0] * x[0] * y[2] - x[2] * x[2] * y[0])
1583 + x[0] * x[2] * (x[2] - x[0]) * y[1];
1585 return TVector3(c, b, a);
1593void BmnStsVectorFinder::FitTracks()
1597 const Double_t gkChi2Cut = 5.0;
1602 for (Int_t ista = 0; ista < fNsta; ++ista) {
1603 Int_t ntra = fCandVec[ista].size();
1606 for (Int_t itra = 0; itra < ntra; ++itra) {
1607 candvec& cand = fCandVec[ista][itra];
1610 map<Int_t, Int_t>& hitMap = cand.stahit;
1611 Int_t nhits = hitMap.size();
1613 if (nhits < fNhitsMin[fPass])
1618 Int_t indx = 0, iok = 1;
1621 string hitcode(
"-");
1622 for (map<Int_t, Int_t>::iterator mit = hitMap.begin(); mit != hitMap.end(); ++mit)
1623 hitcode += (
to_string(mit->second) +
"-");
1634 fCandSet[nhits].insert(hitcode);
1636 for (map<Int_t, Int_t>::iterator mit = hitMap.begin(); mit != hitMap.end(); ++mit) {
1637 hits[indx++] = mit->second;
1660 hit->SetDx(dx / TMath::Sqrt(12.0));
1688 cout <<
" aaaaaaa " << endl;
1690 cout << track.
GetChi2() <<
" " << nhits <<
" " << endl;
1747 for (Int_t
i = 0;
i < nhits;
i++)
1749 int imax = nhits - 1;
1751 if (indok.size() > 3) {
1758 for (set<Int_t>::iterator sit = indok.begin(); sit != indok.end(); ++sit) {
1759 hits[indx++] = hits[*sit];
1761 hitcode += (
to_string(hits[*sit]) +
"-");
1766 if (fCandSet[indok.size()].find(hitcode) != fCandSet[indok.size()].end())
1768 fCandSet[indok.size()].insert(hitcode);
1770 hits.Set(indok.size());
1777 cout <<
" bbbbbb " << track.
GetChi2() <<
" " << hits.GetSize() <<
" " << track.
GetChi2() / ndf
1813 xextr = param.GetX() - fXyzv[0];
1814 yextr = param.GetY() - fXyzv[1];
1816 TMath::Sqrt(xextr * xextr / 0.035 / 0.035 + yextr * yextr / 0.2 / 0.2);
1817 Double_t www = TMath::Min(TMath::Exp(-rad), 0.999);
1818 qual += TMath::Exp(-TMath::Abs(track.
GetChi2())) * www;
1820 qual += (100.0 - TMath::Min(TMath::Abs(track.
GetChi2()), 100.0)) / 101.0;
1821 fTracks.insert(pair<Double_t, CbmStsTrack>(-qual, track));
1823 pair<unordered_multimap<Int_t, Int_t>::iterator, unordered_multimap<Int_t, Int_t>::iterator>
1825 nhits = hits.GetSize();
1827 cout <<
" Good track: " << endl;
1831 for (Int_t j = nhits - 1; j >= 0; --j) {
1832 ret = fHit2id.equal_range(hits[j]);
1835 for (unordered_multimap<Int_t, Int_t>::iterator mit = ret.first; mit != ret.second; ++mit) {
1836 if (mit == ret.first)
1837 cout << mit->first <<
"*";
1840 cout << mit->second;
1854void BmnStsVectorFinder::RemoveDoubles()
1858 multimap<Double_t, CbmStsTrack>::iterator mit = fTracks.begin(), mit1;
1859 Int_t nOK = fTracks.size(), nOut = fVectorArray->GetEntriesFast();
1861 for (; mit != fTracks.end(); ++mit) {
1862 if (mit->second.GetFlag())
1867 for (; mit1 != fTracks.end(); ++mit1) {
1868 if (mit1->second.GetFlag())
1870 if (!AreTracksDoubles(mit1->second, mit->second))
1872 mit1->second.SetFlag(1);
1894 new ((*fVectorArray)[nOut++])
CbmStsTrack(mit->second);
1898 cout <<
" RemoveDoubles: " << fTracks.size() <<
" " << nOK << endl;
1908 Int_t limCommonPoint = (tr1.
GetNStsHits() + 1) / 2;
1910 limCommonPoint = TMath::Min(limCommonPoint, 1);
1912 Int_t nh1 = hits1.GetSize(), nh2 = hits2.GetSize(), nHitsCommon = 0, j = nh2 - 1;
1916 for (Int_t
i = nh1 - 1;
i >= 0;
i--) {
1920 for (; j >= 0; j--) {
1928 if (nHitsCommon > limCommonPoint)
1939 if (
i + nHitsCommon <= limCommonPoint)
1944 if (nHitsCommon <= limCommonPoint)
1974void BmnStsVectorFinder::RemoveFakes()
1978 multimap<Double_t, CbmStsTrack>::iterator mit = fTracks.begin();
1979 Int_t nOK = fTracks.size(), nOut = nOK;
1981 for (; mit != fTracks.end(); ++mit) {
1982 if (mit->second.GetFlag())
2001 cout <<
" Remove fakes: " << nOK <<
" " << nOut << endl;
2006void BmnStsVectorFinder::ExcludeFakes()
2010 Int_t ncand = fVectorArray->GetEntriesFast();
2012 map<Int_t, set<Int_t>> mClusTr;
2013 map<Int_t, Double_t> mWeight;
2015 for (Int_t j = 0; j < ncand; ++j) {
2019 for (Int_t jh = 0; jh < nhits; ++jh) {
2023 for (Int_t side = 0; side < 2; ++side) {
2024 Int_t iclus = hit->
GetDigi(side);
2025 if (mClusTr.count(iclus) == 0) {
2027 mClusTr[iclus] = aaa;
2029 mClusTr[iclus].insert(j);
2038 Double_t xextr = param.GetX() - fXyzv[0];
2039 Double_t yextr = param.GetY() - fXyzv[1];
2041 TMath::Sqrt(xextr * xextr / 0.035 / 0.035 + yextr * yextr / 0.2 / 0.2);
2042 www *= TMath::Exp(-rad);
2048 multimap<Double_t, pair<Int_t, Int_t>> mapQual;
2049 set<Int_t> set2kill, set2kill1;
2051 for (Int_t j = 0; j < ncand; ++j) {
2058 for (Int_t jh = 0; jh < nhits; ++jh) {
2063 for (Int_t side = 0; side < 2; ++side) {
2064 Int_t iclus = hit->
GetDigi(side);
2065 if (mClusTr[iclus].size() > 1)
2071 Double_t quality = nhits * 1000;
2072 Double_t www = TMath::Exp(-Double_t(nover) / nhits / 2) * mWeight[j];
2073 mapQual.insert(pair<Double_t, pair<Int_t, Int_t>>(quality + www, pair<Int_t, Int_t>(j, nover)));
2077 if (nhits <= 5 && Double_t(nover) / nhits / 2 > 0.6)
2079 else if (!fExact && nhits <= 3 && www < 1.e-8)
2080 set2kill1.insert(j);
2083 if (set2kill.size())
2085 if (set2kill.size() || set2kill1.size()) {
2088 for (multimap<Double_t, pair<Int_t, Int_t>>::iterator mit = mapQual.begin(); mit != mapQual.end(); ++mit) {
2089 Int_t itr = mit->second.first;
2092 if (set2kill.count(itr) == 0 && set2kill1.count(itr) == 0)
2095 for (Int_t jh = 0; jh < nhits; ++jh) {
2098 if (mClusTr[hit->
GetDigi(0)].count(itr) == 0 || mClusTr[hit->
GetDigi(1)].count(itr) == 0)
2102 cout <<
" !!! No track found: " << itr << endl;
2104 mClusTr[hit->
GetDigi(0)].erase(itr);
2105 mClusTr[hit->
GetDigi(1)].erase(itr);
2107 fVectorArray->Remove(tr);
2114 fVectorArray->Compress();
2117 cout <<
" Exclude fakes: " << ncand <<
" " << fVectorArray->GetEntriesFast() << endl;
2264Double_t BmnStsVectorFinder::DxVsMom(Int_t ista, candvec& vec)
2268 Double_t pars[19][4] = {{0, 0, 0, 0},
2270 {8.28698e-06, 13.3515, 0, 0},
2271 {0.031189, 4.56933, 0.031189, 4.56933},
2272 {0.395468, 3.77954, 0.190848, 3.41027},
2273 {0.128467, 4.26652, 0.128467, 4.26652},
2274 {0.160979, 4.95095, 0.160979, 4.95095}};
2276 Double_t pxz = vec.momxz;
2277 Int_t endsta = vec.stahit.rbegin()->first;
2278 Double_t p0 = pars[ista][0];
2279 Double_t p1 = pars[ista][1];
2280 if (endsta > ista + 2) {
2285 Double_t dx = p0 / TMath::Power(TMath::Log10(10 * pxz), p1);
2291Double_t BmnStsVectorFinder::Proxim(Double_t phi0, Double_t phi)
2295 Double_t dPhi = phi0 - phi;
2296 if (TMath::Abs(dPhi) > TMath::Pi())
2297 phi += TMath::Pi() * 2 * TMath::Sign(1., dPhi);
2303Double_t BmnStsVectorFinder::LinearFit(candvec& cand,
2312 static Double_t y[3], l[3] = {0}, lens[3] = {0}, ys[3], lys[3], l2s[3];
2315 Int_t i0 = (newtr == 0) ? 0 : 2;
2317 for (Int_t
i = i0;
i < 3; ++
i) {
2328 l[
i] = lens[
i] = cand.lengxz;
2330 l[
i] = lens[
i] = cand2.lengxz + l[
i - 1];
2332 y[
i] = ys[
i] = hit->GetY();
2336 for (Int_t
i = i0;
i < 3; ++
i) {
2337 lys[
i] = l[
i] * y[
i];
2338 l2s[
i] = l[
i] * l[
i];
2340 lens[
i] += lens[
i - 1];
2342 lys[
i] += lys[
i - 1];
2343 l2s[
i] += l2s[
i - 1];
2346 Double_t b = 3 * lys[2] - lens[2] * ys[2];
2347 b /= (3 * l2s[2] - lens[2] * lens[2]);
2348 Double_t a = (ys[2] - b * lens[2]) / 3;
2350 Double_t chi2 = 0.0;
2352 for (
int i = 0;
i < 3; ++
i) {
2353 Double_t dy = a + b * l[
i] - y[
i];
2366Double_t BmnStsVectorFinder::Curv3(candvec& cand1, candvec& cand2, candvec& cand3,
int newtr)
2370 static TVector3 points3[3], midPoint;
2372 static Double_t by = 0.0;
2373 static int first = 99;
2379 points3[0].SetXYZ(fXyzv[0], fXyzv[1], fXyzv[2]);
2382 map<int, int>::iterator mit = cand3.stahit.begin();
2385 points3[0] = fmapHits[mit->second].xyz;
2386 points3[0].SetY(0.0);
2389 if (cand3.stahit.size() > 2)
2392 for (; mit != cand3.stahit.end(); ++mit) {
2394 points3[indx] = fmapHits[mit->second].xyz;
2396 midPoint = points3[indx];
2397 points3[indx] -= points3[0];
2398 points3[indx++].SetY(0.0);
2401 TVector3 vec21 = points3[2] - points3[1];
2404 Double_t cosAlpha = points3[1] * vec21 / points3[1].Mag() / cand2.lengxz;
2406 Double_t rad = points3[2].Mag() / 2. / TMath::Sin(TMath::ACos(cosAlpha));
2410 Double_t sign = TMath::Sign(3e-4, points3[1].Cross(points3[2]).Y());
2412 FairField* magField = FairRunAna::Instance()->GetField();
2413 by = magField->GetBy(midPoint[0], midPoint[1], midPoint[2]);
2414 if (TMath::Abs(by) < 0.1)
2417 Double_t pxz = by * rad * sign;
2424set<int> BmnStsVectorFinder::KalmanWindow(candvec& cand,
int hitIndx)
2430 MakeStsTrack(cand, hitcode, track);
2431 fitter.
DoFit(&track);
2432 FairTrackParam param;
2434 Double_t z = hit->GetZ();
2436 Double_t sigx = 5 * TMath::Sqrt(param.GetCovariance(0, 0));
2437 Double_t sigy = 5 * TMath::Sqrt(param.GetCovariance(1, 1));
2439 cout <<
" Kalman: " << z <<
" " << hit->
GetStationNr() <<
" " << sigx <<
" " << sigy << endl;
2443 multimap<Double_t, Int_t>::iterator mityb = fmapY[istanext].lower_bound(param.GetY() - sigy);
2444 multimap<Double_t, Int_t>::iterator mitye = fmapY[istanext].upper_bound(param.GetY() + sigy);
2445 multimap<Double_t, Int_t>::iterator mitxb = fmapX[istanext].lower_bound(param.GetX() - sigx);
2446 multimap<Double_t, Int_t>::iterator mitxe = fmapX[istanext].upper_bound(param.GetX() + sigx);
2448 set<Int_t> setX, setY, intersect;
2449 for (multimap<Double_t, Int_t>::iterator mit = mitxb; mit != mitxe; ++mit)
2450 if (fmapHits[mit->second].used == 0)
2451 setX.insert(mit->second);
2452 for (multimap<Double_t, Int_t>::iterator mit = mityb; mit != mitye; ++mit)
2453 if (fmapHits[mit->second].used == 0)
2454 setY.insert(mit->second);
2455 set_intersection(setX.begin(), setX.end(), setY.begin(), setY.end(), std::inserter(intersect, intersect.begin()));
2461std::string BmnStsVectorFinder::MakeCode(candvec& cand)
2466 for (map<int, int>::iterator it = cand.stahit.begin(); it != cand.stahit.end(); ++it)
2473void BmnStsVectorFinder::PrintHits(candvec& cand)
2477 for (map<int, int>::iterator mit = cand.stahit.begin(); mit != cand.stahit.end(); ++mit) {
2479 cout << mit->first <<
"(" << hit->GetZ() <<
"):" << mit->second <<
" - ";
2486void BmnStsVectorFinder::InitTMVA3()
2494 std::map<std::string, int> Use;
2501 TMVA::Reader* reader =
new TMVA::Reader(
"!Color:!Silent");
2502 fReaderTMVA3 = reader;
2508 Float_t* var = fVarTMVA;
2510 reader->AddVariable(
"xb", &var[iii++]);
2511 reader->AddVariable(
"yb", &var[iii++]);
2512 reader->AddVariable(
"zb", &var[iii++]);
2513 reader->AddVariable(
"tx", &var[iii++]);
2514 reader->AddVariable(
"ty", &var[iii++]);
2520 reader->AddVariable(
"dtanysc1-dtanysc2", &var[iii++]);
2521 reader->AddVariable(
"lenxz1", &var[iii++]);
2522 reader->AddVariable(
"lenxz2", &var[iii++]);
2523 reader->AddVariable(
"1/pxz1", &var[iii++]);
2524 reader->AddVariable(
"(1/pxz1-1/pxz2)/(abs(1/pxz1)+abs(1/pxz2))*sqrt(lenxz1+lenxz2)", &var[iii++]);
2525 reader->AddVariable(
"pass", &var[iii++]);
2530 TString dir =
"dataset4diff/weights/";
2531 TString prefix =
"TMVAClassification";
2534 for (std::map<std::string, int>::iterator it = Use.begin(); it != Use.end(); it++) {
2536 TString methodName = TString(it->first) + TString(
" method");
2537 TString weightfile = dir + prefix + TString(
"_") + TString(it->first) + TString(
".weights.xml");
2538 reader->BookMVA(methodName, weightfile);
2545Float_t BmnStsVectorFinder::TMVAOutput3(candvec& aaa1, candvec& aaa2)
2549 Float_t* var = fVarTMVA ;
2550 map<Int_t, Int_t>& hitMap = aaa1.stahit;
2552 int iii = 0, indx = 0;
2555 for (map<Int_t, Int_t>::iterator mit = hitMap.begin(); mit != hitMap.end(); ++mit) {
2556 hit = (
CbmStsHit*)fHitArray->UncheckedAt(mit->second);
2558 var[iii++] = hit->GetX();
2559 var[iii++] = hit->GetY();
2560 var[iii++] = hit->GetZ();
2561 }
else if (indx == 1) {
2562 Double_t dx = hit->GetX() - var[0];
2563 Double_t dy = hit->GetY() - var[1];
2564 Double_t dz = hit->GetZ() - var[2];
2565 var[iii++] = dx / dz;
2566 var[iii++] = dy / dz;
2567 var[iii++] = aaa1.ty - aaa2.ty;
2568 var[iii++] = aaa1.lengxz;
2569 var[iii++] = aaa2.lengxz;
2570 var[iii++] = aaa1.momxz;
2572 (aaa1.momxz - aaa2.momxz) / (abs(aaa1.momxz) + abs(aaa2.momxz)) *
sqrt(aaa1.lengxz + aaa2.lengxz);
2573 var[iii++] = (fPass == 2) ? 1 : fPass;
2577 return fReaderTMVA3->EvaluateMVA(
"MLPBNN method");
2582void BmnStsVectorFinder::InitTMVA2()
2590 std::map<std::string, int> Use;
2597 TMVA::Reader* reader =
new TMVA::Reader(
"!Color:!Silent");
2598 fReaderTMVA2 = reader;
2604 Float_t* var = fVarTMVA;
2606 reader->AddVariable(
"xb", &var[iii++]);
2607 reader->AddVariable(
"yb", &var[iii++]);
2608 reader->AddVariable(
"zb", &var[iii++]);
2609 reader->AddVariable(
"tx", &var[iii++]);
2610 reader->AddVariable(
"ty", &var[iii++]);
2612 reader->AddVariable(
"dtanysc", &var[iii++]);
2613 reader->AddVariable(
"lenxz", &var[iii++]);
2614 reader->AddVariable(
"1/pxz", &var[iii++]);
2615 reader->AddVariable(
"corrq[1]-corrq[0]", &var[iii++]);
2616 reader->AddVariable(
"corrn[1]-corrn[0]", &var[iii++]);
2617 reader->AddVariable(
"pass", &var[iii++]);
2621 TString dir =
"dataset4diff/weights2/";
2622 TString prefix =
"TMVAClassification";
2625 for (std::map<std::string, int>::iterator it = Use.begin(); it != Use.end(); it++) {
2627 TString methodName = TString(it->first) + TString(
" method");
2628 TString weightfile = dir + prefix + TString(
"_") + TString(it->first) + TString(
".weights.xml");
2629 reader->BookMVA(methodName, weightfile);
2636Float_t BmnStsVectorFinder::TMVAOutput2(candvec& aaa1)
2640 Float_t* var = fVarTMVA ;
2641 map<Int_t, Int_t>& hitMap = aaa1.stahit;
2642 CbmStsHit *hit =
nullptr, *hit1 =
nullptr;
2643 int iii = 0, indx = 0;
2646 for (map<Int_t, Int_t>::iterator mit = hitMap.begin(); mit != hitMap.end(); ++mit) {
2647 hit = (
CbmStsHit*)fHitArray->UncheckedAt(mit->second);
2649 var[iii++] = hit->GetX();
2650 var[iii++] = hit->GetY();
2651 var[iii++] = hit->GetZ();
2653 }
else if (indx == 1) {
2654 Double_t dx = hit->GetX() - var[0];
2655 Double_t dy = hit->GetY() - var[1];
2656 Double_t dz = hit->GetZ() - var[2];
2657 var[iii++] = dx / dz;
2658 var[iii++] = dy / dz;
2659 var[iii++] = aaa1.ty;
2660 var[iii++] = aaa1.lengxz;
2661 var[iii++] = aaa1.momxz;
2663 var[iii++] = hit->GetTimeStamp() - hit1->GetTimeStamp();
2664 var[iii++] = (fPass == 2) ? 1 : fPass;
2668 return fReaderTMVA2->EvaluateMVA(
"MLPBNN method");
friend F32vec4 sqrt(const F32vec4 &a)
void Extrapolate(CbmStsTrack *track, Double_t z, FairTrackParam *e_track)
void ReadMatBudget(TString &matBudgetFileName)
void SetKFHits(CbmKFTrack &T, CbmStsTrack *track)
Int_t DoFit(CbmStsTrack *track, Int_t pidHypo=211)
Int_t Fit(CbmStsTrack *track, Int_t pidHypo=211)
virtual void Exec(Option_t *opt)
virtual InitStatus Init()
virtual void FinishEvent()
virtual Int_t Filter(CbmKFTrackInterface &track, Bool_t downstream, Double_t &QP0)=0
void SetStsTrack(CbmStsTrack &track, bool first=1)
CbmKFHit * GetHit(Int_t i)
Number of hits.
void GetTrackParam(FairTrackParam &track)
Double_t & GetRefChi2()
array[15] of covariance matrix
static CbmKF * Instance()
int GetNStsStations() const
Int_t GetDigi(Int_t inum)
Int_t GetRefIndex(Int_t i=0) const
static CbmStsDigiScheme * Instance(int version=1)
CbmStsStation * GetStationByNr(Int_t stationNr)
virtual Int_t GetStationNr() const
Double_t GetSignalDiv() const
Int_t GetSystemId() const
Int_t GetDigi(Int_t iSide) const
CbmStsSector * GetSector(Int_t iSector)
FairTrackParam * GetParamLast()
void SetParamLast(FairTrackParam &par)
void SetParamFirst(FairTrackParam &par)
void SetChi2(Double_t chi2)
Int_t GetNStsHits() const
Int_t GetStsHitIndex(Int_t iHit) const
FairTrackParam * GetParamFirst()
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values