Skip to content
Snippets Groups Projects
Commit 20e04efe authored by Johnston's avatar Johnston
Browse files

fix compile errors, confirm merge works, check HT_test example script works

parent 67c59b15
Branches
Tags v1.1.0
No related merge requests found
......@@ -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
......
......@@ -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;
......
// this one doesn't work, uses bits that have been commented, alternative finding method
#include "GenFind/GenFindHits.h"
#include "GenFind/HoughTransform.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment