53 produces<edm::ValueMap<float>>(
"ptRatio");
54 produces<edm::ValueMap<float>>(
"ptRel");
55 produces<edm::ValueMap<float>>(
"jetNDauChargedMVASel");
56 produces<edm::ValueMap<reco::CandidatePtr>>(
"jetForLepJetVar");
98 unsigned int nJet =
srcJet->size();
99 unsigned int nLep =
srcLep->size();
101 std::vector<float>
ptRatio(nLep, -1);
102 std::vector<float>
ptRel(nLep, -1);
106 const auto&
pv = (*srcVtx)[0];
108 for (
unsigned int il = 0; il < nLep; il++) {
109 for (
unsigned int ij = 0; ij < nJet; ij++) {
110 auto lep =
srcLep->ptrAt(il);
113 auto res = calculatePtRatioRel(lep,
jet,
pv);
144 fillerjetForLepJetVar.
fill();
148 template <
typename T>
152 auto rawp4 =
jet->correctedP4(
"Uncorrected");
153 auto lepp4 = lep->
p4();
155 if ((rawp4 - lepp4).
R() < 1
e-4)
156 return std::tuple<float, float, float>(1.0, 0.0, 0.0);
158 auto l1corrFactor =
jet->jecFactor(
"L1FastJet") /
jet->jecFactor(
"Uncorrected");
160 auto jetp4 = (rawp4 - lepp4 * (1.0 / l1corrFactor)) * (
jet->pt() / rawp4.pt()) + lepp4;
161 auto ptratio = lepp4.pt() / jetp4.pt();
162 auto ptrel = lepp4.Vect().Cross((jetp4 - lepp4).Vect().Unit()).R();
164 unsigned int jndau = 0;
165 for (
const auto& _d :
jet->daughterPtrVector()) {
167 if (
d->charge() == 0)
169 if (
d->fromPV() <= 1)
173 if (!(
d->hasTrackDetails()))
175 auto tk =
d->pseudoTrack();
176 if (tk.pt() > 1 && tk.hitPattern().numberOfValidHits() >= 8 && tk.hitPattern().numberOfValidPixelHits() >= 2 &&
177 tk.normalizedChi2() < 5 && fabs(tk.dxy(
vtx.position())) < 0.2 && fabs(tk.dz(
vtx.position())) < 17)
181 return std::tuple<float, float, float>(ptratio, ptrel,
float(jndau));
185 template <
typename T>
192 desc.add<
edm::InputTag>(
"srcVtx")->setComment(
"primary vertex input collection");
std::tuple< float, float, float > calculatePtRatioRel(edm::Ptr< reco::Candidate > lep, edm::Ptr< pat::Jet > jet, const reco::Vertex &vtx) const
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
#define DEFINE_FWK_MODULE(type)
void insert(const H &h, I begin, I end)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
LeptonJetVarProducer< pat::Electron > ElectronJetVarProducer
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< std::vector< reco::Vertex > > srcVtx_
bool matchByCommonSourceCandidatePtr(const C1 &c1, const C2 &c2)
~LeptonJetVarProducer() override
LeptonJetVarProducer(const edm::ParameterSet &iConfig)
Analysis-level electron class.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< edm::View< pat::Jet > > srcJet_
Analysis-level muon class.
LeptonJetVarProducer< pat::Muon > MuonJetVarProducer
edm::EDGetTokenT< edm::View< T > > srcLep_
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector