#include <RecoParticleFlow/Benchmark/interface/PFBenchmarkAlgo.h>
Static Public Member Functions | |
template<typename U, template< typename > class Collection> | |
static Collection< U > | copyCollection (const Collection< U > *) |
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 U, template< typename > class Collection> | |
static Collection< U > | findAllInCone (const T *, const Collection< U > *, double) |
template<typename T, typename U, template< typename > class Collection> | |
static Collection< U > | findAllInEtWindow (const T *, const Collection< U > *, double) |
template<typename T, typename U, template< typename > class Collection> | |
static const U * | matchByDeltaEt (const T *, const Collection< U > *) |
template<typename T, typename U, template< typename > class Collection> | |
static const U * | matchByDeltaR (const T *, const Collection< U > *) |
template<typename T, typename U, template< typename > class Collection> | |
static void | sortByDeltaEt (const T *, Collection< U > &) |
template<typename T, typename U, template< typename > class Collection> | |
static void | sortByDeltaR (const T *, Collection< U > &) |
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) |
Definition at line 16 of file PFBenchmarkAlgo.h.
Collection< U > PFBenchmarkAlgo::copyCollection | ( | const Collection< U > * | candidates | ) | [inline, static] |
Definition at line 240 of file PFBenchmarkAlgo.h.
References edmNew::copy(), Exception, i, and vector_add().
00240 { 00241 00242 // Try to verify the validity of the Collection 00243 if (!candidates) throw cms::Exception("Invalid Arg") << "attempted to copy invalid Collection"; 00244 00245 Collection<U> copy; 00246 00247 for (unsigned int i = 0; i < candidates->size(); i++) 00248 vector_add(&(*candidates)[i],copy); 00249 00250 return copy; 00251 00252 }
double PFBenchmarkAlgo::deltaEt | ( | const T * | c1, | |
const U * | c2 | |||
) | [inline, static] |
Definition at line 127 of file PFBenchmarkAlgo.h.
References Exception, and NULL.
Referenced by GenericBenchmark::fill(), findAllInEtWindow(), matchByDeltaEt(), and deltaEtSorter< T, U >::operator()().
00127 { 00128 00129 if (c1 == NULL || c2 == NULL) 00130 throw cms::Exception("Invalid Arg") << "attempted to calculate deltaEt for invalid Candidate(s)"; 00131 00132 return c1->et() - c2->et(); 00133 00134 }
double PFBenchmarkAlgo::deltaEta | ( | const T * | c1, | |
const U * | c2 | |||
) | [inline, static] |
Definition at line 138 of file PFBenchmarkAlgo.h.
References Exception, and NULL.
Referenced by deltaR(), and GenericBenchmark::fill().
00138 { 00139 00140 if (c1 == NULL || c2 == NULL) 00141 throw cms::Exception("Invalid Arg") << "attempted to calculate deltaEta for invalid Candidate(s)"; 00142 00143 return c1->eta() - c2->eta(); 00144 00145 }
double PFBenchmarkAlgo::deltaPhi | ( | const T * | c1, | |
const U * | c2 | |||
) | [inline, static] |
Definition at line 149 of file PFBenchmarkAlgo.h.
References Exception, and NULL.
Referenced by deltaR(), and GenericBenchmark::fill().
00149 { 00150 00151 if (c1 == NULL || c2 == NULL) 00152 throw cms::Exception("Invalid Arg") << "attempted to calculate deltaPhi for invalid Candidate(s)"; 00153 00154 00155 double phi1 = c1->phi(); 00156 if (phi1 > M_PI) phi1 -= ceil((phi1 - M_PI) / (2 * M_PI)) * 2 * M_PI; 00157 if (phi1 <= - M_PI) phi1 += ceil((phi1 + M_PI) / (-2. * M_PI)) * 2. * M_PI; 00158 00159 double phi2 = c2->phi(); 00160 if (phi2 > M_PI) phi2 -= ceil((phi2 - M_PI) / (2 * M_PI)) * 2 * M_PI; 00161 if (phi2 <= - M_PI) phi2 += ceil((phi2 + M_PI) / (-2. * M_PI)) * 2 * M_PI; 00162 00163 // alternative method: 00164 // while (phi > M_PI) phi -= 2 * M_PI; 00165 // while (phi <= - M_PI) phi += 2 * M_PI; 00166 00167 return ( (fabs(phi1 - phi2)<M_PI)?(phi1-phi2):(2*M_PI - fabs(phi1 - phi2) ) ); 00168 00169 }
double PFBenchmarkAlgo::deltaR | ( | const T * | c1, | |
const U * | c2 | |||
) | [inline, static] |
Definition at line 173 of file PFBenchmarkAlgo.h.
References deltaEta(), deltaPhi(), Exception, NULL, funct::pow(), and funct::sqrt().
Referenced by GenericBenchmark::fill(), findAllInCone(), matchByDeltaR(), deltaRSorter< T, U >::operator()(), and PFJetBenchmark::process().
00173 { 00174 00175 if (c1 == NULL || c2 == NULL) 00176 throw cms::Exception("Invalid Arg") << "attempted to calculate deltaR for invalid Candidate(s)"; 00177 00178 return sqrt(pow(deltaPhi(c1,c2),2) + pow(deltaEta(c1,c2),2)); 00179 00180 }
Collection< U > PFBenchmarkAlgo::findAllInCone | ( | const T * | c1, | |
const Collection< U > * | candidates, | |||
double | ConeSize | |||
) | [inline, static] |
Definition at line 283 of file PFBenchmarkAlgo.h.
References c2, deltaR(), Exception, i, sortByDeltaR(), and vector_add().
00283 { 00284 00285 // Try to verify the validity of Candidate and the Collection 00286 if (!c1) throw cms::Exception("Invalid Arg") << "attempted to constrain to invalid Candidate"; 00287 if (!candidates) throw cms::Exception("Invalid Arg") << "attempted to constrain invalid Collection"; 00288 if (ConeSize <= 0) throw cms::Exception("Invalid Arg") << "zero or negative cone size specified"; 00289 00290 Collection<U> constrained; 00291 00292 for (unsigned int i = 0; i < candidates->size(); i++) { 00293 00294 const U *c2 = &(*candidates)[i]; 00295 00296 // Add in-cone Candidates to the new Collection 00297 double dR = deltaR(c1,c2); 00298 if (dR < ConeSize) vector_add(c2,constrained); 00299 00300 } 00301 00302 // Sort and return Collection 00303 sortByDeltaR(c1,constrained); 00304 return constrained; 00305 00306 }
Collection< U > PFBenchmarkAlgo::findAllInEtWindow | ( | const T * | c1, | |
const Collection< U > * | candidates, | |||
double | EtWindow | |||
) | [inline, static] |
Definition at line 310 of file PFBenchmarkAlgo.h.
References c2, deltaEt(), Exception, i, sortByDeltaEt(), and vector_add().
00310 { 00311 00312 // Try to verify the validity of Candidate and the Collection 00313 if (!c1) throw cms::Exception("Invalid Arg") << "attempted to constrain to invalid Candidate"; 00314 if (!candidates) throw cms::Exception("Invalid Arg") << "attempted to constrain invalid Collection"; 00315 if (EtWindow <= 0) throw cms::Exception("Invalid Arg") << "zero or negative cone size specified"; 00316 00317 Collection<U> constrained; 00318 00319 //CandidateCollection::const_iterator candidate; 00320 //for (candidate = candidates->begin(); candidate != candidates->end(); candidate++) { 00321 for (unsigned int i = 0; i < candidates->size(); i++) { 00322 00323 const U *c2 = &(*candidates)[i]; 00324 00325 // Add in-cone Candidates to the new Collection 00326 double dEt = fabs(deltaEt(c1,c2)); 00327 if (dEt < EtWindow) vector_add(c2,constrained); 00328 00329 } 00330 00331 // Sort and return Collection 00332 sortByDeltaEt(c1,constrained); 00333 return constrained; 00334 00335 }
const U * PFBenchmarkAlgo::matchByDeltaEt | ( | const T * | c1, | |
const Collection< U > * | candidates | |||
) | [inline, static] |
Definition at line 212 of file PFBenchmarkAlgo.h.
References c2, deltaEt(), Exception, i, edm::match(), and NULL.
00212 { 00213 00214 // Try to verify the validity of the Candidate and Collection 00215 if (!c1) throw cms::Exception("Invalid Arg") << "attempted to match invalid Candidate"; 00216 if (!candidates) throw cms::Exception("Invalid Arg") << "attempted to match to invalid Collection"; 00217 00218 double minDeltaEt = 9999.; 00219 const U *match = NULL; 00220 00221 // Loop Over the Candidates... 00222 for (unsigned int i = 0; i < candidates->size(); i++) { 00223 00224 const T *c2 = &(*candidates)[i]; 00225 if (!c2) throw cms::Exception("Invalid Arg") << "attempted to match to invalid Candidate"; 00226 00227 // Find Minimal Delta-R 00228 double dEt = fabs(deltaEt(c1,c2)); 00229 if (dEt <= minDeltaEt) { match = c2; minDeltaEt = dEt; } 00230 00231 } 00232 00233 // Return the Candidate with the smallest dR 00234 return match; 00235 00236 }
const U * PFBenchmarkAlgo::matchByDeltaR | ( | const T * | c1, | |
const Collection< U > * | candidates | |||
) | [inline, static] |
Definition at line 184 of file PFBenchmarkAlgo.h.
References c2, deltaR(), Exception, i, edm::match(), and NULL.
Referenced by GenericBenchmark::fill(), and PFJetBenchmark::process().
00184 { 00185 00186 // Try to verify the validity of the Candidate and Collection 00187 if (!c1) throw cms::Exception("Invalid Arg") << "attempted to match invalid Candidate"; 00188 if (!candidates) throw cms::Exception("Invalid Arg") << "attempted to match to invalid Collection"; 00189 00190 double minDeltaR = 9999.; 00191 const U *match = NULL; 00192 00193 // Loop Over the Candidates... 00194 for (unsigned int i = 0; i < candidates->size(); i++) { 00195 00196 const U *c2 = &(*candidates)[i]; 00197 if (!c2) throw cms::Exception("Invalid Arg") << "attempted to match to invalid Candidate"; 00198 00199 // Find Minimal Delta-R 00200 double dR = deltaR(c1,c2); 00201 if (dR <= minDeltaR) { match = c2; minDeltaR = dR; } 00202 00203 } 00204 00205 // Return the Candidate with the smallest dR 00206 return match; 00207 00208 }
void PFBenchmarkAlgo::sortByDeltaEt | ( | const T * | c1, | |
Collection< U > & | candidates | |||
) | [inline, static] |
Definition at line 270 of file PFBenchmarkAlgo.h.
References Exception, and vector_sort().
Referenced by findAllInEtWindow().
00270 { 00271 00272 // Try to verify the validity of Candidate and Collection 00273 if (!c1) throw cms::Exception("Invalid Arg") << "attempted to sort by invalid Candidate"; 00274 if (!candidates) throw cms::Exception("Invalid Arg") << "attempted to sort invalid Candidates"; 00275 00276 // Sort the collection 00277 vector_sort(candidates,deltaEtSorter<T,U>(c1)); 00278 00279 }
void PFBenchmarkAlgo::sortByDeltaR | ( | const T * | c1, | |
Collection< U > & | candidates | |||
) | [inline, static] |
Definition at line 257 of file PFBenchmarkAlgo.h.
References Exception, and vector_sort().
Referenced by findAllInCone().
00257 { 00258 00259 // Try to verify the validity of Candidate and Collection 00260 if (!c1) throw cms::Exception("Invalid Arg") << "attempted to sort by invalid Candidate"; 00261 if (!candidates) throw cms::Exception("Invalid Arg") << "attempted to sort invalid Candidates"; 00262 00263 // Sort the collection 00264 vector_sort(candidates,deltaRSorter<T,U>(c1)); 00265 00266 }
static void PFBenchmarkAlgo::vector_add | ( | const T * | c1, | |
edm::OwnVector< T > & | candidates | |||
) | [inline, static, private] |
static void PFBenchmarkAlgo::vector_add | ( | const T * | c1, | |
std::vector< T > & | candidates | |||
) | [inline, static, private] |
Definition at line 73 of file PFBenchmarkAlgo.h.
Referenced by copyCollection(), findAllInCone(), and findAllInEtWindow().
00073 { 00074 candidates.push_back(*c1); 00075 }
static void PFBenchmarkAlgo::vector_sort | ( | edm::OwnVector< T > & | candidates, | |
Sorter< T, U > | S | |||
) | [inline, static, private] |
Definition at line 79 of file PFBenchmarkAlgo.h.
References edm::OwnVector< T, P >::sort().
00079 { 00080 candidates.sort(S); 00081 }
static void PFBenchmarkAlgo::vector_sort | ( | std::vector< T > & | candidates, | |
Sorter< T, U > | S | |||
) | [inline, static, private] |
Definition at line 67 of file PFBenchmarkAlgo.h.
References python::multivaluedict::sort().
Referenced by sortByDeltaEt(), and sortByDeltaR().
00067 { 00068 sort(candidates.begin(),candidates.end(),S); 00069 }