CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

JetCharge Class Reference

#include <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 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 (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

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.

: var_(var), exp_(exponent) { }
JetCharge::JetCharge ( const edm::ParameterSet iCfg)

Definition at line 19 of file JetCharge.cc.

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

                                                :
var_(Pt),
exp_(iCfg.getParameter<double>("exp")) {
        std::string var = iCfg.getParameter<std::string>("var");
        if (var == "Pt") {
                var_ = Pt;
        } else if (var == "RelPt") {
                var_ = RelPt;
        } else if (var == "RelEta") {
                var_ = RelEta;
        } else if (var == "DeltaR") {
                var_ = DeltaR;
        } else if (var == "Unit") {
                var_ = Unit;
        } else  {
                throw cms::Exception("Configuration error") << "Unknown variable " 
                        << var.c_str() << " for computing jet charge";
        }
}

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

                                                                                      {
    return chargeFromVal<reco::Track,reco::TrackCollection>(lv, vec);
}
double JetCharge::charge ( const LorentzVector lv,
const reco::TrackRefVector vec 
) const

Definition at line 11 of file JetCharge.cc.

                                                                                     {
    return chargeFromRef<reco::TrackRef,reco::TrackRefVector>(lv, vec);
}
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().

                                                          {
    return chargeFromValIterator<reco::Candidate,reco::Candidate::const_iterator>(parent.p4(),parent.begin(),parent.end()); 
}
double JetCharge::charge ( const LorentzVector lv,
const reco::CandidateCollection vec 
) const

Definition at line 3 of file JetCharge.cc.

                                                                                          {
    return chargeFromVal<reco::Candidate,reco::CandidateCollection>(lv, vec);
}
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(), getGTfromDQMFile::obj, and w().

                                                                           {
    typedef typename C::const_iterator IT;
    double num = 0.0, den = 0.0;
    for (IT it = vec.begin(), end = vec.end(); it != end ; ++it) {
        const T & obj = *it;
        double w = getWeight(lv, *obj);
        den += w;
        num += w * obj->charge();
    }
    return (den > 0.0 ? num/den : 0.0);
}
template<typename T , typename C >
double JetCharge::chargeFromVal ( const LorentzVector lv,
const C &  vec 
) const [private]

Definition at line 63 of file JetCharge.h.

                                                                           {
    typedef typename C::const_iterator IT;
    return JetCharge::chargeFromValIterator<T,IT>(lv, vec.begin(), vec.end());
}
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(), getGTfromDQMFile::obj, and w().

                                                                                                     {
    double num = 0.0, den = 0.0;
    for (IT it = begin; it != end ; ++it) {
        const T & obj = *it;
        double w = getWeight(lv, obj);
        den += w;
        num += w * obj.charge(); 
    }
    return (den > 0.0 ? num/den : 0.0);
}
template<class T >
double JetCharge::getWeight ( const LorentzVector lv,
const T obj 
) const [private]

Definition at line 82 of file JetCharge.h.

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

Referenced by chargeFromRef(), and chargeFromValIterator().

                                                                       { 
    double ret;
    switch (var_) {
        case Pt: 
            ret = obj.pt(); 
            break;
        case DeltaR: 
            ret = ROOT::Math::VectorUtil::DeltaR(lv.Vect(), obj.momentum());
            break;
        case RelPt: 
        case RelEta: 
            ret =  lv.Vect().Dot(obj.momentum())/(lv.P() * obj.p()); // cos(theta)
            ret =  (var_ == RelPt ? 
                std::sqrt(1 - ret*ret) * obj.p() :    // p * sin(theta) = pt
            - 0.5 * std::log((1-ret)/(1+ret)));   // = - log tan theta/2 = eta
            break;
        case Unit:
        default:
            ret = 1.0;
    }
    return (exp_ == 1.0 ? ret :  (ret > 0 ? 
                                std::pow(ret,exp_) : 
                                - std::pow(std::abs(ret), exp_)));
}

Member Data Documentation

double JetCharge::exp_ [private]

Definition at line 46 of file JetCharge.h.

Referenced by getWeight().

Definition at line 46 of file JetCharge.h.

Referenced by getWeight(), and JetCharge().