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 //
3 
4 #ifndef DataFormats_PatCandidates_Photon_h
5 #define DataFormats_PatCandidates_Photon_h
6 
25 
26 
27 // Define typedefs for convenience
28 namespace pat {
29  class Photon;
30  typedef std::vector<Photon> PhotonCollection;
33 }
34 
35 namespace reco {
37  std::ostream& operator<<(std::ostream& out, const pat::Photon& obj);
38 }
39 
40 // Class definition
41 namespace pat {
42 
43 
44  class Photon : public PATObject<reco::Photon> {
45 
46  public:
47 
48  typedef std::pair<std::string,Bool_t> IdPair;
49 
51  Photon();
53  Photon(const reco::Photon & aPhoton);
55  Photon(const edm::RefToBase<reco::Photon> & aPhotonRef);
57  Photon(const edm::Ptr<reco::Photon> & aPhotonRef);
59  virtual ~Photon();
60 
62  virtual Photon * clone() const { return new Photon(*this); }
63 
64  // ---- methods for content embedding ----
68  void embedSuperCluster();
69 
70  // ---- methods for access the generated photon ----
72  const reco::Candidate * genPhoton() const { return genParticle(); }
74  void setGenPhoton(const reco::GenParticleRef & gp, bool embed=false) { setGenParticleRef(gp, embed); }
75 
76  // ---- methods for photon ID ----
79  Bool_t photonID(const std::string & name) const;
81  bool isPhotonIDAvailable(const std::string & name) const;
84  const std::vector<IdPair> & photonIDs() const { return photonIDs_; }
87  void setPhotonIDs(const std::vector<IdPair> & ids) { photonIDs_ = ids; }
88 
89 
90  // ---- methods for photon isolation ----
93  float trackIso() const { return trkSumPtSolidConeDR04(); }
96  float ecalIso() const { return ecalRecHitSumEtConeDR04(); }
99  float hcalIso() const { return hcalTowerSumEtConeDR04(); }
102  float caloIso() const { return ecalIso()+hcalIso(); }
103 
115  float photonIso() const { return userIsolation(pat::PfGammaIso); }
119 
121  float userIso(uint8_t index=0) const { return userIsolation(IsolationKeys(UserBaseIso + index)); }
125  if (key >= 0) {
126  //if (key >= isolations_.size()) throw cms::Excepton("Missing Data")
127  //<< "Isolation corresponding to key " << key
128  //<< " was not stored for this particle.";
129  if (size_t(key) >= isolations_.size()) return -1.0;
130  return isolations_[key];
131  } else switch (key) {
132  case pat::CaloIso:
133  //if (isolations_.size() <= pat::HcalIso) throw cms::Excepton("Missing Data")
134  //<< "CalIsoo Isolation was not stored for this particle.";
135  if (isolations_.size() <= pat::HcalIso) return -1.0;
137  default:
138  return -1.0;
139  //throw cms::Excepton("Missing Data") << "Isolation corresponding to key "
140  //<< key << " was not stored for this particle.";
141  }
142  }
146  if (key >= 0) {
147  if (size_t(key) >= isolations_.size()) isolations_.resize(key+1, -1.0);
148  isolations_[key] = value;
149  } else {
150  throw cms::Exception("Illegal Argument") <<
151  "The key for which you're setting isolation does not correspond " <<
152  "to an individual isolation but to the sum of more independent isolations " <<
153  "(e.g. Calo = Ecal + Hcal), so you can't SET the value, just GET it.\n" <<
154  "Please set up each component independly.\n";
155  }
156  }
158  void setTrackIso(float trackIso) { setIsolation(TrackIso, trackIso); }
160  void setEcalIso(float caloIso) { setIsolation(EcalIso, caloIso); }
162  void setHcalIso(float caloIso) { setIsolation(HcalIso, caloIso); }
164  void setUserIso(float value, uint8_t index=0) { setIsolation(IsolationKeys(UserBaseIso + index), value); }
165 
166  // ---- methods for photon isolation deposits ----
169  for (IsoDepositPairs::const_iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
170  it != ed; ++it)
171  {
172  if (it->first == key) return & it->second;
173  }
174  return 0;
175  }
177  const IsoDeposit * trackIsoDeposit() const { return isoDeposit(pat::TrackIso); }
179  const IsoDeposit * ecalIsoDeposit() const { return isoDeposit(pat::EcalIso ); }
181  const IsoDeposit * hcalIsoDeposit() const { return isoDeposit(pat::HcalIso ); }
183  const IsoDeposit * userIsoDeposit(uint8_t index=0) const { return isoDeposit(IsolationKeys(UserBaseIso + index)); }
186  IsoDepositPairs::iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
187  for (; it != ed; ++it) {
188  if (it->first == key) { it->second = dep; return; }
189  }
190  isoDeposits_.push_back(std::make_pair(key,dep));
191  }
199  void userIsoDeposit(const IsoDeposit &dep, uint8_t index=0) { setIsoDeposit(IsolationKeys(UserBaseIso + index), dep); }
200 
202  friend std::ostream& reco::operator<<(std::ostream& out, const pat::Photon& obj);
203 
204  protected:
205 
206  // ---- for content embedding ----
208  std::vector<reco::SuperCluster> superCluster_;
209  // ---- photon ID's holder ----
210  std::vector<IdPair> photonIDs_;
211  // ---- Isolation and IsoDeposit related datamebers ----
212  typedef std::vector<std::pair<IsolationKeys, pat::IsoDeposit> > IsoDepositPairs;
214  std::vector<float> isolations_;
215 
216  };
217 
218 
219 }
220 
221 #endif
float hcalTowerSumEtConeDR04() const
Hcal isolation sum.
Definition: Photon.h:340
Analysis-level Photon class.
Definition: Photon.h:44
edm::RefVector< PhotonCollection > PhotonRefVector
Definition: Photon.h:32
float trackIso() const
Definition: Photon.h:93
void setEcalIso(float caloIso)
Sets ecal isolation variable.
Definition: Photon.h:160
float neutralHadronIso() const
Definition: Photon.h:112
void setTrackIso(float trackIso)
Sets tracker isolation variable.
Definition: Photon.h:158
const reco::GenParticle * genParticle(size_t idx=0) const
Definition: PATObject.h:232
Photon()
default constructor
Definition: Photon.cc:11
void trackIsoDeposit(const IsoDeposit &dep)
Sets tracker IsoDeposit.
Definition: Photon.h:193
virtual Photon * clone() const
required reimplementation of the Candidate&#39;s clone method
Definition: Photon.h:62
edm::Ref< PhotonCollection > PhotonRef
Definition: Photon.h:31
float trkSumPtSolidConeDR04() const
Definition: Photon.h:352
float puChargedHadronIso() const
Definition: Photon.h:118
void ecalIsoDeposit(const IsoDeposit &dep)
Sets ecal IsoDeposit.
Definition: Photon.h:195
float ecalRecHitSumEtConeDR04() const
Definition: Photon.h:338
void embedSuperCluster()
method to store the photon&#39;s supercluster internally
Definition: Photon.cc:70
std::vector< reco::SuperCluster > superCluster_
Definition: Photon.h:208
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
float hcalIso() const
Definition: Photon.h:99
void setUserIso(float value, uint8_t index=0)
Sets user isolation variable index.
Definition: Photon.h:164
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:162
void setIsolation(IsolationKeys key, float value)
Definition: Photon.h:145
float chargedHadronIso() const
Definition: Photon.h:109
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:185
void userIsoDeposit(const IsoDeposit &dep, uint8_t index=0)
Sets user-level IsoDeposit.
Definition: Photon.h:199
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:71
const reco::Candidate * genPhoton() const
return the match to the generated photon
Definition: Photon.h:72
void setPhotonIDs(const std::vector< IdPair > &ids)
Definition: Photon.h:87
const IsoDeposit * hcalIsoDeposit() const
Return the hcal IsoDeposit.
Definition: Photon.h:181
bool isPhotonIDAvailable(const std::string &name) const
Returns true if a specific ID is available in this pat::Photon.
Definition: Photon.cc:93
float userIso(uint8_t index=0) const
Returns a user defined isolation value.
Definition: Photon.h:121
Bool_t photonID(const std::string &name) const
Definition: Photon.cc:79
void hcalIsoDeposit(const IsoDeposit &dep)
Sets hcal IsoDeposit.
Definition: Photon.h:197
std::vector< IdPair > photonIDs_
Definition: Photon.h:210
bool embeddedSuperCluster_
Definition: Photon.h:207
const IsoDeposit * ecalIsoDeposit() const
Return the ecal IsoDeposit.
Definition: Photon.h:179
tuple out
Definition: dbtoconf.py:99
unsigned int index
index type
Definition: Candidate.h:55
std::pair< std::string, Bool_t > IdPair
Definition: Photon.h:48
float ecalIso() const
Definition: Photon.h:96
const std::vector< IdPair > & photonIDs() const
Definition: Photon.h:84
float particleIso() const
Definition: Photon.h:106
IsoDepositPairs isoDeposits_
Definition: Photon.h:213
reco::SuperClusterRef superCluster() const
override the superCluster method from CaloJet, to access the internal storage of the supercluster ...
Definition: Photon.cc:61
float caloIso() const
Definition: Photon.h:102
float photonIso() const
Definition: Photon.h:115
const IsoDeposit * trackIsoDeposit() const
Return the tracker IsoDeposit.
Definition: Photon.h:177
list key
Definition: combine.py:13
virtual ~Photon()
destructor
Definition: Photon.cc:39
Templated PAT object container.
Definition: PATObject.h:41
float userIsolation(IsolationKeys key) const
Definition: Photon.h:124
const IsoDeposit * userIsoDeposit(uint8_t index=0) const
Return a specified user-level IsoDeposit.
Definition: Photon.h:183
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:168
std::vector< std::pair< IsolationKeys, pat::IsoDeposit > > IsoDepositPairs
Definition: Photon.h:212
void setGenPhoton(const reco::GenParticleRef &gp, bool embed=false)
method to set the generated photon
Definition: Photon.h:74
std::vector< Photon > PhotonCollection
Definition: Photon.h:29
std::vector< float > isolations_
Definition: Photon.h:214