CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
pat::PATElectronSlimmer Class Reference

Slimmer of PAT Electrons. More...

Inheritance diagram for pat::PATElectronSlimmer:
edm::stream::EDProducer<>

Public Member Functions

void beginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) final
 
 PATElectronSlimmer (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) final
 
 ~PATElectronSlimmer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Attributes

const StringCutObjectSelector< pat::ElectrondropBasicClusters_
 
const StringCutObjectSelector< pat::ElectrondropClassifications_
 
const StringCutObjectSelector< pat::ElectrondropCorrections_
 
const StringCutObjectSelector< pat::ElectrondropExtrapolations_
 
const StringCutObjectSelector< pat::ElectrondropIsolations_
 
const StringCutObjectSelector< pat::ElectrondropPFlowClusters_
 
const StringCutObjectSelector< pat::ElectrondropPreshowerClusters_
 
const StringCutObjectSelector< pat::ElectrondropRecHits_
 
const StringCutObjectSelector< pat::ElectrondropSaturation_
 
const StringCutObjectSelector< pat::ElectrondropSeedCluster_
 
const StringCutObjectSelector< pat::ElectrondropShapes_
 
const StringCutObjectSelector< pat::ElectrondropSuperClusters_
 
std::unique_ptr< pat::ObjectModifier< pat::Electron > > electronModifier_
 
const bool linkToPackedPF_
 
const bool modifyElectron_
 
const edm::EDGetTokenT< pat::PackedCandidateCollectionpc_
 
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
 
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > reco2pf_
 
const edm::EDGetTokenT< EcalRecHitCollectionreducedBarrelRecHitCollectionToken_
 
const edm::EDGetTokenT< EcalRecHitCollectionreducedEndcapRecHitCollectionToken_
 
const StringCutObjectSelector< pat::ElectronsaveNonZSClusterShapes_
 
const edm::EDGetTokenT< edm::View< pat::Electron > > src_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Slimmer of PAT Electrons.

Definition at line 26 of file PATElectronSlimmer.cc.

Constructor & Destructor Documentation

pat::PATElectronSlimmer::PATElectronSlimmer ( const edm::ParameterSet iConfig)
explicit

Definition at line 55 of file PATElectronSlimmer.cc.

References electronModifier_, edm::ParameterSet::getParameter(), HLT_2018_cff::InputTag, and modifyElectron_.

56  : src_(consumes<edm::View<pat::Electron>>(iConfig.getParameter<edm::InputTag>("src"))),
57  dropSuperClusters_(iConfig.getParameter<std::string>("dropSuperCluster")),
58  dropBasicClusters_(iConfig.getParameter<std::string>("dropBasicClusters")),
59  dropPFlowClusters_(iConfig.getParameter<std::string>("dropPFlowClusters")),
60  dropPreshowerClusters_(iConfig.getParameter<std::string>("dropPreshowerClusters")),
61  dropSeedCluster_(iConfig.getParameter<std::string>("dropSeedCluster")),
62  dropRecHits_(iConfig.getParameter<std::string>("dropRecHits")),
63  dropCorrections_(iConfig.getParameter<std::string>("dropCorrections")),
64  dropIsolations_(iConfig.getParameter<std::string>("dropIsolations")),
65  dropShapes_(iConfig.getParameter<std::string>("dropShapes")),
66  dropSaturation_(iConfig.getParameter<std::string>("dropSaturation")),
67  dropExtrapolations_(iConfig.getParameter<std::string>("dropExtrapolations")),
68  dropClassifications_(iConfig.getParameter<std::string>("dropClassifications")),
69  reco2pf_(mayConsume<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(
70  iConfig.getParameter<edm::InputTag>("recoToPFMap"))),
72  iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
73  pc_(mayConsume<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
74  linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates")),
75  saveNonZSClusterShapes_(iConfig.getParameter<std::string>("saveNonZSClusterShapes")),
77  consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedBarrelRecHitCollection"))),
79  consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEndcapRecHitCollection"))),
80  modifyElectron_(iConfig.getParameter<bool>("modifyElectrons")) {
81  if (modifyElectron_) {
82  const edm::ParameterSet& mod_config = iConfig.getParameter<edm::ParameterSet>("modifierConfig");
83  electronModifier_ = std::make_unique<pat::ObjectModifier<pat::Electron>>(mod_config, consumesCollector());
84  }
85 
86  mayConsume<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEB"));
87  mayConsume<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEE"));
88 
89  produces<std::vector<pat::Electron>>();
90 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
const StringCutObjectSelector< pat::Electron > dropRecHits_
const StringCutObjectSelector< pat::Electron > dropIsolations_
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > reco2pf_
const StringCutObjectSelector< pat::Electron > dropSuperClusters_
const StringCutObjectSelector< pat::Electron > dropCorrections_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
const edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
std::unique_ptr< pat::ObjectModifier< pat::Electron > > electronModifier_
const StringCutObjectSelector< pat::Electron > dropBasicClusters_
const StringCutObjectSelector< pat::Electron > dropPreshowerClusters_
const StringCutObjectSelector< pat::Electron > dropClassifications_
const StringCutObjectSelector< pat::Electron > dropShapes_
const StringCutObjectSelector< pat::Electron > dropExtrapolations_
const StringCutObjectSelector< pat::Electron > saveNonZSClusterShapes_
const StringCutObjectSelector< pat::Electron > dropSeedCluster_
const StringCutObjectSelector< pat::Electron > dropPFlowClusters_
const StringCutObjectSelector< pat::Electron > dropSaturation_
const edm::EDGetTokenT< edm::View< pat::Electron > > src_
const edm::EDGetTokenT< pat::PackedCandidateCollection > pc_
pat::PATElectronSlimmer::~PATElectronSlimmer ( )
inlineoverride

Definition at line 29 of file PATElectronSlimmer.cc.

References beginLuminosityBlock(), iEvent, and produce().

29 {}

Member Function Documentation

void pat::PATElectronSlimmer::beginLuminosityBlock ( const edm::LuminosityBlock ,
const edm::EventSetup iSetup 
)
final

Definition at line 92 of file PATElectronSlimmer.cc.

Referenced by ~PATElectronSlimmer().

92 {}
void pat::PATElectronSlimmer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
final

Definition at line 94 of file PATElectronSlimmer.cc.

References pat::Electron::basicClusters_, DEFINE_FWK_MODULE, dropBasicClusters_, dropClassifications_, dropCorrections_, dropExtrapolations_, dropIsolations_, dropPFlowClusters_, dropPreshowerClusters_, dropRecHits_, dropSaturation_, dropSeedCluster_, dropShapes_, dropSuperClusters_, metsig::electron, electronModifier_, pat::Electron::embeddedPflowSuperCluster_, pat::Electron::embeddedRecHits_, pat::Electron::embeddedSeedCluster_, pat::Electron::embeddedSuperCluster_, pat::Electron::full5x5_setSigmaIetaIphi(), edm::Event::getByToken(), edm::HandleBase::id(), crabWrapper::key, relativeConstraints::keys, linkToPackedPF_, EcalClusterLazyToolsT< ClusterTools >::localCovariances(), modifyElectron_, eostools::move(), MillePedeFileConverter_cfg::out, pc_, packedPFCandidateRefMixer_cfi::pf, pf2pc_, pat::Electron::pflowBasicClusters_, pat::Electron::pflowPreshowerClusters_, pat::Electron::pflowSuperCluster_, pat::Electron::preshowerClusters_, edm::Event::put(), pat::Electron::recHits_, reco2pf_, reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollectionToken_, pat::PATObject< ObjectType >::refToOrig_, saveNonZSClusterShapes_, pat::Electron::seedCluster_, pat::Electron::setAssociatedPackedPFCandidates(), reco::GsfElectron::setClassification(), reco::GsfElectron::setClassificationVariables(), reco::GsfElectron::setCorrections(), reco::GsfElectron::setDr03Isolation(), reco::GsfElectron::setDr04Isolation(), reco::GsfElectron::setPfIsolationVariables(), reco::GsfElectron::setSaturationInfo(), reco::GsfElectron::setShowerShape(), reco::GsfElectron::setTrackExtrapolations(), pat::Electron::sourceCandidatePtr(), TrackRefitter_38T_cff::src, src_, pat::Electron::superCluster(), and pat::Electron::superCluster_.

Referenced by ~PATElectronSlimmer().

94  {
95  using namespace edm;
96  using namespace std;
97 
99  iEvent.getByToken(src_, src);
100 
104  if (linkToPackedPF_) {
105  iEvent.getByToken(reco2pf_, reco2pf);
106  iEvent.getByToken(pf2pc_, pf2pc);
107  iEvent.getByToken(pc_, pc);
108  }
109  noZS::EcalClusterLazyTools lazyToolsNoZS(
111 
112  auto out = std::make_unique<std::vector<pat::Electron>>();
113  out->reserve(src->size());
114 
115  if (modifyElectron_) {
116  electronModifier_->setEvent(iEvent);
117  }
118  if (modifyElectron_)
119  electronModifier_->setEventContent(iSetup);
120 
121  std::vector<unsigned int> keys;
122  for (View<pat::Electron>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
123  out->push_back(*it);
124  pat::Electron& electron = out->back();
125 
126  if (modifyElectron_) {
127  electronModifier_->modify(electron);
128  }
129 
130  if (dropSuperClusters_(electron)) {
131  electron.superCluster_.clear();
132  electron.embeddedSuperCluster_ = false;
133  }
134  if (dropBasicClusters_(electron)) {
135  electron.basicClusters_.clear();
136  }
137  if (dropSuperClusters_(electron) || dropPFlowClusters_(electron)) {
138  electron.pflowSuperCluster_.clear();
139  electron.embeddedPflowSuperCluster_ = false;
140  }
141  if (dropBasicClusters_(electron) || dropPFlowClusters_(electron)) {
142  electron.pflowBasicClusters_.clear();
143  }
144  if (dropPreshowerClusters_(electron)) {
145  electron.preshowerClusters_.clear();
146  }
147  if (dropPreshowerClusters_(electron) || dropPFlowClusters_(electron)) {
148  electron.pflowPreshowerClusters_.clear();
149  }
150  if (dropSeedCluster_(electron)) {
151  electron.seedCluster_.clear();
152  electron.embeddedSeedCluster_ = false;
153  }
154  if (dropRecHits_(electron)) {
155  electron.recHits_ = EcalRecHitCollection();
156  electron.embeddedRecHits_ = false;
157  }
158  if (dropCorrections_(electron)) {
160  }
161  if (dropIsolations_(electron)) {
165  }
166  if (dropShapes_(electron)) {
168  }
169  if (dropSaturation_(electron)) {
171  }
172  if (dropExtrapolations_(electron)) {
174  }
175  if (dropClassifications_(electron)) {
178  }
179  if (linkToPackedPF_) {
180  //std::cout << " PAT electron in " << src.id() << " comes from " << electron.refToOrig_.id() << ", " << electron.refToOrig_.key() << std::endl;
181  keys.clear();
182  for (auto const& pf : (*reco2pf)[electron.refToOrig_]) {
183  if (pf2pc->contains(pf.id())) {
184  keys.push_back((*pf2pc)[pf].key());
185  }
186  }
188  edm::RefProd<pat::PackedCandidateCollection>(pc), keys.begin(), keys.end());
189  //std::cout << "Electron with pt " << electron.pt() << " associated to " << electron.associatedPackedFCandidateIndices_.size() << " PF Candidates\n";
190  //if there's just one PF Cand then it's me, otherwise I have no univoque parent so my ref will be null
191  if (keys.size() == 1) {
192  electron.refToOrig_ = electron.sourceCandidatePtr(0);
193  } else {
194  electron.refToOrig_ = reco::CandidatePtr(pc.id());
195  }
196  }
197  if (saveNonZSClusterShapes_(electron)) {
198  std::vector<float> vCov = lazyToolsNoZS.localCovariances(*(electron.superCluster()->seed()));
199  electron.full5x5_setSigmaIetaIphi(vCov[1]);
200  }
201  }
202 
203  iEvent.put(std::move(out));
204 }
void setDr04Isolation(const IsolationVariables &dr04)
Definition: GsfElectron.h:546
const edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
const StringCutObjectSelector< pat::Electron > dropRecHits_
const StringCutObjectSelector< pat::Electron > dropIsolations_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > reco2pf_
ProductID id() const
Definition: HandleBase.cc:13
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
const StringCutObjectSelector< pat::Electron > dropSuperClusters_
void setSaturationInfo(const SaturationInfo &s)
Definition: GsfElectron.h:492
const StringCutObjectSelector< pat::Electron > dropCorrections_
void full5x5_setSigmaIetaIphi(float sigmaIetaIphi)
Definition: Electron.h:218
void setShowerShape(const ShowerShape &s)
Definition: GsfElectron.h:459
std::vector< reco::SuperCluster > superCluster_
Place to store electron&#39;s supercluster internally.
Definition: Electron.h:291
reco::CandidatePtr sourceCandidatePtr(size_type i) const override
get the source candidate pointer with index i
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
void setPfIsolationVariables(const PflowIsolationVariables &iso)
Definition: GsfElectron.h:659
void setDr03Isolation(const IsolationVariables &dr03)
Definition: GsfElectron.h:545
std::vector< reco::CaloCluster > pflowBasicClusters_
Place to store electron&#39;s pflow basic clusters internally.
Definition: Electron.h:299
const edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
std::unique_ptr< pat::ObjectModifier< pat::Electron > > electronModifier_
std::vector< reco::CaloCluster > basicClusters_
Place to store electron&#39;s basic clusters internally.
Definition: Electron.h:295
const StringCutObjectSelector< pat::Electron > dropBasicClusters_
std::vector< reco::CaloCluster > preshowerClusters_
Place to store electron&#39;s preshower clusters internally.
Definition: Electron.h:297
bool embeddedRecHits_
True if RecHits stored internally.
Definition: Electron.h:313
const StringCutObjectSelector< pat::Electron > dropPreshowerClusters_
const StringCutObjectSelector< pat::Electron > dropClassifications_
const StringCutObjectSelector< pat::Electron > dropShapes_
const StringCutObjectSelector< pat::Electron > dropExtrapolations_
bool embeddedSeedCluster_
True if seed cluster is stored internally.
Definition: Electron.h:309
const StringCutObjectSelector< pat::Electron > saveNonZSClusterShapes_
EcalRecHitCollection recHits_
Place to store electron&#39;s RecHits internally (5x5 around seed+ all RecHits)
Definition: Electron.h:315
const StringCutObjectSelector< pat::Electron > dropSeedCluster_
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
const StringCutObjectSelector< pat::Electron > dropPFlowClusters_
void setClassification(Classification myclass)
Definition: GsfElectron.h:732
bool embeddedPflowSuperCluster_
True if electron&#39;s pflowsupercluster is stored internally.
Definition: Electron.h:289
Analysis-level electron class.
Definition: Electron.h:51
const StringCutObjectSelector< pat::Electron > dropSaturation_
bool embeddedSuperCluster_
True if electron&#39;s supercluster is stored internally.
Definition: Electron.h:287
void setTrackExtrapolations(const TrackExtrapolations &te)
Definition: GsfElectron.h:278
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
std::vector< reco::CaloCluster > pflowPreshowerClusters_
Place to store electron&#39;s pflow preshower clusters internally.
Definition: Electron.h:301
void setCorrections(const Corrections &c)
Definition: GsfElectron.h:808
void setAssociatedPackedPFCandidates(const edm::RefProd< pat::PackedCandidateCollection > &refprod, T beginIndexItr, T endIndexItr)
References to PFCandidates linked to this object (e.g. for isolation vetos or masking before jet recl...
Definition: Electron.h:263
void setClassificationVariables(const ClassificationVariables &cv)
Definition: GsfElectron.h:731
const edm::EDGetTokenT< edm::View< pat::Electron > > src_
const edm::EDGetTokenT< pat::PackedCandidateCollection > pc_
edm::Ptr< reco::Candidate > refToOrig_
Definition: PATObject.h:463
reco::SuperClusterRef superCluster() const override
override the reco::GsfElectron::superCluster method, to access the internal storage of the superclust...
def move(src, dest)
Definition: eostools.py:511
std::vector< reco::SuperCluster > pflowSuperCluster_
Place to store electron&#39;s pflow supercluster internally.
Definition: Electron.h:303
edm::SortedCollection< EcalRecHit > EcalRecHitCollection
std::vector< reco::CaloCluster > seedCluster_
Place to store electron&#39;s seed cluster internally.
Definition: Electron.h:311

Member Data Documentation

const StringCutObjectSelector<pat::Electron> pat::PATElectronSlimmer::dropBasicClusters_
private

Definition at line 37 of file PATElectronSlimmer.cc.

Referenced by produce().

const StringCutObjectSelector<pat::Electron> pat::PATElectronSlimmer::dropClassifications_
private

Definition at line 39 of file PATElectronSlimmer.cc.

Referenced by produce().

const StringCutObjectSelector<pat::Electron> pat::PATElectronSlimmer::dropCorrections_
private

Definition at line 39 of file PATElectronSlimmer.cc.

Referenced by produce().

const StringCutObjectSelector<pat::Electron> pat::PATElectronSlimmer::dropExtrapolations_
private

Definition at line 39 of file PATElectronSlimmer.cc.

Referenced by produce().

const StringCutObjectSelector<pat::Electron> pat::PATElectronSlimmer::dropIsolations_
private

Definition at line 39 of file PATElectronSlimmer.cc.

Referenced by produce().

const StringCutObjectSelector<pat::Electron> pat::PATElectronSlimmer::dropPFlowClusters_
private

Definition at line 37 of file PATElectronSlimmer.cc.

Referenced by produce().

const StringCutObjectSelector<pat::Electron> pat::PATElectronSlimmer::dropPreshowerClusters_
private

Definition at line 37 of file PATElectronSlimmer.cc.

Referenced by produce().

const StringCutObjectSelector<pat::Electron> pat::PATElectronSlimmer::dropRecHits_
private

Definition at line 37 of file PATElectronSlimmer.cc.

Referenced by produce().

const StringCutObjectSelector<pat::Electron> pat::PATElectronSlimmer::dropSaturation_
private

Definition at line 39 of file PATElectronSlimmer.cc.

Referenced by produce().

const StringCutObjectSelector<pat::Electron> pat::PATElectronSlimmer::dropSeedCluster_
private

Definition at line 37 of file PATElectronSlimmer.cc.

Referenced by produce().

const StringCutObjectSelector<pat::Electron> pat::PATElectronSlimmer::dropShapes_
private

Definition at line 39 of file PATElectronSlimmer.cc.

Referenced by produce().

const StringCutObjectSelector<pat::Electron> pat::PATElectronSlimmer::dropSuperClusters_
private

Definition at line 37 of file PATElectronSlimmer.cc.

Referenced by produce().

std::unique_ptr<pat::ObjectModifier<pat::Electron> > pat::PATElectronSlimmer::electronModifier_
private

Definition at line 50 of file PATElectronSlimmer.cc.

Referenced by PATElectronSlimmer(), and produce().

const bool pat::PATElectronSlimmer::linkToPackedPF_
private

Definition at line 45 of file PATElectronSlimmer.cc.

Referenced by produce().

const bool pat::PATElectronSlimmer::modifyElectron_
private

Definition at line 49 of file PATElectronSlimmer.cc.

Referenced by PATElectronSlimmer(), and produce().

const edm::EDGetTokenT<pat::PackedCandidateCollection> pat::PATElectronSlimmer::pc_
private

Definition at line 44 of file PATElectronSlimmer.cc.

Referenced by produce().

const edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection> > pat::PATElectronSlimmer::pf2pc_
private

Definition at line 43 of file PATElectronSlimmer.cc.

Referenced by produce().

const edm::EDGetTokenT<edm::ValueMap<std::vector<reco::PFCandidateRef> > > pat::PATElectronSlimmer::reco2pf_
private

Definition at line 42 of file PATElectronSlimmer.cc.

Referenced by produce().

const edm::EDGetTokenT<EcalRecHitCollection> pat::PATElectronSlimmer::reducedBarrelRecHitCollectionToken_
private

Definition at line 47 of file PATElectronSlimmer.cc.

Referenced by produce().

const edm::EDGetTokenT<EcalRecHitCollection> pat::PATElectronSlimmer::reducedEndcapRecHitCollectionToken_
private

Definition at line 47 of file PATElectronSlimmer.cc.

Referenced by produce().

const StringCutObjectSelector<pat::Electron> pat::PATElectronSlimmer::saveNonZSClusterShapes_
private

Definition at line 46 of file PATElectronSlimmer.cc.

Referenced by produce().

const edm::EDGetTokenT<edm::View<pat::Electron> > pat::PATElectronSlimmer::src_
private

Definition at line 35 of file PATElectronSlimmer.cc.

Referenced by produce().