CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

pat::DiObjectProxy Class Reference

#include <PATDiObjectProxy.h>

List of all members.

Public Member Functions

const reco::Candidatecand1 () const
 Gets the first Candidate.
const reco::Candidatecand2 () const
 Gets the second Candidate.
double deltaPhi () const
 Get the phi separation.
double deltaR () const
 Get the angular separation.
 DiObjectProxy (const reco::Candidate &c1, const reco::Candidate &c2)
 DiObjectProxy ()
 Default constructor, requested by ROOT. NEVER use a default constructed item!
const Electronele () const
 Get the PAT Electron, if the pair contains one and only one PAT Electron (throw exception otherwise)
const Electronele1 () const
 Get the first item, if it's a PAT Electron (throw exception otherwise)
const Electronele2 () const
 Get the second item, if it's a PAT Electron (throw exception otherwise)
const Photongam () const
 Get the PAT Photon, if the pair contains one and only one PAT Photon (throw exception otherwise)
const Photongam1 () const
 Get the first item, if it's a PAT Photon (throw exception otherwise)
const Photongam2 () const
 Get the second item, if it's a PAT Photon (throw exception otherwise)
const Jetjet () const
 Get the PAT Jet, if the pair contains one and only one PAT Jet (throw exception otherwise)
const Jetjet1 () const
 Get the first item, if it's a PAT Jet (throw exception otherwise)
const Jetjet2 () const
 Get the second item, if it's a PAT Jet (throw exception otherwise)
const METmet () const
 Get the PAT MET, if the pair contains one and only one PAT MET (throw exception otherwise)
const METmet1 () const
 Get the first item, if it's a PAT MET (throw exception otherwise)
const METmet2 () const
 Get the second item, if it's a PAT MET (throw exception otherwise)
const Muonmu () const
 Get the PAT Muon, if the pair contains one and only one PAT Muon (throw exception otherwise)
const Muonmu1 () const
 Get the first item, if it's a PAT Muon (throw exception otherwise)
const Muonmu2 () const
 Get the second item, if it's a PAT Muon (throw exception otherwise)
const GenericParticlepart () const
 Get the PAT GenericParticle, if the pair contains one and only one PAT GenericParticle (throw exception otherwise)
const GenericParticlepart1 () const
 Get the first item, if it's a PAT GenericParticle (throw exception otherwise)
const GenericParticlepart2 () const
 Get the second item, if it's a PAT GenericParticle (throw exception otherwise)
const PFParticlepf () const
 Get the PAT PFParticle, if the pair contains one and only one PAT PFParticle (throw exception otherwise)
const PFParticlepf1 () const
 Get the first item, if it's a PAT PFParticle (throw exception otherwise)
const PFParticlepf2 () const
 Get the second item, if it's a PAT PFParticle (throw exception otherwise)
const Tautau () const
 Get the PAT Tau, if the pair contains one and only one PAT Tau (throw exception otherwise)
const Tautau1 () const
 Get the first item, if it's a PAT Tau (throw exception otherwise)
const Tautau2 () const
 Get the second item, if it's a PAT Tau (throw exception otherwise)
const
reco::Candidate::LorentzVector
totalP4 () const
 Get the total four momentum.

Private Member Functions

template<typename T >
const TtryGet_ (const reco::Candidate *ptr, const std::type_info *type) const
template<typename T >
const TtryGetOne_ () const

Private Attributes

const reco::Candidatecand1_
const reco::Candidatecand2_
reco::Candidate::LorentzVector totalP4_
bool totalP4ok_
const std::type_info * type1_
const std::type_info * type2_

Detailed Description

Definition at line 19 of file PATDiObjectProxy.h.


Constructor & Destructor Documentation

pat::DiObjectProxy::DiObjectProxy ( ) [inline]

Default constructor, requested by ROOT. NEVER use a default constructed item!

Definition at line 23 of file PATDiObjectProxy.h.

: cand1_(0), cand2_(0), type1_(0), type2_(0), totalP4ok_(false), totalP4_()  {}
pat::DiObjectProxy::DiObjectProxy ( const reco::Candidate c1,
const reco::Candidate c2 
) [inline]

Constructor of the pair from two Candidates Note: the Proxy MUST NOT outlive the Candidates, otherwise you get dangling pointers

Definition at line 26 of file PATDiObjectProxy.h.

                                                                        :
            cand1_(&c1), cand2_(&c2), type1_(&typeid(c1)), type2_(&typeid(c2)), totalP4ok_(false), totalP4_() {}

Member Function Documentation

const reco::Candidate& pat::DiObjectProxy::cand1 ( ) const [inline]

Gets the first Candidate.

Definition at line 30 of file PATDiObjectProxy.h.

References cand1_.

{ return *cand1_; }
const reco::Candidate& pat::DiObjectProxy::cand2 ( ) const [inline]

Gets the second Candidate.

Definition at line 32 of file PATDiObjectProxy.h.

References cand2_.

{ return *cand2_; }
double pat::DiObjectProxy::deltaPhi ( void  ) const [inline]

Get the phi separation.

Definition at line 37 of file PATDiObjectProxy.h.

References cand1_, cand2_, and reco::Candidate::phi().

double pat::DiObjectProxy::deltaR ( ) const [inline]

Get the angular separation.

Definition at line 35 of file PATDiObjectProxy.h.

References cand1_, and cand2_.

const Electron& pat::DiObjectProxy::ele ( ) const [inline]

Get the PAT Electron, if the pair contains one and only one PAT Electron (throw exception otherwise)

Definition at line 51 of file PATDiObjectProxy.h.

{ return tryGetOne_<Electron>(); }
const Electron& pat::DiObjectProxy::ele1 ( ) const [inline]

Get the first item, if it's a PAT Electron (throw exception otherwise)

Definition at line 68 of file PATDiObjectProxy.h.

References cand1_, and type1_.

{ return tryGet_<Electron>(cand1_, type1_); }
const Electron& pat::DiObjectProxy::ele2 ( ) const [inline]

Get the second item, if it's a PAT Electron (throw exception otherwise)

Definition at line 85 of file PATDiObjectProxy.h.

References cand2_, and type2_.

{ return tryGet_<Electron>(cand2_, type2_); }
const Photon& pat::DiObjectProxy::gam ( ) const [inline]

Get the PAT Photon, if the pair contains one and only one PAT Photon (throw exception otherwise)

Definition at line 57 of file PATDiObjectProxy.h.

{ return tryGetOne_<Photon>(); }
const Photon& pat::DiObjectProxy::gam1 ( ) const [inline]

Get the first item, if it's a PAT Photon (throw exception otherwise)

Definition at line 74 of file PATDiObjectProxy.h.

References cand1_, and type1_.

{ return tryGet_<Photon>(cand1_, type1_); }
const Photon& pat::DiObjectProxy::gam2 ( ) const [inline]

Get the second item, if it's a PAT Photon (throw exception otherwise)

Definition at line 91 of file PATDiObjectProxy.h.

References cand2_, and type2_.

{ return tryGet_<Photon>(cand2_, type2_); }
const Jet& pat::DiObjectProxy::jet ( void  ) const [inline]

Get the PAT Jet, if the pair contains one and only one PAT Jet (throw exception otherwise)

Definition at line 59 of file PATDiObjectProxy.h.

{ return tryGetOne_<Jet>(); }
const Jet& pat::DiObjectProxy::jet1 ( ) const [inline]

Get the first item, if it's a PAT Jet (throw exception otherwise)

Definition at line 76 of file PATDiObjectProxy.h.

References cand1_, and type1_.

{ return tryGet_<Jet>(cand1_, type1_); }
const Jet& pat::DiObjectProxy::jet2 ( ) const [inline]

Get the second item, if it's a PAT Jet (throw exception otherwise)

Definition at line 93 of file PATDiObjectProxy.h.

References cand2_, and type2_.

{ return tryGet_<Jet>(cand2_, type2_); }
const MET& pat::DiObjectProxy::met ( ) const [inline]

Get the PAT MET, if the pair contains one and only one PAT MET (throw exception otherwise)

Definition at line 61 of file PATDiObjectProxy.h.

{ return tryGetOne_<MET>(); }
const MET& pat::DiObjectProxy::met1 ( ) const [inline]

Get the first item, if it's a PAT MET (throw exception otherwise)

Definition at line 78 of file PATDiObjectProxy.h.

References cand1_, and type1_.

{ return tryGet_<MET>(cand1_, type1_); }
const MET& pat::DiObjectProxy::met2 ( ) const [inline]

Get the second item, if it's a PAT MET (throw exception otherwise)

Definition at line 95 of file PATDiObjectProxy.h.

References cand2_, and type2_.

{ return tryGet_<MET>(cand2_, type2_); }
const Muon& pat::DiObjectProxy::mu ( ) const [inline]

Get the PAT Muon, if the pair contains one and only one PAT Muon (throw exception otherwise)

Definition at line 53 of file PATDiObjectProxy.h.

{ return tryGetOne_<Muon>(); }
const Muon& pat::DiObjectProxy::mu1 ( ) const [inline]

Get the first item, if it's a PAT Muon (throw exception otherwise)

Definition at line 70 of file PATDiObjectProxy.h.

References cand1_, and type1_.

{ return tryGet_<Muon>(cand1_, type1_); }
const Muon& pat::DiObjectProxy::mu2 ( ) const [inline]

Get the second item, if it's a PAT Muon (throw exception otherwise)

Definition at line 87 of file PATDiObjectProxy.h.

References cand2_, and type2_.

{ return tryGet_<Muon>(cand2_, type2_); }
const GenericParticle& pat::DiObjectProxy::part ( ) const [inline]

Get the PAT GenericParticle, if the pair contains one and only one PAT GenericParticle (throw exception otherwise)

Definition at line 63 of file PATDiObjectProxy.h.

{ return tryGetOne_<GenericParticle>(); }
const GenericParticle& pat::DiObjectProxy::part1 ( ) const [inline]

Get the first item, if it's a PAT GenericParticle (throw exception otherwise)

Definition at line 80 of file PATDiObjectProxy.h.

References cand1_, and type1_.

{ return tryGet_<GenericParticle>(cand1_, type1_); }
const GenericParticle& pat::DiObjectProxy::part2 ( ) const [inline]

Get the second item, if it's a PAT GenericParticle (throw exception otherwise)

Definition at line 97 of file PATDiObjectProxy.h.

References cand2_, and type2_.

{ return tryGet_<GenericParticle>(cand2_, type2_); }
const PFParticle& pat::DiObjectProxy::pf ( ) const [inline]

Get the PAT PFParticle, if the pair contains one and only one PAT PFParticle (throw exception otherwise)

Definition at line 65 of file PATDiObjectProxy.h.

{ return tryGetOne_<PFParticle>(); }
const PFParticle& pat::DiObjectProxy::pf1 ( ) const [inline]

Get the first item, if it's a PAT PFParticle (throw exception otherwise)

Definition at line 82 of file PATDiObjectProxy.h.

References cand1_, and type1_.

{ return tryGet_<PFParticle>(cand1_, type1_); }
const PFParticle& pat::DiObjectProxy::pf2 ( ) const [inline]

Get the second item, if it's a PAT PFParticle (throw exception otherwise)

Definition at line 99 of file PATDiObjectProxy.h.

References cand2_, and type2_.

{ return tryGet_<PFParticle>(cand2_, type2_); }
const Tau& pat::DiObjectProxy::tau ( ) const [inline]

Get the PAT Tau, if the pair contains one and only one PAT Tau (throw exception otherwise)

Definition at line 55 of file PATDiObjectProxy.h.

{ return tryGetOne_<Tau>(); }
const Tau& pat::DiObjectProxy::tau1 ( ) const [inline]

Get the first item, if it's a PAT Tau (throw exception otherwise)

Definition at line 72 of file PATDiObjectProxy.h.

References cand1_, and type1_.

{ return tryGet_<Tau>(cand1_, type1_); }
const Tau& pat::DiObjectProxy::tau2 ( ) const [inline]

Get the second item, if it's a PAT Tau (throw exception otherwise)

Definition at line 89 of file PATDiObjectProxy.h.

References cand2_, and type2_.

{ return tryGet_<Tau>(cand2_, type2_); }
const reco::Candidate::LorentzVector& pat::DiObjectProxy::totalP4 ( ) const [inline]

Get the total four momentum.

Definition at line 42 of file PATDiObjectProxy.h.

References cand1_, cand2_, reco::Candidate::p4(), totalP4_, and totalP4ok_.

                                                           { 
            if (!totalP4ok_) { 
                totalP4_ = cand1_->p4() + cand2_->p4(); 
                totalP4ok_ = true; 
            }
            return totalP4_;
        }
template<typename T >
const T& pat::DiObjectProxy::tryGet_ ( const reco::Candidate ptr,
const std::type_info *  type 
) const [inline, private]

Definition at line 104 of file PATDiObjectProxy.h.

References cand1_, className(), and Exception.

                                                                                    {
            if (typeid(T) != *type) {
                throw cms::Exception("Type Error") << "pat::DiObjectProxy: the object of the pair is not of the type you request.\n" 
                                                   << " Item Index in pair: " << (ptr == cand1_ ? "first" : "second") << "\n"
                                                   << " Requested TypeID  : " << ClassName<T>::name() << "\n"
                                                   << " Found TypeID      : " << className(*ptr) << "\n";
            }
            return static_cast<const T &>(*ptr);
        }
template<typename T >
const T& pat::DiObjectProxy::tryGetOne_ ( ) const [inline, private]

Definition at line 115 of file PATDiObjectProxy.h.

References cand1_, cand2_, className(), Exception, mergeVDriftHistosByStation::name, type1_, and type2_.

                                     {
            if (typeid(T) == *type1_) {
                if (typeid(T) == *type2_) {
                    throw cms::Exception("Type Error") << "pat::DiObjectProxy: " << 
                        "you can't get use methods that get a particle by type if the two are of the same type!\n" <<
                        " Requested Type:" << ClassName<T>::name() << "\n";
                }
                return static_cast<const T &>(*cand1_);
            } else {
                if (typeid(T) != *type2_) {
                    throw cms::Exception("Type Error") << "pat::DiObjectProxy: " << 
                        "you can't get use methods that get a particle by type if neither of the two is of that type!\n" <<
                        " Requested Type:" << ClassName<T>::name() << "\n" <<
                        " Type of first :" << className(*cand1_) << "\n" <<
                        " Type of second:" << className(*cand2_) << "\n";
                }
                return static_cast<const T &>(*cand2_);
            }
        }

Member Data Documentation

Definition at line 139 of file PATDiObjectProxy.h.

Referenced by totalP4().

bool pat::DiObjectProxy::totalP4ok_ [mutable, private]

Definition at line 138 of file PATDiObjectProxy.h.

Referenced by totalP4().

const std::type_info* pat::DiObjectProxy::type1_ [private]

Definition at line 136 of file PATDiObjectProxy.h.

Referenced by ele1(), gam1(), jet1(), met1(), mu1(), part1(), pf1(), tau1(), and tryGetOne_().

const std::type_info * pat::DiObjectProxy::type2_ [private]

Definition at line 136 of file PATDiObjectProxy.h.

Referenced by ele2(), gam2(), jet2(), met2(), mu2(), part2(), pf2(), tau2(), and tryGetOne_().