CMS 3D CMS Logo

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::ProductRegistryHelper

List of all members.

Public Member Functions

 PATMETProducer (const edm::ParameterSet &iConfig)
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 ~PATMETProducer ()

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)

Private Attributes

bool addEfficiencies_
bool addGenMET_
bool addMuonCorr_
bool addResolutions_
pat::helper::EfficiencyLoader efficiencyLoader_
GreaterByEt< METeTComparator_
edm::InputTag genMETSrc_
edm::InputTag metSrc_
edm::InputTag muonSrc_
pat::helper::KinResolutionsLoader resolutionLoader_
pat::PATUserDataHelper< pat::METuserDataHelper_
bool useUserData_

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 37 of file PATMETProducer.h.


Constructor & Destructor Documentation

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

Definition at line 19 of file PATMETProducer.cc.

References addEfficiencies_, addGenMET_, addResolutions_, efficiencyLoader_, genMETSrc_, edm::ParameterSet::getParameter(), metSrc_, resolutionLoader_, userDataHelper_, and useUserData_.

                                                             :
  useUserData_(iConfig.exists("userData"))
{
  // initialize the configurables
  metSrc_         = iConfig.getParameter<edm::InputTag>("metSource");
  addGenMET_      = iConfig.getParameter<bool>         ("addGenMET");
  genMETSrc_      = iConfig.getParameter<edm::InputTag>("genMETSource");
  addResolutions_ = iConfig.getParameter<bool>         ("addResolutions");

  // Efficiency configurables
  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
  if (addEfficiencies_) {
     efficiencyLoader_ = pat::helper::EfficiencyLoader(iConfig.getParameter<edm::ParameterSet>("efficiencies"));
  }

  // Resolution configurables
  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
  if (addResolutions_) {
     resolutionLoader_ = pat::helper::KinResolutionsLoader(iConfig.getParameter<edm::ParameterSet>("resolutions"));
  }

  // Check to see if the user wants to add user data
  if ( useUserData_ ) {
    userDataHelper_ = PATUserDataHelper<MET>(iConfig.getParameter<edm::ParameterSet>("userData"));
  }

  
  // produces vector of mets
  produces<std::vector<MET> >();
}
PATMETProducer::~PATMETProducer ( )

Definition at line 51 of file PATMETProducer.cc.

                                {
}

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 111 of file PATMETProducer.cc.

References edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), pat::helper::KinResolutionsLoader::fillDescription(), edm::ParameterSetDescription::setAllowAnything(), and edm::ParameterSetDescription::setComment().

{
  edm::ParameterSetDescription iDesc;
  iDesc.setComment("PAT MET producer module");

  // input source 
  iDesc.add<edm::InputTag>("metSource", edm::InputTag("no default"))->setComment("input collection");

  // MC configurations
  iDesc.add<bool>("addGenMET", false);
  iDesc.add<edm::InputTag>("genMETSource", edm::InputTag("genMetCalo"));

  pat::helper::KinResolutionsLoader::fillDescription(iDesc);

  // Efficiency configurables
  edm::ParameterSetDescription efficienciesPSet;
  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
  iDesc.add("efficiencies", efficienciesPSet);
  iDesc.add<bool>("addEfficiencies", false);

  // Check to see if the user wants to add user data
  edm::ParameterSetDescription userDataPSet;
  PATUserDataHelper<MET>::fillDescription(userDataPSet);
  iDesc.addOptional("userData", userDataPSet);

  // muon correction
  iDesc.add<bool>("addMuonCorrections", false);
  iDesc.add<edm::InputTag>("muonSource", edm::InputTag("muons"));

}
void PATMETProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 55 of file PATMETProducer.cc.

References pat::PATUserDataHelper< ObjectType >::add(), addGenMET_, efficiencyLoader_, pat::helper::KinResolutionsLoader::enabled(), pat::helper::EfficiencyLoader::enabled(), edm::InputTag::encode(), genMETSrc_, edm::Event::getByLabel(), customizeTrackingMonitorSeedNumber::idx, metSrc_, 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_.

                                                                            {
 
  // Get the vector of MET's from the event
  edm::Handle<edm::View<reco::MET> > mets;
  iEvent.getByLabel(metSrc_, mets);

  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";
  if (efficiencyLoader_.enabled()) efficiencyLoader_.newEvent(iEvent);
  if (resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);

  // Get the vector of generated met from the event if needed
  edm::Handle<edm::View<reco::GenMET> > genMETs;
  if (addGenMET_) {
    iEvent.getByLabel(genMETSrc_, genMETs);
  }

  // loop over mets
  std::vector<MET> * patMETs = new std::vector<MET>(); 
  for (edm::View<reco::MET>::const_iterator itMET = mets->begin(); itMET != mets->end(); itMET++) {
    // construct the MET from the ref -> save ref to original object
    unsigned int idx = itMET - mets->begin();
    edm::RefToBase<reco::MET> metsRef = mets->refAt(idx);
    edm::Ptr<reco::MET> metsPtr = mets->ptrAt(idx);
    MET amet(metsRef);
    // add the generated MET
    if (addGenMET_) amet.setGenMET((*genMETs)[idx]);

    if (efficiencyLoader_.enabled()) {
        efficiencyLoader_.setEfficiencies( amet, metsRef );
    }

    if (resolutionLoader_.enabled()) {
        resolutionLoader_.setResolutions(amet);
    }


    if ( useUserData_ ) {
      userDataHelper_.add( amet, iEvent, iSetup );
    }
    

    // correct for muons if demanded... never more: it's now done by JetMETCorrections
    // add the MET to the vector of METs
    patMETs->push_back(amet);
  }

  // sort MET in ET .. don't mess with this
  //  std::sort(patMETs->begin(), patMETs->end(), eTComparator_);

  // put genEvt object in Event
  std::auto_ptr<std::vector<MET> > myMETs(patMETs);
  iEvent.put(myMETs);

}

Member Data Documentation

Definition at line 61 of file PATMETProducer.h.

Referenced by PATMETProducer().

Definition at line 52 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

Definition at line 56 of file PATMETProducer.h.

Definition at line 54 of file PATMETProducer.h.

Referenced by PATMETProducer().

Definition at line 62 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

Definition at line 59 of file PATMETProducer.h.

Definition at line 53 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

Definition at line 51 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

Definition at line 57 of file PATMETProducer.h.

Definition at line 55 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

Definition at line 65 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().

Definition at line 64 of file PATMETProducer.h.

Referenced by PATMETProducer(), and produce().