#include "PndFtsHoughTrackFinder.h" #include #include "TMath.h" #include #include #include #include #include // FTS #include "PndGeoFtsPar.h" #include "PndFtsMapCreator.h" #include "PndFtsHit.h" #include "FairHit.h" // magnetic field #include "FairField.h" #include "TVector3.h" // (Hough) tracking #include "PndFtsHoughTrackerTask.h" #include "PndTrackCand.h" #include "PndTrack.h" #include "FairTrackParP.h" #include "PndFtsHoughTrackCand.h" // histogramming / plotting #include "TH1.h" #include "TH2.h" #include "TGraph.h" // peak finder #include "TSpectrum2.h" // root IO #include "TClonesArray.h" #include "FairRunAna.h" #include "FairRootManager.h" #include "FairRuntimeDb.h" #include "FairTask.h" #include "PndFtsHit.h" #include "TString.h" #include "FairHit.h" #include "PndFtsTube.h" #include "FairEventHeader.h" using namespace std; ClassImp(PndFtsHoughTrackFinder) ; PndFtsHoughTrackFinder::PndFtsHoughTrackFinder(PndFtsHoughTrackerTask *trackerTask, Int_t branchId, TClonesArray* hits, FairField* field) : fTrackerTask(trackerTask), fFtsHitArray(hits), fFtsBranchId(branchId), fField(field), // Hough spaces fHoughSpaceZxLineBeforeDipole(0), fHoughspaceZxParabola(0), fHoughSpaceZxLineBehindDipole(0), fHoughspaceZyLine(0), // min peak heights fMinPeakHeightZxLineParabola(4), fMinPeakHeightZxParabola(6), fMinPeakHeightZxParabolaLine(4), fMinPeakHeightZyLine(4), // general fSaveDebugInfo(kFALSE), fVerbose(0) { if (0==fTrackerTask){ std::cout << "PndFtsHoughTrackFinder FATAL ERROR Tracker task not set.\n"; } } PndFtsHoughTrackFinder::~PndFtsHoughTrackFinder() { if(3 fFtsHitArray->GetEntriesFast()) { if(0GetXaxis()->SetTitle("#theta [rad]"); fHoughSpaceZxLineBeforeDipole->GetYaxis()->SetTitle("x_{LP} [cm]"); // Do straight line hough transform on non-skewed hits from stations 1+2 if ( kTRUE == fHoughSpaceZxLineBeforeDipole->MakeHoughSpace() ) { if (0GetNHits() << " hits in the line Hough space.\n"; } if (fTrackerTask->GetSaveDebugInfo()){ fTrackerTask->WriteHistogram(fHoughSpaceZxLineBeforeDipole); } } else { std::cout << "Hough Space for zx line before dipole could not be created! " << std::endl; } // 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!!!" << std::endl; } // 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, fFtsBranchId, fFtsHitArray, fField ); 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 if ( kTRUE == fHoughspaceZxParabola->MakeHoughSpace() ) { if (0GetNHits() << " hits in the line Hough space.\n"; } if (fTrackerTask->GetSaveDebugInfo()){ fTrackerTask->WriteHistogram(fHoughspaceZxParabola, iTrackletLine); } } else { std::cout << "Hough Space for zx parabola could not be created! " << std::endl; } // 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!!!" << std::endl; } if(1GetXaxis()->SetTitle("#theta [rad]"); fHoughSpaceZxLineBehindDipole->GetYaxis()->SetTitle("x_{LP} [cm]"); // Do straight line hough transform on non-skewed hits from stations 1+2 if ( kTRUE == fHoughSpaceZxLineBehindDipole->MakeHoughSpace() ) { if (0GetNHits() << " hits in the line Hough space.\n"; } } else { std::cout << "Hough Space for zx line behind dipole could not be created! " << std::endl; } // 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!!!" << std::endl; } // if (0 &tracklets ) { // to store indices that I want to "delete" std::set indicesToDelete; std::set::iterator findIndex; // compare all tracklets with each other, keep track which tracklets should be "deleted" // delete all tracklets that share more than maxAcceptableSharedHits hits // keep only the heighest peak 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; }