CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
WtoLNuSelector Class Reference

#include <WtoLNuSelector.h>

Inheritance diagram for WtoLNuSelector:
edm::stream::EDFilter<> edm::stream::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 WtoLNuSelector (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::stream::EDFilter<>
 EDFilter ()=default
 
 EDFilter (const EDFilter &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDFilteroperator= (const EDFilter &)=delete
 
- Public Member Functions inherited from edm::stream::EDFilterBase
 EDFilterBase ()
 
 EDFilterBase (const EDFilterBase &)=delete
 
ModuleDescription const & moduleDescription () const
 
const EDFilterBaseoperator= (const EDFilterBase &)=delete
 
 ~EDFilterBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

bool filter (edm::Event &, edm::EventSetup const &) override
 
double getMt (const TLorentzVector &vlep, const reco::PFMET &obj)
 

Private Attributes

const edm::InputTag bsTag_
 
const edm::EDGetTokenT< reco::BeamSpotbsToken_
 
const edm::InputTag electronTag_
 
const edm::EDGetTokenT< reco::GsfElectronCollectionelectronToken_
 
const edm::InputTag muonTag_
 
const edm::EDGetTokenT< reco::MuonCollectionmuonToken_
 
const edm::InputTag pfmetTag_
 
const edm::EDGetTokenT< reco::PFMETCollectionpfmetToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDFilter<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- Public Types inherited from edm::stream::EDFilterBase
typedef EDFilterAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 22 of file WtoLNuSelector.h.

Constructor & Destructor Documentation

◆ WtoLNuSelector()

WtoLNuSelector::WtoLNuSelector ( const edm::ParameterSet ps)
explicit

Definition at line 25 of file WtoLNuSelector.cc.

26  : electronTag_(ps.getUntrackedParameter<edm::InputTag>("electronInputTag", edm::InputTag("gedGsfElectrons"))),
27  bsTag_(ps.getUntrackedParameter<edm::InputTag>("offlineBeamSpot", edm::InputTag("offlineBeamSpot"))),
28  muonTag_(ps.getUntrackedParameter<edm::InputTag>("muonInputTag", edm::InputTag("muons"))),
29  pfmetTag_(ps.getUntrackedParameter<edm::InputTag>("pfmetTag", edm::InputTag("pfMetT1T2Txy"))),
30  electronToken_(consumes<reco::GsfElectronCollection>(electronTag_)),
31  bsToken_(consumes<reco::BeamSpot>(bsTag_)),
32  muonToken_(consumes<reco::MuonCollection>(muonTag_)),
33  pfmetToken_(consumes<reco::PFMETCollection>(pfmetTag_)) {}
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
const edm::InputTag electronTag_
const edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_
T getUntrackedParameter(std::string const &, T const &) const
const edm::EDGetTokenT< reco::MuonCollection > muonToken_
const edm::InputTag bsTag_
const edm::InputTag muonTag_
const edm::InputTag pfmetTag_
const edm::EDGetTokenT< reco::PFMETCollection > pfmetToken_

Member Function Documentation

◆ filter()

bool WtoLNuSelector::filter ( edm::Event iEvent,
edm::EventSetup const &  iSetup 
)
overrideprivatevirtual

Implements edm::stream::EDFilterBase.

Definition at line 35 of file WtoLNuSelector.cc.

References pwdgSkimBPark_cfi::beamSpot, bsTag_, bsToken_, nano_mu_local_reco_cff::chi2, reco::TrackBase::chi2(), reco::TrackBase::d0(), electronIdCutBasedExt_cfi::deltaEtaIn, electronIdCutBasedExt_cfi::deltaPhiIn, reco::TrackBase::dxy(), reco::TrackBase::dz(), electronTag_, electronToken_, getMt(), reco::TrackBase::hitPattern(), EgHLTOffHistBins_cfi::hOverE, iEvent, edm::Ref< C, T, F >::isNonnull(), edm::HandleBase::isValid(), SiStripPI::max, TtSemiLepEvtBuilder_cfi::mt, amptDefaultParameters_cff::mu, muonTag_, muonToken_, ndof, reco::TrackBase::ndof(), reco::HitPattern::numberOfValidPixelHits(), reco::HitPattern::numberOfValidStripHits(), nano_mu_reco_cff::pfIso04, pfmetTag_, pfmetToken_, reco::GsfElectron::PflowIsolationVariables::sumChargedHadronPt, reco::GsfElectron::PflowIsolationVariables::sumNeutralHadronEt, reco::GsfElectron::PflowIsolationVariables::sumPhotonEt, and reco::GsfElectron::PflowIsolationVariables::sumPUPt.

35  {
36  // Read Electron Collection
38  iEvent.getByToken(electronToken_, electronColl);
39 
41  iEvent.getByToken(bsToken_, beamSpot);
42 
43  std::vector<TLorentzVector> eleList;
44  if (electronColl.isValid()) {
45  for (auto const& ele : *electronColl) {
46  if (!ele.ecalDriven())
47  continue;
48 
49  double hOverE = ele.hadronicOverEm();
50  double sigmaee = ele.sigmaIetaIeta();
51  double deltaPhiIn = ele.deltaPhiSuperClusterTrackAtVtx();
52  double deltaEtaIn = ele.deltaEtaSuperClusterTrackAtVtx();
53 
54  // separate cut for barrel and endcap
55  if (ele.isEB()) {
56  if (std::fabs(deltaPhiIn) >= .15 && std::fabs(deltaEtaIn) >= .007 && hOverE >= .12 && sigmaee >= .01)
57  continue;
58  } else if (ele.isEE()) {
59  if (std::fabs(deltaPhiIn) >= .10 && std::fabs(deltaEtaIn) >= .009 && hOverE >= .10 && sigmaee >= .03)
60  continue;
61  }
62 
63  reco::GsfTrackRef trk = ele.gsfTrack();
64  if (!trk.isNonnull())
65  continue; // only electrons wd tracks
66  double chi2 = trk->chi2();
67  double ndof = trk->ndof();
68  double chbyndof = (ndof > 0) ? chi2 / ndof : 0;
69  double trkd0 = trk->d0();
70  double trkdz = trk->dz();
71  if (beamSpot.isValid()) {
72  trkd0 = -(trk->dxy(beamSpot->position()));
73  trkdz = trk->dz(beamSpot->position());
74  } else {
75  edm::LogError("WtoLNuSelector") << "Error >> Failed to get BeamSpot for label: " << bsTag_;
76  }
77  if (chbyndof >= 10 || std::fabs(trkd0) >= 0.02 || std::fabs(trkdz) >= 20)
78  continue;
79  const reco::HitPattern& hitp = trk->hitPattern();
80  int nPixelHits = hitp.numberOfValidPixelHits();
81  int nStripHits = hitp.numberOfValidStripHits();
82  if (nPixelHits < 1 || nStripHits < 8)
83  continue;
84 
85  // PF Isolation
86  reco::GsfElectron::PflowIsolationVariables pfIso = ele.pfIsolationVariables();
87  float absiso =
88  pfIso.sumChargedHadronPt + std::max(0.0, pfIso.sumNeutralHadronEt + pfIso.sumPhotonEt - 0.5 * pfIso.sumPUPt);
89  float eiso = absiso / ele.pt();
90  if (eiso > 0.3)
91  continue;
92 
93  TLorentzVector le;
94  le.SetPtEtaPhiE(ele.pt(), ele.eta(), ele.phi(), ele.energy());
95  eleList.push_back(le);
96  }
97  } else {
98  edm::LogError("WtoLNuSelector") << "Error >> Failed to get ElectronCollection for label: " << electronTag_;
99  }
100 
101  // Read Muon Collection
103  iEvent.getByToken(muonToken_, muonColl);
104 
105  std::vector<TLorentzVector> muList;
106  if (muonColl.isValid()) {
107  for (auto const& mu : *muonColl) {
108  if (!mu.isGlobalMuon() || !mu.isPFMuon() || std::fabs(mu.eta()) > 2.1 || mu.pt() <= 5)
109  continue;
110 
111  reco::TrackRef gtrkref = mu.globalTrack();
112  if (!gtrkref.isNonnull())
113  continue;
114  const reco::Track* gtk = &(*gtrkref);
115  double chi2 = gtk->chi2();
116  double ndof = gtk->ndof();
117  double chbyndof = (ndof > 0) ? chi2 / ndof : 0;
118 
119  const reco::HitPattern& hitp = gtk->hitPattern();
120  int nPixelHits = hitp.numberOfValidPixelHits();
121  int nStripHits = hitp.numberOfValidStripHits();
122 
123  reco::TrackRef itrkref = mu.innerTrack(); // tracker segment only
124  if (!itrkref.isNonnull())
125  continue;
126  const reco::Track* tk = &(*itrkref);
127  double trkd0 = tk->d0();
128  double trkdz = tk->dz();
129  if (beamSpot.isValid()) {
130  trkd0 = -(tk->dxy(beamSpot->position()));
131  trkdz = tk->dz(beamSpot->position());
132  }
133  // Hits/section in the muon chamber
134  int nChambers = mu.numberOfChambers();
135  int nMatches = mu.numberOfMatches();
136  int nMatchedStations = mu.numberOfMatchedStations();
137 
138  // PF Isolation
139  const reco::MuonPFIsolation& pfIso04 = mu.pfIsolationR04();
140  double absiso = pfIso04.sumChargedParticlePt +
141  std::max(0.0, pfIso04.sumNeutralHadronEt + pfIso04.sumPhotonEt - 0.5 * pfIso04.sumPUPt);
142 
143  // Final selection
144  if (chbyndof < 10 && std::fabs(trkd0) < 0.02 && std::fabs(trkdz) < 20.0 && nPixelHits > 1 && nStripHits > 8 &&
145  nChambers > 2 && nMatches > 2 && nMatchedStations > 2 && absiso / mu.pt() < 0.3) {
146  TLorentzVector lm;
147  lm.SetPtEtaPhiE(mu.pt(), mu.eta(), mu.phi(), mu.energy());
148  muList.push_back(lm);
149  }
150  }
151  } else {
152  edm::LogError("WtoLNuSelector") << "Error >> Failed to get MuonCollection for label: " << muonTag_;
153  }
154 
155  // Require either a high pt electron or muon
156  if (eleList.empty() && muList.empty())
157  return false;
158 
159  // Both should not be present at the same time
160  if ((!eleList.empty() && eleList[0].Pt() > 20) && (!muList.empty() && muList[0].Pt() > 20))
161  return false;
162 
163  // find the high pt lepton
164  TLorentzVector vlep;
165  if (!eleList.empty() && !muList.empty()) {
166  vlep = (eleList[0].Pt() > muList[0].Pt()) ? eleList[0] : muList[0];
167  } else if (!eleList.empty()) {
168  vlep = eleList[0];
169  } else {
170  vlep = muList[0];
171  }
172  if (vlep.Pt() < 20)
173  return false;
174 
176  iEvent.getByToken(pfmetToken_, pfColl);
177 
178  if (pfColl.isValid()) {
179  double mt = getMt(vlep, pfColl->front());
180  if (mt < 60 || mt > 80)
181  return false;
182  } else {
183  edm::LogError("WtoLNuSelector") << "Error >> Failed to get PFMETCollection for label: " << pfmetTag_;
184  return false;
185  }
186 
187  return true;
188 }
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
int numberOfValidPixelHits() const
Definition: HitPattern.h:831
double getMt(const TLorentzVector &vlep, const reco::PFMET &obj)
float sumPUPt
sum pt of charged Particles not from PV (for Pu corrections)
Definition: GsfElectron.h:670
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
const edm::InputTag electronTag_
const edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_
Log< level::Error, false > LogError
int numberOfValidStripHits() const
Definition: HitPattern.h:843
double ndof() const
number of degrees of freedom of the fit
Definition: TrackBase.h:590
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:622
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< reco::MuonCollection > muonToken_
float sumPhotonEt
sum pt of PF photons // old float photonIso ;
Definition: GsfElectron.h:665
float sumNeutralHadronEt
sum pt of neutral hadrons // old float neutralHadronIso ;
Definition: GsfElectron.h:664
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:504
double d0() const
dxy parameter in perigee convention (d0 = -dxy)
Definition: TrackBase.h:611
double chi2() const
chi-squared of the fit
Definition: TrackBase.h:587
const edm::InputTag bsTag_
const edm::InputTag muonTag_
bool isValid() const
Definition: HandleBase.h:70
const edm::InputTag pfmetTag_
float sumChargedHadronPt
sum-pt of charged Hadron // old float chargedHadronIso ;
Definition: GsfElectron.h:663
const edm::EDGetTokenT< reco::PFMETCollection > pfmetToken_
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:608

◆ getMt()

double WtoLNuSelector::getMt ( const TLorentzVector &  vlep,
const reco::PFMET obj 
)
private

Definition at line 189 of file WtoLNuSelector.cc.

References funct::cos(), SiPixelRawToDigiRegional_cfi::deltaPhi, BTaggingMonitor_cfi::met, getGTfromDQMFile::obj, phi, funct::sin(), and mathSSE::sqrt().

Referenced by filter().

189  {
190  double met = obj.et();
191  double phi = obj.phi();
192 
193  TLorentzVector vmet;
194  double metx = met * std::cos(phi);
195  double mety = met * std::sin(phi);
196  vmet.SetPxPyPzE(metx, mety, 0.0, met);
197 
198  // transverse mass
199  TLorentzVector vw = vlep + vmet;
200 
201  return std::sqrt(2 * vlep.Et() * met * (1 - std::cos(deltaPhi(vlep.Phi(), phi))));
202 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22

Member Data Documentation

◆ bsTag_

const edm::InputTag WtoLNuSelector::bsTag_
private

Definition at line 33 of file WtoLNuSelector.h.

Referenced by filter().

◆ bsToken_

const edm::EDGetTokenT<reco::BeamSpot> WtoLNuSelector::bsToken_
private

Definition at line 37 of file WtoLNuSelector.h.

Referenced by filter().

◆ electronTag_

const edm::InputTag WtoLNuSelector::electronTag_
private

Definition at line 32 of file WtoLNuSelector.h.

Referenced by filter().

◆ electronToken_

const edm::EDGetTokenT<reco::GsfElectronCollection> WtoLNuSelector::electronToken_
private

Definition at line 36 of file WtoLNuSelector.h.

Referenced by filter().

◆ muonTag_

const edm::InputTag WtoLNuSelector::muonTag_
private

Definition at line 34 of file WtoLNuSelector.h.

Referenced by filter().

◆ muonToken_

const edm::EDGetTokenT<reco::MuonCollection> WtoLNuSelector::muonToken_
private

Definition at line 38 of file WtoLNuSelector.h.

Referenced by filter().

◆ pfmetTag_

const edm::InputTag WtoLNuSelector::pfmetTag_
private

Definition at line 35 of file WtoLNuSelector.h.

Referenced by filter().

◆ pfmetToken_

const edm::EDGetTokenT<reco::PFMETCollection> WtoLNuSelector::pfmetToken_
private

Definition at line 39 of file WtoLNuSelector.h.

Referenced by filter().