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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::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

◆ METCollection

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

Definition at line 29 of file MinMETProducerT.h.

◆ vInputTag

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

Definition at line 82 of file MinMETProducerT.h.

◆ vInputToken

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

Definition at line 84 of file MinMETProducerT.h.

Constructor & Destructor Documentation

◆ MinMETProducerT()

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

Definition at line 32 of file MinMETProducerT.h.

References looper::cfg, MinMETProducerT< T >::src_, and MinMETProducerT< T >::src_token_.

33  : moduleLabel_(cfg.getParameter<std::string>("@module_label")) {
34  src_ = cfg.getParameter<vInputTag>("src");
35 
36  for (vInputTag::const_iterator src_i = src_.begin(); src_i != src_.end(); ++src_i) {
37  src_token_.push_back(consumes<METCollection>(*src_i));
38  }
39  produces<METCollection>();
40  }
std::vector< edm::InputTag > vInputTag
vInputToken src_token_
std::string moduleLabel_

◆ ~MinMETProducerT()

template<typename T >
MinMETProducerT< T >::~MinMETProducerT ( )
inlineoverride

Definition at line 41 of file MinMETProducerT.h.

41 {}

Member Function Documentation

◆ produce()

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

Definition at line 44 of file MinMETProducerT.h.

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

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

Member Data Documentation

◆ moduleLabel_

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

◆ src_

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

Definition at line 83 of file MinMETProducerT.h.

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

◆ src_token_

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