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 
13  PATObject<reco::Photon>(reco::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 
90 Photon::Photon(const edm::RefToBase<reco::Photon> & aPhotonRef) :
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 
129 Photon::Photon(const edm::Ptr<reco::Photon> & aPhotonRef) :
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 
168 Photon::~Photon() {
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) {
201  clusters.push_back(reco::CaloClusterPtr(&basicClusters_,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) {
208  clusters.push_back(reco::CaloClusterPtr(&preshowerClusters_,iclus));
209  }
210  (*sc)[0].setPreshowerClusters(clusters);
211  }
212  superClusterRelinked_.set(std::move(sc));
213  }
214  return reco::SuperClusterRef(&*superClusterRelinked_, 0);
215  } else {
216  return reco::SuperClusterRef(&superCluster_, 0);
217  }
218  } else {
220  }
221 }
222 
225  if(embeddedSeedCluster_){
226  return reco::CaloClusterPtr(&seedCluster_,0);
227  } else {
228  return reco::Photon::superCluster()->seed();
229  }
230 }
231 
233 void Photon::embedSuperCluster() {
234  superCluster_.clear();
235  if (reco::Photon::superCluster().isNonnull()) {
236  superCluster_.push_back(*reco::Photon::superCluster());
237  embeddedSuperCluster_ = true;
238  }
239 }
240 
242 void Photon::embedSeedCluster() {
243  seedCluster_.clear();
244  if (reco::Photon::superCluster().isNonnull() && reco::Photon::superCluster()->seed().isNonnull()) {
245  seedCluster_.push_back(*reco::Photon::superCluster()->seed());
246  embeddedSeedCluster_ = true;
247  }
248 }
249 
251 void Photon::embedBasicClusters() {
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 
263 void Photon::embedPreshowerClusters() {
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
275 void Photon::embedRecHits(const EcalRecHitCollection * rechits) {
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
297 bool Photon::isPhotonIDAvailable(const std::string & name) const {
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 
305 void Photon::setPackedPFCandidateCollection(const edm::RefProd<pat::PackedCandidateCollection> & refprod) {
306  if (!associatedPackedFCandidateIndices_.empty()) throw cms::Exception("Unsupported", "You can't call setPackedPFCandidateCollection _after_ having called setAssociatedPackedPFCandidates");
307  packedPFCandidates_ = refprod;
308 }
309 
310 edm::RefVector<pat::PackedCandidateCollection> Photon::associatedPackedPFCandidates() const {
311  edm::RefVector<pat::PackedCandidateCollection> ret(packedPFCandidates_.id());
312  for (uint16_t idx : associatedPackedFCandidateIndices_) {
313  ret.push_back(edm::Ref<pat::PackedCandidateCollection>(packedPFCandidates_, idx));
314  }
315  return ret;
316 }
317 
318 void Photon::setAssociatedPackedPFCandidates(const edm::RefVector<pat::PackedCandidateCollection> &refvector) {
319  if (packedPFCandidates_.isNonnull()) {
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 {
324  packedPFCandidates_ = edm::RefProd<pat::PackedCandidateCollection>(refvector);
325  }
326  associatedPackedFCandidateIndices_.clear();
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 {
338  return reco::CandidatePtr(edm::refToPtr(edm::Ref<pat::PackedCandidateCollection>(packedPFCandidates_, associatedPackedFCandidateIndices_[i])));
339  }
340 }
341 
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
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
virtual ~Photon()
destructor
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:139
virtual float phi() const
momentum azimuthal angle
edm::Ptr< CaloCluster > CaloClusterPtr
uint16_t size_type
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
Photon()
default constructor
Definition: Photon.h:31
static const char sep_[]
virtual double energy() const
energy
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
virtual CandidatePtr sourceCandidatePtr(size_type i) const
tuple out
Definition: dbtoconf.py:99
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
volatile std::atomic< bool > shutdown_flag false