CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
MinMETProducerT< T > Class Template Reference

#include <MinMETProducerT.h>

Inheritance diagram for MinMETProducerT< T >:
edm::stream::EDProducer<>

Public Member Functions

 MinMETProducerT (const edm::ParameterSet &cfg)
 
 ~MinMETProducerT () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Types

typedef std::vector< TMETCollection
 
typedef std::vector< edm::InputTagvInputTag
 
typedef std::vector< edm::EDGetTokenT< METCollection > > vInputToken
 

Private Member Functions

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

Private Attributes

std::string moduleLabel_
 
vInputTag src_
 
vInputToken src_token_
 

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, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

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

Definition at line 28 of file MinMETProducerT.h.

Member Typedef Documentation

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

Definition at line 30 of file MinMETProducerT.h.

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

Definition at line 88 of file MinMETProducerT.h.

template<typename T >
typedef std::vector<edm::EDGetTokenT<METCollection> > MinMETProducerT< T >::vInputToken
private

Definition at line 90 of file MinMETProducerT.h.

Constructor & Destructor Documentation

template<typename T >
MinMETProducerT< T >::MinMETProducerT ( const edm::ParameterSet cfg)
inlineexplicit

Definition at line 34 of file MinMETProducerT.h.

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

34  : moduleLabel_(cfg.getParameter<std::string>("@module_label"))
35  {
36  src_ = cfg.getParameter<vInputTag>("src");
37 
38  for ( vInputTag::const_iterator src_i = src_.begin();
39  src_i != src_.end(); ++src_i ) {
40  src_token_.push_back( consumes<METCollection>(*src_i) );
41  }
42  produces<METCollection>();
43  }
T getParameter(std::string const &) const
std::vector< edm::InputTag > vInputTag
vInputToken src_token_
std::string moduleLabel_
template<typename T >
MinMETProducerT< T >::~MinMETProducerT ( )
inlineoverride

Definition at line 44 of file MinMETProducerT.h.

44 {}

Member Function Documentation

template<typename T >
void MinMETProducerT< T >::produce ( edm::Event evt,
const edm::EventSetup es 
)
inlineoverrideprivate

Definition at line 48 of file MinMETProducerT.h.

References edm::Event::getByToken(), JetEnergyShift_cfi::inputMETs, eostools::move(), edm::Event::put(), and MinMETProducerT< T >::src_token_.

49  {
50  auto outputMETs = std::make_unique<METCollection>();
51 
52  // check that all MET collections given as input have the same number of entries
53  int numMEtObjects = -1;
54  // for ( vInputTag::const_iterator src_i = src_.begin();
55  // src_i != src_.end(); ++src_i ) {
56  for ( typename vInputToken::const_iterator src_i = src_token_.begin();
57  src_i != src_token_.end(); ++src_i ) {
59  // evt.getByLabel(*src_i, inputMETs);
60  evt.getByToken(*src_i, inputMETs);
61  if ( numMEtObjects == -1 ) numMEtObjects = inputMETs->size();
62  else if ( numMEtObjects != (int)inputMETs->size() )
63  throw cms::Exception("MinMETProducer::produce")
64  << "Mismatch in number of input MET objects !!\n";
65  }
66 
67  for ( int iMEtObject = 0; iMEtObject < numMEtObjects; ++iMEtObject ) {
68  const T* minMET = nullptr;
69  // for ( vInputTag::const_iterator src_i = src_.begin();
70  // src_i != src_.end(); ++src_i ) {
71  for ( typename vInputToken::const_iterator src_i = src_token_.begin();
72  src_i != src_token_.end(); ++src_i ) {
74  // evt.getByLabel(*src_i, inputMETs);
75  evt.getByToken(*src_i, inputMETs);
76  const T& inputMET = inputMETs->at(iMEtObject);
77  if ( minMET == nullptr || inputMET.pt() < minMET->pt() ) minMET = &inputMET;
78  }
79  assert(minMET);
80  outputMETs->push_back(T(*minMET));
81  }
82 
83  evt.put(std::move(outputMETs));
84  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
vInputToken src_token_
long double T
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

template<typename T >
std::string MinMETProducerT< T >::moduleLabel_
private
template<typename T >
vInputTag MinMETProducerT< T >::src_
private

Definition at line 89 of file MinMETProducerT.h.

Referenced by MinMETProducerT< T >::MinMETProducerT().

template<typename T >
vInputToken MinMETProducerT< T >::src_token_
private