Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GenFind
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sjohnston
GenFind
Commits
20e04efe
Commit
20e04efe
authored
8 years ago
by
Johnston
Browse files
Options
Downloads
Patches
Plain Diff
fix compile errors, confirm merge works, check HT_test example script works
parent
67c59b15
Branches
Branches containing commit
Tags
v1.1.0
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/GenFind/include/HoughTransform.h
+49
-49
49 additions, 49 deletions
src/GenFind/include/HoughTransform.h
src/GenFind/src/HoughTransform.cxx
+65
-61
65 additions, 61 deletions
src/GenFind/src/HoughTransform.cxx
src/GenFind/tests/ht_test.cxx
+2
-0
2 additions, 0 deletions
src/GenFind/tests/ht_test.cxx
with
116 additions
and
110 deletions
src/GenFind/include/HoughTransform.h
+
49
−
49
View file @
20e04efe
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
src/GenFind/src/HoughTransform.cxx
+
65
−
61
View file @
20e04efe
...
...
@@ -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 diff is collapsed.
Click to expand it.
src/GenFind/tests/ht_test.cxx
+
2
−
0
View file @
20e04efe
// this one doesn't work, uses bits that have been commented, alternative finding method
#include
"GenFind/GenFindHits.h"
#include
"GenFind/HoughTransform.h"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment