46 produces<std::vector<pat::GenericParticle>>();
47 produces<edm::ValueMap<int>>(
"muFsrIndex");
48 produces<edm::ValueMap<int>>(
"eleFsrIndex");
53 ->setComment(
"packed pf candidates where to look for photons");
56 "electrons to check for footprint, the electron collection must have proper linking with the "
57 "packedCandidate collection");
59 ->setComment(
"collection of muons to match with FSR ");
61 ->setComment(
"collection of electrons to match with FSR ");
62 desc.
add<
double>(
"muonPtMin", 3.)->
setComment(
"minimum pt of the muon to look for a near photon");
63 desc.
add<
double>(
"muonEtaMax", 2.4)->
setComment(
"max eta of the muon to look for a near photon");
64 desc.
add<
double>(
"elePtMin", 5.)->
setComment(
"minimum pt of the electron to look for a near photon");
65 desc.
add<
double>(
"eleEtaMax", 2.5)->
setComment(
"max eta of the electron to look for a near photon");
66 desc.
add<
double>(
"photonPtMin", 2.0)->
setComment(
"minimum photon Pt");
67 desc.
add<
double>(
"deltaROverEt2Max", 0.05)->
setComment(
"max ratio of deltaR(lep,photon) over et2 of the photon");
68 desc.
add<
double>(
"isolation", 2.0)->
setComment(
"photon relative isolation cut");
79 const double& isoConeMax2,
80 const double& isoConeMin2)
const;
113 auto fsrPhotons = std::make_unique<std::vector<pat::GenericParticle>>();
115 std::vector<int> muPhotonIdxs(
muons->size(), -1);
116 std::vector<double> muPhotonDRET2(
muons->size(), 1e9);
118 std::vector<int> elePhotonIdxs(
electrons->size(), -1);
119 std::vector<double> elePhotonDRET2(
electrons->size(), 1e9);
136 double photon_relIso03 = 1e9;
137 bool skipPhoton =
false;
144 double dR =
deltaR(
muon->eta(),
muon->phi(), pc->eta(), pc->phi());
145 if (dR < dRMin && dR >
drSafe && dR < drEtCut * pc->
pt() * pc->pt()) {
148 if (photon_relIso03 >
isoCut) {
172 double dR =
deltaR(ele->eta(), ele->phi(), pc->eta(), pc->phi());
173 if (dR < dRMin && dR >
drSafe && dR < drEtCut * pc->
pt() * pc->pt()) {
175 if (photon_relIso03 > 1e8) {
178 if (photon_relIso03 >
isoCut) {
194 if (closestMu >= 0 || closestEle >= 0) {
196 double dRET2 = dRMin / pc->pt() / pc->pt();
197 int iPhoton = fsrPhotons->size();
199 fsrPhotons->back().addUserFloat(
"relIso03", photon_relIso03);
200 fsrPhotons->back().addUserFloat(
"dROverEt2", dRET2);
202 if (closestMu >= 0) {
205 if (dRET2 < muPhotonDRET2[closestMu]) {
206 muPhotonDRET2[closestMu] = dRET2;
207 muPhotonIdxs[closestMu] = iPhoton;
209 }
else if (closestEle >= 0) {
212 if (dRET2 < elePhotonDRET2[closestEle]) {
213 elePhotonDRET2[closestEle] = dRET2;
214 elePhotonIdxs[closestEle] = iPhoton;
225 fillerBareIdx.
insert(
muons, muPhotonIdxs.begin(), muPhotonIdxs.end());
226 fillerBareIdx.
fill();
233 fillerBareIdx.
insert(
electrons, elePhotonIdxs.begin(), elePhotonIdxs.end());
234 fillerBareIdx.
fill();
241 const double& isoConeMax2,
242 const double& isoConeMin2)
const {
245 for (
const auto& pfcand : pfcands) {
247 double dRIsoCone2 =
deltaR2(photon.
eta(), photon.
phi(), pfcand.eta(), pfcand.phi());
248 if (dRIsoCone2 > isoConeMax2 || dRIsoCone2 < isoConeMin2)
252 if (pfcand.charge() != 0 &&
abs(pfcand.pdgId()) == 211 && pfcand.pt() > 0.2 && dRIsoCone2 >
drSafe *
drSafe) {
253 ptsum += pfcand.pt();
255 }
else if (pfcand.charge() == 0 && (
abs(pfcand.pdgId()) == 22 ||
abs(pfcand.pdgId()) == 130) && pfcand.pt() > 0.5 &&
256 dRIsoCone2 > 0.01 * 0.01) {
257 ptsum += pfcand.pt();
261 return ptsum / photon.
pt();
266 bool skipPhoton =
false;
267 for (
auto electrons_iter = electronsForVeto->begin(); electrons_iter != electronsForVeto->end(); ++electrons_iter) {
268 for (
auto const& cand : electrons_iter->associatedPackedPFCandidates()) {
269 if (!cand.isAvailable())
271 if (cand.id() != pfcandRef.
id())
273 <<
"The electron associatedPackedPFCandidates item does not have "
274 <<
"the same ID of packed candidate collection used for cleaning the electron footprint: " << cand.id()
275 <<
" (" << pfcandRef.
id() <<
")\n";
276 if (cand.key() == pfcandRef.
key()) {
void setComment(std::string const &value)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool electronFootprintVeto(pat::PackedCandidateRef &pfcandRef, edm::Handle< pat::ElectronCollection > electronsForVeto) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
#define DEFINE_FWK_MODULE(type)
std::vector< pat::PackedCandidate > PackedCandidateCollection
void insert(const H &h, I begin, I end)
const edm::EDGetTokenT< pat::PackedCandidateCollection > pfcands_
key_type key() const
Accessor for product key.
ProductID id() const
Accessor for product ID.
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed) ...
~LeptonFSRProducer() override=default
double computeRelativeIsolation(const pat::PackedCandidate &photon, const pat::PackedCandidateCollection &pfcands, const double &isoConeMax2, const double &isoConeMin2) const
double eta() const override
momentum pseudorapidity
edm::Ref< pat::PackedCandidateCollection > PackedCandidateRef
Abs< T >::type abs(const T &t)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const edm::EDGetTokenT< edm::View< reco::Muon > > muons_
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
const edm::EDGetTokenT< pat::ElectronCollection > electronsForVeto_
double pt() const override
transverse momentum
T getParameter(std::string const &) const
LeptonFSRProducer(const edm::ParameterSet &iConfig)
double phi() const override
momentum azimuthal angle
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > electrons_