CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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:46
JetCharge::JetCharge ( const edm::ParameterSet iCfg)

Definition at line 19 of file JetCharge.cc.

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

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

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>(parent.p4(),parent.begin(),parent.end());
17 }
virtual const_iterator end() const =0
last daughter const_iterator
virtual const_iterator begin() const =0
first daughter const_iterator
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 69 of file JetCharge.h.

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

69  {
70  typedef typename C::const_iterator IT;
71  double num = 0.0, den = 0.0;
72  for (IT it = vec.begin(), end = vec.end(); it != end ; ++it) {
73  const T & obj = *it;
74  double w = getWeight(lv, *obj);
75  den += w;
76  num += w * obj->charge();
77  }
78  return (den > 0.0 ? num/den : 0.0);
79 }
#define end
Definition: vmac.h:37
std::vector< LinkConnSpec >::const_iterator IT
double getWeight(const LorentzVector &lv, const T &obj) const
Definition: JetCharge.h:82
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 63 of file JetCharge.h.

63  {
64  typedef typename C::const_iterator IT;
65  return JetCharge::chargeFromValIterator<T,IT>(lv, vec.begin(), vec.end());
66 }
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 51 of file JetCharge.h.

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

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

Definition at line 82 of file JetCharge.h.

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

Referenced by chargeFromRef(), and chargeFromValIterator().

82  {
83  double ret;
84  switch (var_) {
85  case Pt:
86  ret = obj.pt();
87  break;
88  case DeltaR:
89  ret = ROOT::Math::VectorUtil::DeltaR(lv.Vect(), obj.momentum());
90  break;
91  case RelPt:
92  case RelEta:
93  ret = lv.Vect().Dot(obj.momentum())/(lv.P() * obj.p()); // cos(theta)
94  ret = (var_ == RelPt ?
95  std::sqrt(1 - ret*ret) * obj.p() : // p * sin(theta) = pt
96  - 0.5 * std::log((1-ret)/(1+ret))); // = - log tan theta/2 = eta
97  break;
98  case Unit:
99  default:
100  ret = 1.0;
101  }
102  return (exp_ == 1.0 ? ret : (ret > 0 ?
103  std::pow(ret,exp_) :
104  - std::pow(std::abs(ret), exp_)));
105 }
Definition: deltaR.h:79
Variable var_
Definition: JetCharge.h:46
T sqrt(T t)
Definition: SSEVec.h:48
double exp_
Definition: JetCharge.h:46
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:40

Member Data Documentation

double JetCharge::exp_
private

Definition at line 46 of file JetCharge.h.

Referenced by getWeight().

Variable JetCharge::var_
private

Definition at line 46 of file JetCharge.h.

Referenced by getWeight(), and JetCharge().