Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
larreco
larreco
RecoAlg
CMTool
CMTAlgMerge
CBAlgoMergeTinyWithBig.cxx
Go to the documentation of this file.
1
#include "
CBAlgoMergeTinyWithBig.h
"
2
3
#include <math.h>
4
5
namespace
cmtool
{
6
7
//-------------------------------------------------------
8
CBAlgoMergeTinyWithBig::CBAlgoMergeTinyWithBig
() :
CBoolAlgoBase
()
9
//-------------------------------------------------------
10
{
11
SetMinHitsBig
(50);
12
SetMaxHitsBig
(99999);
13
SetMinHitsSmall
(0);
14
SetMaxHitsSmall
(15);
15
SetMinDistSquared
(0);
16
17
SetDebug
(
false
);
18
}
19
20
//-----------------------------
21
void
CBAlgoMergeTinyWithBig::Reset
()
22
//-----------------------------
23
{
24
25
}
26
27
//----------------------------------------------------------------
28
bool
CBAlgoMergeTinyWithBig::Bool
(const ::cluster::ClusterParamsAlg &cluster1,
29
const ::cluster::ClusterParamsAlg &cluster2)
30
//----------------------------------------------------------------
31
{
32
33
if
(
_debug
)
34
std::cout<<
"MergeTinyWithBig. One cluster has "
35
<<cluster1.GetNHits()<<
" hits, the other has "
36
<<cluster2.GetNHits()<<
" hits."
<<
std::endl
;
37
38
39
bool
is_1_small =
false
;
40
bool
is_2_small =
false
;
41
bool
is_1_big =
false
;
42
bool
is_2_big =
false
;
43
44
//if the first cluster counts as "small"
45
if
(cluster1.GetNHits() >
_min_hits_small
&&
46
cluster1.GetNHits() <
_max_hits_small
)
47
is_1_small =
true
;
48
//if the second cluster counts as "small"
49
if
(cluster2.GetNHits() >
_min_hits_small
&&
50
cluster2.GetNHits() <
_max_hits_small
)
51
is_2_small =
true
;
52
if
(cluster1.GetNHits() >
_min_hits_big
&&
53
cluster1.GetNHits() <
_max_hits_big
)
54
is_1_big =
true
;
55
if
(cluster2.GetNHits() >
_min_hits_big
&&
56
cluster2.GetNHits() <
_max_hits_big
)
57
is_2_big =
true
;
58
59
if
(
_debug
)
60
std::cout<<
"is_1_small, is_1_big, is_2_small, is_2_big are: "
61
<<is_1_small<<
", "
<<is_1_big<<
", "
62
<<is_2_small<<
", "
<<is_2_big<<
std::endl
;
63
64
//if neither of the clusters is small don't merge
65
if
(!is_1_small && !is_2_small)
66
return
false
;
67
//if neither of the clusters is big, don't merge
68
if
(!is_1_big && !is_2_big)
69
return
false
;
70
//if both are small, don't merge
71
if
(is_1_small && is_2_small)
72
return
false
;
73
//if both are big, don't merge
74
if
(is_1_big && is_2_big)
75
return
false
;
76
77
if
(
_debug
)
78
std::cout<<
"Looks like one of them is big, and one is small."
<<
std::endl
;
79
//god this code is ugly
80
81
//now we know which one of them is big & the other is small.
82
83
//loop over the points on the first polygon and calculate
84
//distance to each point on the second polygon
85
//if any two points are close enough to each other,
86
//merge the two clusters
87
88
unsigned
int
npoints1 = cluster1.GetParams().PolyObject.Size();
89
unsigned
int
npoints2 = cluster2.GetParams().PolyObject.Size();
90
//loop over points on first polygon
91
for
(
unsigned
int
i = 0; i < npoints1; ++i){
92
float
pt1w = cluster1.GetParams().PolyObject.Point(i).first;
93
float
pt1t = cluster1.GetParams().PolyObject.Point(i).second;
94
//loop over points on second polygon
95
for
(
unsigned
int
j = 0; j < npoints2; ++j){
96
float
pt2w = cluster2.GetParams().PolyObject.Point(j).first;
97
float
pt2t = cluster2.GetParams().PolyObject.Point(j).second;
98
double
distsqrd =
pow
(pt2w-pt1w,2)+
pow
(pt2t-pt1t,2);
99
100
if
(
_debug
){
101
std::cout<<
"two polygon points dist2 is "
<<distsqrd<<
std::endl
;
102
}
103
if
(distsqrd<
_dist_sqrd_cut
)
104
return
true
;
105
}
106
107
}
108
109
return
false
;
110
111
}
112
113
//------------------------------
114
void
CBAlgoMergeTinyWithBig::Report
()
115
//------------------------------
116
{
117
118
}
119
120
}
cmtool::CBoolAlgoBase
Definition:
CBoolAlgoBase.h:27
cmtool::CBAlgoMergeTinyWithBig::SetMinDistSquared
void SetMinDistSquared(double dist)
Definition:
CBAlgoMergeTinyWithBig.h:96
cmtool::CBAlgoMergeTinyWithBig::SetMaxHitsBig
void SetMaxHitsBig(size_t nhits)
Definition:
CBAlgoMergeTinyWithBig.h:90
cmtool::CBAlgoMergeTinyWithBig::_dist_sqrd_cut
double _dist_sqrd_cut
Definition:
CBAlgoMergeTinyWithBig.h:104
cet::pow
constexpr T pow(T x)
Definition:
pow.h:72
cmtool::CBAlgoMergeTinyWithBig::Reset
virtual void Reset()
Function to reset the algorithm instance ... maybe implemented via child class.
Definition:
CBAlgoMergeTinyWithBig.cxx:21
cmtool::CBAlgoMergeTinyWithBig::SetDebug
void SetDebug(bool flag)
Definition:
CBAlgoMergeTinyWithBig.h:98
cmtool::CBAlgoMergeTinyWithBig::_max_hits_big
size_t _max_hits_big
Definition:
CBAlgoMergeTinyWithBig.h:102
cmtool::CBAlgoMergeTinyWithBig::SetMinHitsSmall
void SetMinHitsSmall(size_t nhits)
Definition:
CBAlgoMergeTinyWithBig.h:92
cmtool::CBAlgoMergeTinyWithBig::SetMaxHitsSmall
void SetMaxHitsSmall(size_t nhits)
Definition:
CBAlgoMergeTinyWithBig.h:94
cmtool::CBAlgoMergeTinyWithBig::CBAlgoMergeTinyWithBig
CBAlgoMergeTinyWithBig()
Default constructor.
Definition:
CBAlgoMergeTinyWithBig.cxx:8
cmtool::CBAlgoMergeTinyWithBig::_min_hits_big
size_t _min_hits_big
Definition:
CBAlgoMergeTinyWithBig.h:102
cmtool::CBAlgoMergeTinyWithBig::_min_hits_small
size_t _min_hits_small
Definition:
CBAlgoMergeTinyWithBig.h:102
cmtool::CBAlgoMergeTinyWithBig::_debug
bool _debug
Definition:
CBAlgoMergeTinyWithBig.h:106
cmtool
Definition:
CFAlgoQRatio.cxx:3
cmtool::CBAlgoMergeTinyWithBig::_max_hits_small
size_t _max_hits_small
Definition:
CBAlgoMergeTinyWithBig.h:102
cmtool::CBAlgoMergeTinyWithBig::SetMinHitsBig
void SetMinHitsBig(size_t nhits)
Definition:
CBAlgoMergeTinyWithBig.h:88
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
CBAlgoMergeTinyWithBig.h
Class def header for a class CBAlgoMergeTinyWithBig.
cmtool::CBAlgoMergeTinyWithBig::Report
virtual void Report()
Definition:
CBAlgoMergeTinyWithBig.cxx:114
cmtool::CBAlgoMergeTinyWithBig::Bool
virtual bool Bool(const ::cluster::ClusterParamsAlg &cluster1, const ::cluster::ClusterParamsAlg &cluster2)
Definition:
CBAlgoMergeTinyWithBig.cxx:28
Generated by
1.8.11