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 {
18 }
19 
21 Photon::Photon(const reco::Photon & aPhoton) :
22  PATObject<reco::Photon>(aPhoton),
23  embeddedSuperCluster_(false),
24  embeddedSeedCluster_(false),
25  embeddedRecHits_(false)
26 {
27 }
28 
31  PATObject<reco::Photon>(aPhotonRef),
32  embeddedSuperCluster_(false),
33  embeddedSeedCluster_(false),
34  embeddedRecHits_(false)
35 {
36 }
37 
40  PATObject<reco::Photon>(aPhotonRef),
41  embeddedSuperCluster_(false),
42  embeddedSeedCluster_(false),
43  embeddedRecHits_(false)
44 {
45 }
46 
49 }
50 
51 std::ostream&
52 reco::operator<<(std::ostream& out, const pat::Photon& obj)
53 {
54  if(!out) return out;
55 
56  out << "\tpat::Photon: ";
57  out << std::setiosflags(std::ios::right);
58  out << std::setiosflags(std::ios::fixed);
59  out << std::setprecision(3);
60  out << " E/pT/eta/phi "
61  << obj.energy()<<"/"
62  << obj.pt()<<"/"
63  << obj.eta()<<"/"
64  << obj.phi();
65  return out;
66 }
67 
72  if (embeddedSeedCluster_ || !basicClusters_.empty() || !preshowerClusters_.empty()) {
74  std::unique_ptr<std::vector<reco::SuperCluster> > sc(new std::vector<reco::SuperCluster>(superCluster_));
75  if (embeddedSeedCluster_ && !(*sc)[0].seed().isAvailable()) {
76  (*sc)[0].setSeed(seed());
77  }
78  if (basicClusters_.size() && !(*sc)[0].clusters().isAvailable()) {
80  for (unsigned int iclus=0; iclus<basicClusters_.size(); ++iclus) {
82  }
83  (*sc)[0].setClusters(clusters);
84  }
85  if (preshowerClusters_.size() && !(*sc)[0].preshowerClusters().isAvailable()) {
87  for (unsigned int iclus=0; iclus<preshowerClusters_.size(); ++iclus) {
89  }
90  (*sc)[0].setPreshowerClusters(clusters);
91  }
92  superClusterRelinked_.set(std::move(sc));
93  }
95  } else {
97  }
98  } else {
100  }
101 }
102 
107  } else {
108  return reco::Photon::superCluster()->seed();
109  }
110 }
111 
114  superCluster_.clear();
115  if (reco::Photon::superCluster().isNonnull()) {
117  embeddedSuperCluster_ = true;
118  }
119 }
120 
123  seedCluster_.clear();
124  if (reco::Photon::superCluster().isNonnull() && reco::Photon::superCluster()->seed().isNonnull()) {
126  embeddedSeedCluster_ = true;
127  }
128 }
129 
132  basicClusters_.clear();
133  if (reco::Photon::superCluster().isNonnull()){
134  reco::CaloCluster_iterator itscl = reco::Photon::superCluster()->clustersBegin();
135  reco::CaloCluster_iterator itsclE = reco::Photon::superCluster()->clustersEnd();
136  for(;itscl!=itsclE;++itscl){
137  basicClusters_.push_back( **itscl ) ;
138  }
139  }
140 }
141 
144  preshowerClusters_.clear();
145  if (reco::Photon::superCluster().isNonnull()){
146  reco::CaloCluster_iterator itscl = reco::Photon::superCluster()->preshowerClustersBegin();
147  reco::CaloCluster_iterator itsclE = reco::Photon::superCluster()->preshowerClustersEnd();
148  for(;itscl!=itsclE;++itscl){
149  preshowerClusters_.push_back( **itscl ) ;
150  }
151  }
152 }
153 
154 // method to store the RecHits internally
156  if (rechits!=0) {
157  recHits_ = *rechits;
158  embeddedRecHits_ = true;
159  }
160 }
161 
162 // method to retrieve a photon ID (or throw)
163 Bool_t Photon::photonID(const std::string & name) const {
164  for (std::vector<IdPair>::const_iterator it = photonIDs_.begin(), ed = photonIDs_.end(); it != ed; ++it) {
165  if (it->first == name) return it->second;
166  }
167  cms::Exception ex("Key not found");
168  ex << "pat::Photon: the ID " << name << " can't be found in this pat::Photon.\n";
169  ex << "The available IDs are: ";
170  for (std::vector<IdPair>::const_iterator it = photonIDs_.begin(), ed = photonIDs_.end(); it != ed; ++it) {
171  ex << "'" << it->first << "' ";
172  }
173  ex << ".\n";
174  throw ex;
175 }
176 // check if an ID is there
178  for (std::vector<IdPair>::const_iterator it = photonIDs_.begin(), ed = photonIDs_.end(); it != ed; ++it) {
179  if (it->first == name) return true;
180  }
181  return false;
182 }
183 
184 
186  if (!associatedPackedFCandidateIndices_.empty()) throw cms::Exception("Unsupported", "You can't call setPackedPFCandidateCollection _after_ having called setAssociatedPackedPFCandidates");
187  packedPFCandidates_ = refprod;
188 }
189 
192  for (uint16_t idx : associatedPackedFCandidateIndices_) {
194  }
195  return ret;
196 }
197 
200  if (refvector.id().isValid() && refvector.id() != packedPFCandidates_.id()) {
201  throw cms::Exception("Unsupported", "setAssociatedPackedPFCandidates pointing to a collection other than the one from setPackedPFCandidateCollection");
202  }
203  } else {
205  }
207  for (const edm::Ref<pat::PackedCandidateCollection> & ref : refvector) {
208  associatedPackedFCandidateIndices_.push_back(ref.key());
209  }
210 }
211 
215  if (i >= associatedPackedFCandidateIndices_.size()) {
216  return reco::CandidatePtr();
217  } else {
219  }
220 }
221 
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
virtual double energy() const GCC11_FINAL
energy
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
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
reco::CaloClusterPtr seed() const
direct access to the seed cluster
Definition: Photon.cc:104
void embedBasicClusters()
method to store the electron&#39;s basic clusters
Definition: Photon.cc:131
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:113
std::vector< reco::SuperCluster > superCluster_
Definition: Photon.h:245
edm::Ptr< CaloCluster > CaloClusterPtr
std::vector< reco::CaloCluster > preshowerClusters_
Place to store electron&#39;s preshower clusters internally.
Definition: Photon.h:251
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:255
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
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
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:71
ProductID id() const
Accessor for product ID.
Definition: RefVector.h:104
edm::RefProd< pat::PackedCandidateCollection > packedPFCandidates_
Definition: Photon.h:268
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
Bool_t photonID(const std::string &name) const
Definition: Photon.cc:163
std::vector< IdPair > photonIDs_
Definition: Photon.h:261
bool embeddedSuperCluster_
Definition: Photon.h:244
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
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
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:70
virtual ~Photon()
destructor
Definition: Photon.cc:48
bool embeddedSeedCluster_
True if seed cluster is stored internally.
Definition: Photon.h:253
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:269
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:185
virtual float pt() const GCC11_FINAL
transverse momentum
void embedRecHits(const EcalRecHitCollection *rechits)
method to store the RecHits internally - can be called from the PATElectronProducer ...
Definition: Photon.cc:155
reco::CandidatePtr sourceCandidatePtr(size_type i) const
get the source candidate pointer with index i
Definition: Photon.cc:214
std::vector< reco::CaloCluster > basicClusters_
Place to store electron&#39;s basic clusters internally.
Definition: Photon.h:249