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");
93 const auto& vtxProd =
iEvent.get(srcVtx_);
95 unsigned int nJet =
srcJet->size();
96 unsigned int nLep =
srcLep->size();
98 std::vector<float>
ptRatio(nLep, -1);
99 std::vector<float>
ptRel(nLep, -1);
103 const auto&
pv = vtxProd.at(0);
105 for (
unsigned int il = 0; il < nLep; il++) {
106 for (
unsigned int ij = 0; ij < nJet; ij++) {
107 auto lep =
srcLep->ptrAt(il);
110 auto res = calculatePtRatioRel(lep,
jet,
pv);
120 auto ptRatioV = std::make_unique<edm::ValueMap<float>>();
126 auto ptRelV = std::make_unique<edm::ValueMap<float>>();
132 auto jetNDauChargedMVASelV = std::make_unique<edm::ValueMap<float>>();
138 auto jetForLepJetVarV = std::make_unique<edm::ValueMap<reco::CandidatePtr>>();
141 fillerjetForLepJetVar.fill();
145 template <
typename T>
149 auto rawp4 =
jet->correctedP4(
"Uncorrected");
150 auto lepp4 = lep->
p4();
152 if ((rawp4 - lepp4).
R() < 1
e-4)
153 return std::tuple<float, float, float>(1.0, 0.0, 0.0);
155 auto l1corrFactor =
jet->jecFactor(
"L1FastJet") /
jet->jecFactor(
"Uncorrected");
157 auto jetp4 = (rawp4 - lepp4 * (1.0 / l1corrFactor)) * (
jet->pt() / rawp4.pt()) + lepp4;
158 auto ptratio = lepp4.pt() / jetp4.pt();
159 auto ptrel = lepp4.Vect().Cross((jetp4 - lepp4).Vect().Unit()).R();
161 unsigned int jndau = 0;
162 for (
const auto& _d :
jet->daughterPtrVector()) {
164 if (
d->charge() == 0)
166 if (
d->fromPV() <= 1)
170 if (!(
d->hasTrackDetails()))
172 auto tk =
d->pseudoTrack();
173 if (tk.pt() > 1 && tk.hitPattern().numberOfValidHits() >= 8 && tk.hitPattern().numberOfValidPixelHits() >= 2 &&
174 tk.normalizedChi2() < 5 && fabs(tk.dxy(
vtx.position())) < 0.2 && fabs(tk.dz(
vtx.position())) < 17)
178 return std::tuple<float, float, float>(ptratio, ptrel,
float(jndau));
182 template <
typename T>
189 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
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
#define DEFINE_FWK_MODULE(type)
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