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 
6 
7 #include <limits>
8 
9 using namespace pat;
10 
13  Lepton<reco::GsfElectron>(),
14  embeddedGsfElectronCore_(false),
15  embeddedGsfTrack_(false),
16  embeddedSuperCluster_(false),
17  embeddedPflowSuperCluster_(false),
18  embeddedTrack_(false),
19  embeddedSeedCluster_(false),
20  embeddedRecHits_(false),
21  embeddedPFCandidate_(false),
22  ecalDrivenMomentum_(Candidate::LorentzVector(0.,0.,0.,0.)),
23  cachedDB_(false),
24  dB_(0.0),
25  edB_(0.0),
26  ecalRegressionEnergy_(0.0),
27  ecalTrackRegressionEnergy_(0.0),
28  ecalRegressionError_(0.0),
29  ecalTrackRegressionError_(0.0),
30  ecalScale_(-99999.),
31  ecalSmear_(-99999.),
32  ecalRegressionScale_(-99999.),
33  ecalRegressionSmear_(-99999.),
34  ecalTrackRegressionScale_(-99999.),
35  ecalTrackRegressionSmear_(-99999.)
36 {
38 }
39 
42  Lepton<reco::GsfElectron>(anElectron),
43  embeddedGsfElectronCore_(false),
44  embeddedGsfTrack_(false),
45  embeddedSuperCluster_(false),
46  embeddedPflowSuperCluster_(false),
47  embeddedTrack_(false),
48  embeddedSeedCluster_(false),
49  embeddedRecHits_(false),
50  embeddedPFCandidate_(false),
51  ecalDrivenMomentum_(anElectron.p4()),
52  cachedDB_(false),
53  dB_(0.0),
54  edB_(0.0)
55 {
57 }
58 
61  Lepton<reco::GsfElectron>(anElectronRef),
62  embeddedGsfElectronCore_(false),
63  embeddedGsfTrack_(false),
64  embeddedSuperCluster_(false),
65  embeddedPflowSuperCluster_(false),
66  embeddedTrack_(false),
67  embeddedSeedCluster_(false),
68  embeddedRecHits_(false),
69  embeddedPFCandidate_(false),
70  ecalDrivenMomentum_(anElectronRef->p4()),
71  cachedDB_(false),
72  dB_(0.0),
73  edB_(0.0)
74 {
76 }
77 
80  Lepton<reco::GsfElectron>(anElectronRef),
81  embeddedGsfElectronCore_(false),
82  embeddedGsfTrack_(false),
83  embeddedSuperCluster_(false),
84  embeddedPflowSuperCluster_(false),
85  embeddedTrack_(false),
86  embeddedSeedCluster_(false),
87  embeddedRecHits_(false),
88  embeddedPFCandidate_(false),
89  ecalDrivenMomentum_(anElectronRef->p4()),
90  cachedDB_(false),
91  dB_(0.0),
92  edB_(0.0)
93 {
95 }
96 
99 }
100 
102 std::ostream&
103 reco::operator<<(std::ostream& out, const pat::Electron& obj)
104 {
105  if(!out) return out;
106 
107  out << "\tpat::Electron: ";
108  out << std::setiosflags(std::ios::right);
109  out << std::setiosflags(std::ios::fixed);
110  out << std::setprecision(3);
111  out << " E/pT/eta/phi "
112  << obj.energy()<<"/"
113  << obj.pt()<<"/"
114  << obj.eta()<<"/"
115  << obj.phi();
116  return out;
117 }
118 
121  for (int i_ = 0; i_<5; ++i_){
122  ip_.push_back(0.0);
123  eip_.push_back(0.0);
124  cachedIP_.push_back(false);
125  }
126 }
127 
128 
131  if (embeddedGsfTrack_) {
132  return reco::GsfTrackRef(&gsfTrack_, 0);
133  } else {
135  }
136 }
137 
142  } else {
143  return reco::GsfElectron::core();
144  }
145 }
146 
147 
150  if (embeddedSuperCluster_) {
152  } else {
154  }
155 }
156 
161  } else {
163  }
164 }
165 
170  } else {
171  return reco::GsfElectron::superCluster()->seed();
172  }
173 }
174 
177  if (embeddedTrack_) {
178  return reco::TrackRef(&track_, 0);
179  } else {
181  }
182 }
183 
184 // the name of the method is misleading, users should use gsfTrack of closestCtfTrack
186  return reco::TrackRef();
187 }
188 
191  gsfElectronCore_.clear();
192  if (reco::GsfElectron::core().isNonnull()) {
195  }
196 }
197 
200  gsfTrack_.clear();
201  if (reco::GsfElectron::gsfTrack().isNonnull()) {
203  embeddedGsfTrack_ = true;
204  }
205 }
206 
207 
210  superCluster_.clear();
211  if (reco::GsfElectron::superCluster().isNonnull()) {
213  embeddedSuperCluster_ = true;
214  }
215 }
216 
219  pflowSuperCluster_.clear();
220  if (reco::GsfElectron::parentSuperCluster().isNonnull()) {
223  }
224 }
225 
228  seedCluster_.clear();
229  if (reco::GsfElectron::superCluster().isNonnull() && reco::GsfElectron::superCluster()->seed().isNonnull()) {
231  embeddedSeedCluster_ = true;
232  }
233 }
234 
237  basicClusters_.clear();
238  if (reco::GsfElectron::superCluster().isNonnull()){
241  for(;itscl!=itsclE;++itscl){
242  basicClusters_.push_back( **itscl ) ;
243  }
244  }
245 }
246 
249  preshowerClusters_.clear();
250  if (reco::GsfElectron::superCluster().isNonnull()){
251  reco::CaloCluster_iterator itscl = reco::GsfElectron::superCluster()->preshowerClustersBegin();
252  reco::CaloCluster_iterator itsclE = reco::GsfElectron::superCluster()->preshowerClustersEnd();
253  for(;itscl!=itsclE;++itscl){
254  preshowerClusters_.push_back( **itscl ) ;
255  }
256  }
257 }
258 
261  pflowBasicClusters_.clear();
262  if (reco::GsfElectron::parentSuperCluster().isNonnull()){
265  for(;itscl!=itsclE;++itscl){
266  pflowBasicClusters_.push_back( **itscl ) ;
267  }
268  }
269 }
270 
273  pflowPreshowerClusters_.clear();
274  if (reco::GsfElectron::parentSuperCluster().isNonnull()){
275  reco::CaloCluster_iterator itscl = reco::GsfElectron::parentSuperCluster()->preshowerClustersBegin();
276  reco::CaloCluster_iterator itsclE = reco::GsfElectron::parentSuperCluster()->preshowerClustersEnd();
277  for(;itscl!=itsclE;++itscl){
278  pflowPreshowerClusters_.push_back( **itscl ) ;
279  }
280  }
281 }
282 
285  track_.clear();
286  if (reco::GsfElectron::closestCtfTrackRef().isNonnull()) {
288  embeddedTrack_ = true;
289  }
290 }
291 
292 // method to store the RecHits internally
294  if (rechits!=0) {
295  recHits_ = *rechits;
296  embeddedRecHits_ = true;
297  }
298 }
299 
314 float Electron::electronID(const std::string& name) const {
315  for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
316  if (it->first == name) return it->second;
317  }
318  cms::Exception ex("Key not found");
319  ex << "pat::Electron: the ID " << name << " can't be found in this pat::Electron.\n";
320  ex << "The available IDs are: ";
321  for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
322  ex << "'" << it->first << "' ";
323  }
324  ex << ".\n";
325  throw ex;
326 }
327 
330  for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
331  if (it->first == name) return true;
332  }
333  return false;
334 }
335 
336 
339  if (embeddedPFCandidate_) {
341  } else {
342  return pfCandidateRef_;
343  }
344 }
345 
348  pfCandidate_.clear();
350  pfCandidate_.push_back( *pfCandidateRef_ );
351  embeddedPFCandidate_ = true;
352  }
353 }
354 
358  if (embeddedPFCandidate_) {
360  } else {
361  return reco::CandidatePtr();
362  }
363 }
364 
365 
366 
377 double Electron::dB(IpType type_) const {
378  // preserve old functionality exactly
379  if (type_ == None){
380  if ( cachedDB_ ) {
381  return dB_;
382  } else {
384  }
385  }
386  // more IP types (new)
387  else if ( cachedIP_[type_] ) {
388  return ip_[type_];
389  } else {
391  }
392 }
393 
404 double Electron::edB(IpType type_) const {
405  // preserve old functionality exactly
406  if (type_ == None) {
407  if ( cachedDB_ ) {
408  return edB_;
409  } else {
411  }
412  }
413  // more IP types (new)
414  else if ( cachedIP_[type_] ) {
415  return eip_[type_];
416  } else {
418  }
419 
420 }
421 
423 void Electron::setDB(double dB, double edB, IpType type){
424  if (type == None) { // Preserve old functionality exactly
425  dB_ = dB; edB_ = edB;
426  cachedDB_ = true;
427  } else {
428  ip_[type] = dB;
429  eip_[type] = edB;
430  cachedIP_[type] = true;
431  }
432 }
433 
435 void Electron::setMvaVariables( double r9, double sigmaIphiIphi, double sigmaIetaIphi, double ip3d){
436  r9_ = r9;
439  ip3d_ = ip3d;
440 }
double edB(IpType type=None) const
Uncertainty on the corresponding impact parameter.
Definition: Electron.cc:404
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
type
Definition: HCALResponse.h:21
virtual double energy() const GCC11_FINAL
energy
int i
Definition: DBlmapReader.cc:9
virtual ~Electron()
destructor
Definition: Electron.cc:98
bool embeddedTrack_
True if electron&#39;s track is stored internally.
Definition: Electron.h:266
std::vector< reco::GsfTrack > gsfTrack_
Place to store electron&#39;s gsfTrack internally.
Definition: Electron.h:248
edm::Ref< GsfElectronCoreCollection > GsfElectronCoreRef
void embedTrack()
method to store the electron&#39;s Track internally
Definition: Electron.cc:284
void embedSeedCluster()
method to store the electron&#39;s seedcluster internally
Definition: Electron.cc:227
SuperClusterRef parentSuperCluster() const
Definition: GsfElectron.h:174
void embedGsfElectronCore()
method to store the electron&#39;s core internally
Definition: Electron.cc:190
void embedPflowBasicClusters()
method to store the electron&#39;s pflow basic clusters
Definition: Electron.cc:260
reco::TrackRef closestCtfTrackRef() const
override the reco::GsfElectron::closestCtfTrackRef method, to access the internal storage of the trac...
Definition: Electron.cc:176
size_t size_type
Definition: Candidate.h:34
void embedSuperCluster()
method to store the electron&#39;s SuperCluster internally
Definition: Electron.cc:209
double ip3d() const
ip3d
Definition: Electron.h:199
void embedPFCandidate()
embed the PFCandidate pointed to by pfCandidateRef_
Definition: Electron.cc:347
void setDB(double dB, double edB, IpType type=None)
Set impact parameter of a certain type and its uncertainty.
Definition: Electron.cc:423
reco::SuperClusterRef superCluster() const
override the reco::GsfElectron::superCluster method, to access the internal storage of the superclust...
Definition: Electron.cc:149
reco::TrackRef track() const
returns nothing. Use either gsfTrack or closestCtfTrack
Definition: Electron.cc:185
std::vector< reco::SuperCluster > superCluster_
Place to store electron&#39;s supercluster internally.
Definition: Electron.h:254
reco::GsfTrackRef gsfTrack() const
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
Definition: Electron.cc:130
double dB_
Impact parameter at the primary vertex.
Definition: Electron.h:299
edm::Ptr< CaloCluster > CaloClusterPtr
std::vector< reco::Track > track_
Place to store electron&#39;s track internally.
Definition: Electron.h:268
bool isAvailable() const
Definition: Ref.h:276
double sigmaIetaIphi() const
sigmaIEtaIPhi
Definition: Electron.h:197
bool embeddedGsfElectronCore_
True if electron&#39;s gsfElectronCore is stored internally.
Definition: Electron.h:242
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
void setMvaVariables(double r9, double sigmaIphiIphi, double sigmaIetaIphi, double ip3d)
set missing mva input variables
Definition: Electron.cc:435
void embedPreshowerClusters()
method to store the electron&#39;s preshower clusters
Definition: Electron.cc:248
std::vector< reco::CaloCluster > pflowBasicClusters_
Place to store electron&#39;s pflow basic clusters internally.
Definition: Electron.h:260
TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:185
reco::CaloClusterPtr seed() const
direct access to the seed cluster
Definition: Electron.cc:167
void embedBasicClusters()
method to store the electron&#39;s basic clusters
Definition: Electron.cc:236
std::vector< reco::CaloCluster > basicClusters_
Place to store electron&#39;s basic clusters internally.
Definition: Electron.h:256
double r9_
additional missing mva variables : 14/04/2012
Definition: Electron.h:304
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
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:258
const T & max(const T &a, const T &b)
bool embeddedRecHits_
True if RecHits stored internally.
Definition: Electron.h:274
void embedRecHits(const EcalRecHitCollection *rechits)
method to store the RecHits internally - can be called from the PATElectronProducer ...
Definition: Electron.cc:293
double p4[4]
Definition: TauolaWrapper.h:92
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
Definition: GsfElectron.h:168
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:270
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:139
std::vector< reco::GsfElectronCore > gsfElectronCore_
Place to store electron&#39;s gsfElectronCore internally.
Definition: Electron.h:244
reco::PFCandidateRef pfCandidateRef() const
reference to the source PFCandidates; null if this has been built from a standard electron ...
Definition: Electron.cc:338
double ip3d_
Definition: Electron.h:307
Electron()
default constructor
Definition: Electron.cc:12
void initImpactParameters()
init impact parameter defaults (for use in a constructor)
Definition: Electron.cc:120
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
void embedGsfTrack()
method to store the electron&#39;s GsfTrack internally
Definition: Electron.cc:199
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
tuple out
Definition: dbtoconf.py:99
EcalRecHitCollection recHits_
Place to store electron&#39;s RecHits internally (5x5 around seed+ all RecHits)
Definition: Electron.h:276
reco::PFCandidateCollection pfCandidate_
A copy of the source IsolatedPFCandidate is stored in this vector if embeddedPFCandidate_ if True...
Definition: Electron.h:287
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:301
float electronID(const std::string &name) const
Returns a specific electron ID associated to the pat::Electron given its name.
Definition: Electron.cc:314
bool embeddedGsfTrack_
True if electron&#39;s gsfTrack is stored internally.
Definition: Electron.h:246
double r9() const
Definition: Electron.h:193
bool embeddedPflowSuperCluster_
True if electron&#39;s pflowsupercluster is stored internally.
Definition: Electron.h:252
double sigmaIphiIphi_
Definition: Electron.h:305
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
key_type key() const
Accessor for product key.
Definition: Ref.h:266
double sigmaIphiIphi() const
sigmaIPhiPhi
Definition: Electron.h:195
void embedPflowSuperCluster()
method to store the electron&#39;s PflowSuperCluster internally
Definition: Electron.cc:218
Analysis-level electron class.
Definition: Electron.h:50
std::vector< IdPair > electronIDs_
Electron IDs.
Definition: Electron.h:280
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:289
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.cc:8
bool embeddedSuperCluster_
True if electron&#39;s supercluster is stored internally.
Definition: Electron.h:250
bool isElectronIDAvailable(const std::string &name) const
Returns true if a specific ID is available in this pat::Electron.
Definition: Electron.cc:329
std::vector< reco::CaloCluster > pflowPreshowerClusters_
Place to store electron&#39;s pflow preshower clusters internally.
Definition: Electron.h:262
reco::SuperClusterRef parentSuperCluster() const
override the reco::GsfElectron::pflowSuperCluster method, to access the internal storage of the pflow...
Definition: Electron.cc:158
bool cachedDB_
True if impact parameter has been cached.
Definition: Electron.h:297
std::vector< double > ip_
Impact parameter at the primary vertex,.
Definition: Electron.h:333
double sigmaIetaIphi_
Definition: Electron.h:306
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
volatile std::atomic< bool > shutdown_flag false
std::vector< bool > cachedIP_
True if the IP (former dB) has been cached.
Definition: Electron.h:331
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242
bool embeddedPFCandidate_
true if the IsolatedPFCandidate is embedded
Definition: Electron.h:285
virtual float pt() const GCC11_FINAL
transverse momentum
reco::CandidatePtr sourceCandidatePtr(size_type i) const
get the source candidate pointer with index i
Definition: Electron.cc:357
double dB(IpType type=None) const
Impact parameter wrt primary vertex or beamspot.
Definition: Electron.cc:377
void embedPflowPreshowerClusters()
method to store the electron&#39;s pflow preshower clusters
Definition: Electron.cc:272
std::vector< double > eip_
Impact parameter uncertainty as recommended by the tracking group.
Definition: Electron.h:335
std::vector< reco::SuperCluster > pflowSuperCluster_
Place to store electron&#39;s pflow supercluster internally.
Definition: Electron.h:264
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:169
std::vector< reco::CaloCluster > seedCluster_
Place to store electron&#39;s seed cluster internally.
Definition: Electron.h:272