#include <PhysicsTools/PatAlgos/interface/PATMETProducer.h>
Public Member Functions | |
PATMETProducer (const edm::ParameterSet &iConfig) | |
virtual void | produce (edm::Event &iEvent, const edm::EventSetup &iSetup) |
~PATMETProducer () | |
Private Attributes | |
bool | addEfficiencies_ |
bool | addGenMET_ |
bool | addMuonCorr_ |
bool | addResolutions_ |
bool | addTrigMatch_ |
pat::helper::EfficiencyLoader | efficiencyLoader_ |
GreaterByEt< MET > | eTComparator_ |
edm::InputTag | genMETSrc_ |
edm::InputTag | metSrc_ |
edm::InputTag | muonSrc_ |
std::vector< edm::InputTag > | trigMatchSrc_ |
pat::PATUserDataHelper< pat::MET > | userDataHelper_ |
bool | useUserData_ |
The PATMETProducer produces the analysis-level pat::MET starting from a collection of objects of METType.
Definition at line 36 of file PATMETProducer.h.
PATMETProducer::PATMETProducer | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 16 of file PATMETProducer.cc.
References addEfficiencies_, addGenMET_, addResolutions_, addTrigMatch_, efficiencyLoader_, edm::ParameterSet::exists(), genMETSrc_, edm::ParameterSet::getParameter(), metSrc_, trigMatchSrc_, and useUserData_.
00016 : 00017 userDataHelper_ ( iConfig.getParameter<edm::ParameterSet>("userData") ) 00018 { 00019 // initialize the configurables 00020 metSrc_ = iConfig.getParameter<edm::InputTag>("metSource"); 00021 addGenMET_ = iConfig.getParameter<bool> ("addGenMET"); 00022 genMETSrc_ = iConfig.getParameter<edm::InputTag>("genMETSource"); 00023 addTrigMatch_ = iConfig.getParameter<bool> ( "addTrigMatch" ); 00024 trigMatchSrc_ = iConfig.getParameter<std::vector<edm::InputTag> >( "trigPrimMatch" ); 00025 addResolutions_ = iConfig.getParameter<bool> ("addResolutions"); 00026 00027 // Efficiency configurables 00028 addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies"); 00029 if (addEfficiencies_) { 00030 efficiencyLoader_ = pat::helper::EfficiencyLoader(iConfig.getParameter<edm::ParameterSet>("efficiencies")); 00031 } 00032 00033 // Check to see if the user wants to add user data 00034 useUserData_ = false; 00035 if ( iConfig.exists("userData") ) { 00036 useUserData_ = true; 00037 } 00038 00039 00040 // produces vector of mets 00041 produces<std::vector<MET> >(); 00042 }
PATMETProducer::~PATMETProducer | ( | ) |
void PATMETProducer::produce | ( | edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [virtual] |
Implements edm::EDProducer.
Definition at line 49 of file PATMETProducer.cc.
References pat::PATUserDataHelper< ObjectType >::add(), addGenMET_, pat::PATObject< ObjectType >::addTriggerMatch(), addTrigMatch_, efficiencyLoader_, pat::helper::EfficiencyLoader::enabled(), edm::InputTag::encode(), genMETSrc_, edm::Event::getByLabel(), i, edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), metSrc_, pat::helper::EfficiencyLoader::newEvent(), edm::Event::put(), pat::helper::EfficiencyLoader::setEfficiencies(), pat::MET::setGenMET(), trigMatchSrc_, userDataHelper_, and useUserData_.
00049 { 00050 00051 // Get the vector of MET's from the event 00052 edm::Handle<edm::View<METType> > mets; 00053 iEvent.getByLabel(metSrc_, mets); 00054 00055 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"; 00056 if (efficiencyLoader_.enabled()) efficiencyLoader_.newEvent(iEvent); 00057 00058 // Get the vector of generated met from the event if needed 00059 edm::Handle<edm::View<reco::GenMET> > genMETs; 00060 if (addGenMET_) { 00061 iEvent.getByLabel(genMETSrc_, genMETs); 00062 } 00063 00064 // loop over mets 00065 std::vector<MET> * patMETs = new std::vector<MET>(); 00066 for (edm::View<METType>::const_iterator itMET = mets->begin(); itMET != mets->end(); itMET++) { 00067 // construct the MET from the ref -> save ref to original object 00068 unsigned int idx = itMET - mets->begin(); 00069 edm::RefToBase<METType> metsRef = mets->refAt(idx); 00070 edm::Ptr<METType> metsPtr = mets->ptrAt(idx); 00071 MET amet(metsRef); 00072 // add the generated MET 00073 if (addGenMET_) amet.setGenMET((*genMETs)[idx]); 00074 // matches to trigger primitives 00075 if ( addTrigMatch_ ) { 00076 for ( size_t i = 0; i < trigMatchSrc_.size(); ++i ) { 00077 edm::Handle<edm::Association<TriggerPrimitiveCollection> > trigMatch; 00078 iEvent.getByLabel(trigMatchSrc_[i], trigMatch); 00079 TriggerPrimitiveRef trigPrim = (*trigMatch)[metsRef]; 00080 if ( trigPrim.isNonnull() && trigPrim.isAvailable() ) { 00081 amet.addTriggerMatch(*trigPrim); 00082 } 00083 } 00084 } 00085 00086 if (efficiencyLoader_.enabled()) { 00087 efficiencyLoader_.setEfficiencies( amet, metsRef ); 00088 } 00089 00090 00091 if ( useUserData_ ) { 00092 userDataHelper_.add( amet, iEvent, iSetup ); 00093 } 00094 00095 00096 // correct for muons if demanded... never more: it's now done by JetMETCorrections 00097 // add the MET to the vector of METs 00098 patMETs->push_back(amet); 00099 } 00100 00101 // sort MET in ET .. don't mess with this 00102 // std::sort(patMETs->begin(), patMETs->end(), eTComparator_); 00103 00104 // put genEvt object in Event 00105 std::auto_ptr<std::vector<MET> > myMETs(patMETs); 00106 iEvent.put(myMETs); 00107 00108 }
bool pat::PATMETProducer::addEfficiencies_ [private] |
bool pat::PATMETProducer::addGenMET_ [private] |
bool pat::PATMETProducer::addMuonCorr_ [private] |
Definition at line 54 of file PATMETProducer.h.
bool pat::PATMETProducer::addResolutions_ [private] |
bool pat::PATMETProducer::addTrigMatch_ [private] |
GreaterByEt<MET> pat::PATMETProducer::eTComparator_ [private] |
Definition at line 57 of file PATMETProducer.h.
edm::InputTag pat::PATMETProducer::genMETSrc_ [private] |
edm::InputTag pat::PATMETProducer::metSrc_ [private] |
edm::InputTag pat::PATMETProducer::muonSrc_ [private] |
Definition at line 55 of file PATMETProducer.h.
std::vector<edm::InputTag> pat::PATMETProducer::trigMatchSrc_ [private] |
bool pat::PATMETProducer::useUserData_ [private] |