CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Photon.cc
Go to the documentation of this file.
1 //
2 //
3 
6 
7 
8 using pat::Photon;
9 
10 
12 Photon::Photon() :
14  embeddedSuperCluster_(false),
15  embeddedSeedCluster_(false),
16  embeddedRecHits_(false),
17  passElectronVeto_(false),
18  hasPixelSeed_(false),
19  seedEnergy_(0.0),
20  eMax_(0.0),
21  e2nd_(0.0),
22  e3x3_(0.0),
23  eTop_(0.0),
24  eBottom_(0.0),
25  eLeft_(0.0),
26  eRight_(0.0),
27  see_(-999.),
28  spp_(-999.),
29  sep_(-999.),
30  maxDR_(-999.),
31  maxDRDPhi_(-999.),
32  maxDRDEta_(-999.),
33  maxDRRawEnergy_(-999.),
34  subClusRawE1_(-999.),
35  subClusRawE2_(-999.),
36  subClusRawE3_(-999.),
37  subClusDPhi1_(-999.),
38  subClusDPhi2_(-999.),
39  subClusDPhi3_(-999.),
40  subClusDEta1_(-999.),
41  subClusDEta2_(-999.),
42  subClusDEta3_(-999.),
43  cryEta_(-999.),
44  cryPhi_(-999),
45  iEta_(-999),
46  iPhi_(-999)
47 {
48 }
49 
51 Photon::Photon(const reco::Photon & aPhoton) :
52  PATObject<reco::Photon>(aPhoton),
53  embeddedSuperCluster_(false),
54  embeddedSeedCluster_(false),
55  embeddedRecHits_(false),
56  passElectronVeto_(false),
57  hasPixelSeed_(false),
58  seedEnergy_(0.0),
59  eMax_(0.0),
60  e2nd_(0.0),
61  e3x3_(0.0),
62  eTop_(0.0),
63  eBottom_(0.0),
64  eLeft_(0.0),
65  eRight_(0.0),
66  see_(-999.),
67  spp_(-999.),
68  sep_(-999.),
69  maxDR_(-999.),
70  maxDRDPhi_(-999.),
71  maxDRDEta_(-999.),
72  maxDRRawEnergy_(-999.),
73  subClusRawE1_(-999.),
74  subClusRawE2_(-999.),
75  subClusRawE3_(-999.),
76  subClusDPhi1_(-999.),
77  subClusDPhi2_(-999.),
78  subClusDPhi3_(-999.),
79  subClusDEta1_(-999.),
80  subClusDEta2_(-999.),
81  subClusDEta3_(-999.),
82  cryEta_(-999.),
83  cryPhi_(-999),
84  iEta_(-999),
85  iPhi_(-999)
86 {
87 }
88 
91  PATObject<reco::Photon>(aPhotonRef),
92  embeddedSuperCluster_(false),
93  embeddedSeedCluster_(false),
94  embeddedRecHits_(false),
95  passElectronVeto_(false),
96  hasPixelSeed_(false),
97  seedEnergy_(0.0),
98  eMax_(0.0),
99  e2nd_(0.0),
100  e3x3_(0.0),
101  eTop_(0.0),
102  eBottom_(0.0),
103  eLeft_(0.0),
104  eRight_(0.0),
105  see_(-999.),
106  spp_(-999.),
107  sep_(-999.),
108  maxDR_(-999.),
109  maxDRDPhi_(-999.),
110  maxDRDEta_(-999.),
111  maxDRRawEnergy_(-999.),
112  subClusRawE1_(-999.),
113  subClusRawE2_(-999.),
114  subClusRawE3_(-999.),
115  subClusDPhi1_(-999.),
116  subClusDPhi2_(-999.),
117  subClusDPhi3_(-999.),
118  subClusDEta1_(-999.),
119  subClusDEta2_(-999.),
120  subClusDEta3_(-999.),
121  cryEta_(-999.),
122  cryPhi_(-999),
123  iEta_(-999),
124  iPhi_(-999)
125 {
126 }
127 
130  PATObject<reco::Photon>(aPhotonRef),
131  embeddedSuperCluster_(false),
132  embeddedSeedCluster_(false),
133  embeddedRecHits_(false),
134  passElectronVeto_(false),
135  hasPixelSeed_(false),
136  seedEnergy_(0.0),
137  eMax_(0.0),
138  e2nd_(0.0),
139  e3x3_(0.0),
140  eTop_(0.0),
141  eBottom_(0.0),
142  eLeft_(0.0),
143  eRight_(0.0),
144  see_(-999.),
145  spp_(-999.),
146  sep_(-999.),
147  maxDR_(-999.),
148  maxDRDPhi_(-999.),
149  maxDRDEta_(-999.),
150  maxDRRawEnergy_(-999.),
151  subClusRawE1_(-999.),
152  subClusRawE2_(-999.),
153  subClusRawE3_(-999.),
154  subClusDPhi1_(-999.),
155  subClusDPhi2_(-999.),
156  subClusDPhi3_(-999.),
157  subClusDEta1_(-999.),
158  subClusDEta2_(-999.),
159  subClusDEta3_(-999.),
160  cryEta_(-999.),
161  cryPhi_(-999),
162  iEta_(-999),
163  iPhi_(-999)
164 {
165 }
166 
169 }
170 
171 std::ostream&
172 reco::operator<<(std::ostream& out, const pat::Photon& obj)
173 {
174  if(!out) return out;
175 
176  out << "\tpat::Photon: ";
177  out << std::setiosflags(std::ios::right);
178  out << std::setiosflags(std::ios::fixed);
179  out << std::setprecision(3);
180  out << " E/pT/eta/phi "
181  << obj.energy()<<"/"
182  << obj.pt()<<"/"
183  << obj.eta()<<"/"
184  << obj.phi();
185  return out;
186 }
187 
191  if (embeddedSuperCluster_) {
192  if (embeddedSeedCluster_ || !basicClusters_.empty() || !preshowerClusters_.empty()) {
193  if (!superClusterRelinked_.isSet()) {
194  std::unique_ptr<std::vector<reco::SuperCluster> > sc(new std::vector<reco::SuperCluster>(superCluster_));
195  if (embeddedSeedCluster_ && !(*sc)[0].seed().isAvailable()) {
196  (*sc)[0].setSeed(seed());
197  }
198  if (basicClusters_.size() && !(*sc)[0].clusters().isAvailable()) {
200  for (unsigned int iclus=0; iclus<basicClusters_.size(); ++iclus) {
202  }
203  (*sc)[0].setClusters(clusters);
204  }
205  if (preshowerClusters_.size() && !(*sc)[0].preshowerClusters().isAvailable()) {
207  for (unsigned int iclus=0; iclus<preshowerClusters_.size(); ++iclus) {
209  }
210  (*sc)[0].setPreshowerClusters(clusters);
211  }
212  superClusterRelinked_.set(std::move(sc));
213  }
215  } else {
217  }
218  } else {
220  }
221 }
222 
227  } else {
228  return reco::Photon::superCluster()->seed();
229  }
230 }
231 
234  superCluster_.clear();
235  if (reco::Photon::superCluster().isNonnull()) {
237  embeddedSuperCluster_ = true;
238  }
239 }
240 
243  seedCluster_.clear();
244  if (reco::Photon::superCluster().isNonnull() && reco::Photon::superCluster()->seed().isNonnull()) {
246  embeddedSeedCluster_ = true;
247  }
248 }
249 
252  basicClusters_.clear();
253  if (reco::Photon::superCluster().isNonnull()){
254  reco::CaloCluster_iterator itscl = reco::Photon::superCluster()->clustersBegin();
255  reco::CaloCluster_iterator itsclE = reco::Photon::superCluster()->clustersEnd();
256  for(;itscl!=itsclE;++itscl){
257  basicClusters_.push_back( **itscl ) ;
258  }
259  }
260 }
261 
264  preshowerClusters_.clear();
265  if (reco::Photon::superCluster().isNonnull()){
266  reco::CaloCluster_iterator itscl = reco::Photon::superCluster()->preshowerClustersBegin();
267  reco::CaloCluster_iterator itsclE = reco::Photon::superCluster()->preshowerClustersEnd();
268  for(;itscl!=itsclE;++itscl){
269  preshowerClusters_.push_back( **itscl ) ;
270  }
271  }
272 }
273 
274 // method to store the RecHits internally
276  if (rechits!=0) {
277  recHits_ = *rechits;
278  embeddedRecHits_ = true;
279  }
280 }
281 
282 // method to retrieve a photon ID (or throw)
283 Bool_t Photon::photonID(const std::string & name) const {
284  for (std::vector<IdPair>::const_iterator it = photonIDs_.begin(), ed = photonIDs_.end(); it != ed; ++it) {
285  if (it->first == name) return it->second;
286  }
287  cms::Exception ex("Key not found");
288  ex << "pat::Photon: the ID " << name << " can't be found in this pat::Photon.\n";
289  ex << "The available IDs are: ";
290  for (std::vector<IdPair>::const_iterator it = photonIDs_.begin(), ed = photonIDs_.end(); it != ed; ++it) {
291  ex << "'" << it->first << "' ";
292  }
293  ex << ".\n";
294  throw ex;
295 }
296 // check if an ID is there
298  for (std::vector<IdPair>::const_iterator it = photonIDs_.begin(), ed = photonIDs_.end(); it != ed; ++it) {
299  if (it->first == name) return true;
300  }
301  return false;
302 }
303 
304 
306  if (!associatedPackedFCandidateIndices_.empty()) throw cms::Exception("Unsupported", "You can't call setPackedPFCandidateCollection _after_ having called setAssociatedPackedPFCandidates");
307  packedPFCandidates_ = refprod;
308 }
309 
312  for (uint16_t idx : associatedPackedFCandidateIndices_) {
314  }
315  return ret;
316 }
317 
320  if (refvector.id().isValid() && refvector.id() != packedPFCandidates_.id()) {
321  throw cms::Exception("Unsupported", "setAssociatedPackedPFCandidates pointing to a collection other than the one from setPackedPFCandidateCollection");
322  }
323  } else {
325  }
327  for (const edm::Ref<pat::PackedCandidateCollection> & ref : refvector) {
328  associatedPackedFCandidateIndices_.push_back(ref.key());
329  }
330 }
331 
335  if (i >= associatedPackedFCandidateIndices_.size()) {
336  return reco::CandidatePtr();
337  } else {
339  }
340 }
341 
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:318
int i
Definition: DBlmapReader.cc:9
Analysis-level Photon class.
Definition: Photon.h:47
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
virtual float pt() const
transverse momentum
size_t size_type
Definition: Candidate.h:34
Photon()
default constructor
Definition: Photon.cc:12
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:138
virtual float phi() const
momentum azimuthal angle
reco::CaloClusterPtr seed() const
direct access to the seed cluster
Definition: Photon.cc:224
void embedBasicClusters()
method to store the electron&#39;s basic clusters
Definition: Photon.cc:251
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
Definition: Photon.cc:58
void embedSuperCluster()
method to store the photon&#39;s supercluster internally
Definition: Photon.cc:233
std::vector< reco::SuperCluster > superCluster_
Definition: Photon.h:317
edm::Ptr< CaloCluster > CaloClusterPtr
std::vector< reco::CaloCluster > preshowerClusters_
Place to store electron&#39;s preshower clusters internally.
Definition: Photon.h:323
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
bool isSet() const
std::vector< reco::CaloCluster > seedCluster_
Place to store electron&#39;s seed cluster internally.
Definition: Photon.h:327
static const char sep_[]
virtual double energy() const
energy
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:310
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:71
ProductID id() const
Accessor for product ID.
Definition: RefVector.h:104
virtual float eta() const
momentum pseudorapidity
edm::RefProd< pat::PackedCandidateCollection > packedPFCandidates_
Definition: Photon.h:380
void embedSeedCluster()
method to store the electron&#39;s seedcluster internally
Definition: Photon.cc:242
void embedPreshowerClusters()
method to store the electron&#39;s preshower clusters
Definition: Photon.cc:263
bool isPhotonIDAvailable(const std::string &name) const
Returns true if a specific ID is available in this pat::Photon.
Definition: Photon.cc:297
Bool_t photonID(const std::string &name) const
Definition: Photon.cc:283
std::vector< IdPair > photonIDs_
Definition: Photon.h:333
bool embeddedSuperCluster_
Definition: Photon.h:316
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:319
EcalRecHitCollection recHits_
Place to store electron&#39;s RecHits internally (5x5 around seed+ all RecHits)
Definition: Photon.h:331
bool embeddedRecHits_
True if RecHits stored internally.
Definition: Photon.h:329
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
bool set(std::unique_ptr< T > iNewValue) const
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
reco::SuperClusterRef superCluster() const
override the superCluster method from CaloJet, to access the internal storage of the supercluster ...
Definition: Photon.cc:190
virtual ~Photon()
destructor
Definition: Photon.cc:168
bool embeddedSeedCluster_
True if seed cluster is stored internally.
Definition: Photon.h:325
bool isNonnull() const
Checks for non-null.
Definition: RefProd.h:134
ProductID id() const
Accessor for product ID.
Definition: RefProd.h:140
Templated PAT object container.
Definition: PATObject.h:41
std::vector< uint16_t > associatedPackedFCandidateIndices_
Definition: Photon.h:381
volatile std::atomic< bool > shutdown_flag false
void setPackedPFCandidateCollection(const edm::RefProd< pat::PackedCandidateCollection > &refprod)
References to PFCandidates (e.g. to recompute isolation)
Definition: Photon.cc:305
void embedRecHits(const EcalRecHitCollection *rechits)
method to store the RecHits internally - can be called from the PATElectronProducer ...
Definition: Photon.cc:275
reco::CandidatePtr sourceCandidatePtr(size_type i) const
get the source candidate pointer with index i
Definition: Photon.cc:334
std::vector< reco::CaloCluster > basicClusters_
Place to store electron&#39;s basic clusters internally.
Definition: Photon.h:321