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);
163 auto jetp4 = (rawp4 - lepp4*(1.0/jet->
jecFactor(
"L1FastJet")))*(jet->
pt()/rawp4.pt())+lepp4;
164 auto ptratio = lepp4.pt()/jetp4.pt();
165 auto ptrel = lepp4.Vect().Cross((jetp4-lepp4).Vect().Unit()).R();
167 unsigned int jndau = 0;
170 if (
d->charge()==0)
continue;
171 if (
d->fromPV()<=1)
continue;
172 if (
deltaR(*
d,*lep)>0.4)
continue;
173 if (!(
d->hasTrackDetails()))
continue;
174 auto tk =
d->pseudoTrack();
176 tk.hitPattern().numberOfValidHits()>=8 &&
177 tk.hitPattern().numberOfValidPixelHits()>=2 &&
178 tk.normalizedChi2()<5 &&
184 return std::tuple<float,float,float>(ptratio,ptrel,
float(jndau));
188 template <
typename T>
196 desc.
add<
edm::InputTag>(
"srcVtx")->setComment(
"primary vertex input collection");
198 if (
typeid(
T) ==
typeid(
pat::Muon)) modname+=
"Muon";
200 modname+=
"JetVarProducer";
201 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
#define DEFINE_FWK_MODULE(type)
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_
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)
double deltaR(double eta1, double eta2, double phi1, double phi2)
LeptonJetVarProducer(const edm::ParameterSet &iConfig)
float ptRel(const reco::Candidate::LorentzVector &muP4, const reco::Candidate::LorentzVector &jetP4, bool subtractMuon=true)
Analysis-level electron class.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< edm::View< pat::Jet > > srcJet_
const daughters & daughterPtrVector() const
references to daughtes
float jecFactor(const std::string &level, const std::string &flavor="none", const std::string &set="") const
Analysis-level muon class.
LeptonJetVarProducer< pat::Muon > MuonJetVarProducer
edm::EDGetTokenT< edm::View< T > > srcLep_