CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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::LorentzVectortotalP4 () 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

◆ DiObjectProxy() [1/2]

pat::DiObjectProxy::DiObjectProxy ( )
inline

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

Definition at line 22 of file PATDiObjectProxy.h.

23  : cand1_(nullptr), cand2_(nullptr), type1_(nullptr), type2_(nullptr), 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_

◆ DiObjectProxy() [2/2]

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.

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

◆ cand1()

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_

◆ cand2()

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_

◆ deltaPhi()

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

◆ deltaR()

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

Get the angular separation.

Definition at line 35 of file PATDiObjectProxy.h.

References cand1_, cand2_, and PbPb_ZMuSkimMuonDPG_cff::deltaR.

◆ ele()

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>(); }

◆ ele1()

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_

◆ ele2()

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_

◆ gam()

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>(); }

◆ gam1()

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_

◆ gam2()

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_

◆ jet()

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>(); }

◆ jet1()

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_

◆ jet2()

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_

◆ met()

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.

Referenced by objects.METAnalyzer.METAnalyzer::applyDeltaMet().

61 { return tryGetOne_<MET>(); }

◆ met1()

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_

◆ met2()

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_

◆ mu()

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>(); }

◆ mu1()

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_

◆ mu2()

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_

◆ part()

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>(); }

◆ part1()

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_

◆ part2()

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_

◆ pf()

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>(); }

◆ pf1()

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_

◆ pf2()

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_

◆ tau()

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>(); }

◆ tau1()

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_

◆ tau2()

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_

◆ totalP4()

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

◆ tryGet_()

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

Definition at line 103 of file PATDiObjectProxy.h.

References cand1_, className(), and Exception.

103  {
104  if (typeid(T) != *type) {
105  throw cms::Exception("Type Error")
106  << "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  }
const reco::Candidate * cand1_
long double T
std::string className(const T &t)
Definition: ClassName.h:31

◆ tryGetOne_()

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")
119  << "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")
127  << "pat::DiObjectProxy: "
128  << "you can't get use methods that get a particle by type if neither of the two is of that type!\n"
129  << " Requested Type:" << ClassName<T>::name() << "\n"
130  << " Type of first :" << className(*cand1_) << "\n"
131  << " Type of second:" << className(*cand2_) << "\n";
132  }
133  return static_cast<const T &>(*cand2_);
134  }
135  }
const reco::Candidate * cand2_
const reco::Candidate * cand1_
const std::type_info * type1_
static const std::string & name()
Definition: ClassName.h:38
const std::type_info * type2_
long double T
std::string className(const T &t)
Definition: ClassName.h:31

Member Data Documentation

◆ cand1_

const reco::Candidate* pat::DiObjectProxy::cand1_
private

◆ cand2_

const reco::Candidate * pat::DiObjectProxy::cand2_
private

◆ totalP4_

reco::Candidate::LorentzVector pat::DiObjectProxy::totalP4_
mutableprivate

Definition at line 141 of file PATDiObjectProxy.h.

Referenced by totalP4().

◆ totalP4ok_

bool pat::DiObjectProxy::totalP4ok_
mutableprivate

Definition at line 140 of file PATDiObjectProxy.h.

Referenced by totalP4().

◆ type1_

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

Definition at line 138 of file PATDiObjectProxy.h.

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

◆ type2_

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

Definition at line 138 of file PATDiObjectProxy.h.

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