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 PndTrkLegendreSecTask::PndTrkLegendreSecTask() : 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 PndTrkLegendreSecTask::PndTrkLegendreSecTask(
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) {
96 FairRootManager* ioman = FairRootManager::Instance();
98 cout <<
"-E- PndTrkLegendreSecTask::Init: "
99 <<
"RootManager not instantiated, return!" << endl;
108 cout <<
"-W- PndTrkLegendreSecTask::Init: "
109 <<
"No STTHit array, return!" << endl;
116 std::cout <<
"-W- PndTrkLegendreSecTask::Init: " <<
"No MVD Pixel hitArray, return!" << std::endl;
123 std::cout <<
"-W- PndTrkLegendreSecTask::Init: " <<
"No MVD Strip hitArray, return!" << std::endl;
139 display =
new TCanvas(
"display",
"display", 0, 0, 800, 800);
160 FairRuntimeDb*
rtdb = FairRunAna::Instance()->GetRuntimeDb();
198 if(
fVerbose > 0) cout <<
"*********************** " <<
fEventCounter <<
" ***********************" << endl;
225 cout <<
"number of stt hits " <<
fSttHitArray->GetEntriesFast() << endl;
242 cout <<
" STARTING" << endl;
252 cout <<
" STARTING" << endl;
260 Double_t delta = 0, trasl[2] = {0., 0.};
271 std::vector< std::pair<double, double> > foundpeaks;
275 fTimer =
new TStopwatch();
306 if(
fVerbose > 1) cout << nchits <<
" " << trasl[0] <<
" " << trasl[1] <<
" " << delta << endl;
315 cout <<
"Next peak? ";
321 if(
fVerbose > 1) cout <<
"@@@@ PEAK No. " << ipeak <<
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;
327 double theta_max, r_max;
329 if(maxpeak <= 3)
break;
352 cluster = cleancluster;
362 for(
int ihit = 0; ihit < cluster.
GetNofHits(); ihit++)
377 double xi = 0, yi = 0;
379 fabs(yi1 - (fitm * xi1 + fitq)) <
fabs(yi2 - (fitm * xi2 + fitq)) ? (yi = yi1, xi = xi1) : (yi = yi2, xi = xi2);
386 TMarker *mrk =
new TMarker(xi, yi, 6);
397 TLine *line =
new TLine(-0.07, fitq + fitm * (-0.07), 0.07, fitq + fitm * (0.07));
399 TLine *line2 =
new TLine(-0.07, fitq2 + fitm2 * (-0.07), 0.07, fitq2 + fitm2 * (0.07));
400 line2->SetLineColor(2);
416 if(
fVerbose > 1) cout <<
"ADDING CLUSTER WITH " << cluster.
GetNofHits() <<
" hits " << endl;
421 if(
fVerbose > 1) cout <<
"MAXPEAK " << maxpeak << endl;
428 cout <<
"waiting 2 " << endl;
435 if(
fVerbose > 1) cout <<
"XR, YC, R: " << xc <<
" " << yc <<
" " << R << endl;
445 cout <<
"waiting 3 " << endl;
452 if(
fVerbose > 1) cout <<
"%%%%%%%%%%%%%%%%%%%% ZFINDER %%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
461 int iz = -1, jz = -1;
466 for(
int ihit = 0; ihit < skewhitlist.
GetNofHits() - 1; ihit++) {
468 if(!skewhit1)
continue;
474 if(!skewhit2)
continue;
481 double distance =
fabs(fin_intersection1[iz].
Z() - fin_intersection2[0].
Z());
484 fabs(fin_intersection1[iz].
Z() - fin_intersection2[1].
Z()) < distance ? (distance =
fabs(fin_intersection1[iz].
Z() - fin_intersection2[1].
Z()), jz = 1) : distance;
488 double distance =
fabs(fin_intersection1[0].
Z() - fin_intersection2[0].
Z());
492 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;
494 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;
496 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;
519 TMarker *mrkfoundzphi1 =
new TMarker(phi1[iz], fin_intersection1[iz].
Z(), 20);
520 mrkfoundzphi1->SetMarkerColor(kYellow);
521 mrkfoundzphi1->Draw(
"SAME");
523 TMarker *mrkfoundzphi2 =
new TMarker(phi2[jz], fin_intersection2[jz].
Z(), 20);
524 mrkfoundzphi2->SetMarkerColor(kYellow);
525 mrkfoundzphi2->Draw(
"SAME");
536 for(
int ihit = 0; ihit < mvdcluster->
GetNofHits(); ihit++) {
548 TMarker *mrkfoundzphi =
new TMarker(phi, position.Z(), 21);
549 mrkfoundzphi->SetMarkerColor(kOrange);
550 mrkfoundzphi->Draw(
"SAME");
565 if(straightlinefit = kTRUE) {
570 TLine *l222 =
new TLine(-1000, -1000 * ml + pl, 1000, 1000 * ml + pl);
581 for(
int ihit = 0; ihit < skewhitlist.
GetNofHits(); ihit++) {
586 else trkcluster->
AddHit(skewhit);
588 double phi1 = track->
ComputePhi(intersection1);
589 double calcz1 = ml * phi1 + pl;
591 double phi2 = track->
ComputePhi(intersection2);
592 double calcz2 = ml * phi2 + pl;
601 for(
int ihit = 0; ihit < trkcluster->
GetNofHits(); ihit++) {
616 trkcluster = tmpcluster;
622 hzphi->SetXTitle(
"#phi");
623 hzphi->SetYTitle(
"#z");
629 zfit =
ZPhiFit(1, trkcluster, ml, pl);
653 for(
int ihit = 0; ihit < trkcluster2->
GetNofHits(); ihit++) {
672 if(
fVerbose > 1) cout <<
"MAXPEAK " << maxpeak << endl;
680 cout <<
"FINISH" << endl;
698 cout <<
"FINISH" << endl;
779 if(hit->
IsUsed())
continue;
790 for(
int ihit = 0; ihit < cluster->
GetNofHits(); ihit++) {
803 if(hit->
IsUsed())
continue;
826 double distlimit = 0;
827 if(detID == FairRootManager::Instance()->GetBranchId(
fMvdPixelBranch)) distlimit = 0.003;
828 else if(detID == FairRootManager::Instance()->GetBranchId(
fMvdStripBranch)) distlimit = 0.003;
829 else if(detID == FairRootManager::Instance()->GetBranchId(
fSttBranch)) {
831 else distlimit = 0.001;
837 if(dist < distlimit) {
841 arc->SetFillStyle(0);
842 arc->SetLineColor(5);
848 if(detID == FairRootManager::Instance()->GetBranchId(
fMvdPixelBranch)) mrk =
new TMarker(chit->
GetU(), chit->
GetV(), 21);
849 else if(detID == FairRootManager::Instance()->GetBranchId(
fMvdStripBranch)) mrk =
new TMarker(chit->
GetU(), chit->
GetV(), 25);
850 mrk->SetMarkerColor(5);
857 if(detID == FairRootManager::Instance()->GetBranchId(
fMvdPixelBranch)) {
860 else if(detID == FairRootManager::Instance()->GetBranchId(
fMvdStripBranch)) {
863 else if(detID == FairRootManager::Instance()->GetBranchId(
fSttBranch)) {
888 TArc *arc =
new TArc(xc0, yc0, R0);
889 arc->SetFillStyle(0);
890 arc->SetLineColor(5);
900 double distlimit = 1.5 * 0.5;
901 if(dist < distlimit){
907 arc->SetFillStyle(0);
908 arc->SetLineColor(5);
918 double distlimit = 0.5;
919 if(dist < distlimit) {
923 mrk->SetMarkerColor(5);
933 double distlimit = 0.5;
934 if(dist < distlimit){
938 mrk->SetMarkerColor(5);
964 TArc *arc =
new TArc(xc0, yc0, R0);
965 arc->SetFillStyle(0);
966 arc->SetLineColor(5);
974 double distlimit = 0.5;
975 if(dist < distlimit) {
979 mrk->SetMarkerColor(5);
989 double distlimit = 0.5;
990 if(dist < distlimit){
994 mrk->SetMarkerColor(5);
1009 if(detID != FairRootManager::Instance()->GetBranchId(
fSttBranch))
continue;
1010 double distlimit = 0;
1012 else distlimit = 0.001;
1015 if(dist < distlimit) {
1021 arc->SetFillStyle(0);
1022 arc->SetLineColor(5);
1042 if(detID == FairRootManager::Instance()->GetBranchId(
fMvdPixelBranch)) {
1045 else if(detID == FairRootManager::Instance()->GetBranchId(
fMvdStripBranch)) {
1048 else if(detID == FairRootManager::Instance()->GetBranchId(
fSttBranch)) {
1058 if(detID == FairRootManager::Instance()->GetBranchId(
fMvdPixelBranch)) {
1061 else if(detID == FairRootManager::Instance()->GetBranchId(
fMvdStripBranch)) {
1064 else if(detID == FairRootManager::Instance()->GetBranchId(
fSttBranch)) {
1094 else if(mode == 2) {
1104 arc->SetFillStyle(0);
1105 arc->SetLineColor(5);
1112 mrk->SetMarkerColor(5);
1120 if(accept == kTRUE) {
1132 ycrot0 = 1 / (2 * fitp);
1133 xcrot0 = - fitm * ycrot0;
1134 R =
sqrt(xcrot0 * xcrot0 + ycrot0 * ycrot0);
1145 if(
hxy == NULL)
hxy =
new TH2F(
"hxy",
"xy plane", 100, -43, 43, 100, -43, 43);
1156 if(
hxz == NULL)
hxz =
new TH2F(
"hxz",
"xz plane", 100, -43, 43, 100, -43, 113);
1161 if(
hzphi == NULL)
hzphi =
new TH2F(
"hzphi",
"z - phi plane", phimax - phimin, phimin, phimax, zmax - zmin, zmin, zmax);
1164 hzphi->GetXaxis()->SetLimits(phimin, phimax);
1165 hzphi->GetYaxis()->SetLimits(zmin, zmax);
1186 if(
fVerbose) cout <<
"Refresh stt" << endl;
1188 if(
fVerbose) cout <<
"Refresh pixel" << endl;
1190 if(
fVerbose) cout <<
"Refresh strip" << endl;
1192 if(
fVerbose) cout <<
"Refresh stop" << endl;
1209 if(
huv == NULL)
huv =
new TH2F(
"huv",
"uv plane", 100, x1, y1, 100, x2, y2);
1212 huv->GetXaxis()->SetLimits(x1, y1);
1213 huv->GetYaxis()->SetLimits(x2, y2);
1250 TArc *arc =
new TArc(u, v, r);
1251 arc->SetFillStyle(0);
1255 TMarker *mrk =
new TMarker(u, v, marker);
1281 cluster.
AddHit(firsthit);
1295 for(
int jhit = 0; jhit < cluster.
GetNofHits(); jhit++) {
1299 if(*hit == *clushit) {
1305 if(!success)
continue;
1345 double phimin = 400, phimax = -1, zmin = 1000, zmax = -1;
1352 if(hit->
IsSttSkew() == kFALSE)
continue;
1360 TVector3 first = tube->
GetPosition() + wireDirection * halflength;
1361 TVector3 second = tube->
GetPosition() - wireDirection * halflength;
1372 double m1 = (first - second).
Y()/(first - second).
X();
1373 double q1 = first.Y() - m1 * first.X();
1376 TVector2 intersection1, intersection2;
1379 if(nofintersections == 0)
continue;
1380 if(nofintersections >= 2) {
1381 cout <<
"ERROR: MORE THAN 1 INTERSECTION!!" << endl;
1388 TLine *l =
new TLine(first.X(), first.Y(), second.X(), second.Y());
1389 l->SetLineColor(kBlue);
1392 TMarker *mrk =
new TMarker(intersection1.X(), intersection1.Y(), 20);
1393 mrk->SetMarkerColor(kBlue);
1411 double beta = wireDirection.Phi();
1416 TVector2 rottangent(rtx, rty);
1417 rottangent = rottangent.Unit();
1428 Double_t rotm = rottangent.Y()/rottangent.X();
1438 x0a = (-rotp +
TMath::Sqrt(b * b + a * a * rotm * rotm)) / rotm;
1439 x0b = (-rotp -
TMath::Sqrt(b * b + a * a * rotm * rotm)) / rotm;
1442 double intxa = (x0a * b * b - rotm * rotp * a *
a) / (b * b + rotm * rotm * a * a);
1443 double intya = rotm * intxa + rotp;
1444 double intxb = (x0b * b * b - rotm * rotp * a *
a) / (b * b + rotm * rotm * a * a);
1445 double intyb = rotm * intxb + rotp;
1472 double y0a = y0anew;
1474 double y0b = y0bnew;
1480 TEllipse *ell1 =
new TEllipse(x0a, y0a, a, b, 0, 360, -beta);
1481 ell1->SetFillStyle(0);
1482 ell1->SetLineColor(4);
1484 TEllipse *ell2 =
new TEllipse(x0b, y0b, a, b, 0, 360, -beta);
1485 ell2->SetFillStyle(0);
1486 ell2->SetLineColor(6);
1489 TMarker *mrkinta =
new TMarker(intxa, intya, 20);
1490 mrkinta->SetMarkerColor(4);
1491 mrkinta->Draw(
"SAME");
1492 TMarker *mrkintb =
new TMarker(intxb, intyb, 20);
1493 mrkintb->SetMarkerColor(6);
1494 mrkintb->Draw(
"SAME");
1501 Double_t t = ((x0a + y0a) - (first.X() + first.Y())) / ((second.X() - first.X()) + (second.Y() - first.Y()));
1502 Double_t z0a = first.Z() + (second.Z() - first.Z()) * t;
1505 t = ((x0b + y0b) - (first.X() + first.Y())) / ((second.X() - first.X()) + (second.Y() - first.Y()));
1506 Double_t z0b = first.Z() + (second.Z() - first.Z()) * t;
1508 TVector3 center1(x0a, y0a, z0a);
1509 TVector3 center2(x0b, y0b, z0b);
1516 TLine *linezx =
new TLine(first.X(), first.Z(), second.X(), second.Z());
1517 linezx->Draw(
"SAME");
1518 TMarker *mrkza =
new TMarker(x0a, z0a, 20);
1519 mrkza->SetMarkerColor(4);
1520 mrkza->Draw(
"SAME");
1521 TMarker *mrkzb =
new TMarker(x0b, z0b, 20);
1522 mrkzb->SetMarkerColor(6);
1523 mrkzb->Draw(
"SAME");
1528 double dx = intxa - x0a;
1529 double dy = intya - y0a;
1530 TVector3 dxdy(dx, dy, 0.0);
1532 TVector3 tfirst = first + dxdy;
1533 TVector3 tsecond = second + dxdy;
1535 t = ((intxa + intya) - (tfirst.X() + tfirst.Y())) / ((tsecond.X() - tfirst.X()) + (tsecond.Y() - tfirst.Y()));
1536 double intza = tfirst.Z() + (tsecond.Z() - tfirst.Z()) * t;
1540 TLine *linezx1 =
new TLine(tfirst.X(), tfirst.Z(), tsecond.X(), tsecond.Z());
1541 linezx1->SetLineStyle(1);
1542 linezx1->Draw(
"SAME");
1543 TMarker *mrkza1 =
new TMarker(intxa, intza, 20);
1544 mrkza1->SetMarkerColor(kBlue - 9);
1545 mrkza1->Draw(
"SAME");
1549 tfirst = first - dxdy;
1550 tsecond = second - dxdy;
1552 t = ((intxb + intyb) - (tfirst.X() + tfirst.Y())) / ((tsecond.X() - tfirst.X()) + (tsecond.Y() - tfirst.Y()));
1553 double intzb = tfirst.Z() + (tsecond.Z() - tfirst.Z()) * t;
1555 TVector3 fin_intersection1(intxa, intya, intza);
1556 TVector3 fin_intersection2(intxb, intyb, intzb);
1561 TLine *linezx2 =
new TLine(tfirst.X(), tfirst.Z(), tsecond.X(), tsecond.Z());
1562 linezx2->SetLineStyle(1);
1563 linezx2->Draw(
"SAME");
1564 TMarker *mrkzb1 =
new TMarker(intxb, intzb, 20);
1565 mrkzb1->SetMarkerColor(kMagenta - 7);
1566 mrkzb1->Draw(
"SAME");
1575 double phi1 = track->
ComputePhi(fin_intersection1);
1576 double phi2 = track->
ComputePhi(fin_intersection2);
1578 PndTrkSkewHit *skewhit =
new PndTrkSkewHit(*hit, trackID, center1, fin_intersection1, phi1, center2, fin_intersection2, phi2, a, b, -1, beta);
1580 skewhitlist.
AddHit(skewhit);
1598 double phimin = 400, phimax = -1, zmin = 1000, zmax = -1;
1600 for(
int ihit = 0; ihit < skewhitlist->
GetNofHits(); ihit++) {
1602 if(!skewhit)
continue;
1606 double phi1 = skewhit->
GetPhi1();
1607 double phi2 = skewhit->
GetPhi2();
1609 if(phi1 < phimin) phimin = phi1;
1610 if(phi2 < phimin) phimin = phi2;
1611 if(fin_intersection1.Z() < zmin) zmin = fin_intersection1.Z();
1612 if(fin_intersection2.Z() < zmin) zmin = fin_intersection2.Z();
1614 if(phi1 > phimax) phimax = phi1;
1615 if(phi2 > phimax) phimax = phi2;
1616 if(fin_intersection1.Z() > zmax) zmax = fin_intersection1.Z();
1617 if(fin_intersection2.Z() > zmax) zmax = fin_intersection2.Z();
1632 hzphi->SetXTitle(
"#phi");
1633 hzphi->SetYTitle(
"#z");
1639 for(
int ihit = 0; ihit < skewhitlist->
GetNofHits(); ihit++) {
1641 if(!skewhit)
continue;
1646 double phi1 = skewhit->
GetPhi1();
1647 double phi2 = skewhit->
GetPhi2();
1649 TLine *linezphi =
new TLine(phi1, fin_intersection1.Z(), phi2, fin_intersection2.Z());
1651 linezphi->SetLineStyle(1);
1652 linezphi->Draw(
"SAME");
1654 TMarker *mrkzphi1 =
new TMarker(phi1, fin_intersection1.Z(), 20);
1657 mrkzphi1->SetMarkerColor(kBlue - 9);
1658 mrkzphi1->Draw(
"SAME");
1660 TMarker *mrkzphi2 =
new TMarker(phi2, fin_intersection2.Z(), 20);
1662 mrkzphi2->SetMarkerColor(kMagenta - 7);
1663 mrkzphi2->Draw(
"SAME");
1671 TH1F hz(
"hz",
"z", (zmax - zmin)/10., zmin, zmax);
1672 for(
int ihit = 0; ihit < skewhitlist->
GetNofHits(); ihit++) {
1674 if(!skewhit)
continue;
1677 hz.Fill(fin_intersection1.Z());
1678 hz.Fill(fin_intersection2.Z());
1680 int maxbinz = hz.GetMaximumBin();
1681 double mostprobZ = hz.GetBinCenter(maxbinz);
1687 for(
int ihit = 0; ihit < skewhitlist->
GetNofHits(); ihit++) {
1689 if(!skewhit)
continue;
1692 double phi1 = skewhit->
GetPhi1();
1693 double phi2 = skewhit->
GetPhi2();
1695 if(
fabs(fin_intersection1.Z() - mostprobZ) > 30. &&
fabs(fin_intersection2.Z() - mostprobZ) > 30.) {
1700 tmpskewhitlist.
AddHit(skewhit);
1702 tmpskewhitlist.
Sort();
1703 return tmpskewhitlist;
1712 Int_t size = clref1.GetEntriesFast();
1716 size = clref2.GetEntriesFast();
1720 cout <<
"MOM FIRST: TOT, PT, PL " << outputtrack->
GetParamFirst().GetMomentum().Mag() <<
" " << outputtrack->
GetParamFirst().GetMomentum().Perp() <<
" " << outputtrack->
GetParamFirst().GetMomentum().Z() << endl;
1721 cout <<
"MOM LAST: TOT, PT, PL " << outputtrack->
GetParamLast().GetMomentum().Mag() <<
" " << outputtrack->
GetParamLast().GetMomentum().Perp() <<
" " << outputtrack->
GetParamLast().GetMomentum().Z() << endl;
1733 cout <<
"Z0, TANL " << track->
GetZ0() <<
" " << track->
GetTanL() << endl;
1734 cout <<
"CHARGE " << track->
GetCharge() << endl;
1747 if(ntot == 0)
return NULL;
1753 for(
int jhit = 0; jhit < ntot; jhit++) {
1759 if(
fVerbose > 1) cout <<
"STT hit " << jhit <<
"already used " << endl;
1768 if(tmphitid == -1)
return NULL;
1771 if(
fVerbose > 1) cout <<
"STT REFERENCE HIT " << tmphitid <<
" " << refhit->
GetIsochrone() << endl;
1785 if(
fVerbose > 1) cout <<
"already used V" << endl;
1791 if(tmphitid == -1)
return NULL;
1793 if(
fVerbose > 1) cout <<
"MVD PIXEL REFERENCE HIT " << refhit->
GetHitID() << endl;
1806 if(
fVerbose > 1) cout <<
"already used V" << endl;
1812 if(tmphitid == -1)
return NULL;
1814 if(
fVerbose > 1) cout <<
"MVD STRIP REFERENCE HIT " << refhit->
GetHitID() << endl;
1823 if(refhit != NULL)
return refhit;
1834 if(refhit != NULL)
return refhit;
1875 if(
fVerbose > 1) cout <<
"%%%%%%%%%%%%%%%%%%%% XY FINDER %%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
1908 bool alreadythere =
false;
1912 if(
fVerbose > 1) cout <<
"MAXPEAK " << maxpeak <<
", BREAK NOW! " << endl;
1916 for(
int ialready = 0; ialready <
fFoundPeaks.size(); ialready++) {
1917 std::pair<double, double> foundthetar =
fFoundPeaks.at(ialready);
1918 double foundtheta = foundthetar.first;
1919 double foundr = foundthetar.second;
1921 if(theta_max == foundtheta && r_max == foundr) {
1924 alreadythere =
true;
1925 if(
fVerbose > 0) cout <<
"OH NO! THIS PEAK IS ALREADY THERE" << endl;
1930 if(alreadythere ==
false) {
1931 std::pair<double, double>
tr(theta_max, r_max);
1944 if(mode == 0 && alreadythere ==
true) {
1945 cout <<
"THIS PEAK IS ALREADY THERE" << endl;
1955 TMarker *mrk =
new TMarker(theta_max, r_max, 29);
1986 for(
int ihit = 0; ihit < mvdpixcluster.
GetNofHits(); ihit++) {
1992 if(layerID%2 == 0) rightvotes++;
1997 for(
int ihit = 0; ihit < mvdstrcluster.
GetNofHits(); ihit++) {
2003 if(layerID%2 == 0) rightvotes++;
2008 for(
int ihit = 0; ihit < sttcluster.
GetNofHits(); ihit++) {
2010 int layerID = -999, tubeID = hit->
GetTubeID(), sectorID = -999;
2016 if(sectorID < 3) rightvotes++;
2021 for(
int ihit = 0; ihit < cluster.
GetNofHits(); ihit++) {
2027 for(
int ihit = 0; ihit < cluster.
GetNofHits(); ihit++) {
2040 for(
int ihit = 0; ihit < mvdpixcluster.
GetNofHits(); ihit++) {
2047 if((leftvotes > rightvotes) && (layerID%2 == 0)) {
2051 else if((leftvotes < rightvotes) && (layerID%2 != 0)) {
2062 cout <<
"WAITING" << endl;
2068 for(
int ihit = 0; ihit < mvdstrcluster.
GetNofHits(); ihit++) {
2073 if((leftvotes > rightvotes) && (layerID%2 == 0)) {
2077 else if((leftvotes < rightvotes) && (layerID%2 != 0)) {
2093 for(
int ihit = 0; ihit < sttcluster.
GetNofHits(); ihit++) {
2095 int layerID = -999, tubeID = hit->
GetTubeID();
2102 if((leftvotes > rightvotes) && (sectorID < 3)) {
2106 else if((leftvotes < rightvotes) && (sectorID >= 3)) {
2119 int neighboringcounter = 0;
2120 for(
int ohit = 0; ohit < sttcluster.
GetNofHits(); ohit++) {
2121 if(ihit == ohit)
continue;
2125 for(
int nhit = 0;
nhit < neighboring.GetSize();
nhit++) {
2126 if(otherhitID == neighboring.At(
nhit)) neighboringcounter++;
2137 if(layerID != 0 && layerID != 7 && layerID != 8 && ihit != sttcluster.
GetNofHits() - 1 && neighboringcounter == 1) {
2145 if(neighboringcounter == 0) {
2147 deletioncluster.
AddHit(hit);
2173 for(
int ihit = 0; ihit < cluster.
GetNofHits(); ihit++) {
2176 for(
int jhit = 0; jhit < deletioncluster.
GetNofHits(); jhit++) {
2186 if(!stop) finalcluster.
AddHit(hit);
2189 return finalcluster;
2196 for(
int ihit = 0; ihit < cluster->
GetNofHits(); ihit++) {
2199 cleancluster->
AddHit(hit);
2207 double distance =
fabs(fitm * phi - position.Z() + fitp )/
sqrt(fitm * fitm + 1);
2211 if(distance < 1) cleancluster->
AddHit(hit);
2214 if(distance < 5) cleancluster->
AddHit(hit);
2218 return cleancluster;
2230 hzphi->SetXTitle(
"#phi");
2231 hzphi->SetYTitle(
"#z");
2241 double refiso = 1000;
2242 for(
int ihit = 0; ihit < cluster->
GetNofHits(); ihit++) {
2243 hit = cluster->
GetHit(ihit);
2253 if(iter != 0) refhit =
hit;
2257 if(iter != 0 && refhit == NULL && hit->
GetIsochrone() < refiso) refhit = hit;
2264 TMarker *mrkfoundzphi = NULL;
2266 mrkfoundzphi =
new TMarker(phi, position.Z(), 21);
2267 if(iter == 0) mrkfoundzphi->SetMarkerColor(kOrange);
2268 else mrkfoundzphi->SetMarkerColor(4);
2271 mrkfoundzphi =
new TMarker(phi, position.Z(), 20);
2272 if(iter == 0) mrkfoundzphi->SetMarkerColor(kGreen);
2273 else mrkfoundzphi->SetMarkerColor(4);
2275 mrkfoundzphi->Draw(
"SAME");
2293 TLine *l22 =
new TLine(-1000, -1000 * fitm + fitp, 1000, 1000 * fitm + fitp);
2294 if(iter == 0) l22->SetLineColor(3);
2295 else if(iter == 1) l22->SetLineColor(4);
2311 TH1F hresiduals(
"hresiduals",
"residuals in z", 20, -5, 5);
2313 for(
int ihit = 0; ihit < cluster->
GetNofHits(); ihit++) {
2323 double distance = fitm * phi + fitp - position.Z();
2325 hresiduals.Fill(distance);
2331 cout <<
"residuals";
2338 return hresiduals.GetMean();
2343 for(
int ihit = 0; ihit < cluster->
GetNofHits(); ihit++) {
2350 double newz = position.Z() - deltaz;
2359 TVector3 first = tube->
GetPosition() + wireDirection * halflength;
2360 TVector3 second = tube->
GetPosition() - wireDirection * halflength;
2363 double newx = position.X();
2364 double newy = position.Y();
2365 if((second.X() - first.X()) != 0) {
2366 m = (second.Z() - first.Z())/(second.X() - first.X());
2367 p = position.Z() - m * position.X();
2368 newx = (newz -
p)/m;
2371 if((second.Y() - first.Y()) != 0) {
2373 m = (second.Z() - first.Z())/(second.Y() - first.Y());
2374 p = position.Z() - m * position.Y();
2375 newy = (newz -
p)/m;
2385 TMarker *mrk =
new TMarker(newx, newy, 6);
2386 mrk->SetMarkerColor(kOrange);
2391 cout <<
"old " << position.X() <<
" " << position.Y() <<
" " << position.Z() << endl;
2392 cout <<
"new " << newx <<
" " << newy <<
" " << newz << endl;
Bool_t DoesRealHitBelong(PndTrkHit *hit, double x0, double y0, double R)
PndTrkCluster Cleanup(PndTrkCluster cluster)
void Replace(PndTrkHit *hit)
Int_t ExtractLegendre(Int_t mode, double &theta_max, double &r_max)
Double_t fStt_ConfDistLimit
void LightCluster(PndTrkCluster *cluster)
void DrawHits(PndTrkHitList *hitlist)
void AddTCA(Int_t detID, TClonesArray *array)
int FindMvdLayer(int sensorID)
Bool_t DoesConfHitBelong(PndTrkConformalHit *hit, double fitm, double fitp)
PndTrkCluster CleanUpSkewHitList(PndTrkCluster *skewhitlist)
PndTrack ConvertToPndTrack()
friend F32vec4 sqrt(const F32vec4 &a)
PndTrkSttHitList * Instanciate()
PndTrkCluster CreateClusterByMixedDistance(double fitm, double fitq)
PndSttMapCreator * fMapper
void DrawGeometryConf(double x1, double y1, double x2, double y2)
static const UInt_t success
static T Sqrt(const T &x)
PndTrkHit * FindSttReferenceHit(int isec=-1)
PndTrkCluster CreateSttCluster(PndTrkHit *firsthit)
PndTrkCluster GetCluster()
void SetTanL(double tanl)
PndTrkCluster CreateClusterByConfDistance(double fitm, double fitq)
PndTrkCluster CreateClusterByDistance(Int_t mode, double fitm, double fitq)
virtual void Exec(Option_t *opt)
PndTrkConformalHitList * conformalhitlist
Double_t fMvdPix_RealDistLimit
void SetPhi(Double_t phi)
Double_t fMvdStr_ConfDistLimit
int GetNofHitsInSector(int isec)
PndGeoSttPar * fSttParameters
void SetSortVariable(Double_t sortvar)
void AddHit(PndTrkHit *hit)
TClonesArray * fMvdPixelHitArray
PndTrkHit * GetHitFromSector(int ihit, int isec)
double CorrectZ(PndTrkCluster *cluster, double deltaz, double fitm, double fitp)
PndTrkHit * GetHit(int index)
TVector3 GetIntersection2()
PndTrkConformalTransform * conform
PndTrkCluster * CleanupZPhiFit(PndTrkCluster *cluster, double fitm, double fitp)
void SetIRegion(int iregion)
PndTrkHit * GetHit(int index)
void AddCluster(PndTrkCluster *cluster)
void RegisterTrack(PndTrkTrack *track)
Double_t ComputePhi(TVector3 hit)
PndTrkSdsHitList * mvdstrhitlist
TClonesArray * fMvdStripHitArray
Double_t fStt_RealDistLimit
std::vector< std::pair< double, double > > fFoundPeaks
PndTrkCluster GetSttParallelHitList()
void FromConformalToRealTrack(double fitm, double fitp, double &x0, double &y0, double &R)
TClonesArray * fTrackArray
PndTrkCluster CreateSkewHitList(PndTrkTrack *track)
PndTrackCand GetTrackCand()
char fMvdPixelBranch[200]
Double_t GetDistance(PndTrkHit *fromhit)
TArrayI GetNeighborings()
PndTrkSdsHitList * InstanciateStrip()
PndTrkCluster CreateClusterByRealDistance(double xc0, double yc0, double R0)
Int_t ApplyLegendre(double &theta_max, double &r_max)
void Draw(Color_t color=kBlack)
void SetPosition(TVector3 pos)
FairTrackParP GetParamLast()
virtual InitStatus Init()
TClonesArray * FillTubeArray()
PndTrkLegendreTransform * legendre
void PrintSector(int isec)
char fMvdStripBranch[200]
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()
void DrawZGeometry(int whichone=1, double phimin=0, double phimax=360, double zmin=-43, double zmax=113)
PndTrkSttHitList * stthitlist
Double_t GetXYDistanceFromTrack(double x0, double y0, double R)
Bool_t IsSttAssociate(PndTrkHit *hit1, PndTrkHit *hit2)
int hit(Int_t nEvents=0, TString inFile="sim.root", TString parFile="par.root", TString inDigi="digi.root", TString outFile="hit.root", Int_t timeBased=0)
Double_t fMvdStr_RealDistLimit
PndTrkCluster GetMvdPixelHitList()
void ComputeTraAndRot(PndTrkHit *hit, Double_t &delta, Double_t trasl[2])
Bool_t DoesContain(PndTrkHit *hit)
PndTrkHit * FindMvdStripReferenceHit()
TVector3 GetIntersection1()
Double_t GetXYDistance(PndTrkHit *fromhit)
Bool_t StraightLineFit(Double_t &fitm, Double_t &fitp)
void DrawConfHit(double x, double y, double r, int marker=2)
double ComputeZRediduals(PndTrkCluster *cluster, double fitm, double fitp)
PndTrkHit * FindMvdReferenceHit()
Double_t fMvdPix_ConfDistLimit
PndTrkHit * FindMvdPixelReferenceHit()
Int_t FillConformalHitList(int isec=-1)
Bool_t ZPhiFit(int iter, PndTrkCluster *cluster, double &fitm, double &fitp)
TClonesArray * fSttHitArray
PndTrkSdsHitList * mvdpixhitlist
PndTrkHit * FindReferenceHit()
PndTrkCluster GetMvdStripHitList()
TVector3 GetWireDirection()
FairTrackParP GetParamFirst()
void FillLegendreHisto(Int_t mode)
TClonesArray * fTrackCandArray
void SetPointToFit(double x, double y, double sigma)
Bool_t IsRegion(Int_t iregion)
TClonesArray * fTubeArray
PndTrkSdsHitList * InstanciatePixel()
void RePrepareLegendre(PndTrkCluster *cluster)
void DrawSector(int isec, Color_t color=kBlack)