CMS 3D CMS Logo

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, edm::OwnVector< T > &candidates)
 
template<typename T >
static void vector_add (const T *c1, std::vector< T > &candidates)
 
template<typename T , typename U , template< typename, typename > class Sorter>
static void vector_sort (edm::OwnVector< T > &candidates, Sorter< T, U > S)
 
template<typename T , typename U , template< typename, typename > class Sorter>
static void vector_sort (std::vector< 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.

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 }

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

◆ deltaEt()

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

Definition at line 120 of file PFBenchmarkAlgo.h.

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 }

References alignmentValidation::c1, and Exception.

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

◆ deltaEta()

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

Definition at line 129 of file PFBenchmarkAlgo.h.

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 }

References alignmentValidation::c1, and Exception.

Referenced by deltaR().

◆ deltaPhi()

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

Definition at line 138 of file PFBenchmarkAlgo.h.

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 }

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

Referenced by deltaR().

◆ deltaR()

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

Definition at line 174 of file PFBenchmarkAlgo.h.

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 }

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

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

◆ 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.

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 }

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

◆ 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.

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 }

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

◆ 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.

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 }

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

◆ 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.

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 }

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

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

◆ sortByDeltaEt()

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

Definition at line 279 of file PFBenchmarkAlgo.h.

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 }

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

Referenced by findAllInEtWindow().

◆ sortByDeltaR()

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

Definition at line 264 of file PFBenchmarkAlgo.h.

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 }

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

Referenced by findAllInCone().

◆ vector_add() [1/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.

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

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

◆ vector_add() [2/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.

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

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

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

◆ vector_sort() [1/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.

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

References HLT_FULL_cff::candidates.

◆ vector_sort() [2/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.

65  {
66  sort(candidates.begin(), candidates.end(), S);
67  }

References HLT_FULL_cff::candidates, and S().

Referenced by sortByDeltaEt(), and sortByDeltaR().

PFBenchmarkAlgo::deltaR
static double deltaR(const T *, const U *)
Definition: PFBenchmarkAlgo.h:174
mps_fire.i
i
Definition: mps_fire.py:428
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
deltaRSorter
Definition: PFBenchmarkAlgo.h:94
PFBenchmarkAlgo::vector_add
static void vector_add(const T *c1, std::vector< T > &candidates)
Definition: PFBenchmarkAlgo.h:71
reco::ceil
constexpr int32_t ceil(float num)
Definition: constexpr_cmath.h:7
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
benchmark_cfg.minDeltaEt
minDeltaEt
Definition: benchmark_cfg.py:54
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
S
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:97
PFBenchmarkAlgo::deltaEt
static double deltaEt(const T *, const U *)
Definition: PFBenchmarkAlgo.h:120
HLT_FULL_cff.minDeltaR
minDeltaR
Definition: HLT_FULL_cff.py:26281
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
alignmentValidation.c1
c1
do drawing
Definition: alignmentValidation.py:1025
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
deltaEtSorter
Definition: PFBenchmarkAlgo.h:107
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
PFBenchmarkAlgo::vector_sort
static void vector_sort(std::vector< T > &candidates, Sorter< T, U > S)
Definition: PFBenchmarkAlgo.h:65
NULL
#define NULL
Definition: scimark2.h:8
T
long double T
Definition: Basic3DVectorLD.h:48
HLT_FULL_cff.candidates
candidates
Definition: HLT_FULL_cff.py:54985
Exception
Definition: hltDiff.cc:246
PFBenchmarkAlgo::sortByDeltaR
static void sortByDeltaR(const T *, Collection &)
Definition: PFBenchmarkAlgo.h:264
S
Definition: CSCDBL1TPParametersExtended.h:16
PFBenchmarkAlgo::sortByDeltaEt
static void sortByDeltaEt(const T *, Collection &)
Definition: PFBenchmarkAlgo.h:279
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
PFBenchmarkAlgo::deltaEta
static double deltaEta(const T *, const U *)
Definition: PFBenchmarkAlgo.h:129
PFBenchmarkAlgo::deltaPhi
static double deltaPhi(const T *, const U *)
Definition: PFBenchmarkAlgo.h:138