CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
JetPlusTrackProducer Class Reference

#include <JetPlusTrackProducer.cc>

Inheritance diagram for JetPlusTrackProducer:
edm::stream::EDProducer<>

Public Member Functions

 JetPlusTrackProducer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~JetPlusTrackProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Attributes

std::string alias
 
edm::EDGetTokenT< edm::View< reco::CaloJet > > input_jets_token_
 
edm::EDGetTokenT< reco::VertexCollectioninput_vertex_token_
 
JetPlusTrackCorrectormJPTalgo
 
ZSPJPTJetCorrectormZSPalgo
 
double ptCUT
 
edm::InputTag src
 
edm::InputTag srcPVs_
 
bool useZSP
 
bool vectorial_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 41 of file JetPlusTrackProducer.h.

Constructor & Destructor Documentation

JetPlusTrackProducer::JetPlusTrackProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 57 of file JetPlusTrackProducer.cc.

References SiStripOfflineCRack_cfg::alias, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), RecoJPTJets_cff::ptCUT, and TrackRefitter_38T_cff::src.

57  {
58  //register your products
59  src = iConfig.getParameter<edm::InputTag>("src");
60  alias = iConfig.getUntrackedParameter<string>("alias");
61  srcPVs_ = iConfig.getParameter<edm::InputTag>("srcPVs");
62  vectorial_ = iConfig.getParameter<bool>("VectorialCorrection");
63  useZSP = iConfig.getParameter<bool>("UseZSP");
64  ptCUT = iConfig.getParameter<double>("ptCUT");
65  mJPTalgo = new JetPlusTrackCorrector(iConfig, consumesCollector());
66  if (useZSP)
67  mZSPalgo = new ZSPJPTJetCorrector(iConfig);
68 
69  produces<reco::JPTJetCollection>().setBranchAlias(alias);
70 
71  input_jets_token_ = consumes<edm::View<reco::CaloJet> >(src);
72  input_vertex_token_ = consumes<reco::VertexCollection>(srcPVs_);
73 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::View< reco::CaloJet > > input_jets_token_
ZSPJPTJetCorrector * mZSPalgo
Jet energy correction algorithm using tracks.
JetPlusTrackCorrector * mJPTalgo
edm::EDGetTokenT< reco::VertexCollection > input_vertex_token_
JetPlusTrackProducer::~JetPlusTrackProducer ( )
override

Definition at line 75 of file JetPlusTrackProducer.cc.

75  {
76  // do anything here that needs to be done at desctruction time
77  // (e.g. close files, deallocate resources etc.)
78 }

Member Function Documentation

void JetPlusTrackProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 85 of file JetPlusTrackProducer.cc.

References edm::RefVector< C, T, F >::begin(), SiPixelRawToDigiRegional_cfi::deltaPhi, PbPb_ZMuSkimMuonDPG_cff::deltaR, singleTopDQM_cfi::elecs, reco::JPTJet::Specific::elecsInVertexInCalo, reco::JPTJet::Specific::elecsInVertexOutCalo, reco::JPTJet::Specific::elecsOutVertexInCalo, edm::RefVector< C, T, F >::end(), reco::LeafCandidate::energy(), reco::JPTJet::Specific::Eta2momtr, dqmMemoryStats::float, edm::Event::getByToken(), reco::Jet::getJetConstituents(), mps_fire::i, jpt::MatchedTracks::inVertexInCalo_, jpt::MatchedTracks::inVertexOutOfCalo_, edm::HandleBase::isValid(), reco::JPTJet::Specific::mChargedHadronEnergy, eostools::move(), reco::JPTJet::Specific::mResponseOfChargedWithEff, reco::JPTJet::Specific::mResponseOfChargedWithoutEff, reco::JPTJet::Specific::mSumEnergyOfChargedWithEff, reco::JPTJet::Specific::mSumEnergyOfChargedWithoutEff, reco::JPTJet::Specific::mSumPtOfChargedWithEff, reco::JPTJet::Specific::mSumPtOfChargedWithoutEff, PDWG_BPHSkim_cff::muons, reco::JPTJet::Specific::muonsInVertexInCalo, reco::JPTJet::Specific::muonsInVertexOutCalo, reco::JPTJet::Specific::muonsOutVertexInCalo, reco::JPTJet::Specific::mZSPCor, convertSQLiteXML::ok, jpt::MatchedTracks::outOfVertexInCalo_, p4, reco::JPTJet::Specific::Phi2momtr, reco::JPTJet::Specific::pionsInVertexInCalo, reco::JPTJet::Specific::pionsInVertexOutCalo, reco::JPTJet::Specific::pionsOutVertexInCalo, reco::JPTJet::Specific::Pout, RecoJPTJets_cff::ptCUT, edm::Event::put(), anotherprimaryvertexanalyzer_cfi::pvCollection, reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::LeafCandidate::pz(), reco::JPTJet::Specific::R2momtr, reco::Jet::scaleEnergy(), timingPdfMaker::specific, mathSSE::sqrt(), reco::JPTJet::Specific::theCaloJetRef, and reco::JPTJet::Specific::Zch.

85  {
86  using namespace edm;
87 
88  // std::cout<<" RecoJets::JetPlusTrackProducer::produce "<<std::endl;
89 
90  // get stuff from Event
92  iEvent.getByToken(input_jets_token_, jets_h);
93 
94  // auto pOut = std::make_unique<reco::CaloJetCollection>();
95  auto pOut = std::make_unique<reco::JPTJetCollection>();
96 
97  for (unsigned i = 0; i < jets_h->size(); ++i) {
98  const reco::CaloJet* oldjet = &(*(jets_h->refAt(i)));
99 
100  reco::CaloJet corrected = *oldjet;
101 
102  // ZSP corrections
103 
104  double factorZSP = 1.;
105  if (useZSP)
106  factorZSP = mZSPalgo->correction(corrected, iEvent, iSetup);
107 
108  corrected.scaleEnergy(factorZSP);
109 
110  // JPT corrections
111 
112  double scaleJPT = 1.;
113 
115 
116  jpt::MatchedTracks pions;
119  bool ok = false;
120 
121  if (!vectorial_) {
122  scaleJPT = mJPTalgo->correction(corrected, *oldjet, iEvent, iSetup, pions, muons, elecs, ok);
123  p4 = math::XYZTLorentzVector(corrected.px() * scaleJPT,
124  corrected.py() * scaleJPT,
125  corrected.pz() * scaleJPT,
126  corrected.energy() * scaleJPT);
127  } else {
128  scaleJPT = mJPTalgo->correction(corrected, *oldjet, iEvent, iSetup, p4, pions, muons, elecs, ok);
129  }
130 
132 
133  if (ok) {
134  specific.pionsInVertexInCalo = pions.inVertexInCalo_;
135  specific.pionsInVertexOutCalo = pions.inVertexOutOfCalo_;
136  specific.pionsOutVertexInCalo = pions.outOfVertexInCalo_;
137  specific.muonsInVertexInCalo = muons.inVertexInCalo_;
138  specific.muonsInVertexOutCalo = muons.inVertexOutOfCalo_;
139  specific.muonsOutVertexInCalo = muons.outOfVertexInCalo_;
140  specific.elecsInVertexInCalo = elecs.inVertexInCalo_;
141  specific.elecsInVertexOutCalo = elecs.inVertexOutOfCalo_;
142  specific.elecsOutVertexInCalo = elecs.outOfVertexInCalo_;
143  }
144 
145  // Fill JPT Specific
146  edm::RefToBase<reco::Jet> myjet = (edm::RefToBase<reco::Jet>)jets_h->refAt(i);
147  specific.theCaloJetRef = myjet;
148  specific.mZSPCor = factorZSP;
156 
157  // Fill Charged Jet shape parameters
158  double deR2Tr = 0.;
159  double deEta2Tr = 0.;
160  double dePhi2Tr = 0.;
161  double Zch = 0.;
162  double Pout2 = 0.;
163  double Pout = 0.;
164  double denominator_tracks = 0.;
165  int ntracks = 0;
166 
168  it++) {
169  double deR = deltaR((*it)->eta(), (*it)->phi(), p4.eta(), p4.phi());
170  double deEta = (*it)->eta() - p4.eta();
171  double dePhi = deltaPhi((*it)->phi(), p4.phi());
172  if ((**it).ptError() / (**it).pt() < 0.1) {
173  deR2Tr = deR2Tr + deR * deR * (*it)->pt();
174  deEta2Tr = deEta2Tr + deEta * deEta * (*it)->pt();
175  dePhi2Tr = dePhi2Tr + dePhi * dePhi * (*it)->pt();
176  denominator_tracks = denominator_tracks + (*it)->pt();
177  Zch = Zch + (*it)->pt();
178 
179  Pout2 = Pout2 + (**it).p() * (**it).p() - (Zch * p4.P()) * (Zch * p4.P());
180  ntracks++;
181  }
182  }
183 
185  it++) {
186  double deR = deltaR((*it)->eta(), (*it)->phi(), p4.eta(), p4.phi());
187  double deEta = (*it)->eta() - p4.eta();
188  double dePhi = deltaPhi((*it)->phi(), p4.phi());
189  if ((**it).ptError() / (**it).pt() < 0.1) {
190  deR2Tr = deR2Tr + deR * deR * (*it)->pt();
191  deEta2Tr = deEta2Tr + deEta * deEta * (*it)->pt();
192  dePhi2Tr = dePhi2Tr + dePhi * dePhi * (*it)->pt();
193  denominator_tracks = denominator_tracks + (*it)->pt();
194  Zch = Zch + (*it)->pt();
195 
196  Pout2 = Pout2 + (**it).p() * (**it).p() - (Zch * p4.P()) * (Zch * p4.P());
197  ntracks++;
198  }
199  }
201  it++) {
202  double deR = deltaR((*it)->eta(), (*it)->phi(), p4.eta(), p4.phi());
203  double deEta = (*it)->eta() - p4.eta();
204  double dePhi = deltaPhi((*it)->phi(), p4.phi());
205  if ((**it).ptError() / (**it).pt() < 0.1) {
206  deR2Tr = deR2Tr + deR * deR * (*it)->pt();
207  deEta2Tr = deEta2Tr + deEta * deEta * (*it)->pt();
208  dePhi2Tr = dePhi2Tr + dePhi * dePhi * (*it)->pt();
209  denominator_tracks = denominator_tracks + (*it)->pt();
210  Zch = Zch + (*it)->pt();
211 
212  Pout2 = Pout2 + (**it).p() * (**it).p() - (Zch * p4.P()) * (Zch * p4.P());
213  ntracks++;
214  }
215  }
217  it != pions.inVertexOutOfCalo_.end();
218  it++) {
219  Zch = Zch + (*it)->pt();
220  }
222  it != muons.inVertexOutOfCalo_.end();
223  it++) {
224  Zch = Zch + (*it)->pt();
225  }
227  it != elecs.inVertexOutOfCalo_.end();
228  it++) {
229  Zch = Zch + (*it)->pt();
230  }
231 
232  if (mJPTalgo->getSumPtForBeta() > 0.)
233  Zch = Zch / mJPTalgo->getSumPtForBeta();
234 
235  // std::cout<<" Zch "<< Zch<<" "<<mJPTalgo->getSumPtForBeta()<<std::endl;
236 
237  if (ntracks > 0) {
238  Pout = sqrt(fabs(Pout2)) / ntracks;
239  }
240  if (denominator_tracks != 0) {
241  deR2Tr = deR2Tr / denominator_tracks;
242  deEta2Tr = deEta2Tr / denominator_tracks;
243  dePhi2Tr = dePhi2Tr / denominator_tracks;
244  }
245 
246  specific.R2momtr = deR2Tr;
247  specific.Eta2momtr = deEta2Tr;
248  specific.Phi2momtr = dePhi2Tr;
249  specific.Pout = Pout;
250  specific.Zch = Zch;
251 
252  // std::cout<<" Moments for charged component "<<deR2_Tr<<" "<<deEta2_Tr<<" "<<dePhi2_Tr<<std::endl;
253 
254  // Create JPT jet
255 
256  reco::Particle::Point vertex_ = reco::Jet::Point(0, 0, 0);
257 
258  // If we add primary vertex
260  iEvent.getByToken(input_vertex_token_, pvCollection);
261  if (pvCollection.isValid() && !pvCollection->empty())
262  vertex_ = pvCollection->begin()->position();
263 
264  reco::JPTJet fJet(p4, vertex_, specific, corrected.getJetConstituents());
265 
266  // fJet.printJet();
267 
268  // Output module
269  if (fJet.pt() > ptCUT)
270  pOut->push_back(fJet);
271  }
272 
273  iEvent.put(std::move(pOut));
274 }
reco::TrackRefVector muonsInVertexOutCalo
Definition: JPTJet.h:54
float mSumEnergyOfChargedWithoutEff
Definition: JPTJet.h:68
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
Jets made from CaloTowers.
Definition: CaloJet.h:27
reco::TrackRefVector muonsInVertexInCalo
Definition: JPTJet.h:53
virtual void scaleEnergy(double fScale)
scale energy of the jet
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
double px() const final
x coordinate of momentum vector
float mChargedHadronEnergy
Definition: JPTJet.h:59
float mSumPtOfChargedWithEff
Definition: JPTJet.h:65
reco::TrackRefVector inVertexInCalo_
reco::TrackRefVector muonsOutVertexInCalo
Definition: JPTJet.h:55
reco::TrackRefVector inVertexOutOfCalo_
virtual double correction(const reco::Jet &, const edm::Event &, const edm::EventSetup &) const
apply correction using Event information
float mResponseOfChargedWithEff
Definition: JPTJet.h:63
edm::EDGetTokenT< edm::View< reco::CaloJet > > input_jets_token_
reco::TrackRefVector elecsOutVertexInCalo
Definition: JPTJet.h:58
virtual Constituents getJetConstituents() const
list of constituents
reco::TrackRefVector pionsInVertexOutCalo
Definition: JPTJet.h:51
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
ZSPJPTJetCorrector * mZSPalgo
double pz() const final
z coordinate of momentum vector
T sqrt(T t)
Definition: SSEVec.h:19
double p4[4]
Definition: TauolaWrapper.h:92
Jets made from CaloJets corrected for ZSP and tracks.
Definition: JPTJet.h:28
double correction(const reco::Jet &, const reco::Jet &, const edm::Event &, const edm::EventSetup &, P4 &, jpt::MatchedTracks &pions, jpt::MatchedTracks &muons, jpt::MatchedTracks &elecs, bool &validMatches)
Vectorial correction method (corrected 4-momentum passed by reference)
double getResponseOfChargedWithEff()
Get responses/sumPT/SumEnergy with and without Efficiency correction.
reco::TrackRefVector pionsOutVertexInCalo
Definition: JPTJet.h:52
double energy() const final
energy
float mSumEnergyOfChargedWithEff
Definition: JPTJet.h:67
math::XYZPoint Point
point in the space
Definition: Particle.h:25
reco::TrackRefVector outOfVertexInCalo_
reco::TrackRefVector elecsInVertexInCalo
Definition: JPTJet.h:56
bool isValid() const
Definition: HandleBase.h:70
edm::RefToBase< reco::Jet > theCaloJetRef
Definition: JPTJet.h:49
float mResponseOfChargedWithoutEff
Definition: JPTJet.h:64
reco::TrackRefVector pionsInVertexInCalo
Definition: JPTJet.h:50
float mSumPtOfChargedWithoutEff
Definition: JPTJet.h:66
double py() const final
y coordinate of momentum vector
reco::TrackRefVector elecsInVertexOutCalo
Definition: JPTJet.h:57
Particles matched to tracks that are in/in, in/out, out/in at Vertex and CaloFace.
HLT enums.
JetPlusTrackCorrector * mJPTalgo
edm::EDGetTokenT< reco::VertexCollection > input_vertex_token_
def move(src, dest)
Definition: eostools.py:511
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:27

Member Data Documentation

std::string JetPlusTrackProducer::alias
private

Definition at line 53 of file JetPlusTrackProducer.h.

edm::EDGetTokenT<edm::View<reco::CaloJet> > JetPlusTrackProducer::input_jets_token_
private

Definition at line 58 of file JetPlusTrackProducer.h.

edm::EDGetTokenT<reco::VertexCollection> JetPlusTrackProducer::input_vertex_token_
private

Definition at line 59 of file JetPlusTrackProducer.h.

JetPlusTrackCorrector* JetPlusTrackProducer::mJPTalgo
private

Definition at line 49 of file JetPlusTrackProducer.h.

ZSPJPTJetCorrector* JetPlusTrackProducer::mZSPalgo
private

Definition at line 50 of file JetPlusTrackProducer.h.

double JetPlusTrackProducer::ptCUT
private

Definition at line 56 of file JetPlusTrackProducer.h.

edm::InputTag JetPlusTrackProducer::src
private

Definition at line 51 of file JetPlusTrackProducer.h.

edm::InputTag JetPlusTrackProducer::srcPVs_
private

Definition at line 52 of file JetPlusTrackProducer.h.

bool JetPlusTrackProducer::useZSP
private

Definition at line 55 of file JetPlusTrackProducer.h.

bool JetPlusTrackProducer::vectorial_
private

Definition at line 54 of file JetPlusTrackProducer.h.