CMS 3D CMS Logo

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

#include <Type0PFMETcorrInputProducer.h>

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

Public Member Functions

 Type0PFMETcorrInputProducer (const edm::ParameterSet &)
 
 ~Type0PFMETcorrInputProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

TFormula * correction_
 
edm::EDGetTokenT< reco::VertexCollectionhardScatterVertexToken_
 
double minDz_
 
std::string moduleLabel_
 
edm::EDGetTokenT< PFCandToVertexAssMappfCandidateToVertexAssociationsToken_
 

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

Compute Type 0 (PF)MET corrections ( https://indico.cern.ch/getFile.py/access?contribId=4&resId=1&materialId=slides&confId=161159 )

Author
Christian Veelken, LLR

Definition at line 29 of file Type0PFMETcorrInputProducer.h.

Constructor & Destructor Documentation

Type0PFMETcorrInputProducer::Type0PFMETcorrInputProducer ( const edm::ParameterSet cfg)
explicit

Definition at line 13 of file Type0PFMETcorrInputProducer.cc.

References correction_, edm::ParameterSet::getParameter(), hardScatterVertexToken_, minDz_, moduleLabel_, pfCandidateToVertexAssociationsToken_, and AlCaHLTBitMon_QueryRunRegistry::string.

14  : moduleLabel_(cfg.getParameter<std::string>("@module_label")),
15  correction_(nullptr)
16 {
17  pfCandidateToVertexAssociationsToken_ = consumes<PFCandToVertexAssMap>(cfg.getParameter<edm::InputTag>("srcPFCandidateToVertexAssociations"));
18  hardScatterVertexToken_ = consumes<reco::VertexCollection>(cfg.getParameter<edm::InputTag>("srcHardScatterVertex"));
19 
20  edm::ParameterSet cfgCorrection_function = cfg.getParameter<edm::ParameterSet>("correction");
21  std::string corrFunctionName = std::string(moduleLabel_).append("correction");
22  std::string corrFunctionFormula = cfgCorrection_function.getParameter<std::string>("formula");
23  correction_ = new TFormula(corrFunctionName.data(), corrFunctionFormula.data());
24  int numParameter = correction_->GetNpar();
25  for ( int iParameter = 0; iParameter < numParameter; ++iParameter ) {
26  std::string parName = Form("par%i", iParameter);
27  double parValue = cfgCorrection_function.getParameter<double>(parName);
28  correction_->SetParameter(iParameter, parValue);
29  }
30 
31  minDz_ = cfg.getParameter<double>("minDz");
32 
33  produces<CorrMETData>();
34 }
T getParameter(std::string const &) const
edm::EDGetTokenT< PFCandToVertexAssMap > pfCandidateToVertexAssociationsToken_
edm::EDGetTokenT< reco::VertexCollection > hardScatterVertexToken_
Type0PFMETcorrInputProducer::~Type0PFMETcorrInputProducer ( )
override

Definition at line 36 of file Type0PFMETcorrInputProducer.cc.

References correction_.

37 {
38  delete correction_;
39 }

Member Function Documentation

void Type0PFMETcorrInputProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
overrideprivate

Definition at line 41 of file Type0PFMETcorrInputProducer.cc.

References Abs(), edm::AssociationMap< Tag >::begin(), correction_, DEFINE_FWK_MODULE, reco::PFCandidate::e, edm::AssociationMap< Tag >::end(), edm::Event::getByToken(), reco::PFCandidate::h, hardScatterVertexToken_, edm::Ref< C, T, F >::key(), minDz_, eostools::move(), reco::PFCandidate::mu, reco::LeafCandidate::p4(), reco::PFCandidate::particleId(), pfCandidateToVertexAssociationsToken_, phi, EnergyCorrector::pt, and edm::Event::put().

42 {
43  edm::Handle<reco::VertexCollection> hardScatterVertex;
44  evt.getByToken(hardScatterVertexToken_, hardScatterVertex);
45 
46  edm::Handle<PFCandToVertexAssMap> pfCandidateToVertexAssociations;
47  evt.getByToken(pfCandidateToVertexAssociationsToken_, pfCandidateToVertexAssociations);
48 
49  std::unique_ptr<CorrMETData> pfMEtCorrection(new CorrMETData());
50 
51  for ( PFCandToVertexAssMap::const_iterator pfCandidateToVertexAssociation = pfCandidateToVertexAssociations->begin();
52  pfCandidateToVertexAssociation != pfCandidateToVertexAssociations->end(); ++pfCandidateToVertexAssociation ) {
53  reco::VertexRef vertex = pfCandidateToVertexAssociation->key;
54  const PFCandQualityPairVector& pfCandidates_vertex = pfCandidateToVertexAssociation->val;
55 
56  bool isHardScatterVertex = false;
57  for ( reco::VertexCollection::const_iterator hardScatterVertex_i = hardScatterVertex->begin();
58  hardScatterVertex_i != hardScatterVertex->end(); ++hardScatterVertex_i ) {
59  if ( TMath::Abs(vertex->position().z() - hardScatterVertex_i->position().z()) < minDz_ ) {
60  isHardScatterVertex = true;
61  break;
62  }
63  }
64 
65  if ( !isHardScatterVertex ) {
66  reco::Candidate::LorentzVector sumChargedPFCandP4_vertex;
67  for ( PFCandQualityPairVector::const_iterator pfCandidate_vertex = pfCandidates_vertex.begin();
68  pfCandidate_vertex != pfCandidates_vertex.end(); ++pfCandidate_vertex ) {
69  const reco::PFCandidate& pfCandidate = (*pfCandidate_vertex->first);
70  if ( pfCandidate.particleId() == reco::PFCandidate::h ||
71  pfCandidate.particleId() == reco::PFCandidate::e ||
72  pfCandidate.particleId() == reco::PFCandidate::mu ) {
73  sumChargedPFCandP4_vertex += pfCandidate.p4();
74  }
75  }
76 
77  double pt = sumChargedPFCandP4_vertex.pt();
78  double phi = sumChargedPFCandP4_vertex.phi();
79  double ptCorr = correction_->Eval(pt);
80  double pxCorr = TMath::Cos(phi)*ptCorr;
81  double pyCorr = TMath::Sin(phi)*ptCorr;
82 
83  pfMEtCorrection->mex += pxCorr;
84  pfMEtCorrection->mey += pyCorr;
85  }
86  }
87 
88  evt.put(std::move(pfMEtCorrection));
89 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
key_type key() const
Accessor for product key.
Definition: Ref.h:263
T Abs(T a)
Definition: MathUtil.h:49
edm::EDGetTokenT< PFCandToVertexAssMap > pfCandidateToVertexAssociationsToken_
std::vector< PFCandQualityPair > PFCandQualityPairVector
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
edm::EDGetTokenT< reco::VertexCollection > hardScatterVertexToken_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
a MET correction term
Definition: CorrMETData.h:14
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
const_iterator begin() const
first iterator over the map (read only)
virtual ParticleType particleId() const
Definition: PFCandidate.h:374
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

TFormula* Type0PFMETcorrInputProducer::correction_
private
edm::EDGetTokenT<reco::VertexCollection> Type0PFMETcorrInputProducer::hardScatterVertexToken_
private

Definition at line 42 of file Type0PFMETcorrInputProducer.h.

Referenced by produce(), and Type0PFMETcorrInputProducer().

double Type0PFMETcorrInputProducer::minDz_
private

Definition at line 47 of file Type0PFMETcorrInputProducer.h.

Referenced by produce(), and Type0PFMETcorrInputProducer().

std::string Type0PFMETcorrInputProducer::moduleLabel_
private
edm::EDGetTokenT<PFCandToVertexAssMap> Type0PFMETcorrInputProducer::pfCandidateToVertexAssociationsToken_
private

Definition at line 43 of file Type0PFMETcorrInputProducer.h.

Referenced by produce(), and Type0PFMETcorrInputProducer().