CMS 3D CMS Logo

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

#include <MultShiftMETcorrDBInputProducer.h>

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

Public Member Functions

 MultShiftMETcorrDBInputProducer (const edm::ParameterSet &)
 
 ~MultShiftMETcorrDBInputProducer () 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 Member Functions

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

Static Private Member Functions

static int translateTypeToAbsPdgId (reco::PFCandidate::ParticleType type)
 

Private Attributes

std::vector< edm::ParameterSetcfgCorrParameters_
 
int counts_
 
std::vector< double > etaMax_
 
std::vector< double > etaMin_
 
std::unique_ptr< TF1 > formula_x_
 
std::unique_ptr< TF1 > formula_y_
 
bool mIsData
 
std::string moduleLabel_
 
std::string mPayloadName
 
std::string mSampleType
 
edm::EDGetTokenT< edm::View< reco::Candidate > > pflow_
 
double sumPt_
 
edm::EDGetTokenT< edm::View< reco::Vertex > > vertices_
 

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 MET correction to compensate systematic shift of MET in x/y-direction (cf. https://indico.cern.ch/getFile.py/access?contribId=1&resId=0&materialId=slides&confId=174318 )

Authors
SangEun Lee,
Robert Schoefbeck, Vienna

Definition at line 32 of file MultShiftMETcorrDBInputProducer.h.

Constructor & Destructor Documentation

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

Definition at line 38 of file MultShiftMETcorrDBInputProducer.cc.

References etaMax_, etaMin_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), mIsData, mPayloadName, mSampleType, pflow_, AlCaHLTBitMon_QueryRunRegistry::string, and vertices_.

39  : moduleLabel_(cfg.getParameter<std::string>("@module_label")) {
40  mPayloadName = cfg.getParameter<std::string>("payloadName");
41  mSampleType = (cfg.exists("sampleType")) ? cfg.getParameter<std::string>("sampleType") : "MC";
42  mIsData = cfg.getParameter<bool>("isData");
43 
44  pflow_ = consumes<edm::View<reco::Candidate> >(cfg.getParameter<edm::InputTag>("srcPFlow"));
45  vertices_ = consumes<edm::View<reco::Vertex> >(cfg.getParameter<edm::InputTag>("vertexCollection"));
46 
47  etaMin_.clear();
48  etaMax_.clear();
49 
50  produces<CorrMETData>();
51 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< reco::Candidate > > pflow_
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< edm::View< reco::Vertex > > vertices_
MultShiftMETcorrDBInputProducer::~MultShiftMETcorrDBInputProducer ( )
override

Definition at line 53 of file MultShiftMETcorrDBInputProducer.cc.

53 {}

Member Function Documentation

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

Definition at line 55 of file MultShiftMETcorrDBInputProducer.cc.

References funct::abs(), HltBtagPostValidation_cff::c, counts_, DEFINE_FWK_MODULE, MEtXYcorrectParameters::definitions(), reco::Candidate::eta(), Exception, MEtXYcorrectParametersCollection::findLabel(), MEtXYcorrectParameters::Definitions::formula(), formula_x_, formula_y_, edm::EventSetup::get(), edm::Event::getByToken(), metFilters_cff::goodVertices, mps_fire::i, MEtXYcorrectParametersCollection::isShiftData(), MEtXYcorrectParametersCollection::isShiftDY(), MEtXYcorrectParametersCollection::isShiftMC(), MEtXYcorrectParametersCollection::isShiftTTJets(), MEtXYcorrectParametersCollection::isShiftWJets(), edm::HandleBase::isValid(), relativeConstraints::keys, mIsData, eostools::move(), mPayloadName, mSampleType, MEtXYcorrectParameters::Record::nParameters(), MEtXYcorrectParameters::Record::parameter(), pfLinker_cff::particleFlow, MEtXYcorrectParameters::Definitions::parVar(), reco::Candidate::pdgId(), pflow_, position, reco::Candidate::pt(), MEtXYcorrectParameters::Definitions::PtclType(), edm::Event::put(), MEtXYcorrectParameters::record(), rho, AlCaHLTBitMon_QueryRunRegistry::string, sumPt_, translateTypeToAbsPdgId(), heppy_batch::val, MEtXYcorrectParametersCollection::validKeys(), vertices_, MEtXYcorrectParameters::Record::xMax(), MEtXYcorrectParameters::Record::xMin(), and z.

55  {
56  // Get para.s from DB
58  es.get<MEtXYcorrectRecord>().get(mPayloadName, MEtXYcorParaColl);
59 
60  // get the sections from Collection (pair of section and METCorr.Par class)
61  std::vector<MEtXYcorrectParametersCollection::key_type> keys;
62  // save level to keys for each METParameter in METParameter collection
63  MEtXYcorParaColl->validKeys(keys);
64 
65  //get primary vertices
67  evt.getByToken(vertices_, hpv);
68  if (!hpv.isValid()) {
69  edm::LogError("MultShiftMETcorrDBInputProducer::produce") << "could not find vertex collection ";
70  }
71  std::vector<reco::Vertex> goodVertices;
72  for (unsigned i = 0; i < hpv->size(); i++) {
73  if ((*hpv)[i].ndof() > 4 && (fabs((*hpv)[i].z()) <= 24.) && (fabs((*hpv)[i].position().rho()) <= 2.0))
74  goodVertices.push_back((*hpv)[i]);
75  }
76  int ngoodVertices = goodVertices.size();
77 
79  evt.getByToken(pflow_, particleFlow);
80 
81  //loop over all constituent types and sum each correction
82  //std::unique_ptr<CorrMETData> metCorr(new CorrMETData());
83  std::unique_ptr<CorrMETData> metCorr(new CorrMETData());
84 
85  double corx = 0.;
86  double cory = 0.;
87 
88  // check DB
89  for (std::vector<MEtXYcorrectParametersCollection::key_type>::const_iterator ikey = keys.begin(); ikey != keys.end();
90  ++ikey) {
91  if (mIsData) {
92  if (!MEtXYcorParaColl->isShiftData(*ikey))
93  throw cms::Exception("MultShiftMETcorrDBInputProducer::produce")
94  << "DB is not for Data. Set proper option: \"corrPfMetXYMultDB.isData\" !!\n";
95  } else {
96  if (MEtXYcorParaColl->isShiftData(*ikey))
97  throw cms::Exception("MultShiftMETcorrDBInputProducer::produce")
98  << "DB is for Data. Set proper option: \"corrPfMetXYMultDB.isData\" !!\n";
99  }
100  }
101 
102  for (std::vector<MEtXYcorrectParametersCollection::key_type>::const_iterator ikey = keys.begin(); ikey != keys.end();
103  ++ikey) {
104  if (!mIsData) {
105  if (mSampleType == "MC") {
106  if (!MEtXYcorParaColl->isShiftMC(*ikey))
107  continue;
108  } else if (mSampleType == "DY") {
109  if (!MEtXYcorParaColl->isShiftDY(*ikey))
110  continue;
111  } else if (mSampleType == "TTJets") {
112  if (!MEtXYcorParaColl->isShiftTTJets(*ikey))
113  continue;
114  } else if (mSampleType == "WJets") {
115  if (!MEtXYcorParaColl->isShiftWJets(*ikey))
116  continue;
117  } else
118  throw cms::Exception("MultShiftMETcorrDBInputProducer::produce")
119  << "SampleType: " << mSampleType << " is not reserved !!!\n";
120  }
121 
122  std::string sectionName = MEtXYcorParaColl->findLabel(*ikey);
123  MEtXYcorrectParameters const& MEtXYcorParams = (*MEtXYcorParaColl)[*ikey];
124 
125  counts_ = 0;
126  sumPt_ = 0;
127 
128  for (unsigned i = 0; i < particleFlow->size(); ++i) {
129  const reco::Candidate& c = particleFlow->at(i);
130  if (abs(c.pdgId()) ==
132  if ((c.eta() > MEtXYcorParams.record(0).xMin(0)) and (c.eta() < MEtXYcorParams.record(0).xMax(0))) {
133  counts_ += 1;
134  sumPt_ += c.pt();
135  continue;
136  }
137  }
138  }
139  double val(0.);
140  unsigned parVar = MEtXYcorParams.definitions().parVar(0);
141 
142  if (parVar == 0) {
143  val = counts_;
144 
145  } else if (parVar == 1) {
146  val = ngoodVertices;
147 
148  } else if (parVar == 2) {
149  val = sumPt_;
150 
151  } else {
152  throw cms::Exception("MultShiftMETcorrDBInputProducer::produce")
153  << "parVar: " << parVar << " is not reserved !!!\n";
154  }
155 
156  formula_x_.reset(new TF1("corrPx", MEtXYcorParams.definitions().formula().c_str()));
157  formula_y_.reset(new TF1("corrPy", MEtXYcorParams.definitions().formula().c_str()));
158 
159  for (unsigned i(0); i < MEtXYcorParams.record(0).nParameters(); i++) {
160  formula_x_->SetParameter(i, MEtXYcorParams.record(0).parameter(i));
161  }
162  for (unsigned i(0); i < MEtXYcorParams.record(1).nParameters(); i++) {
163  formula_y_->SetParameter(i, MEtXYcorParams.record(1).parameter(i));
164  }
165 
166  corx -= formula_x_->Eval(val);
167  cory -= formula_y_->Eval(val);
168 
169  } //end loop over corrections
170 
171  metCorr->mex = corx;
172  metCorr->mey = cory;
173  evt.put(std::move(metCorr), "");
174 }
float parameter(unsigned fIndex) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
ParticleType
particle types
Definition: PFCandidate.h:43
void validKeys(std::vector< key_type > &keys) const
edm::EDGetTokenT< edm::View< reco::Candidate > > pflow_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
const Definitions & definitions() const
float xMax(unsigned fVar) const
goodVertices
The Good vertices collection needed by the tracking failure filter ________||.
const Record & record(unsigned fBin) const
static int translateTypeToAbsPdgId(reco::PFCandidate::ParticleType type)
virtual int pdgId() const =0
PDG identifier.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isValid() const
Definition: HandleBase.h:70
virtual double eta() const =0
momentum pseudorapidity
virtual double pt() const =0
transverse momentum
static std::string findLabel(key_type k)
a MET correction term
Definition: CorrMETData.h:14
float xMin(unsigned fVar) const
static int position[264][3]
Definition: ReadPGInfo.cc:289
T get() const
Definition: EventSetup.h:73
edm::EDGetTokenT< edm::View< reco::Vertex > > vertices_
std::vector< unsigned > parVar() const
def move(src, dest)
Definition: eostools.py:511
int MultShiftMETcorrDBInputProducer::translateTypeToAbsPdgId ( reco::PFCandidate::ParticleType  type)
staticprivate

Definition at line 16 of file MultShiftMETcorrDBInputProducer.cc.

References MillePedeFileConverter_cfg::e, CustomPhysics_cfi::gamma, h, amptDefaultParameters_cff::mu, and X.

Referenced by produce().

16  {
17  switch (type) {
19  return 211; // pi+
21  return 11;
23  return 13;
25  return 22;
26  case reco::PFCandidate::ParticleType::h0:
27  return 130; // K_L0
28  case reco::PFCandidate::ParticleType::h_HF:
29  return 1; // dummy pdg code
30  case reco::PFCandidate::ParticleType::egamma_HF:
31  return 2; // dummy pdg code
33  default:
34  return 0;
35  }
36 }
type
Definition: HCALResponse.h:21
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
#define X(str)
Definition: MuonsGrabber.cc:38

Member Data Documentation

std::vector<edm::ParameterSet> MultShiftMETcorrDBInputProducer::cfgCorrParameters_
private

Definition at line 48 of file MultShiftMETcorrDBInputProducer.h.

int MultShiftMETcorrDBInputProducer::counts_
private

Definition at line 51 of file MultShiftMETcorrDBInputProducer.h.

Referenced by produce().

std::vector<double> MultShiftMETcorrDBInputProducer::etaMax_
private

Definition at line 50 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer().

std::vector<double> MultShiftMETcorrDBInputProducer::etaMin_
private

Definition at line 50 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer().

std::unique_ptr<TF1> MultShiftMETcorrDBInputProducer::formula_x_
private

Definition at line 53 of file MultShiftMETcorrDBInputProducer.h.

Referenced by produce().

std::unique_ptr<TF1> MultShiftMETcorrDBInputProducer::formula_y_
private

Definition at line 54 of file MultShiftMETcorrDBInputProducer.h.

Referenced by produce().

bool MultShiftMETcorrDBInputProducer::mIsData
private

Definition at line 46 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer(), and produce().

std::string MultShiftMETcorrDBInputProducer::moduleLabel_
private
std::string MultShiftMETcorrDBInputProducer::mPayloadName
private

Definition at line 44 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer(), and produce().

std::string MultShiftMETcorrDBInputProducer::mSampleType
private

Definition at line 45 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer(), and produce().

edm::EDGetTokenT<edm::View<reco::Candidate> > MultShiftMETcorrDBInputProducer::pflow_
private

Definition at line 41 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer(), and produce().

double MultShiftMETcorrDBInputProducer::sumPt_
private

Definition at line 52 of file MultShiftMETcorrDBInputProducer.h.

Referenced by produce().

edm::EDGetTokenT<edm::View<reco::Vertex> > MultShiftMETcorrDBInputProducer::vertices_
private

Definition at line 42 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer(), and produce().