CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
JetPlusTrackProducer Class Reference

#include <RecoJets/JetPlusTracks/src/JetPlusTrackProducer.cc>

Inheritance diagram for JetPlusTrackProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
 JetPlusTrackProducer (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~JetPlusTrackProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

std::string alias
 
JetPlusTrackCorrectormJPTalgo
 
ZSPJPTJetCorrectormZSPalgo
 
edm::InputTag src
 
edm::InputTag srcPVs_
 
bool useZSP
 
bool vectorial_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 39 of file JetPlusTrackProducer.h.

Constructor & Destructor Documentation

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

Definition at line 63 of file JetPlusTrackProducer.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and alcazmumu_cfi::src.

64 {
65  //register your products
66  src = iConfig.getParameter<edm::InputTag>("src");
67  alias = iConfig.getUntrackedParameter<string>("alias");
68  srcPVs_ = iConfig.getParameter<edm::InputTag>("srcPVs");
69  vectorial_ = iConfig.getParameter<bool>("VectorialCorrection");
70  useZSP = iConfig.getParameter<bool>("UseZSP");
71  mJPTalgo = new JetPlusTrackCorrector(iConfig);
72  if(useZSP) mZSPalgo = new ZSPJPTJetCorrector(iConfig);
73 
74  produces<reco::JPTJetCollection>().setBranchAlias(alias);
75 
76 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
ZSPJPTJetCorrector * mZSPalgo
Jet energy correction algorithm using tracks.
JetPlusTrackCorrector * mJPTalgo
JetPlusTrackProducer::~JetPlusTrackProducer ( )

Definition at line 79 of file JetPlusTrackProducer.cc.

80 {
81 
82  // do anything here that needs to be done at desctruction time
83  // (e.g. close files, deallocate resources etc.)
84 
85 }

Member Function Documentation

void JetPlusTrackProducer::beginJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 286 of file JetPlusTrackProducer.cc.

287 {
288 }
void JetPlusTrackProducer::endJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 292 of file JetPlusTrackProducer.cc.

292  {
293 }
void JetPlusTrackProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 94 of file JetPlusTrackProducer.cc.

References edm::RefVector< C, T, F >::begin(), SiPixelRawToDigiRegional_cfi::deltaPhi, deltaR(), 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, edm::Event::getByLabel(), reco::Jet::getJetConstituents(), i, jpt::MatchedTracks::inVertexInCalo_, jpt::MatchedTracks::inVertexOutOfCalo_, edm::HandleBase::isValid(), reco::JPTJet::Specific::mChargedHadronEnergy, reco::JPTJet::Specific::mResponseOfChargedWithEff, reco::JPTJet::Specific::mResponseOfChargedWithoutEff, reco::JPTJet::Specific::mSumEnergyOfChargedWithEff, reco::JPTJet::Specific::mSumEnergyOfChargedWithoutEff, reco::JPTJet::Specific::mSumPtOfChargedWithEff, reco::JPTJet::Specific::mSumPtOfChargedWithoutEff, patZpeak::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, edm::Event::put(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::LeafCandidate::pz(), reco::JPTJet::Specific::R2momtr, reco::Jet::scaleEnergy(), timingPdfMaker::specific, mathSSE::sqrt(), alcazmumu_cfi::src, reco::JPTJet::Specific::theCaloJetRef, and reco::JPTJet::Specific::Zch.

95 {
96  using namespace edm;
97 
98 
99 // std::cout<<" RecoJets::JetPlusTrackProducer::produce "<<std::endl;
100 
101 
102 // get stuff from Event
104  iEvent.getByLabel (src, jets_h);
105 
106 // std::auto_ptr<reco::CaloJetCollection> pOut(new reco::CaloJetCollection());
107  std::auto_ptr<reco::JPTJetCollection> pOut(new reco::JPTJetCollection());
108 
109  for (unsigned i = 0; i < jets_h->size(); ++i) {
110 
111  const reco::CaloJet* oldjet = &(*(jets_h->refAt(i)));
112 
113  reco::CaloJet corrected = *oldjet;
114 
115 // ZSP corrections
116 
117  double factorZSP = 1.;
118  if(useZSP) factorZSP = mZSPalgo->correction(corrected, iEvent, iSetup);
119 
120  corrected.scaleEnergy (factorZSP);
121 
122 // JPT corrections
123 
124  double scaleJPT = 1.;
125 
127 
128  jpt::MatchedTracks pions;
130  jpt::MatchedTracks elecs;
131  bool ok=false;
132 
133  if ( !vectorial_ ) {
134 
135  scaleJPT = mJPTalgo->correction ( corrected, *oldjet, iEvent, iSetup, pions, muons, elecs,ok );
136  p4 = math::XYZTLorentzVector( corrected.px()*scaleJPT,
137  corrected.py()*scaleJPT,
138  corrected.pz()*scaleJPT,
139  corrected.energy()*scaleJPT );
140  } else {
141  scaleJPT = mJPTalgo->correction( corrected, *oldjet, iEvent, iSetup, p4, pions, muons, elecs,ok );
142  }
143 
144 
146 
147  if(ok) {
148  specific.pionsInVertexInCalo = pions.inVertexInCalo_;
149  specific.pionsInVertexOutCalo = pions.inVertexOutOfCalo_;
150  specific.pionsOutVertexInCalo = pions.outOfVertexInCalo_;
151  specific.muonsInVertexInCalo = muons.inVertexInCalo_;
152  specific.muonsInVertexOutCalo = muons.inVertexOutOfCalo_;
153  specific.muonsOutVertexInCalo = muons.outOfVertexInCalo_;
154  specific.elecsInVertexInCalo = elecs.inVertexInCalo_;
155  specific.elecsInVertexOutCalo = elecs.inVertexOutOfCalo_;
156  specific.elecsOutVertexInCalo = elecs.outOfVertexInCalo_;
157  }
158 
159 // Fill JPT Specific
160  edm::RefToBase<reco::Jet> myjet = (edm::RefToBase<reco::Jet>)jets_h->refAt(i);
161  specific.theCaloJetRef = myjet;
162  specific.mZSPCor = factorZSP;
165  specific.mSumPtOfChargedWithEff = (float)mJPTalgo->getSumPtWithEff();
170 
171 // Fill Charged Jet shape parameters
172  double deR2Tr = 0.;
173  double deEta2Tr = 0.;
174  double dePhi2Tr = 0.;
175  double Zch = 0.;
176  double Pout2 = 0.;
177  double Pout = 0.;
178  double denominator_tracks = 0.;
179  int ntracks = 0;
180 
181  for( reco::TrackRefVector::const_iterator it = pions.inVertexInCalo_.begin(); it != pions.inVertexInCalo_.end(); it++) {
182  double deR = deltaR((*it)->eta(), (*it)->phi(), p4.eta(), p4.phi());
183  double deEta = (*it)->eta() - p4.eta();
184  double dePhi = deltaPhi((*it)->phi(), p4.phi());
185  if((**it).ptError()/(**it).pt() < 0.1) {
186  deR2Tr = deR2Tr + deR*deR*(*it)->pt();
187  deEta2Tr = deEta2Tr + deEta*deEta*(*it)->pt();
188  dePhi2Tr = dePhi2Tr + dePhi*dePhi*(*it)->pt();
189  denominator_tracks = denominator_tracks + (*it)->pt();
190  Zch = Zch + (*it)->pt();
191 
192  Pout2 = Pout2 + (**it).p()*(**it).p() - (Zch*p4.P())*(Zch*p4.P());
193  ntracks++;
194  }
195  }
196 
197 
198 
199  for( reco::TrackRefVector::const_iterator it = muons.inVertexInCalo_.begin(); it != muons.inVertexInCalo_.end(); it++) {
200  double deR = deltaR((*it)->eta(), (*it)->phi(), p4.eta(), p4.phi());
201  double deEta = (*it)->eta() - p4.eta();
202  double dePhi = deltaPhi((*it)->phi(), p4.phi());
203  if((**it).ptError()/(**it).pt() < 0.1) {
204  deR2Tr = deR2Tr + deR*deR*(*it)->pt();
205  deEta2Tr = deEta2Tr + deEta*deEta*(*it)->pt();
206  dePhi2Tr = dePhi2Tr + dePhi*dePhi*(*it)->pt();
207  denominator_tracks = denominator_tracks + (*it)->pt();
208  Zch = Zch + (*it)->pt();
209 
210  Pout2 = Pout2 + (**it).p()*(**it).p() - (Zch*p4.P())*(Zch*p4.P());
211  ntracks++;
212  }
213  }
214  for( reco::TrackRefVector::const_iterator it = elecs.inVertexInCalo_.begin(); it != elecs.inVertexInCalo_.end(); it++) {
215  double deR = deltaR((*it)->eta(), (*it)->phi(), p4.eta(), p4.phi());
216  double deEta = (*it)->eta() - p4.eta();
217  double dePhi = deltaPhi((*it)->phi(), p4.phi());
218  if((**it).ptError()/(**it).pt() < 0.1) {
219  deR2Tr = deR2Tr + deR*deR*(*it)->pt();
220  deEta2Tr = deEta2Tr + deEta*deEta*(*it)->pt();
221  dePhi2Tr = dePhi2Tr + dePhi*dePhi*(*it)->pt();
222  denominator_tracks = denominator_tracks + (*it)->pt();
223  Zch = Zch + (*it)->pt();
224 
225  Pout2 = Pout2 + (**it).p()*(**it).p() - (Zch*p4.P())*(Zch*p4.P());
226  ntracks++;
227  }
228  }
229  for( reco::TrackRefVector::const_iterator it = pions.inVertexOutOfCalo_.begin(); it != pions.inVertexOutOfCalo_.end(); it++) {
230  Zch = Zch + (*it)->pt();
231  }
232  for( reco::TrackRefVector::const_iterator it = muons.inVertexOutOfCalo_.begin(); it != muons.inVertexOutOfCalo_.end(); it++) {
233  Zch = Zch + (*it)->pt();
234  }
235  for( reco::TrackRefVector::const_iterator it = elecs.inVertexOutOfCalo_.begin(); it != elecs.inVertexOutOfCalo_.end(); it++) {
236  Zch = Zch + (*it)->pt();
237  }
238 
239  if(mJPTalgo->getSumPtForBeta()> 0.) Zch = Zch/mJPTalgo->getSumPtForBeta();
240 
241 // std::cout<<" Zch "<< Zch<<" "<<mJPTalgo->getSumPtForBeta()<<std::endl;
242 
243  if(ntracks > 0) {
244  Pout = sqrt(fabs(Pout2))/ntracks;
245  }
246  if (denominator_tracks!=0){
247  deR2Tr = deR2Tr/denominator_tracks;
248  deEta2Tr= deEta2Tr/denominator_tracks;
249  dePhi2Tr= dePhi2Tr/denominator_tracks;
250  }
251 
252  specific.R2momtr = deR2Tr;
253  specific.Eta2momtr = deEta2Tr;
254  specific.Phi2momtr = dePhi2Tr;
255  specific.Pout = Pout;
256  specific.Zch = Zch;
257 
258 
259 // std::cout<<" Moments for charged component "<<deR2_Tr<<" "<<deEta2_Tr<<" "<<dePhi2_Tr<<std::endl;
260 
261 
262 // Create JPT jet
263 
265 
266 // If we add primary vertex
268  iEvent.getByLabel(srcPVs_,pvCollection);
269  if ( pvCollection.isValid() && pvCollection->size()>0 ) vertex_=pvCollection->begin()->position();
270 
271  reco::JPTJet fJet(p4, vertex_, specific, corrected.getJetConstituents());
272 
273  // fJet.printJet();
274 
275 // Output module
276  pOut->push_back(fJet);
277 
278  }
279 
280  iEvent.put(pOut);
281 
282 }
reco::TrackRefVector muonsInVertexOutCalo
Definition: JPTJet.h:57
int i
Definition: DBlmapReader.cc:9
float mSumEnergyOfChargedWithoutEff
Definition: JPTJet.h:71
dictionary specific
Jets made from CaloTowers.
Definition: CaloJet.h:30
reco::TrackRefVector muonsInVertexInCalo
Definition: JPTJet.h:56
std::vector< JPTJet > JPTJetCollection
collection of CaloJet objects
float mChargedHadronEnergy
Definition: JPTJet.h:62
float mSumPtOfChargedWithEff
Definition: JPTJet.h:68
reco::TrackRefVector inVertexInCalo_
reco::TrackRefVector muonsOutVertexInCalo
Definition: JPTJet.h:58
virtual void scaleEnergy(double fScale)
scale energy of the jet
Definition: Jet.cc:445
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:66
reco::TrackRefVector elecsOutVertexInCalo
Definition: JPTJet.h:61
reco::TrackRefVector pionsInVertexOutCalo
Definition: JPTJet.h:54
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
virtual double energy() const
energy
ZSPJPTJetCorrector * mZSPalgo
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
T sqrt(T t)
Definition: SSEVec.h:46
double p4[4]
Definition: TauolaWrapper.h:92
Jets made from CaloJets corrected for ZSP and tracks.
Definition: JPTJet.h:29
double getResponseOfChargedWithEff()
Get responses/sumPT/SumEnergy with and without Efficiency correction.
reco::TrackRefVector pionsOutVertexInCalo
Definition: JPTJet.h:55
float mSumEnergyOfChargedWithEff
Definition: JPTJet.h:70
math::XYZPoint Point
point in the space
Definition: Particle.h:29
reco::TrackRefVector outOfVertexInCalo_
reco::TrackRefVector elecsInVertexInCalo
Definition: JPTJet.h:59
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) const
Vectorial correction method (corrected 4-momentum passed by reference)
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
edm::RefToBase< reco::Jet > theCaloJetRef
Definition: JPTJet.h:52
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
float mResponseOfChargedWithoutEff
Definition: JPTJet.h:67
reco::TrackRefVector pionsInVertexInCalo
Definition: JPTJet.h:53
virtual double px() const
x coordinate of momentum vector
float mSumPtOfChargedWithoutEff
Definition: JPTJet.h:69
reco::TrackRefVector elecsInVertexOutCalo
Definition: JPTJet.h:60
virtual double pz() const
z coordinate of momentum vector
Particles matched to tracks that are in/in, in/out, out/in at Vertex and CaloFace.
tuple muons
Definition: patZpeak.py:38
JetPlusTrackCorrector * mJPTalgo
virtual double py() const
y coordinate of momentum vector
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:29
virtual Constituents getJetConstituents() const
list of constituents
Definition: Jet.cc:351

Member Data Documentation

std::string JetPlusTrackProducer::alias
private

Definition at line 54 of file JetPlusTrackProducer.h.

JetPlusTrackCorrector* JetPlusTrackProducer::mJPTalgo
private

Definition at line 50 of file JetPlusTrackProducer.h.

ZSPJPTJetCorrector* JetPlusTrackProducer::mZSPalgo
private

Definition at line 51 of file JetPlusTrackProducer.h.

edm::InputTag JetPlusTrackProducer::src
private

Definition at line 52 of file JetPlusTrackProducer.h.

edm::InputTag JetPlusTrackProducer::srcPVs_
private

Definition at line 53 of file JetPlusTrackProducer.h.

bool JetPlusTrackProducer::useZSP
private

Definition at line 56 of file JetPlusTrackProducer.h.

bool JetPlusTrackProducer::vectorial_
private

Definition at line 55 of file JetPlusTrackProducer.h.