CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
JetCharge Class Reference

#include <JetCharge.h>

Public Types

typedef
reco::Particle::LorentzVector 
LorentzVector
 
enum  Variable {
  Pt, RelPt, RelEta, DeltaR,
  Unit
}
 
typedef reco::Particle::Vector Vector
 

Public Member Functions

double charge (const LorentzVector &lv, const reco::TrackCollection &vec) const
 
double charge (const LorentzVector &lv, const reco::TrackRefVector &vec) const
 
double charge (const LorentzVector &lv, const reco::CandidateCollection &vec) const
 
double charge (const reco::Candidate &parent) const
 
 JetCharge (Variable var, double exponent=1.0)
 
 JetCharge (const edm::ParameterSet &iCfg)
 

Private Member Functions

template<typename T , typename C >
double chargeFromRef (const LorentzVector &lv, const C &vec) const
 
template<typename T , typename C >
double chargeFromVal (const LorentzVector &lv, const C &vec) const
 
template<typename T , typename IT >
double chargeFromValIterator (const LorentzVector &lv, const IT &begin, const IT &end) const
 
template<class T >
double getWeight (const LorentzVector &lv, const T &obj) const
 

Private Attributes

double exp_
 
Variable var_
 

Detailed Description

Definition at line 18 of file JetCharge.h.

Member Typedef Documentation

Definition at line 21 of file JetCharge.h.

Definition at line 22 of file JetCharge.h.

Member Enumeration Documentation

Enumerator
Pt 
RelPt 
RelEta 
DeltaR 
Unit 

Definition at line 20 of file JetCharge.h.

Constructor & Destructor Documentation

JetCharge::JetCharge ( Variable  var,
double  exponent = 1.0 
)
inline

Definition at line 24 of file JetCharge.h.

24 : var_(var), exp_(exponent) {}
Variable var_
Definition: JetCharge.h:46
double exp_
Definition: JetCharge.h:47
JetCharge::JetCharge ( const edm::ParameterSet iCfg)

Definition at line 20 of file JetCharge.cc.

References DeltaR, Exception, edm::ParameterSet::getParameter(), Pt, RelEta, RelPt, AlCaHLTBitMon_QueryRunRegistry::string, Unit, ALCARECOEcalPhiSym_cff::var, and var_.

20  : var_(Pt), exp_(iCfg.getParameter<double>("exp")) {
21  std::string var = iCfg.getParameter<std::string>("var");
22  if (var == "Pt") {
23  var_ = Pt;
24  } else if (var == "RelPt") {
25  var_ = RelPt;
26  } else if (var == "RelEta") {
27  var_ = RelEta;
28  } else if (var == "DeltaR") {
29  var_ = DeltaR;
30  } else if (var == "Unit") {
31  var_ = Unit;
32  } else {
33  throw cms::Exception("Configuration error") << "Unknown variable " << var.c_str() << " for computing jet charge";
34  }
35 }
Variable var_
Definition: JetCharge.h:46
double exp_
Definition: JetCharge.h:47
T getParameter(std::string const &) const
Definition: ParameterSet.h:303

Member Function Documentation

double JetCharge::charge ( const LorentzVector lv,
const reco::TrackCollection vec 
) const

Definition at line 7 of file JetCharge.cc.

Referenced by JetChargeProducer::produce().

7  {
8  return chargeFromVal<reco::Track, reco::TrackCollection>(lv, vec);
9 }
double JetCharge::charge ( const LorentzVector lv,
const reco::TrackRefVector vec 
) const

Definition at line 11 of file JetCharge.cc.

11  {
12  return chargeFromRef<reco::TrackRef, reco::TrackRefVector>(lv, vec);
13 }
double JetCharge::charge ( const LorentzVector lv,
const reco::CandidateCollection vec 
) const

Definition at line 3 of file JetCharge.cc.

3  {
4  return chargeFromVal<reco::Candidate, reco::CandidateCollection>(lv, vec);
5 }
double JetCharge::charge ( const reco::Candidate parent) const

Definition at line 15 of file JetCharge.cc.

References reco::Candidate::begin(), reco::Candidate::end(), and reco::Candidate::p4().

15  {
16  return chargeFromValIterator<reco::Candidate, reco::Candidate::const_iterator>(
17  parent.p4(), parent.begin(), parent.end());
18 }
const_iterator end() const
last daughter const_iterator
Definition: Candidate.h:145
const_iterator begin() const
first daughter const_iterator
Definition: Candidate.h:143
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
template<typename T , typename C >
double JetCharge::chargeFromRef ( const LorentzVector lv,
const C &  vec 
) const
private

Definition at line 68 of file JetCharge.h.

References dataset::end, getWeight(), pileupDistInMC::num, getGTfromDQMFile::obj, and w().

68  {
69  typedef typename C::const_iterator IT;
70  double num = 0.0, den = 0.0;
71  for (IT it = vec.begin(), end = vec.end(); it != end; ++it) {
72  const T &obj = *it;
73  double w = getWeight(lv, *obj);
74  den += w;
75  num += w * obj->charge();
76  }
77  return (den > 0.0 ? num / den : 0.0);
78 }
std::vector< LinkConnSpec >::const_iterator IT
double getWeight(const LorentzVector &lv, const T &obj) const
Definition: JetCharge.h:81
string end
Definition: dataset.py:937
T w() const
long double T
template<typename T , typename C >
double JetCharge::chargeFromVal ( const LorentzVector lv,
const C &  vec 
) const
private

Definition at line 62 of file JetCharge.h.

62  {
63  typedef typename C::const_iterator IT;
64  return JetCharge::chargeFromValIterator<T, IT>(lv, vec.begin(), vec.end());
65 }
std::vector< LinkConnSpec >::const_iterator IT
template<typename T , typename IT >
double JetCharge::chargeFromValIterator ( const LorentzVector lv,
const IT begin,
const IT end 
) const
private

Definition at line 50 of file JetCharge.h.

References dataset::end, getWeight(), pileupDistInMC::num, getGTfromDQMFile::obj, and w().

50  {
51  double num = 0.0, den = 0.0;
52  for (IT it = begin; it != end; ++it) {
53  const T &obj = *it;
54  double w = getWeight(lv, obj);
55  den += w;
56  num += w * obj.charge();
57  }
58  return (den > 0.0 ? num / den : 0.0);
59 }
std::vector< LinkConnSpec >::const_iterator IT
double getWeight(const LorentzVector &lv, const T &obj) const
Definition: JetCharge.h:81
string end
Definition: dataset.py:937
T w() const
long double T
template<class T >
double JetCharge::getWeight ( const LorentzVector lv,
const T obj 
) const
private

Definition at line 81 of file JetCharge.h.

References funct::abs(), HLT_FULL_cff::DeltaR, exp_, log, funct::pow(), Pt, RelEta, RelPt, runTheMatrix::ret, mathSSE::sqrt(), Unit, and var_.

Referenced by chargeFromRef(), and chargeFromValIterator().

81  {
82  double ret;
83  switch (var_) {
84  case Pt:
85  ret = obj.pt();
86  break;
87  case DeltaR:
88  ret = ROOT::Math::VectorUtil::DeltaR(lv.Vect(), obj.momentum());
89  break;
90  case RelPt:
91  case RelEta:
92  ret = lv.Vect().Dot(obj.momentum()) / (lv.P() * obj.p()); // cos(theta)
93  ret = (var_ == RelPt ? std::sqrt(1 - ret * ret) * obj.p() : // p * sin(theta) = pt
94  -0.5 * std::log((1 - ret) / (1 + ret))); // = - log tan theta/2 = eta
95  break;
96  case Unit:
97  default:
98  ret = 1.0;
99  }
100  return (exp_ == 1.0 ? ret : (ret > 0 ? std::pow(ret, exp_) : -std::pow(std::abs(ret), exp_)));
101 }
tuple ret
prodAgent to be discontinued
static std::vector< std::string > checklist log
Definition: deltaR.h:58
Variable var_
Definition: JetCharge.h:46
T sqrt(T t)
Definition: SSEVec.h:19
double exp_
Definition: JetCharge.h:47
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

Member Data Documentation

double JetCharge::exp_
private

Definition at line 47 of file JetCharge.h.

Referenced by getWeight().

Variable JetCharge::var_
private

Definition at line 46 of file JetCharge.h.

Referenced by getWeight(), and JetCharge().