CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Static Public Member Functions | Static Private Member Functions
PFBenchmarkAlgo Class Reference

#include <PFBenchmarkAlgo.h>

Static Public Member Functions

template<typename T , typename Collection >
static Collection copyCollection (const Collection *)
 
template<typename T , typename U >
static double deltaEt (const T *, const U *)
 
template<typename T , typename U >
static double deltaEta (const T *, const U *)
 
template<typename T , typename U >
static double deltaPhi (const T *, const U *)
 
template<typename T , typename U >
static double deltaR (const T *, const U *)
 
template<typename T , typename Collection >
static Collection findAllInCone (const T *, const Collection *, double)
 
template<typename T , typename Collection >
static Collection findAllInEtWindow (const T *, const Collection *, double)
 
template<typename T , typename Collection >
static const Collection::value_type * matchByDeltaEt (const T *, const Collection *)
 
template<typename T , typename Collection >
static const Collection::value_type * matchByDeltaR (const T *, const Collection *)
 
template<typename T , typename Collection >
static void sortByDeltaEt (const T *, Collection &)
 
template<typename T , typename Collection >
static void sortByDeltaR (const T *, Collection &)
 

Static Private Member Functions

template<typename T >
static void vector_add (const T *c1, std::vector< T > &candidates)
 
template<typename T >
static void vector_add (const T *c1, edm::OwnVector< T > &candidates)
 
template<typename T , typename U , template< typename, typename > class Sorter>
static void vector_sort (std::vector< T > &candidates, Sorter< T, U > S)
 
template<typename T , typename U , template< typename, typename > class Sorter>
static void vector_sort (edm::OwnVector< T > &candidates, Sorter< T, U > S)
 

Detailed Description

Definition at line 16 of file PFBenchmarkAlgo.h.

Member Function Documentation

◆ copyCollection()

template<typename T , typename Collection >
Collection PFBenchmarkAlgo::copyCollection ( const Collection *  candidates)
static

Definition at line 247 of file PFBenchmarkAlgo.h.

References HLT_2022v15_cff::candidates, filterCSVwithJSON::copy, Exception, mps_fire::i, mitigatedMETSequence_cff::U, and vector_add().

247  {
248  typedef typename Collection::value_type U;
249 
250  // Try to verify the validity of the Collection
251  if (!candidates)
252  throw cms::Exception("Invalid Arg") << "attempted to copy invalid Collection";
253 
254  Collection copy;
255 
256  for (unsigned int i = 0; i < candidates->size(); i++)
257  vector_add(&(*candidates)[i], copy);
258 
259  return copy;
260 }
static void vector_add(const T *c1, std::vector< T > &candidates)

◆ deltaEt()

template<typename T , typename U >
double PFBenchmarkAlgo::deltaEt ( const T c1,
const U *  c2 
)
static

Definition at line 120 of file PFBenchmarkAlgo.h.

References alignmentValidation::c1, and Exception.

Referenced by findAllInEtWindow(), matchByDeltaEt(), and deltaEtSorter< T, U >::operator()().

120  {
121  if (c1 == nullptr || c2 == nullptr)
122  throw cms::Exception("Invalid Arg") << "attempted to calculate deltaEt for invalid Candidate(s)";
123 
124  return c1->et() - c2->et();
125 }

◆ deltaEta()

template<typename T , typename U >
double PFBenchmarkAlgo::deltaEta ( const T c1,
const U *  c2 
)
static

Definition at line 129 of file PFBenchmarkAlgo.h.

References alignmentValidation::c1, and Exception.

Referenced by deltaR().

129  {
130  if (c1 == nullptr || c2 == nullptr)
131  throw cms::Exception("Invalid Arg") << "attempted to calculate deltaEta for invalid Candidate(s)";
132 
133  return c1->eta() - c2->eta();
134 }

◆ deltaPhi()

template<typename T , typename U >
double PFBenchmarkAlgo::deltaPhi ( const T c1,
const U *  c2 
)
static

Definition at line 138 of file PFBenchmarkAlgo.h.

References alignmentValidation::c1, reco::ceil(), Exception, and M_PI.

Referenced by deltaR().

138  {
139  if (c1 == nullptr || c2 == nullptr)
140  throw cms::Exception("Invalid Arg") << "attempted to calculate deltaPhi for invalid Candidate(s)";
141 
142  double phi1 = c1->phi();
143  if (phi1 > M_PI)
144  phi1 -= ceil((phi1 - M_PI) / (2 * M_PI)) * 2 * M_PI;
145  if (phi1 <= -M_PI)
146  phi1 += ceil((phi1 + M_PI) / (-2. * M_PI)) * 2. * M_PI;
147 
148  double phi2 = c2->phi();
149  if (phi2 > M_PI)
150  phi2 -= ceil((phi2 - M_PI) / (2 * M_PI)) * 2 * M_PI;
151  if (phi2 <= -M_PI)
152  phi2 += ceil((phi2 + M_PI) / (-2. * M_PI)) * 2 * M_PI;
153 
154  // alternative method:
155  // while (phi > M_PI) phi -= 2 * M_PI;
156  // while (phi <= - M_PI) phi += 2 * M_PI;
157 
158  double deltaphi = -999.0;
159  if (fabs(phi1 - phi2) < M_PI) {
160  deltaphi = (phi1 - phi2);
161  } else {
162  if ((phi1 - phi2) > 0.0) {
163  deltaphi = (2 * M_PI - fabs(phi1 - phi2));
164  } else {
165  deltaphi = -(2 * M_PI - fabs(phi1 - phi2));
166  }
167  }
168  return deltaphi;
169  //return ( (fabs(phi1 - phi2)<M_PI)?(phi1-phi2):(2*M_PI - fabs(phi1 - phi2) ) ); // FL: wrong
170 }
constexpr int32_t ceil(float num)
#define M_PI

◆ deltaR()

template<typename T , typename U >
double PFBenchmarkAlgo::deltaR ( const T c1,
const U *  c2 
)
static

Definition at line 174 of file PFBenchmarkAlgo.h.

References alignmentValidation::c1, deltaEta(), deltaPhi(), Exception, funct::pow(), and mathSSE::sqrt().

Referenced by TauTagValidation::analyze(), GenericBenchmark::fill(), PFJetFilter::filter(), findAllInCone(), matchByDeltaR(), deltaRSorter< T, U >::operator()(), and PFJetBenchmark::process().

174  {
175  if (c1 == nullptr || c2 == nullptr)
176  throw cms::Exception("Invalid Arg") << "attempted to calculate deltaR for invalid Candidate(s)";
177 
178  return sqrt(std::pow(deltaPhi(c1, c2), 2) + std::pow(deltaEta(c1, c2), 2));
179 }
static double deltaEta(const T *, const U *)
T sqrt(T t)
Definition: SSEVec.h:19
static double deltaPhi(const T *, const U *)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ findAllInCone()

template<typename T , typename Collection >
Collection PFBenchmarkAlgo::findAllInCone ( const T c1,
const Collection *  candidates,
double  ConeSize 
)
static

Definition at line 294 of file PFBenchmarkAlgo.h.

References alignmentValidation::c1, HLT_2022v15_cff::candidates, deltaR(), HGC3DClusterGenMatchSelector_cfi::dR, Exception, mps_fire::i, sortByDeltaR(), mitigatedMETSequence_cff::U, and vector_add().

294  {
295  typedef typename Collection::value_type U;
296 
297  // Try to verify the validity of Candidate and the Collection
298  if (!c1)
299  throw cms::Exception("Invalid Arg") << "attempted to constrain to invalid Candidate";
300  if (!candidates)
301  throw cms::Exception("Invalid Arg") << "attempted to constrain invalid Collection";
302  if (ConeSize <= 0)
303  throw cms::Exception("Invalid Arg") << "zero or negative cone size specified";
304 
305  Collection constrained;
306 
307  for (unsigned int i = 0; i < candidates->size(); i++) {
308  const U *c2 = &(*candidates)[i];
309 
310  // Add in-cone Candidates to the new Collection
311  double dR = deltaR(c1, c2);
312  if (dR < ConeSize)
313  vector_add(c2, constrained);
314  }
315 
316  // Sort and return Collection
317  sortByDeltaR(c1, constrained);
318  return constrained;
319 }
static void vector_add(const T *c1, std::vector< T > &candidates)
static void sortByDeltaR(const T *, Collection &)
static double deltaR(const T *, const U *)

◆ findAllInEtWindow()

template<typename T , typename Collection >
Collection PFBenchmarkAlgo::findAllInEtWindow ( const T c1,
const Collection *  candidates,
double  EtWindow 
)
static

Definition at line 323 of file PFBenchmarkAlgo.h.

References alignmentValidation::c1, HLT_2022v15_cff::candidates, deltaEt(), Exception, mps_fire::i, sortByDeltaEt(), mitigatedMETSequence_cff::U, and vector_add().

323  {
324  typedef typename Collection::value_type U;
325 
326  // Try to verify the validity of Candidate and the Collection
327  if (!c1)
328  throw cms::Exception("Invalid Arg") << "attempted to constrain to invalid Candidate";
329  if (!candidates)
330  throw cms::Exception("Invalid Arg") << "attempted to constrain invalid Collection";
331  if (EtWindow <= 0)
332  throw cms::Exception("Invalid Arg") << "zero or negative cone size specified";
333 
334  Collection constrained;
335 
336  //CandidateCollection::const_iterator candidate;
337  //for (candidate = candidates->begin(); candidate != candidates->end(); candidate++) {
338  for (unsigned int i = 0; i < candidates->size(); i++) {
339  const U *c2 = &(*candidates)[i];
340 
341  // Add in-cone Candidates to the new Collection
342  double dEt = fabs(deltaEt(c1, c2));
343  if (dEt < EtWindow)
344  vector_add(c2, constrained);
345  }
346 
347  // Sort and return Collection
348  sortByDeltaEt(c1, constrained);
349  return constrained;
350 }
static void vector_add(const T *c1, std::vector< T > &candidates)
static double deltaEt(const T *, const U *)
static void sortByDeltaEt(const T *, Collection &)

◆ matchByDeltaEt()

template<typename T , typename Collection >
const Collection::value_type * PFBenchmarkAlgo::matchByDeltaEt ( const T c1,
const Collection *  candidates 
)
static

Definition at line 215 of file PFBenchmarkAlgo.h.

References alignmentValidation::c1, HLT_2022v15_cff::candidates, deltaEt(), Exception, mps_fire::i, match(), caloJetBenchmarkGeneric_cfi::minDeltaEt, NULL, and mitigatedMETSequence_cff::U.

215  {
216  typedef typename Collection::value_type U;
217 
218  // Try to verify the validity of the Candidate and Collection
219  if (!c1)
220  throw cms::Exception("Invalid Arg") << "attempted to match invalid Candidate";
221  if (!candidates)
222  throw cms::Exception("Invalid Arg") << "attempted to match to invalid Collection";
223 
224  double minDeltaEt = 9999.;
225  const U *match = NULL;
226 
227  // Loop Over the Candidates...
228  for (unsigned int i = 0; i < candidates->size(); i++) {
229  const T *c2 = &(*candidates)[i];
230  if (!c2)
231  throw cms::Exception("Invalid Arg") << "attempted to match to invalid Candidate";
232 
233  // Find Minimal Delta-R
234  double dEt = fabs(deltaEt(c1, c2));
235  if (dEt <= minDeltaEt) {
236  match = c2;
237  minDeltaEt = dEt;
238  }
239  }
240 
241  // Return the Candidate with the smallest dR
242  return match;
243 }
#define NULL
Definition: scimark2.h:8
static double deltaEt(const T *, const U *)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
long double T

◆ matchByDeltaR()

template<typename T , typename Collection >
const Collection::value_type * PFBenchmarkAlgo::matchByDeltaR ( const T c1,
const Collection *  candidates 
)
static

Definition at line 183 of file PFBenchmarkAlgo.h.

References alignmentValidation::c1, HLT_2022v15_cff::candidates, deltaR(), HGC3DClusterGenMatchSelector_cfi::dR, Exception, mps_fire::i, match(), HLT_2022v15_cff::minDeltaR, and mitigatedMETSequence_cff::U.

Referenced by GenericBenchmark::fill(), PFJetFilter::filter(), and PFJetBenchmark::process().

183  {
184  typedef typename Collection::value_type U;
185 
186  // Try to verify the validity of the Candidate and Collection
187  if (!c1)
188  throw cms::Exception("Invalid Arg") << "attempted to match invalid Candidate";
189  if (!candidates)
190  throw cms::Exception("Invalid Arg") << "attempted to match to invalid Collection";
191 
192  double minDeltaR = 9999.;
193  const U *match = nullptr;
194 
195  // Loop Over the Candidates...
196  for (unsigned int i = 0; i < candidates->size(); i++) {
197  const U *c2 = &(*candidates)[i];
198  if (!c2)
199  throw cms::Exception("Invalid Arg") << "attempted to match to invalid Candidate";
200 
201  // Find Minimal Delta-R
202  double dR = deltaR(c1, c2);
203  if (dR <= minDeltaR) {
204  match = c2;
205  minDeltaR = dR;
206  }
207  }
208 
209  // Return the Candidate with the smallest dR
210  return match;
211 }
static double deltaR(const T *, const U *)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10

◆ sortByDeltaEt()

template<typename T , typename Collection >
void PFBenchmarkAlgo::sortByDeltaEt ( const T c1,
Collection &  candidates 
)
static

Definition at line 279 of file PFBenchmarkAlgo.h.

References alignmentValidation::c1, HLT_2022v15_cff::candidates, Exception, mitigatedMETSequence_cff::U, and vector_sort().

Referenced by findAllInEtWindow().

279  {
280  typedef typename Collection::value_type U;
281 
282  // Try to verify the validity of Candidate and Collection
283  if (!c1)
284  throw cms::Exception("Invalid Arg") << "attempted to sort by invalid Candidate";
285  if (!candidates)
286  throw cms::Exception("Invalid Arg") << "attempted to sort invalid Candidates";
287 
288  // Sort the collection
290 }
static void vector_sort(std::vector< T > &candidates, Sorter< T, U > S)

◆ sortByDeltaR()

template<typename T , typename Collection >
void PFBenchmarkAlgo::sortByDeltaR ( const T c1,
Collection &  candidates 
)
static

Definition at line 264 of file PFBenchmarkAlgo.h.

References alignmentValidation::c1, HLT_2022v15_cff::candidates, Exception, mitigatedMETSequence_cff::U, and vector_sort().

Referenced by findAllInCone().

264  {
265  typedef typename Collection::value_type U;
266 
267  // Try to verify the validity of Candidate and Collection
268  if (!c1)
269  throw cms::Exception("Invalid Arg") << "attempted to sort by invalid Candidate";
270  if (!candidates)
271  throw cms::Exception("Invalid Arg") << "attempted to sort invalid Candidates";
272 
273  // Sort the collection
275 }
static void vector_sort(std::vector< T > &candidates, Sorter< T, U > S)

◆ vector_add() [1/2]

template<typename T >
static void PFBenchmarkAlgo::vector_add ( const T c1,
std::vector< T > &  candidates 
)
inlinestaticprivate

Definition at line 71 of file PFBenchmarkAlgo.h.

References alignmentValidation::c1, and HLT_2022v15_cff::candidates.

Referenced by copyCollection(), findAllInCone(), and findAllInEtWindow().

71  {
72  candidates.push_back(*c1);
73  }

◆ vector_add() [2/2]

template<typename T >
static void PFBenchmarkAlgo::vector_add ( const T c1,
edm::OwnVector< T > &  candidates 
)
inlinestaticprivate

Definition at line 83 of file PFBenchmarkAlgo.h.

References alignmentValidation::c1, and HLT_2022v15_cff::candidates.

83  {
84  candidates.push_back((T *const)c1->clone());
85  }
long double T

◆ vector_sort() [1/2]

template<typename T , typename U , template< typename, typename > class Sorter>
static void PFBenchmarkAlgo::vector_sort ( std::vector< T > &  candidates,
Sorter< T, U >  S 
)
inlinestaticprivate

Definition at line 65 of file PFBenchmarkAlgo.h.

References HLT_2022v15_cff::candidates, and jetUpdater_cfi::sort.

Referenced by sortByDeltaEt(), and sortByDeltaR().

◆ vector_sort() [2/2]

template<typename T , typename U , template< typename, typename > class Sorter>
static void PFBenchmarkAlgo::vector_sort ( edm::OwnVector< T > &  candidates,
Sorter< T, U >  S 
)
inlinestaticprivate

Definition at line 77 of file PFBenchmarkAlgo.h.

References HLT_2022v15_cff::candidates.

77  {
78  candidates.sort(S);
79  }