CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
pat::LeptonUpdater< T > Class Template Reference
Inheritance diagram for pat::LeptonUpdater< T >:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 LeptonUpdater (const edm::ParameterSet &iConfig)
 
const std::vector< double > & miniIsoParams (const T &lep) const
 
template<>
const std::vector< double > & miniIsoParams (const pat::Electron &lep) const
 
void produce (edm::StreamID, edm::Event &, edm::EventSetup const &) const override
 
void readMiniIsoParams (const edm::ParameterSet &iConfig)
 
template<>
void readMiniIsoParams (const edm::ParameterSet &iConfig)
 
void recomputeMuonBasicSelectors (T &, const reco::Vertex &, const bool) const
 
template<>
void recomputeMuonBasicSelectors (pat::Muon &lep, const reco::Vertex &pv, const bool do_hip_mitigation_2016) const
 
void setDZ (T &lep, const reco::Vertex &pv) const
 
template<>
void setDZ (pat::Electron &anElectron, const reco::Vertex &pv) const
 
template<>
void setDZ (pat::Muon &aMuon, const reco::Vertex &pv) const
 
 ~LeptonUpdater () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () 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
 
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)
 
 ~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
 
ESProxyIndex const * esGetTokenIndices (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::vector< ModuleDescription const * > &modules, 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
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

bool computeMiniIso_
 
std::vector< double > miniIsoParams_ [2]
 
edm::EDGetTokenT< pat::PackedCandidateCollectionpcToken_
 
bool recomputeMuonBasicSelectors_
 
edm::EDGetTokenT< std::vector< T > > src_
 
edm::EDGetTokenT< std::vector< reco::Vertex > > vertices_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
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
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

template<typename T>
class pat::LeptonUpdater< T >

Definition at line 18 of file LeptonUpdater.cc.

Constructor & Destructor Documentation

template<typename T >
pat::LeptonUpdater< T >::LeptonUpdater ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 20 of file LeptonUpdater.cc.

References pat::LeptonUpdater< T >::computeMiniIso_, edm::ParameterSet::getParameter(), pat::LeptonUpdater< T >::pcToken_, pat::LeptonUpdater< T >::readMiniIsoParams(), and pat::LeptonUpdater< T >::recomputeMuonBasicSelectors_.

21  : src_(consumes<std::vector<T>>(iConfig.getParameter<edm::InputTag>("src"))),
22  vertices_(consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("vertices"))),
23  computeMiniIso_(iConfig.getParameter<bool>("computeMiniIso")) {
24  //for mini-isolation calculation
25  if (computeMiniIso_) {
26  readMiniIsoParams(iConfig);
27  pcToken_ = consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("pfCandsForMiniIso"));
28  }
30  if (typeid(T) == typeid(pat::Muon))
31  recomputeMuonBasicSelectors_ = iConfig.getParameter<bool>("recomputeMuonBasicSelectors");
32  produces<std::vector<T>>();
33  }
T getParameter(std::string const &) const
edm::EDGetTokenT< std::vector< T > > src_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
bool recomputeMuonBasicSelectors_
edm::EDGetTokenT< pat::PackedCandidateCollection > pcToken_
void readMiniIsoParams(const edm::ParameterSet &iConfig)
long double T
Analysis-level muon class.
Definition: Muon.h:51
edm::EDGetTokenT< std::vector< reco::Vertex > > vertices_
template<typename T >
pat::LeptonUpdater< T >::~LeptonUpdater ( )
inlineoverride

Definition at line 35 of file LeptonUpdater.cc.

References pat::LeptonUpdater< T >::produce().

35 {}

Member Function Documentation

template<typename T >
static void pat::LeptonUpdater< T >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 39 of file LeptonUpdater.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), and HLT_2018_cff::InputTag.

39  {
41  desc.add<edm::InputTag>("src")->setComment("Lepton collection");
42  desc.add<edm::InputTag>("vertices")->setComment("Vertex collection");
43  desc.add<bool>("computeMiniIso", false)->setComment("Recompute miniIsolation");
44  desc.addOptional<edm::InputTag>("pfCandsForMiniIso", edm::InputTag("packedPFCandidates"))
45  ->setComment("PackedCandidate collection used for miniIso");
46  if (typeid(T) == typeid(pat::Muon)) {
47  desc.add<bool>("recomputeMuonBasicSelectors", false)
48  ->setComment("Recompute basic cut-based muon selector flags");
49  desc.addOptional<std::vector<double>>("miniIsoParams")
50  ->setComment("Parameters used for miniIso (as in PATMuonProducer)");
51  descriptions.add("muonsUpdated", desc);
52  } else if (typeid(T) == typeid(pat::Electron)) {
53  desc.addOptional<std::vector<double>>("miniIsoParamsB")
54  ->setComment("Parameters used for miniIso in the barrel (as in PATElectronProducer)");
55  desc.addOptional<std::vector<double>>("miniIsoParamsE")
56  ->setComment("Parameters used for miniIso in the endcap (as in PATElectronProducer)");
57  descriptions.add("electronsUpdated", desc);
58  }
59  }
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Analysis-level electron class.
Definition: Electron.h:51
void add(std::string const &label, ParameterSetDescription const &psetDescription)
long double T
Analysis-level muon class.
Definition: Muon.h:51
template<typename T >
const std::vector<double>& pat::LeptonUpdater< T >::miniIsoParams ( const T lep) const
inline
template<>
const std::vector< double > & pat::LeptonUpdater< pat::Electron >::miniIsoParams ( const pat::Electron lep) const

Definition at line 106 of file LeptonUpdater.cc.

References reco::GsfElectron::isEE(), and pat::LeptonUpdater< T >::miniIsoParams_.

106  {
107  return miniIsoParams_[lep.isEE()];
108  }
bool isEE() const
Definition: GsfElectron.h:329
std::vector< double > miniIsoParams_[2]
template<typename T >
void pat::LeptonUpdater< T >::produce ( edm::StreamID  ,
edm::Event iEvent,
edm::EventSetup const &   
) const
overridevirtual

Implements edm::global::EDProducerBase.

Definition at line 125 of file LeptonUpdater.cc.

References pat::LeptonUpdater< T >::computeMiniIso_, edm::Event::getByToken(), pat::getMiniPFIsolation(), mps_fire::i, pat::LeptonUpdater< T >::miniIsoParams(), eostools::move(), dqmiodumpmetadata::n, MillePedeFileConverter_cfg::out, CalibrationSummaryClient_cfi::params, pat::LeptonUpdater< T >::pcToken_, edm::Handle< T >::product(), edm::Event::put(), MetAnalyzer::pv(), pat::LeptonUpdater< T >::recomputeMuonBasicSelectors(), pat::LeptonUpdater< T >::recomputeMuonBasicSelectors_, edm::Event::run(), pat::LeptonUpdater< T >::setDZ(), TrackRefitter_38T_cff::src, pat::LeptonUpdater< T >::src_, pwdgSkimBPark_cfi::vertices, and pat::LeptonUpdater< T >::vertices_.

Referenced by pat::LeptonUpdater< T >::~LeptonUpdater().

125  {
127  iEvent.getByToken(src_, src);
128 
130  iEvent.getByToken(vertices_, vertices);
131  const reco::Vertex &pv = vertices->front();
132 
134  if (computeMiniIso_)
135  iEvent.getByToken(pcToken_, pc);
136 
137  std::unique_ptr<std::vector<T>> out(new std::vector<T>(*src));
138 
139  const bool do_hip_mitigation_2016 =
140  recomputeMuonBasicSelectors_ && (272728 <= iEvent.run() && iEvent.run() <= 278808);
141 
142  for (unsigned int i = 0, n = src->size(); i < n; ++i) {
143  T &lep = (*out)[i];
144  setDZ(lep, pv);
145  if (computeMiniIso_) {
146  const auto &params = miniIsoParams(lep);
148  lep.p4(),
149  params[0],
150  params[1],
151  params[2],
152  params[3],
153  params[4],
154  params[5],
155  params[6],
156  params[7],
157  params[8]);
158  lep.setMiniPFIsolation(miniiso);
159  }
161  recomputeMuonBasicSelectors(lep, pv, do_hip_mitigation_2016);
162  }
163 
164  iEvent.put(std::move(out));
165 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::EDGetTokenT< std::vector< T > > src_
bool recomputeMuonBasicSelectors_
RunNumber_t run() const
Definition: Event.h:107
def pv(vc)
Definition: MetAnalyzer.py:7
void setDZ(T &lep, const reco::Vertex &pv) const
void recomputeMuonBasicSelectors(T &, const reco::Vertex &, const bool) const
edm::EDGetTokenT< pat::PackedCandidateCollection > pcToken_
T const * product() const
Definition: Handle.h:69
const std::vector< double > & miniIsoParams(const T &lep) const
PFIsolation getMiniPFIsolation(const pat::PackedCandidateCollection *pfcands, const math::XYZTLorentzVector &p4, float mindr=0.05, float maxdr=0.2, float kt_scale=10.0, float ptthresh=0.5, float deadcone_ch=0.0001, float deadcone_pu=0.01, float deadcone_ph=0.01, float deadcone_nh=0.01, float dZ_cut=0.0)
long double T
edm::EDGetTokenT< std::vector< reco::Vertex > > vertices_
def move(src, dest)
Definition: eostools.py:511
template<typename T >
void pat::LeptonUpdater< T >::readMiniIsoParams ( const edm::ParameterSet iConfig)
inline

Definition at line 63 of file LeptonUpdater.cc.

References edm::ParameterSet::getParameter(), pat::LeptonUpdater< T >::miniIsoParams_, and findQualityFiles::size.

Referenced by pat::LeptonUpdater< T >::LeptonUpdater().

63  {
64  miniIsoParams_[0] = iConfig.getParameter<std::vector<double>>("miniIsoParams");
65  if (miniIsoParams_[0].size() != 9)
66  throw cms::Exception("ParameterError", "miniIsoParams must have exactly 9 elements.\n");
67  }
size
Write out results.
T getParameter(std::string const &) const
std::vector< double > miniIsoParams_[2]
template<>
void pat::LeptonUpdater< pat::Electron >::readMiniIsoParams ( const edm::ParameterSet iConfig)

Definition at line 97 of file LeptonUpdater.cc.

References edm::ParameterSet::getParameter(), pat::LeptonUpdater< T >::miniIsoParams_, and findQualityFiles::size.

97  {
98  miniIsoParams_[0] = iConfig.getParameter<std::vector<double>>("miniIsoParamsB");
99  miniIsoParams_[1] = iConfig.getParameter<std::vector<double>>("miniIsoParamsE");
100  if (miniIsoParams_[0].size() != 9)
101  throw cms::Exception("ParameterError", "miniIsoParamsB must have exactly 9 elements.\n");
102  if (miniIsoParams_[1].size() != 9)
103  throw cms::Exception("ParameterError", "miniIsoParamsE must have exactly 9 elements.\n");
104  }
size
Write out results.
T getParameter(std::string const &) const
std::vector< double > miniIsoParams_[2]
template<typename T >
void pat::LeptonUpdater< T >::recomputeMuonBasicSelectors ( T lep,
const reco::Vertex pv,
const bool  do_hip_mitigation_2016 
) const

Definition at line 111 of file LeptonUpdater.cc.

Referenced by pat::LeptonUpdater< T >::miniIsoParams(), and pat::LeptonUpdater< T >::produce().

113  {}
template<>
void pat::LeptonUpdater< pat::Muon >::recomputeMuonBasicSelectors ( pat::Muon lep,
const reco::Vertex pv,
const bool  do_hip_mitigation_2016 
) const

Definition at line 116 of file LeptonUpdater.cc.

References muon::makeSelectorBitset(), and reco::Muon::setSelectors().

118  {
119  lep.setSelectors(muon::makeSelectorBitset(lep, &pv, do_hip_mitigation_2016));
120  }
void setSelectors(uint64_t selectors)
Definition: Muon.h:240
reco::Muon::Selector makeSelectorBitset(reco::Muon const &muon, reco::Vertex const *vertex=0, bool run2016_hip_mitigation=false)
template<typename T >
void pat::LeptonUpdater< T >::setDZ ( T lep,
const reco::Vertex pv 
) const
inline

Definition at line 61 of file LeptonUpdater.cc.

Referenced by pat::LeptonUpdater< T >::produce().

61 {}
template<>
void pat::LeptonUpdater< pat::Electron >::setDZ ( pat::Electron anElectron,
const reco::Vertex pv 
) const

Definition at line 85 of file LeptonUpdater.cc.

References pat::Electron::gsfTrack(), reco::Vertex::position(), pat::Electron::PVDZ, pat::Electron::setDB(), HLT_2018_cff::track, and reco::Vertex::zError().

85  {
86  auto track = anElectron.gsfTrack();
87  anElectron.setDB(track->dz(pv.position()), std::hypot(track->dzError(), pv.zError()), pat::Electron::PVDZ);
88  }
double zError() const
error on z
Definition: Vertex.h:127
const Point & position() const
position
Definition: Vertex.h:113
void setDB(double dB, double edB, IPTYPE type)
Set impact parameter of a certain type and its uncertainty.
reco::GsfTrackRef gsfTrack() const override
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
template<>
void pat::LeptonUpdater< pat::Muon >::setDZ ( pat::Muon aMuon,
const reco::Vertex pv 
) const

Definition at line 91 of file LeptonUpdater.cc.

References pat::Muon::muonBestTrack(), reco::Vertex::position(), pat::Muon::PVDZ, pat::Muon::setDB(), HLT_2018_cff::track, and reco::Vertex::zError().

91  {
92  auto track = aMuon.muonBestTrack();
93  aMuon.setDB(track->dz(pv.position()), std::hypot(track->dzError(), pv.zError()), pat::Muon::PVDZ);
94  }
double zError() const
error on z
Definition: Vertex.h:127
const Point & position() const
position
Definition: Vertex.h:113
void setDB(double dB, double edB, IPTYPE type=PV2D)
Definition: Muon.h:245
reco::TrackRef muonBestTrack() const override
Track selected to be the best measurement of the muon parameters (including PFlow global information)...

Member Data Documentation

template<typename T >
bool pat::LeptonUpdater< T >::computeMiniIso_
private
template<typename T >
std::vector<double> pat::LeptonUpdater< T >::miniIsoParams_[2]
private
template<typename T >
edm::EDGetTokenT<pat::PackedCandidateCollection> pat::LeptonUpdater< T >::pcToken_
private
template<typename T >
bool pat::LeptonUpdater< T >::recomputeMuonBasicSelectors_
private
template<typename T >
edm::EDGetTokenT<std::vector<T> > pat::LeptonUpdater< T >::src_
private

Definition at line 74 of file LeptonUpdater.cc.

Referenced by pat::LeptonUpdater< T >::produce().

template<typename T >
edm::EDGetTokenT<std::vector<reco::Vertex> > pat::LeptonUpdater< T >::vertices_
private

Definition at line 75 of file LeptonUpdater.cc.

Referenced by pat::LeptonUpdater< T >::produce().