CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
pat::PATMETProducer Class Reference

Produces the pat::MET. More...

#include "PhysicsTools/PatAlgos/interface/PATMETProducer.h"

Inheritance diagram for pat::PATMETProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PATMETProducer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~PATMETProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 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 (const std::string &iProcessName, std::vector< const char * > &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 ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

bool addEfficiencies_
 
bool addGenMET_
 
bool addMuonCorr_
 
bool addResolutions_
 
pat::helper::EfficiencyLoader efficiencyLoader_
 
GreaterByEt< METeTComparator_
 
edm::EDGetTokenT< edm::View
< reco::GenMET > > 
genMETToken_
 
edm::InputTag metSrc_
 
edm::EDGetTokenT< edm::View
< reco::MET > > 
metToken_
 
edm::InputTag muonSrc_
 
pat::helper::KinResolutionsLoader resolutionLoader_
 
pat::PATUserDataHelper< pat::METuserDataHelper_
 
bool useUserData_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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

Produces the pat::MET.

The PATMETProducer produces the analysis-level pat::MET starting from a collection of objects of METType.

Author
Steven Lowette
Version
Id:
PATMETProducer.h,v 1.10 2009/06/25 23:49:35 gpetrucc Exp

Definition at line 36 of file PATMETProducer.h.

Constructor & Destructor Documentation

PATMETProducer::PATMETProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 18 of file PATMETProducer.cc.

References addEfficiencies_, addGenMET_, addResolutions_, edm::EDConsumerBase::consumesCollector(), efficiencyLoader_, genMETToken_, edm::ParameterSet::getParameter(), metSrc_, metToken_, resolutionLoader_, userDataHelper_, and useUserData_.

18  :
19  useUserData_(iConfig.exists("userData"))
20 {
21  // initialize the configurables
22  metSrc_ = iConfig.getParameter<edm::InputTag>("metSource");
23  metToken_ = consumes<edm::View<reco::MET> >(metSrc_);
24  addGenMET_ = iConfig.getParameter<bool> ("addGenMET");
25  genMETToken_ = mayConsume<edm::View<reco::GenMET> >(iConfig.getParameter<edm::InputTag>("genMETSource"));
26  addResolutions_ = iConfig.getParameter<bool> ("addResolutions");
27 
28  // Efficiency configurables
29  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
30  if (addEfficiencies_) {
32  }
33 
34  // Resolution configurables
35  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
36  if (addResolutions_) {
38  }
39 
40  // Check to see if the user wants to add user data
41  if ( useUserData_ ) {
43  }
44 
45 
46  // produces vector of mets
47  produces<std::vector<MET> >();
48 }
T getParameter(std::string const &) const
Assists in assimilating all pat::UserData into pat objects.
pat::PATUserDataHelper< pat::MET > userDataHelper_
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::InputTag metSrc_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
pat::helper::EfficiencyLoader efficiencyLoader_
pat::helper::KinResolutionsLoader resolutionLoader_
edm::EDGetTokenT< edm::View< reco::GenMET > > genMETToken_
PATMETProducer::~PATMETProducer ( )

Definition at line 51 of file PATMETProducer.cc.

51  {
52 }

Member Function Documentation

void PATMETProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 111 of file PATMETProducer.cc.

References edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), pat::helper::KinResolutionsLoader::fillDescription(), pat::PATUserDataHelper< ObjectType >::fillDescription(), HLT_25ns14e33_v1_cff::InputTag, edm::ParameterSetDescription::setAllowAnything(), and edm::ParameterSetDescription::setComment().

112 {
114  iDesc.setComment("PAT MET producer module");
115 
116  // input source
117  iDesc.add<edm::InputTag>("metSource", edm::InputTag("no default"))->setComment("input collection");
118 
119  // MC configurations
120  iDesc.add<bool>("addGenMET", false);
121  iDesc.add<edm::InputTag>("genMETSource", edm::InputTag("genMetCalo"));
122 
124 
125  // Efficiency configurables
126  edm::ParameterSetDescription efficienciesPSet;
127  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
128  iDesc.add("efficiencies", efficienciesPSet);
129  iDesc.add<bool>("addEfficiencies", false);
130 
131  // Check to see if the user wants to add user data
132  edm::ParameterSetDescription userDataPSet;
134  iDesc.addOptional("userData", userDataPSet);
135 
136  // muon correction
137  iDesc.add<bool>("addMuonCorrections", false);
138  iDesc.add<edm::InputTag>("muonSource", edm::InputTag("muons"));
139 
140 }
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void setAllowAnything()
allow any parameter label/value pairs
static void fillDescription(edm::ParameterSetDescription &iDesc)
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
void PATMETProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 55 of file PATMETProducer.cc.

References addGenMET_, efficiencyLoader_, pat::helper::EfficiencyLoader::enabled(), pat::helper::KinResolutionsLoader::enabled(), edm::InputTag::encode(), genMETToken_, edm::Event::getByToken(), customizeTrackingMonitorSeedNumber::idx, metSrc_, metToken_, pat::helper::EfficiencyLoader::newEvent(), pat::helper::KinResolutionsLoader::newEvent(), metProducer_cfi::patMETs, edm::Event::put(), resolutionLoader_, pat::helper::EfficiencyLoader::setEfficiencies(), pat::MET::setGenMET(), pat::helper::KinResolutionsLoader::setResolutions(), userDataHelper_, and useUserData_.

55  {
56 
57  // Get the vector of MET's from the event
59  iEvent.getByToken(metToken_, mets);
60 
61  if (mets->size() != 1) throw cms::Exception("Corrupt Data") << "The input MET collection " << metSrc_.encode() << " has size " << mets->size() << " instead of 1 as it should.\n";
63  if (resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
64 
65  // Get the vector of generated met from the event if needed
67  if (addGenMET_) {
68  iEvent.getByToken(genMETToken_, genMETs);
69  }
70 
71  // loop over mets
72  std::vector<MET> * patMETs = new std::vector<MET>();
73  for (edm::View<reco::MET>::const_iterator itMET = mets->begin(); itMET != mets->end(); itMET++) {
74  // construct the MET from the ref -> save ref to original object
75  unsigned int idx = itMET - mets->begin();
76  edm::RefToBase<reco::MET> metsRef = mets->refAt(idx);
77  edm::Ptr<reco::MET> metsPtr = mets->ptrAt(idx);
78  MET amet(metsRef);
79  // add the generated MET
80  if (addGenMET_) amet.setGenMET((*genMETs)[idx]);
81 
82  if (efficiencyLoader_.enabled()) {
83  efficiencyLoader_.setEfficiencies( amet, metsRef );
84  }
85 
86  if (resolutionLoader_.enabled()) {
88  }
89 
90 
91  if ( useUserData_ ) {
92  userDataHelper_.add( amet, iEvent, iSetup );
93  }
94 
95 
96  // correct for muons if demanded... never more: it's now done by JetMETCorrections
97  // add the MET to the vector of METs
98  patMETs->push_back(amet);
99  }
100 
101  // sort MET in ET .. don't mess with this
102  // std::sort(patMETs->begin(), patMETs->end(), eTComparator_);
103 
104  // put genEvt object in Event
105  std::auto_ptr<std::vector<MET> > myMETs(patMETs);
106  iEvent.put(myMETs);
107 
108 }
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
Analysis-level MET class.
Definition: MET.h:43
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
pat::PATUserDataHelper< pat::MET > userDataHelper_
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
edm::InputTag metSrc_
std::string encode() const
Definition: InputTag.cc:164
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
pat::helper::EfficiencyLoader efficiencyLoader_
pat::helper::KinResolutionsLoader resolutionLoader_
edm::EDGetTokenT< edm::View< reco::GenMET > > genMETToken_
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
void newEvent(const edm::Event &event, const edm::EventSetup &setup) const
To be called for each new event, reads in the EventSetup object.
void newEvent(const edm::Event &event) const
To be called for each new event, reads in the ValueMaps for efficiencies.

Member Data Documentation

bool pat::PATMETProducer::addEfficiencies_
private

Definition at line 61 of file PATMETProducer.h.

Referenced by PATMETProducer().

bool pat::PATMETProducer::addGenMET_
private

Definition at line 52 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

bool pat::PATMETProducer::addMuonCorr_
private

Definition at line 56 of file PATMETProducer.h.

bool pat::PATMETProducer::addResolutions_
private

Definition at line 54 of file PATMETProducer.h.

Referenced by PATMETProducer().

pat::helper::EfficiencyLoader pat::PATMETProducer::efficiencyLoader_
private

Definition at line 62 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

GreaterByEt<MET> pat::PATMETProducer::eTComparator_
private

Definition at line 59 of file PATMETProducer.h.

edm::EDGetTokenT<edm::View<reco::GenMET> > pat::PATMETProducer::genMETToken_
private

Definition at line 53 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

edm::InputTag pat::PATMETProducer::metSrc_
private

Definition at line 50 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

edm::EDGetTokenT<edm::View<reco::MET> > pat::PATMETProducer::metToken_
private

Definition at line 51 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

edm::InputTag pat::PATMETProducer::muonSrc_
private

Definition at line 57 of file PATMETProducer.h.

pat::helper::KinResolutionsLoader pat::PATMETProducer::resolutionLoader_
private

Definition at line 55 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

pat::PATUserDataHelper<pat::MET> pat::PATMETProducer::userDataHelper_
private

Definition at line 65 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

bool pat::PATMETProducer::useUserData_
private

Definition at line 64 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().