CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
pat::PATElectronSlimmer Class Reference

Slimmer of PAT Electrons. More...

Inheritance diagram for pat::PATElectronSlimmer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PATElectronSlimmer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
virtual ~PATElectronSlimmer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

StringCutObjectSelector
< pat::Electron
dropBasicClusters_
 
StringCutObjectSelector
< pat::Electron
dropClassifications_
 
StringCutObjectSelector
< pat::Electron
dropCorrections_
 
StringCutObjectSelector
< pat::Electron
dropExtrapolations_
 
StringCutObjectSelector
< pat::Electron
dropIsolations_
 
StringCutObjectSelector
< pat::Electron
dropPFlowClusters_
 
StringCutObjectSelector
< pat::Electron
dropPreshowerClusters_
 
StringCutObjectSelector
< pat::Electron
dropRecHits_
 
StringCutObjectSelector
< pat::Electron
dropSeedCluster_
 
StringCutObjectSelector
< pat::Electron
dropShapes_
 
StringCutObjectSelector
< pat::Electron
dropSuperClusters_
 
bool linkToPackedPF_
 
edm::EDGetTokenT
< pat::PackedCandidateCollection
pc_
 
edm::EDGetTokenT
< edm::Association
< pat::PackedCandidateCollection > > 
pf2pc_
 
edm::EDGetTokenT
< edm::ValueMap< std::vector
< reco::PFCandidateRef > > > 
reco2pf_
 
edm::EDGetTokenT
< EcalRecHitCollection
reducedBarrelRecHitCollectionToken_
 
edm::EDGetTokenT
< EcalRecHitCollection
reducedEndcapRecHitCollectionToken_
 
StringCutObjectSelector
< pat::Electron
saveNonZSClusterShapes_
 
edm::EDGetTokenT< edm::View
< pat::Electron > > 
src_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Slimmer of PAT Electrons.

Definition at line 24 of file PATElectronSlimmer.cc.

Constructor & Destructor Documentation

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

Definition at line 47 of file PATElectronSlimmer.cc.

References edm::ParameterSet::getParameter(), linkToPackedPF_, pc_, pf2pc_, and reco2pf_.

47  :
49  dropSuperClusters_(iConfig.getParameter<std::string>("dropSuperCluster")),
50  dropBasicClusters_(iConfig.getParameter<std::string>("dropBasicClusters")),
51  dropPFlowClusters_(iConfig.getParameter<std::string>("dropPFlowClusters")),
52  dropPreshowerClusters_(iConfig.getParameter<std::string>("dropPreshowerClusters")),
53  dropSeedCluster_(iConfig.getParameter<std::string>("dropSeedCluster")),
54  dropRecHits_(iConfig.getParameter<std::string>("dropRecHits")),
55  dropCorrections_(iConfig.getParameter<std::string>("dropCorrections")),
56  dropIsolations_(iConfig.getParameter<std::string>("dropIsolations")),
57  dropShapes_(iConfig.getParameter<std::string>("dropShapes")),
58  dropExtrapolations_(iConfig.getParameter<std::string>("dropExtrapolations")),
59  dropClassifications_(iConfig.getParameter<std::string>("dropClassifications")),
60  linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates")),
61  saveNonZSClusterShapes_(iConfig.getParameter<std::string>("saveNonZSClusterShapes")),
62  reducedBarrelRecHitCollectionToken_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedBarrelRecHitCollection"))),
63  reducedEndcapRecHitCollectionToken_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEndcapRecHitCollection")))
64 {
65  produces<std::vector<pat::Electron> >();
66  if (linkToPackedPF_) {
67  reco2pf_ = consumes<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(iConfig.getParameter<edm::InputTag>("recoToPFMap"));
68  pf2pc_ = consumes<edm::Association<pat::PackedCandidateCollection>>(iConfig.getParameter<edm::InputTag>("packedPFCandidates"));
69  pc_ = consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("packedPFCandidates"));
70  }
71  mayConsume<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEB"));
72  mayConsume<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEE"));
73 }
edm::EDGetTokenT< pat::PackedCandidateCollection > pc_
T getParameter(std::string const &) const
StringCutObjectSelector< pat::Electron > dropPFlowClusters_
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
edm::EDGetTokenT< edm::View< pat::Electron > > src_
edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
StringCutObjectSelector< pat::Electron > dropIsolations_
StringCutObjectSelector< pat::Electron > dropBasicClusters_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > reco2pf_
StringCutObjectSelector< pat::Electron > dropExtrapolations_
edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
StringCutObjectSelector< pat::Electron > dropShapes_
StringCutObjectSelector< pat::Electron > dropSuperClusters_
StringCutObjectSelector< pat::Electron > dropSeedCluster_
StringCutObjectSelector< pat::Electron > dropRecHits_
StringCutObjectSelector< pat::Electron > dropClassifications_
StringCutObjectSelector< pat::Electron > dropCorrections_
StringCutObjectSelector< pat::Electron > dropPreshowerClusters_
StringCutObjectSelector< pat::Electron > saveNonZSClusterShapes_
virtual pat::PATElectronSlimmer::~PATElectronSlimmer ( )
inlinevirtual

Definition at line 27 of file PATElectronSlimmer.cc.

27 { }

Member Function Documentation

void pat::PATElectronSlimmer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 76 of file PATElectronSlimmer.cc.

References pat::Electron::basicClusters_, metsig::electron, pat::Electron::embeddedPflowSuperCluster_, pat::Electron::embeddedRecHits_, pat::Electron::embeddedSeedCluster_, pat::Electron::embeddedSuperCluster_, pat::Electron::full5x5_setSigmaIetaIphi(), edm::Event::getByToken(), EcalClusterLazyToolsT< EcalClusterToolsImpl >::localCovariances(), dbtoconf::out, pat::Electron::pflowBasicClusters_, pat::Electron::pflowPreshowerClusters_, pat::Electron::pflowSuperCluster_, pat::Electron::preshowerClusters_, edm::RefVector< C, T, F >::push_back(), edm::Event::put(), pat::Electron::recHits_, pat::PATObject< ObjectType >::refToOrig_, edm::refToPtr(), pat::Electron::seedCluster_, pat::Electron::setAssociatedPackedPFCandidates(), reco::GsfElectron::setClassification(), reco::GsfElectron::setClassificationVariables(), reco::GsfElectron::setCorrections(), reco::GsfElectron::setDr03Isolation(), reco::GsfElectron::setDr04Isolation(), pat::Electron::setPackedPFCandidateCollection(), reco::GsfElectron::setPfIsolationVariables(), reco::GsfElectron::setPfShowerShape(), reco::GsfElectron::setShowerShape(), reco::GsfElectron::setTrackExtrapolations(), edm::RefVector< C, T, F >::size(), alcazmumu_cfi::src, pat::Electron::superCluster(), and pat::Electron::superCluster_.

76  {
77  using namespace edm;
78  using namespace std;
79 
81  iEvent.getByToken(src_, src);
82 
86  if (linkToPackedPF_) {
87  iEvent.getByToken(reco2pf_, reco2pf);
88  iEvent.getByToken(pf2pc_, pf2pc);
89  iEvent.getByToken(pc_, pc);
90  }
92 
93  auto_ptr<vector<pat::Electron> > out(new vector<pat::Electron>());
94  out->reserve(src->size());
95 
96  for (View<pat::Electron>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
97  out->push_back(*it);
98  pat::Electron & electron = out->back();
99  if (dropSuperClusters_(electron)) { electron.superCluster_.clear(); electron.embeddedSuperCluster_ = false; }
100  if (dropBasicClusters_(electron)) { electron.basicClusters_.clear(); }
101  if (dropSuperClusters_(electron) || dropPFlowClusters_(electron)) { electron.pflowSuperCluster_.clear(); electron.embeddedPflowSuperCluster_ = false; }
102  if (dropBasicClusters_(electron) || dropPFlowClusters_(electron)) { electron.pflowBasicClusters_.clear(); }
103  if (dropPreshowerClusters_(electron)) { electron.preshowerClusters_.clear(); }
104  if (dropPreshowerClusters_(electron) || dropPFlowClusters_(electron)) { electron.pflowPreshowerClusters_.clear(); }
105  if (dropSeedCluster_(electron)) { electron.seedCluster_.clear(); electron.embeddedSeedCluster_ = false; }
106  if (dropRecHits_(electron)) { electron.recHits_ = EcalRecHitCollection(); electron.embeddedRecHits_ = false; }
107  if (dropCorrections_(electron)) { electron.setCorrections(reco::GsfElectron::Corrections()); }
112  if (linkToPackedPF_) {
114  //std::cout << " PAT electron in " << src.id() << " comes from " << electron.refToOrig_.id() << ", " << electron.refToOrig_.key() << std::endl;
116  for (const reco::PFCandidateRef & pf : (*reco2pf)[electron.refToOrig_]) {
117  if (pf2pc->contains(pf.id())) {
118  origs.push_back((*pf2pc)[pf]);
119  } //else std::cerr << " Electron linked to a PFCand in " << pf.id() << " while we expect them in " << pf2pc->ids().front().first << "\n";
120  }
121  //std::cout << "Electron with pt " << electron.pt() << " associated to " << origs.size() << " PF Candidates\n";
122  electron.setAssociatedPackedPFCandidates(origs);
123  //if there's just one PF Cand then it's me, otherwise I have no univoque parent so my ref will be null
124  if (origs.size() == 1) {
125  electron.refToOrig_ = refToPtr(origs[0]);
126  } else {
127  electron.refToOrig_ = reco::CandidatePtr(pc.id());
128  }
129  }
130  if (saveNonZSClusterShapes_(electron)) {
131  std::vector<float> vCov = lazyToolsNoZS.localCovariances(*( electron.superCluster()->seed()));
132  electron.full5x5_setSigmaIetaIphi(vCov[1]);
133  }
134 
135  }
136 
137  iEvent.put(out);
138 }
edm::EDGetTokenT< pat::PackedCandidateCollection > pc_
void setDr04Isolation(const IsolationVariables &dr04)
Definition: GsfElectron.h:497
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
StringCutObjectSelector< pat::Electron > dropPFlowClusters_
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
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
edm::EDGetTokenT< edm::View< pat::Electron > > src_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
reco::SuperClusterRef superCluster() const
override the reco::GsfElectron::superCluster method, to access the internal storage of the superclust...
Definition: Electron.cc:152
StringCutObjectSelector< pat::Electron > dropIsolations_
void setAssociatedPackedPFCandidates(const edm::RefVector< pat::PackedCandidateCollection > &refvector)
References to PFCandidates linked to this object (e.g. for isolation vetos or masking before jet recl...
Definition: Electron.cc:490
void full5x5_setSigmaIetaIphi(float sigmaIetaIphi)
Definition: Electron.h:202
void setShowerShape(const ShowerShape &s)
Definition: GsfElectron.h:431
std::vector< reco::SuperCluster > superCluster_
Place to store electron&#39;s supercluster internally.
Definition: Electron.h:264
StringCutObjectSelector< pat::Electron > dropBasicClusters_
void setPfIsolationVariables(const PflowIsolationVariables &iso)
Definition: GsfElectron.h:607
void setDr03Isolation(const IsolationVariables &dr03)
Definition: GsfElectron.h:496
std::vector< reco::CaloCluster > pflowBasicClusters_
Place to store electron&#39;s pflow basic clusters internally.
Definition: Electron.h:272
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > reco2pf_
std::vector< reco::CaloCluster > basicClusters_
Place to store electron&#39;s basic clusters internally.
Definition: Electron.h:268
StringCutObjectSelector< pat::Electron > dropExtrapolations_
edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
std::vector< reco::CaloCluster > preshowerClusters_
Place to store electron&#39;s preshower clusters internally.
Definition: Electron.h:270
bool embeddedRecHits_
True if RecHits stored internally.
Definition: Electron.h:286
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
bool embeddedSeedCluster_
True if seed cluster is stored internally.
Definition: Electron.h:282
StringCutObjectSelector< pat::Electron > dropShapes_
void setPfShowerShape(const ShowerShape &shape)
Definition: GsfElectron.h:606
tuple out
Definition: dbtoconf.py:99
EcalRecHitCollection recHits_
Place to store electron&#39;s RecHits internally (5x5 around seed+ all RecHits)
Definition: Electron.h:288
void setPackedPFCandidateCollection(const edm::RefProd< pat::PackedCandidateCollection > &refprod)
References to PFCandidates (e.g. to recompute isolation)
Definition: Electron.cc:477
StringCutObjectSelector< pat::Electron > dropSuperClusters_
StringCutObjectSelector< pat::Electron > dropSeedCluster_
StringCutObjectSelector< pat::Electron > dropRecHits_
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
void setClassification(Classification myclass)
Definition: GsfElectron.h:691
StringCutObjectSelector< pat::Electron > dropClassifications_
bool embeddedPflowSuperCluster_
True if electron&#39;s pflowsupercluster is stored internally.
Definition: Electron.h:262
Analysis-level electron class.
Definition: Electron.h:52
StringCutObjectSelector< pat::Electron > dropCorrections_
bool embeddedSuperCluster_
True if electron&#39;s supercluster is stored internally.
Definition: Electron.h:260
StringCutObjectSelector< pat::Electron > dropPreshowerClusters_
void setTrackExtrapolations(const TrackExtrapolations &te)
Definition: GsfElectron.h:294
std::vector< reco::CaloCluster > pflowPreshowerClusters_
Place to store electron&#39;s pflow preshower clusters internally.
Definition: Electron.h:274
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:64
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
void setCorrections(const Corrections &c)
Definition: GsfElectron.h:768
void setClassificationVariables(const ClassificationVariables &cv)
Definition: GsfElectron.h:690
StringCutObjectSelector< pat::Electron > saveNonZSClusterShapes_
edm::Ptr< reco::Candidate > refToOrig_
Definition: PATObject.h:407
std::vector< reco::SuperCluster > pflowSuperCluster_
Place to store electron&#39;s pflow supercluster internally.
Definition: Electron.h:276
edm::SortedCollection< EcalRecHit > EcalRecHitCollection
std::vector< reco::CaloCluster > seedCluster_
Place to store electron&#39;s seed cluster internally.
Definition: Electron.h:284

Member Data Documentation

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

Definition at line 34 of file PATElectronSlimmer.cc.

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

Definition at line 35 of file PATElectronSlimmer.cc.

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

Definition at line 35 of file PATElectronSlimmer.cc.

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

Definition at line 35 of file PATElectronSlimmer.cc.

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

Definition at line 35 of file PATElectronSlimmer.cc.

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

Definition at line 34 of file PATElectronSlimmer.cc.

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

Definition at line 34 of file PATElectronSlimmer.cc.

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

Definition at line 34 of file PATElectronSlimmer.cc.

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

Definition at line 34 of file PATElectronSlimmer.cc.

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

Definition at line 35 of file PATElectronSlimmer.cc.

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

Definition at line 34 of file PATElectronSlimmer.cc.

bool pat::PATElectronSlimmer::linkToPackedPF_
private

Definition at line 40 of file PATElectronSlimmer.cc.

Referenced by PATElectronSlimmer().

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

Definition at line 39 of file PATElectronSlimmer.cc.

Referenced by PATElectronSlimmer().

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

Definition at line 38 of file PATElectronSlimmer.cc.

Referenced by PATElectronSlimmer().

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

Definition at line 37 of file PATElectronSlimmer.cc.

Referenced by PATElectronSlimmer().

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

Definition at line 42 of file PATElectronSlimmer.cc.

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

Definition at line 42 of file PATElectronSlimmer.cc.

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

Definition at line 41 of file PATElectronSlimmer.cc.

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

Definition at line 32 of file PATElectronSlimmer.cc.