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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MultShiftMETcorrInputProducer (const edm::ParameterSet &)
 
 ~MultShiftMETcorrInputProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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_
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 31 of file MultShiftMETcorrInputProducer.h.

Constructor & Destructor Documentation

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

Definition at line 27 of file MultShiftMETcorrInputProducer.cc.

References mps_alisetup::append, cfgCorrParameters_, counts_, etaMax_, etaMin_, formula_x_, formula_y_, edm::ParameterSet::getParameter(), mps_fire::i, moduleLabel_, pflow_, AlCaHLTBitMon_QueryRunRegistry::string, sumPt_, type_, findQualityFiles::v, varType_, and vertices_.

27  :
28  moduleLabel_(cfg.getParameter<std::string>("@module_label"))
29 {
30 
31  pflow_ = consumes<edm::View<reco::Candidate> >(cfg.getParameter< edm::InputTag >("srcPFlow") );
32  vertices_ = consumes<edm::View<reco::Vertex> >( cfg.getParameter< edm::InputTag >("vertexCollection") );
33 
34  cfgCorrParameters_ = cfg.getParameter<std::vector<edm::ParameterSet> >("parameters");
35  etaMin_.clear();
36  etaMax_.clear();
37  type_.clear();
38  varType_.clear();
39 
40  produces<CorrMETData>();
41 
42  for (std::vector<edm::ParameterSet>::const_iterator v = cfgCorrParameters_.begin(); v!=cfgCorrParameters_.end(); v++) {
43  TString corrPxFormula = v->getParameter<std::string>("fx");
44  TString corrPyFormula = v->getParameter<std::string>("fy");
45  std::vector<double> corrPxParams = v->getParameter<std::vector<double> >("px");
46  std::vector<double> corrPyParams = v->getParameter<std::vector<double> >("py");
47 
48  formula_x_.push_back( std::unique_ptr<TF1>(new TF1(std::string(moduleLabel_).append("_").append(v->getParameter<std::string>("name")).append("_corrPx").c_str(), v->getParameter<std::string>("fx").c_str()) ) );
49  formula_y_.push_back( std::unique_ptr<TF1>(new TF1(std::string(moduleLabel_).append("_").append(v->getParameter<std::string>("name")).append("_corrPy").c_str(), v->getParameter<std::string>("fy").c_str()) ) );
50 
51  for (unsigned i=0; i<corrPxParams.size();i++) formula_x_.back()->SetParameter(i, corrPxParams[i]);
52  for (unsigned i=0; i<corrPyParams.size();i++) formula_y_.back()->SetParameter(i, corrPyParams[i]);
53 
54  counts_.push_back(0);
55  sumPt_.push_back(0.);
56  etaMin_.push_back(v->getParameter<double>("etaMin"));
57  etaMax_.push_back(v->getParameter<double>("etaMax"));
58  type_.push_back(v->getParameter<int>("type"));
59  varType_.push_back(v->getParameter<int>("varType"));
60  }
61 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< reco::Vertex > > vertices_
std::vector< edm::ParameterSet > cfgCorrParameters_
std::vector< std::unique_ptr< TF1 > > formula_x_
std::vector< std::unique_ptr< TF1 > > formula_y_
edm::EDGetTokenT< edm::View< reco::Candidate > > pflow_
MultShiftMETcorrInputProducer::~MultShiftMETcorrInputProducer ( )

Definition at line 63 of file MultShiftMETcorrInputProducer.cc.

64 {
65 }

Member Function Documentation

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

Definition at line 67 of file MultShiftMETcorrInputProducer.cc.

References funct::abs(), EnergyCorrector::c, cfgCorrParameters_, counts_, DEFINE_FWK_MODULE, reco::Candidate::eta(), etaMax_, etaMin_, formula_x_, formula_y_, edm::Event::getByToken(), metFilters_cff::goodVertices, mps_fire::i, edm::HandleBase::isValid(), eostools::move(), pfLinker_cff::particleFlow, reco::Candidate::pdgId(), pflow_, position, reco::Candidate::pt(), edm::Event::put(), rho, sumPt_, translateTypeToAbsPdgId(), type_, findQualityFiles::v, heppy_batch::val, varType_, vertices_, and z.

68 {
69  //get primary vertices
71  evt.getByToken( vertices_, hpv );
72  if(!hpv.isValid()) {
73  edm::LogError("MultShiftMETcorrInputProducer::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 &&
78  ( fabs((*hpv)[i].z()) <= 24. ) &&
79  ( fabs((*hpv)[i].position().rho()) <= 2.0 ) )
80  goodVertices.push_back((*hpv)[i]);
81  }
82  int ngoodVertices = goodVertices.size();
83 
84  for (unsigned i=0;i<counts_.size();i++) counts_[i]=0;
85  for (unsigned i=0;i<sumPt_.size();i++) sumPt_[i]=0.;
86 
88  evt.getByToken(pflow_, particleFlow);
89  for (unsigned i = 0; i < particleFlow->size(); ++i) {
90  const reco::Candidate& c = particleFlow->at(i);
91  for (unsigned j=0; j<type_.size(); j++) {
92 
94  if ((c.eta()>etaMin_[j]) and (c.eta()<etaMax_[j])) {
95  counts_[j]+=1;
96  sumPt_[j]+=c.pt();
97  continue;
98  }
99  }
100  }
101  }
102 
103  //MM: loop over all constituent types and sum each correction
104  std::unique_ptr<CorrMETData> metCorr(new CorrMETData());
105 
106  double corx=0.;
107  double cory=0.;
108 
109  for (std::vector<edm::ParameterSet>::const_iterator v = cfgCorrParameters_.begin(); v!=cfgCorrParameters_.end(); v++) {
110  unsigned j=v-cfgCorrParameters_.begin();
111 
112  double val(0.);
113  if (varType_[j]==0) {
114  val = counts_[j];
115  }
116  if (varType_[j]==1) {
117  val = ngoodVertices;
118  }
119  if (varType_[j]==2) {
120  val = sumPt_[j];
121  }
122 
123  corx -= formula_x_[j]->Eval(val);
124  cory -= formula_y_[j]->Eval(val);
125 
126  } //end loop over corrections
127 
128  metCorr->mex = corx;
129  metCorr->mey = cory;
130  evt.put(std::move(metCorr), "");
131 
132 }
edm::EDGetTokenT< edm::View< reco::Vertex > > vertices_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
ParticleType
particle types
Definition: PFCandidate.h:44
std::vector< edm::ParameterSet > cfgCorrParameters_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
goodVertices
The Good vertices collection needed by the tracking failure filter ________||.
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:74
virtual double eta() const =0
momentum pseudorapidity
virtual double pt() const =0
transverse momentum
a MET correction term
Definition: CorrMETData.h:14
static int position[264][3]
Definition: ReadPGInfo.cc:509
std::vector< std::unique_ptr< TF1 > > formula_x_
std::vector< std::unique_ptr< TF1 > > formula_y_
def move(src, dest)
Definition: eostools.py:510
edm::EDGetTokenT< edm::View< reco::Candidate > > pflow_
int MultShiftMETcorrInputProducer::translateTypeToAbsPdgId ( reco::PFCandidate::ParticleType  type)
staticprivate

Definition at line 12 of file MultShiftMETcorrInputProducer.cc.

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

Referenced by produce().

12  {
13  switch( type ) {
14  case reco::PFCandidate::ParticleType::h: return 211; // pi+
15  case reco::PFCandidate::ParticleType::e: return 11;
18  case reco::PFCandidate::ParticleType::h0: return 130; // K_L0
19  case reco::PFCandidate::ParticleType::h_HF: return 1; // dummy pdg code
20  case reco::PFCandidate::ParticleType::egamma_HF: return 2; // dummy pdg code
22  default: return 0;
23  }
24 }
type
Definition: HCALResponse.h:21
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
#define X(str)
Definition: MuonsGrabber.cc:48
const int mu
Definition: Constants.h:22

Member Data Documentation

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

Definition at line 48 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

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

Definition at line 51 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

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

Definition at line 50 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

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

Definition at line 50 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

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

Definition at line 53 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

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

Definition at line 54 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

std::string MultShiftMETcorrInputProducer::moduleLabel_
private
edm::EDGetTokenT<edm::View<reco::Candidate> > MultShiftMETcorrInputProducer::pflow_
private

Definition at line 44 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

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

Definition at line 52 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

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

Definition at line 51 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().

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

Definition at line 45 of file MultShiftMETcorrInputProducer.h.

Referenced by MultShiftMETcorrInputProducer(), and produce().