test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
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 bitset_utilities::append(), cfgCorrParameters_, counts_, etaMax_, etaMin_, formula_x_, formula_y_, edm::ParameterSet::getParameter(), 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
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< edm::View< reco::Vertex > > vertices_
std::vector< edm::ParameterSet > cfgCorrParameters_
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
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 
)
overrideprivatevirtual

Implements edm::stream::EDProducerBase.

Definition at line 67 of file MultShiftMETcorrInputProducer.cc.

References funct::abs(), EnergyCorrector::c, cfgCorrParameters_, counts_, reco::Candidate::eta(), etaMax_, etaMin_, formula_x_, formula_y_, edm::Event::getByToken(), metFilters_cff::goodVertices, i, edm::HandleBase::isValid(), j, pfLinker_cff::particleFlow, reco::Candidate::pdgId(), pflow_, position, reco::Candidate::pt(), edm::Event::put(), rho, sumPt_, translateTypeToAbsPdgId(), type_, findQualityFiles::v, 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::auto_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(metCorr, "");
131 
132 }
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< edm::View< reco::Vertex > > vertices_
ParticleType
particle types
Definition: PFCandidate.h:44
std::vector< edm::ParameterSet > cfgCorrParameters_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
virtual double pt() const =0
transverse momentum
tuple particleFlow
Definition: pfLinker_cff.py:5
static int translateTypeToAbsPdgId(reco::PFCandidate::ParticleType type)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
tuple goodVertices
The Good vertices collection needed by the tracking failure filter ________||.
bool isValid() const
Definition: HandleBase.h:75
virtual int pdgId() const =0
PDG identifier.
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_
virtual double eta() const =0
momentum pseudorapidity
edm::EDGetTokenT< edm::View< reco::Candidate > > pflow_
int MultShiftMETcorrInputProducer::translateTypeToAbsPdgId ( reco::PFCandidate::ParticleType  type)
staticprivate

Definition at line 12 of file MultShiftMETcorrInputProducer.cc.

References alignCSCRings::e, 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;
17  case reco::PFCandidate::ParticleType::gamma: return 22;
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().