5#ifndef ANALYSISUTILS_ANALYSISMISC_H
6#define ANALYSISUTILS_ANALYSISMISC_H
24#ifndef XAOD_STANDALONE
25#include "CLHEP/Vector/LorentzVector.h"
31#ifndef XAOD_STANDALONE
40 double phi1 = (p1->phi()>
M_PI) ? p1->phi()-2*
M_PI : p1->phi();
41 double phi2 = (p2->phi()>
M_PI) ? p2->phi()-2*
M_PI : p2->phi();
42 double dphi = fabs(phi1-phi2);
50 double phi1 = (p1->phi()>
M_PI) ? p1->phi()-2*
M_PI : p1->phi();
51 double phi2 = (v_phi>
M_PI) ? v_phi-2*
M_PI : v_phi;
52 double dphi = fabs(phi1-phi2);
54 double deta = p1->eta() - v_eta;
55 return sqrt(dphi*dphi+deta*deta);
61 return R (p1, p2->eta(), p2->phi());
72 return (p1->hlv()+p2->hlv()).m();
77 return (p1->hlv()+p2->hlv()+p3->hlv()+p4->
hlv()).m();
93 inline bool R (
const double eta,
const double phi, COLL *coll,
int &
index,
double &
deltaR,
const int pdg)
96 bool l_return =
false;
98 typename COLL::const_iterator it = coll->begin();
99 typename COLL::const_iterator itE = coll->end();
100 for (; it != itE; ++it)
102 if (((*it)->pdgId()==pdg) || pdg==0 )
122 template <
class COLL>
123 inline bool R (
const double eta,
const double phi,
const double e, COLL *coll,
124 int &
index,
double &
deltaR,
const int pdg,
double &deltaE)
128 bool l_return =
false;
130 typename COLL::const_iterator it = coll->begin();
131 typename COLL::const_iterator itE = coll->end();
132 for (; it != itE; ++it)
134 if (((*it)->pdgId()==pdg) || pdg==0 )
137 double dE = fabs( e-(*it)->e() );
138 if ( rtu <
deltaR && dE < deltaE)
156 template <
class COLL>
159 return R (t->eta(), t->phi(), coll,
index,
deltaR, pdg);
167 template <
class COLL>
169 const int pdg,
double &deltaE)
171 return R (t->eta(), t->phi(), t->e(), coll,
index,
deltaR, pdg, deltaE);
177 template <
class COLL>
181 bool l_return =
false;
183 typename COLL::const_iterator it = coll->begin();
184 typename COLL::const_iterator itE = coll->end();
185 for (; it != itE; ++it)
202 template <
class COLL>
203 inline bool R (
const double eta,
const double phi,
const double e, COLL *coll,
int &
index,
204 double &
deltaR,
double &deltaE)
208 bool l_return =
false;
210 typename COLL::const_iterator it = coll->begin();
211 typename COLL::const_iterator itE = coll->end();
212 for (; it != itE; ++it)
215 double dE = fabs( e-(*it)->e() );
216 if ( rtu <
deltaR && dE < deltaE)
231 template <
class COLL>
240 template <
class COLL>
243 return R (t->eta(), t->phi(), t->e(), coll,
index,
deltaR, deltaE);
261 template <
class T>
inline bool compPt (T
a, T b)
263 return greater (
a->pt(), b->pt());
267 template <
class T>
inline bool compE (T
a, T b)
269 return greater (
a->e(), b->e());
275 return greater (
a->eta(), b->eta());
281 return greater (
a->phi(), b->phi());
287 template <
class COLL,
class COMP>
288 static void dosort (COLL& coll, COMP comp)
289 {
std::sort (coll.begin(), coll.end(), comp); }
295 template <
class COLL,
class COMP>
296 static void dosort (COLL& coll, COMP comp)
300 template <
class COLL,
class COMP>
301 inline void dosort (COLL& coll, COMP comp)
303 typedef typename std::remove_pointer<typename COLL::value_type>::type valtype;
305 const bool is_dv = std::is_convertible<COLL&, dvtype&>::value;
315 template <
class COLL>
inline void pT (COLL *coll)
325 template <
class COLL>
inline void e (COLL *coll)
335 template <
class COLL>
inline void eta (COLL *coll)
345 template <
class COLL>
inline void phi (COLL *coll)
352#ifndef XAOD_STANDALONE
365 template <
class COLL>
inline void charge (COLL *coll,
366 std::vector<typename COLL::value_type> &pos,
367 std::vector<typename COLL::value_type> &neg)
373 typename COLL::const_iterator it = coll->begin();
374 typename COLL::const_iterator itE = coll->end();
375 for (; it != itE; ++it)
377 if ((*it)->pdgId() > 0)
379 else if ((*it)->pdgId() < 0)
Scalar eta() const
pseudorapidity method
Scalar deltaR(const MatrixBase< Derived > &vec) const
Scalar phi() const
phi method
An STL vector of pointers that by default owns its pointed-to elements.
virtual CLHEP::HepLorentzVector hlv() const =0
CLHEP HepLorentzVector.
Workaround x86 precision issues for FP inequality comparisons.
void charge(COLL *coll, std::vector< typename COLL::value_type > &pos, std::vector< typename COLL::value_type > &neg)
classify by charge
double R(const INavigable4Momentum *p1, const double v_eta, const double v_phi)
double four(const INavigable4Momentum *p1, const INavigable4Momentum *p2, const INavigable4Momentum *p3, const INavigable4Momentum *p4)
double two(const INavigable4Momentum *p1, const INavigable4Momentum *p2)
find the closest element in a collection to an INavigable4Momentum
bool R(const double eta, const double phi, COLL *coll, int &index, double &deltaR, const int pdg)
find the closest element in R
void dosort(COLL &coll, COMP comp)
void pT(COLL *coll)
sort by pT
void e(COLL *coll)
sort by e
utility class to select combination of elements in a collection
bool greater(double a, double b)
Compare two FP numbers, working around x87 precision issues.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
static void dosort(COLL &coll, COMP comp)
static void dosort(COLL &coll, COMP comp)