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.23 2010/10/14 13:55:24 beaudett 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  embeddedTrack_(false),
19  embeddedPFCandidate_(false),
20  ecalDrivenMomentum_(Candidate::LorentzVector(0.,0.,0.,0.)),
21  cachedDB_(false),
22  dB_(0.0),
23  edB_(0.0)
24 {
25 }
26 
27 
28 
31  Lepton<reco::GsfElectron>(anElectron),
32  embeddedGsfElectronCore_(false),
33  embeddedGsfTrack_(false),
34  embeddedSuperCluster_(false),
35  embeddedTrack_(false),
36  embeddedPFCandidate_(false),
37  ecalDrivenMomentum_(anElectron.p4()),
38  cachedDB_(false),
39  dB_(0.0),
40  edB_(0.0)
41 {
42 }
43 
44 
47  Lepton<reco::GsfElectron>(anElectronRef),
48  embeddedGsfElectronCore_(false),
49  embeddedGsfTrack_(false),
50  embeddedSuperCluster_(false),
51  embeddedTrack_(false),
52  embeddedPFCandidate_(false),
53  ecalDrivenMomentum_(anElectronRef->p4()),
54  cachedDB_(false),
55  dB_(0.0),
56  edB_(0.0)
57 {
58 }
59 
62  Lepton<reco::GsfElectron>(anElectronRef),
63  embeddedGsfElectronCore_(false),
64  embeddedGsfTrack_(false),
65  embeddedSuperCluster_(false),
66  embeddedTrack_(false),
67  embeddedPFCandidate_(false),
68  ecalDrivenMomentum_(anElectronRef->p4()),
69  cachedDB_(false),
70  dB_(0.0),
71  edB_(0.0)
72 {
73 }
74 
75 
78 }
79 
80 
83  if (embeddedGsfTrack_) {
84  return reco::GsfTrackRef(&gsfTrack_, 0);
85  } else {
87  }
88 }
89 
94  } else {
95  return reco::GsfElectron::core();
96  }
97 }
98 
99 
102  if (embeddedSuperCluster_) {
104  } else {
106  }
107 }
108 
109 
112  if (embeddedTrack_) {
113  return reco::TrackRef(&track_, 0);
114  } else {
115  return reco::GsfElectron::track();
116  }
117 }
118 
121  gsfElectronCore_.clear();
122  if (reco::GsfElectron::core().isNonnull()) {
125  }
126 }
127 
130  gsfTrack_.clear();
131  if (reco::GsfElectron::gsfTrack().isNonnull()) {
133  embeddedGsfTrack_ = true;
134  }
135 }
136 
137 
140  superCluster_.clear();
141  if (reco::GsfElectron::superCluster().isNonnull()) {
143  embeddedSuperCluster_ = true;
144  }
145 }
146 
147 
150  track_.clear();
151  if (reco::GsfElectron::track().isNonnull()) {
152  track_.push_back(*reco::GsfElectron::track());
153  embeddedTrack_ = true;
154  }
155 }
156 
157 // method to retrieve a lepton ID (or throw)
158 float Electron::electronID(const std::string & name) const {
159  for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
160  if (it->first == name) return it->second;
161  }
162  cms::Exception ex("Key not found");
163  ex << "pat::Electron: the ID " << name << " can't be found in this pat::Electron.\n";
164  ex << "The available IDs are: ";
165  for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
166  ex << "'" << it->first << "' ";
167  }
168  ex << ".\n";
169  throw ex;
170 }
171 // check if an ID is there
172 bool Electron::isElectronIDAvailable(const std::string & name) const {
173  for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
174  if (it->first == name) return true;
175  }
176  return false;
177 }
178 
179 
182  if (embeddedPFCandidate_) {
184  } else {
185  return pfCandidateRef_;
186  }
187 }
190  pfCandidate_.clear();
192  pfCandidate_.push_back( *pfCandidateRef_ );
193  embeddedPFCandidate_ = true;
194  }
195 }
196 
199  if (embeddedPFCandidate_) {
201  } else {
202  return reco::CandidatePtr();
203  }
204 }
205 
206 
207 
211 double Electron::dB() const {
212  if ( cachedDB_ ) {
213  return dB_;
214  } else {
216  }
217 }
218 
222 double Electron::edB() const {
223  if ( cachedDB_ ) {
224  return edB_;
225  } else {
227  }
228 }
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
double edB() const
Definition: Electron.cc:222
int i
Definition: DBlmapReader.cc:9
virtual ~Electron()
destructor
Definition: Electron.cc:77
bool embeddedTrack_
Definition: Electron.h:163
std::vector< reco::GsfTrack > gsfTrack_
Definition: Electron.h:160
edm::Ref< GsfElectronCoreCollection > GsfElectronCoreRef
void embedTrack()
method to store the electron&#39;s Track internally
Definition: Electron.cc:149
void embedGsfElectronCore()
method to store the electron&#39;s core internally
Definition: Electron.cc:120
size_t size_type
Definition: Candidate.h:32
void embedSuperCluster()
method to store the electron&#39;s SuperCluster internally
Definition: Electron.cc:139
void embedPFCandidate()
embed the PFCandidate pointed to by pfCandidateRef_
Definition: Electron.cc:189
reco::SuperClusterRef superCluster() const
override the reco::GsfElectron::superCluster method, to access the internal storage of the superclust...
Definition: Electron.cc:101
reco::TrackRef track() const
override the reco::GsfElectron::track method, to access the internal storage of the track ...
Definition: Electron.cc:111
std::vector< reco::SuperCluster > superCluster_
Definition: Electron.h:162
reco::GsfTrackRef gsfTrack() const
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
Definition: Electron.cc:82
double dB_
Definition: Electron.h:185
SuperClusterRef superCluster() const
reference to a SuperCluster
Definition: GsfElectron.h:166
std::vector< reco::Track > track_
Definition: Electron.h:164
bool isAvailable() const
Definition: Ref.h:278
bool embeddedGsfElectronCore_
Definition: Electron.h:157
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
virtual reco::TrackRef track() const
reference to a Track
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:248
const T & max(const T &a, const T &b)
double p4[4]
Definition: TauolaWrapper.h:92
Analysis-level lepton class.
Definition: Lepton.h:32
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:91
std::vector< reco::GsfElectronCore > gsfElectronCore_
Definition: Electron.h:158
reco::PFCandidateRef pfCandidateRef() const
reference to the source PFCandidates
Definition: Electron.cc:181
Electron()
default constructor
Definition: Electron.cc:13
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
void embedGsfTrack()
method to store the electron&#39;s GsfTrack internally
Definition: Electron.cc:129
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.h:163
GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:167
reco::PFCandidateCollection pfCandidate_
Definition: Electron.h:174
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
double edB_
Definition: Electron.h:186
float electronID(const std::string &name) const
Definition: Electron.cc:158
bool embeddedGsfTrack_
Definition: Electron.h:159
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
double dB() const
Definition: Electron.cc:211
key_type key() const
Accessor for product key.
Definition: Ref.h:264
std::vector< IdPair > electronIDs_
Definition: Electron.h:167
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:39
reco::PFCandidateRef pfCandidateRef_
Definition: Electron.h:177
bool embeddedSuperCluster_
Definition: Electron.h:161
bool isElectronIDAvailable(const std::string &name) const
Returns true if a specific ID is available in this pat::Electron.
Definition: Electron.cc:172
bool cachedDB_
Definition: Electron.h:184
ProductID id() const
Accessor for product ID.
Definition: Ref.h:254
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:239
bool embeddedPFCandidate_
true if the IsolatedPFCandidate is embedded
Definition: Electron.h:171
reco::CandidatePtr sourceCandidatePtr(size_type i) const
get the candidate pointer with index i
Definition: Electron.cc:198