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 hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () 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
 
edm::ESGetToken< MEtXYcorrectParametersCollection, MEtXYcorrectRecordmMEtXYcorParaColl_
 
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 36 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"));
47  esConsumes<MEtXYcorrectParametersCollection, MEtXYcorrectRecord>(edm::ESInputTag("", mPayloadName));
48 
49  edm::InputTag srcWeights = cfg.getParameter<edm::InputTag>("srcWeights");
50  if (!srcWeights.label().empty())
52 
53  etaMin_.clear();
54  etaMax_.clear();
55 
56  produces<CorrMETData>();
57 }

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

◆ ~MultShiftMETcorrDBInputProducer()

MultShiftMETcorrDBInputProducer::~MultShiftMETcorrDBInputProducer ( )
override

Definition at line 59 of file MultShiftMETcorrDBInputProducer.cc.

59 {}

Member Function Documentation

◆ produce()

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

Definition at line 61 of file MultShiftMETcorrDBInputProducer.cc.

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

References funct::abs(), HltBtagPostValidation_cff::c, counts_, MEtXYcorrectParameters::definitions(), Exception, MEtXYcorrectParametersCollection::findLabel(), MEtXYcorrectParameters::Definitions::formula(), formula_x_, formula_y_, edm::Event::getByToken(), edm::EventSetup::getHandle(), 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, mMEtXYcorParaColl_, eostools::move(), 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_, translateTypeToAbsPdgId(), heppy_batch::val, MEtXYcorrectParametersCollection::validKeys(), vertices_, mps_merge::weight, HLT_FULL_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 54 of file MultShiftMETcorrDBInputProducer.h.

◆ counts_

int MultShiftMETcorrDBInputProducer::counts_
private

Definition at line 57 of file MultShiftMETcorrDBInputProducer.h.

Referenced by produce().

◆ etaMax_

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

Definition at line 56 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer().

◆ etaMin_

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

Definition at line 56 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer().

◆ formula_x_

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

Definition at line 59 of file MultShiftMETcorrDBInputProducer.h.

Referenced by produce().

◆ formula_y_

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

Definition at line 60 of file MultShiftMETcorrDBInputProducer.h.

Referenced by produce().

◆ mIsData

bool MultShiftMETcorrDBInputProducer::mIsData
private

Definition at line 51 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer(), and produce().

◆ mMEtXYcorParaColl_

edm::ESGetToken<MEtXYcorrectParametersCollection, MEtXYcorrectRecord> MultShiftMETcorrDBInputProducer::mMEtXYcorParaColl_
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 49 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer().

◆ mSampleType

std::string MultShiftMETcorrDBInputProducer::mSampleType
private

Definition at line 50 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer(), and produce().

◆ pflow_

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

Definition at line 45 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer(), and produce().

◆ sumPt_

double MultShiftMETcorrDBInputProducer::sumPt_
private

Definition at line 58 of file MultShiftMETcorrDBInputProducer.h.

Referenced by produce().

◆ vertices_

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

Definition at line 46 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer(), and produce().

◆ weightsToken_

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

Definition at line 52 of file MultShiftMETcorrDBInputProducer.h.

Referenced by MultShiftMETcorrDBInputProducer(), and produce().

MEtXYcorrectParameters
Definition: MEtXYcorrectParameters.h:14
mps_fire.i
i
Definition: mps_fire.py:428
edm::ESInputTag
Definition: ESInputTag.h:87
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:60
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:52
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
edm::EDGetTokenT::isUninitialized
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
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:50
edm::Handle
Definition: AssociativeIterator.h:50
MEtXYcorrectParameters::Definitions::parVar
std::vector< unsigned > parVar() const
Definition: MEtXYcorrectParameters.h:32
metFilters_cff.goodVertices
goodVertices
The Good vertices collection needed by the tracking failure filter ________||.
Definition: metFilters_cff.py:44
HLT_FULL_cff.weights
weights
Definition: HLT_FULL_cff.py:95855
DDAxes::z
MultShiftMETcorrDBInputProducer::pflow_
edm::EDGetTokenT< edm::View< reco::Candidate > > pflow_
Definition: MultShiftMETcorrDBInputProducer.h:45
edm::ESHandle
Definition: DTSurvey.h:22
CorrMETData
a MET correction term
Definition: CorrMETData.h:14
MultShiftMETcorrDBInputProducer::counts_
int counts_
Definition: MultShiftMETcorrDBInputProducer.h:57
MultShiftMETcorrDBInputProducer::etaMin_
std::vector< double > etaMin_
Definition: MultShiftMETcorrDBInputProducer.h:56
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
pfLinker_cff.particleFlow
particleFlow
Definition: pfLinker_cff.py:5
MultShiftMETcorrDBInputProducer::etaMax_
std::vector< double > etaMax_
Definition: MultShiftMETcorrDBInputProducer.h:56
DDAxes::rho
MultShiftMETcorrDBInputProducer::moduleLabel_
std::string moduleLabel_
Definition: MultShiftMETcorrDBInputProducer.h:48
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MEtXYcorrectParametersCollection::isShiftWJets
static bool isShiftWJets(key_type k)
Definition: MEtXYcorrectParameters.cc:479
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
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
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:133
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:148
MEtXYcorrectParameters::Record::xMax
float xMax(unsigned fVar) const
Definition: MEtXYcorrectParameters.h:61
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
HLT_FULL_cff.srcWeights
srcWeights
Definition: HLT_FULL_cff.py:8710
looper.cfg
cfg
Definition: looper.py:297
reco::Candidate
Definition: Candidate.h:27
MultShiftMETcorrDBInputProducer::sumPt_
double sumPt_
Definition: MultShiftMETcorrDBInputProducer.h:58
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:59
MEtXYcorrectParameters::Record::nParameters
unsigned nParameters() const
Definition: MEtXYcorrectParameters.h:65
edm::ValueMap< float >
Exception
Definition: hltDiff.cc:246
MultShiftMETcorrDBInputProducer::mMEtXYcorParaColl_
edm::ESGetToken< MEtXYcorrectParametersCollection, MEtXYcorrectRecord > mMEtXYcorParaColl_
Definition: MultShiftMETcorrDBInputProducer.h:47
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:51
reco::PFCandidate::ParticleType
ParticleType
particle types
Definition: PFCandidate.h:44
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:46
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:49
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
MEtXYcorrectParametersCollection::isShiftMC
static bool isShiftMC(key_type k)
Definition: MEtXYcorrectParameters.cc:470