CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Photon.h
Go to the documentation of this file.
1 //
2 // $Id: Photon.h,v 1.24 2011/06/08 20:40:18 rwolf Exp $
3 //
4 
5 #ifndef DataFormats_PatCandidates_Photon_h
6 #define DataFormats_PatCandidates_Photon_h
7 
27 
28 
29 // Define typedefs for convenience
30 namespace pat {
31  class Photon;
32  typedef std::vector<Photon> PhotonCollection;
35 }
36 
37 namespace reco {
39  std::ostream& operator<<(std::ostream& out, const pat::Photon& obj);
40 }
41 
42 // Class definition
43 namespace pat {
44 
45 
46  class Photon : public PATObject<reco::Photon> {
47 
48  public:
49 
50  typedef std::pair<std::string,Bool_t> IdPair;
51 
53  Photon();
55  Photon(const reco::Photon & aPhoton);
57  Photon(const edm::RefToBase<reco::Photon> & aPhotonRef);
59  Photon(const edm::Ptr<reco::Photon> & aPhotonRef);
61  virtual ~Photon();
62 
64  virtual Photon * clone() const { return new Photon(*this); }
65 
66  // ---- methods for content embedding ----
70  void embedSuperCluster();
71 
72  // ---- methods for access the generated photon ----
74  const reco::Candidate * genPhoton() const { return genParticle(); }
76  void setGenPhoton(const reco::GenParticleRef & gp, bool embed=false) { setGenParticleRef(gp, embed); }
77 
78  // ---- methods for photon ID ----
81  Bool_t photonID(const std::string & name) const;
83  bool isPhotonIDAvailable(const std::string & name) const;
86  const std::vector<IdPair> & photonIDs() const { return photonIDs_; }
89  void setPhotonIDs(const std::vector<IdPair> & ids) { photonIDs_ = ids; }
90 
91 
92  // ---- methods for photon isolation ----
95  float trackIso() const { return trkSumPtSolidConeDR04(); }
98  float ecalIso() const { return ecalRecHitSumEtConeDR04(); }
101  float hcalIso() const { return hcalTowerSumEtConeDR04(); }
104  float caloIso() const { return ecalIso()+hcalIso(); }
106  float userIso(uint8_t index=0) const { return userIsolation(IsolationKeys(UserBaseIso + index)); }
110  if (key >= 0) {
111  //if (key >= isolations_.size()) throw cms::Excepton("Missing Data")
112  //<< "Isolation corresponding to key " << key
113  //<< " was not stored for this particle.";
114  if (size_t(key) >= isolations_.size()) return -1.0;
115  return isolations_[key];
116  } else switch (key) {
117  case pat::CaloIso:
118  //if (isolations_.size() <= pat::HcalIso) throw cms::Excepton("Missing Data")
119  //<< "CalIsoo Isolation was not stored for this particle.";
120  if (isolations_.size() <= pat::HcalIso) return -1.0;
122  default:
123  return -1.0;
124  //throw cms::Excepton("Missing Data") << "Isolation corresponding to key "
125  //<< key << " was not stored for this particle.";
126  }
127  }
131  if (key >= 0) {
132  if (size_t(key) >= isolations_.size()) isolations_.resize(key+1, -1.0);
133  isolations_[key] = value;
134  } else {
135  throw cms::Exception("Illegal Argument") <<
136  "The key for which you're setting isolation does not correspond " <<
137  "to an individual isolation but to the sum of more independent isolations " <<
138  "(e.g. Calo = Ecal + Hcal), so you can't SET the value, just GET it.\n" <<
139  "Please set up each component independly.\n";
140  }
141  }
143  void setTrackIso(float trackIso) { setIsolation(TrackIso, trackIso); }
145  void setEcalIso(float caloIso) { setIsolation(EcalIso, caloIso); }
147  void setHcalIso(float caloIso) { setIsolation(HcalIso, caloIso); }
149  void setUserIso(float value, uint8_t index=0) { setIsolation(IsolationKeys(UserBaseIso + index), value); }
150 
151  // ---- methods for photon isolation deposits ----
154  for (IsoDepositPairs::const_iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
155  it != ed; ++it)
156  {
157  if (it->first == key) return & it->second;
158  }
159  return 0;
160  }
162  const IsoDeposit * trackIsoDeposit() const { return isoDeposit(pat::TrackIso); }
164  const IsoDeposit * ecalIsoDeposit() const { return isoDeposit(pat::EcalIso ); }
166  const IsoDeposit * hcalIsoDeposit() const { return isoDeposit(pat::HcalIso ); }
168  const IsoDeposit * userIsoDeposit(uint8_t index=0) const { return isoDeposit(IsolationKeys(UserBaseIso + index)); }
171  IsoDepositPairs::iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
172  for (; it != ed; ++it) {
173  if (it->first == key) { it->second = dep; return; }
174  }
175  isoDeposits_.push_back(std::make_pair(key,dep));
176  }
184  void userIsoDeposit(const IsoDeposit &dep, uint8_t index=0) { setIsoDeposit(IsolationKeys(UserBaseIso + index), dep); }
185 
187  friend std::ostream& reco::operator<<(std::ostream& out, const pat::Photon& obj);
188 
189  protected:
190 
191  // ---- for content embedding ----
193  std::vector<reco::SuperCluster> superCluster_;
194  // ---- photon ID's holder ----
195  std::vector<IdPair> photonIDs_;
196  // ---- Isolation and IsoDeposit related datamebers ----
197  typedef std::vector<std::pair<IsolationKeys, pat::IsoDeposit> > IsoDepositPairs;
199  std::vector<float> isolations_;
200 
201  };
202 
203 
204 }
205 
206 #endif
float hcalTowerSumEtConeDR04() const
Hcal isolation sum.
Definition: Photon.h:340
Analysis-level Photon class.
Definition: Photon.h:46
edm::RefVector< PhotonCollection > PhotonRefVector
Definition: Photon.h:34
float trackIso() const
Definition: Photon.h:95
void setEcalIso(float caloIso)
Sets ecal isolation variable.
Definition: Photon.h:145
void setTrackIso(float trackIso)
Sets tracker isolation variable.
Definition: Photon.h:143
const reco::GenParticle * genParticle(size_t idx=0) const
Definition: PATObject.h:234
Photon()
default constructor
Definition: Photon.cc:12
void trackIsoDeposit(const IsoDeposit &dep)
Sets tracker IsoDeposit.
Definition: Photon.h:178
virtual Photon * clone() const
required reimplementation of the Candidate&#39;s clone method
Definition: Photon.h:64
edm::Ref< PhotonCollection > PhotonRef
Definition: Photon.h:33
float trkSumPtSolidConeDR04() const
Definition: Photon.h:352
void ecalIsoDeposit(const IsoDeposit &dep)
Sets ecal IsoDeposit.
Definition: Photon.h:180
float ecalRecHitSumEtConeDR04() const
Definition: Photon.h:338
void embedSuperCluster()
method to store the photon&#39;s supercluster internally
Definition: Photon.cc:71
std::vector< reco::SuperCluster > superCluster_
Definition: Photon.h:193
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
float hcalIso() const
Definition: Photon.h:101
void setUserIso(float value, uint8_t index=0)
Sets user isolation variable index.
Definition: Photon.h:149
void setGenParticleRef(const reco::GenParticleRef &ref, bool embed=false)
Set the generator level particle reference.
#define embed
Definition: AMPTWrapper.h:178
void setHcalIso(float caloIso)
Sets hcal isolation variable.
Definition: Photon.h:147
void setIsolation(IsolationKeys key, float value)
Definition: Photon.h:130
void setIsoDeposit(IsolationKeys key, const IsoDeposit &dep)
Sets the IsoDeposit associated with some key; if it is already existent, it is overwritten.
Definition: Photon.h:170
void userIsoDeposit(const IsoDeposit &dep, uint8_t index=0)
Sets user-level IsoDeposit.
Definition: Photon.h:184
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:72
const reco::Candidate * genPhoton() const
return the match to the generated photon
Definition: Photon.h:74
void setPhotonIDs(const std::vector< IdPair > &ids)
Definition: Photon.h:89
const IsoDeposit * hcalIsoDeposit() const
Return the hcal IsoDeposit.
Definition: Photon.h:166
bool isPhotonIDAvailable(const std::string &name) const
Returns true if a specific ID is available in this pat::Photon.
Definition: Photon.cc:94
float userIso(uint8_t index=0) const
Returns a user defined isolation value.
Definition: Photon.h:106
Bool_t photonID(const std::string &name) const
Definition: Photon.cc:80
void hcalIsoDeposit(const IsoDeposit &dep)
Sets hcal IsoDeposit.
Definition: Photon.h:182
std::vector< IdPair > photonIDs_
Definition: Photon.h:195
bool embeddedSuperCluster_
Definition: Photon.h:192
const IsoDeposit * ecalIsoDeposit() const
Return the ecal IsoDeposit.
Definition: Photon.h:164
tuple out
Definition: dbtoconf.py:99
unsigned int index
index type
Definition: Candidate.h:52
std::pair< std::string, Bool_t > IdPair
Definition: Photon.h:50
float ecalIso() const
Definition: Photon.h:98
const std::vector< IdPair > & photonIDs() const
Definition: Photon.h:86
IsoDepositPairs isoDeposits_
Definition: Photon.h:198
reco::SuperClusterRef superCluster() const
override the superCluster method from CaloJet, to access the internal storage of the supercluster ...
Definition: Photon.cc:62
float caloIso() const
Definition: Photon.h:104
const IsoDeposit * trackIsoDeposit() const
Return the tracker IsoDeposit.
Definition: Photon.h:162
list key
Definition: combine.py:13
virtual ~Photon()
destructor
Definition: Photon.cc:40
Templated PAT object container.
Definition: PATObject.h:43
float userIsolation(IsolationKeys key) const
Definition: Photon.h:109
const IsoDeposit * userIsoDeposit(uint8_t index=0) const
Return a specified user-level IsoDeposit.
Definition: Photon.h:168
const IsoDeposit * isoDeposit(IsolationKeys key) const
Returns the IsoDeposit associated with some key, or a null pointer if it is not available.
Definition: Photon.h:153
std::vector< std::pair< IsolationKeys, pat::IsoDeposit > > IsoDepositPairs
Definition: Photon.h:197
void setGenPhoton(const reco::GenParticleRef &gp, bool embed=false)
method to set the generated photon
Definition: Photon.h:76
std::vector< Photon > PhotonCollection
Definition: Photon.h:31
std::vector< float > isolations_
Definition: Photon.h:199