CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
pat::DiObjectProxy Class Reference

#include <PATDiObjectProxy.h>

Public Member Functions

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

Private Member Functions

template<typename T >
const T & tryGet_ (const reco::Candidate *ptr, const std::type_info *type) const
 
template<typename T >
const T & tryGetOne_ () const
 

Private Attributes

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

Detailed Description

Definition at line 20 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 24 of file PATDiObjectProxy.h.

24 : cand1_(0), cand2_(0), type1_(0), type2_(0) {}
const reco::Candidate * cand2_
const reco::Candidate * cand1_
const std::type_info * type1_
const std::type_info * type2_
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 27 of file PATDiObjectProxy.h.

27  :
28  cand1_(&c1), cand2_(&c2), type1_(&typeid(c1)), type2_(&typeid(c2)) {}
const reco::Candidate * cand2_
const reco::Candidate * cand1_
const std::type_info * type1_
const std::type_info * type2_

Member Function Documentation

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

Gets the first Candidate.

Definition at line 31 of file PATDiObjectProxy.h.

References cand1_.

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

Gets the second Candidate.

Definition at line 33 of file PATDiObjectProxy.h.

References cand2_.

33 { return *cand2_; }
const reco::Candidate * cand2_
double pat::DiObjectProxy::deltaPhi ( ) const
inline

Get the phi separation.

Definition at line 38 of file PATDiObjectProxy.h.

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

double deltaPhi(float phi1, float phi2)
Definition: VectorUtil.h:30
const reco::Candidate * cand2_
const reco::Candidate * cand1_
virtual double phi() const =0
momentum azimuthal angle
double pat::DiObjectProxy::deltaR ( ) const
inline

Get the angular separation.

Definition at line 36 of file PATDiObjectProxy.h.

References cand1_, cand2_, and deltaR().

const reco::Candidate * cand2_
const reco::Candidate * cand1_
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
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 52 of file PATDiObjectProxy.h.

52 { 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 69 of file PATDiObjectProxy.h.

References cand1_, and type1_.

69 { return tryGet_<Electron>(cand1_, type1_); }
const reco::Candidate * cand1_
const std::type_info * type1_
const Electron& pat::DiObjectProxy::ele2 ( ) const
inline

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

Definition at line 86 of file PATDiObjectProxy.h.

References cand2_, and type2_.

86 { return tryGet_<Electron>(cand2_, type2_); }
const reco::Candidate * cand2_
const std::type_info * 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 58 of file PATDiObjectProxy.h.

58 { 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 75 of file PATDiObjectProxy.h.

References cand1_, and type1_.

75 { return tryGet_<Photon>(cand1_, type1_); }
const reco::Candidate * cand1_
const std::type_info * type1_
const Photon& pat::DiObjectProxy::gam2 ( ) const
inline

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

Definition at line 92 of file PATDiObjectProxy.h.

References cand2_, and type2_.

92 { return tryGet_<Photon>(cand2_, type2_); }
const reco::Candidate * cand2_
const std::type_info * 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 60 of file PATDiObjectProxy.h.

60 { 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 77 of file PATDiObjectProxy.h.

References cand1_, and type1_.

77 { return tryGet_<Jet>(cand1_, type1_); }
const reco::Candidate * cand1_
const std::type_info * type1_
const Jet& pat::DiObjectProxy::jet2 ( ) const
inline

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

Definition at line 94 of file PATDiObjectProxy.h.

References cand2_, and type2_.

94 { return tryGet_<Jet>(cand2_, type2_); }
const reco::Candidate * cand2_
const std::type_info * 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 62 of file PATDiObjectProxy.h.

62 { 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 79 of file PATDiObjectProxy.h.

References cand1_, and type1_.

79 { return tryGet_<MET>(cand1_, type1_); }
const reco::Candidate * cand1_
const std::type_info * type1_
const MET& pat::DiObjectProxy::met2 ( ) const
inline

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

Definition at line 96 of file PATDiObjectProxy.h.

References cand2_, and type2_.

96 { return tryGet_<MET>(cand2_, type2_); }
const reco::Candidate * cand2_
const std::type_info * 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 54 of file PATDiObjectProxy.h.

54 { 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 71 of file PATDiObjectProxy.h.

References cand1_, and type1_.

71 { return tryGet_<Muon>(cand1_, type1_); }
const reco::Candidate * cand1_
const std::type_info * type1_
const Muon& pat::DiObjectProxy::mu2 ( ) const
inline

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

Definition at line 88 of file PATDiObjectProxy.h.

References cand2_, and type2_.

88 { return tryGet_<Muon>(cand2_, type2_); }
const reco::Candidate * cand2_
const std::type_info * 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 64 of file PATDiObjectProxy.h.

64 { 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 81 of file PATDiObjectProxy.h.

References cand1_, and type1_.

81 { return tryGet_<GenericParticle>(cand1_, type1_); }
const reco::Candidate * cand1_
const std::type_info * type1_
const GenericParticle& pat::DiObjectProxy::part2 ( ) const
inline

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

Definition at line 98 of file PATDiObjectProxy.h.

References cand2_, and type2_.

98 { return tryGet_<GenericParticle>(cand2_, type2_); }
const reco::Candidate * cand2_
const std::type_info * 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 66 of file PATDiObjectProxy.h.

66 { 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 83 of file PATDiObjectProxy.h.

References cand1_, and type1_.

83 { return tryGet_<PFParticle>(cand1_, type1_); }
const reco::Candidate * cand1_
const std::type_info * type1_
const PFParticle& pat::DiObjectProxy::pf2 ( ) const
inline

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

Definition at line 100 of file PATDiObjectProxy.h.

References cand2_, and type2_.

100 { return tryGet_<PFParticle>(cand2_, type2_); }
const reco::Candidate * cand2_
const std::type_info * 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 56 of file PATDiObjectProxy.h.

56 { 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 73 of file PATDiObjectProxy.h.

References cand1_, and type1_.

73 { return tryGet_<Tau>(cand1_, type1_); }
const reco::Candidate * cand1_
const std::type_info * type1_
const Tau& pat::DiObjectProxy::tau2 ( ) const
inline

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

Definition at line 90 of file PATDiObjectProxy.h.

References cand2_, and type2_.

90 { return tryGet_<Tau>(cand2_, type2_); }
const reco::Candidate * cand2_
const std::type_info * type2_
const reco::Candidate::LorentzVector& pat::DiObjectProxy::totalP4 ( ) const
inline

Get the total four momentum.

Definition at line 43 of file PATDiObjectProxy.h.

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

43  {
44  if (!totalP4ok_) {
45  totalP4_ = cand1_->p4() + cand2_->p4();
46  totalP4ok_ = true;
47  }
48  return totalP4_;
49  }
const reco::Candidate * cand2_
const reco::Candidate * cand1_
edm::BoolCache totalP4ok_
reco::Candidate::LorentzVector totalP4_
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
template<typename T >
const T& pat::DiObjectProxy::tryGet_ ( const reco::Candidate ptr,
const std::type_info *  type 
) const
inlineprivate

Definition at line 105 of file PATDiObjectProxy.h.

References cand1_, className(), and edm::hlt::Exception.

105  {
106  if (typeid(T) != *type) {
107  throw cms::Exception("Type Error") << "pat::DiObjectProxy: the object of the pair is not of the type you request.\n"
108  << " Item Index in pair: " << (ptr == cand1_ ? "first" : "second") << "\n"
109  << " Requested TypeID : " << ClassName<T>::name() << "\n"
110  << " Found TypeID : " << className(*ptr) << "\n";
111  }
112  return static_cast<const T &>(*ptr);
113  }
type
Definition: HCALResponse.h:22
const reco::Candidate * cand1_
std::string className(const T &t)
Definition: ClassName.h:30
template<typename T >
const T& pat::DiObjectProxy::tryGetOne_ ( ) const
inlineprivate

Definition at line 116 of file PATDiObjectProxy.h.

References cand1_, cand2_, className(), edm::hlt::Exception, ClassName< T >::name(), type1_, and type2_.

116  {
117  if (typeid(T) == *type1_) {
118  if (typeid(T) == *type2_) {
119  throw cms::Exception("Type Error") << "pat::DiObjectProxy: " <<
120  "you can't get use methods that get a particle by type if the two are of the same type!\n" <<
121  " Requested Type:" << ClassName<T>::name() << "\n";
122  }
123  return static_cast<const T &>(*cand1_);
124  } else {
125  if (typeid(T) != *type2_) {
126  throw cms::Exception("Type Error") << "pat::DiObjectProxy: " <<
127  "you can't get use methods that get a particle by type if neither of the two is of that type!\n" <<
128  " Requested Type:" << ClassName<T>::name() << "\n" <<
129  " Type of first :" << className(*cand1_) << "\n" <<
130  " Type of second:" << className(*cand2_) << "\n";
131  }
132  return static_cast<const T &>(*cand2_);
133  }
134  }
const reco::Candidate * cand2_
const reco::Candidate * cand1_
const std::type_info * type1_
static const std::string & name()
Definition: ClassName.h:37
const std::type_info * type2_
std::string className(const T &t)
Definition: ClassName.h:30

Member Data Documentation

const reco::Candidate* pat::DiObjectProxy::cand1_
private
const reco::Candidate * pat::DiObjectProxy::cand2_
private
reco::Candidate::LorentzVector pat::DiObjectProxy::totalP4_
mutableprivate

Definition at line 140 of file PATDiObjectProxy.h.

Referenced by totalP4().

edm::BoolCache pat::DiObjectProxy::totalP4ok_
mutableprivate

Definition at line 139 of file PATDiObjectProxy.h.

Referenced by totalP4().

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

Definition at line 137 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 137 of file PATDiObjectProxy.h.

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