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::CandidateCollection &vec) const
 
double charge (const LorentzVector &lv, const reco::TrackCollection &vec) const
 
double charge (const LorentzVector &lv, const reco::TrackRefVector &vec) const
 
double charge (const reco::Candidate &parent) const
 
 JetCharge (const edm::ParameterSet &iCfg)
 
 JetCharge (Variable var, double exponent=1.0)
 

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

◆ LorentzVector

Definition at line 21 of file JetCharge.h.

◆ Vector

Definition at line 22 of file JetCharge.h.

Member Enumeration Documentation

◆ Variable

Enumerator
Pt 
RelPt 
RelEta 
DeltaR 
Unit 

Definition at line 20 of file JetCharge.h.

20 { Pt, RelPt, RelEta, DeltaR, Unit };

Constructor & Destructor Documentation

◆ JetCharge() [1/2]

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

Definition at line 24 of file JetCharge.h.

24 : var_(var), exp_(exponent) {}

◆ JetCharge() [2/2]

JetCharge::JetCharge ( const edm::ParameterSet iCfg)

Definition at line 20 of file JetCharge.cc.

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 }

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

Member Function Documentation

◆ charge() [1/4]

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 }

◆ charge() [2/4]

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

Definition at line 7 of file JetCharge.cc.

7  {
8  return chargeFromVal<reco::Track, reco::TrackCollection>(lv, vec);
9 }

Referenced by JetChargeProducer::produce().

◆ charge() [3/4]

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 }

◆ charge() [4/4]

double JetCharge::charge ( const reco::Candidate parent) const

Definition at line 15 of file JetCharge.cc.

15  {
16  return chargeFromValIterator<reco::Candidate, reco::Candidate::const_iterator>(
17  parent.p4(), parent.begin(), parent.end());
18 }

References class-composition::parent.

◆ chargeFromRef()

template<typename T , typename C >
double JetCharge::chargeFromRef ( const LorentzVector lv,
const C &  vec 
) const
private

Definition at line 68 of file JetCharge.h.

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 }

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

◆ chargeFromVal()

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 }

◆ chargeFromValIterator()

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.

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 }

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

◆ getWeight()

template<class T >
double JetCharge::getWeight ( const LorentzVector lv,
const T obj 
) const
private

Definition at line 81 of file JetCharge.h.

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 }

References funct::abs(), DeltaR, electronAnalyzer_cfi::DeltaR, exp_, dqm-mbProfile::log, getGTfromDQMFile::obj, funct::pow(), Pt, RelEta, RelPt, runTheMatrix::ret, mathSSE::sqrt(), Unit, and var_.

Referenced by chargeFromRef(), and chargeFromValIterator().

Member Data Documentation

◆ exp_

double JetCharge::exp_
private

Definition at line 47 of file JetCharge.h.

Referenced by getWeight().

◆ var_

Variable JetCharge::var_
private

Definition at line 46 of file JetCharge.h.

Referenced by getWeight(), and JetCharge().

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:542
JetCharge::var_
Variable var_
Definition: JetCharge.h:46
trigObjTnPSource_cfi.var
var
Definition: trigObjTnPSource_cfi.py:21
JetCharge::DeltaR
Definition: JetCharge.h:20
w
const double w
Definition: UKUtility.cc:23
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
mps_fire.end
end
Definition: mps_fire.py:242
HLT_FULL_cff.exponent
exponent
Definition: HLT_FULL_cff.py:52795
JetCharge::exp_
double exp_
Definition: JetCharge.h:47
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
JetCharge::RelEta
Definition: JetCharge.h:20
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
JetCharge::Pt
Definition: JetCharge.h:20
electronAnalyzer_cfi.DeltaR
DeltaR
Definition: electronAnalyzer_cfi.py:33
IT
std::vector< LinkConnSpec >::const_iterator IT
Definition: TriggerBoardSpec.cc:5
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
JetCharge::getWeight
double getWeight(const LorentzVector &lv, const T &obj) const
Definition: JetCharge.h:81
JetCharge::RelPt
Definition: JetCharge.h:20
JetCharge::Unit
Definition: JetCharge.h:20
T
long double T
Definition: Basic3DVectorLD.h:48
Exception
Definition: hltDiff.cc:245
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
class-composition.parent
parent
Definition: class-composition.py:88