85 produces<edm::ValueMap<float>>(
"leptonPtRel");
86 produces<edm::ValueMap<float>>(
"leptonPtRatio");
87 produces<edm::ValueMap<float>>(
"leptonPtRelInv");
88 produces<edm::ValueMap<float>>(
"leptonPtRelv0");
89 produces<edm::ValueMap<float>>(
"leptonPtRatiov0");
90 produces<edm::ValueMap<float>>(
"leptonPtRelInvv0");
91 produces<edm::ValueMap<float>>(
"leptonPt");
92 produces<edm::ValueMap<int>>(
"leptonPdgId");
93 produces<edm::ValueMap<float>>(
"leptonDeltaR");
94 produces<edm::ValueMap<float>>(
"leadTrackPt");
95 produces<edm::ValueMap<float>>(
"vtxPt");
96 produces<edm::ValueMap<float>>(
"vtxMass");
97 produces<edm::ValueMap<float>>(
"vtx3dL");
98 produces<edm::ValueMap<float>>(
"vtx3deL");
99 produces<edm::ValueMap<int>>(
"vtxNtrk");
100 produces<edm::ValueMap<float>>(
"ptD");
101 produces<edm::ValueMap<float>>(
"genPtwNu");
137 template <
typename T>
150 unsigned int nJet = srcJet->size();
156 std::vector<float> leptonPtRel_v0(nJet,0);
157 std::vector<float> leptonPtRatio_v0(nJet,0);
158 std::vector<float> leptonPtRelInv_v0(nJet,0);
160 std::vector<float>
leptonPt(nJet,0);
163 std::vector<float>
vtxPt(nJet,0);
164 std::vector<float>
vtxMass(nJet,0);
165 std::vector<float>
vtx3dL(nJet,0);
166 std::vector<float>
vtx3deL(nJet,0);
167 std::vector<int>
vtxNtrk(nJet,0);
168 std::vector<float>
ptD(nJet,0);
169 std::vector<float>
genPtwNu(nJet,0);
172 const auto &
pv = (*srcVtx)[0];
173 for (
unsigned int ij = 0; ij<nJet; ij++){
175 auto jet = srcJet->ptrAt(ij);
177 if (
jet->genJet()!=
nullptr){
178 auto genp4 =
jet->genJet()->p4();
179 auto gep4wNu = genp4;
180 for(
const auto &
gp : *srcGP){
181 if((
abs(
gp.pdgId())==12 ||
abs(
gp.pdgId())==14 ||
abs(
gp.pdgId())==16) &&
gp.status()==1){
184 gep4wNu=gep4wNu+
gp.p4();
190 genPtwNu[ij]=gep4wNu.pt();
199 for(
const auto &
d :
jet->daughterPtrVector()){
200 sumWeight+=(
d->pt())*(
d->pt());
202 if(
d->pt()>
ptMax) ptMax=
d->pt();}
203 leadTrackPt[ij]=
ptMax;
204 ptD[ij] = (sumWeight > 0 ?
sqrt(sumWeight)/sumPt : 0);
210 for(
const auto &
d :
jet->daughterPtrVector()){
212 if(
abs(
d->pdgId())==11 ||
abs(
d->pdgId())==13){
213 if(
d->pt()<maxLepPt)
continue;
215 leptonPtRatio[ij] = std::get<0>(
res);
216 leptonPtRel[ij] = std::get<1>(
res);
217 leptonPtRelInv[ij] = std::get<2>(
res);
219 leptonPtRatio_v0[ij] = std::get<0>(res2);
220 leptonPtRel_v0[ij] = std::get<1>(res2);
221 leptonPtRelInv_v0[ij] = std::get<2>(res2);
222 leptonPdgId[ij] =
d->pdgId();
224 leptonPt[ij] =
d->pt();
234 float maxFoundSignificance=0;
242 for(
const auto &
sv: *srcSV){
250 vtxMass[ij]=
sv.p4().M();
251 vtx3dL[ij]=dl.
value();
252 vtx3deL[ij]=dl.
error();
253 vtxNtrk[ij]=
sv.numberOfSourceCandidatePtrs();
267 fillerRel.
insert(srcJet,leptonPtRel.begin(),leptonPtRel.end());
273 fillerRatio.
insert(srcJet,leptonPtRatio.begin(),leptonPtRatio.end());
279 fillerRelInv.
insert(srcJet,leptonPtRelInv.begin(),leptonPtRelInv.end());
281 iEvent.
put(
std::move(leptonPtRelInvV),
"leptonPtRelInv");
285 fillerRel_v0.
insert(srcJet,leptonPtRel_v0.begin(),leptonPtRel_v0.end());
291 fillerRatio_v0.
insert(srcJet,leptonPtRatio_v0.begin(),leptonPtRatio_v0.end());
292 fillerRatio_v0.
fill();
293 iEvent.
put(
std::move(leptonPtRatioV_v0),
"leptonPtRatiov0");
297 fillerRelInv_v0.
insert(srcJet,leptonPtRelInv_v0.begin(),leptonPtRelInv_v0.end());
298 fillerRelInv_v0.
fill();
299 iEvent.
put(
std::move(leptonPtRelInvV_v0),
"leptonPtRelInvv0");
303 fillerLpt.
insert(srcJet,leptonPt.begin(),leptonPt.end());
309 fillerLdR.
insert(srcJet,leptonDeltaR.begin(),leptonDeltaR.end());
315 fillerId.
insert(srcJet,leptonPdgId.begin(),leptonPdgId.end());
321 fillerLT.
insert(srcJet,leadTrackPt.begin(),leadTrackPt.end());
327 fillerVtxPt.
insert(srcJet,vtxPt.begin(),vtxPt.end());
333 fillerVtxMass.
insert(srcJet,vtxMass.begin(),vtxMass.end());
334 fillerVtxMass.
fill();
339 fillerVtx3dL.
insert(srcJet,vtx3dL.begin(),vtx3dL.end());
345 fillerVtx3deL.
insert(srcJet,vtx3deL.begin(),vtx3deL.end());
346 fillerVtx3deL.
fill();
351 fillerVtxNT.
insert(srcJet,vtxNtrk.begin(),vtxNtrk.end());
357 fillerPtD.
insert(srcJet,ptD.begin(),ptD.end());
363 fillergenpt.
insert(srcJet,genPtwNu.begin(),genPtwNu.end());
370 template <
typename T>
371 std::tuple<float,float,float>
375 auto lepp4 = lep->
p4();
377 if ((rawp4-lepp4).
R()<1
e-4)
return std::tuple<float,float,float>(1.0,0.0,0.0);
379 auto jetp4 = (rawp4 - lepp4*(1.0/jet->
jecFactor(
"L1FastJet")))*(jet->
pt()/rawp4.pt())+lepp4;
380 auto ptratio = lepp4.pt()/jetp4.pt();
381 auto ptrel = lepp4.Vect().Cross((jetp4-lepp4).Vect().Unit()).R();
382 auto ptrelinv = (jetp4-lepp4).Vect().Cross((lepp4).Vect().Unit()).R();
384 return std::tuple<float,float,float>(ptratio,ptrel,ptrelinv);
388 template <
typename T>
389 std::tuple<float,float,float>
392 auto lepp4 = lep->
p4();
395 if ((rawp4-lepp4).
R()<1
e-4)
return std::tuple<float,float,float>(1.0,0.0,0.0);
397 auto jetp4 = jet->
p4();
398 auto ptratio = lepp4.pt()/jetp4.pt();
399 auto ptrel = lepp4.Vect().Cross((jetp4).Vect().Unit()).R();
400 auto ptrelinv = jetp4.Vect().Cross((lepp4).Vect().Unit()).R();
402 return std::tuple<float,float,float>(ptratio,ptrel,ptrelinv);
409 template <
typename T>
418 desc.
add<
edm::InputTag>(
"pvsrc")->setComment(
"primary vertex input collection");
419 desc.
add<
edm::InputTag>(
"svsrc")->setComment(
"secondary vertex input collection");
420 desc.
add<
edm::InputTag>(
"gpsrc")->setComment(
"genparticles for nu recovery");
422 if (
typeid(
T) ==
typeid(
pat::Jet)) modname+=
"Jet";
423 modname+=
"RegressionVarProducer";
424 descriptions.
add(modname,desc);
const LorentzVector correctedP4(const std::string &level, const std::string &flavor="none", const std::string &set="") const
reco::Vertex::Point convertPos(const GlobalPoint &p)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< edm::View< reco::VertexCompositePtrCandidate > > srcSV_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< std::vector< reco::GenParticle > > srcGP_
std::tuple< float, float, float > calculatePtRatioRel(edm::Ptr< reco::Candidate > lep, edm::Ptr< pat::Jet > jet) const
#define DEFINE_FWK_MODULE(type)
~BJetEnergyRegressionVarProducer() override
reco::Vertex::Error convertError(const GlobalError &ge)
void insert(const H &h, I begin, I end)
BJetEnergyRegressionVarProducer(const edm::ParameterSet &iConfig)
double pt() const final
transverse momentum
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::View< pat::Jet > > srcJet_
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
BJetEnergyRegressionVarProducer< pat::Jet > JetRegressionVarProducer
Abs< T >::type abs(const T &t)
const LorentzVector & p4() const final
four-momentum Lorentz vector
ParameterDescriptionBase * add(U const &iLabel, T const &value)
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
double significance() const
edm::EDGetTokenT< std::vector< reco::Vertex > > srcVtx_
Analysis-level calorimeter jet class.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::tuple< float, float, float > calculatePtRatioRelSimple(edm::Ptr< reco::Candidate > lep, edm::Ptr< pat::Jet > jet) const
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
float jecFactor(const std::string &level, const std::string &flavor="none", const std::string &set="") const