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 PndTrkLegendreTask::PndTrkLegendreTask() : 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 PndTrkLegendreTask::PndTrkLegendreTask(
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- PndTrkLegendreTask::Init: "
99 <<
"RootManager not instantiated, return!" << endl;
108 cout <<
"-W- PndTrkLegendreTask::Init: "
109 <<
"No STTHit array, return!" << endl;
116 std::cout <<
"-W- PndTrkLegendreTask::Init: " <<
"No MVD Pixel hitArray, return!" << std::endl;
123 std::cout <<
"-W- PndTrkLegendreTask::Init: " <<
"No MVD Strip hitArray, return!" << std::endl;
139 display =
new TCanvas(
"display",
"display", 0, 0, 800, 800);
160 FairRuntimeDb*
rtdb = FairRunAna::Instance()->GetRuntimeDb();
199 if(
fVerbose > 0) cout <<
"*********************** " <<
fEventCounter <<
" ***********************" << endl;
225 cout <<
"number of stt hits " <<
fSttHitArray->GetEntriesFast() << endl;
240 cout <<
" STARTING" << endl;
244 Double_t delta = 0, trasl[2] = {0., 0.};
255 std::vector< std::pair<double, double> > foundpeaks;
259 fTimer =
new TStopwatch();
290 if(
fVerbose > 1) cout << nchits <<
" " << trasl[0] <<
" " << trasl[1] <<
" " << delta << endl;
299 cout <<
"Next peak? ";
305 if(
fVerbose > 1) cout <<
"@@@@ PEAK No. " << ipeak <<
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;
311 double theta_max, r_max;
313 if(maxpeak <= 3)
break;
342 cluster = cleancluster;
352 for(
int ihit = 0; ihit < cluster.
GetNofHits(); ihit++)
367 double xi = 0, yi = 0;
369 fabs(yi1 - (fitm * xi1 + fitq)) <
fabs(yi2 - (fitm * xi2 + fitq)) ? (yi = yi1, xi = xi1) : (yi = yi2, xi = xi2);
376 TMarker *mrk =
new TMarker(xi, yi, 6);
387 TLine *line =
new TLine(-0.07, fitq + fitm * (-0.07), 0.07, fitq + fitm * (0.07));
389 TLine *line2 =
new TLine(-0.07, fitq2 + fitm2 * (-0.07), 0.07, fitq2 + fitm2 * (0.07));
390 line2->SetLineColor(2);
406 if(
fVerbose > 1) cout <<
"ADDING CLUSTER WITH " << cluster.
GetNofHits() <<
" hits " << endl;
411 if(
fVerbose > 1) cout <<
"MAXPEAK " << maxpeak << endl;
418 cout <<
"waiting 2 " << endl;
425 if(
fVerbose > 1) cout <<
"XR, YC, R: " << xc <<
" " << yc <<
" " << R << endl;
435 cout <<
"waiting 3 " << endl;
442 if(
fVerbose > 1) cout <<
"%%%%%%%%%%%%%%%%%%%% ZFINDER %%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
451 int iz = -1, jz = -1;
456 for(
int ihit = 0; ihit < skewhitlist.
GetNofHits() - 1; ihit++) {
458 if(!skewhit1)
continue;
464 if(!skewhit2)
continue;
471 double distance =
fabs(fin_intersection1[iz].
Z() - fin_intersection2[0].
Z());
474 fabs(fin_intersection1[iz].
Z() - fin_intersection2[1].
Z()) < distance ? (distance =
fabs(fin_intersection1[iz].
Z() - fin_intersection2[1].
Z()), jz = 1) : distance;
478 double distance =
fabs(fin_intersection1[0].
Z() - fin_intersection2[0].
Z());
482 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;
484 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;
486 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;
509 TMarker *mrkfoundzphi1 =
new TMarker(phi1[iz], fin_intersection1[iz].
Z(), 20);
510 mrkfoundzphi1->SetMarkerColor(kYellow);
511 mrkfoundzphi1->Draw(
"SAME");
513 TMarker *mrkfoundzphi2 =
new TMarker(phi2[jz], fin_intersection2[jz].
Z(), 20);
514 mrkfoundzphi2->SetMarkerColor(kYellow);
515 mrkfoundzphi2->Draw(
"SAME");
526 for(
int ihit = 0; ihit < mvdcluster->
GetNofHits(); ihit++) {
538 TMarker *mrkfoundzphi =
new TMarker(phi, position.Z(), 21);
539 mrkfoundzphi->SetMarkerColor(kOrange);
540 mrkfoundzphi->Draw(
"SAME");
555 if(straightlinefit = kTRUE) {
560 TLine *l222 =
new TLine(-1000, -1000 * ml + pl, 1000, 1000 * ml + pl);
571 for(
int ihit = 0; ihit < skewhitlist.
GetNofHits(); ihit++) {
573 bool doescontain = trkcluster->
DoesContain(skewhit);
575 if(doescontain == kTRUE) {
578 else trkcluster->
AddHit(skewhit);
582 double phi1 = track->
ComputePhi(intersection1);
583 double calcz1 = ml * phi1 + pl;
585 double phi2 = track->
ComputePhi(intersection2);
586 double calcz2 = ml * phi2 + pl;
595 for(
int ihit = 0; ihit < trkcluster->
GetNofHits(); ihit++) {
610 trkcluster = tmpcluster;
616 hzphi->SetXTitle(
"#phi");
617 hzphi->SetYTitle(
"#z");
623 zfit =
ZPhiFit(1, trkcluster, ml, pl);
647 for(
int ihit = 0; ihit < trkcluster2->
GetNofHits(); ihit++) {
666 if(
fVerbose > 1) cout <<
"MAXPEAK " << maxpeak << endl;
674 cout <<
"FINISH" << endl;
691 cout <<
"FINISH" << endl;
751 if(hit->
IsUsed())
continue;
762 for(
int ihit = 0; ihit < cluster->
GetNofHits(); ihit++) {
775 if(hit->
IsUsed())
continue;
798 double distlimit = 0;
799 if(detID == FairRootManager::Instance()->GetBranchId(
fMvdPixelBranch)) distlimit = 0.003;
800 else if(detID == FairRootManager::Instance()->GetBranchId(
fMvdStripBranch)) distlimit = 0.003;
801 else if(detID == FairRootManager::Instance()->GetBranchId(
fSttBranch)) {
803 else distlimit = 0.001;
809 if(dist < distlimit) {
813 arc->SetFillStyle(0);
814 arc->SetLineColor(5);
820 if(detID == FairRootManager::Instance()->GetBranchId(
fMvdPixelBranch)) mrk =
new TMarker(chit->
GetU(), chit->
GetV(), 21);
821 else if(detID == FairRootManager::Instance()->GetBranchId(
fMvdStripBranch)) mrk =
new TMarker(chit->
GetU(), chit->
GetV(), 25);
822 mrk->SetMarkerColor(5);
829 if(detID == FairRootManager::Instance()->GetBranchId(
fMvdPixelBranch)) {
832 else if(detID == FairRootManager::Instance()->GetBranchId(
fMvdStripBranch)) {
835 else if(detID == FairRootManager::Instance()->GetBranchId(
fSttBranch)) {
860 TArc *arc =
new TArc(xc0, yc0, R0);
861 arc->SetFillStyle(0);
862 arc->SetLineColor(5);
872 double distlimit = 1.5 * 0.5;
873 if(dist < distlimit){
879 arc->SetFillStyle(0);
880 arc->SetLineColor(5);
890 double distlimit = 0.5;
891 if(dist < distlimit) {
895 mrk->SetMarkerColor(5);
905 double distlimit = 0.5;
906 if(dist < distlimit){
910 mrk->SetMarkerColor(5);
936 TArc *arc =
new TArc(xc0, yc0, R0);
937 arc->SetFillStyle(0);
938 arc->SetLineColor(5);
946 double distlimit = 0.5;
947 if(dist < distlimit) {
951 mrk->SetMarkerColor(5);
961 double distlimit = 0.5;
962 if(dist < distlimit){
966 mrk->SetMarkerColor(5);
981 if(detID != FairRootManager::Instance()->GetBranchId(
fSttBranch))
continue;
982 double distlimit = 0;
984 else distlimit = 0.001;
987 if(dist < distlimit) {
993 arc->SetFillStyle(0);
994 arc->SetLineColor(5);
1014 if(detID == FairRootManager::Instance()->GetBranchId(
fMvdPixelBranch)) {
1017 else if(detID == FairRootManager::Instance()->GetBranchId(
fMvdStripBranch)) {
1020 else if(detID == FairRootManager::Instance()->GetBranchId(
fSttBranch)) {
1030 if(detID == FairRootManager::Instance()->GetBranchId(
fMvdPixelBranch)) {
1033 else if(detID == FairRootManager::Instance()->GetBranchId(
fMvdStripBranch)) {
1036 else if(detID == FairRootManager::Instance()->GetBranchId(
fSttBranch)) {
1066 else if(mode == 2) {
1076 arc->SetFillStyle(0);
1077 arc->SetLineColor(5);
1084 mrk->SetMarkerColor(5);
1092 if(accept == kTRUE) {
1105 ycrot0 = 1 / (2 * fitp);
1106 xcrot0 = - fitm * ycrot0;
1107 R =
sqrt(xcrot0 * xcrot0 + ycrot0 * ycrot0);
1118 if(
hxy == NULL)
hxy =
new TH2F(
"hxy",
"xy plane", 100, -43, 43, 100, -43, 43);
1129 if(
hxz == NULL)
hxz =
new TH2F(
"hxz",
"xz plane", 100, -43, 43, 100, -43, 113);
1134 if(
hzphi == NULL)
hzphi =
new TH2F(
"hzphi",
"z - phi plane", phimax - phimin, phimin, phimax, zmax - zmin, zmin, zmax);
1137 hzphi->GetXaxis()->SetLimits(phimin, phimax);
1138 hzphi->GetYaxis()->SetLimits(zmin, zmax);
1159 if(
fVerbose) cout <<
"Refresh stt" << endl;
1161 if(
fVerbose) cout <<
"Refresh pixel" << endl;
1163 if(
fVerbose) cout <<
"Refresh strip" << endl;
1165 if(
fVerbose) cout <<
"Refresh stop" << endl;
1182 if(
huv == NULL)
huv =
new TH2F(
"huv",
"uv plane", 100, x1, y1, 100, x2, y2);
1185 huv->GetXaxis()->SetLimits(x1, y1);
1186 huv->GetYaxis()->SetLimits(x2, y2);
1223 TArc *arc =
new TArc(u, v, r);
1224 arc->SetFillStyle(0);
1228 TMarker *mrk =
new TMarker(u, v, marker);
1254 cluster.
AddHit(firsthit);
1268 for(
int jhit = 0; jhit < cluster.
GetNofHits(); jhit++) {
1272 if(*hit == *clushit) {
1278 if(!success)
continue;
1318 double phimin = 400, phimax = -1, zmin = 1000, zmax = -1;
1325 if(hit->
IsSttSkew() == kFALSE)
continue;
1333 TVector3 first = tube->
GetPosition() + wireDirection * halflength;
1334 TVector3 second = tube->
GetPosition() - wireDirection * halflength;
1347 double m1 = (first - second).
Y()/(first - second).
X();
1348 double q1 = first.Y() - m1 * first.X();
1351 TVector2 intersection1, intersection2;
1354 if(nofintersections == 0)
continue;
1355 if(nofintersections >= 2) {
1356 cout <<
"ERROR: MORE THAN 1 INTERSECTION!!" << endl;
1363 TLine *l =
new TLine(first.X(), first.Y(), second.X(), second.Y());
1364 l->SetLineColor(kBlue);
1367 TMarker *mrk =
new TMarker(intersection1.X(), intersection1.Y(), 20);
1368 mrk->SetMarkerColor(kBlue);
1386 double beta = wireDirection.Phi();
1391 TVector2 rottangent(rtx, rty);
1392 rottangent = rottangent.Unit();
1403 Double_t rotm = rottangent.Y()/rottangent.X();
1413 x0a = (-rotp +
TMath::Sqrt(b * b + a * a * rotm * rotm)) / rotm;
1414 x0b = (-rotp -
TMath::Sqrt(b * b + a * a * rotm * rotm)) / rotm;
1417 double intxa = (x0a * b * b - rotm * rotp * a *
a) / (b * b + rotm * rotm * a * a);
1418 double intya = rotm * intxa + rotp;
1419 double intxb = (x0b * b * b - rotm * rotp * a *
a) / (b * b + rotm * rotm * a * a);
1420 double intyb = rotm * intxb + rotp;
1447 double y0a = y0anew;
1449 double y0b = y0bnew;
1455 TEllipse *ell1 =
new TEllipse(x0a, y0a, a, b, 0, 360, -beta);
1456 ell1->SetFillStyle(0);
1457 ell1->SetLineColor(4);
1459 TEllipse *ell2 =
new TEllipse(x0b, y0b, a, b, 0, 360, -beta);
1460 ell2->SetFillStyle(0);
1461 ell2->SetLineColor(6);
1464 TMarker *mrkinta =
new TMarker(intxa, intya, 20);
1465 mrkinta->SetMarkerColor(4);
1466 mrkinta->Draw(
"SAME");
1467 TMarker *mrkintb =
new TMarker(intxb, intyb, 20);
1468 mrkintb->SetMarkerColor(6);
1469 mrkintb->Draw(
"SAME");
1476 Double_t t = ((x0a + y0a) - (first.X() + first.Y())) / ((second.X() - first.X()) + (second.Y() - first.Y()));
1477 Double_t z0a = first.Z() + (second.Z() - first.Z()) * t;
1480 t = ((x0b + y0b) - (first.X() + first.Y())) / ((second.X() - first.X()) + (second.Y() - first.Y()));
1481 Double_t z0b = first.Z() + (second.Z() - first.Z()) * t;
1483 TVector3 center1(x0a, y0a, z0a);
1484 TVector3 center2(x0b, y0b, z0b);
1491 TLine *linezx =
new TLine(first.X(), first.Z(), second.X(), second.Z());
1492 linezx->Draw(
"SAME");
1493 TMarker *mrkza =
new TMarker(x0a, z0a, 20);
1494 mrkza->SetMarkerColor(4);
1495 mrkza->Draw(
"SAME");
1496 TMarker *mrkzb =
new TMarker(x0b, z0b, 20);
1497 mrkzb->SetMarkerColor(6);
1498 mrkzb->Draw(
"SAME");
1503 double dx = intxa - x0a;
1504 double dy = intya - y0a;
1505 TVector3 dxdy(dx, dy, 0.0);
1507 TVector3 tfirst = first + dxdy;
1508 TVector3 tsecond = second + dxdy;
1510 t = ((intxa + intya) - (tfirst.X() + tfirst.Y())) / ((tsecond.X() - tfirst.X()) + (tsecond.Y() - tfirst.Y()));
1511 double intza = tfirst.Z() + (tsecond.Z() - tfirst.Z()) * t;
1515 TLine *linezx1 =
new TLine(tfirst.X(), tfirst.Z(), tsecond.X(), tsecond.Z());
1516 linezx1->SetLineStyle(1);
1517 linezx1->Draw(
"SAME");
1518 TMarker *mrkza1 =
new TMarker(intxa, intza, 20);
1519 mrkza1->SetMarkerColor(kBlue - 9);
1520 mrkza1->Draw(
"SAME");
1524 tfirst = first - dxdy;
1525 tsecond = second - dxdy;
1527 t = ((intxb + intyb) - (tfirst.X() + tfirst.Y())) / ((tsecond.X() - tfirst.X()) + (tsecond.Y() - tfirst.Y()));
1528 double intzb = tfirst.Z() + (tsecond.Z() - tfirst.Z()) * t;
1530 TVector3 fin_intersection1(intxa, intya, intza);
1531 TVector3 fin_intersection2(intxb, intyb, intzb);
1536 TLine *linezx2 =
new TLine(tfirst.X(), tfirst.Z(), tsecond.X(), tsecond.Z());
1537 linezx2->SetLineStyle(1);
1538 linezx2->Draw(
"SAME");
1539 TMarker *mrkzb1 =
new TMarker(intxb, intzb, 20);
1540 mrkzb1->SetMarkerColor(kMagenta - 7);
1541 mrkzb1->Draw(
"SAME");
1550 double phi1 = track->
ComputePhi(fin_intersection1);
1551 double phi2 = track->
ComputePhi(fin_intersection2);
1553 PndTrkSkewHit *skewhit =
new PndTrkSkewHit(*hit, trackID, center1, fin_intersection1, phi1, center2, fin_intersection2, phi2, a, b, -1, beta);
1555 skewhitlist.
AddHit(skewhit);
1573 double phimin = 400, phimax = -1, zmin = 1000, zmax = -1;
1575 for(
int ihit = 0; ihit < skewhitlist->
GetNofHits(); ihit++) {
1577 if(!skewhit)
continue;
1581 double phi1 = skewhit->
GetPhi1();
1582 double phi2 = skewhit->
GetPhi2();
1584 if(phi1 < phimin) phimin = phi1;
1585 if(phi2 < phimin) phimin = phi2;
1586 if(fin_intersection1.Z() < zmin) zmin = fin_intersection1.Z();
1587 if(fin_intersection2.Z() < zmin) zmin = fin_intersection2.Z();
1589 if(phi1 > phimax) phimax = phi1;
1590 if(phi2 > phimax) phimax = phi2;
1591 if(fin_intersection1.Z() > zmax) zmax = fin_intersection1.Z();
1592 if(fin_intersection2.Z() > zmax) zmax = fin_intersection2.Z();
1607 hzphi->SetXTitle(
"#phi");
1608 hzphi->SetYTitle(
"#z");
1614 for(
int ihit = 0; ihit < skewhitlist->
GetNofHits(); ihit++) {
1616 if(!skewhit)
continue;
1621 double phi1 = skewhit->
GetPhi1();
1622 double phi2 = skewhit->
GetPhi2();
1624 TLine *linezphi =
new TLine(phi1, fin_intersection1.Z(), phi2, fin_intersection2.Z());
1626 linezphi->SetLineStyle(1);
1627 linezphi->Draw(
"SAME");
1629 TMarker *mrkzphi1 =
new TMarker(phi1, fin_intersection1.Z(), 20);
1632 mrkzphi1->SetMarkerColor(kBlue - 9);
1633 mrkzphi1->Draw(
"SAME");
1635 TMarker *mrkzphi2 =
new TMarker(phi2, fin_intersection2.Z(), 20);
1637 mrkzphi2->SetMarkerColor(kMagenta - 7);
1638 mrkzphi2->Draw(
"SAME");
1646 TH1F hz(
"hz",
"z", (zmax - zmin)/10., zmin, zmax);
1647 for(
int ihit = 0; ihit < skewhitlist->
GetNofHits(); ihit++) {
1649 if(!skewhit)
continue;
1652 hz.Fill(fin_intersection1.Z());
1653 hz.Fill(fin_intersection2.Z());
1655 int maxbinz = hz.GetMaximumBin();
1656 double mostprobZ = hz.GetBinCenter(maxbinz);
1662 for(
int ihit = 0; ihit < skewhitlist->
GetNofHits(); ihit++) {
1664 if(!skewhit)
continue;
1667 double phi1 = skewhit->
GetPhi1();
1668 double phi2 = skewhit->
GetPhi2();
1670 if(
fabs(fin_intersection1.Z() - mostprobZ) > 30. &&
fabs(fin_intersection2.Z() - mostprobZ) > 30.) {
1675 tmpskewhitlist.
AddHit(skewhit);
1677 tmpskewhitlist.
Sort();
1678 return tmpskewhitlist;
1687 Int_t size = clref1.GetEntriesFast();
1691 size = clref2.GetEntriesFast();
1695 cout <<
"MOM FIRST: TOT, PT, PL " << outputtrack->
GetParamFirst().GetMomentum().Mag() <<
" " << outputtrack->
GetParamFirst().GetMomentum().Perp() <<
" " << outputtrack->
GetParamFirst().GetMomentum().Z() << endl;
1696 cout <<
"MOM LAST: TOT, PT, PL " << outputtrack->
GetParamLast().GetMomentum().Mag() <<
" " << outputtrack->
GetParamLast().GetMomentum().Perp() <<
" " << outputtrack->
GetParamLast().GetMomentum().Z() << endl;
1708 cout <<
"Z0, TANL " << track->
GetZ0() <<
" " << track->
GetTanL() << endl;
1709 cout <<
"CHARGE " << track->
GetCharge() << endl;
1727 if(
fVerbose > 1) cout <<
"STT hit " << jhit <<
"already used " << endl;
1735 if(tmphitid == -1)
return NULL;
1738 if(
fVerbose > 1) cout <<
"STT REFERENCE HIT " << tmphitid <<
" " << refhit->
GetIsochrone() << endl;
1751 if(
fVerbose > 1) cout <<
"already used V" << endl;
1757 if(tmphitid == -1)
return NULL;
1759 if(
fVerbose > 1) cout <<
"MVD PIXEL REFERENCE HIT " << refhit->
GetHitID() << endl;
1772 if(
fVerbose > 1) cout <<
"already used V" << endl;
1778 if(tmphitid == -1)
return NULL;
1780 if(
fVerbose > 1) cout <<
"MVD STRIP REFERENCE HIT " << refhit->
GetHitID() << endl;
1789 if(refhit != NULL)
return refhit;
1800 if(refhit != NULL)
return refhit;
1841 if(
fVerbose > 1) cout <<
"%%%%%%%%%%%%%%%%%%%% XY FINDER %%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
1874 bool alreadythere =
false;
1878 if(
fVerbose > 1) cout <<
"MAXPEAK " << maxpeak <<
", BREAK NOW! " << endl;
1882 for(
int ialready = 0; ialready <
fFoundPeaks.size(); ialready++) {
1883 std::pair<double, double> foundthetar =
fFoundPeaks.at(ialready);
1884 double foundtheta = foundthetar.first;
1885 double foundr = foundthetar.second;
1887 if(theta_max == foundtheta && r_max == foundr) {
1890 alreadythere =
true;
1891 if(
fVerbose > 0) cout <<
"OH NO! THIS PEAK IS ALREADY THERE" << endl;
1896 if(alreadythere ==
false) {
1897 std::pair<double, double>
tr(theta_max, r_max);
1910 if(mode == 0 && alreadythere ==
true) {
1911 cout <<
"THIS PEAK IS ALREADY THERE" << endl;
1921 TMarker *mrk =
new TMarker(theta_max, r_max, 29);
1952 for(
int ihit = 0; ihit < mvdpixcluster.
GetNofHits(); ihit++) {
1958 if(layerID%2 == 0) rightvotes++;
1963 for(
int ihit = 0; ihit < mvdstrcluster.
GetNofHits(); ihit++) {
1969 if(layerID%2 == 0) rightvotes++;
1974 for(
int ihit = 0; ihit < sttcluster.
GetNofHits(); ihit++) {
1976 int layerID = -999, tubeID = hit->
GetTubeID(), sectorID = -999;
1982 if(sectorID < 3) rightvotes++;
1987 for(
int ihit = 0; ihit < cluster.
GetNofHits(); ihit++) {
1993 for(
int ihit = 0; ihit < cluster.
GetNofHits(); ihit++) {
2006 for(
int ihit = 0; ihit < mvdpixcluster.
GetNofHits(); ihit++) {
2013 if((leftvotes > rightvotes) && (layerID%2 == 0)) {
2017 else if((leftvotes < rightvotes) && (layerID%2 != 0)) {
2028 cout <<
"WAITING" << endl;
2034 for(
int ihit = 0; ihit < mvdstrcluster.
GetNofHits(); ihit++) {
2039 if((leftvotes > rightvotes) && (layerID%2 == 0)) {
2043 else if((leftvotes < rightvotes) && (layerID%2 != 0)) {
2059 for(
int ihit = 0; ihit < sttcluster.
GetNofHits(); ihit++) {
2061 int layerID = -999, tubeID = hit->
GetTubeID();
2068 if((leftvotes > rightvotes) && (sectorID < 3)) {
2072 else if((leftvotes < rightvotes) && (sectorID >= 3)) {
2085 int neighboringcounter = 0;
2086 for(
int ohit = 0; ohit < sttcluster.
GetNofHits(); ohit++) {
2087 if(ihit == ohit)
continue;
2091 for(
int nhit = 0;
nhit < neighboring.GetSize();
nhit++) {
2092 if(otherhitID == neighboring.At(
nhit)) neighboringcounter++;
2103 if(layerID != 0 && layerID != 7 && layerID != 8 && ihit != sttcluster.
GetNofHits() - 1 && neighboringcounter == 1) {
2111 if(neighboringcounter == 0) {
2113 deletioncluster.
AddHit(hit);
2139 for(
int ihit = 0; ihit < cluster.
GetNofHits(); ihit++) {
2142 for(
int jhit = 0; jhit < deletioncluster.
GetNofHits(); jhit++) {
2152 if(!stop) finalcluster.
AddHit(hit);
2155 return finalcluster;
2162 for(
int ihit = 0; ihit < cluster->
GetNofHits(); ihit++) {
2165 cleancluster->
AddHit(hit);
2173 double distance =
fabs(fitm * phi - position.Z() + fitp )/
sqrt(fitm * fitm + 1);
2177 if(distance < 1) cleancluster->
AddHit(hit);
2180 if(distance < 5) cleancluster->
AddHit(hit);
2184 return cleancluster;
2196 hzphi->SetXTitle(
"#phi");
2197 hzphi->SetYTitle(
"#z");
2207 double refiso = 1000;
2208 for(
int ihit = 0; ihit < cluster->
GetNofHits(); ihit++) {
2209 hit = cluster->
GetHit(ihit);
2219 if(iter != 0) refhit =
hit;
2223 if(iter != 0 && refhit == NULL && hit->
GetIsochrone() < refiso) refhit = hit;
2230 TMarker *mrkfoundzphi = NULL;
2232 mrkfoundzphi =
new TMarker(phi, position.Z(), 21);
2233 if(iter == 0) mrkfoundzphi->SetMarkerColor(kOrange);
2234 else mrkfoundzphi->SetMarkerColor(4);
2237 mrkfoundzphi =
new TMarker(phi, position.Z(), 20);
2238 if(iter == 0) mrkfoundzphi->SetMarkerColor(kGreen);
2239 else mrkfoundzphi->SetMarkerColor(4);
2241 mrkfoundzphi->Draw(
"SAME");
2259 TLine *l22 =
new TLine(-1000, -1000 * fitm + fitp, 1000, 1000 * fitm + fitp);
2260 if(iter == 0) l22->SetLineColor(3);
2261 else if(iter == 1) l22->SetLineColor(4);
2277 TH1F hresiduals(
"hresiduals",
"residuals in z", 20, -5, 5);
2279 for(
int ihit = 0; ihit < cluster->
GetNofHits(); ihit++) {
2289 double distance = fitm * phi + fitp - position.Z();
2291 hresiduals.Fill(distance);
2297 cout <<
"residuals";
2304 return hresiduals.GetMean();
2309 for(
int ihit = 0; ihit < cluster->
GetNofHits(); ihit++) {
2316 double newz = position.Z() - deltaz;
2325 TVector3 first = tube->
GetPosition() + wireDirection * halflength;
2326 TVector3 second = tube->
GetPosition() - wireDirection * halflength;
2329 double newx = position.X();
2330 double newy = position.Y();
2331 if((second.X() - first.X()) != 0) {
2332 m = (second.Z() - first.Z())/(second.X() - first.X());
2333 p = position.Z() - m * position.X();
2334 newx = (newz -
p)/m;
2337 if((second.Y() - first.Y()) != 0) {
2339 m = (second.Z() - first.Z())/(second.Y() - first.Y());
2340 p = position.Z() - m * position.Y();
2341 newy = (newz -
p)/m;
2351 TMarker *mrk =
new TMarker(newx, newy, 6);
2352 mrk->SetMarkerColor(kOrange);
2357 cout <<
"old " << position.X() <<
" " << position.Y() <<
" " << position.Z() << endl;
2358 cout <<
"new " << newx <<
" " << newy <<
" " << newz << endl;
PndTrkHit * FindReferenceHit()
void Replace(PndTrkHit *hit)
PndTrkHit * FindMvdPixelReferenceHit()
void AddTCA(Int_t detID, TClonesArray *array)
PndTrkCluster Cleanup(PndTrkCluster cluster)
int FindMvdLayer(int sensorID)
PndTrack ConvertToPndTrack()
Int_t ExtractLegendre(Int_t mode, double &theta_max, double &r_max)
Double_t fStt_RealDistLimit
PndSttMapCreator * fMapper
PndTrkHit * FindMvdReferenceHit()
Bool_t IsSttAssociate(PndTrkHit *hit1, PndTrkHit *hit2)
void FromConformalToRealTrack(double fitm, double fitp, double &x0, double &y0, double &R)
friend F32vec4 sqrt(const F32vec4 &a)
PndTrkSttHitList * Instanciate()
static const UInt_t success
static T Sqrt(const T &x)
PndTrkSttHitList * stthitlist
void DrawConfHit(double x, double y, double r, int marker=2)
PndTrkCluster GetCluster()
PndTrkLegendreTransform * legendre
void SetTanL(double tanl)
PndGeoSttPar * fSttParameters
double ComputeZRediduals(PndTrkCluster *cluster, double fitm, double fitp)
void SetPhi(Double_t phi)
void FillLegendreHisto(Int_t mode)
void SetSortVariable(Double_t sortvar)
void AddHit(PndTrkHit *hit)
Double_t fStt_ConfDistLimit
PndTrkCluster CreateClusterByMixedDistance(double fitm, double fitq)
PndTrkHit * GetHit(int index)
TVector3 GetIntersection2()
void ComputeTraAndRot(PndTrkHit *hit, Double_t &delta, Double_t trasl[2])
TClonesArray * fMvdPixelHitArray
void SetIRegion(int iregion)
PndTrkHit * GetHit(int index)
void AddCluster(PndTrkCluster *cluster)
Double_t ComputePhi(TVector3 hit)
virtual InitStatus Init()
void RePrepareLegendre(PndTrkCluster *cluster)
void DrawZGeometry(int whichone=1, double phimin=0, double phimax=360, double zmin=-43, double zmax=113)
Int_t FillConformalHitList()
PndTrkConformalTransform * conform
void DrawGeometryConf(double x1, double y1, double x2, double y2)
PndTrkHit * FindMvdStripReferenceHit()
TClonesArray * fTubeArray
Bool_t DoesConfHitBelong(PndTrkConformalHit *hit, double fitm, double fitp)
Double_t fMvdPix_ConfDistLimit
PndTrkCluster GetSttParallelHitList()
PndTrackCand GetTrackCand()
std::vector< std::pair< double, double > > fFoundPeaks
Bool_t ZPhiFit(int iter, PndTrkCluster *cluster, double &fitm, double &fitp)
Double_t GetDistance(PndTrkHit *fromhit)
Double_t fMvdStr_RealDistLimit
TArrayI GetNeighborings()
PndTrkSdsHitList * InstanciateStrip()
void Draw(Color_t color=kBlack)
char fMvdPixelBranch[200]
char fMvdStripBranch[200]
void SetPosition(TVector3 pos)
FairTrackParP GetParamLast()
Double_t fMvdPix_RealDistLimit
TClonesArray * fTrackCandArray
TClonesArray * FillTubeArray()
void Draw(Color_t color=kBlack)
friend F32vec4 fabs(const F32vec4 &a)
PndTrkCluster CreateSkewHitList(PndTrkTrack *track)
Bool_t ConstrainedStraightLineFit(Double_t x0, Double_t y0, Double_t &fitm, Double_t &fitp)
PndTrkCluster * CleanupZPhiFit(PndTrkCluster *cluster, double fitm, double fitp)
Double_t fMvdStr_ConfDistLimit
static PndGeoHandling * Instance()
void RegisterTrack(PndTrkTrack *track)
PndTrkCluster CreateClusterByConfDistance(double fitm, double fitq)
PndTrkSdsHitList * mvdpixhitlist
Int_t ApplyLegendre(double &theta_max, double &r_max)
virtual void Exec(Option_t *opt)
TClonesArray * fSttHitArray
Double_t GetXYDistanceFromTrack(double x0, double y0, double R)
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)
PndTrkCluster GetMvdPixelHitList()
Bool_t DoesContain(PndTrkHit *hit)
TVector3 GetIntersection1()
Double_t GetXYDistance(PndTrkHit *fromhit)
TClonesArray * fTrackArray
Bool_t StraightLineFit(Double_t &fitm, Double_t &fitp)
PndTrkHit * FindSttReferenceHit()
void LightCluster(PndTrkCluster *cluster)
double CorrectZ(PndTrkCluster *cluster, double deltaz, double fitm, double fitp)
PndTrkCluster CreateClusterByRealDistance(double xc0, double yc0, double R0)
PndTrkCluster CreateClusterByDistance(Int_t mode, double fitm, double fitq)
PndTrkSdsHitList * mvdstrhitlist
Bool_t DoesRealHitBelong(PndTrkHit *hit, double x0, double y0, double R)
void DrawHits(PndTrkHitList *hitlist)
PndTrkCluster GetMvdStripHitList()
TVector3 GetWireDirection()
PndTrkCluster CreateSttCluster(PndTrkHit *firsthit)
FairTrackParP GetParamFirst()
TClonesArray * fMvdStripHitArray
PndTrkCluster CleanUpSkewHitList(PndTrkCluster *skewhitlist)
PndTrkConformalHitList * conformalhitlist
void SetPointToFit(double x, double y, double sigma)
Bool_t IsRegion(Int_t iregion)
PndTrkSdsHitList * InstanciatePixel()