86 vectorial_ = iConfig.
getParameter<
bool>(
"VectorialCorrection");
97 produces<reco::JPTJetCollection>().setBranchAlias(alias);
99 input_jets_token_ = consumes<edm::View<reco::CaloJet> >(
src);
100 input_vertex_token_ = consumes<reco::VertexCollection>(srcPVs_);
101 input_tracks_token_ = consumes<reco::TrackCollection>(mTracks);
102 input_extrapolations_token_ = consumes<std::vector<reco::TrackExtrapolation> >(mExtrapolations);
130 iEvent.
getByToken (input_jets_token_, jets_h);
133 iEvent.
getByToken (input_tracks_token_, tracks_h);
135 std::vector <reco::TrackRef> fTracks;
136 fTracks.reserve (tracks_h->size());
137 for (
unsigned i = 0;
i < tracks_h->size(); ++
i) {
143 iEvent.
getByToken(input_extrapolations_token_, extrapolations_h);
148 auto pOut = std::make_unique<reco::JPTJetCollection>();
152 for (
unsigned i = 0;
i < jets_h->size(); ++
i) {
160 double factorZSP = 1.;
161 if(useZSP) factorZSP = mZSPalgo->correction(corrected, iEvent, iSetup);
170 double scaleJPT = 1.;
182 scaleJPT = mJPTalgo->correction ( corrected, *oldjet, iEvent, iSetup, pions, muons, elecs, ok );
184 corrected.
py()*scaleJPT,
185 corrected.
pz()*scaleJPT,
186 corrected.
energy()*scaleJPT );
188 scaleJPT = mJPTalgo->correction( corrected, *oldjet, iEvent, iSetup, p4, pions, muons, elecs, ok );
225 double deEta2Tr = 0.;
226 double dePhi2Tr = 0.;
230 double denominator_tracks = 0.;
234 double deR =
deltaR((*it)->eta(), (*it)->phi(), p4.eta(), p4.phi());
235 double deEta = (*it)->eta() - p4.eta();
236 double dePhi =
deltaPhi((*it)->phi(), p4.phi());
237 if((**it).ptError()/(**it).pt() < 0.1) {
238 deR2Tr = deR2Tr + deR*deR*(*it)->pt();
239 deEta2Tr = deEta2Tr + deEta*deEta*(*it)->pt();
240 dePhi2Tr = dePhi2Tr + dePhi*dePhi*(*it)->pt();
241 denominator_tracks = denominator_tracks + (*it)->pt();
242 Zch = Zch + (*it)->pt();
244 Pout2 = Pout2 + (**it).p()*(**it).p() - (Zch*p4.P())*(Zch*p4.P());
249 double deR =
deltaR((*it)->eta(), (*it)->phi(), p4.eta(), p4.phi());
250 double deEta = (*it)->eta() - p4.eta();
251 double dePhi =
deltaPhi((*it)->phi(), p4.phi());
252 if((**it).ptError()/(**it).pt() < 0.1) {
253 deR2Tr = deR2Tr + deR*deR*(*it)->pt();
254 deEta2Tr = deEta2Tr + deEta*deEta*(*it)->pt();
255 dePhi2Tr = dePhi2Tr + dePhi*dePhi*(*it)->pt();
256 denominator_tracks = denominator_tracks + (*it)->pt();
257 Zch = Zch + (*it)->pt();
259 Pout2 = Pout2 + (**it).p()*(**it).p() - (Zch*p4.P())*(Zch*p4.P());
264 double deR =
deltaR((*it)->eta(), (*it)->phi(), p4.eta(), p4.phi());
265 double deEta = (*it)->eta() - p4.eta();
266 double dePhi =
deltaPhi((*it)->phi(), p4.phi());
267 if((**it).ptError()/(**it).pt() < 0.1) {
268 deR2Tr = deR2Tr + deR*deR*(*it)->pt();
269 deEta2Tr = deEta2Tr + deEta*deEta*(*it)->pt();
270 dePhi2Tr = dePhi2Tr + dePhi*dePhi*(*it)->pt();
271 denominator_tracks = denominator_tracks + (*it)->pt();
272 Zch = Zch + (*it)->pt();
274 Pout2 = Pout2 + (**it).p()*(**it).p() - (Zch*p4.P())*(Zch*p4.P());
279 Zch = Zch + (*it)->pt();
282 Zch = Zch + (*it)->pt();
285 Zch = Zch + (*it)->pt();
288 if(mJPTalgo->getSumPtForBeta()> 0.) Zch = Zch/mJPTalgo->getSumPtForBeta();
293 Pout =
sqrt(fabs(Pout2))/ntracks;
297 if (denominator_tracks!=0){
298 deR2Tr = deR2Tr/denominator_tracks;
299 deEta2Tr= deEta2Tr/denominator_tracks;
300 dePhi2Tr= dePhi2Tr/denominator_tracks;
306 specific.
Pout = Pout;
315 iEvent.
getByToken(input_vertex_token_, pvCollection);
316 if ( pvCollection.
isValid() && !pvCollection->empty() ) vertex_=pvCollection->begin()->position();
323 tmpColl.push_back(fJet);
331 reco::TrackRefVector trBgOutOfVertex = calculateBGtracksJet(tmpColl,fTracks,extrapolations_h,trBgOutOfCalo);
334 std::map<reco::JPTJetCollection::iterator, double> AreaNonJet;
336 for(reco::JPTJetCollection::iterator ij1=tmpColl.begin(); ij1!=tmpColl.end(); ij1++)
339 for(reco::JPTJetCollection::iterator ij2=tmpColl.begin(); ij2!=tmpColl.end(); ij2++)
341 if(ij2 == ij1)
continue;
342 if(fabs((*ij1).eta() - (*ij2).eta()) > 0.5 )
continue;
347 AreaNonJet[ij1] = 4*
M_PI*mConeSize - nj1*4*mConeSize*mConeSize;
359 for(reco::JPTJetCollection::iterator ij=tmpColl.begin(); ij!=tmpColl.end(); ij++)
366 double ja = (AreaNonJet.find(ij))->
second;
370 double factorPU = mJPTalgo->correctAA(*ij,trBgOutOfVertex,mConeSize,pioninin,pioninout,ja,trBgOutOfCalo);
372 (*ij).scaleEnergy (factorPU);
377 pOut->push_back(*ij);
391 edm::Handle <std::vector<reco::TrackExtrapolation> > & extrapolations_h,
397 for (
unsigned t = 0;
t < fTracks.size(); ++
t) {
415 for (
unsigned j = 0; j < fJets.size(); ++j) {
424 if(fabs(jetEta - trackEta) < mConeSize) {
425 double dphiTrackJet = fabs(trackPhi - jetPhi);
426 if(dphiTrackJet >
M_PI) dphiTrackJet = 2*
M_PI - dphiTrackJet;
428 if(dphiTrackJet < mConeSize)
450 for ( std::vector<reco::TrackExtrapolation>::const_iterator xtrpBegin = extrapolations_h->begin(),
451 xtrpEnd = extrapolations_h->end(), ixtrp = xtrpBegin;
452 ixtrp != xtrpEnd; ++ixtrp ) {
464 if ( it != trBgOutOfVertex.
end() ){
477 return trBgOutOfVertex;
reco::TrackRefVector muonsInVertexOutCalo
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
float mSumEnergyOfChargedWithoutEff
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
double eta() const final
momentum pseudorapidity
Jets made from CaloTowers.
reco::TrackRefVector muonsInVertexInCalo
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 &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< JPTJet > JPTJetCollection
collection of CaloJet objects
Base class for all types of Jets.
double px() const final
x coordinate of momentum vector
float mChargedHadronEnergy
float mSumPtOfChargedWithEff
reco::TrackRefVector inVertexInCalo_
reco::TrackRefVector muonsOutVertexInCalo
~JetPlusTrackProducerAA() override
JetPlusTrackProducerAA(const edm::ParameterSet &)
double phi() const
azimuthal angle of momentum vector
reco::TrackRefVector inVertexOutOfCalo_
float mResponseOfChargedWithEff
reco::TrackRefVector elecsOutVertexInCalo
virtual Constituents getJetConstituents() const
list of constituents
reco::TrackRefVector pionsInVertexOutCalo
void produce(edm::Event &, const edm::EventSetup &) override
const_iterator end() const
Termination of iteration.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const_iterator begin() const
Initialize an iterator over the RefVector.
U second(std::pair< T, U > const &p)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
double eta() const
pseudorapidity of momentum vector
double pz() const final
z coordinate of momentum vector
Jets made from CaloJets corrected for ZSP and tracks.
reco::TrackRefVector pionsOutVertexInCalo
double energy() const final
energy
float mSumEnergyOfChargedWithEff
math::XYZPoint Point
point in the space
reco::TrackRefVector outOfVertexInCalo_
reco::TrackRefVector elecsInVertexInCalo
edm::RefToBase< reco::Jet > theCaloJetRef
double deltaR(double eta1, double eta2, double phi1, double phi2)
float mResponseOfChargedWithoutEff
reco::TrackRefVector pionsInVertexInCalo
static TrackQuality qualityByName(const std::string &name)
float mSumPtOfChargedWithoutEff
double py() const final
y coordinate of momentum vector
reco::TrackRefVector elecsInVertexOutCalo
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.
double phi() const final
momentum azimuthal angle
math::XYZPoint Point
point in the space