83 vectorial_ = iConfig.
getParameter<
bool>(
"VectorialCorrection");
95 produces<reco::JPTJetCollection>().setBranchAlias(
alias);
97 input_jets_token_ = consumes<edm::View<reco::CaloJet> >(
src);
98 input_vertex_token_ = consumes<reco::VertexCollection>(srcPVs_);
99 input_tracks_token_ = consumes<reco::TrackCollection>(mTracks);
100 input_extrapolations_token_ = consumes<std::vector<reco::TrackExtrapolation> >(mExtrapolations);
120 iEvent.getByToken(input_jets_token_, jets_h);
123 iEvent.getByToken(input_tracks_token_, tracks_h);
125 std::vector<reco::TrackRef> fTracks;
126 fTracks.reserve(tracks_h->size());
127 for (
unsigned i = 0;
i < tracks_h->size(); ++
i) {
133 iEvent.getByToken(input_extrapolations_token_, extrapolations_h);
138 auto pOut = std::make_unique<reco::JPTJetCollection>();
142 for (
unsigned i = 0;
i < jets_h->size(); ++
i) {
149 double factorZSP = 1.;
151 factorZSP = mZSPalgo->correction(corrected,
iEvent, iSetup);
159 double scaleJPT = 1.;
170 scaleJPT = mJPTalgo->correction(corrected, *oldjet,
iEvent, iSetup, pions,
muons,
elecs,
ok);
172 corrected.
py() * scaleJPT,
173 corrected.
pz() * scaleJPT,
174 corrected.
energy() * scaleJPT);
176 scaleJPT = mJPTalgo->correction(corrected, *oldjet,
iEvent, iSetup,
p4, pions,
muons,
elecs,
ok);
201 specific.mResponseOfChargedWithEff = (
float)mJPTalgo->getResponseOfChargedWithEff();
202 specific.mResponseOfChargedWithoutEff = (
float)mJPTalgo->getResponseOfChargedWithoutEff();
203 specific.mSumPtOfChargedWithEff = (
float)mJPTalgo->getSumPtWithEff();
204 specific.mSumPtOfChargedWithoutEff = (
float)mJPTalgo->getSumPtWithoutEff();
205 specific.mSumEnergyOfChargedWithEff = (
float)mJPTalgo->getSumEnergyWithEff();
206 specific.mSumEnergyOfChargedWithoutEff = (
float)mJPTalgo->getSumEnergyWithoutEff();
207 specific.mChargedHadronEnergy = (
float)mJPTalgo->getSumEnergyWithoutEff();
210 double deEta2Tr = 0.;
211 double dePhi2Tr = 0.;
215 double denominator_tracks = 0.;
220 double deR =
deltaR((*it)->eta(), (*it)->phi(),
p4.eta(),
p4.phi());
221 double deEta = (*it)->eta() -
p4.eta();
222 double dePhi =
deltaPhi((*it)->phi(),
p4.phi());
223 if ((**it).ptError() / (**it).pt() < 0.1) {
224 deR2Tr = deR2Tr + deR * deR * (*it)->pt();
225 deEta2Tr = deEta2Tr + deEta * deEta * (*it)->pt();
226 dePhi2Tr = dePhi2Tr + dePhi * dePhi * (*it)->pt();
227 denominator_tracks = denominator_tracks + (*it)->pt();
228 Zch = Zch + (*it)->pt();
230 Pout2 = Pout2 + (**it).p() * (**it).p() - (Zch *
p4.P()) * (Zch *
p4.P());
236 double deR =
deltaR((*it)->eta(), (*it)->phi(),
p4.eta(),
p4.phi());
237 double deEta = (*it)->eta() -
p4.eta();
238 double dePhi =
deltaPhi((*it)->phi(),
p4.phi());
239 if ((**it).ptError() / (**it).pt() < 0.1) {
240 deR2Tr = deR2Tr + deR * deR * (*it)->pt();
241 deEta2Tr = deEta2Tr + deEta * deEta * (*it)->pt();
242 dePhi2Tr = dePhi2Tr + dePhi * dePhi * (*it)->pt();
243 denominator_tracks = denominator_tracks + (*it)->pt();
244 Zch = Zch + (*it)->pt();
246 Pout2 = Pout2 + (**it).p() * (**it).p() - (Zch *
p4.P()) * (Zch *
p4.P());
252 double deR =
deltaR((*it)->eta(), (*it)->phi(),
p4.eta(),
p4.phi());
253 double deEta = (*it)->eta() -
p4.eta();
254 double dePhi =
deltaPhi((*it)->phi(),
p4.phi());
255 if ((**it).ptError() / (**it).pt() < 0.1) {
256 deR2Tr = deR2Tr + deR * deR * (*it)->pt();
257 deEta2Tr = deEta2Tr + deEta * deEta * (*it)->pt();
258 dePhi2Tr = dePhi2Tr + dePhi * dePhi * (*it)->pt();
259 denominator_tracks = denominator_tracks + (*it)->pt();
260 Zch = Zch + (*it)->pt();
262 Pout2 = Pout2 + (**it).p() * (**it).p() - (Zch *
p4.P()) * (Zch *
p4.P());
269 Zch = Zch + (*it)->pt();
272 it !=
muons.inVertexOutOfCalo_.end();
274 Zch = Zch + (*it)->pt();
277 it !=
elecs.inVertexOutOfCalo_.end();
279 Zch = Zch + (*it)->pt();
282 if (mJPTalgo->getSumPtForBeta() > 0.)
283 Zch = Zch / mJPTalgo->getSumPtForBeta();
288 Pout =
sqrt(fabs(Pout2)) / ntracks;
291 if (denominator_tracks != 0) {
292 deR2Tr = deR2Tr / denominator_tracks;
293 deEta2Tr = deEta2Tr / denominator_tracks;
294 dePhi2Tr = dePhi2Tr / denominator_tracks;
318 tmpColl.push_back(fJet);
325 reco::TrackRefVector trBgOutOfVertex = calculateBGtracksJet(tmpColl, fTracks, extrapolations_h, trBgOutOfCalo);
328 std::map<reco::JPTJetCollection::iterator, double> AreaNonJet;
330 for (reco::JPTJetCollection::iterator ij1 = tmpColl.begin(); ij1 != tmpColl.end(); ij1++) {
332 for (reco::JPTJetCollection::iterator ij2 = tmpColl.begin(); ij2 != tmpColl.end(); ij2++) {
335 if (fabs((*ij1).eta() - (*ij2).eta()) > 0.5)
340 AreaNonJet[ij1] = 4 *
M_PI * mConeSize - nj1 * 4 * mConeSize * mConeSize;
352 for (reco::JPTJetCollection::iterator ij = tmpColl.begin(); ij != tmpColl.end(); ij++) {
358 double ja = (AreaNonJet.find(ij))->
second;
362 double factorPU = mJPTalgo->correctAA(*ij, trBgOutOfVertex, mConeSize, pioninin, pioninout, ja, trBgOutOfCalo);
364 (*ij).scaleEnergy(factorPU);
369 pOut->push_back(*ij);
382 std::vector<reco::TrackRef>& fTracks,
383 edm::Handle<std::vector<reco::TrackExtrapolation> >& extrapolations_h,
387 for (
unsigned t = 0;
t < fTracks.size(); ++
t) {
404 for (
unsigned j = 0;
j < fJets.size(); ++
j) {
414 if (dphiTrackJet >
M_PI)
415 dphiTrackJet = 2 *
M_PI - dphiTrackJet;
417 if (dphiTrackJet < mConeSize) {
437 for (std::vector<reco::TrackExtrapolation>::const_iterator xtrpBegin = extrapolations_h->begin(),
438 xtrpEnd = extrapolations_h->end(),
452 if (it != trBgOutOfVertex.
end()) {
464 return trBgOutOfVertex;