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

23 : cand1_(0), cand2_(0), type1_(0), type2_(0), totalP4ok_(false), totalP4_() {}
const reco::Candidate * cand2_
const reco::Candidate * cand1_
const std::type_info * type1_
const std::type_info * type2_
reco::Candidate::LorentzVector 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.

26  :
27  cand1_(&c1), cand2_(&c2), type1_(&typeid(c1)), type2_(&typeid(c2)), totalP4ok_(false), totalP4_() {}
const reco::Candidate * cand2_
const reco::Candidate * cand1_
const std::type_info * type1_
const std::type_info * type2_
reco::Candidate::LorentzVector 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_.

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

Gets the second Candidate.

Definition at line 32 of file PATDiObjectProxy.h.

References cand2_.

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

Get the phi separation.

Definition at line 37 of file PATDiObjectProxy.h.

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

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 35 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 51 of file PATDiObjectProxy.h.

51 { 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_.

68 { 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 85 of file PATDiObjectProxy.h.

References cand2_, and type2_.

85 { 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 57 of file PATDiObjectProxy.h.

57 { 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_.

74 { 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 91 of file PATDiObjectProxy.h.

References cand2_, and type2_.

91 { 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 59 of file PATDiObjectProxy.h.

59 { 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_.

76 { 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 93 of file PATDiObjectProxy.h.

References cand2_, and type2_.

93 { 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 61 of file PATDiObjectProxy.h.

61 { 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_.

78 { 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 95 of file PATDiObjectProxy.h.

References cand2_, and type2_.

95 { 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 53 of file PATDiObjectProxy.h.

53 { 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_.

70 { 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 87 of file PATDiObjectProxy.h.

References cand2_, and type2_.

87 { 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 63 of file PATDiObjectProxy.h.

63 { 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_.

80 { 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 97 of file PATDiObjectProxy.h.

References cand2_, and type2_.

97 { 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 65 of file PATDiObjectProxy.h.

65 { 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_.

82 { 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 99 of file PATDiObjectProxy.h.

References cand2_, and type2_.

99 { 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 55 of file PATDiObjectProxy.h.

55 { 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_.

72 { 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 89 of file PATDiObjectProxy.h.

References cand2_, and type2_.

89 { 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 42 of file PATDiObjectProxy.h.

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

42  {
43  if (!totalP4ok_) {
44  totalP4_ = cand1_->p4() + cand2_->p4();
45  totalP4ok_ = true;
46  }
47  return totalP4_;
48  }
const reco::Candidate * cand2_
const reco::Candidate * cand1_
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 104 of file PATDiObjectProxy.h.

References cand1_, className(), and Exception.

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

Definition at line 115 of file PATDiObjectProxy.h.

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

115  {
116  if (typeid(T) == *type1_) {
117  if (typeid(T) == *type2_) {
118  throw cms::Exception("Type Error") << "pat::DiObjectProxy: " <<
119  "you can't get use methods that get a particle by type if the two are of the same type!\n" <<
120  " Requested Type:" << ClassName<T>::name() << "\n";
121  }
122  return static_cast<const T &>(*cand1_);
123  } else {
124  if (typeid(T) != *type2_) {
125  throw cms::Exception("Type Error") << "pat::DiObjectProxy: " <<
126  "you can't get use methods that get a particle by type if neither of the two is of that type!\n" <<
127  " Requested Type:" << ClassName<T>::name() << "\n" <<
128  " Type of first :" << className(*cand1_) << "\n" <<
129  " Type of second:" << className(*cand2_) << "\n";
130  }
131  return static_cast<const T &>(*cand2_);
132  }
133  }
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_
long double T
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 139 of file PATDiObjectProxy.h.

Referenced by totalP4().

bool pat::DiObjectProxy::totalP4ok_
mutableprivate

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