CMS 3D CMS Logo

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
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, trigObjTnPSource_cfi::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 }
T getParameter(std::string const &) const
Variable var_
Definition: JetCharge.h:46
double exp_
Definition: JetCharge.h:47

Member Function Documentation

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

Definition at line 7 of file JetCharge.cc.

Referenced by JetCharge(), and 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 }
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
const_iterator end() const
last daughter const_iterator
Definition: Candidate.h:146
const_iterator begin() const
first daughter const_iterator
Definition: Candidate.h:144
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 end, getWeight(), EgammaValidation_cff::num, getGTfromDQMFile::obj, and w.

Referenced by JetCharge().

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 }
const double w
Definition: UKUtility.cc:23
#define end
Definition: vmac.h:39
std::vector< LinkConnSpec >::const_iterator IT
double getWeight(const LorentzVector &lv, const T &obj) const
Definition: JetCharge.h:81
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.

Referenced by JetCharge().

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 end, getWeight(), EgammaValidation_cff::num, getGTfromDQMFile::obj, and w.

Referenced by JetCharge().

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 }
const double w
Definition: UKUtility.cc:23
#define end
Definition: vmac.h:39
std::vector< LinkConnSpec >::const_iterator IT
double getWeight(const LorentzVector &lv, const T &obj) const
Definition: JetCharge.h:81
#define begin
Definition: vmac.h:32
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(), electronAnalyzer_cfi::DeltaR, exp_, dqm-mbProfile::log, funct::pow(), Pt, RelEta, RelPt, runTheMatrix::ret, mathSSE::sqrt(), Unit, and var_.

Referenced by chargeFromRef(), chargeFromValIterator(), and JetCharge().

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 }
Definition: DeltaR.py:1
ret
prodAgent to be discontinued
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:30

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().