31 #include "FairRootManager.h"
32 #include "FairRunAna.h"
33 #include "FairRuntimeDb.h"
35 #include "TClonesArray.h"
40 #include "TSpectrum2.h"
41 #include "TSpectrum.h"
42 #include "TStopwatch.h"
54 PndTrkLegendreSecTask2::PndTrkLegendreSecTask2() : FairTask(
"secondary track finder", 0), fDisplayOn(kFALSE), fPersistence(kTRUE), fUseMVDPix(kTRUE), fUseMVDStr(kTRUE), fUseSTT(kTRUE), fSecondary(kFALSE), fMvdPix_RealDistLimit(1000), fMvdStr_RealDistLimit(1000), fStt_RealDistLimit(1000), fMvdPix_ConfDistLimit(1000), fMvdStr_ConfDistLimit(1000), fStt_ConfDistLimit(1000), fInitDone(kFALSE) {
61 PndTrkLegendreSecTask2::PndTrkLegendreSecTask2(
int verbose) : FairTask(
"secondary track finder", verbose), fDisplayOn(kFALSE), fPersistence(kTRUE), fUseMVDPix(kTRUE), fUseMVDStr(kTRUE), fUseSTT(kTRUE), fSecondary(kFALSE), fMvdPix_RealDistLimit(1000), fMvdStr_RealDistLimit(1000), fStt_RealDistLimit(1000), fMvdPix_ConfDistLimit(1000), fMvdStr_ConfDistLimit(1000), fStt_ConfDistLimit(1000), fInitDone(kFALSE) {
98 FairRootManager* ioman = FairRootManager::Instance();
100 cout <<
"-E- PndTrkLegendreSecTask2::Init: "
101 <<
"RootManager not instantiated, return!" << endl;
110 cout <<
"-W- PndTrkLegendreSecTask2::Init: "
111 <<
"No STTHit array, return!" << endl;
118 std::cout <<
"-W- PndTrkLegendreSecTask2::Init: " <<
"No MVD Pixel hitArray, return!" << std::endl;
125 std::cout <<
"-W- PndTrkLegendreSecTask2::Init: " <<
"No MVD Strip hitArray, return!" << std::endl;
141 display =
new TCanvas(
"display",
"display", 0, 0, 800, 800);
162 FairRuntimeDb*
rtdb = FairRunAna::Instance()->GetRuntimeDb();
228 if(
fVerbose > 0) cout <<
"*********************** " <<
fEventCounter <<
" ***********************" << endl;
239 cout <<
"number of stt hits " <<
fSttHitArray->GetEntriesFast() << endl;
342 Bool_t stilltoassign = kTRUE;
344 while(stilltoassign == kTRUE) {
351 cout <<
" STARTING" << endl;
362 for(
int ilay = 0; ilay < 26; ilay++) {
366 for(
int ihit = 0; ihit < sttinlay.size(); ihit++) {
368 if(thishit->
IsUsed() == kTRUE)
continue;
385 cluster->
AddHit(sttinlay.at(ihit));
407 cout <<
"ADD CLUSTER " << cluster->
GetNofHits() << endl;
439 Double_t delta = 0, trasl[2] = {0., 0.};
465 double theta_max, r_max;
480 TLine *line =
new TLine(-10.07, fitq + fitm * (-10.07), 10.07, fitq + fitm * (10.07));
498 cout <<
"waiting 3 " << endl;
517 cluster = &thiscluster;
522 for(
int ihit = 0; ihit < cluster->
GetNofHits(); ihit++)
540 double xi = 0, yi = 0;
542 fabs(yi1 - (fitm * xi1 + fitq)) <
fabs(yi2 - (fitm * xi2 + fitq)) ? (yi = yi1, xi = xi1) : (yi = yi2, xi = xi2);
549 TMarker *mrk =
new TMarker(xi, yi, 6);
558 if(
fVerbose > 1) cout <<
"FITTER XR, YC, R: " << xc <<
" " << yc <<
" " << R << endl;
565 TLine *line =
new TLine(-0.07, fitq + fitm * (-0.07), 0.07, fitq + fitm * (0.07));
567 TLine *line2 =
new TLine(-0.07, fitq2 + fitm2 * (-0.07), 0.07, fitq2 + fitm2 * (0.07));
568 line2->SetLineColor(2);
593 if(
fVerbose > 1) cout <<
"%%%%%%%%%%%%%%%%%%%% ZFINDER %%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
617 int iz = -1, jz = -1;
622 for(
int ihit = 0; ihit < skewhitlist.
GetNofHits() - 1; ihit++) {
624 if(!skewhit1)
continue;
630 if(!skewhit2)
continue;
637 double distance =
fabs(fin_intersection1[iz].
Z() - fin_intersection2[0].
Z());
640 fabs(fin_intersection1[iz].
Z() - fin_intersection2[1].
Z()) < distance ? (distance =
fabs(fin_intersection1[iz].
Z() - fin_intersection2[1].
Z()), jz = 1) : distance;
644 double distance =
fabs(fin_intersection1[0].
Z() - fin_intersection2[0].
Z());
648 fabs(fin_intersection1[0].
Z() - fin_intersection2[1].
Z()) < distance ? (distance =
fabs(fin_intersection1[0].
Z() - fin_intersection2[1].
Z()), iz = 0, jz = 1 ): distance;
650 fabs(fin_intersection1[1].
Z() - fin_intersection2[0].
Z()) < distance ? (distance =
fabs(fin_intersection1[1].
Z() - fin_intersection2[0].
Z()), iz = 1, jz = 0) : distance;
652 fabs(fin_intersection1[1].
Z() - fin_intersection2[1].
Z()) < distance ? (distance =
fabs(fin_intersection1[1].
Z() - fin_intersection2[1].
Z()), iz = 1, jz = 1): distance;
681 TMarker *mrkfoundzphi1 =
new TMarker(phi1[iz], fin_intersection1[iz].
Z(), 20);
682 mrkfoundzphi1->SetMarkerColor(kYellow);
683 mrkfoundzphi1->Draw(
"SAME");
685 TMarker *mrkfoundzphi2 =
new TMarker(phi2[jz], fin_intersection2[jz].
Z(), 20);
686 mrkfoundzphi2->SetMarkerColor(kYellow);
687 mrkfoundzphi2->Draw(
"SAME");
699 for(
int ihit = 0; ihit < mvdcluster->
GetNofHits(); ihit++) {
711 TMarker *mrkfoundzphi =
new TMarker(phi, position.Z(), 21);
712 mrkfoundzphi->SetMarkerColor(kOrange);
713 mrkfoundzphi->Draw(
"SAME");
728 if(straightlinefit = kTRUE) {
733 TLine *l222 =
new TLine(-1000, -1000 * ml + pl, 1000, 1000 * ml + pl);
744 for(
int ihit = 0; ihit < trkcluster->
GetNofHits(); ihit++) {
750 for(
int ihit = 0; ihit < skewhitlist.
GetNofHits(); ihit++) {
757 else trkcluster->
AddHit(skewhit);
759 double phi1 = track->
ComputePhi(intersection1);
760 double calcz1 = ml * phi1 + pl;
762 double phi2 = track->
ComputePhi(intersection2);
763 double calcz2 = ml * phi2 + pl;
772 for(
int ihit = 0; ihit < trkcluster->
GetNofHits(); ihit++) {
791 trkcluster = tmpcluster;
797 hzphi->SetXTitle(
"#phi");
798 hzphi->SetYTitle(
"#z");
804 zfit =
ZPhiFit(1, trkcluster, ml, pl);
828 for(
int ihit = 0; ihit < trkcluster2->
GetNofHits(); ihit++) {
863 cout <<
"FINISH" << endl;
888 for(
int ihit = 0; ihit < hitlist.size(); ihit++) {
890 if(hit->
IsUsed() == kFALSE)
return kTRUE;
904 cout <<
"FINISH" << endl;
986 for(
int jhit = 0; jhit < cluster->
GetNofHits(); jhit++) {
994 cout <<
"CONFORMAL " << chit->
GetU() <<
" " << chit->
GetV() <<
" " << chit->
GetIsochrone() << endl;
1050 double distlimit = 0;
1051 if(detID == FairRootManager::Instance()->GetBranchId(
fMvdPixelBranch)) distlimit = 0.003;
1052 else if(detID == FairRootManager::Instance()->GetBranchId(
fMvdStripBranch)) distlimit = 0.003;
1053 else if(detID == FairRootManager::Instance()->GetBranchId(
fSttBranch)) {
1055 else distlimit = 0.001;
1061 if(dist < distlimit) {
1065 arc->SetFillStyle(0);
1066 arc->SetLineColor(5);
1072 if(detID == FairRootManager::Instance()->GetBranchId(
fMvdPixelBranch)) mrk =
new TMarker(chit->
GetU(), chit->
GetV(), 21);
1073 else if(detID == FairRootManager::Instance()->GetBranchId(
fMvdStripBranch)) mrk =
new TMarker(chit->
GetU(), chit->
GetV(), 25);
1074 mrk->SetMarkerColor(5);
1081 if(detID == FairRootManager::Instance()->GetBranchId(
fMvdPixelBranch)) {
1084 else if(detID == FairRootManager::Instance()->GetBranchId(
fMvdStripBranch)) {
1087 else if(detID == FairRootManager::Instance()->GetBranchId(
fSttBranch)) {
1112 TArc *arc =
new TArc(xc0, yc0, R0);
1113 arc->SetFillStyle(0);
1114 arc->SetLineColor(5);
1124 double distlimit = 1.5 * 0.5;
1125 if(dist < distlimit){
1131 arc->SetFillStyle(0);
1132 arc->SetLineColor(5);
1142 double distlimit = 0.5;
1143 if(dist < distlimit) {
1147 mrk->SetMarkerColor(5);
1157 double distlimit = 0.5;
1158 if(dist < distlimit){
1162 mrk->SetMarkerColor(5);
1188 TArc *arc =
new TArc(xc0, yc0, R0);
1189 arc->SetFillStyle(0);
1190 arc->SetLineColor(5);
1198 double distlimit = 0.5;
1199 if(dist < distlimit) {
1203 mrk->SetMarkerColor(5);
1213 double distlimit = 0.5;
1214 if(dist < distlimit){
1218 mrk->SetMarkerColor(5);
1233 if(detID != FairRootManager::Instance()->GetBranchId(
fSttBranch))
continue;
1234 double distlimit = 0;
1236 else distlimit = 0.001;
1239 if(dist < distlimit) {
1245 arc->SetFillStyle(0);
1246 arc->SetLineColor(5);
1266 if(detID == FairRootManager::Instance()->GetBranchId(
fMvdPixelBranch)) {
1269 else if(detID == FairRootManager::Instance()->GetBranchId(
fMvdStripBranch)) {
1272 else if(detID == FairRootManager::Instance()->GetBranchId(
fSttBranch)) {
1282 if(detID == FairRootManager::Instance()->GetBranchId(
fMvdPixelBranch)) {
1285 else if(detID == FairRootManager::Instance()->GetBranchId(
fMvdStripBranch)) {
1288 else if(detID == FairRootManager::Instance()->GetBranchId(
fSttBranch)) {
1318 else if(mode == 2) {
1329 arc->SetFillStyle(0);
1330 arc->SetLineColor(5);
1337 mrk->SetMarkerColor(5);
1345 if(accept == kTRUE) {
1363 int addedcounter = 0;
1374 else if(mode == 2) {
1389 arc->SetFillStyle(0);
1390 arc->SetLineColor(5);
1397 mrk->SetMarkerColor(5);
1405 if(accept == kTRUE) {
1411 return addedcounter;
1419 Double_t fMinimumDistanceLimit = 3;
1422 if(hit->
IsMvdStrip()) fMinimumDistanceLimit = 10;
1423 else if(hit->
IsMvdPixel()) fMinimumDistanceLimit = 3;
1424 else if(hit->
IsStt()) fMinimumDistanceLimit = 2;
1428 if(distance < fMinimumDistanceLimit)
return kTRUE;
1436 ycrot0 = 1 / (2 * fitp);
1437 xcrot0 = - fitm * ycrot0;
1438 R =
sqrt(xcrot0 * xcrot0 + ycrot0 * ycrot0);
1449 if(
hxy == NULL)
hxy =
new TH2F(
"hxy",
"xy plane", 100, -43, 43, 100, -43, 43);
1460 if(
hxz == NULL)
hxz =
new TH2F(
"hxz",
"xz plane", 100, -43, 43, 100, -43, 113);
1465 if(
hzphi == NULL)
hzphi =
new TH2F(
"hzphi",
"z - phi plane", phimax - phimin, phimin, phimax, zmax - zmin, zmin, zmax);
1468 hzphi->GetXaxis()->SetLimits(phimin, phimax);
1469 hzphi->GetYaxis()->SetLimits(zmin, zmax);
1490 if(
fVerbose) cout <<
"Refresh stt" << endl;
1492 if(
fVerbose) cout <<
"Refresh pixel" << endl;
1494 if(
fVerbose) cout <<
"Refresh strip" << endl;
1496 if(
fVerbose) cout <<
"Refresh stop" << endl;
1513 if(
huv == NULL)
huv =
new TH2F(
"huv",
"uv plane", 100, x1, y1, 100, x2, y2);
1516 huv->GetXaxis()->SetLimits(x1, y1);
1517 huv->GetYaxis()->SetLimits(x2, y2);
1554 TArc *arc =
new TArc(u, v, r);
1555 arc->SetFillStyle(0);
1559 TMarker *mrk =
new TMarker(u, v, marker);
1585 cluster.
AddHit(firsthit);
1599 for(
int jhit = 0; jhit < cluster.
GetNofHits(); jhit++) {
1603 if(*hit == *clushit) {
1609 if(!success)
continue;
1649 double phimin = 400, phimax = -1, zmin = 1000, zmax = -1;
1656 if(hit->
IsSttSkew() == kFALSE)
continue;
1664 TVector3 first = tube->
GetPosition() + wireDirection * halflength;
1665 TVector3 second = tube->
GetPosition() - wireDirection * halflength;
1676 double m1 = (first - second).
Y()/(first - second).
X();
1677 double q1 = first.Y() - m1 * first.X();
1680 TVector2 intersection1, intersection2;
1683 if(nofintersections == 0)
continue;
1684 if(nofintersections >= 2) {
1685 cout <<
"ERROR: MORE THAN 1 INTERSECTION!!" << endl;
1692 TLine *l =
new TLine(first.X(), first.Y(), second.X(), second.Y());
1693 l->SetLineColor(kBlue);
1696 TMarker *mrk =
new TMarker(intersection1.X(), intersection1.Y(), 20);
1697 mrk->SetMarkerColor(kBlue);
1715 double beta = wireDirection.Phi();
1720 TVector2 rottangent(rtx, rty);
1721 rottangent = rottangent.Unit();
1732 Double_t rotm = rottangent.Y()/rottangent.X();
1742 x0a = (-rotp +
TMath::Sqrt(b * b + a * a * rotm * rotm)) / rotm;
1743 x0b = (-rotp -
TMath::Sqrt(b * b + a * a * rotm * rotm)) / rotm;
1746 double intxa = (x0a * b * b - rotm * rotp * a *
a) / (b * b + rotm * rotm * a * a);
1747 double intya = rotm * intxa + rotp;
1748 double intxb = (x0b * b * b - rotm * rotp * a *
a) / (b * b + rotm * rotm * a * a);
1749 double intyb = rotm * intxb + rotp;
1776 double y0a = y0anew;
1778 double y0b = y0bnew;
1784 TEllipse *ell1 =
new TEllipse(x0a, y0a, a, b, 0, 360, -beta);
1785 ell1->SetFillStyle(0);
1786 ell1->SetLineColor(4);
1788 TEllipse *ell2 =
new TEllipse(x0b, y0b, a, b, 0, 360, -beta);
1789 ell2->SetFillStyle(0);
1790 ell2->SetLineColor(6);
1793 TMarker *mrkinta =
new TMarker(intxa, intya, 20);
1794 mrkinta->SetMarkerColor(4);
1795 mrkinta->Draw(
"SAME");
1796 TMarker *mrkintb =
new TMarker(intxb, intyb, 20);
1797 mrkintb->SetMarkerColor(6);
1798 mrkintb->Draw(
"SAME");
1805 Double_t t = ((x0a + y0a) - (first.X() + first.Y())) / ((second.X() - first.X()) + (second.Y() - first.Y()));
1806 Double_t z0a = first.Z() + (second.Z() - first.Z()) * t;
1809 t = ((x0b + y0b) - (first.X() + first.Y())) / ((second.X() - first.X()) + (second.Y() - first.Y()));
1810 Double_t z0b = first.Z() + (second.Z() - first.Z()) * t;
1812 TVector3 center1(x0a, y0a, z0a);
1813 TVector3 center2(x0b, y0b, z0b);
1820 TLine *linezx =
new TLine(first.X(), first.Z(), second.X(), second.Z());
1821 linezx->Draw(
"SAME");
1822 TMarker *mrkza =
new TMarker(x0a, z0a, 20);
1823 mrkza->SetMarkerColor(4);
1824 mrkza->Draw(
"SAME");
1825 TMarker *mrkzb =
new TMarker(x0b, z0b, 20);
1826 mrkzb->SetMarkerColor(6);
1827 mrkzb->Draw(
"SAME");
1832 double dx = intxa - x0a;
1833 double dy = intya - y0a;
1834 TVector3 dxdy(dx, dy, 0.0);
1836 TVector3 tfirst = first + dxdy;
1837 TVector3 tsecond = second + dxdy;
1839 t = ((intxa + intya) - (tfirst.X() + tfirst.Y())) / ((tsecond.X() - tfirst.X()) + (tsecond.Y() - tfirst.Y()));
1840 double intza = tfirst.Z() + (tsecond.Z() - tfirst.Z()) * t;
1844 TLine *linezx1 =
new TLine(tfirst.X(), tfirst.Z(), tsecond.X(), tsecond.Z());
1845 linezx1->SetLineStyle(1);
1846 linezx1->Draw(
"SAME");
1847 TMarker *mrkza1 =
new TMarker(intxa, intza, 20);
1848 mrkza1->SetMarkerColor(kBlue - 9);
1849 mrkza1->Draw(
"SAME");
1853 tfirst = first - dxdy;
1854 tsecond = second - dxdy;
1856 t = ((intxb + intyb) - (tfirst.X() + tfirst.Y())) / ((tsecond.X() - tfirst.X()) + (tsecond.Y() - tfirst.Y()));
1857 double intzb = tfirst.Z() + (tsecond.Z() - tfirst.Z()) * t;
1859 TVector3 fin_intersection1(intxa, intya, intza);
1860 TVector3 fin_intersection2(intxb, intyb, intzb);
1865 TLine *linezx2 =
new TLine(tfirst.X(), tfirst.Z(), tsecond.X(), tsecond.Z());
1866 linezx2->SetLineStyle(1);
1867 linezx2->Draw(
"SAME");
1868 TMarker *mrkzb1 =
new TMarker(intxb, intzb, 20);
1869 mrkzb1->SetMarkerColor(kMagenta - 7);
1870 mrkzb1->Draw(
"SAME");
1879 double phi1 = track->
ComputePhi(fin_intersection1);
1880 double phi2 = track->
ComputePhi(fin_intersection2);
1882 PndTrkSkewHit *skewhit =
new PndTrkSkewHit(*hit, trackID, center1, fin_intersection1, phi1, center2, fin_intersection2, phi2, a, b, -1, beta);
1884 skewhitlist.
AddHit(skewhit);
1902 double phimin = 400, phimax = -1, zmin = 1000, zmax = -1;
1904 for(
int ihit = 0; ihit < skewhitlist->
GetNofHits(); ihit++) {
1906 if(!skewhit)
continue;
1910 double phi1 = skewhit->
GetPhi1();
1911 double phi2 = skewhit->
GetPhi2();
1913 if(phi1 < phimin) phimin = phi1;
1914 if(phi2 < phimin) phimin = phi2;
1915 if(fin_intersection1.Z() < zmin) zmin = fin_intersection1.Z();
1916 if(fin_intersection2.Z() < zmin) zmin = fin_intersection2.Z();
1918 if(phi1 > phimax) phimax = phi1;
1919 if(phi2 > phimax) phimax = phi2;
1920 if(fin_intersection1.Z() > zmax) zmax = fin_intersection1.Z();
1921 if(fin_intersection2.Z() > zmax) zmax = fin_intersection2.Z();
1936 hzphi->SetXTitle(
"#phi");
1937 hzphi->SetYTitle(
"#z");
1943 for(
int ihit = 0; ihit < skewhitlist->
GetNofHits(); ihit++) {
1945 if(!skewhit)
continue;
1950 double phi1 = skewhit->
GetPhi1();
1951 double phi2 = skewhit->
GetPhi2();
1953 TLine *linezphi =
new TLine(phi1, fin_intersection1.Z(), phi2, fin_intersection2.Z());
1955 linezphi->SetLineStyle(1);
1956 linezphi->Draw(
"SAME");
1958 TMarker *mrkzphi1 =
new TMarker(phi1, fin_intersection1.Z(), 20);
1961 mrkzphi1->SetMarkerColor(kBlue - 9);
1962 mrkzphi1->Draw(
"SAME");
1964 TMarker *mrkzphi2 =
new TMarker(phi2, fin_intersection2.Z(), 20);
1966 mrkzphi2->SetMarkerColor(kMagenta - 7);
1967 mrkzphi2->Draw(
"SAME");
1975 TH1F hz(
"hz",
"z", (zmax - zmin)/10., zmin, zmax);
1976 for(
int ihit = 0; ihit < skewhitlist->
GetNofHits(); ihit++) {
1978 if(!skewhit)
continue;
1981 hz.Fill(fin_intersection1.Z());
1982 hz.Fill(fin_intersection2.Z());
1984 int maxbinz = hz.GetMaximumBin();
1985 double mostprobZ = hz.GetBinCenter(maxbinz);
1991 for(
int ihit = 0; ihit < skewhitlist->
GetNofHits(); ihit++) {
1993 if(!skewhit)
continue;
1996 double phi1 = skewhit->
GetPhi1();
1997 double phi2 = skewhit->
GetPhi2();
1999 if(
fabs(fin_intersection1.Z() - mostprobZ) > 30. &&
fabs(fin_intersection2.Z() - mostprobZ) > 30.) {
2004 tmpskewhitlist.
AddHit(skewhit);
2006 tmpskewhitlist.
Sort();
2007 return tmpskewhitlist;
2016 Int_t size = clref1.GetEntriesFast();
2020 size = clref2.GetEntriesFast();
2024 cout <<
"MOM FIRST: TOT, PT, PL " << outputtrack->
GetParamFirst().GetMomentum().Mag() <<
" " << outputtrack->
GetParamFirst().GetMomentum().Perp() <<
" " << outputtrack->
GetParamFirst().GetMomentum().Z() << endl;
2025 cout <<
"MOM LAST: TOT, PT, PL " << outputtrack->
GetParamLast().GetMomentum().Mag() <<
" " << outputtrack->
GetParamLast().GetMomentum().Perp() <<
" " << outputtrack->
GetParamLast().GetMomentum().Z() << endl;
2037 cout <<
"Z0, TANL " << track->
GetZ0() <<
" " << track->
GetTanL() << endl;
2038 cout <<
"CHARGE " << track->
GetCharge() << endl;
2051 if(ntot == 0)
return NULL;
2057 for(
int jhit = 0; jhit < ntot; jhit++) {
2063 if(
fVerbose > 1) cout <<
"STT hit " << jhit <<
"already used " << endl;
2072 if(tmphitid == -1)
return NULL;
2075 if(
fVerbose > 1) cout <<
"STT REFERENCE HIT " << tmphitid <<
" " << refhit->
GetIsochrone() << endl;
2089 if(
fVerbose > 1) cout <<
"already used V" << endl;
2095 if(tmphitid == -1)
return NULL;
2097 if(
fVerbose > 1) cout <<
"MVD PIXEL REFERENCE HIT " << refhit->
GetHitID() << endl;
2110 if(
fVerbose > 1) cout <<
"already used V" << endl;
2116 if(tmphitid == -1)
return NULL;
2118 if(
fVerbose > 1) cout <<
"MVD STRIP REFERENCE HIT " << refhit->
GetHitID() << endl;
2127 if(refhit != NULL)
return refhit;
2138 if(refhit != NULL)
return refhit;
2149 if(ntot == 0)
return NULL;
2155 for(
int jhit = 0; jhit < ntot; jhit++) {
2177 if(tmphitid == -1)
return NULL;
2178 refhit = cluster->
GetHit(tmphitid);
2220 if(
fVerbose > 1) cout <<
"%%%%%%%%%%%%%%%%%%%% XY FINDER %%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
2253 bool alreadythere =
false;
2259 cout <<
"MAXPEAK " << maxpeak <<
", BREAK NOW! " << endl;
2263 for(
int ialready = 0; ialready <
fFoundPeaks.size(); ialready++) {
2264 std::pair<double, double> foundthetar =
fFoundPeaks.at(ialready);
2265 double foundtheta = foundthetar.first;
2266 double foundr = foundthetar.second;
2268 if(theta_max == foundtheta && r_max == foundr) {
2271 alreadythere =
true;
2272 if(
fVerbose > 0) cout <<
"OH NO! THIS PEAK IS ALREADY THERE" << endl;
2277 if(alreadythere ==
false) {
2278 std::pair<double, double>
tr(theta_max, r_max);
2291 if(mode == 0 && alreadythere ==
true) {
2292 cout <<
"THIS PEAK IS ALREADY THERE" << endl;
2302 TMarker *mrk =
new TMarker(theta_max, r_max, 29);
2333 for(
int ihit = 0; ihit < mvdpixcluster.
GetNofHits(); ihit++) {
2339 if(layerID%2 == 0) rightvotes++;
2344 for(
int ihit = 0; ihit < mvdstrcluster.
GetNofHits(); ihit++) {
2350 if(layerID%2 == 0) rightvotes++;
2355 for(
int ihit = 0; ihit < sttcluster.
GetNofHits(); ihit++) {
2357 int layerID = -999, tubeID = hit->
GetTubeID(), sectorID = -999;
2363 if(sectorID < 3) rightvotes++;
2368 for(
int ihit = 0; ihit < cluster.
GetNofHits(); ihit++) {
2374 for(
int ihit = 0; ihit < cluster.
GetNofHits(); ihit++) {
2387 for(
int ihit = 0; ihit < mvdpixcluster.
GetNofHits(); ihit++) {
2394 if((leftvotes > rightvotes) && (layerID%2 == 0)) {
2398 else if((leftvotes < rightvotes) && (layerID%2 != 0)) {
2409 cout <<
"WAITING" << endl;
2415 for(
int ihit = 0; ihit < mvdstrcluster.
GetNofHits(); ihit++) {
2420 if((leftvotes > rightvotes) && (layerID%2 == 0)) {
2424 else if((leftvotes < rightvotes) && (layerID%2 != 0)) {
2440 for(
int ihit = 0; ihit < sttcluster.
GetNofHits(); ihit++) {
2442 int layerID = -999, tubeID = hit->
GetTubeID();
2449 if((leftvotes > rightvotes) && (sectorID < 3)) {
2453 else if((leftvotes < rightvotes) && (sectorID >= 3)) {
2466 int neighboringcounter = 0;
2467 for(
int ohit = 0; ohit < sttcluster.
GetNofHits(); ohit++) {
2468 if(ihit == ohit)
continue;
2472 for(
int nhit = 0;
nhit < neighboring.GetSize();
nhit++) {
2473 if(otherhitID == neighboring.At(
nhit)) neighboringcounter++;
2484 if(layerID != 0 && layerID != 7 && layerID != 8 && ihit != sttcluster.
GetNofHits() - 1 && neighboringcounter == 1) {
2492 if(neighboringcounter == 0) {
2494 deletioncluster.
AddHit(hit);
2520 for(
int ihit = 0; ihit < cluster.
GetNofHits(); ihit++) {
2523 for(
int jhit = 0; jhit < deletioncluster.
GetNofHits(); jhit++) {
2533 if(!stop) finalcluster.
AddHit(hit);
2536 return finalcluster;
2543 for(
int ihit = 0; ihit < cluster->
GetNofHits(); ihit++) {
2546 cleancluster->
AddHit(hit);
2554 double distance =
fabs(fitm * phi - position.Z() + fitp )/
sqrt(fitm * fitm + 1);
2558 if(distance < 1) cleancluster->
AddHit(hit);
2561 if(distance < 5) cleancluster->
AddHit(hit);
2565 return cleancluster;
2579 hzphi->SetXTitle(
"#phi");
2580 hzphi->SetYTitle(
"#z");
2590 double refiso = 1000;
2591 for(
int ihit = 0; ihit < cluster->
GetNofHits(); ihit++) {
2592 hit = cluster->
GetHit(ihit);
2602 if(iter != 0) refhit =
hit;
2607 if(iter != 0 && refhit == NULL && hit->
GetIsochrone() < refiso) refhit = hit;
2615 TMarker *mrkfoundzphi = NULL;
2617 mrkfoundzphi =
new TMarker(phi, position.Z(), 21);
2618 if(iter == 0) mrkfoundzphi->SetMarkerColor(kOrange);
2619 else mrkfoundzphi->SetMarkerColor(4);
2622 mrkfoundzphi =
new TMarker(phi, position.Z(), 20);
2623 if(iter == 0) mrkfoundzphi->SetMarkerColor(kGreen);
2624 else mrkfoundzphi->SetMarkerColor(4);
2626 mrkfoundzphi->Draw(
"SAME");
2644 TLine *l22 =
new TLine(-1000, -1000 * fitm + fitp, 1000, 1000 * fitm + fitp);
2645 if(iter == 0) l22->SetLineColor(3);
2646 else if(iter == 1) l22->SetLineColor(4);
2662 TH1F hresiduals(
"hresiduals",
"residuals in z", 20, -5, 5);
2664 for(
int ihit = 0; ihit < cluster->
GetNofHits(); ihit++) {
2674 double distance = fitm * phi + fitp - position.Z();
2676 hresiduals.Fill(distance);
2682 cout <<
"residuals";
2689 return hresiduals.GetMean();
2694 for(
int ihit = 0; ihit < cluster->
GetNofHits(); ihit++) {
2701 double newz = position.Z() - deltaz;
2710 TVector3 first = tube->
GetPosition() + wireDirection * halflength;
2711 TVector3 second = tube->
GetPosition() - wireDirection * halflength;
2714 double newx = position.X();
2715 double newy = position.Y();
2716 if((second.X() - first.X()) != 0) {
2717 m = (second.Z() - first.Z())/(second.X() - first.X());
2718 p = position.Z() - m * position.X();
2719 newx = (newz -
p)/m;
2722 if((second.Y() - first.Y()) != 0) {
2724 m = (second.Z() - first.Z())/(second.Y() - first.Y());
2725 p = position.Z() - m * position.Y();
2726 newy = (newz -
p)/m;
2736 TMarker *mrk =
new TMarker(newx, newy, 6);
2737 mrk->SetMarkerColor(kOrange);
2742 cout <<
"old " << position.X() <<
" " << position.Y() <<
" " << position.Z() << endl;
2743 cout <<
"new " << newx <<
" " << newy <<
" " << newz << endl;
char fMvdPixelBranch[200]
PndTrkCluster CreateSkewHitList(PndTrkTrack *track)
Int_t ApplyLegendre(double &theta_max, double &r_max)
void Replace(PndTrkHit *hit)
void LightCluster(PndTrkCluster *cluster)
TClonesArray * fTrackArray
PndTrkSdsHitList * mvdpixhitlist
void RegisterTrack(PndTrkTrack *track)
void AddTCA(Int_t detID, TClonesArray *array)
void DrawGeometryConf(double x1, double y1, double x2, double y2)
int FindMvdLayer(int sensorID)
PndTrack ConvertToPndTrack()
virtual void Exec(Option_t *opt)
Int_t ExtractLegendre(Int_t mode, double &theta_max, double &r_max)
friend F32vec4 sqrt(const F32vec4 &a)
PndTrkConformalTransform * conform
PndTrkSttHitList * Instanciate()
static const UInt_t success
TClonesArray * fSttHitArray
static T Sqrt(const T &x)
PndTrkHit * FindMvdPixelReferenceHit()
Double_t GetMinimumXYDistanceFromHit(PndTrkHit *hit)
std::vector< PndTrkHit * > GetHitList()
PndTrkHit * FindMvdStripReferenceHit()
PndTrkCluster CreateClusterByRealDistance(double xc0, double yc0, double R0)
PndTrkCluster GetCluster()
void SetTanL(double tanl)
void FillLegendreHisto(Int_t mode)
PndGeoSttPar * fSttParameters
void SetPhi(Double_t phi)
PndTrkHit * FindMvdReferenceHit()
int GetNofHitsInSector(int isec)
void SetSortVariable(Double_t sortvar)
PndTrkCluster CreateClusterByDistance(Int_t mode, double fitm, double fitq)
void AddHit(PndTrkHit *hit)
PndTrkHit * GetHitFromSector(int ihit, int isec)
void RePrepareLegendre(PndTrkCluster *cluster)
char fMvdStripBranch[200]
PndTrkHit * GetHit(int index)
std::vector< PndTrkHit * > GetHitListFromLayer(int ilay)
TVector3 GetIntersection2()
void SetIRegion(int iregion)
PndTrkHit * GetHit(int index)
void AddCluster(PndTrkCluster *cluster)
Double_t ComputePhi(TVector3 hit)
void DrawHits(PndTrkHitList *hitlist)
TClonesArray * fTrackCandArray
PndTrkHit * FindReferenceHit()
double CorrectZ(PndTrkCluster *cluster, double deltaz, double fitm, double fitp)
void SetCenter(double x, double y)
std::vector< std::pair< double, double > > fFoundPeaks
Bool_t CheckAssignability(std::vector< PndTrkHit * > hitlist)
Bool_t IsNeighboring(int tubeID)
PndTrkCluster GetSttParallelHitList()
Double_t fMvdStr_ConfDistLimit
PndTrackCand GetTrackCand()
void SetUsedFlag(Bool_t used)
Bool_t CheckVicinity(PndTrkHit *hit, PndTrkCluster *cluster)
Double_t fStt_ConfDistLimit
Double_t GetDistance(PndTrkHit *fromhit)
TArrayI GetNeighborings()
void SetRadius(double radius)
PndTrkSdsHitList * InstanciateStrip()
Int_t FillConformalHitList(int isec=-1)
Bool_t DoesConfHitBelong(PndTrkConformalHit *hit, double fitm, double fitp)
void Draw(Color_t color=kBlack)
PndTrkCluster CleanUpSkewHitList(PndTrkCluster *skewhitlist)
void SetPosition(TVector3 pos)
FairTrackParP GetParamLast()
TClonesArray * fMvdStripHitArray
TClonesArray * FillTubeArray()
TClonesArray * fMvdPixelHitArray
PndTrkCluster CreateClusterByConfDistance(double fitm, double fitq)
void Draw(Color_t color=kBlack)
friend F32vec4 fabs(const F32vec4 &a)
Bool_t ConstrainedStraightLineFit(Double_t x0, Double_t y0, Double_t &fitm, Double_t &fitp)
static PndGeoHandling * Instance()
PndTrkCluster * CleanupZPhiFit(PndTrkCluster *cluster, double fitm, double fitp)
void DrawConfHit(double x, double y, double r, int marker=2)
Double_t GetXYDistanceFromTrack(double x0, double y0, double R)
PndTrkCluster Cleanup(PndTrkCluster cluster)
Double_t fMvdStr_RealDistLimit
PndTrkCluster GetMvdPixelHitList()
PndTrkLegendreTransform * legendre
Bool_t DoesContain(PndTrkHit *hit)
virtual InitStatus Init()
TVector3 GetIntersection1()
Double_t GetXYDistance(PndTrkHit *fromhit)
TClonesArray * fTubeArray
Bool_t StraightLineFit(Double_t &fitm, Double_t &fitp)
PndTrkHit * FindSttReferenceHit(int isec=-1)
Double_t fMvdPix_RealDistLimit
void ComputeTraAndRot(PndTrkHit *hit, Double_t &delta, Double_t trasl[2])
Bool_t DoesRealHitBelong(PndTrkHit *hit, double x0, double y0, double R)
PndSttMapCreator * fMapper
PndTrkConformalHitList * conformalhitlist
Bool_t ZPhiFit(int iter, PndTrkCluster *cluster, double &fitm, double &fitp)
void FromConformalToRealTrack(double fitm, double fitp, double &x0, double &y0, double &R)
Double_t fStt_RealDistLimit
double ComputeZRediduals(PndTrkCluster *cluster, double fitm, double fitp)
Double_t fMvdPix_ConfDistLimit
PndTrkCluster CreateSttCluster(PndTrkHit *firsthit)
PndTrkCluster CreateClusterByMixedDistance(double fitm, double fitq)
PndTrkCluster GetMvdStripHitList()
Int_t AddHitToClusterByDistance(PndTrkCluster *cluster, Int_t mode, double fitm, double fitp)
TVector3 GetWireDirection()
PndTrkSttHitList * stthitlist
void DrawZGeometry(int whichone=1, double phimin=0, double phimax=360, double zmin=-43, double zmax=113)
FairTrackParP GetParamFirst()
PndTrkSdsHitList * mvdstrhitlist
~PndTrkLegendreSecTask2()
void SetPointToFit(double x, double y, double sigma)
Bool_t IsRegion(Int_t iregion)
Bool_t IsSttAssociate(PndTrkHit *hit1, PndTrkHit *hit2)
PndTrkSdsHitList * InstanciatePixel()