CMS 3D CMS Logo

JetCharge Class Reference

#include <PhysicsTools/JetCharge/interface/JetCharge.h>

List of all members.

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 reco::Candidate &parent) const
double charge (const LorentzVector &lv, const reco::CandidateCollection &vec) const
double charge (const LorentzVector &lv, const reco::TrackRefVector &vec) const
double charge (const LorentzVector &lv, const reco::TrackCollection &vec) 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

typedef reco::Particle::LorentzVector JetCharge::LorentzVector

Definition at line 21 of file JetCharge.h.

typedef reco::Particle::Vector JetCharge::Vector

Definition at line 22 of file JetCharge.h.


Member Enumeration Documentation

enum JetCharge::Variable

Enumerator:
Pt 
RelPt 
RelEta 
DeltaR 
Unit 

Definition at line 20 of file JetCharge.h.

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


Constructor & Destructor Documentation

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

Definition at line 24 of file JetCharge.h.

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

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

Definition at line 19 of file JetCharge.cc.

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

00019                                                 :
00020 var_(Pt),
00021 exp_(iCfg.getParameter<double>("exp")) {
00022         std::string var = iCfg.getParameter<std::string>("var");
00023         if (var == "Pt") {
00024                 var_ = Pt;
00025         } else if (var == "RelPt") {
00026                 var_ = RelPt;
00027         } else if (var == "RelEta") {
00028                 var_ = RelEta;
00029         } else if (var == "DeltaR") {
00030                 var_ = DeltaR;
00031         } else if (var == "Unit") {
00032                 var_ = Unit;
00033         } else  {
00034                 throw cms::Exception("Configuration error") << "Unknown variable " 
00035                         << var.c_str() << " for computing jet charge";
00036         }
00037 }


Member Function Documentation

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::Particle::p4().

00015                                                           {
00016     return chargeFromValIterator<reco::Candidate,reco::Candidate::const_iterator>(parent.p4(),parent.begin(),parent.end()); 
00017 }

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

Definition at line 3 of file JetCharge.cc.

00003                                                                                           {
00004     return chargeFromVal<reco::Candidate,reco::CandidateCollection>(lv, vec);
00005 }

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

Definition at line 11 of file JetCharge.cc.

00011                                                                                      {
00012     return chargeFromRef<reco::TrackRef,reco::TrackRefVector>(lv, vec);
00013 }

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

Definition at line 7 of file JetCharge.cc.

Referenced by JetChargeProducer::produce().

00007                                                                                       {
00008     return chargeFromVal<reco::Track,reco::TrackCollection>(lv, vec);
00009 }

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

Definition at line 69 of file JetCharge.h.

References end, getWeight(), it, funct::num(), VarParsing::obj, and w.

00069                                                                            {
00070     typedef typename C::const_iterator IT;
00071     double num = 0.0, den = 0.0;
00072     for (IT it = vec.begin(), end = vec.end(); it != end ; ++it) {
00073         const T & obj = *it;
00074         double w = getWeight(lv, *obj);
00075         den += w;
00076         num += w * obj->charge();
00077     }
00078     return (den > 0.0 ? num/den : 0.0);
00079 }

template<typename T, typename C>
double JetCharge::chargeFromVal ( const LorentzVector lv,
const C &  vec 
) const [inline, private]

Definition at line 63 of file JetCharge.h.

00063                                                                            {
00064     typedef typename C::const_iterator IT;
00065     return JetCharge::chargeFromValIterator<T,IT>(lv, vec.begin(), vec.end());
00066 }

template<typename T, typename IT>
double JetCharge::chargeFromValIterator ( const LorentzVector lv,
const IT begin,
const IT end 
) const [inline, private]

Definition at line 51 of file JetCharge.h.

References getWeight(), it, funct::num(), VarParsing::obj, and w.

00051                                                                                                      {
00052     double num = 0.0, den = 0.0;
00053     for (IT it = begin; it != end ; ++it) {
00054         const T & obj = *it;
00055         double w = getWeight(lv, obj);
00056         den += w;
00057         num += w * obj.charge(); 
00058     }
00059     return (den > 0.0 ? num/den : 0.0);
00060 }

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

Definition at line 82 of file JetCharge.h.

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

Referenced by chargeFromRef(), and chargeFromValIterator().

00082                                                                        { 
00083     double ret;
00084     switch (var_) {
00085         case Pt: 
00086             ret = obj.pt(); 
00087             break;
00088         case DeltaR: 
00089             ret = ROOT::Math::VectorUtil::DeltaR(lv.Vect(), obj.momentum());
00090             break;
00091         case RelPt: 
00092         case RelEta: 
00093             ret =  lv.Vect().Dot(obj.momentum())/(lv.P() * obj.p()); // cos(theta)
00094             ret =  (var_ == RelPt ? 
00095                 std::sqrt(1 - ret*ret) * obj.p() :    // p * sin(theta) = pt
00096             - 0.5 * std::log((1-ret)/(1+ret)));   // = - log tan theta/2 = eta
00097             break;
00098         case Unit:
00099         default:
00100             ret = 1.0;
00101     }
00102     return (exp_ == 1.0 ? ret :  (ret > 0 ? 
00103                                 std::pow(ret,exp_) : 
00104                                 - std::pow(std::abs(ret), exp_)));
00105 }


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


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:26:02 2009 for CMSSW by  doxygen 1.5.4