#include "PndFtsHoughTrackFinder.h" ClassImp(PndFtsHoughTrackFinder); PndFtsHoughTrackFinder::PndFtsHoughTrackFinder(PndFtsHoughTrackerTask *trackerTask) : fTrackerTask(trackerTask), // Hough spaces fHoughSpaceZxLineBeforeDipole(0), fHoughspaceZxParabola(0), fHoughSpaceZxLineBehindDipole(0), fHoughspaceZyLine(0), // min peak heights fMinPeakHeightZxLineParabola(4), fMinPeakHeightZxParabola(6), fMinPeakHeightZxParabolaLine(4), fMinPeakHeightZyLine(4), // set later using tracker task if needed // fFtsHitArray(0), // fFtsBranchId(0), // fField(0), // general fSaveDebugInfo(kFALSE), fVerbose(0) { if (0==fTrackerTask){ std::cout << "PndFtsHoughTrackFinder FATAL ERROR Tracker task not set.\n"; } else { fVerbose = fTrackerTask->GetVerbose(); if(3GetSaveDebugInfo(); // fFtsHitArray = fTrackerTask->getFtsHitArrayPtr(); // fFtsBranchId = fTrackerTask->getFtsBranchId(); // fField = fTrackerTask->getMagneticFieldPtr(); } } PndFtsHoughTrackFinder::~PndFtsHoughTrackFinder() { if(3fLogger->Info(MESSAGE_ORIGIN,"Destructor of PndFtsHoughTrackFinder"); } //void PndFtsHoughTrackFinder::CreatePndTrackCands() { // //} void PndFtsHoughTrackFinder::FindTracks() { if (0 fTrackerTask->GetNFtsHits() ) { if(0fLogger->Info(MESSAGE_ORIGIN,"Skip the event, since we have too few hits in FTS"); return; } // zx plane: Straight line Hough transform before dipole static const Int_t stepsPerThetaDegLineBeforeDipole = 4; // greater number means finer scanning in theta static const Int_t thetaDegLowLineBeforeDipole = -18; // in degree static const Int_t thetaDegHighLineBeforeDipole = 18; // in degree delete fHoughSpaceZxLineBeforeDipole; fHoughSpaceZxLineBeforeDipole = new PndFtsHoughSpace( "lineBeforeDipole", stepsPerThetaDegLineBeforeDipole*(thetaDegHighLineBeforeDipole-thetaDegLowLineBeforeDipole), thetaDegLowLineBeforeDipole / 180. * meinpi, // in rad thetaDegHighLineBeforeDipole / 180. * meinpi, // in rad stepsPerThetaDegLineBeforeDipole*16, // TODO: Check values -80., // in cm // TODO: Check values 80., // in cm fZLineParabola, 0., fTrackerTask ); fHoughSpaceZxLineBeforeDipole->GetXaxis()->SetTitle("#theta [rad]"); fHoughSpaceZxLineBeforeDipole->GetYaxis()->SetTitle("x_{LP} [cm]"); // Do straight line Hough transform on non-skewed hits from stations 1+2 // try{ fHoughSpaceZxLineBeforeDipole->FillHoughSpace(); if (0GetNHits() << " hits in the line Hough space.\n"; } if (fTrackerTask->GetSaveDebugInfo()){ fTrackerTask->WriteHistogram(fHoughSpaceZxLineBeforeDipole); } // } // catch (std::runtime_error& e){ // std::cerr << "Hough Space for zx line before dipole could not be created! \n"; // std::cerr << "runtime_error: " << e.what() << '\n'; // } // find peaks for line hough space and store in vector const Int_t minHeightLineBeforeDipole = 6; std::vector trackletsLineBeforeDipole; // Call peak finder and plot the solution if it was found! if (kTRUE == fHoughSpaceZxLineBeforeDipole->FindAllPeaks(minHeightLineBeforeDipole, trackletsLineBeforeDipole)) { if (0GetName()); fTrackerTask->WriteHistogram(fHoughSpaceZxLineBeforeDipole); } } else { std::cout << "Error: Peak finder had a problem with Hough space for zx line before dipole!!!" << '\n'; } // loop over all line tracklets which were found by line HT before dipole field for (UInt_t iTrackletLine=0; iTrackletLine < trackletsLineBeforeDipole.size(); ++iTrackletLine) { const Double_t peakThetaRadLineBeforeDipole = trackletsLineBeforeDipole[iTrackletLine].getThetaRadVal(); const Double_t peakInterceptLineBeforeDipole = trackletsLineBeforeDipole[iTrackletLine].getSecondVal(); const Double_t peakThetaRadHwLineBeforeDipole = trackletsLineBeforeDipole[iTrackletLine].getThetaRadHw(); // determine where to look for parabola const Int_t stepsPerThetaDegParabola = 10; // greater number means finer scanning in theta // TODO: Rework this const Double_t thetaRadLowParabola = peakThetaRadLineBeforeDipole - peakThetaRadHwLineBeforeDipole; // in rad const Double_t thetaRadHighParabola = peakThetaRadLineBeforeDipole + peakThetaRadHwLineBeforeDipole; // in rad const Double_t thetaDegLowParabola = thetaRadLowParabola / meinpi * 180.; // in deg const Double_t thetaDegHighParabola = thetaRadHighParabola / meinpi * 180.; // in deg if (thetaRadHighParabola==thetaRadLowParabola) std::cout << "ERROR: low and high are the same for parabola!\n"; UInt_t thetaBins = ceil(stepsPerThetaDegParabola*(thetaDegHighParabola-thetaDegLowParabola)); std::cout << "event: " << fTrackerTask->GetEventNr() << "\nthetaDegLowParabola=" << thetaDegLowParabola << " thetaDegHighParabola=" << thetaDegHighParabola << " thetaBins=" << thetaBins << " peakThetaDegLineBeforeDipole=" << peakThetaRadLineBeforeDipole/meinpi*180. << " peakThetaDegHwLineBeforeDipole=" << peakThetaRadHwLineBeforeDipole/meinpi*180. << '\n'; delete fHoughspaceZxParabola; fHoughspaceZxParabola= new PndFtsHoughSpace( "parabola", thetaBins, thetaRadLowParabola, // in rad thetaRadHighParabola, // in rad stepsPerThetaDegParabola*300, // 300 is good as factor -0.015, // a.u. 0.015, // a.u. fZLineParabola, peakInterceptLineBeforeDipole, fTrackerTask ); fHoughspaceZxParabola->GetXaxis()->SetTitle("#theta [rad]"); fHoughspaceZxParabola->GetYaxis()->SetTitle("#frac{Q}{p_zx} [a.u.]"); // Do parabola hough transform (shifts FTS hits by hitshiftinx) for non-skewed hits in stations 3+4+5 // try{ fHoughspaceZxParabola->FillHoughSpace(); if (0GetNHits() << " hits in the line Hough space.\n"; } if (fTrackerTask->GetSaveDebugInfo()){ fTrackerTask->WriteHistogram(fHoughspaceZxParabola, iTrackletLine); } // } // catch (std::runtime_error& e){ // std::cerr << "Hough Space for zx parabola could not be created! \n"; // std::cerr << "runtime_error: " << e.what() << '\n'; // } // TODO: Rewrite the following conversion // Get momenta from arbitrary units to meaningful ones // pzinvpeak = 1./pzinvpeak*0.00299792458; // pzinvpeakWithBField = pzinvpeak/BMeanForParabola; // find peaks for zx parabola hough space const Int_t minHeightZxParabola = 8; std::vector zxParabolaTracklets; if (kTRUE == fHoughspaceZxParabola->FindAllPeaks(minHeightZxParabola, zxParabolaTracklets)) { if (0GetName()); } } else { std::cout << "Error: Peak finder had a problem for parabola!!!" << '\n'; } if(1GetXaxis()->SetTitle("#theta [rad]"); fHoughSpaceZxLineBehindDipole->GetYaxis()->SetTitle("x_{LP} [cm]"); // Do straight line hough transform on non-skewed hits from stations 1+2 try{ fHoughSpaceZxLineBehindDipole->FillHoughSpace(); if (0GetNHits() << " hits in the line Hough space.\n"; } } catch (std::runtime_error& e){ std::cerr << "Hough Space for zx line behind dipole could not be created! \n"; std::cerr << "runtime_error: " << e.what() << '\n'; } // find peaks for line hough space and store in vector const Int_t minHeightLineBehindDipole = 6; std::vector trackletsLineBehindDipole; // Call peak finder and plot the solution if it was found! if (kTRUE == fHoughSpaceZxLineBehindDipole->FindAllPeaks(minHeightLineBehindDipole, trackletsLineBehindDipole)) { if (0GetName()); } if (fTrackerTask->GetSaveDebugInfo()){ fTrackerTask->WriteHistogram(fHoughSpaceZxLineBehindDipole); } } else { std::cout << "Error: Peak finder had a problem with hough space for zx line behind dipole!!!" << '\n'; } // if (0 &tracklets ) { // to store indices that I want to "delete" std::set indicesToDelete; std::set::iterator findIndex; // for all tracklets that share more than maxAcceptableSharedHits hits keep only the heighest peak // compare all tracklets with each other, keep track of which tracklets should be "deleted" for (UInt_t iTrackletLeft = 0; iTrackletLeft < tracklets.size(); ++iTrackletLeft) { for (UInt_t iTrackletRight = iTrackletLeft+1; iTrackletRight < tracklets.size(); ++iTrackletRight) { // check if two tracks share more than maxAcceptableSharedHits hits PndFtsHoughTracklet trackletLeft = tracklets[iTrackletLeft]; PndFtsHoughTracklet trackletRight = tracklets[iTrackletRight]; const UInt_t nSharedHits = trackletLeft.getNSharedHits(trackletRight); if (nSharedHits>maxAcceptableSharedHits){ // mark the peak with the lower "height" for deletion const Double_t heightLeft = trackletLeft.getPeakHeightFromPeakFinder(); const Double_t heightRight = trackletRight.getPeakHeightFromPeakFinder(); if (heightLeft>heightRight){ indicesToDelete.insert(iTrackletRight); } else if (heightLeft filteredTracklets; for (UInt_t iTracklet = 0; iTracklet < tracklets.size(); ++iTracklet) { // check if the index is marked for "deletion" findIndex = indicesToDelete.find(iTracklet); if (findIndex == indicesToDelete.end()){ // index was not found -> entry is not marked for deletion -> I should copy it filteredTracklets.push_back(tracklets[iTracklet]); } } // replace input tracklets with filtered ones tracklets = filteredTracklets; return kTRUE; }