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);
118 iEvent.getByToken(input_tracks_token_, tracks_h);
120 auto const& jets_h =
iEvent.get(input_jets_token_);
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>();
136 for (
auto const& oldjet : jets_h) {
141 double factorZSP = 1.;
143 factorZSP = mZSPalgo->correction(corrected,
iEvent, iSetup);
149 double scaleJPT = 1.;
157 bool validMatches =
false;
160 scaleJPT = mJPTalgo->correction(corrected, oldjet,
iEvent, iSetup, pions,
muons,
elecs, validMatches);
162 corrected.
py() * scaleJPT,
163 corrected.
pz() * scaleJPT,
164 corrected.
energy() * scaleJPT);
166 scaleJPT = mJPTalgo->correction(corrected, oldjet,
iEvent, iSetup, p4, pions,
muons,
elecs, validMatches);
185 specific.mResponseOfChargedWithEff = (
float)mJPTalgo->getResponseOfChargedWithEff();
186 specific.mResponseOfChargedWithoutEff = (
float)mJPTalgo->getResponseOfChargedWithoutEff();
187 specific.mSumPtOfChargedWithEff = (
float)mJPTalgo->getSumPtWithEff();
188 specific.mSumPtOfChargedWithoutEff = (
float)mJPTalgo->getSumPtWithoutEff();
189 specific.mSumEnergyOfChargedWithEff = (
float)mJPTalgo->getSumEnergyWithEff();
190 specific.mSumEnergyOfChargedWithoutEff = (
float)mJPTalgo->getSumEnergyWithoutEff();
191 specific.mChargedHadronEnergy = (
float)mJPTalgo->getSumEnergyWithoutEff();
195 double deEta2Tr = 0.;
196 double dePhi2Tr = 0.;
200 double denominator_tracks = 0.;
205 double deR =
deltaR((*it)->eta(), (*it)->phi(), p4.eta(), p4.phi());
206 double deEta = (*it)->eta() - p4.eta();
207 double dePhi =
deltaPhi((*it)->phi(), p4.phi());
208 if ((**it).ptError() / (**it).pt() < 0.1) {
209 deR2Tr = deR2Tr + deR * deR * (*it)->pt();
210 deEta2Tr = deEta2Tr + deEta * deEta * (*it)->pt();
211 dePhi2Tr = dePhi2Tr + dePhi * dePhi * (*it)->pt();
212 denominator_tracks = denominator_tracks + (*it)->pt();
213 Zch = Zch + (*it)->pt();
215 Pout2 = Pout2 + (**it).p() * (**it).p() - (Zch * p4.P()) * (Zch * p4.P());
221 double deR =
deltaR((*it)->eta(), (*it)->phi(), p4.eta(), p4.phi());
222 double deEta = (*it)->eta() - p4.eta();
223 double dePhi =
deltaPhi((*it)->phi(), p4.phi());
224 if ((**it).ptError() / (**it).pt() < 0.1) {
225 deR2Tr = deR2Tr + deR * deR * (*it)->pt();
226 deEta2Tr = deEta2Tr + deEta * deEta * (*it)->pt();
227 dePhi2Tr = dePhi2Tr + dePhi * dePhi * (*it)->pt();
228 denominator_tracks = denominator_tracks + (*it)->pt();
229 Zch = Zch + (*it)->pt();
231 Pout2 = Pout2 + (**it).p() * (**it).p() - (Zch * p4.P()) * (Zch * p4.P());
237 double deR =
deltaR((*it)->eta(), (*it)->phi(), p4.eta(), p4.phi());
238 double deEta = (*it)->eta() - p4.eta();
239 double dePhi =
deltaPhi((*it)->phi(), p4.phi());
240 if ((**it).ptError() / (**it).pt() < 0.1) {
241 deR2Tr = deR2Tr + deR * deR * (*it)->pt();
242 deEta2Tr = deEta2Tr + deEta * deEta * (*it)->pt();
243 dePhi2Tr = dePhi2Tr + dePhi * dePhi * (*it)->pt();
244 denominator_tracks = denominator_tracks + (*it)->pt();
245 Zch = Zch + (*it)->pt();
247 Pout2 = Pout2 + (**it).p() * (**it).p() - (Zch * p4.P()) * (Zch * p4.P());
254 Zch = Zch + (*it)->pt();
257 it !=
muons.inVertexOutOfCalo_.end();
259 Zch = Zch + (*it)->pt();
262 it !=
elecs.inVertexOutOfCalo_.end();
264 Zch = Zch + (*it)->pt();
267 if (mJPTalgo->getSumPtForBeta() > 0.)
268 Zch = Zch / mJPTalgo->getSumPtForBeta();
274 if (denominator_tracks != 0) {
275 deR2Tr = deR2Tr / denominator_tracks;
276 deEta2Tr = deEta2Tr / denominator_tracks;
277 dePhi2Tr = dePhi2Tr / denominator_tracks;
300 tmpColl.push_back(fJet);
307 reco::TrackRefVector trBgOutOfVertex = calculateBGtracksJet(tmpColl, fTracks, extrapolations_h, trBgOutOfCalo);
310 std::map<reco::JPTJetCollection::iterator, double> AreaNonJet;
312 for (reco::JPTJetCollection::iterator ij1 = tmpColl.begin(); ij1 != tmpColl.end(); ij1++) {
314 for (reco::JPTJetCollection::iterator ij2 = tmpColl.begin(); ij2 != tmpColl.end(); ij2++) {
317 if (fabs((*ij1).eta() - (*ij2).eta()) > 0.5)
322 AreaNonJet[ij1] = 4 *
M_PI * mConeSize - nj1 * 4 * mConeSize * mConeSize;
327 for (reco::JPTJetCollection::iterator ij = tmpColl.begin(); ij != tmpColl.end(); ij++) {
333 double ja = (AreaNonJet.find(ij))->
second;
335 double factorPU = mJPTalgo->correctAA(*ij, trBgOutOfVertex, mConeSize, pioninin, pioninout, ja, trBgOutOfCalo);
337 (*ij).scaleEnergy(factorPU);
340 pOut->push_back(*ij);
351 std::vector<reco::TrackRef>& fTracks,
352 edm::Handle<std::vector<reco::TrackExtrapolation> >& extrapolations_h,
356 for (
unsigned t = 0;
t < fTracks.size(); ++
t) {
364 for (
unsigned j = 0;
j < fJets.size(); ++
j) {
371 if (dphiTrackJet < mConeSize) {
384 for (std::vector<reco::TrackExtrapolation>::const_iterator xtrpBegin = extrapolations_h->begin(),
385 xtrpEnd = extrapolations_h->end(),
391 if (it != trBgOutOfVertex.
end()) {
396 return trBgOutOfVertex;
T getParameter(std::string const &) const
double pz() const final
z coordinate of momentum vector
Jets made from CaloTowers.
virtual void scaleEnergy(double fScale)
scale energy of the jet
reco::TrackRefVector calculateBGtracksJet(reco::JPTJetCollection &, std::vector< reco::TrackRef > &, edm::Handle< std::vector< reco::TrackExtrapolation > > &, reco::TrackRefVector &)
std::vector< JPTJet > JPTJetCollection
collection of CaloJet objects
Base class for all types of Jets.
reco::TrackRefVector inVertexInCalo_
~JetPlusTrackProducerAA() override
JetPlusTrackProducerAA(const edm::ParameterSet &)
reco::TrackRefVector inVertexOutOfCalo_
void produce(edm::Event &, const edm::EventSetup &) override
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
T getUntrackedParameter(std::string const &, T const &) const
U second(std::pair< T, U > const &p)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
virtual Constituents getJetConstituents() const
list of constituents
double px() const final
x coordinate of momentum vector
Jets made from CaloJets corrected for ZSP and tracks.
math::XYZPoint Point
point in the space
reco::TrackRefVector outOfVertexInCalo_
double py() const final
y coordinate of momentum vector
static TrackQuality qualityByName(const std::string &name)
const_iterator end() const
Termination of iteration.
Particles matched to tracks that are in/in, in/out, out/in at Vertex and CaloFace.
Jet energy correction algorithm using tracks.
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
const_iterator begin() const
Initialize an iterator over the RefVector.
math::XYZPoint Point
point in the space
double energy() const final
energy