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_
 
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
 

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 33 of file MultShiftMETcorrDBInputProducer.h.

Constructor & Destructor Documentation

◆ MultShiftMETcorrDBInputProducer()

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

Definition at line 38 of file MultShiftMETcorrDBInputProducer.cc.

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  edm::InputTag srcWeights = cfg.getParameter<edm::InputTag>("srcWeights");
48  if (!srcWeights.label().empty())
50 
51  etaMin_.clear();
52  etaMax_.clear();
53 
54  produces<CorrMETData>();
55 }

References looper::cfg, etaMax_, etaMin_, mIsData, mPayloadName, mSampleType, pflow_, HLT_2018_cff::srcWeights, AlCaHLTBitMon_QueryRunRegistry::string, vertices_, and weightsToken_.

◆ ~MultShiftMETcorrDBInputProducer()

MultShiftMETcorrDBInputProducer::~MultShiftMETcorrDBInputProducer ( )
override

Definition at line 57 of file MultShiftMETcorrDBInputProducer.cc.

57 {}

Member Function Documentation

◆ produce()

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

Definition at line 59 of file MultShiftMETcorrDBInputProducer.cc.

59  {
60  // Get para.s from DB
62  es.get<MEtXYcorrectRecord>().get(mPayloadName, MEtXYcorParaColl);
63 
64  // get the sections from Collection (pair of section and METCorr.Par class)
65  std::vector<MEtXYcorrectParametersCollection::key_type> keys;
66  // save level to keys for each METParameter in METParameter collection
67  MEtXYcorParaColl->validKeys(keys);
68 
69  //get primary vertices
71  evt.getByToken(vertices_, hpv);
72  if (!hpv.isValid()) {
73  edm::LogError("MultShiftMETcorrDBInputProducer::produce") << "could not find vertex collection ";
74  }
75  std::vector<reco::Vertex> goodVertices;
76  for (unsigned i = 0; i < hpv->size(); i++) {
77  if ((*hpv)[i].ndof() > 4 && (fabs((*hpv)[i].z()) <= 24.) && (fabs((*hpv)[i].position().rho()) <= 2.0))
78  goodVertices.push_back((*hpv)[i]);
79  }
80  int ngoodVertices = goodVertices.size();
81 
84 
88 
89  //loop over all constituent types and sum each correction
90  //std::unique_ptr<CorrMETData> metCorr(new CorrMETData());
91  std::unique_ptr<CorrMETData> metCorr(new CorrMETData());
92 
93  double corx = 0.;
94  double cory = 0.;
95 
96  // check DB
97  for (std::vector<MEtXYcorrectParametersCollection::key_type>::const_iterator ikey = keys.begin(); ikey != keys.end();
98  ++ikey) {
99  if (mIsData) {
100  if (!MEtXYcorParaColl->isShiftData(*ikey))
101  throw cms::Exception("MultShiftMETcorrDBInputProducer::produce")
102  << "DB is not for Data. Set proper option: \"corrPfMetXYMultDB.isData\" !!\n";
103  } else {
104  if (MEtXYcorParaColl->isShiftData(*ikey))
105  throw cms::Exception("MultShiftMETcorrDBInputProducer::produce")
106  << "DB is for Data. Set proper option: \"corrPfMetXYMultDB.isData\" !!\n";
107  }
108  }
109 
110  for (std::vector<MEtXYcorrectParametersCollection::key_type>::const_iterator ikey = keys.begin(); ikey != keys.end();
111  ++ikey) {
112  if (!mIsData) {
113  if (mSampleType == "MC") {
114  if (!MEtXYcorParaColl->isShiftMC(*ikey))
115  continue;
116  } else if (mSampleType == "DY") {
117  if (!MEtXYcorParaColl->isShiftDY(*ikey))
118  continue;
119  } else if (mSampleType == "TTJets") {
120  if (!MEtXYcorParaColl->isShiftTTJets(*ikey))
121  continue;
122  } else if (mSampleType == "WJets") {
123  if (!MEtXYcorParaColl->isShiftWJets(*ikey))
124  continue;
125  } else
126  throw cms::Exception("MultShiftMETcorrDBInputProducer::produce")
127  << "SampleType: " << mSampleType << " is not reserved !!!\n";
128  }
129 
130  std::string sectionName = MEtXYcorParaColl->findLabel(*ikey);
131  MEtXYcorrectParameters const& MEtXYcorParams = (*MEtXYcorParaColl)[*ikey];
132 
133  counts_ = 0;
134  sumPt_ = 0;
135 
136  for (unsigned i = 0; i < particleFlow->size(); ++i) {
137  const reco::Candidate& c = particleFlow->at(i);
138  if (abs(c.pdgId()) ==
140  if ((c.eta() > MEtXYcorParams.record(0).xMin(0)) and (c.eta() < MEtXYcorParams.record(0).xMax(0))) {
141  float weight = (!weightsToken_.isUninitialized()) ? (*weights)[particleFlow->ptrAt(i)] : 1.0;
142  counts_ += (weight > 0);
143  sumPt_ += c.pt() * weight;
144  continue;
145  }
146  }
147  }
148  double val(0.);
149  unsigned parVar = MEtXYcorParams.definitions().parVar(0);
150 
151  if (parVar == 0) {
152  val = counts_;
153 
154  } else if (parVar == 1) {
155  val = ngoodVertices;
156 
157  } else if (parVar == 2) {
158  val = sumPt_;
159 
160  } else {
161  throw cms::Exception("MultShiftMETcorrDBInputProducer::produce")
162  << "parVar: " << parVar << " is not reserved !!!\n";
163  }
164 
165  formula_x_.reset(new TF1("corrPx", MEtXYcorParams.definitions().formula().c_str()));
166  formula_y_.reset(new TF1("corrPy", MEtXYcorParams.definitions().formula().c_str()));
167 
168  for (unsigned i(0); i < MEtXYcorParams.record(0).nParameters(); i++) {
169  formula_x_->SetParameter(i, MEtXYcorParams.record(0).parameter(i));
170  }
171  for (unsigned i(0); i < MEtXYcorParams.record(1).nParameters(); i++) {
172  formula_y_->SetParameter(i, MEtXYcorParams.record(1).parameter(i));
173  }
174 
175  corx -= formula_x_->Eval(val);
176  cory -= formula_y_->Eval(val);
177 
178  } //end loop over corrections
179 
180  metCorr->mex = corx;
181  metCorr->mey = cory;
182  evt.put(std::move(metCorr), "");
183 }

References funct::abs(), HltBtagPostValidation_cff::c, counts_, MEtXYcorrectParameters::definitions(), Exception, MEtXYcorrectParametersCollection::findLabel(), MEtXYcorrectParameters::Definitions::formula(), formula_x_, formula_y_, edm::EventSetup::get(), get, edm::Event::getByToken(), metFilters_cff::goodVertices, mps_fire::i, MEtXYcorrectParametersCollection::isShiftData(), MEtXYcorrectParametersCollection::isShiftDY(), MEtXYcorrectParametersCollection::isShiftMC(), MEtXYcorrectParametersCollection::isShiftTTJets(), MEtXYcorrectParametersCollection::isShiftWJets(), edm::EDGetTokenT< T >::isUninitialized(), edm::HandleBase::isValid(), relativeConstraints::keys, mIsData, eostools::move(), mPayloadName, mSampleType, MEtXYcorrectParameters::Record::nParameters(), MEtXYcorrectParameters::Record::parameter(), pfLinker_cff::particleFlow, MEtXYcorrectParameters::Definitions::parVar(), pflow_, position, MEtXYcorrectParameters::Definitions::PtclType(), edm::Event::put(), MEtXYcorrectParameters::record(), rho, AlCaHLTBitMon_QueryRunRegistry::string, sumPt_, tools::TF1, translateTypeToAbsPdgId(), heppy_batch::val, MEtXYcorrectParametersCollection::validKeys(), vertices_, mps_merge::weight, HLT_2018_cff::weights, weightsToken_, MEtXYcorrectParameters::Record::xMax(), MEtXYcorrectParameters::Record::xMin(), and z.

◆ translateTypeToAbsPdgId()

int MultShiftMETcorrDBInputProducer::translateTypeToAbsPdgId ( reco::PFCandidate::ParticleType  type)
staticprivate

Definition at line 16 of file MultShiftMETcorrDBInputProducer.cc.

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 }

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

Referenced by produce().

Member Data Documentation

◆ cfgCorrParameters_

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

Definition at line 50 of file MultShiftMETcorrDBInputProducer.h.

◆ counts_

int MultShiftMETcorrDBInputProducer::counts_
private

Definition at line 53 of file MultShiftMETcorrDBInputProducer.h.

Referenced by produce().

◆ etaMax_

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

Definition at line 52 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer().

◆ etaMin_

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

Definition at line 52 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer().

◆ formula_x_

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

Definition at line 55 of file MultShiftMETcorrDBInputProducer.h.

Referenced by produce().

◆ formula_y_

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

Definition at line 56 of file MultShiftMETcorrDBInputProducer.h.

Referenced by produce().

◆ mIsData

bool MultShiftMETcorrDBInputProducer::mIsData
private

Definition at line 47 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer(), and produce().

◆ moduleLabel_

std::string MultShiftMETcorrDBInputProducer::moduleLabel_
private

◆ mPayloadName

std::string MultShiftMETcorrDBInputProducer::mPayloadName
private

Definition at line 45 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer(), and produce().

◆ mSampleType

std::string MultShiftMETcorrDBInputProducer::mSampleType
private

Definition at line 46 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer(), and produce().

◆ pflow_

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

Definition at line 42 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer(), and produce().

◆ sumPt_

double MultShiftMETcorrDBInputProducer::sumPt_
private

Definition at line 54 of file MultShiftMETcorrDBInputProducer.h.

Referenced by produce().

◆ vertices_

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

Definition at line 43 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer(), and produce().

◆ weightsToken_

edm::EDGetTokenT<edm::ValueMap<float> > MultShiftMETcorrDBInputProducer::weightsToken_
private

Definition at line 48 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer(), and produce().

MEtXYcorrectParameters
Definition: MEtXYcorrectParameters.h:14
HLT_2018_cff.weights
weights
Definition: HLT_2018_cff.py:87167
mps_fire.i
i
Definition: mps_fire.py:355
MEtXYcorrectParametersCollection::isShiftDY
static bool isShiftDY(key_type k)
Definition: MEtXYcorrectParameters.cc:473
MEtXYcorrectParametersCollection::isShiftTTJets
static bool isShiftTTJets(key_type k)
Definition: MEtXYcorrectParameters.cc:476
MultShiftMETcorrDBInputProducer::formula_y_
std::unique_ptr< TF1 > formula_y_
Definition: MultShiftMETcorrDBInputProducer.h:56
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
X
#define X(str)
Definition: MuonsGrabber.cc:38
MEtXYcorrectParametersCollection::validKeys
void validKeys(std::vector< key_type > &keys) const
Definition: MEtXYcorrectParameters.cc:411
mps_merge.weight
weight
Definition: mps_merge.py:88
MEtXYcorrectParameters::definitions
const Definitions & definitions() const
Definition: MEtXYcorrectParameters.h:90
MultShiftMETcorrDBInputProducer::weightsToken_
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
Definition: MultShiftMETcorrDBInputProducer.h:48
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
MEtXYcorrectParametersCollection::isShiftData
static bool isShiftData(key_type k)
Definition: MEtXYcorrectParameters.cc:482
CustomPhysics_cfi.gamma
gamma
Definition: CustomPhysics_cfi.py:17
MEtXYcorrectParameters::Definitions::formula
std::string formula() const
Definition: MEtXYcorrectParameters.h:36
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
MEtXYcorrectParameters::Definitions::PtclType
int PtclType() const
Definition: MEtXYcorrectParameters.h:31
MultShiftMETcorrDBInputProducer::mSampleType
std::string mSampleType
Definition: MultShiftMETcorrDBInputProducer.h:46
tools.TF1
TF1
Definition: tools.py:23
edm::Handle
Definition: AssociativeIterator.h:50
MEtXYcorrectParameters::Definitions::parVar
std::vector< unsigned > parVar() const
Definition: MEtXYcorrectParameters.h:32
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
metFilters_cff.goodVertices
goodVertices
The Good vertices collection needed by the tracking failure filter ________||.
Definition: metFilters_cff.py:44
edm::EDGetTokenT::isUninitialized
bool isUninitialized() const
Definition: EDGetToken.h:70
DDAxes::z
MultShiftMETcorrDBInputProducer::pflow_
edm::EDGetTokenT< edm::View< reco::Candidate > > pflow_
Definition: MultShiftMETcorrDBInputProducer.h:42
edm::ESHandle
Definition: DTSurvey.h:22
CorrMETData
a MET correction term
Definition: CorrMETData.h:14
MultShiftMETcorrDBInputProducer::counts_
int counts_
Definition: MultShiftMETcorrDBInputProducer.h:53
MultShiftMETcorrDBInputProducer::etaMin_
std::vector< double > etaMin_
Definition: MultShiftMETcorrDBInputProducer.h:52
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
pfLinker_cff.particleFlow
particleFlow
Definition: pfLinker_cff.py:5
MultShiftMETcorrDBInputProducer::etaMax_
std::vector< double > etaMax_
Definition: MultShiftMETcorrDBInputProducer.h:52
HLT_2018_cff.srcWeights
srcWeights
Definition: HLT_2018_cff.py:7335
DDAxes::rho
MultShiftMETcorrDBInputProducer::moduleLabel_
std::string moduleLabel_
Definition: MultShiftMETcorrDBInputProducer.h:44
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MEtXYcorrectParametersCollection::isShiftWJets
static bool isShiftWJets(key_type k)
Definition: MEtXYcorrectParameters.cc:479
edm::LogError
Definition: MessageLogger.h:183
MultShiftMETcorrDBInputProducer::translateTypeToAbsPdgId
static int translateTypeToAbsPdgId(reco::PFCandidate::ParticleType type)
Definition: MultShiftMETcorrDBInputProducer.cc:16
MEtXYcorrectParametersCollection::findLabel
static std::string findLabel(key_type k)
Definition: MEtXYcorrectParameters.cc:284
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
MEtXYcorrectParameters::Record::xMax
float xMax(unsigned fVar) const
Definition: MEtXYcorrectParameters.h:61
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
get
#define get
looper.cfg
cfg
Definition: looper.py:297
reco::Candidate
Definition: Candidate.h:27
MultShiftMETcorrDBInputProducer::sumPt_
double sumPt_
Definition: MultShiftMETcorrDBInputProducer.h:54
MEtXYcorrectRecord
Definition: MEtXYcorrectRecord.h:7
type
type
Definition: HCALResponse.h:21
heppy_batch.val
val
Definition: heppy_batch.py:351
eostools.move
def move(src, dest)
Definition: eostools.py:511
MultShiftMETcorrDBInputProducer::formula_x_
std::unique_ptr< TF1 > formula_x_
Definition: MultShiftMETcorrDBInputProducer.h:55
MEtXYcorrectParameters::Record::nParameters
unsigned nParameters() const
Definition: MEtXYcorrectParameters.h:65
edm::ValueMap< float >
Exception
Definition: hltDiff.cc:246
cms::Exception
Definition: Exception.h:70
MEtXYcorrectParameters::Record::xMin
float xMin(unsigned fVar) const
Definition: MEtXYcorrectParameters.h:60
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MultShiftMETcorrDBInputProducer::mIsData
bool mIsData
Definition: MultShiftMETcorrDBInputProducer.h:47
reco::PFCandidate::ParticleType
ParticleType
particle types
Definition: PFCandidate.h:43
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
MEtXYcorrectParameters::Record::parameter
float parameter(unsigned fIndex) const
Definition: MEtXYcorrectParameters.h:63
edm::InputTag
Definition: InputTag.h:15
MultShiftMETcorrDBInputProducer::vertices_
edm::EDGetTokenT< edm::View< reco::Vertex > > vertices_
Definition: MultShiftMETcorrDBInputProducer.h:43
weight
Definition: weight.py:1
MEtXYcorrectParameters::record
const Record & record(unsigned fBin) const
Definition: MEtXYcorrectParameters.h:89
MultShiftMETcorrDBInputProducer::mPayloadName
std::string mPayloadName
Definition: MultShiftMETcorrDBInputProducer.h:45
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
MEtXYcorrectParametersCollection::isShiftMC
static bool isShiftMC(key_type k)
Definition: MEtXYcorrectParameters.cc:470