81 produces<edm::ValueMap<float>>(
"leptonPtRel");
82 produces<edm::ValueMap<float>>(
"leptonPtRatio");
83 produces<edm::ValueMap<float>>(
"leptonPtRelInv");
84 produces<edm::ValueMap<float>>(
"leptonPtRelv0");
85 produces<edm::ValueMap<float>>(
"leptonPtRatiov0");
86 produces<edm::ValueMap<float>>(
"leptonPtRelInvv0");
87 produces<edm::ValueMap<float>>(
"leptonPt");
88 produces<edm::ValueMap<int>>(
"leptonPdgId");
89 produces<edm::ValueMap<float>>(
"leptonDeltaR");
90 produces<edm::ValueMap<float>>(
"leadTrackPt");
91 produces<edm::ValueMap<float>>(
"vtxPt");
92 produces<edm::ValueMap<float>>(
"vtxMass");
93 produces<edm::ValueMap<float>>(
"vtx3dL");
94 produces<edm::ValueMap<float>>(
"vtx3deL");
95 produces<edm::ValueMap<int>>(
"vtxNtrk");
96 produces<edm::ValueMap<float>>(
"ptD");
97 produces<edm::ValueMap<float>>(
"genPtwNu");
131 template <
typename T>
140 iEvent.getByToken(srcSV_, srcSV);
142 iEvent.getByToken(srcGP_, srcGP);
144 unsigned int nJet =
srcJet->size();
150 std::vector<float> leptonPtRel_v0(nJet, 0);
151 std::vector<float> leptonPtRatio_v0(nJet, 0);
152 std::vector<float> leptonPtRelInv_v0(nJet, 0);
154 std::vector<float>
leptonPt(nJet, 0);
157 std::vector<float>
vtxPt(nJet, 0);
158 std::vector<float>
vtxMass(nJet, 0);
159 std::vector<float>
vtx3dL(nJet, 0);
160 std::vector<float>
vtx3deL(nJet, 0);
161 std::vector<int>
vtxNtrk(nJet, 0);
162 std::vector<float>
ptD(nJet, 0);
163 std::vector<float>
genPtwNu(nJet, 0);
165 const auto&
pv = (*srcVtx)[0];
166 for (
unsigned int ij = 0; ij < nJet; ij++) {
169 if (
jet->genJet() !=
nullptr) {
170 auto genp4 =
jet->genJet()->p4();
171 auto gep4wNu = genp4;
172 for (
const auto&
gp : *srcGP) {
173 if ((
abs(
gp.pdgId()) == 12 ||
abs(
gp.pdgId()) == 14 ||
abs(
gp.pdgId()) == 16) &&
gp.status() == 1) {
176 gep4wNu = gep4wNu +
gp.p4();
189 for (
const auto&
d :
jet->daughterPtrVector()) {
190 sumWeight += (
d->pt()) * (
d->pt());
196 ptD[ij] = (sumWeight > 0 ?
sqrt(sumWeight) /
sumPt : 0);
202 for (
const auto&
d :
jet->daughterPtrVector()) {
203 if (
abs(
d->pdgId()) == 11 ||
abs(
d->pdgId()) == 13) {
204 if (
d->pt() < maxLepPt)
206 auto res = calculatePtRatioRel(
d,
jet);
210 auto res2 = calculatePtRatioRelSimple(
d,
jet);
211 leptonPtRatio_v0[ij] = std::get<0>(res2);
212 leptonPtRel_v0[ij] = std::get<1>(res2);
213 leptonPtRelInv_v0[ij] = std::get<2>(res2);
223 float maxFoundSignificance = 0;
231 for (
const auto&
sv : *srcSV) {
243 vtxNtrk[ij] =
sv.numberOfSourceCandidatePtrs();
269 fillerRel_v0.
insert(
srcJet, leptonPtRel_v0.begin(), leptonPtRel_v0.end());
275 fillerRatio_v0.
insert(
srcJet, leptonPtRatio_v0.begin(), leptonPtRatio_v0.end());
276 fillerRatio_v0.
fill();
281 fillerRelInv_v0.
insert(
srcJet, leptonPtRelInv_v0.begin(), leptonPtRelInv_v0.end());
282 fillerRelInv_v0.
fill();
318 fillerVtxMass.
fill();
330 fillerVtx3deL.
fill();
352 template <
typename T>
355 auto rawp4 =
jet->correctedP4(
"Uncorrected");
356 auto lepp4 = lep->
p4();
358 if ((rawp4 - lepp4).
R() < 1
e-4)
359 return std::tuple<float, float, float>(1.0, 0.0, 0.0);
361 auto jetp4 = (rawp4 - lepp4 * (1.0 /
jet->jecFactor(
"L1FastJet"))) * (
jet->pt() / rawp4.pt()) + lepp4;
362 auto ptratio = lepp4.pt() / jetp4.pt();
363 auto ptrel = lepp4.Vect().Cross((jetp4 - lepp4).Vect().Unit()).R();
364 auto ptrelinv = (jetp4 - lepp4).Vect().Cross((lepp4).Vect().Unit()).R();
366 return std::tuple<float, float, float>(ptratio, ptrel, ptrelinv);
369 template <
typename T>
372 auto lepp4 = lep->
p4();
373 auto rawp4 =
jet->correctedP4(
"Uncorrected");
375 if ((rawp4 - lepp4).
R() < 1
e-4)
376 return std::tuple<float, float, float>(1.0, 0.0, 0.0);
378 auto jetp4 =
jet->p4();
379 auto ptratio = lepp4.pt() / jetp4.pt();
380 auto ptrel = lepp4.Vect().Cross((jetp4).Vect().Unit()).R();
381 auto ptrelinv = jetp4.Vect().Cross((lepp4).Vect().Unit()).R();
383 return std::tuple<float, float, float>(ptratio, ptrel, ptrelinv);
387 template <
typename T>
396 desc.add<
edm::InputTag>(
"svsrc")->setComment(
"secondary vertex input collection");
401 modname +=
"RegressionVarProducer";
reco::Vertex::Point convertPos(const GlobalPoint &p)
edm::EDGetTokenT< edm::View< reco::VertexCompositePtrCandidate > > srcSV_
edm::EDGetTokenT< std::vector< reco::GenParticle > > srcGP_
~BJetEnergyRegressionVarProducer() override
reco::Vertex::Error convertError(const GlobalError &ge)
void insert(const H &h, I begin, I end)
BJetEnergyRegressionVarProducer(const edm::ParameterSet &iConfig)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::View< pat::Jet > > srcJet_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
BJetEnergyRegressionVarProducer< pat::Jet > JetRegressionVarProducer
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
edm::EDGetTokenT< std::vector< reco::Vertex > > srcVtx_
std::tuple< float, float, float > calculatePtRatioRel(edm::Ptr< reco::Candidate > lep, edm::Ptr< pat::Jet > jet) const
Analysis-level calorimeter jet class.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
double significance() const
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
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector