CMS 3D CMS Logo

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

#include <MultShiftMETcorrInputProducer.h>

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

Public Member Functions

 MultShiftMETcorrInputProducer (const edm::ParameterSet &)
 
 ~MultShiftMETcorrInputProducer () 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_
 
std::vector< int > counts_
 
std::vector< double > etaMax_
 
std::vector< double > etaMin_
 
std::vector< std::unique_ptr< TF1 > > formula_x_
 
std::vector< std::unique_ptr< TF1 > > formula_y_
 
std::string moduleLabel_
 
edm::EDGetTokenT< edm::View< reco::Candidate > > pflow_
 
std::vector< double > sumPt_
 
std::vector< int > type_
 
std::vector< int > varType_
 
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
Robert Schoefbeck, Vienna

Definition at line 32 of file MultShiftMETcorrInputProducer.h.

Constructor & Destructor Documentation

◆ MultShiftMETcorrInputProducer()

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

Definition at line 34 of file MultShiftMETcorrInputProducer.cc.

35  : moduleLabel_(cfg.getParameter<std::string>("@module_label")) {
36  pflow_ = consumes<edm::View<reco::Candidate>>(cfg.getParameter<edm::InputTag>("srcPFlow"));
37  vertices_ = consumes<edm::View<reco::Vertex>>(cfg.getParameter<edm::InputTag>("vertexCollection"));
38 
39  edm::InputTag srcWeights = cfg.getParameter<edm::InputTag>("srcWeights");
40  if (!srcWeights.label().empty())
42 
43  cfgCorrParameters_ = cfg.getParameter<std::vector<edm::ParameterSet>>("parameters");
44  etaMin_.clear();
45  etaMax_.clear();
46  type_.clear();
47  varType_.clear();
48 
49  produces<CorrMETData>();
50 
51  for (std::vector<edm::ParameterSet>::const_iterator v = cfgCorrParameters_.begin(); v != cfgCorrParameters_.end();
52  v++) {
53  TString corrPxFormula = v->getParameter<std::string>("fx");
54  TString corrPyFormula = v->getParameter<std::string>("fy");
55  std::vector<double> corrPxParams = v->getParameter<std::vector<double>>("px");
56  std::vector<double> corrPyParams = v->getParameter<std::vector<double>>("py");
57 
58  formula_x_.push_back(std::unique_ptr<TF1>(new TF1(
59  std::string(moduleLabel_).append("_").append(v->getParameter<std::string>("name")).append("_corrPx").c_str(),
60  v->getParameter<std::string>("fx").c_str())));
61  formula_y_.push_back(std::unique_ptr<TF1>(new TF1(
62  std::string(moduleLabel_).append("_").append(v->getParameter<std::string>("name")).append("_corrPy").c_str(),
63  v->getParameter<std::string>("fy").c_str())));
64 
65  for (unsigned i = 0; i < corrPxParams.size(); i++)
66  formula_x_.back()->SetParameter(i, corrPxParams[i]);
67  for (unsigned i = 0; i < corrPyParams.size(); i++)
68  formula_y_.back()->SetParameter(i, corrPyParams[i]);
69 
70  counts_.push_back(0);
71  sumPt_.push_back(0.);
72  etaMin_.push_back(v->getParameter<double>("etaMin"));
73  etaMax_.push_back(v->getParameter<double>("etaMax"));
74  type_.push_back(v->getParameter<int>("type"));
75  varType_.push_back(v->getParameter<int>("varType"));
76  }
77 }

References mps_setup::append, looper::cfg, cfgCorrParameters_, counts_, etaMax_, etaMin_, formula_x_, formula_y_, mps_fire::i, moduleLabel_, pflow_, HLT_2018_cff::srcWeights, AlCaHLTBitMon_QueryRunRegistry::string, sumPt_, tools::TF1, type_, findQualityFiles::v, varType_, vertices_, and weightsToken_.

◆ ~MultShiftMETcorrInputProducer()

MultShiftMETcorrInputProducer::~MultShiftMETcorrInputProducer ( )
override

Definition at line 79 of file MultShiftMETcorrInputProducer.cc.

79 {}

Member Function Documentation

◆ produce()

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

Definition at line 81 of file MultShiftMETcorrInputProducer.cc.

81  {
82  //get primary vertices
84  evt.getByToken(vertices_, hpv);
85  if (!hpv.isValid()) {
86  edm::LogError("MultShiftMETcorrInputProducer::produce") << "could not find vertex collection ";
87  }
88  std::vector<reco::Vertex> goodVertices;
89  for (unsigned i = 0; i < hpv->size(); i++) {
90  if ((*hpv)[i].ndof() > 4 && (fabs((*hpv)[i].z()) <= 24.) && (fabs((*hpv)[i].position().rho()) <= 2.0))
91  goodVertices.push_back((*hpv)[i]);
92  }
93  int ngoodVertices = goodVertices.size();
94 
95  for (unsigned i = 0; i < counts_.size(); i++)
96  counts_[i] = 0;
97  for (unsigned i = 0; i < sumPt_.size(); i++)
98  sumPt_[i] = 0.;
99 
102 
106  for (unsigned i = 0; i < particleFlow->size(); ++i) {
107  const reco::Candidate& c = particleFlow->at(i);
108  for (unsigned j = 0; j < type_.size(); j++) {
110  if ((c.eta() > etaMin_[j]) and (c.eta() < etaMax_[j])) {
111  float weight = (!weightsToken_.isUninitialized()) ? (*weights)[particleFlow->ptrAt(i)] : 1.0;
112  counts_[j] += (weight > 0);
113  sumPt_[j] += c.pt() * weight;
114  continue;
115  }
116  }
117  }
118  }
119 
120  //MM: loop over all constituent types and sum each correction
121  std::unique_ptr<CorrMETData> metCorr(new CorrMETData());
122 
123  double corx = 0.;
124  double cory = 0.;
125 
126  for (std::vector<edm::ParameterSet>::const_iterator v = cfgCorrParameters_.begin(); v != cfgCorrParameters_.end();
127  v++) {
128  unsigned j = v - cfgCorrParameters_.begin();
129 
130  double val(0.);
131  if (varType_[j] == 0) {
132  val = counts_[j];
133  }
134  if (varType_[j] == 1) {
135  val = ngoodVertices;
136  }
137  if (varType_[j] == 2) {
138  val = sumPt_[j];
139  }
140 
141  corx -= formula_x_[j]->Eval(val);
142  cory -= formula_y_[j]->Eval(val);
143 
144  } //end loop over corrections
145 
146  metCorr->mex = corx;
147  metCorr->mey = cory;
148  evt.put(std::move(metCorr), "");
149 }

References funct::abs(), HltBtagPostValidation_cff::c, cfgCorrParameters_, counts_, etaMax_, etaMin_, formula_x_, formula_y_, edm::Event::getByToken(), metFilters_cff::goodVertices, mps_fire::i, edm::EDGetTokenT< T >::isUninitialized(), edm::HandleBase::isValid(), dqmiolumiharvest::j, eostools::move(), pfLinker_cff::particleFlow, pflow_, position, edm::Event::put(), rho, sumPt_, translateTypeToAbsPdgId(), type_, findQualityFiles::v, heppy_batch::val, varType_, vertices_, mps_merge::weight, HLT_2018_cff::weights, weightsToken_, and z.

◆ translateTypeToAbsPdgId()

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

Definition at line 12 of file MultShiftMETcorrInputProducer.cc.

12  {
13  switch (type) {
15  return 211; // pi+
17  return 11;
19  return 13;
21  return 22;
22  case reco::PFCandidate::ParticleType::h0:
23  return 130; // K_L0
24  case reco::PFCandidate::ParticleType::h_HF:
25  return 1; // dummy pdg code
26  case reco::PFCandidate::ParticleType::egamma_HF:
27  return 2; // dummy pdg code
29  default:
30  return 0;
31  }
32 }

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

Referenced by produce().

Member Data Documentation

◆ cfgCorrParameters_

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

Definition at line 46 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

◆ counts_

std::vector<int> MultShiftMETcorrInputProducer::counts_
private

Definition at line 49 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

◆ etaMax_

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

Definition at line 48 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

◆ etaMin_

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

Definition at line 48 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

◆ formula_x_

std::vector<std::unique_ptr<TF1> > MultShiftMETcorrInputProducer::formula_x_
private

Definition at line 51 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

◆ formula_y_

std::vector<std::unique_ptr<TF1> > MultShiftMETcorrInputProducer::formula_y_
private

Definition at line 52 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

◆ moduleLabel_

std::string MultShiftMETcorrInputProducer::moduleLabel_
private

◆ pflow_

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

Definition at line 41 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

◆ sumPt_

std::vector<double> MultShiftMETcorrInputProducer::sumPt_
private

Definition at line 50 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

◆ type_

std::vector<int> MultShiftMETcorrInputProducer::type_
private

◆ varType_

std::vector<int> MultShiftMETcorrInputProducer::varType_
private

Definition at line 49 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

◆ vertices_

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

Definition at line 42 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

◆ weightsToken_

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

Definition at line 44 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

HLT_2018_cff.weights
weights
Definition: HLT_2018_cff.py:87167
mps_fire.i
i
Definition: mps_fire.py:355
MultShiftMETcorrInputProducer::formula_y_
std::vector< std::unique_ptr< TF1 > > formula_y_
Definition: MultShiftMETcorrInputProducer.h:52
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
X
#define X(str)
Definition: MuonsGrabber.cc:38
mps_merge.weight
weight
Definition: mps_merge.py:88
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
CustomPhysics_cfi.gamma
gamma
Definition: CustomPhysics_cfi.py:17
MultShiftMETcorrInputProducer::vertices_
edm::EDGetTokenT< edm::View< reco::Vertex > > vertices_
Definition: MultShiftMETcorrInputProducer.h:42
findQualityFiles.v
v
Definition: findQualityFiles.py:179
tools.TF1
TF1
Definition: tools.py:23
edm::Handle
Definition: AssociativeIterator.h:50
MultShiftMETcorrInputProducer::weightsToken_
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
Definition: MultShiftMETcorrInputProducer.h:44
MultShiftMETcorrInputProducer::cfgCorrParameters_
std::vector< edm::ParameterSet > cfgCorrParameters_
Definition: MultShiftMETcorrInputProducer.h:46
MultShiftMETcorrInputProducer::type_
std::vector< int > type_
Definition: MultShiftMETcorrInputProducer.h:49
MultShiftMETcorrInputProducer::varType_
std::vector< int > varType_
Definition: MultShiftMETcorrInputProducer.h:49
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
MultShiftMETcorrInputProducer::etaMax_
std::vector< double > etaMax_
Definition: MultShiftMETcorrInputProducer.h:48
CorrMETData
a MET correction term
Definition: CorrMETData.h:14
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
pfLinker_cff.particleFlow
particleFlow
Definition: pfLinker_cff.py:5
MultShiftMETcorrInputProducer::sumPt_
std::vector< double > sumPt_
Definition: MultShiftMETcorrInputProducer.h:50
HLT_2018_cff.srcWeights
srcWeights
Definition: HLT_2018_cff.py:7335
DDAxes::rho
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogError
Definition: MessageLogger.h:183
MultShiftMETcorrInputProducer::translateTypeToAbsPdgId
static int translateTypeToAbsPdgId(reco::PFCandidate::ParticleType type)
Definition: MultShiftMETcorrInputProducer.cc:12
MultShiftMETcorrInputProducer::moduleLabel_
std::string moduleLabel_
Definition: MultShiftMETcorrInputProducer.h:43
mps_setup.append
append
Definition: mps_setup.py:85
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
MultShiftMETcorrInputProducer::counts_
std::vector< int > counts_
Definition: MultShiftMETcorrInputProducer.h:49
MultShiftMETcorrInputProducer::formula_x_
std::vector< std::unique_ptr< TF1 > > formula_x_
Definition: MultShiftMETcorrInputProducer.h:51
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
MultShiftMETcorrInputProducer::etaMin_
std::vector< double > etaMin_
Definition: MultShiftMETcorrInputProducer.h:48
looper.cfg
cfg
Definition: looper.py:297
reco::Candidate
Definition: Candidate.h:27
MultShiftMETcorrInputProducer::pflow_
edm::EDGetTokenT< edm::View< reco::Candidate > > pflow_
Definition: MultShiftMETcorrInputProducer.h:41
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
edm::ValueMap< float >
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
reco::PFCandidate::ParticleType
ParticleType
particle types
Definition: PFCandidate.h:43
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15
weight
Definition: weight.py:1
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37