CMS 3D CMS Logo

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  initImpactParameters();
37 }
38 
40 Electron::Electron(const reco::GsfElectron& anElectron)
41  : Lepton<reco::GsfElectron>(anElectron),
42  embeddedGsfElectronCore_(false),
43  embeddedGsfTrack_(false),
44  embeddedSuperCluster_(false),
45  embeddedPflowSuperCluster_(false),
46  embeddedTrack_(false),
47  embeddedSeedCluster_(false),
48  embeddedRecHits_(false),
49  embeddedPFCandidate_(false),
50  ecalDrivenMomentum_(anElectron.p4()) {
51  initImpactParameters();
52 }
53 
56  : Lepton<reco::GsfElectron>(anElectronRef),
57  embeddedGsfElectronCore_(false),
58  embeddedGsfTrack_(false),
59  embeddedSuperCluster_(false),
60  embeddedPflowSuperCluster_(false),
61  embeddedTrack_(false),
62  embeddedSeedCluster_(false),
63  embeddedRecHits_(false),
64  embeddedPFCandidate_(false),
65  ecalDrivenMomentum_(anElectronRef->p4()) {
66  initImpactParameters();
67 }
68 
71  : Lepton<reco::GsfElectron>(anElectronRef),
72  embeddedGsfElectronCore_(false),
73  embeddedGsfTrack_(false),
74  embeddedSuperCluster_(false),
75  embeddedPflowSuperCluster_(false),
76  embeddedTrack_(false),
77  embeddedSeedCluster_(false),
78  embeddedRecHits_(false),
79  embeddedPFCandidate_(false),
80  ecalDrivenMomentum_(anElectronRef->p4()) {
81  initImpactParameters();
82 }
83 
86 
88 std::ostream& reco::operator<<(std::ostream& out, const pat::Electron& obj) {
89  if (!out)
90  return out;
91 
92  out << "\tpat::Electron: ";
93  out << std::setiosflags(std::ios::right);
94  out << std::setiosflags(std::ios::fixed);
95  out << std::setprecision(3);
96  out << " E/pT/eta/phi " << obj.energy() << "/" << obj.pt() << "/" << obj.eta() << "/" << obj.phi();
97  return out;
98 }
99 
102  std::fill(ip_, ip_ + IpTypeSize, 0.0f);
103  std::fill(eip_, eip_ + IpTypeSize, 0.0f);
104  cachedIP_ = 0;
105 }
106 
109  if (embeddedGsfTrack_) {
110  return reco::GsfTrackRef(&gsfTrack_, 0);
111  } else {
113  }
114 }
115 
120  } else {
121  return reco::GsfElectron::core();
122  }
123 }
124 
127  if (embeddedSuperCluster_) {
128  if (embeddedSeedCluster_ || !basicClusters_.empty() || !preshowerClusters_.empty()) {
129  if (!superClusterRelinked_.isSet()) {
130  std::unique_ptr<std::vector<reco::SuperCluster> > sc(new std::vector<reco::SuperCluster>(superCluster_));
131  if (embeddedSeedCluster_ && !(*sc)[0].seed().isAvailable()) {
132  (*sc)[0].setSeed(seed());
133  }
134  if (!basicClusters_.empty() && !(*sc)[0].clusters().isAvailable()) {
136  for (unsigned int iclus = 0; iclus < basicClusters_.size(); ++iclus) {
137  clusters.push_back(reco::CaloClusterPtr(&basicClusters_, iclus));
138  }
139  (*sc)[0].setClusters(clusters);
140  }
141  if (!preshowerClusters_.empty() && !(*sc)[0].preshowerClusters().isAvailable()) {
143  for (unsigned int iclus = 0; iclus < preshowerClusters_.size(); ++iclus) {
145  }
146  (*sc)[0].setPreshowerClusters(clusters);
147  }
149  }
151  } else {
153  }
154  //relink caloclusters if needed
156  } else {
158  }
159 }
160 
165  } else {
167  }
168 }
169 
172  if (embeddedSeedCluster_) {
174  } else {
175  return reco::GsfElectron::superCluster()->seed();
176  }
177 }
178 
181  if (embeddedTrack_) {
182  return reco::TrackRef(&track_, 0);
183  } else {
185  }
186 }
187 
188 // the name of the method is misleading, users should use gsfTrack of closestCtfTrack
189 reco::TrackRef Electron::track() const { return reco::TrackRef(); }
190 
193  gsfElectronCore_.clear();
194  if (reco::GsfElectron::core().isNonnull()) {
197  }
198 }
199 
202  gsfTrack_.clear();
203  if (reco::GsfElectron::gsfTrack().isNonnull()) {
205  embeddedGsfTrack_ = true;
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::parentSuperCluster().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::parentSuperCluster().isNonnull()) {
266  for (; itscl != itsclE; ++itscl) {
267  pflowBasicClusters_.push_back(**itscl);
268  }
269  }
270 }
271 
274  pflowPreshowerClusters_.clear();
275  if (reco::GsfElectron::parentSuperCluster().isNonnull()) {
276  reco::CaloCluster_iterator itscl = reco::GsfElectron::parentSuperCluster()->preshowerClustersBegin();
277  reco::CaloCluster_iterator itsclE = reco::GsfElectron::parentSuperCluster()->preshowerClustersEnd();
278  for (; itscl != itsclE; ++itscl) {
279  pflowPreshowerClusters_.push_back(**itscl);
280  }
281  }
282 }
283 
285 void Electron::embedTrack() {
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 != nullptr) {
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)
318  return it->second;
319  }
320  cms::Exception ex("Key not found");
321  ex << "pat::Electron: the ID " << name << " can't be found in this pat::Electron.\n";
322  ex << "The available IDs are: ";
323  for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
324  ex << "'" << it->first << "' ";
325  }
326  ex << ".\n";
327  throw ex;
328 }
329 
332  for (std::vector<IdPair>::const_iterator it = electronIDs_.begin(), ed = electronIDs_.end(); it != ed; ++it) {
333  if (it->first == name)
334  return true;
335  }
336  return false;
337 }
338 
341  if (embeddedPFCandidate_) {
343  } else {
344  return pfCandidateRef_;
345  }
346 }
347 
350  pfCandidate_.clear();
352  pfCandidate_.push_back(*pfCandidateRef_);
353  embeddedPFCandidate_ = true;
354  }
355 }
356 
360  if (pfCandidateRef_.isNonnull()) {
361  if (i == 0) {
363  } else {
364  i--;
365  }
366  }
367  if (i >= associatedPackedFCandidateIndices_.size()) {
368  return reco::CandidatePtr();
369  } else {
372  }
373 }
374 
385 double Electron::dB(IpType type_) const {
386  // more IP types (new)
387  if (cachedIP_ & (1 << int(type_))) {
388  return ip_[type_];
389  } else {
391  }
392 }
393 
404 double Electron::edB(IpType type_) const {
405  // more IP types (new)
406  if (cachedIP_ & (1 << int(type_))) {
407  return eip_[type_];
408  } else {
410  }
411 }
412 
414 void Electron::setDB(double dB, double edB, IpType type) {
415  ip_[type] = dB;
416  eip_[type] = edB;
417  cachedIP_ |= (1 << int(type));
418 }
419 
421 void Electron::setMvaVariables(double sigmaIetaIphi, double ip3d) {
423  ip3d_ = ip3d;
424 }
425 
428  for (uint16_t idx : associatedPackedFCandidateIndices_) {
430  }
431  return ret;
432 }
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:543
pat::Electron::pfCandidateRef_
reco::PFCandidateRef pfCandidateRef_
reference to the IsolatedPFCandidate this has been built from; null if this has been built from a sta...
Definition: Electron.h:328
pat::Electron::Electron
Electron()
default constructor
pat::Electron::embeddedSuperCluster_
bool embeddedSuperCluster_
True if electron's supercluster is stored internally.
Definition: Electron.h:287
reco::GsfTrackRef
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
pat::Electron::pflowBasicClusters_
std::vector< reco::CaloCluster > pflowBasicClusters_
Place to store electron's pflow basic clusters internally.
Definition: Electron.h:299
alignBH_cfg.fixed
fixed
Definition: alignBH_cfg.py:54
pat::Electron::embedTrack
void embedTrack()
method to store the electron's Track internally
pat::Electron::embeddedGsfTrack_
bool embeddedGsfTrack_
True if electron's gsfTrack is stored internally.
Definition: Electron.h:283
mps_fire.i
i
Definition: mps_fire.py:428
pat::Electron::sigmaIetaIphi_
float sigmaIetaIphi_
additional missing mva variables : 14/04/2012
Definition: Electron.h:335
pat::Electron::preshowerClusters_
std::vector< reco::CaloCluster > preshowerClusters_
Place to store electron's preshower clusters internally.
Definition: Electron.h:297
reco::GsfElectron::gsfTrack
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:164
pat::Electron::basicClusters_
std::vector< reco::CaloCluster > basicClusters_
Place to store electron's basic clusters internally.
Definition: Electron.h:295
funct::false
false
Definition: Factorize.h:29
edm::RefProd::id
ProductID id() const
Accessor for product ID.
Definition: RefProd.h:124
configurableAnalysis::Candidate
char Candidate[]
Definition: modules.cc:20
Lepton
Definition: Lepton.py:1
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
reco::GsfElectron::parentSuperCluster
virtual SuperClusterRef parentSuperCluster() const
Definition: GsfElectron.h:168
pat::Electron::embedSeedCluster
void embedSeedCluster()
method to store the electron's seedcluster internally
pat::Electron::embeddedGsfElectronCore_
bool embeddedGsfElectronCore_
True if electron's gsfElectronCore is stored internally.
Definition: Electron.h:279
pat::Electron::embedPreshowerClusters
void embedPreshowerClusters()
method to store the electron's preshower clusters
edm::Ref::isAvailable
bool isAvailable() const
Definition: Ref.h:537
pat::Electron::recHits_
EcalRecHitCollection recHits_
Place to store electron's RecHits internally (5x5 around seed+ all RecHits)
Definition: Electron.h:315
pat::Electron::embedGsfElectronCore
void embedGsfElectronCore()
method to store the electron's core internally
pat::Electron::gsfTrack
reco::GsfTrackRef gsfTrack() const override
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster
pat::Electron::eip_
float eip_[IpTypeSize]
Impact parameter uncertainty as recommended by the tracking group.
Definition: Electron.h:373
pat::Electron::embedRecHits
void embedRecHits(const EcalRecHitCollection *rechits)
method to store the RecHits internally - can be called from the PATElectronProducer
edm::PtrVectorItr
Definition: PtrVector.h:51
edm::SortedCollection< EcalRecHit >
pat::Electron::associatedPackedPFCandidates
edm::RefVector< pat::PackedCandidateCollection > associatedPackedPFCandidates() const
References to PFCandidates linked to this object (e.g. for isolation vetos or masking before jet recl...
edm::RefVector
Definition: EDProductfwd.h:27
pat::Electron::closestCtfTrackRef
reco::TrackRef closestCtfTrackRef() const override
override the reco::GsfElectron::closestCtfTrackRef method, to access the internal storage of the trac...
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
pat::Electron::embedPflowBasicClusters
void embedPflowBasicClusters()
method to store the electron's pflow basic clusters
pat::Electron::pfCandidateRef
reco::PFCandidateRef pfCandidateRef() const
reference to the source PFCandidates; null if this has been built from a standard electron
pat::Electron::embedPflowSuperCluster
void embedPflowSuperCluster()
method to store the electron's PflowSuperCluster internally
pat::Electron::embedGsfTrack
void embedGsfTrack()
method to store the electron's GsfTrack internally
reco::CaloClusterPtr
edm::Ptr< CaloCluster > CaloClusterPtr
Definition: CaloClusterFwd.h:21
edm::Ref
Definition: AssociativeIterator.h:58
edm::AtomicPtrCache::isSet
bool isSet() const
Definition: AtomicPtrCache.h:122
pat::Electron::pflowPreshowerClusters_
std::vector< reco::CaloCluster > pflowPreshowerClusters_
Place to store electron's pflow preshower clusters internally.
Definition: Electron.h:301
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
reco::GsfElectron::core
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.cc:8
edm::AtomicPtrCache::set
bool set(std::unique_ptr< T > iNewValue) const
Definition: AtomicPtrCache.h:127
edm::refToPtr
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
pat::Electron::setDB
void setDB(double dB, double edB, IPTYPE type)
Set impact parameter of a certain type and its uncertainty.
pat::Electron::cachedIP_
uint8_t cachedIP_
True if the IP (former dB) has been cached.
Definition: Electron.h:369
pat::Electron::IpTypeSize
Definition: Electron.h:190
pat::Electron::embeddedTrack_
bool embeddedTrack_
True if electron's track is stored internally.
Definition: Electron.h:305
pat::Electron::electronID
float electronID(const std::string &name) const
Returns a specific electron ID associated to the pat::Electron given its name.
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
pat::Electron::~Electron
~Electron() override
destructor
pat::Electron::embedPflowPreshowerClusters
void embedPflowPreshowerClusters()
method to store the electron's pflow preshower clusters
pat::Electron::track
reco::TrackRef track() const override
returns nothing. Use either gsfTrack or closestCtfTrack
edm::PtrVector< CaloCluster >
pat::Electron::pfCandidate_
reco::PFCandidateCollection pfCandidate_
A copy of the source IsolatedPFCandidate is stored in this vector if embeddedPFCandidate_ if True.
Definition: Electron.h:326
pat::Electron::gsfElectronCore_
std::vector< reco::GsfElectronCore > gsfElectronCore_
Place to store electron's gsfElectronCore internally.
Definition: Electron.h:281
pat::Electron::core
reco::GsfElectronCoreRef core() const override
override the virtual reco::GsfElectron::core method, so that the embedded core can be used by GsfElec...
reco::SuperClusterRef
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
Definition: SuperClusterFwd.h:15
pat::Electron::embedBasicClusters
void embedBasicClusters()
method to store the electron's basic clusters
HI_PhotonSkim_cff.rechits
rechits
Definition: HI_PhotonSkim_cff.py:76
reco::GsfElectron
Definition: GsfElectron.h:35
pat::Electron::parentSuperCluster
reco::SuperClusterRef parentSuperCluster() const override
override the reco::GsfElectron::pflowSuperCluster method, to access the internal storage of the pflow...
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
pat::Electron::embedSuperCluster
void embedSuperCluster()
method to store the electron's SuperCluster internally
reco::TrackRef
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
pat::Electron::superCluster_
std::vector< reco::SuperCluster > superCluster_
Place to store electron's supercluster internally.
Definition: Electron.h:291
pat::Electron::setMvaVariables
void setMvaVariables(double sigmaIetaIphi, double ip3d)
set missing mva input variables
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
pat::Electron::dB
double dB() const
the version without arguments returns PD2D, but with an absolute value (for backwards compatibility)
Definition: Electron.h:196
ntuplemaker.fill
fill
Definition: ntuplemaker.py:304
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
electrons_cff.ip3d
ip3d
Definition: electrons_cff.py:357
createfilelist.int
int
Definition: createfilelist.py:10
RefToPtr.h
pat::Electron::ip3d_
double ip3d_
Definition: Electron.h:336
p4
double p4[4]
Definition: TauolaWrapper.h:92
reco::PFCandidateRef
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
Definition: PFCandidateFwd.h:24
pat::Electron::embeddedSeedCluster_
bool embeddedSeedCluster_
True if seed cluster is stored internally.
Definition: Electron.h:309
pat::Electron::superClusterRelinked_
edm::AtomicPtrCache< std::vector< reco::SuperCluster > > superClusterRelinked_
Place to temporarily store the electron's supercluster after relinking the seed to it.
Definition: Electron.h:293
reco::operator<<
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:66
pat::Electron::track_
std::vector< reco::Track > track_
Place to store electron's track internally.
Definition: Electron.h:307
pat::Electron::electronIDs_
std::vector< IdPair > electronIDs_
Electron IDs.
Definition: Electron.h:319
reco::GsfElectron::closestCtfTrackRef
virtual TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:188
pat
Definition: HeavyIon.h:7
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
pat::Electron::embedPFCandidate
void embedPFCandidate()
embed the PFCandidate pointed to by pfCandidateRef_
pat::Electron::associatedPackedFCandidateIndices_
std::vector< uint16_t > associatedPackedFCandidateIndices_
Definition: Electron.h:377
edm::Ptr< reco::GsfElectron >
pat::Electron::packedPFCandidates_
edm::RefProd< pat::PackedCandidateCollection > packedPFCandidates_
Definition: Electron.h:376
pat::Electron::embeddedPFCandidate_
bool embeddedPFCandidate_
true if the IsolatedPFCandidate is embedded
Definition: Electron.h:324
eostools.move
def move(src, dest)
Definition: eostools.py:511
pat::Electron::edB
double edB() const
the version without arguments returns PD2D, but with an absolute value (for backwards compatibility)
Definition: Electron.h:198
pat::Electron::superCluster
reco::SuperClusterRef superCluster() const override
override the reco::GsfElectron::superCluster method, to access the internal storage of the superclust...
pat::Electron::embeddedPflowSuperCluster_
bool embeddedPflowSuperCluster_
True if electron's pflowsupercluster is stored internally.
Definition: Electron.h:289
pat::Electron::seed
reco::CaloClusterPtr seed() const
direct access to the seed cluster
LorentzVector
math::XYZTLorentzVector LorentzVector
Definition: HLTMuonMatchAndPlot.h:49
pat::Electron::isElectronIDAvailable
bool isElectronIDAvailable(const std::string &name) const
Returns true if a specific ID is available in this pat::Electron.
pat::Electron::embeddedRecHits_
bool embeddedRecHits_
True if RecHits stored internally.
Definition: Electron.h:313
pat::Electron::initImpactParameters
void initImpactParameters()
init impact parameter defaults (for use in a constructor)
pat::Electron::ip_
float ip_[IpTypeSize]
Impact parameter at the primary vertex,.
Definition: Electron.h:371
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
pat::Electron::seedCluster_
std::vector< reco::CaloCluster > seedCluster_
Place to store electron's seed cluster internally.
Definition: Electron.h:311
edm::RefToBase
Definition: AssociativeIterator.h:54
Exception.h
reco::GsfElectron::superCluster
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:163
Electron.h
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
cms::Exception
Definition: Exception.h:70
reco::CandidatePtr
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
pat::Electron
Analysis-level electron class.
Definition: Electron.h:51
pat::Electron::pflowSuperCluster_
std::vector< reco::SuperCluster > pflowSuperCluster_
Place to store electron's pflow supercluster internally.
Definition: Electron.h:303
pat::Electron::sigmaIetaIphi
float sigmaIetaIphi() const
Definition: Electron.h:211
pat::Electron::sourceCandidatePtr
reco::CandidatePtr sourceCandidatePtr(size_type i) const override
get the source candidate pointer with index i
pat::Electron::ip3d
double ip3d() const
ip3d
Definition: Electron.h:215
reco::GsfElectronCoreRef
edm::Ref< GsfElectronCoreCollection > GsfElectronCoreRef
Definition: GsfElectronCoreFwd.h:14
pat::Electron::gsfTrack_
std::vector< reco::GsfTrack > gsfTrack_
Place to store electron's gsfTrack internally.
Definition: Electron.h:285