CMS 3D CMS Logo

JetCharge.h
Go to the documentation of this file.
1 #ifndef RecoJets_JetCharge_JetCharge_H
2 #define RecoJets_JetCharge_JetCharge_H
3 
6 //#include "DataFormats/Candidate/interface/CandidateFwd.h"
12 #include <Math/VectorUtil.h>
13 #include <Math/Rotation3D.h>
14 #include <Math/RotationZ.h>
15 #include <Math/RotationY.h>
16 #include <cmath>
17 
18 class JetCharge {
19 public:
23 
25  JetCharge(const edm::ParameterSet &iCfg);
26 
27  double charge(const LorentzVector &lv, const reco::TrackCollection &vec) const;
28  double charge(const LorentzVector &lv, const reco::TrackRefVector &vec) const;
29  double charge(const LorentzVector &lv, const reco::CandidateCollection &vec) const;
30  double charge(const reco::Candidate &parent) const;
31  //double charge(const LorentzVector &lv, const reco::CandidateRefVector &vec) const ;
32 
33 private:
34  // functions
35  template <typename T, typename C>
36  double chargeFromRef(const LorentzVector &lv, const C &vec) const;
37  template <typename T, typename C>
38  double chargeFromVal(const LorentzVector &lv, const C &vec) const;
39  template <typename T, typename IT>
40  double chargeFromValIterator(const LorentzVector &lv, const IT &begin, const IT &end) const;
41 
42  template <class T>
43  double getWeight(const LorentzVector &lv, const T &obj) const;
44 
45  // data members
47  double exp_;
48 };
49 template <typename T, typename IT>
50 double JetCharge::chargeFromValIterator(const LorentzVector &lv, const IT &begin, const IT &end) const {
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 }
60 
61 template <typename T, typename C>
62 double JetCharge::chargeFromVal(const LorentzVector &lv, const C &vec) const {
63  typedef typename C::const_iterator IT;
64  return JetCharge::chargeFromValIterator<T, IT>(lv, vec.begin(), vec.end());
65 }
66 
67 template <typename T, typename C>
68 double JetCharge::chargeFromRef(const LorentzVector &lv, const C &vec) const {
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 }
79 
80 template <class T>
81 double JetCharge::getWeight(const LorentzVector &lv, const T &obj) const {
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 }
102 
103 #endif
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:543
CompositeCandidate.h
Vector.h
JetCharge::var_
Variable var_
Definition: JetCharge.h:46
JetCharge::Vector
reco::Particle::Vector Vector
Definition: JetCharge.h:22
JetCharge::chargeFromRef
double chargeFromRef(const LorentzVector &lv, const C &vec) const
Definition: JetCharge.h:68
edm::RefVector< TrackCollection >
JetCharge::JetCharge
JetCharge(Variable var, double exponent=1.0)
Definition: JetCharge.h:24
reco::Particle::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
trigObjTnPSource_cfi.var
var
Definition: trigObjTnPSource_cfi.py:21
reco::Particle::Vector
math::XYZVector Vector
point in the space
Definition: Particle.h:27
Track.h
TrackFwd.h
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:52824
JetCharge::exp_
double exp_
Definition: JetCharge.h:47
JetCharge::charge
double charge(const LorentzVector &lv, const reco::TrackCollection &vec) const
Definition: JetCharge.cc:7
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
JetCharge::RelEta
Definition: JetCharge.h:20
edm::ParameterSet
Definition: ParameterSet.h:47
JetCharge
Definition: JetCharge.h:18
LorentzVector.h
JetCharge::Pt
Definition: JetCharge.h:20
JetCharge::chargeFromVal
double chargeFromVal(const LorentzVector &lv, const C &vec) const
Definition: JetCharge.h:62
electronAnalyzer_cfi.DeltaR
DeltaR
Definition: electronAnalyzer_cfi.py:33
JetCharge::LorentzVector
reco::Particle::LorentzVector LorentzVector
Definition: JetCharge.h:21
IT
std::vector< LinkConnSpec >::const_iterator IT
Definition: TriggerBoardSpec.cc:5
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:33
reco::Candidate
Definition: Candidate.h:27
JetCharge::getWeight
double getWeight(const LorentzVector &lv, const T &obj) const
Definition: JetCharge.h:81
JetCharge::RelPt
Definition: JetCharge.h:20
gen::C
C
Definition: PomwigHadronizer.cc:78
JetCharge::Unit
Definition: JetCharge.h:20
T
long double T
Definition: Basic3DVectorLD.h:48
LorentzVector
math::XYZTLorentzVector LorentzVector
Definition: HLTMuonMatchAndPlot.h:49
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
Candidate.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
JetCharge::chargeFromValIterator
double chargeFromValIterator(const LorentzVector &lv, const IT &begin, const IT &end) const
Definition: JetCharge.h:50
class-composition.parent
parent
Definition: class-composition.py:98
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
JetCharge::Variable
Variable
Definition: JetCharge.h:20
edm::OwnVector
Definition: OwnVector.h:24