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
JetPlusTrackProducerAA Class Reference

#include <JetPlusTrackProducerAA.cc>

Inheritance diagram for JetPlusTrackProducerAA:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginJob ()
 
reco::TrackRefVector calculateBGtracksJet (reco::JPTJetCollection &, std::vector< reco::TrackRef > &, edm::Handle< std::vector< reco::TrackExtrapolation > > &, reco::TrackRefVector &)
 
virtual void endJob ()
 
 JetPlusTrackProducerAA (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~JetPlusTrackProducerAA ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

std::string alias
 
edm::EDGetTokenT< std::vector
< reco::TrackExtrapolation > > 
input_extrapolations_token_
 
edm::EDGetTokenT< edm::View
< reco::CaloJet > > 
input_jets_token_
 
edm::EDGetTokenT
< reco::TrackCollection
input_tracks_token_
 
edm::EDGetTokenT
< reco::VertexCollection
input_vertex_token_
 
double mConeSize
 
edm::InputTag mExtrapolations
 
JetPlusTrackCorrectormJPTalgo
 
edm::InputTag mTracks
 
ZSPJPTJetCorrectormZSPalgo
 
edm::InputTag src
 
edm::InputTag srcPVs_
 
reco::TrackBase::TrackQuality trackQuality_
 
bool useZSP
 
bool vectorial_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 56 of file JetPlusTrackProducerAA.h.

Constructor & Destructor Documentation

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

Definition at line 79 of file JetPlusTrackProducerAA.cc.

References HLT_FULL_cff::alias, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), reco::TrackBase::qualityByName(), alcazmumu_cfi::src, and AlCaHLTBitMon_QueryRunRegistry::string.

80 {
81  //register your products
82  src = iConfig.getParameter<edm::InputTag>("src");
83  alias = iConfig.getUntrackedParameter<string>("alias");
84  mTracks = iConfig.getParameter<edm::InputTag> ("tracks");
85  srcPVs_ = iConfig.getParameter<edm::InputTag>("srcPVs");
86  vectorial_ = iConfig.getParameter<bool>("VectorialCorrection");
87  useZSP = iConfig.getParameter<bool>("UseZSP");
88  std::string tq = iConfig.getParameter<std::string>("TrackQuality");
90  mConeSize = iConfig.getParameter<double> ("coneSize");
91 //=>
92  mExtrapolations = iConfig.getParameter<edm::InputTag> ("extrapolations");
93 //=>
95  if(useZSP) mZSPalgo = new ZSPJPTJetCorrector(iConfig);
96 
97  produces<reco::JPTJetCollection>().setBranchAlias(alias);
98 
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);
103 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
reco::TrackBase::TrackQuality trackQuality_
ZSPJPTJetCorrector * mZSPalgo
edm::EDGetTokenT< edm::View< reco::CaloJet > > input_jets_token_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
JetPlusTrackCorrector * mJPTalgo
edm::EDGetTokenT< reco::TrackCollection > input_tracks_token_
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:125
edm::EDGetTokenT< reco::VertexCollection > input_vertex_token_
Jet energy correction algorithm using tracks.
edm::EDGetTokenT< std::vector< reco::TrackExtrapolation > > input_extrapolations_token_
JetPlusTrackProducerAA::~JetPlusTrackProducerAA ( )

Definition at line 106 of file JetPlusTrackProducerAA.cc.

107 {
108 
109  // do anything here that needs to be done at desctruction time
110  // (e.g. close files, deallocate resources etc.)
111 
112 }

Member Function Documentation

void JetPlusTrackProducerAA::beginJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 481 of file JetPlusTrackProducerAA.cc.

482 {
483 }
reco::TrackRefVector JetPlusTrackProducerAA::calculateBGtracksJet ( reco::JPTJetCollection fJets,
std::vector< reco::TrackRef > &  fTracks,
edm::Handle< std::vector< reco::TrackExtrapolation > > &  extrapolations_h,
reco::TrackRefVector trBgOutOfCalo 
)

Definition at line 390 of file JetPlusTrackProducerAA.cc.

References edm::RefVector< C, T, F >::begin(), edm::RefVector< C, T, F >::end(), reco::LeafCandidate::eta(), reco::TrackBase::eta(), spr::find(), j, metsig::jet, reco::btau::jetEta, reco::btau::jetPhi, M_PI, reco::LeafCandidate::phi(), reco::TrackBase::phi(), edm::RefVector< C, T, F >::push_back(), lumiQTWidget::t, reco::btau::trackEta, and reco::btau::trackPhi.

392  {
393 
394 
395  reco::TrackRefVector trBgOutOfVertex;
396 
397  for (unsigned t = 0; t < fTracks.size(); ++t) {
398 
399  int track_bg = 0;
400 
401  // if(!(*fTracks[t]).quality(trackQuality_))
402  // {
403  // cout<<"BG, BAD trackQuality, ptBgV="<<fTracks[t]->pt()<<" etaBgV = "<<fTracks[t]->eta()<<" phiBgV = "<<fTracks[t]->phi()<<endl;
404  // continue;
405  // }
406 
407  const reco::Track* track = &*(fTracks[t]);
408  double trackEta = track->eta();
409  double trackPhi = track->phi();
410 
411  // std::cout<<"++++++++++++++++> track="<<t<<" trackEta="<<trackEta<<" trackPhi="<<trackPhi
412  // <<" coneSize="<<mConeSize<<std::endl;
413 
414  //loop on jets
415  for (unsigned j = 0; j < fJets.size(); ++j) {
416 
417  const reco::Jet* jet = &(fJets[j]);
418  double jetEta = jet->eta();
419  double jetPhi = jet->phi();
420 
421  // std::cout<<"-jet="<<j<<" jetEt ="<<jet->pt()
422  // <<" jetE="<<jet->energy()<<" jetEta="<<jetEta<<" jetPhi="<<jetPhi<<std::endl;
423 
424  if(fabs(jetEta - trackEta) < mConeSize) {
425  double dphiTrackJet = fabs(trackPhi - jetPhi);
426  if(dphiTrackJet > M_PI) dphiTrackJet = 2*M_PI - dphiTrackJet;
427 
428  if(dphiTrackJet < mConeSize)
429  {
430  track_bg = 1;
431  // std::cout<<"===>>>> Track inside jet at vertex, track_bg="<< track_bg <<" track="<<t<<" jet="<<j
432  // <<" trackEta="<<trackEta<<" trackPhi="<<trackPhi
433  // <<" jetEta="<<jetEta<<" jetPhi="<<jetPhi<<std::endl;
434  }
435  }
436  } //jets
437 
438  if( track_bg == 0 )
439  {
440  trBgOutOfVertex.push_back (fTracks[t]);
441 
442 // std::cout<<"------Track outside jet at vertex, track_bg="<< track_bg<<" track="<<t
443 // <<" trackEta="<<trackEta<<" trackPhi="<<trackPhi <<std::endl;
444  }
445 
446  } //tracks
447 
448 //=====> Propagate BG tracks to calo
449  int nValid = 0;
450  for ( std::vector<reco::TrackExtrapolation>::const_iterator xtrpBegin = extrapolations_h->begin(),
451  xtrpEnd = extrapolations_h->end(), ixtrp = xtrpBegin;
452  ixtrp != xtrpEnd; ++ixtrp ) {
453 
454 // std::cout<<"JetPlusTrackProducerAA::calculateBGtracksJet: initial track pt= "<<ixtrp->track()->pt()
455 // <<" eta= "<<ixtrp->track()->eta()<<" phi="<<ixtrp->track()->phi()
456 // <<" Valid? "<<ixtrp->isValid().at(0)<<std::endl;
457 
458  //if( ixtrp->isValid().at(0) == 0 ) continue;
459  //in DF change in 4.2, all entries are valid.
460  nValid++;
461 
462  reco::TrackRefVector::iterator it = find(trBgOutOfVertex.begin(),trBgOutOfVertex.end(),(*ixtrp).track() );
463 
464  if ( it != trBgOutOfVertex.end() ){
465  trBgOutOfCalo.push_back (*it);
466 
467 // std::cout<<"+++trBgOutOfCalo, pt= "<<ixtrp->track()->pt()<<" eta= "<<ixtrp->track()->eta()<<" phi="<<ixtrp->track()->phi()
468 // <<" Valid? "<<ixtrp->isValid().at(0)<<std::endl;
469  }
470 
471  }
472 
473 // std::cout<<"calculateBGtracksJet, trBgOutOfCalo="<<trBgOutOfCalo.size()
474 // <<" trBgOutOfVertex="<<trBgOutOfVertex.size()<<" nValid="<<nValid<<endl;
475 //=====>
476 
477  return trBgOutOfVertex;
478 }
Base class for all types of Jets.
Definition: Jet.h:20
virtual double phi() const final
momentum azimuthal angle
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:640
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:255
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:250
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:646
int j
Definition: DBlmapReader.cc:9
#define M_PI
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:62
virtual double eta() const final
momentum pseudorapidity
void JetPlusTrackProducerAA::endJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 487 of file JetPlusTrackProducerAA.cc.

487  {
488 }
void JetPlusTrackProducerAA::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 121 of file JetPlusTrackProducerAA.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::getByToken(), reco::Jet::getJetConstituents(), i, jpt::MatchedTracks::inVertexInCalo_, jpt::MatchedTracks::inVertexOutOfCalo_, edm::HandleBase::isValid(), M_PI, 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(), edm::second(), timingPdfMaker::specific, mathSSE::sqrt(), reco::JPTJet::Specific::theCaloJetRef, and reco::JPTJet::Specific::Zch.

122 {
123  using namespace edm;
124 
125 
126 // std::cout<<" RecoJets::JetPlusTrackProducerAA::produce "<<std::endl;
127 
128 // get stuff from Event
130  iEvent.getByToken (input_jets_token_, jets_h);
131 
133  iEvent.getByToken (input_tracks_token_, tracks_h);
134 
135  std::vector <reco::TrackRef> fTracks;
136  fTracks.reserve (tracks_h->size());
137  for (unsigned i = 0; i < tracks_h->size(); ++i) {
138  fTracks.push_back (reco::TrackRef (tracks_h, i));
139  }
140 
141 //=>
143  iEvent.getByToken(input_extrapolations_token_, extrapolations_h);
144 
145 // std::cout<<"JetPlusTrackProducerAA::produce, extrapolations_h="<<extrapolations_h->size()<<std::endl;
146 //=>
147 
148  std::auto_ptr<reco::JPTJetCollection> pOut(new reco::JPTJetCollection());
149 
150  reco::JPTJetCollection tmpColl;
151 
152  for (unsigned i = 0; i < jets_h->size(); ++i) {
153 
154  const reco::CaloJet* oldjet = &(*(jets_h->refAt(i)));
155 
156  reco::CaloJet corrected = *oldjet;
157 
158 // ZSP corrections
159 
160  double factorZSP = 1.;
161  if(useZSP) factorZSP = mZSPalgo->correction(corrected, iEvent, iSetup);
162 
163 // std::cout << " UseZSP = "<<useZSP<<std::endl;
164 
165 
166  corrected.scaleEnergy (factorZSP);
167 
168 // JPT corrections
169 
170  double scaleJPT = 1.;
171 
173 
174 // Construct JPTJet constituent
175  jpt::MatchedTracks pions;
177  jpt::MatchedTracks elecs;
178  bool ok=false;
179 
180  if ( !vectorial_ ) {
181 
182  scaleJPT = mJPTalgo->correction ( corrected, *oldjet, iEvent, iSetup, pions, muons, elecs, ok );
183  p4 = math::XYZTLorentzVector( corrected.px()*scaleJPT,
184  corrected.py()*scaleJPT,
185  corrected.pz()*scaleJPT,
186  corrected.energy()*scaleJPT );
187  } else {
188  scaleJPT = mJPTalgo->correction( corrected, *oldjet, iEvent, iSetup, p4, pions, muons, elecs, ok );
189  }
190 
191 
192 
194 
195  if(ok) {
196 // std::cout<<" Size of Pion in-in "<<pions.inVertexInCalo_.size()<<" in-out "<<pions.inVertexOutOfCalo_.size()
197 // <<" out-in "<<pions.outOfVertexInCalo_.size()<<" Oldjet "<<oldjet->et()<<" factorZSP "<<factorZSP
198 // <<" "<<corrected.et()<<" scaleJPT "<<scaleJPT<<" after JPT "<<p4.pt()<<std::endl;
199 
200 
201  specific.pionsInVertexInCalo = pions.inVertexInCalo_;
202  specific.pionsInVertexOutCalo = pions.inVertexOutOfCalo_;
203  specific.pionsOutVertexInCalo = pions.outOfVertexInCalo_;
204  specific.muonsInVertexInCalo = muons.inVertexInCalo_;
205  specific.muonsInVertexOutCalo = muons.inVertexOutOfCalo_;
206  specific.muonsOutVertexInCalo = muons.outOfVertexInCalo_;
207  specific.elecsInVertexInCalo = elecs.inVertexInCalo_;
208  specific.elecsInVertexOutCalo = elecs.inVertexOutOfCalo_;
209  specific.elecsOutVertexInCalo = elecs.outOfVertexInCalo_;
210  }
211 
212 // Fill JPT Specific
213  edm::RefToBase<reco::Jet> myjet = (edm::RefToBase<reco::Jet>)jets_h->refAt(i);
214  specific.theCaloJetRef = myjet;
215  specific.mZSPCor = factorZSP;
218  specific.mSumPtOfChargedWithEff = (float)mJPTalgo->getSumPtWithEff();
223 // Fill Charged Jet shape parameters
224  double deR2Tr = 0.;
225  double deEta2Tr = 0.;
226  double dePhi2Tr = 0.;
227  double Zch = 0.;
228  double Pout2 = 0.;
229  double Pout = 0.;
230  double denominator_tracks = 0.;
231  int ntracks = 0;
232 
233  for( reco::TrackRefVector::const_iterator it = pions.inVertexInCalo_.begin(); it != pions.inVertexInCalo_.end(); it++) {
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();
243 
244  Pout2 = Pout2 + (**it).p()*(**it).p() - (Zch*p4.P())*(Zch*p4.P());
245  ntracks++;
246  }
247  }
248  for( reco::TrackRefVector::const_iterator it = muons.inVertexInCalo_.begin(); it != muons.inVertexInCalo_.end(); it++) {
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();
258 
259  Pout2 = Pout2 + (**it).p()*(**it).p() - (Zch*p4.P())*(Zch*p4.P());
260  ntracks++;
261  }
262  }
263  for( reco::TrackRefVector::const_iterator it = elecs.inVertexInCalo_.begin(); it != elecs.inVertexInCalo_.end(); it++) {
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();
273 
274  Pout2 = Pout2 + (**it).p()*(**it).p() - (Zch*p4.P())*(Zch*p4.P());
275  ntracks++;
276  }
277  }
278  for( reco::TrackRefVector::const_iterator it = pions.inVertexOutOfCalo_.begin(); it != pions.inVertexOutOfCalo_.end(); it++) {
279  Zch = Zch + (*it)->pt();
280  }
281  for( reco::TrackRefVector::const_iterator it = muons.inVertexOutOfCalo_.begin(); it != muons.inVertexOutOfCalo_.end(); it++) {
282  Zch = Zch + (*it)->pt();
283  }
284  for( reco::TrackRefVector::const_iterator it = elecs.inVertexOutOfCalo_.begin(); it != elecs.inVertexOutOfCalo_.end(); it++) {
285  Zch = Zch + (*it)->pt();
286  }
287 
288  if(mJPTalgo->getSumPtForBeta()> 0.) Zch = Zch/mJPTalgo->getSumPtForBeta();
289 
290  // std::cout<<" Zch "<< Zch<<" "<<mJPTalgo->getSumPtForBeta()<<std::endl;
291 
292  if(ntracks > 0) {
293  Pout = sqrt(fabs(Pout2))/ntracks;
294  }
295 
296 
297  if (denominator_tracks!=0){
298  deR2Tr = deR2Tr/denominator_tracks;
299  deEta2Tr= deEta2Tr/denominator_tracks;
300  dePhi2Tr= dePhi2Tr/denominator_tracks;
301  }
302 
303  specific.R2momtr = deR2Tr;
304  specific.Eta2momtr = deEta2Tr;
305  specific.Phi2momtr = dePhi2Tr;
306  specific.Pout = Pout;
307  specific.Zch = Zch;
308 
309 // Create JPT jet
310 
312 
313 // If we add primary vertex
315  iEvent.getByToken(input_vertex_token_, pvCollection);
316  if ( pvCollection.isValid() && pvCollection->size()>0 ) vertex_=pvCollection->begin()->position();
317 
318  reco::JPTJet fJet(p4, vertex_, specific, corrected.getJetConstituents());
319  // fJet.printJet();
320 
321 // Temporarily collection before correction for background
322 
323  tmpColl.push_back(fJet);
324 
325  }
326 
327 //=======================================================================================================>
328 // Correction for background
329 
330  reco::TrackRefVector trBgOutOfCalo;
331  reco::TrackRefVector trBgOutOfVertex = calculateBGtracksJet(tmpColl,fTracks,extrapolations_h,trBgOutOfCalo);
332 
333 //===> Area without Jets
334  std::map<reco::JPTJetCollection::iterator, double> AreaNonJet;
335 
336  for(reco::JPTJetCollection::iterator ij1=tmpColl.begin(); ij1!=tmpColl.end(); ij1++)
337  {
338  int nj1 = 1;
339  for(reco::JPTJetCollection::iterator ij2=tmpColl.begin(); ij2!=tmpColl.end(); ij2++)
340  {
341  if(ij2 == ij1) continue;
342  if(fabs((*ij1).eta() - (*ij2).eta()) > 0.5 ) continue;
343  nj1++;
344 
345  }
346 
347  AreaNonJet[ij1] = 4*M_PI*mConeSize - nj1*4*mConeSize*mConeSize;
348 
349 // std::cout<<"+++AreaNonJet[ij1]="<<AreaNonJet[ij1]<<" nj1="<<nj1<<std::endl;
350  }
351 
352 //===>
353 
354 // std::cout<<" The size of BG tracks: trBgOutOfVertex= "<<trBgOutOfVertex.size()
355 // <<" trBgOutOfCalo= "<<trBgOutOfCalo.size()<<std::endl;
356 //
357 // std::cout<<" The size of JPT jet collection "<<tmpColl.size()<<std::endl;
358 
359  for(reco::JPTJetCollection::iterator ij=tmpColl.begin(); ij!=tmpColl.end(); ij++)
360  {
361 // Correct JPTjet for background tracks
362 
363  const reco::TrackRefVector pioninin = (*ij).getPionsInVertexInCalo();
364  const reco::TrackRefVector pioninout = (*ij).getPionsInVertexOutCalo();
365 
366  double ja = (AreaNonJet.find(ij))->second;
367 
368 // std::cout<<"+++ ja="<<ja<<" pioninout="<<pioninout.size()<<std::endl;
369 
370  double factorPU = mJPTalgo->correctAA(*ij,trBgOutOfVertex,mConeSize,pioninin,pioninout,ja,trBgOutOfCalo);
371 
372  (*ij).scaleEnergy (factorPU);
373 
374 // std::cout<<" FactorPU "<<factorPU<<std::endl;
375 
376 // Output module
377  pOut->push_back(*ij);
378 
379 // std::cout<<" New JPT energy "<<(*ij).et()<<" "<<(*ij).pt()<<" "<<(*ij).eta()<<" "<<(*ij).phi()<<std::endl;
380 
381  }
382 
383  iEvent.put(pOut);
384 
385 }
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:29
reco::TrackRefVector muonsInVertexInCalo
Definition: JPTJet.h:56
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 &)
virtual double energy() const final
energy
ZSPJPTJetCorrector * mZSPalgo
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
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
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
virtual Constituents getJetConstituents() const
list of constituents
reco::TrackRefVector pionsInVertexOutCalo
Definition: JPTJet.h:54
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:255
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:250
edm::EDGetTokenT< edm::View< reco::CaloJet > > input_jets_token_
U second(std::pair< T, U > const &p)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
T sqrt(T t)
Definition: SSEVec.h:18
double p4[4]
Definition: TauolaWrapper.h:92
Jets made from CaloJets corrected for ZSP and tracks.
Definition: JPTJet.h:29
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)
JetPlusTrackCorrector * mJPTalgo
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:25
reco::TrackRefVector outOfVertexInCalo_
virtual double py() const final
y coordinate of momentum vector
reco::TrackRefVector elecsInVertexInCalo
Definition: JPTJet.h:59
edm::EDGetTokenT< reco::TrackCollection > input_tracks_token_
bool isValid() const
Definition: HandleBase.h:75
double correctAA(const reco::Jet &, const reco::TrackRefVector &, double &, const reco::TrackRefVector &, const reco::TrackRefVector &, double, const reco::TrackRefVector &) const
For AA - correct in tracker.
virtual double pz() const final
z coordinate of momentum vector
#define M_PI
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
edm::EDGetTokenT< reco::VertexCollection > input_vertex_token_
float mSumPtOfChargedWithoutEff
Definition: JPTJet.h:69
reco::TrackRefVector elecsInVertexOutCalo
Definition: JPTJet.h:60
Particles matched to tracks that are in/in, in/out, out/in at Vertex and CaloFace.
tuple muons
Definition: patZpeak.py:38
virtual double px() const final
x coordinate of momentum vector
edm::EDGetTokenT< std::vector< reco::TrackExtrapolation > > input_extrapolations_token_
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:27

Member Data Documentation

std::string JetPlusTrackProducerAA::alias
private

Definition at line 76 of file JetPlusTrackProducerAA.h.

edm::EDGetTokenT<std::vector<reco::TrackExtrapolation> > JetPlusTrackProducerAA::input_extrapolations_token_
private

Definition at line 90 of file JetPlusTrackProducerAA.h.

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

Definition at line 87 of file JetPlusTrackProducerAA.h.

edm::EDGetTokenT<reco::TrackCollection> JetPlusTrackProducerAA::input_tracks_token_
private

Definition at line 89 of file JetPlusTrackProducerAA.h.

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

Definition at line 88 of file JetPlusTrackProducerAA.h.

double JetPlusTrackProducerAA::mConeSize
private

Definition at line 80 of file JetPlusTrackProducerAA.h.

edm::InputTag JetPlusTrackProducerAA::mExtrapolations
private

Definition at line 84 of file JetPlusTrackProducerAA.h.

JetPlusTrackCorrector* JetPlusTrackProducerAA::mJPTalgo
private

Definition at line 72 of file JetPlusTrackProducerAA.h.

edm::InputTag JetPlusTrackProducerAA::mTracks
private

Definition at line 79 of file JetPlusTrackProducerAA.h.

ZSPJPTJetCorrector* JetPlusTrackProducerAA::mZSPalgo
private

Definition at line 73 of file JetPlusTrackProducerAA.h.

edm::InputTag JetPlusTrackProducerAA::src
private

Definition at line 74 of file JetPlusTrackProducerAA.h.

edm::InputTag JetPlusTrackProducerAA::srcPVs_
private

Definition at line 75 of file JetPlusTrackProducerAA.h.

reco::TrackBase::TrackQuality JetPlusTrackProducerAA::trackQuality_
private

Definition at line 81 of file JetPlusTrackProducerAA.h.

bool JetPlusTrackProducerAA::useZSP
private

Definition at line 78 of file JetPlusTrackProducerAA.h.

bool JetPlusTrackProducerAA::vectorial_
private

Definition at line 77 of file JetPlusTrackProducerAA.h.