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 
28 
29 
30 // Define typedefs for convenience
31 namespace pat {
32  class Photon;
33  typedef std::vector<Photon> PhotonCollection;
36 }
37 
38 namespace reco {
40  std::ostream& operator<<(std::ostream& out, const pat::Photon& obj);
41 }
42 
43 // Class definition
44 namespace pat {
45  class PATPhotonSlimmer;
46 
47  class Photon : public PATObject<reco::Photon> {
48 
49  public:
50 
51  typedef std::pair<std::string,Bool_t> IdPair;
52 
54  Photon();
56  Photon(const reco::Photon & aPhoton);
58  Photon(const edm::RefToBase<reco::Photon> & aPhotonRef);
60  Photon(const edm::Ptr<reco::Photon> & aPhotonRef);
62  virtual ~Photon();
63 
65  virtual Photon * clone() const { return new Photon(*this); }
66 
67  // ---- methods for content embedding ----
71  reco::CaloClusterPtr seed() const;
72 
73  //method to access the basic clusters
74  const std::vector<reco::CaloCluster>& basicClusters() const { return basicClusters_ ; }
75  //method to access the preshower clusters
76  const std::vector<reco::CaloCluster>& preshowerClusters() const { return preshowerClusters_ ; }
77 
78  //method to access embedded ecal RecHits
79  const EcalRecHitCollection * recHits() const { return &recHits_;}
80 
82  void embedSuperCluster();
84  void embedSeedCluster();
86  void embedBasicClusters();
91 
92 
93  // ---- methods for access the generated photon ----
95  const reco::Candidate * genPhoton() const { return genParticle(); }
97  void setGenPhoton(const reco::GenParticleRef & gp, bool embed=false) { setGenParticleRef(gp, embed); }
98 
99  // ---- methods for photon ID ----
102  Bool_t photonID(const std::string & name) const;
104  bool isPhotonIDAvailable(const std::string & name) const;
107  const std::vector<IdPair> & photonIDs() const { return photonIDs_; }
110  void setPhotonIDs(const std::vector<IdPair> & ids) { photonIDs_ = ids; }
111 
112 
113  // ---- methods for photon isolation ----
116  float trackIso() const { return trkSumPtSolidConeDR04(); }
119  float ecalIso() const { return ecalRecHitSumEtConeDR04(); }
122  float hcalIso() const { return hcalTowerSumEtConeDR04(); }
125  float caloIso() const { return ecalIso()+hcalIso(); }
126 
138  float photonIso() const { return userIsolation(pat::PfGammaIso); }
142 
144  float userIso(uint8_t index=0) const { return userIsolation(IsolationKeys(UserBaseIso + index)); }
148  if (key >= 0) {
149  //if (key >= isolations_.size()) throw cms::Excepton("Missing Data")
150  //<< "Isolation corresponding to key " << key
151  //<< " was not stored for this particle.";
152  if (size_t(key) >= isolations_.size()) return -1.0;
153  return isolations_[key];
154  } else switch (key) {
155  case pat::CaloIso:
156  //if (isolations_.size() <= pat::HcalIso) throw cms::Excepton("Missing Data")
157  //<< "CalIsoo Isolation was not stored for this particle.";
158  if (isolations_.size() <= pat::HcalIso) return -1.0;
160  default:
161  return -1.0;
162  //throw cms::Excepton("Missing Data") << "Isolation corresponding to key "
163  //<< key << " was not stored for this particle.";
164  }
165  }
169  if (key >= 0) {
170  if (size_t(key) >= isolations_.size()) isolations_.resize(key+1, -1.0);
171  isolations_[key] = value;
172  } else {
173  throw cms::Exception("Illegal Argument") <<
174  "The key for which you're setting isolation does not correspond " <<
175  "to an individual isolation but to the sum of more independent isolations " <<
176  "(e.g. Calo = Ecal + Hcal), so you can't SET the value, just GET it.\n" <<
177  "Please set up each component independly.\n";
178  }
179  }
181  void setTrackIso(float trackIso) { setIsolation(TrackIso, trackIso); }
183  void setEcalIso(float caloIso) { setIsolation(EcalIso, caloIso); }
185  void setHcalIso(float caloIso) { setIsolation(HcalIso, caloIso); }
187  void setUserIso(float value, uint8_t index=0) { setIsolation(IsolationKeys(UserBaseIso + index), value); }
188 
189  // ---- methods for photon isolation deposits ----
192  for (IsoDepositPairs::const_iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
193  it != ed; ++it)
194  {
195  if (it->first == key) return & it->second;
196  }
197  return 0;
198  }
200  const IsoDeposit * trackIsoDeposit() const { return isoDeposit(pat::TrackIso); }
202  const IsoDeposit * ecalIsoDeposit() const { return isoDeposit(pat::EcalIso ); }
204  const IsoDeposit * hcalIsoDeposit() const { return isoDeposit(pat::HcalIso ); }
206  const IsoDeposit * userIsoDeposit(uint8_t index=0) const { return isoDeposit(IsolationKeys(UserBaseIso + index)); }
209  IsoDepositPairs::iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
210  for (; it != ed; ++it) {
211  if (it->first == key) { it->second = dep; return; }
212  }
213  isoDeposits_.push_back(std::make_pair(key,dep));
214  }
222  void userIsoDeposit(const IsoDeposit &dep, uint8_t index=0) { setIsoDeposit(IsolationKeys(UserBaseIso + index), dep); }
223 
225  friend std::ostream& reco::operator<<(std::ostream& out, const pat::Photon& obj);
226 
233 
238 
239  friend class PATPhotonSlimmer;
240 
241  protected:
242 
243  // ---- for content embedding ----
245  std::vector<reco::SuperCluster> superCluster_;
249  std::vector<reco::CaloCluster> basicClusters_;
251  std::vector<reco::CaloCluster> preshowerClusters_;
255  std::vector<reco::CaloCluster> seedCluster_;
260  // ---- photon ID's holder ----
261  std::vector<IdPair> photonIDs_;
262  // ---- Isolation and IsoDeposit related datamebers ----
263  typedef std::vector<std::pair<IsolationKeys, pat::IsoDeposit> > IsoDepositPairs;
265  std::vector<float> isolations_;
266 
267  // ---- link to PackedPFCandidates
269  std::vector<uint16_t> associatedPackedFCandidateIndices_;
270  };
271 
272 
273 }
274 
275 #endif
void setAssociatedPackedPFCandidates(const edm::RefVector< pat::PackedCandidateCollection > &refvector)
References to PFCandidates linked to this object (e.g. for isolation vetos or masking before jet recl...
Definition: Photon.cc:198
int i
Definition: DBlmapReader.cc:9
float hcalTowerSumEtConeDR04() const
Hcal isolation sum.
Definition: Photon.h:342
Analysis-level Photon class.
Definition: Photon.h:47
edm::RefVector< PhotonCollection > PhotonRefVector
Definition: Photon.h:35
float trackIso() const
Definition: Photon.h:116
void setEcalIso(float caloIso)
Sets ecal isolation variable.
Definition: Photon.h:183
float neutralHadronIso() const
Definition: Photon.h:135
void setTrackIso(float trackIso)
Sets tracker isolation variable.
Definition: Photon.h:181
size_t size_type
Definition: Candidate.h:34
const reco::GenParticle * genParticle(size_t idx=0) const
Definition: PATObject.h:236
Photon()
default constructor
Definition: Photon.cc:12
void trackIsoDeposit(const IsoDeposit &dep)
Sets tracker IsoDeposit.
Definition: Photon.h:216
virtual Photon * clone() const
required reimplementation of the Candidate&#39;s clone method
Definition: Photon.h:65
edm::Ref< PhotonCollection > PhotonRef
Definition: Photon.h:34
reco::CaloClusterPtr seed() const
direct access to the seed cluster
Definition: Photon.cc:104
float trkSumPtSolidConeDR04() const
Definition: Photon.h:354
float puChargedHadronIso() const
Definition: Photon.h:141
void embedBasicClusters()
method to store the electron&#39;s basic clusters
Definition: Photon.cc:131
void ecalIsoDeposit(const IsoDeposit &dep)
Sets ecal IsoDeposit.
Definition: Photon.h:218
float ecalRecHitSumEtConeDR04() const
Definition: Photon.h:340
void embedSuperCluster()
method to store the photon&#39;s supercluster internally
Definition: Photon.cc:113
const std::vector< reco::CaloCluster > & basicClusters() const
Definition: Photon.h:74
std::vector< reco::SuperCluster > superCluster_
Definition: Photon.h:245
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
float hcalIso() const
Definition: Photon.h:122
std::vector< reco::CaloCluster > preshowerClusters_
Place to store electron&#39;s preshower clusters internally.
Definition: Photon.h:251
void setUserIso(float value, uint8_t index=0)
Sets user isolation variable index.
Definition: Photon.h:187
void setGenParticleRef(const reco::GenParticleRef &ref, bool embed=false)
Set the generator level particle reference.
std::vector< reco::CaloCluster > seedCluster_
Place to store electron&#39;s seed cluster internally.
Definition: Photon.h:255
#define embed
Definition: AMPTWrapper.h:178
void setHcalIso(float caloIso)
Sets hcal isolation variable.
Definition: Photon.h:185
void setIsolation(IsolationKeys key, float value)
Definition: Photon.h:168
float chargedHadronIso() const
Definition: Photon.h:132
edm::RefVector< pat::PackedCandidateCollection > associatedPackedPFCandidates() const
References to PFCandidates linked to this object (e.g. for isolation vetos or masking before jet recl...
Definition: Photon.cc:190
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:208
void userIsoDeposit(const IsoDeposit &dep, uint8_t index=0)
Sets user-level IsoDeposit.
Definition: Photon.h:222
slimmer of PAT Taus
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:71
const EcalRecHitCollection * recHits() const
Definition: Photon.h:79
const reco::Candidate * genPhoton() const
return the match to the generated photon
Definition: Photon.h:95
void setPhotonIDs(const std::vector< IdPair > &ids)
Definition: Photon.h:110
edm::RefProd< pat::PackedCandidateCollection > packedPFCandidates_
Definition: Photon.h:268
const IsoDeposit * hcalIsoDeposit() const
Return the hcal IsoDeposit.
Definition: Photon.h:204
void embedSeedCluster()
method to store the electron&#39;s seedcluster internally
Definition: Photon.cc:122
void embedPreshowerClusters()
method to store the electron&#39;s preshower clusters
Definition: Photon.cc:143
bool isPhotonIDAvailable(const std::string &name) const
Returns true if a specific ID is available in this pat::Photon.
Definition: Photon.cc:177
float userIso(uint8_t index=0) const
Returns a user defined isolation value.
Definition: Photon.h:144
Bool_t photonID(const std::string &name) const
Definition: Photon.cc:163
void hcalIsoDeposit(const IsoDeposit &dep)
Sets hcal IsoDeposit.
Definition: Photon.h:220
std::vector< IdPair > photonIDs_
Definition: Photon.h:261
bool embeddedSuperCluster_
Definition: Photon.h:244
const IsoDeposit * ecalIsoDeposit() const
Return the ecal IsoDeposit.
Definition: Photon.h:202
tuple out
Definition: dbtoconf.py:99
edm::AtomicPtrCache< std::vector< reco::SuperCluster > > superClusterRelinked_
Place to temporarily store the electron&#39;s supercluster after relinking the seed to it...
Definition: Photon.h:247
EcalRecHitCollection recHits_
Place to store electron&#39;s RecHits internally (5x5 around seed+ all RecHits)
Definition: Photon.h:259
bool embeddedRecHits_
True if RecHits stored internally.
Definition: Photon.h:257
unsigned int index
index type
Definition: Candidate.h:55
std::pair< std::string, Bool_t > IdPair
Definition: Photon.h:51
float ecalIso() const
Definition: Photon.h:119
const std::vector< IdPair > & photonIDs() const
Definition: Photon.h:107
size_t numberOfSourceCandidatePtrs() const
get the number of non-null PFCandidates
Definition: Photon.h:235
float particleIso() const
Definition: Photon.h:129
IsoDepositPairs isoDeposits_
Definition: Photon.h:264
reco::SuperClusterRef superCluster() const
override the superCluster method from CaloJet, to access the internal storage of the supercluster ...
Definition: Photon.cc:70
float caloIso() const
Definition: Photon.h:125
float photonIso() const
Definition: Photon.h:138
const IsoDeposit * trackIsoDeposit() const
Return the tracker IsoDeposit.
Definition: Photon.h:200
list key
Definition: combine.py:13
virtual ~Photon()
destructor
Definition: Photon.cc:48
bool embeddedSeedCluster_
True if seed cluster is stored internally.
Definition: Photon.h:253
Templated PAT object container.
Definition: PATObject.h:41
float userIsolation(IsolationKeys key) const
Definition: Photon.h:147
const IsoDeposit * userIsoDeposit(uint8_t index=0) const
Return a specified user-level IsoDeposit.
Definition: Photon.h:206
std::vector< uint16_t > associatedPackedFCandidateIndices_
Definition: Photon.h:269
void setPackedPFCandidateCollection(const edm::RefProd< pat::PackedCandidateCollection > &refprod)
References to PFCandidates (e.g. to recompute isolation)
Definition: Photon.cc:185
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:191
std::vector< std::pair< IsolationKeys, pat::IsoDeposit > > IsoDepositPairs
Definition: Photon.h:263
void embedRecHits(const EcalRecHitCollection *rechits)
method to store the RecHits internally - can be called from the PATElectronProducer ...
Definition: Photon.cc:155
void setGenPhoton(const reco::GenParticleRef &gp, bool embed=false)
method to set the generated photon
Definition: Photon.h:97
reco::CandidatePtr sourceCandidatePtr(size_type i) const
get the source candidate pointer with index i
Definition: Photon.cc:214
std::vector< Photon > PhotonCollection
Definition: Photon.h:32
std::vector< reco::CaloCluster > basicClusters_
Place to store electron&#39;s basic clusters internally.
Definition: Photon.h:249
std::vector< float > isolations_
Definition: Photon.h:265
const std::vector< reco::CaloCluster > & preshowerClusters() const
Definition: Photon.h:76