82 vectorial_ = iConfig.
getParameter<
bool>(
"VectorialCorrection");
94 produces<reco::JPTJetCollection>().setBranchAlias(
alias);
96 input_jets_token_ = consumes<edm::View<reco::CaloJet> >(
src);
97 input_vertex_token_ = consumes<reco::VertexCollection>(srcPVs_);
98 input_tracks_token_ = consumes<reco::TrackCollection>(mTracks);
99 input_extrapolations_token_ = consumes<std::vector<reco::TrackExtrapolation> >(mExtrapolations);
117 iEvent.getByToken(input_jets_token_, jets_h);
120 iEvent.getByToken(input_tracks_token_, tracks_h);
122 std::vector<reco::TrackRef> fTracks;
123 fTracks.reserve(tracks_h->size());
124 for (
unsigned i = 0;
i < tracks_h->size(); ++
i) {
129 iEvent.getByToken(input_extrapolations_token_, extrapolations_h);
131 auto pOut = std::make_unique<reco::JPTJetCollection>();
135 for (
unsigned i = 0;
i < jets_h->size(); ++
i) {
142 double factorZSP = 1.;
144 factorZSP = mZSPalgo->correction(corrected,
iEvent, iSetup);
150 double scaleJPT = 1.;
161 scaleJPT = mJPTalgo->correction(corrected, *oldjet,
iEvent, iSetup, pions,
muons,
elecs,
ok);
163 corrected.
py() * scaleJPT,
164 corrected.
pz() * scaleJPT,
165 corrected.
energy() * scaleJPT);
167 scaleJPT = mJPTalgo->correction(corrected, *oldjet,
iEvent, iSetup,
p4, pions,
muons,
elecs,
ok);
188 specific.mResponseOfChargedWithEff = (
float)mJPTalgo->getResponseOfChargedWithEff();
189 specific.mResponseOfChargedWithoutEff = (
float)mJPTalgo->getResponseOfChargedWithoutEff();
190 specific.mSumPtOfChargedWithEff = (
float)mJPTalgo->getSumPtWithEff();
191 specific.mSumPtOfChargedWithoutEff = (
float)mJPTalgo->getSumPtWithoutEff();
192 specific.mSumEnergyOfChargedWithEff = (
float)mJPTalgo->getSumEnergyWithEff();
193 specific.mSumEnergyOfChargedWithoutEff = (
float)mJPTalgo->getSumEnergyWithoutEff();
194 specific.mChargedHadronEnergy = (
float)mJPTalgo->getSumEnergyWithoutEff();
197 double deEta2Tr = 0.;
198 double dePhi2Tr = 0.;
202 double denominator_tracks = 0.;
207 double deR =
deltaR((*it)->eta(), (*it)->phi(),
p4.eta(),
p4.phi());
208 double deEta = (*it)->eta() -
p4.eta();
209 double dePhi =
deltaPhi((*it)->phi(),
p4.phi());
210 if ((**it).ptError() / (**it).pt() < 0.1) {
211 deR2Tr = deR2Tr + deR * deR * (*it)->pt();
212 deEta2Tr = deEta2Tr + deEta * deEta * (*it)->pt();
213 dePhi2Tr = dePhi2Tr + dePhi * dePhi * (*it)->pt();
214 denominator_tracks = denominator_tracks + (*it)->pt();
215 Zch = Zch + (*it)->pt();
217 Pout2 = Pout2 + (**it).p() * (**it).p() - (Zch *
p4.P()) * (Zch *
p4.P());
223 double deR =
deltaR((*it)->eta(), (*it)->phi(),
p4.eta(),
p4.phi());
224 double deEta = (*it)->eta() -
p4.eta();
225 double dePhi =
deltaPhi((*it)->phi(),
p4.phi());
226 if ((**it).ptError() / (**it).pt() < 0.1) {
227 deR2Tr = deR2Tr + deR * deR * (*it)->pt();
228 deEta2Tr = deEta2Tr + deEta * deEta * (*it)->pt();
229 dePhi2Tr = dePhi2Tr + dePhi * dePhi * (*it)->pt();
230 denominator_tracks = denominator_tracks + (*it)->pt();
231 Zch = Zch + (*it)->pt();
233 Pout2 = Pout2 + (**it).p() * (**it).p() - (Zch *
p4.P()) * (Zch *
p4.P());
239 double deR =
deltaR((*it)->eta(), (*it)->phi(),
p4.eta(),
p4.phi());
240 double deEta = (*it)->eta() -
p4.eta();
241 double dePhi =
deltaPhi((*it)->phi(),
p4.phi());
242 if ((**it).ptError() / (**it).pt() < 0.1) {
243 deR2Tr = deR2Tr + deR * deR * (*it)->pt();
244 deEta2Tr = deEta2Tr + deEta * deEta * (*it)->pt();
245 dePhi2Tr = dePhi2Tr + dePhi * dePhi * (*it)->pt();
246 denominator_tracks = denominator_tracks + (*it)->pt();
247 Zch = Zch + (*it)->pt();
249 Pout2 = Pout2 + (**it).p() * (**it).p() - (Zch *
p4.P()) * (Zch *
p4.P());
256 Zch = Zch + (*it)->pt();
259 it !=
muons.inVertexOutOfCalo_.end();
261 Zch = Zch + (*it)->pt();
264 it !=
elecs.inVertexOutOfCalo_.end();
266 Zch = Zch + (*it)->pt();
269 if (mJPTalgo->getSumPtForBeta() > 0.)
270 Zch = Zch / mJPTalgo->getSumPtForBeta();
276 if (denominator_tracks != 0) {
277 deR2Tr = deR2Tr / denominator_tracks;
278 deEta2Tr = deEta2Tr / denominator_tracks;
279 dePhi2Tr = dePhi2Tr / denominator_tracks;
303 tmpColl.push_back(fJet);
310 reco::TrackRefVector trBgOutOfVertex = calculateBGtracksJet(tmpColl, fTracks, extrapolations_h, trBgOutOfCalo);
313 std::map<reco::JPTJetCollection::iterator, double> AreaNonJet;
315 for (reco::JPTJetCollection::iterator ij1 = tmpColl.begin(); ij1 != tmpColl.end(); ij1++) {
317 for (reco::JPTJetCollection::iterator ij2 = tmpColl.begin(); ij2 != tmpColl.end(); ij2++) {
320 if (fabs((*ij1).eta() - (*ij2).eta()) > 0.5)
325 AreaNonJet[ij1] = 4 *
M_PI * mConeSize - nj1 * 4 * mConeSize * mConeSize;
330 for (reco::JPTJetCollection::iterator ij = tmpColl.begin(); ij != tmpColl.end(); ij++) {
336 double ja = (AreaNonJet.find(ij))->
second;
338 double factorPU = mJPTalgo->correctAA(*ij, trBgOutOfVertex, mConeSize, pioninin, pioninout, ja, trBgOutOfCalo);
340 (*ij).scaleEnergy(factorPU);
343 pOut->push_back(*ij);
354 std::vector<reco::TrackRef>& fTracks,
355 edm::Handle<std::vector<reco::TrackExtrapolation> >& extrapolations_h,
359 for (
unsigned t = 0;
t < fTracks.size(); ++
t) {
367 for (
unsigned j = 0;
j < fJets.size(); ++
j) {
374 if (dphiTrackJet < mConeSize) {
388 for (std::vector<reco::TrackExtrapolation>::const_iterator xtrpBegin = extrapolations_h->begin(),
389 xtrpEnd = extrapolations_h->end(),
397 if (it != trBgOutOfVertex.
end()) {
402 return trBgOutOfVertex;