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 // $Id: Electron.cc,v 1.34 2013/04/01 17:52:02 tjkim Exp $
3 //
4 
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 {
39 }
40 
43  Lepton<reco::GsfElectron>(anElectron),
44  embeddedGsfElectronCore_(false),
45  embeddedGsfTrack_(false),
46  embeddedSuperCluster_(false),
47  embeddedPflowSuperCluster_(false),
48  embeddedTrack_(false),
49  embeddedSeedCluster_(false),
50  embeddedRecHits_(false),
51  embeddedPFCandidate_(false),
52  ecalDrivenMomentum_(anElectron.p4()),
53  cachedDB_(false),
54  dB_(0.0),
55  edB_(0.0)
56 {
58 }
59 
62  Lepton<reco::GsfElectron>(anElectronRef),
63  embeddedGsfElectronCore_(false),
64  embeddedGsfTrack_(false),
65  embeddedSuperCluster_(false),
66  embeddedPflowSuperCluster_(false),
67  embeddedTrack_(false),
68  embeddedSeedCluster_(false),
69  embeddedRecHits_(false),
70  embeddedPFCandidate_(false),
71  ecalDrivenMomentum_(anElectronRef->p4()),
72  cachedDB_(false),
73  dB_(0.0),
74  edB_(0.0)
75 {
77 }
78 
81  Lepton<reco::GsfElectron>(anElectronRef),
82  embeddedGsfElectronCore_(false),
83  embeddedGsfTrack_(false),
84  embeddedSuperCluster_(false),
85  embeddedPflowSuperCluster_(false),
86  embeddedTrack_(false),
87  embeddedSeedCluster_(false),
88  embeddedRecHits_(false),
89  embeddedPFCandidate_(false),
90  ecalDrivenMomentum_(anElectronRef->p4()),
91  cachedDB_(false),
92  dB_(0.0),
93  edB_(0.0)
94 {
96 }
97 
100 }
101 
103 std::ostream&
104 reco::operator<<(std::ostream& out, const pat::Electron& obj)
105 {
106  if(!out) return out;
107 
108  out << "\tpat::Electron: ";
109  out << std::setiosflags(std::ios::right);
110  out << std::setiosflags(std::ios::fixed);
111  out << std::setprecision(3);
112  out << " E/pT/eta/phi "
113  << obj.energy()<<"/"
114  << obj.pt()<<"/"
115  << obj.eta()<<"/"
116  << obj.phi();
117  return out;
118 }
119 
122  for (int i_ = 0; i_<5; ++i_){
123  ip_.push_back(0.0);
124  eip_.push_back(0.0);
125  cachedIP_.push_back(false);
126  }
127 }
128 
129 
132  if (embeddedGsfTrack_) {
133  return reco::GsfTrackRef(&gsfTrack_, 0);
134  } else {
136  }
137 }
138 
143  } else {
144  return reco::GsfElectron::core();
145  }
146 }
147 
148 
151  if (embeddedSuperCluster_) {
153  } else {
155  }
156 }
157 
162  } else {
164  }
165 }
166 
171  } else {
172  return reco::GsfElectron::superCluster()->seed();
173  }
174 }
175 
178  if (embeddedTrack_) {
179  return reco::TrackRef(&track_, 0);
180  } else {
182  }
183 }
184 
185 // the name of the method is misleading, users should use gsfTrack of closestCtfTrack
187  return reco::TrackRef();
188 }
189 
192  gsfElectronCore_.clear();
193  if (reco::GsfElectron::core().isNonnull()) {
196  }
197 }
198 
201  gsfTrack_.clear();
202  if (reco::GsfElectron::gsfTrack().isNonnull()) {
204  embeddedGsfTrack_ = true;
205  }
206 }
207 
208 
211  superCluster_.clear();
212  if (reco::GsfElectron::superCluster().isNonnull()) {
214  embeddedSuperCluster_ = true;
215  }
216 }
217 
220  pflowSuperCluster_.clear();
221  if (reco::GsfElectron::pflowSuperCluster().isNonnull()) {
224  }
225 }
226 
229  seedCluster_.clear();
230  if (reco::GsfElectron::superCluster().isNonnull() && reco::GsfElectron::superCluster()->seed().isNonnull()) {
232  embeddedSeedCluster_ = true;
233  }
234 }
235 
238  basicClusters_.clear();
239  if (reco::GsfElectron::superCluster().isNonnull()){
242  for(;itscl!=itsclE;++itscl){
243  basicClusters_.push_back( **itscl ) ;
244  }
245  }
246 }
247 
250  preshowerClusters_.clear();
251  if (reco::GsfElectron::superCluster().isNonnull()){
252  reco::CaloCluster_iterator itscl = reco::GsfElectron::superCluster()->preshowerClustersBegin();
253  reco::CaloCluster_iterator itsclE = reco::GsfElectron::superCluster()->preshowerClustersEnd();
254  for(;itscl!=itsclE;++itscl){
255  preshowerClusters_.push_back( **itscl ) ;
256  }
257  }
258 }
259 
262  pflowBasicClusters_.clear();
263  if (reco::GsfElectron::pflowSuperCluster().isNonnull()){
266  for(;itscl!=itsclE;++itscl){
267  pflowBasicClusters_.push_back( **itscl ) ;
268  }
269  }
270 }
271 
274  pflowPreshowerClusters_.clear();
275  if (reco::GsfElectron::pflowSuperCluster().isNonnull()){
276  reco::CaloCluster_iterator itscl = reco::GsfElectron::pflowSuperCluster()->preshowerClustersBegin();
277  reco::CaloCluster_iterator itsclE = reco::GsfElectron::pflowSuperCluster()->preshowerClustersEnd();
278  for(;itscl!=itsclE;++itscl){
279  pflowPreshowerClusters_.push_back( **itscl ) ;
280  }
281  }
282 }
283 
286  track_.clear();
287  if (reco::GsfElectron::closestCtfTrackRef().isNonnull()) {
289  embeddedTrack_ = true;
290  }
291 }
292 
293 // method to store the RecHits internally
295  if (rechits!=0) {
296  recHits_ = *rechits;
297  embeddedRecHits_ = true;
298  }
299 }
300 
315 float Electron::electronID(const std::string& name) const {
316  for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
317  if (it->first == name) return it->second;
318  }
319  cms::Exception ex("Key not found");
320  ex << "pat::Electron: the ID " << name << " can't be found in this pat::Electron.\n";
321  ex << "The available IDs are: ";
322  for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
323  ex << "'" << it->first << "' ";
324  }
325  ex << ".\n";
326  throw ex;
327 }
328 
330 bool Electron::isElectronIDAvailable(const std::string& name) const {
331  for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
332  if (it->first == name) return true;
333  }
334  return false;
335 }
336 
337 
340  if (embeddedPFCandidate_) {
342  } else {
343  return pfCandidateRef_;
344  }
345 }
346 
349  pfCandidate_.clear();
351  pfCandidate_.push_back( *pfCandidateRef_ );
352  embeddedPFCandidate_ = true;
353  }
354 }
355 
359  if (embeddedPFCandidate_) {
361  } else {
362  return reco::CandidatePtr();
363  }
364 }
365 
366 
367 
378 double Electron::dB(IpType type_) const {
379  // preserve old functionality exactly
380  if (type_ == None){
381  if ( cachedDB_ ) {
382  return dB_;
383  } else {
385  }
386  }
387  // more IP types (new)
388  else if ( cachedIP_[type_] ) {
389  return ip_[type_];
390  } else {
392  }
393 }
394 
405 double Electron::edB(IpType type_) const {
406  // preserve old functionality exactly
407  if (type_ == None) {
408  if ( cachedDB_ ) {
409  return edB_;
410  } else {
412  }
413  }
414  // more IP types (new)
415  else if ( cachedIP_[type_] ) {
416  return eip_[type_];
417  } else {
419  }
420 
421 }
422 
424 void Electron::setDB(double dB, double edB, IpType type){
425  if (type == None) { // Preserve old functionality exactly
426  dB_ = dB; edB_ = edB;
427  cachedDB_ = true;
428  } else {
429  ip_[type] = dB;
430  eip_[type] = edB;
431  cachedIP_[type] = true;
432  }
433 }
434 
436 void Electron::setMvaVariables( double r9, double sigmaIphiIphi, double sigmaIetaIphi, double ip3d){
437  r9_ = r9;
440  ip3d_ = ip3d;
441 }
double edB(IpType type=None) const
Uncertainty on the corresponding impact parameter.
Definition: Electron.cc:405
reco::SuperClusterRef pflowSuperCluster() const
override the reco::GsfElectron::pflowSuperCluster method, to access the internal storage of the pflow...
Definition: Electron.cc:159
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
type
Definition: HCALResponse.h:22
int i
Definition: DBlmapReader.cc:9
virtual ~Electron()
destructor
Definition: Electron.cc:99
bool embeddedTrack_
True if electron&#39;s track is stored internally.
Definition: Electron.h:268
std::vector< reco::GsfTrack > gsfTrack_
Place to store electron&#39;s gsfTrack internally.
Definition: Electron.h:250
edm::Ref< GsfElectronCoreCollection > GsfElectronCoreRef
void embedTrack()
method to store the electron&#39;s Track internally
Definition: Electron.cc:285
void embedSeedCluster()
method to store the electron&#39;s seedcluster internally
Definition: Electron.cc:228
void embedGsfElectronCore()
method to store the electron&#39;s core internally
Definition: Electron.cc:191
void embedPflowBasicClusters()
method to store the electron&#39;s pflow basic clusters
Definition: Electron.cc:261
reco::TrackRef closestCtfTrackRef() const
override the reco::GsfElectron::closestCtfTrackRef method, to access the internal storage of the trac...
Definition: Electron.cc:177
size_t size_type
Definition: Candidate.h:31
void embedSuperCluster()
method to store the electron&#39;s SuperCluster internally
Definition: Electron.cc:210
double ip3d() const
ip3d
Definition: Electron.h:201
void embedPFCandidate()
embed the PFCandidate pointed to by pfCandidateRef_
Definition: Electron.cc:348
void setDB(double dB, double edB, IpType type=None)
Set impact parameter of a certain type and its uncertainty.
Definition: Electron.cc:424
reco::SuperClusterRef superCluster() const
override the reco::GsfElectron::superCluster method, to access the internal storage of the superclust...
Definition: Electron.cc:150
reco::TrackRef track() const
returns nothing. Use either gsfTrack or closestCtfTrack
Definition: Electron.cc:186
std::vector< reco::SuperCluster > superCluster_
Place to store electron&#39;s supercluster internally.
Definition: Electron.h:256
reco::GsfTrackRef gsfTrack() const
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
Definition: Electron.cc:131
double dB_
Impact parameter at the primary vertex.
Definition: Electron.h:301
edm::Ptr< CaloCluster > CaloClusterPtr
std::vector< reco::Track > track_
Place to store electron&#39;s track internally.
Definition: Electron.h:270
bool isAvailable() const
Definition: Ref.h:276
double sigmaIetaIphi() const
sigmaIEtaIPhi
Definition: Electron.h:199
bool embeddedGsfElectronCore_
True if electron&#39;s gsfElectronCore is stored internally.
Definition: Electron.h:244
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:436
virtual double eta() const
momentum pseudorapidity
void embedPreshowerClusters()
method to store the electron&#39;s preshower clusters
Definition: Electron.cc:249
std::vector< reco::CaloCluster > pflowBasicClusters_
Place to store electron&#39;s pflow basic clusters internally.
Definition: Electron.h:262
TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:185
reco::CaloClusterPtr seed() const
direct access to the seed cluster
Definition: Electron.cc:168
void embedBasicClusters()
method to store the electron&#39;s basic clusters
Definition: Electron.cc:237
std::vector< reco::CaloCluster > basicClusters_
Place to store electron&#39;s basic clusters internally.
Definition: Electron.h:258
double r9_
additional missing mva variables : 14/04/2012
Definition: Electron.h:306
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
virtual double energy() const
energy
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:72
std::vector< reco::CaloCluster > preshowerClusters_
Place to store electron&#39;s preshower clusters internally.
Definition: Electron.h:260
const T & max(const T &a, const T &b)
bool embeddedRecHits_
True if RecHits stored internally.
Definition: Electron.h:276
void embedRecHits(const EcalRecHitCollection *rechits)
method to store the RecHits internally - can be called from the PATElectronProducer ...
Definition: Electron.cc:294
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:32
bool embeddedSeedCluster_
True if seed cluster is stored internally.
Definition: Electron.h:272
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:140
std::vector< reco::GsfElectronCore > gsfElectronCore_
Place to store electron&#39;s gsfElectronCore internally.
Definition: Electron.h:246
reco::PFCandidateRef pfCandidateRef() const
reference to the source PFCandidates; null if this has been built from a standard electron ...
Definition: Electron.cc:339
double ip3d_
Definition: Electron.h:309
Electron()
default constructor
Definition: Electron.cc:13
void initImpactParameters()
init impact parameter defaults (for use in a constructor)
Definition: Electron.cc:121
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
void embedGsfTrack()
method to store the electron&#39;s GsfTrack internally
Definition: Electron.cc:200
tuple out
Definition: dbtoconf.py:99
EcalRecHitCollection recHits_
Place to store electron&#39;s RecHits internally (5x5 around seed+ all RecHits)
Definition: Electron.h:278
reco::PFCandidateCollection pfCandidate_
A copy of the source IsolatedPFCandidate is stored in this vector if embeddedPFCandidate_ if True...
Definition: Electron.h:289
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:303
float electronID(const std::string &name) const
Returns a specific electron ID associated to the pat::Electron given its name.
Definition: Electron.cc:315
bool embeddedGsfTrack_
True if electron&#39;s gsfTrack is stored internally.
Definition: Electron.h:248
double r9() const
Definition: Electron.h:195
virtual double pt() const
transverse momentum
bool embeddedPflowSuperCluster_
True if electron&#39;s pflowsupercluster is stored internally.
Definition: Electron.h:254
double sigmaIphiIphi_
Definition: Electron.h:307
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:197
void embedPflowSuperCluster()
method to store the electron&#39;s PflowSuperCluster internally
Definition: Electron.cc:219
Analysis-level electron class.
Definition: Electron.h:52
std::vector< IdPair > electronIDs_
Electron IDs.
Definition: Electron.h:282
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:38
reco::PFCandidateRef pfCandidateRef_
reference to the IsolatedPFCandidate this has been built from; null if this has been built from a sta...
Definition: Electron.h:291
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.cc:8
bool embeddedSuperCluster_
True if electron&#39;s supercluster is stored internally.
Definition: Electron.h:252
bool isElectronIDAvailable(const std::string &name) const
Returns true if a specific ID is available in this pat::Electron.
Definition: Electron.cc:330
std::vector< reco::CaloCluster > pflowPreshowerClusters_
Place to store electron&#39;s pflow preshower clusters internally.
Definition: Electron.h:264
bool cachedDB_
True if impact parameter has been cached.
Definition: Electron.h:299
std::vector< double > ip_
Impact parameter at the primary vertex,.
Definition: Electron.h:335
double sigmaIetaIphi_
Definition: Electron.h:308
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
std::vector< bool > cachedIP_
True if the IP (former dB) has been cached.
Definition: Electron.h:333
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:287
virtual double phi() const
momentum azimuthal angle
reco::CandidatePtr sourceCandidatePtr(size_type i) const
get the source candidate pointer with index i
Definition: Electron.cc:358
SuperClusterRef pflowSuperCluster() const
Definition: GsfElectron.h:174
double dB(IpType type=None) const
Impact parameter wrt primary vertex or beamspot.
Definition: Electron.cc:378
void embedPflowPreshowerClusters()
method to store the electron&#39;s pflow preshower clusters
Definition: Electron.cc:273
std::vector< double > eip_
Impact parameter uncertainty as recommended by the tracking group.
Definition: Electron.h:337
std::vector< reco::SuperCluster > pflowSuperCluster_
Place to store electron&#39;s pflow supercluster internally.
Definition: Electron.h:266
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:274