CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Electron.cc
Go to the documentation of this file.
1 //
2 //
3 
7 
8 #include <limits>
9 
10 using namespace pat;
11 
14  Lepton<reco::GsfElectron>(),
15  embeddedGsfElectronCore_(false),
16  embeddedGsfTrack_(false),
17  embeddedSuperCluster_(false),
18  embeddedPflowSuperCluster_(false),
19  embeddedTrack_(false),
20  embeddedSeedCluster_(false),
21  embeddedRecHits_(false),
22  embeddedPFCandidate_(false),
23  ecalDrivenMomentum_(Candidate::LorentzVector(0.,0.,0.,0.)),
24  cachedDB_(false),
25  dB_(0.0),
26  edB_(0.0),
27  ecalRegressionEnergy_(0.0),
28  ecalTrackRegressionEnergy_(0.0),
29  ecalRegressionError_(0.0),
30  ecalTrackRegressionError_(0.0),
31  ecalScale_(-99999.),
32  ecalSmear_(-99999.),
33  ecalRegressionScale_(-99999.),
34  ecalRegressionSmear_(-99999.),
35  ecalTrackRegressionScale_(-99999.),
36  ecalTrackRegressionSmear_(-99999.),
37  packedPFCandidates_(),
38  associatedPackedFCandidateIndices_()
39 {
41 }
42 
45  Lepton<reco::GsfElectron>(anElectron),
46  embeddedGsfElectronCore_(false),
47  embeddedGsfTrack_(false),
48  embeddedSuperCluster_(false),
49  embeddedPflowSuperCluster_(false),
50  embeddedTrack_(false),
51  embeddedSeedCluster_(false),
52  embeddedRecHits_(false),
53  embeddedPFCandidate_(false),
54  ecalDrivenMomentum_(anElectron.p4()),
55  cachedDB_(false),
56  dB_(0.0),
57  edB_(0.0)
58 {
60 }
61 
64  Lepton<reco::GsfElectron>(anElectronRef),
65  embeddedGsfElectronCore_(false),
66  embeddedGsfTrack_(false),
67  embeddedSuperCluster_(false),
68  embeddedPflowSuperCluster_(false),
69  embeddedTrack_(false),
70  embeddedSeedCluster_(false),
71  embeddedRecHits_(false),
72  embeddedPFCandidate_(false),
73  ecalDrivenMomentum_(anElectronRef->p4()),
74  cachedDB_(false),
75  dB_(0.0),
76  edB_(0.0)
77 {
79 }
80 
83  Lepton<reco::GsfElectron>(anElectronRef),
84  embeddedGsfElectronCore_(false),
85  embeddedGsfTrack_(false),
86  embeddedSuperCluster_(false),
87  embeddedPflowSuperCluster_(false),
88  embeddedTrack_(false),
89  embeddedSeedCluster_(false),
90  embeddedRecHits_(false),
91  embeddedPFCandidate_(false),
92  ecalDrivenMomentum_(anElectronRef->p4()),
93  cachedDB_(false),
94  dB_(0.0),
95  edB_(0.0)
96 {
98 }
99 
102 }
103 
105 std::ostream&
106 reco::operator<<(std::ostream& out, const pat::Electron& obj)
107 {
108  if(!out) return out;
109 
110  out << "\tpat::Electron: ";
111  out << std::setiosflags(std::ios::right);
112  out << std::setiosflags(std::ios::fixed);
113  out << std::setprecision(3);
114  out << " E/pT/eta/phi "
115  << obj.energy()<<"/"
116  << obj.pt()<<"/"
117  << obj.eta()<<"/"
118  << obj.phi();
119  return out;
120 }
121 
124  for (int i_ = 0; i_<5; ++i_){
125  ip_.push_back(0.0);
126  eip_.push_back(0.0);
127  cachedIP_.push_back(false);
128  }
129 }
130 
131 
134  if (embeddedGsfTrack_) {
135  return reco::GsfTrackRef(&gsfTrack_, 0);
136  } else {
138  }
139 }
140 
145  } else {
146  return reco::GsfElectron::core();
147  }
148 }
149 
150 
153  if (embeddedSuperCluster_) {
154  if (embeddedSeedCluster_ || !basicClusters_.empty() || !preshowerClusters_.empty()) {
155  if (!superClusterRelinked_.isSet()) {
156  std::unique_ptr<std::vector<reco::SuperCluster> > sc(new std::vector<reco::SuperCluster>(superCluster_));
157  if (embeddedSeedCluster_ && !(*sc)[0].seed().isAvailable()) {
158  (*sc)[0].setSeed(seed());
159  }
160  if (basicClusters_.size() && !(*sc)[0].clusters().isAvailable()) {
162  for (unsigned int iclus=0; iclus<basicClusters_.size(); ++iclus) {
164  }
165  (*sc)[0].setClusters(clusters);
166  }
167  if (preshowerClusters_.size() && !(*sc)[0].preshowerClusters().isAvailable()) {
169  for (unsigned int iclus=0; iclus<preshowerClusters_.size(); ++iclus) {
171  }
172  (*sc)[0].setPreshowerClusters(clusters);
173  }
174  superClusterRelinked_.set(std::move(sc));
175  }
177  } else {
179  }
180  //relink caloclusters if needed
182  } else {
184  }
185 }
186 
191  } else {
193  }
194 }
195 
200  } else {
201  return reco::GsfElectron::superCluster()->seed();
202  }
203 }
204 
207  if (embeddedTrack_) {
208  return reco::TrackRef(&track_, 0);
209  } else {
211  }
212 }
213 
214 // the name of the method is misleading, users should use gsfTrack of closestCtfTrack
216  return reco::TrackRef();
217 }
218 
221  gsfElectronCore_.clear();
222  if (reco::GsfElectron::core().isNonnull()) {
225  }
226 }
227 
230  gsfTrack_.clear();
231  if (reco::GsfElectron::gsfTrack().isNonnull()) {
233  embeddedGsfTrack_ = true;
234  }
235 }
236 
237 
240  superCluster_.clear();
241  if (reco::GsfElectron::superCluster().isNonnull()) {
243  embeddedSuperCluster_ = true;
244  }
245 }
246 
249  pflowSuperCluster_.clear();
250  if (reco::GsfElectron::parentSuperCluster().isNonnull()) {
253  }
254 }
255 
258  seedCluster_.clear();
259  if (reco::GsfElectron::superCluster().isNonnull() && reco::GsfElectron::superCluster()->seed().isNonnull()) {
261  embeddedSeedCluster_ = true;
262  }
263 }
264 
267  basicClusters_.clear();
268  if (reco::GsfElectron::superCluster().isNonnull()){
271  for(;itscl!=itsclE;++itscl){
272  basicClusters_.push_back( **itscl ) ;
273  }
274  }
275 }
276 
279  preshowerClusters_.clear();
280  if (reco::GsfElectron::superCluster().isNonnull()){
281  reco::CaloCluster_iterator itscl = reco::GsfElectron::superCluster()->preshowerClustersBegin();
282  reco::CaloCluster_iterator itsclE = reco::GsfElectron::superCluster()->preshowerClustersEnd();
283  for(;itscl!=itsclE;++itscl){
284  preshowerClusters_.push_back( **itscl ) ;
285  }
286  }
287 }
288 
291  pflowBasicClusters_.clear();
292  if (reco::GsfElectron::parentSuperCluster().isNonnull()){
295  for(;itscl!=itsclE;++itscl){
296  pflowBasicClusters_.push_back( **itscl ) ;
297  }
298  }
299 }
300 
303  pflowPreshowerClusters_.clear();
304  if (reco::GsfElectron::parentSuperCluster().isNonnull()){
305  reco::CaloCluster_iterator itscl = reco::GsfElectron::parentSuperCluster()->preshowerClustersBegin();
306  reco::CaloCluster_iterator itsclE = reco::GsfElectron::parentSuperCluster()->preshowerClustersEnd();
307  for(;itscl!=itsclE;++itscl){
308  pflowPreshowerClusters_.push_back( **itscl ) ;
309  }
310  }
311 }
312 
315  track_.clear();
316  if (reco::GsfElectron::closestCtfTrackRef().isNonnull()) {
318  embeddedTrack_ = true;
319  }
320 }
321 
322 // method to store the RecHits internally
324  if (rechits!=0) {
325  recHits_ = *rechits;
326  embeddedRecHits_ = true;
327  }
328 }
329 
344 float Electron::electronID(const std::string& name) const {
345  for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
346  if (it->first == name) return it->second;
347  }
348  cms::Exception ex("Key not found");
349  ex << "pat::Electron: the ID " << name << " can't be found in this pat::Electron.\n";
350  ex << "The available IDs are: ";
351  for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
352  ex << "'" << it->first << "' ";
353  }
354  ex << ".\n";
355  throw ex;
356 }
357 
360  for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
361  if (it->first == name) return true;
362  }
363  return false;
364 }
365 
366 
369  if (embeddedPFCandidate_) {
371  } else {
372  return pfCandidateRef_;
373  }
374 }
375 
378  pfCandidate_.clear();
380  pfCandidate_.push_back( *pfCandidateRef_ );
381  embeddedPFCandidate_ = true;
382  }
383 }
384 
388  if (pfCandidateRef_.isNonnull()) {
389  if (i == 0) {
391  } else {
392  i--;
393  }
394  }
395  if (i >= associatedPackedFCandidateIndices_.size()) {
396  return reco::CandidatePtr();
397  } else {
399  }
400 }
401 
402 
403 
414 double Electron::dB(IpType type_) const {
415  // preserve old functionality exactly
416  if (type_ == None){
417  if ( cachedDB_ ) {
418  return dB_;
419  } else {
421  }
422  }
423  // more IP types (new)
424  else if ( cachedIP_[type_] ) {
425  return ip_[type_];
426  } else {
428  }
429 }
430 
441 double Electron::edB(IpType type_) const {
442  // preserve old functionality exactly
443  if (type_ == None) {
444  if ( cachedDB_ ) {
445  return edB_;
446  } else {
448  }
449  }
450  // more IP types (new)
451  else if ( cachedIP_[type_] ) {
452  return eip_[type_];
453  } else {
455  }
456 
457 }
458 
460 void Electron::setDB(double dB, double edB, IpType type){
461  if (type == None) { // Preserve old functionality exactly
462  dB_ = dB; edB_ = edB;
463  cachedDB_ = true;
464  } else {
465  ip_[type] = dB;
466  eip_[type] = edB;
467  cachedIP_[type] = true;
468  }
469 }
470 
472 void Electron::setMvaVariables( double sigmaIetaIphi, double ip3d){
474  ip3d_ = ip3d;
475 }
476 
478  if (!associatedPackedFCandidateIndices_.empty()) throw cms::Exception("Unsupported", "You can't call setPackedPFCandidateCollection _after_ having called setAssociatedPackedPFCandidates");
479  packedPFCandidates_ = refprod;
480 }
481 
484  for (uint16_t idx : associatedPackedFCandidateIndices_) {
486  }
487  return ret;
488 }
489 
492  if (refvector.id().isValid() && refvector.id() != packedPFCandidates_.id()) {
493  throw cms::Exception("Unsupported", "setAssociatedPackedPFCandidates pointing to a collection other than the one from setPackedPFCandidateCollection");
494  }
495  } else {
497  }
499  for (const edm::Ref<pat::PackedCandidateCollection> & ref : refvector) {
500  associatedPackedFCandidateIndices_.push_back(ref.key());
501  }
502 }
503 
double edB(IpType type=None) const
Uncertainty on the corresponding impact parameter.
Definition: Electron.cc:441
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
virtual ~Electron()
destructor
Definition: Electron.cc:101
bool embeddedTrack_
True if electron&#39;s track is stored internally.
Definition: Electron.h:278
std::vector< reco::GsfTrack > gsfTrack_
Place to store electron&#39;s gsfTrack internally.
Definition: Electron.h:258
edm::Ref< GsfElectronCoreCollection > GsfElectronCoreRef
void embedTrack()
method to store the electron&#39;s Track internally
Definition: Electron.cc:314
void embedSeedCluster()
method to store the electron&#39;s seedcluster internally
Definition: Electron.cc:257
SuperClusterRef parentSuperCluster() const
Definition: GsfElectron.h:188
void embedGsfElectronCore()
method to store the electron&#39;s core internally
Definition: Electron.cc:220
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
void embedPflowBasicClusters()
method to store the electron&#39;s pflow basic clusters
Definition: Electron.cc:290
virtual float pt() const
transverse momentum
reco::TrackRef closestCtfTrackRef() const
override the reco::GsfElectron::closestCtfTrackRef method, to access the internal storage of the trac...
Definition: Electron.cc:206
size_t size_type
Definition: Candidate.h:34
void embedSuperCluster()
method to store the electron&#39;s SuperCluster internally
Definition: Electron.cc:239
double ip3d() const
ip3d
Definition: Electron.h:199
void embedPFCandidate()
embed the PFCandidate pointed to by pfCandidateRef_
Definition: Electron.cc:377
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:138
virtual float phi() const
momentum azimuthal angle
void setDB(double dB, double edB, IpType type=None)
Set impact parameter of a certain type and its uncertainty.
Definition: Electron.cc:460
reco::SuperClusterRef superCluster() const
override the reco::GsfElectron::superCluster method, to access the internal storage of the superclust...
Definition: Electron.cc:152
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: Electron.cc:490
reco::TrackRef track() const
returns nothing. Use either gsfTrack or closestCtfTrack
Definition: Electron.cc:215
std::vector< reco::SuperCluster > superCluster_
Place to store electron&#39;s supercluster internally.
Definition: Electron.h:264
reco::GsfTrackRef gsfTrack() const
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
Definition: Electron.cc:133
double dB_
Impact parameter at the primary vertex.
Definition: Electron.h:311
edm::Ptr< CaloCluster > CaloClusterPtr
std::vector< reco::Track > track_
Place to store electron&#39;s track internally.
Definition: Electron.h:280
bool isAvailable() const
Definition: Ref.h:276
bool embeddedGsfElectronCore_
True if electron&#39;s gsfElectronCore is stored internally.
Definition: Electron.h:252
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
bool isSet() const
void embedPreshowerClusters()
method to store the electron&#39;s preshower clusters
Definition: Electron.cc:278
std::vector< reco::CaloCluster > pflowBasicClusters_
Place to store electron&#39;s pflow basic clusters internally.
Definition: Electron.h:272
TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:199
reco::CaloClusterPtr seed() const
direct access to the seed cluster
Definition: Electron.cc:197
edm::RefProd< pat::PackedCandidateCollection > packedPFCandidates_
Definition: Electron.h:348
void embedBasicClusters()
method to store the electron&#39;s basic clusters
Definition: Electron.cc:266
std::vector< reco::CaloCluster > basicClusters_
Place to store electron&#39;s basic clusters internally.
Definition: Electron.h:268
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
virtual double energy() const
energy
std::vector< uint16_t > associatedPackedFCandidateIndices_
Definition: Electron.h:349
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:71
std::vector< reco::CaloCluster > preshowerClusters_
Place to store electron&#39;s preshower clusters internally.
Definition: Electron.h:270
ProductID id() const
Accessor for product ID.
Definition: RefVector.h:104
bool embeddedRecHits_
True if RecHits stored internally.
Definition: Electron.h:286
void embedRecHits(const EcalRecHitCollection *rechits)
method to store the RecHits internally - can be called from the PATElectronProducer ...
Definition: Electron.cc:323
virtual float eta() const
momentum pseudorapidity
double p4[4]
Definition: TauolaWrapper.h:92
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
Definition: GsfElectron.h:182
enum pat::Electron::IPTYPE IpType
Analysis-level lepton class.
Definition: Lepton.h:30
bool embeddedSeedCluster_
True if seed cluster is stored internally.
Definition: Electron.h:282
edm::AtomicPtrCache< std::vector< reco::SuperCluster > > superClusterRelinked_
Place to temporarily store the electron&#39;s supercluster after relinking the seed to it...
Definition: Electron.h:266
virtual reco::GsfElectronCoreRef core() const
override the virtual reco::GsfElectron::core method, so that the embedded core can be used by GsfElec...
Definition: Electron.cc:142
std::vector< reco::GsfElectronCore > gsfElectronCore_
Place to store electron&#39;s gsfElectronCore internally.
Definition: Electron.h:254
reco::PFCandidateRef pfCandidateRef() const
reference to the source PFCandidates; null if this has been built from a standard electron ...
Definition: Electron.cc:368
double ip3d_
Definition: Electron.h:317
Electron()
default constructor
Definition: Electron.cc:13
void initImpactParameters()
init impact parameter defaults (for use in a constructor)
Definition: Electron.cc:123
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
void embedGsfTrack()
method to store the electron&#39;s GsfTrack internally
Definition: Electron.cc:229
tuple out
Definition: dbtoconf.py:99
EcalRecHitCollection recHits_
Place to store electron&#39;s RecHits internally (5x5 around seed+ all RecHits)
Definition: Electron.h:288
void setPackedPFCandidateCollection(const edm::RefProd< pat::PackedCandidateCollection > &refprod)
References to PFCandidates (e.g. to recompute isolation)
Definition: Electron.cc:477
reco::PFCandidateCollection pfCandidate_
A copy of the source IsolatedPFCandidate is stored in this vector if embeddedPFCandidate_ if True...
Definition: Electron.h:299
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
double edB_
Impact paramater uncertainty at the primary vertex.
Definition: Electron.h:313
float electronID(const std::string &name) const
Returns a specific electron ID associated to the pat::Electron given its name.
Definition: Electron.cc:344
bool embeddedGsfTrack_
True if electron&#39;s gsfTrack is stored internally.
Definition: Electron.h:256
bool set(std::unique_ptr< T > iNewValue) const
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
bool embeddedPflowSuperCluster_
True if electron&#39;s pflowsupercluster is stored internally.
Definition: Electron.h:262
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
void embedPflowSuperCluster()
method to store the electron&#39;s PflowSuperCluster internally
Definition: Electron.cc:248
Analysis-level electron class.
Definition: Electron.h:52
std::vector< IdPair > electronIDs_
Electron IDs.
Definition: Electron.h:292
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
reco::PFCandidateRef pfCandidateRef_
reference to the IsolatedPFCandidate this has been built from; null if this has been built from a sta...
Definition: Electron.h:301
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.cc:8
bool embeddedSuperCluster_
True if electron&#39;s supercluster is stored internally.
Definition: Electron.h:260
bool isElectronIDAvailable(const std::string &name) const
Returns true if a specific ID is available in this pat::Electron.
Definition: Electron.cc:359
std::vector< reco::CaloCluster > pflowPreshowerClusters_
Place to store electron&#39;s pflow preshower clusters internally.
Definition: Electron.h:274
bool isNonnull() const
Checks for non-null.
Definition: RefProd.h:134
ProductID id() const
Accessor for product ID.
Definition: RefProd.h:140
reco::SuperClusterRef parentSuperCluster() const
override the reco::GsfElectron::pflowSuperCluster method, to access the internal storage of the pflow...
Definition: Electron.cc:188
edm::RefVector< pat::PackedCandidateCollection > associatedPackedPFCandidates() const
References to PFCandidates linked to this object (e.g. for isolation vetos or masking before jet recl...
Definition: Electron.cc:482
float sigmaIetaIphi() const
Definition: Electron.h:195
bool cachedDB_
True if impact parameter has been cached.
Definition: Electron.h:309
std::vector< double > ip_
Impact parameter at the primary vertex,.
Definition: Electron.h:343
volatile std::atomic< bool > shutdown_flag false
std::vector< bool > cachedIP_
True if the IP (former dB) has been cached.
Definition: Electron.h:341
bool embeddedPFCandidate_
true if the IsolatedPFCandidate is embedded
Definition: Electron.h:297
void setMvaVariables(double sigmaIetaIphi, double ip3d)
set missing mva input variables
Definition: Electron.cc:472
reco::CandidatePtr sourceCandidatePtr(size_type i) const
get the source candidate pointer with index i
Definition: Electron.cc:387
double dB(IpType type=None) const
Impact parameter wrt primary vertex or beamspot.
Definition: Electron.cc:414
void embedPflowPreshowerClusters()
method to store the electron&#39;s pflow preshower clusters
Definition: Electron.cc:302
std::vector< double > eip_
Impact parameter uncertainty as recommended by the tracking group.
Definition: Electron.h:345
std::vector< reco::SuperCluster > pflowSuperCluster_
Place to store electron&#39;s pflow supercluster internally.
Definition: Electron.h:276
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:183
float sigmaIetaIphi_
additional missing mva variables : 14/04/2012
Definition: Electron.h:316
std::vector< reco::CaloCluster > seedCluster_
Place to store electron&#39;s seed cluster internally.
Definition: Electron.h:284