diff --git a/src/GenFind/include/HoughTransform.h b/src/GenFind/include/HoughTransform.h index 2c7cda279f6dde2f22646e6768cbb4aa5247fa97..b980a94ac00091d11b3bc2aa30c833be33d169a8 100644 --- a/src/GenFind/include/HoughTransform.h +++ b/src/GenFind/include/HoughTransform.h @@ -54,55 +54,55 @@ namespace genfind { //====== delete the following from a merge if it conflicts with some of the other stuff. // - /** @brief Method to get the result. - * - * @param hits Vector of hit type T which. - * - * Returns vector of vector of hits group into possilbe track candidates. - * Note: the reference hit for the conformal transform is at the origin. - * - */ - template<class T> - std::vector<std::vector<T>> operator()(const std::vector<T>& hits){ - std::vector<std::vector<T>> res; - T ref = {0.0,0.0,0.0,0.0}; - auto chits = genfind::compute_conformal_hits(hits, ref); - auto peaks = FindPhiPeaks(chits); - res = SelectPhiPeaks<T>(peaks, chits); - return res; - } - - template<class T> - std::vector<std::vector<T>> SelectPhiPeaks(const std::vector<double>& peaks, - const std::vector<genfind::ConformalHit>& chits) - { - double degree = TMath::Pi()/180.0; - std::vector<std::vector<T>> res; - for(auto& p : peaks){ - std::vector<T> p_hits; - for(const auto& ahit : chits){ - double phi = TMath::ATan(ahit.Y()/ahit.X())/degree; - if( TMath::Abs(phi-p) < fPhiThresh ) { - p_hits.push_back( - {ahit.fImageHit->X(), - ahit.fImageHit->Y(), - ahit.fImageHit->Z(), - ahit.fImageHit->T()}); - } - } - res.push_back(p_hits); - } - return res; - } - - /** @brief Fill the Hough transform histograms for searching. - * - * @param chits Vector of ConformalHits used to find lines. - * - */ - void FillHistograms(const std::vector<genfind::ConformalHit>& chits); - - std::vector<double> FindPhiPeaks(const std::vector<genfind::ConformalHit>& chits); +// /** @brief Method to get the result. +// * +// * @param hits Vector of hit type T which. +// * +// * Returns vector of vector of hits group into possilbe track candidates. +// * Note: the reference hit for the conformal transform is at the origin. +// * +// */ +// template<class T> +// std::vector<std::vector<T>> operator()(const std::vector<T>& hits){ +// std::vector<std::vector<T>> res; +// T ref = {0.0,0.0,0.0,0.0}; +// auto chits = genfind::compute_conformal_hits(hits, ref); +// auto peaks = FindPhiPeaks(chits); +// res = SelectPhiPeaks<T>(peaks, chits); +// return res; +// } +// +// template<class T> +// std::vector<std::vector<T>> SelectPhiPeaks(const std::vector<double>& peaks, +// const std::vector<genfind::ConformalHit>& chits) +// { +// double degree = TMath::Pi()/180.0; +// std::vector<std::vector<T>> res; +// for(auto& p : peaks){ +// std::vector<T> p_hits; +// for(const auto& ahit : chits){ +// double phi = TMath::ATan(ahit.Y()/ahit.X())/degree; +// if( TMath::Abs(phi-p) < fPhiThresh ) { +// p_hits.push_back( +// {ahit.fImageHit->X(), +// ahit.fImageHit->Y(), +// ahit.fImageHit->Z(), +// ahit.fImageHit->T()}); +// } +// } +// res.push_back(p_hits); +// } +// return res; +// } +// +// /** @brief Fill the Hough transform histograms for searching. +// * +// * @param chits Vector of ConformalHits used to find lines. +// * +// */ +// void FillHistograms(const std::vector<genfind::ConformalHit>& chits); +// +// std::vector<double> FindPhiPeaks(const std::vector<genfind::ConformalHit>& chits); // next line, end deletes if the merge caused a conflict. //>>>>>>> d267ad98e7036905dfceb221e8b3f316819b0990 diff --git a/src/GenFind/src/HoughTransform.cxx b/src/GenFind/src/HoughTransform.cxx index 5c3d998282b54a730cf400d68ee714c1350f7c97..3b6b795e1a4c011cdef668e8c00a648283177d50 100644 --- a/src/GenFind/src/HoughTransform.cxx +++ b/src/GenFind/src/HoughTransform.cxx @@ -70,6 +70,10 @@ namespace genfind { double y2 = ref_point.Y(); double y3 = bhit.Y(); + double x = x1-x2; + double y = y1-y2; + double R = x*x+y*y; + if( !(ahit == ref_point) ) { res.push_back(ROOT::Math::XYZTVector{ 2.0*x/R, 2.0*y/R, ahit.Z(), ahit.T() }); } @@ -96,67 +100,67 @@ namespace genfind { } //_________________________________________________________________________ // - - void HoughTransform::FillHistograms(const std::vector<genfind::ConformalHit>& chits) - { - double degree = TMath::Pi()/180.0; - double phi_min = 0.0; - double phi_max = 180.0; - - TH1F* temp0 = (TH1F*)fRhoTheta0->Clone(); - TH1F* temp1 = (TH1F*)fRhoTheta1->Clone(); - TH1F* temp2 = (TH1F*)fRhoTheta2->Clone(); - fRhoTheta0->Reset(); - fRhoTheta1->Reset(); - fRhoTheta2->Reset(); - for(const auto& ahit : chits) { - temp0->Reset(); - temp1->Reset(); - temp2->Reset(); - for(int i_theta = 0; i_theta<1000; i_theta++) { - - double theta = 180.0*degree*double(i_theta)/double(500);//rand.Uniform(0.0,180.0)*degree; - - int bin = temp0->FindBin(theta/degree, ahit.X()*TMath::Cos(theta) + ahit.Y()*TMath::Sin(theta) ); - temp0->SetBinContent(bin, 1); - - bin = temp1->FindBin(theta/degree, ahit.X()*TMath::Cos(theta) + ahit.Y()*TMath::Sin(theta) ); - temp1->SetBinContent(bin, 1); - - bin = temp2->FindBin(theta/degree, ahit.X()*TMath::Cos(theta) + ahit.Y()*TMath::Sin(theta) ); - temp2->SetBinContent(bin, 1); - } - fRhoTheta0->Add(temp0); - fRhoTheta1->Add(temp1); - fRhoTheta2->Add(temp2); - } - - delete temp0; - delete temp1; - delete temp2; - } - //__________________________________________________________________________ - - std::vector<double> HoughTransform::FindPhiPeaks(const std::vector<genfind::ConformalHit>& chits) - { - double degree = TMath::Pi()/180.0; - // First fill the phi histogram - fPhi->Reset(); - for(const auto& ahit : chits){ - double phi = TMath::ATan(ahit.Y()/ahit.X())/degree; - fPhi->Fill(phi); - } - double sigma = 2; - double thresh = 0.1; - int npeaks = fSpec1->Search(fPhi, sigma, "nodraw", thresh ); - std::vector<double> peaks; - for(int i = 0; i<npeaks; i++) { - peaks.push_back( (fSpec1->GetPositionX())[i] ); - } - return peaks; - } - //__________________________________________________________________________ - +// merged in, maybe not used +// void HoughTransform::FillHistograms(const std::vector<genfind::ConformalHit>& chits) +// { +// double degree = TMath::Pi()/180.0; +// double phi_min = 0.0; +// double phi_max = 180.0; +// +// TH1F* temp0 = (TH1F*)fRhoTheta0->Clone(); +// TH1F* temp1 = (TH1F*)fRhoTheta1->Clone(); +// TH1F* temp2 = (TH1F*)fRhoTheta2->Clone(); +// fRhoTheta0->Reset(); +// fRhoTheta1->Reset(); +// fRhoTheta2->Reset(); +// for(const auto& ahit : chits) { +// temp0->Reset(); +// temp1->Reset(); +// temp2->Reset(); +// for(int i_theta = 0; i_theta<1000; i_theta++) { +// +// double theta = 180.0*degree*double(i_theta)/double(500);//rand.Uniform(0.0,180.0)*degree; +// +// int bin = temp0->FindBin(theta/degree, ahit.X()*TMath::Cos(theta) + ahit.Y()*TMath::Sin(theta) ); +// temp0->SetBinContent(bin, 1); +// +// bin = temp1->FindBin(theta/degree, ahit.X()*TMath::Cos(theta) + ahit.Y()*TMath::Sin(theta) ); +// temp1->SetBinContent(bin, 1); +// +// bin = temp2->FindBin(theta/degree, ahit.X()*TMath::Cos(theta) + ahit.Y()*TMath::Sin(theta) ); +// temp2->SetBinContent(bin, 1); +// } +// fRhoTheta0->Add(temp0); +// fRhoTheta1->Add(temp1); +// fRhoTheta2->Add(temp2); +// } +// +// delete temp0; +// delete temp1; +// delete temp2; +// } +// //__________________________________________________________________________ +// +// std::vector<double> HoughTransform::FindPhiPeaks(const std::vector<genfind::ConformalHit>& chits) +// { +// double degree = TMath::Pi()/180.0; +// // First fill the phi histogram +// fPhi->Reset(); +// for(const auto& ahit : chits){ +// double phi = TMath::ATan(ahit.Y()/ahit.X())/degree; +// fPhi->Fill(phi); +// } +// double sigma = 2; +// double thresh = 0.1; +// int npeaks = fSpec1->Search(fPhi, sigma, "nodraw", thresh ); +// std::vector<double> peaks; +// for(int i = 0; i<npeaks; i++) { +// peaks.push_back( (fSpec1->GetPositionX())[i] ); +// } +// return peaks; +// } +// //__________________________________________________________________________ +// TMultiGraph* HoughTransform::FillHoughTransforms(const std::vector<ROOT::Math::XYZTVector>& hits) { double degree = TMath::Pi()/180.0; diff --git a/src/GenFind/tests/ht_test.cxx b/src/GenFind/tests/ht_test.cxx index 36155f89871ae852eefef3d98279d71f6bf722ef..7d947f6b187d4797632f376b8265912b0180a2a9 100644 --- a/src/GenFind/tests/ht_test.cxx +++ b/src/GenFind/tests/ht_test.cxx @@ -1,3 +1,5 @@ +// this one doesn't work, uses bits that have been commented, alternative finding method + #include "GenFind/GenFindHits.h" #include "GenFind/HoughTransform.h"