1 #ifndef RecoParticleFlow_Benchmark_PFBenchmarkAlgo_h
2 #define RecoParticleFlow_Benchmark_PFBenchmarkAlgo_h
19 template <
typename T,
typename U>
20 static double deltaEt(
const T *,
const U *);
23 template <
typename T,
typename U>
24 static double deltaEta(
const T *,
const U *);
27 template <
typename T,
typename U>
28 static double deltaPhi(
const T *,
const U *);
31 template <
typename T,
typename U>
32 static double deltaR(
const T *,
const U *);
35 template <
typename T,
typename Collection>
39 template <
typename T,
typename Collection>
43 template <
typename T,
typename Collection>
47 template <
typename T,
typename Collection>
51 template <
typename T,
typename Collection>
55 template <
typename T,
typename Collection>
56 static Collection
findAllInCone(
const T *,
const Collection *,
double);
59 template <
typename T,
typename Collection>
64 template <
typename T,
typename U,
template <
typename,
typename>
class Sorter>
66 sort(candidates.begin(), candidates.end(),
S);
72 candidates.push_back(*c1);
76 template <
typename T,
typename U,
template <
typename,
typename>
class Sorter>
93 template <
typename T,
typename U>
106 template <
typename T,
typename U>
119 template <
typename T,
typename U>
121 if (c1 ==
nullptr || c2 ==
nullptr)
122 throw cms::Exception(
"Invalid Arg") <<
"attempted to calculate deltaEt for invalid Candidate(s)";
124 return c1->et() - c2->et();
128 template <
typename T,
typename U>
130 if (c1 ==
nullptr || c2 ==
nullptr)
131 throw cms::Exception(
"Invalid Arg") <<
"attempted to calculate deltaEta for invalid Candidate(s)";
133 return c1->eta() - c2->eta();
137 template <
typename T,
typename U>
139 if (c1 ==
nullptr || c2 ==
nullptr)
140 throw cms::Exception(
"Invalid Arg") <<
"attempted to calculate deltaPhi for invalid Candidate(s)";
142 double phi1 = c1->phi();
148 double phi2 = c2->phi();
158 double deltaphi = -999.0;
159 if (fabs(phi1 - phi2) <
M_PI) {
160 deltaphi = (phi1 - phi2);
162 if ((phi1 - phi2) > 0.0) {
163 deltaphi = (2 *
M_PI - fabs(phi1 - phi2));
165 deltaphi = -(2 *
M_PI - fabs(phi1 - phi2));
173 template <
typename T,
typename U>
175 if (c1 ==
nullptr || c2 ==
nullptr)
176 throw cms::Exception(
"Invalid Arg") <<
"attempted to calculate deltaR for invalid Candidate(s)";
182 template <
typename T,
typename Collection>
188 throw cms::Exception(
"Invalid Arg") <<
"attempted to match invalid Candidate";
190 throw cms::Exception(
"Invalid Arg") <<
"attempted to match to invalid Collection";
193 const U *
match =
nullptr;
196 for (
unsigned int i = 0;
i < candidates->size();
i++) {
197 const U *c2 = &(*candidates)[
i];
199 throw cms::Exception(
"Invalid Arg") <<
"attempted to match to invalid Candidate";
202 double dR =
deltaR(c1, c2);
203 if (dR <= minDeltaR) {
214 template <
typename T,
typename Collection>
220 throw cms::Exception(
"Invalid Arg") <<
"attempted to match invalid Candidate";
222 throw cms::Exception(
"Invalid Arg") <<
"attempted to match to invalid Collection";
224 double minDeltaEt = 9999.;
228 for (
unsigned int i = 0;
i < candidates->size();
i++) {
229 const T *c2 = &(*candidates)[
i];
231 throw cms::Exception(
"Invalid Arg") <<
"attempted to match to invalid Candidate";
234 double dEt = fabs(
deltaEt(c1, c2));
235 if (dEt <= minDeltaEt) {
246 template <
typename T,
typename Collection>
252 throw cms::Exception(
"Invalid Arg") <<
"attempted to copy invalid Collection";
256 for (
unsigned int i = 0;
i < candidates->size();
i++)
263 template <
typename T,
typename Collection>
269 throw cms::Exception(
"Invalid Arg") <<
"attempted to sort by invalid Candidate";
271 throw cms::Exception(
"Invalid Arg") <<
"attempted to sort invalid Candidates";
278 template <
typename T,
typename Collection>
284 throw cms::Exception(
"Invalid Arg") <<
"attempted to sort by invalid Candidate";
286 throw cms::Exception(
"Invalid Arg") <<
"attempted to sort invalid Candidates";
293 template <
typename T,
typename Collection>
299 throw cms::Exception(
"Invalid Arg") <<
"attempted to constrain to invalid Candidate";
301 throw cms::Exception(
"Invalid Arg") <<
"attempted to constrain invalid Collection";
303 throw cms::Exception(
"Invalid Arg") <<
"zero or negative cone size specified";
305 Collection constrained;
307 for (
unsigned int i = 0;
i < candidates->size();
i++) {
308 const U *c2 = &(*candidates)[
i];
311 double dR =
deltaR(c1, c2);
322 template <
typename T,
typename Collection>
328 throw cms::Exception(
"Invalid Arg") <<
"attempted to constrain to invalid Candidate";
330 throw cms::Exception(
"Invalid Arg") <<
"attempted to constrain invalid Collection";
332 throw cms::Exception(
"Invalid Arg") <<
"zero or negative cone size specified";
334 Collection constrained;
338 for (
unsigned int i = 0;
i < candidates->size();
i++) {
339 const U *c2 = &(*candidates)[
i];
342 double dEt = fabs(
deltaEt(c1, c2));
352 #endif // RecoParticleFlow_Benchmark_PFBenchmarkAlgo_h
static Collection copyCollection(const Collection *)
constexpr int32_t ceil(float num)
edm::Ref< Container > Ref
static void vector_add(const T *c1, edm::OwnVector< T > &candidates)
static void vector_add(const T *c1, std::vector< T > &candidates)
bool operator()(const U &c1, const U &c2) const
static void sortByDeltaR(const T *, Collection &)
static const Collection::value_type * matchByDeltaEt(const T *, const Collection *)
static double deltaEt(const T *, const U *)
bool operator()(const U &c1, const U &c2) const
static double deltaEta(const T *, const U *)
static void vector_sort(std::vector< T > &candidates, Sorter< T, U > S)
Container::value_type value_type
static Collection findAllInCone(const T *, const Collection *, double)
static double deltaR(const T *, const U *)
deltaRSorter(const T *Ref)
static const Collection::value_type * matchByDeltaR(const T *, const Collection *)
static void sortByDeltaEt(const T *, Collection &)
double S(const TLorentzVector &, const TLorentzVector &)
static void vector_sort(edm::OwnVector< T > &candidates, Sorter< T, U > S)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
static double deltaPhi(const T *, const U *)
static Collection findAllInEtWindow(const T *, const Collection *, double)
deltaEtSorter(const T *Ref)
Power< A, B >::type pow(const A &a, const B &b)