CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions | Private Attributes

MinMETProducerT< T > Class Template Reference

#include <MinMETProducerT.h>

Inheritance diagram for MinMETProducerT< T >:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 MinMETProducerT (const edm::ParameterSet &cfg)
 ~MinMETProducerT ()

Private Types

typedef std::vector< TMETCollection
typedef std::vector
< edm::InputTag
vInputTag

Private Member Functions

void produce (edm::Event &evt, const edm::EventSetup &es) override

Private Attributes

std::string moduleLabel_
vInputTag src_

Detailed Description

template<typename T>
class MinMETProducerT< T >

Produce MET object representing the minimum missing transverse energy of set of MET objects given as input

NOTE: class is templated to that it works with reco::CaloMET as well as with reco::PFMET objects as input

Author:
Christian Veelken, LLR
Version:
Revision:
1.2
Id:
MinMETProducerT.h,v 1.2 2013/03/06 19:31:56 vadler Exp

Definition at line 29 of file MinMETProducerT.h.


Member Typedef Documentation

template<typename T >
typedef std::vector<T> MinMETProducerT< T >::METCollection [private]

Definition at line 31 of file MinMETProducerT.h.

template<typename T >
typedef std::vector<edm::InputTag> MinMETProducerT< T >::vInputTag [private]

Definition at line 80 of file MinMETProducerT.h.


Constructor & Destructor Documentation

template<typename T >
MinMETProducerT< T >::MinMETProducerT ( const edm::ParameterSet cfg) [inline, explicit]

Definition at line 35 of file MinMETProducerT.h.

References edm::ParameterSet::getParameter(), and MinMETProducerT< T >::src_.

    : moduleLabel_(cfg.getParameter<std::string>("@module_label"))
  {
    src_ = cfg.getParameter<vInputTag>("src");

    produces<METCollection>();
  }
template<typename T >
MinMETProducerT< T >::~MinMETProducerT ( ) [inline]

Definition at line 42 of file MinMETProducerT.h.

{}

Member Function Documentation

template<typename T >
void MinMETProducerT< T >::produce ( edm::Event evt,
const edm::EventSetup es 
) [inline, override, private, virtual]

Implements edm::EDProducer.

Definition at line 46 of file MinMETProducerT.h.

References edm::Event::getByLabel(), edm::Event::put(), and MinMETProducerT< T >::src_.

  {
    std::auto_ptr<METCollection> outputMETs(new METCollection());

    // check that all MET collections given as input have the same number of entries
    int numMEtObjects = -1;
    for ( vInputTag::const_iterator src_i = src_.begin();
          src_i != src_.end(); ++src_i ) {
      edm::Handle<METCollection> inputMETs;
      evt.getByLabel(*src_i, inputMETs);
      if ( numMEtObjects == -1 ) numMEtObjects = inputMETs->size();
      else if ( numMEtObjects != (int)inputMETs->size() )
        throw cms::Exception("MinMETProducer::produce")
          << "Mismatch in number of input MET objects !!\n";
    }

    for ( int iMEtObject = 0; iMEtObject < numMEtObjects; ++iMEtObject ) {
      const T* minMET = 0;
      for ( vInputTag::const_iterator src_i = src_.begin();
            src_i != src_.end(); ++src_i ) {
        edm::Handle<METCollection> inputMETs;
        evt.getByLabel(*src_i, inputMETs);
        const T& inputMET = inputMETs->at(iMEtObject);
        if ( minMET == 0 || inputMET.pt() < minMET->pt() ) minMET = &inputMET;
      }
      assert(minMET);
      outputMETs->push_back(T(*minMET));
    }

    evt.put(outputMETs);
  }

Member Data Documentation

template<typename T >
std::string MinMETProducerT< T >::moduleLabel_ [private]

Definition at line 78 of file MinMETProducerT.h.

template<typename T >
vInputTag MinMETProducerT< T >::src_ [private]