26 fixDxySign_(iConfig.getParameter<bool>(
"fixDxySign")) {
35 produces<std::vector<T>>();
47 desc.
add<
bool>(
"computeMiniIso",
false)->setComment(
"Recompute miniIsolation");
48 desc.
add<
bool>(
"fixDxySign",
false)->setComment(
"Fix the IP sign");
50 ->setComment(
"PackedCandidate collection used for miniIso");
52 desc.
add<
bool>(
"recomputeMuonBasicSelectors",
false)
53 ->setComment(
"Recompute basic cut-based muon selector flags");
54 desc.
addOptional<std::vector<double>>(
"miniIsoParams")
55 ->setComment(
"Parameters used for miniIso (as in PATMuonProducer)");
56 descriptions.
add(
"muonsUpdated", desc);
58 desc.
addOptional<std::vector<double>>(
"miniIsoParamsB")
59 ->setComment(
"Parameters used for miniIso in the barrel (as in PATElectronProducer)");
60 desc.
addOptional<std::vector<double>>(
"miniIsoParamsE")
61 ->setComment(
"Parameters used for miniIso in the endcap (as in PATElectronProducer)");
62 descriptions.
add(
"electronsUpdated", desc);
71 throw cms::Exception(
"ParameterError",
"miniIsoParams must have exactly 9 elements.\n");
105 miniIsoParams_[0] = iConfig.
getParameter<std::vector<double>>(
"miniIsoParamsB");
106 miniIsoParams_[1] = iConfig.
getParameter<std::vector<double>>(
"miniIsoParamsE");
107 if (miniIsoParams_[0].
size() != 9)
108 throw cms::Exception(
"ParameterError",
"miniIsoParamsB must have exactly 9 elements.\n");
109 if (miniIsoParams_[1].
size() != 9)
110 throw cms::Exception(
"ParameterError",
"miniIsoParamsE must have exactly 9 elements.\n");
114 return miniIsoParams_[lep.
isEE()];
117 template <
typename T>
120 const bool do_hip_mitigation_2016)
const {}
125 const bool do_hip_mitigation_2016)
const {
131 template <
typename T>
145 iEvent.
getByToken(beamLineToken_, beamSpotHandle);
147 bool beamSpotIsValid =
false;
148 if (beamSpotHandle.
isValid()) {
149 beamSpot = *beamSpotHandle;
150 beamSpotIsValid =
true;
152 edm::LogError(
"DataNotAvailable") <<
"No beam spot available \n";
155 std::unique_ptr<std::vector<T>>
out(
new std::vector<T>(*src));
157 const bool do_hip_mitigation_2016 =
158 recomputeMuonBasicSelectors_ && (272728 <= iEvent.
run() && iEvent.
run() <= 278808);
160 for (
unsigned int i = 0,
n = src->size();
i <
n; ++
i) {
163 if (computeMiniIso_) {
164 const auto &
params = miniIsoParams(lep);
176 lep.setMiniPFIsolation(miniiso);
178 if (recomputeMuonBasicSelectors_)
179 recomputeMuonBasicSelectors(lep, pv, do_hip_mitigation_2016);
184 if (beamSpotIsValid) {
185 if constexpr (std::is_same_v<T, pat::Electron>)
186 signBS = copysign(1., lep.gsfTrack()->dxy(beamSpot));
188 signBS = copysign(1., lep.bestTrack()->dxy(beamSpot));
190 if constexpr (std::is_same_v<T, pat::Electron>)
191 signPV = copysign(1., lep.gsfTrack()->dxy(pv.
position()));
193 signPV = copysign(1., lep.bestTrack()->dxy(pv.
position()));
194 lep.setDB(
abs(lep.dB(T::PV2D)) * signPV, lep.edB(T::PV2D), T::PV2D);
195 lep.setDB(
abs(lep.dB(T::BS2D)) * signBS, lep.edB(T::BS2D), T::BS2D);
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
double zError() const
error on z
pat::LeptonUpdater< pat::Electron > PATElectronUpdater
#define DEFINE_FWK_MODULE(type)
LeptonUpdater(const edm::ParameterSet &iConfig)
reco::GsfTrackRef gsfTrack() const override
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
Log< level::Error, false > LogError
reco::Muon::Selector makeSelectorBitset(reco::Muon const &muon, reco::Vertex const *vertex=nullptr, bool run2016_hip_mitigation=false)
const Point & position() const
position
edm::EDGetTokenT< std::vector< T > > src_
pat::LeptonUpdater< pat::Muon > PATMuonUpdater
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< reco::BeamSpot > beamLineToken_
void setDB(double dB, double edB, IPTYPE type)
Set impact parameter of a certain type and its uncertainty.
void setDB(double dB, double edB, IPTYPE type=PV2D)
bool recomputeMuonBasicSelectors_
void setSelectors(uint64_t selectors)
~LeptonUpdater() override
Abs< T >::type abs(const T &t)
void setDZ(T &lep, const reco::Vertex &pv) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void recomputeMuonBasicSelectors(T &, const reco::Vertex &, const bool) const
edm::EDGetTokenT< pat::PackedCandidateCollection > pcToken_
T const * product() const
T getParameter(std::string const &) const
Analysis-level electron class.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const std::vector< double > & miniIsoParams(const T &lep) const
void readMiniIsoParams(const edm::ParameterSet &iConfig)
std::vector< double > miniIsoParams_[2]
PFIsolation getMiniPFIsolation(const pat::PackedCandidateCollection *pfcands, const reco::Candidate::PolarLorentzVector &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)
reco::TrackRef muonBestTrack() const override
Track selected to be the best measurement of the muon parameters (including PFlow global information)...
Analysis-level muon class.
edm::EDGetTokenT< std::vector< reco::Vertex > > vertices_
tuple size
Write out results.