55 produces<edm::ValueMap<float>>(
"ptRatio");
56 produces<edm::ValueMap<float>>(
"ptRel");
57 produces<edm::ValueMap<float>>(
"jetNDauChargedMVASel");
58 produces<edm::ValueMap<reco::CandidatePtr>>(
"jetForLepJetVar");
102 unsigned int nJet = srcJet->size();
103 unsigned int nLep = srcLep->size();
105 std::vector<float>
ptRatio(nLep,-1);
106 std::vector<float>
ptRel(nLep,-1);
110 const auto &
pv = (*srcVtx)[0];
112 for (
unsigned int il = 0; il<nLep; il++){
113 for (
unsigned int ij = 0; ij<nJet; ij++){
114 auto lep = srcLep->ptrAt(il);
115 auto jet = srcJet->ptrAt(ij);
118 ptRatio[il] = std::get<0>(
res);
119 ptRel[il] = std::get<1>(
res);
120 jetNDauChargedMVASel[il] = std::get<2>(
res);
121 jetForLepJetVar[il] =
jet;
129 fillerRatio.
insert(srcLep,ptRatio.begin(),ptRatio.end());
135 fillerRel.
insert(srcLep,ptRel.begin(),ptRel.end());
141 fillerNDau.
insert(srcLep,jetNDauChargedMVASel.begin(),jetNDauChargedMVASel.end());
143 iEvent.
put(
std::move(jetNDauChargedMVASelV),
"jetNDauChargedMVASel");
147 fillerjetForLepJetVar.
insert(srcLep,jetForLepJetVar.begin(),jetForLepJetVar.end());
148 fillerjetForLepJetVar.
fill();
149 iEvent.
put(
std::move(jetForLepJetVarV),
"jetForLepJetVar");
154 template <
typename T>
155 std::tuple<float,float,float>
159 auto lepp4 = lep->
p4();
161 if ((rawp4-lepp4).
R()<1
e-4)
return std::tuple<float,float,float>(1.0,0.0,0.0);
165 auto jetp4 = (rawp4 - lepp4*(1.0/l1corrFactor))*(jet->
pt()/rawp4.pt())+lepp4;
166 auto ptratio = lepp4.pt()/jetp4.pt();
167 auto ptrel = lepp4.Vect().Cross((jetp4-lepp4).Vect().Unit()).R();
169 unsigned int jndau = 0;
172 if (
d->charge()==0)
continue;
173 if (
d->fromPV()<=1)
continue;
174 if (
deltaR(*
d,*lep)>0.4)
continue;
175 if (!(
d->hasTrackDetails()))
continue;
176 auto tk =
d->pseudoTrack();
178 tk.hitPattern().numberOfValidHits()>=8 &&
179 tk.hitPattern().numberOfValidPixelHits()>=2 &&
180 tk.normalizedChi2()<5 &&
186 return std::tuple<float,float,float>(ptratio,ptrel,
float(jndau));
190 template <
typename T>
198 desc.
add<
edm::InputTag>(
"srcVtx")->setComment(
"primary vertex input collection");
200 if (
typeid(
T) ==
typeid(
pat::Muon)) modname+=
"Muon";
202 modname+=
"JetVarProducer";
203 descriptions.
add(modname,desc);
const LorentzVector correctedP4(const std::string &level, const std::string &flavor="none", const std::string &set="") const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void insert(const H &h, I begin, I end)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double pt() const final
transverse momentum
std::tuple< float, float, float > calculatePtRatioRel(edm::Ptr< reco::Candidate > lep, edm::Ptr< pat::Jet > jet, const reco::Vertex &vtx) const
const Point & position() const
position
LeptonJetVarProducer< pat::Electron > ElectronJetVarProducer
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< std::vector< reco::Vertex > > srcVtx_
#define DEFINE_FWK_MODULE(type)
bool matchByCommonSourceCandidatePtr(const C1 &c1, const C2 &c2)
~LeptonJetVarProducer() override
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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_
float jecFactor(const std::string &level, const std::string &flavor="none", const std::string &set="") const
const reco::CompositePtrCandidate::daughters & daughterPtrVector() const override
references to daughtes
Analysis-level muon class.
LeptonJetVarProducer< pat::Muon > MuonJetVarProducer
edm::EDGetTokenT< edm::View< T > > srcLep_