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  ecalRegressionEnergy_(0.0),
25  ecalTrackRegressionEnergy_(0.0),
26  ecalRegressionError_(0.0),
27  ecalTrackRegressionError_(0.0),
28  ecalScale_(-99999.),
29  ecalSmear_(-99999.),
30  ecalRegressionScale_(-99999.),
31  ecalRegressionSmear_(-99999.),
32  ecalTrackRegressionScale_(-99999.),
33  ecalTrackRegressionSmear_(-99999.),
34  packedPFCandidates_(),
35  associatedPackedFCandidateIndices_()
36 {
37  initImpactParameters();
38 }
39 
41 Electron::Electron(const reco::GsfElectron & anElectron) :
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 {
53  initImpactParameters();
54 }
55 
58  Lepton<reco::GsfElectron>(anElectronRef),
59  embeddedGsfElectronCore_(false),
60  embeddedGsfTrack_(false),
61  embeddedSuperCluster_(false),
62  embeddedPflowSuperCluster_(false),
63  embeddedTrack_(false),
64  embeddedSeedCluster_(false),
65  embeddedRecHits_(false),
66  embeddedPFCandidate_(false),
67  ecalDrivenMomentum_(anElectronRef->p4())
68 {
69  initImpactParameters();
70 }
71 
73 Electron::Electron(const edm::Ptr<reco::GsfElectron> & anElectronRef) :
74  Lepton<reco::GsfElectron>(anElectronRef),
75  embeddedGsfElectronCore_(false),
76  embeddedGsfTrack_(false),
77  embeddedSuperCluster_(false),
78  embeddedPflowSuperCluster_(false),
79  embeddedTrack_(false),
80  embeddedSeedCluster_(false),
81  embeddedRecHits_(false),
82  embeddedPFCandidate_(false),
83  ecalDrivenMomentum_(anElectronRef->p4())
84 {
85  initImpactParameters();
86 }
87 
90 }
91 
93 std::ostream&
94 reco::operator<<(std::ostream& out, const pat::Electron& obj)
95 {
96  if(!out) return out;
97 
98  out << "\tpat::Electron: ";
99  out << std::setiosflags(std::ios::right);
100  out << std::setiosflags(std::ios::fixed);
101  out << std::setprecision(3);
102  out << " E/pT/eta/phi "
103  << obj.energy()<<"/"
104  << obj.pt()<<"/"
105  << obj.eta()<<"/"
106  << obj.phi();
107  return out;
108 }
109 
112  std::fill(ip_, ip_+IpTypeSize, 0.0f);
114  cachedIP_ = 0;
115 }
116 
117 
120  if (embeddedGsfTrack_) {
121  return reco::GsfTrackRef(&gsfTrack_, 0);
122  } else {
124  }
125 }
126 
131  } else {
132  return reco::GsfElectron::core();
133  }
134 }
135 
136 
139  if (embeddedSuperCluster_) {
140  if (embeddedSeedCluster_ || !basicClusters_.empty() || !preshowerClusters_.empty()) {
141  if (!superClusterRelinked_.isSet()) {
142  std::unique_ptr<std::vector<reco::SuperCluster> > sc(new std::vector<reco::SuperCluster>(superCluster_));
143  if (embeddedSeedCluster_ && !(*sc)[0].seed().isAvailable()) {
144  (*sc)[0].setSeed(seed());
145  }
146  if (basicClusters_.size() && !(*sc)[0].clusters().isAvailable()) {
148  for (unsigned int iclus=0; iclus<basicClusters_.size(); ++iclus) {
150  }
151  (*sc)[0].setClusters(clusters);
152  }
153  if (preshowerClusters_.size() && !(*sc)[0].preshowerClusters().isAvailable()) {
155  for (unsigned int iclus=0; iclus<preshowerClusters_.size(); ++iclus) {
157  }
158  (*sc)[0].setPreshowerClusters(clusters);
159  }
161  }
163  } else {
165  }
166  //relink caloclusters if needed
168  } else {
170  }
171 }
172 
177  } else {
179  }
180 }
181 
186  } else {
187  return reco::GsfElectron::superCluster()->seed();
188  }
189 }
190 
193  if (embeddedTrack_) {
194  return reco::TrackRef(&track_, 0);
195  } else {
197  }
198 }
199 
200 // the name of the method is misleading, users should use gsfTrack of closestCtfTrack
202  return reco::TrackRef();
203 }
204 
207  gsfElectronCore_.clear();
208  if (reco::GsfElectron::core().isNonnull()) {
211  }
212 }
213 
216  gsfTrack_.clear();
217  if (reco::GsfElectron::gsfTrack().isNonnull()) {
219  embeddedGsfTrack_ = true;
220  }
221 }
222 
223 
226  superCluster_.clear();
227  if (reco::GsfElectron::superCluster().isNonnull()) {
229  embeddedSuperCluster_ = true;
230  }
231 }
232 
235  pflowSuperCluster_.clear();
236  if (reco::GsfElectron::parentSuperCluster().isNonnull()) {
239  }
240 }
241 
244  seedCluster_.clear();
245  if (reco::GsfElectron::superCluster().isNonnull() && reco::GsfElectron::superCluster()->seed().isNonnull()) {
247  embeddedSeedCluster_ = true;
248  }
249 }
250 
253  basicClusters_.clear();
254  if (reco::GsfElectron::superCluster().isNonnull()){
257  for(;itscl!=itsclE;++itscl){
258  basicClusters_.push_back( **itscl ) ;
259  }
260  }
261 }
262 
265  preshowerClusters_.clear();
266  if (reco::GsfElectron::superCluster().isNonnull()){
267  reco::CaloCluster_iterator itscl = reco::GsfElectron::superCluster()->preshowerClustersBegin();
268  reco::CaloCluster_iterator itsclE = reco::GsfElectron::superCluster()->preshowerClustersEnd();
269  for(;itscl!=itsclE;++itscl){
270  preshowerClusters_.push_back( **itscl ) ;
271  }
272  }
273 }
274 
277  pflowBasicClusters_.clear();
278  if (reco::GsfElectron::parentSuperCluster().isNonnull()){
281  for(;itscl!=itsclE;++itscl){
282  pflowBasicClusters_.push_back( **itscl ) ;
283  }
284  }
285 }
286 
289  pflowPreshowerClusters_.clear();
290  if (reco::GsfElectron::parentSuperCluster().isNonnull()){
291  reco::CaloCluster_iterator itscl = reco::GsfElectron::parentSuperCluster()->preshowerClustersBegin();
292  reco::CaloCluster_iterator itsclE = reco::GsfElectron::parentSuperCluster()->preshowerClustersEnd();
293  for(;itscl!=itsclE;++itscl){
294  pflowPreshowerClusters_.push_back( **itscl ) ;
295  }
296  }
297 }
298 
300 void Electron::embedTrack() {
301  track_.clear();
302  if (reco::GsfElectron::closestCtfTrackRef().isNonnull()) {
304  embeddedTrack_ = true;
305  }
306 }
307 
308 // method to store the RecHits internally
310  if (rechits!=0) {
311  recHits_ = *rechits;
312  embeddedRecHits_ = true;
313  }
314 }
315 
330 float Electron::electronID(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 it->second;
333  }
334  cms::Exception ex("Key not found");
335  ex << "pat::Electron: the ID " << name << " can't be found in this pat::Electron.\n";
336  ex << "The available IDs are: ";
337  for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
338  ex << "'" << it->first << "' ";
339  }
340  ex << ".\n";
341  throw ex;
342 }
343 
345 bool Electron::isElectronIDAvailable(const std::string& name) const {
346  for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
347  if (it->first == name) return true;
348  }
349  return false;
350 }
351 
352 
355  if (embeddedPFCandidate_) {
357  } else {
358  return pfCandidateRef_;
359  }
360 }
361 
364  pfCandidate_.clear();
366  pfCandidate_.push_back( *pfCandidateRef_ );
367  embeddedPFCandidate_ = true;
368  }
369 }
370 
374  if (pfCandidateRef_.isNonnull()) {
375  if (i == 0) {
377  } else {
378  i--;
379  }
380  }
381  if (i >= associatedPackedFCandidateIndices_.size()) {
382  return reco::CandidatePtr();
383  } else {
385  }
386 }
387 
388 
389 
400 double Electron::dB(IpType type_) const {
401  // more IP types (new)
402  if ( cachedIP_ & (1 << int(type_))) {
403  return ip_[type_];
404  } else {
406  }
407 }
408 
419 double Electron::edB(IpType type_) const {
420  // more IP types (new)
421  if ( cachedIP_ & (1 << int(type_))) {
422  return eip_[type_];
423  } else {
425  }
426 }
427 
429 void Electron::setDB(double dB, double edB, IpType type){
430  ip_[type] = dB; eip_[type] = edB; cachedIP_ |= (1 << int(type));
431 }
432 
434 void Electron::setMvaVariables( double sigmaIetaIphi, double ip3d){
436  ip3d_ = ip3d;
437 }
438 
441  for (uint16_t idx : associatedPackedFCandidateIndices_) {
443  }
444  return ret;
445 }
446 
447 
void setMvaVariables(double sigmaIetaIphi, double ip3d)
set missing mva input variables
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
bool isAvailable() const
Definition: Ref.h:614
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
uint8_t cachedIP_
True if the IP (former dB) has been cached.
Definition: Electron.h:352
void embedRecHits(const EcalRecHitCollection *rechits)
method to store the RecHits internally - can be called from the PATElectronProducer ...
bool embeddedTrack_
True if electron&#39;s track is stored internally.
Definition: Electron.h:294
std::vector< reco::GsfTrack > gsfTrack_
Place to store electron&#39;s gsfTrack internally.
Definition: Electron.h:274
bool isElectronIDAvailable(const std::string &name) const
Returns true if a specific ID is available in this pat::Electron.
edm::Ref< GsfElectronCoreCollection > GsfElectronCoreRef
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
string fill
Definition: lumiContext.py:319
SuperClusterRef parentSuperCluster() const
Definition: GsfElectron.h:188
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
double dB() const
the version without arguments returns PD2D, but with an absolute value (for backwards compatibility) ...
Definition: Electron.h:189
double ip3d() const
ip3d
Definition: Electron.h:208
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:139
void embedSuperCluster()
method to store the electron&#39;s SuperCluster internally
void setDB(double dB, double edB, IpType type)
Set impact parameter of a certain type and its uncertainty.
void embedGsfElectronCore()
method to store the electron&#39;s core internally
std::vector< reco::SuperCluster > superCluster_
Place to store electron&#39;s supercluster internally.
Definition: Electron.h:280
edm::Ptr< CaloCluster > CaloClusterPtr
std::vector< reco::Track > track_
Place to store electron&#39;s track internally.
Definition: Electron.h:296
bool embeddedGsfElectronCore_
True if electron&#39;s gsfElectronCore is stored internally.
Definition: Electron.h:268
uint16_t size_type
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
bool isSet() const
std::vector< reco::CaloCluster > pflowBasicClusters_
Place to store electron&#39;s pflow basic clusters internally.
Definition: Electron.h:288
TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:199
void embedPflowSuperCluster()
method to store the electron&#39;s PflowSuperCluster internally
edm::RefProd< pat::PackedCandidateCollection > packedPFCandidates_
Definition: Electron.h:359
std::vector< reco::CaloCluster > basicClusters_
Place to store electron&#39;s basic clusters internally.
Definition: Electron.h:284
virtual double energy() const
energy
std::vector< uint16_t > associatedPackedFCandidateIndices_
Definition: Electron.h:360
reco::SuperClusterRef superCluster() const
override the reco::GsfElectron::superCluster method, to access the internal storage of the superclust...
void embedSeedCluster()
method to store the electron&#39;s seedcluster internally
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:286
reco::GsfTrackRef gsfTrack() const
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
reco::PFCandidateRef pfCandidateRef() const
reference to the source PFCandidates; null if this has been built from a standard electron ...
reco::TrackRef closestCtfTrackRef() const
override the reco::GsfElectron::closestCtfTrackRef method, to access the internal storage of the trac...
bool embeddedRecHits_
True if RecHits stored internally.
Definition: Electron.h:302
double p4[4]
Definition: TauolaWrapper.h:92
double edB() const
the version without arguments returns PD2D, but with an absolute value (for backwards compatibility) ...
Definition: Electron.h:191
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
Definition: GsfElectron.h:182
Analysis-level lepton class.
Definition: Lepton.h:30
def move
Definition: eostools.py:508
float electronID(const std::string &name) const
Returns a specific electron ID associated to the pat::Electron given its name.
bool embeddedSeedCluster_
True if seed cluster is stored internally.
Definition: Electron.h:298
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:282
double f[11][100]
std::vector< reco::GsfElectronCore > gsfElectronCore_
Place to store electron&#39;s gsfElectronCore internally.
Definition: Electron.h:270
float eip_[IpTypeSize]
Impact parameter uncertainty as recommended by the tracking group.
Definition: Electron.h:356
double ip3d_
Definition: Electron.h:325
reco::SuperClusterRef parentSuperCluster() const
override the reco::GsfElectron::pflowSuperCluster method, to access the internal storage of the pflow...
virtual reco::GsfElectronCoreRef core() const
override the virtual reco::GsfElectron::core method, so that the embedded core can be used by GsfElec...
void embedPflowBasicClusters()
method to store the electron&#39;s pflow basic clusters
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
void embedBasicClusters()
method to store the electron&#39;s basic clusters
void embedGsfTrack()
method to store the electron&#39;s GsfTrack internally
tuple out
Definition: dbtoconf.py:99
EcalRecHitCollection recHits_
Place to store electron&#39;s RecHits internally (5x5 around seed+ all RecHits)
Definition: Electron.h:304
reco::PFCandidateCollection pfCandidate_
A copy of the source IsolatedPFCandidate is stored in this vector if embeddedPFCandidate_ if True...
Definition: Electron.h:315
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
reco::TrackRef track() const
returns nothing. Use either gsfTrack or closestCtfTrack
bool embeddedGsfTrack_
True if electron&#39;s gsfTrack is stored internally.
Definition: Electron.h:272
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:278
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:19
Analysis-level electron class.
Definition: Electron.h:52
std::vector< IdPair > electronIDs_
Electron IDs.
Definition: Electron.h:308
reco::PFCandidateRef pfCandidateRef_
reference to the IsolatedPFCandidate this has been built from; null if this has been built from a sta...
Definition: Electron.h:317
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.cc:8
float ip_[IpTypeSize]
Impact parameter at the primary vertex,.
Definition: Electron.h:354
bool embeddedSuperCluster_
True if electron&#39;s supercluster is stored internally.
Definition: Electron.h:276
void embedPreshowerClusters()
method to store the electron&#39;s preshower clusters
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > LorentzVector
Definition: analysisEnums.h:9
reco::CandidatePtr sourceCandidatePtr(size_type i) const
get the source candidate pointer with index i
std::vector< reco::CaloCluster > pflowPreshowerClusters_
Place to store electron&#39;s pflow preshower clusters internally.
Definition: Electron.h:290
ProductID id() const
Accessor for product ID.
Definition: RefProd.h:140
float sigmaIetaIphi() const
Definition: Electron.h:204
reco::CaloClusterPtr seed() const
direct access to the seed cluster
volatile std::atomic< bool > shutdown_flag false
void initImpactParameters()
init impact parameter defaults (for use in a constructor)
void embedPflowPreshowerClusters()
method to store the electron&#39;s pflow preshower clusters
Electron()
default constructor
bool embeddedPFCandidate_
true if the IsolatedPFCandidate is embedded
Definition: Electron.h:313
virtual ~Electron()
destructor
void embedTrack()
method to store the electron&#39;s Track internally
virtual double phi() const
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...
void embedPFCandidate()
embed the PFCandidate pointed to by pfCandidateRef_
std::vector< reco::SuperCluster > pflowSuperCluster_
Place to store electron&#39;s pflow supercluster internally.
Definition: Electron.h:292
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:183
float sigmaIetaIphi_
additional missing mva variables : 14/04/2012
Definition: Electron.h:324
std::vector< reco::CaloCluster > seedCluster_
Place to store electron&#39;s seed cluster internally.
Definition: Electron.h:300