CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
pat::PATMETSlimmer Class Reference

Slimmer of PAT METs. More...

Inheritance diagram for pat::PATMETSlimmer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

class  OneMETShift
 

Public Member Functions

 PATMETSlimmer (const edm::ParameterSet &iConfig)
 
void produce (edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
 
 ~PATMETSlimmer () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void maybeReadShifts (const edm::ParameterSet &basePSet, const std::string &name, pat::MET::METCorrectionType level, bool readFromMiniAOD=false)
 

Private Attributes

const bool onMiniAOD_
 
std::vector< OneMETShiftshifts_
 
const edm::EDGetTokenT< pat::METCollectionsrc_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Slimmer of PAT METs.

Definition at line 19 of file PATMETSlimmer.cc.

Constructor & Destructor Documentation

pat::PATMETSlimmer::PATMETSlimmer ( const edm::ParameterSet iConfig)
explicit

Definition at line 53 of file PATMETSlimmer.cc.

References pat::MET::Calo, pat::MET::Chs, maybeReadShifts(), pat::MET::None, onMiniAOD_, pat::MET::Smear, pat::MET::T0, pat::MET::T1, pat::MET::Trk, pat::MET::TXY, pat::MET::TXYForRaw, pat::MET::TXYForT01, pat::MET::TXYForT01Smear, and pat::MET::TXYForT1Smear.

53  :
54  src_(consumes<pat::METCollection>(iConfig.getParameter<edm::InputTag>("src"))),
55  onMiniAOD_(iConfig.existsAs<bool>("runningOnMiniAOD") ? iConfig.getParameter<bool>("runningOnMiniAOD") : false)
56 {
57  maybeReadShifts( iConfig, "rawVariation", pat::MET::None );
58  maybeReadShifts( iConfig, "t1Uncertainties", pat::MET::T1 );
59  maybeReadShifts( iConfig, "t01Variation", pat::MET::T0, onMiniAOD_ );
60  maybeReadShifts( iConfig, "t1SmearedVarsAndUncs", pat::MET::Smear );
61 
62  maybeReadShifts( iConfig, "tXYUncForRaw", pat::MET::TXYForRaw );
63  maybeReadShifts( iConfig, "tXYUncForT1", pat::MET::TXY );
64  maybeReadShifts( iConfig, "tXYUncForT01", pat::MET::TXYForT01 );
65  maybeReadShifts( iConfig, "tXYUncForT1Smear", pat::MET::TXYForT1Smear );
66  maybeReadShifts( iConfig, "tXYUncForT01Smear", pat::MET::TXYForT01Smear );
67  maybeReadShifts( iConfig, "caloMET", pat::MET::Calo );
68  maybeReadShifts( iConfig, "chsMET", pat::MET::Chs );
69  maybeReadShifts( iConfig, "trkMET", pat::MET::Trk );
70 
71  produces<std::vector<pat::MET> >();
72 }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
void maybeReadShifts(const edm::ParameterSet &basePSet, const std::string &name, pat::MET::METCorrectionType level, bool readFromMiniAOD=false)
const edm::EDGetTokenT< pat::METCollection > src_
const bool onMiniAOD_
pat::PATMETSlimmer::~PATMETSlimmer ( )
inlineoverride

Definition at line 22 of file PATMETSlimmer.cc.

References iEvent, and produce().

22 { }

Member Function Documentation

void pat::PATMETSlimmer::maybeReadShifts ( const edm::ParameterSet basePSet,
const std::string &  name,
pat::MET::METCorrectionType  level,
bool  readFromMiniAOD = false 
)
private

Definition at line 74 of file PATMETSlimmer.cc.

References edm::EDConsumerBase::consumesCollector(), pat::MET::ElectronEnDown, pat::MET::ElectronEnUp, Exception, edm::ParameterSet::existsAs(), edm::ParameterSet::getParameter(), pat::MET::JetEnDown, pat::MET::JetEnUp, pat::MET::JetResDown, pat::MET::JetResUp, pat::MET::MuonEnDown, pat::MET::MuonEnUp, dataset::name, pat::MET::NoShift, pat::MET::PhotonEnDown, pat::MET::PhotonEnUp, shifts_, pat::MET::Smear, pat::MET::T1, pat::MET::TauEnDown, pat::MET::TauEnUp, pat::MET::UnclusteredEnDown, and pat::MET::UnclusteredEnUp.

Referenced by PATMETSlimmer().

74  {
75 
76  if (basePSet.existsAs<edm::ParameterSet>(name)) {
77  throw cms::Exception("Unsupported", "Reading PSets not supported, for now just use input tag");
78  } else if (basePSet.existsAs<edm::InputTag>(name) ) {
79  const edm::InputTag & baseTag = basePSet.getParameter<edm::InputTag>(name);
80 
81  if(level==pat::MET::T1) {
82  shifts_.push_back(OneMETShift(pat::MET::NoShift, level, baseTag, consumesCollector(), readFromMiniAOD, true, false, false));
83  shifts_.push_back(OneMETShift(pat::MET::NoShift, level, baseTag, consumesCollector(), readFromMiniAOD, false, true));
84  shifts_.push_back(OneMETShift(pat::MET::JetResUp, level, baseTag, consumesCollector(), readFromMiniAOD, false, true));
85  shifts_.push_back(OneMETShift(pat::MET::JetResDown, level, baseTag, consumesCollector(), readFromMiniAOD, false, true));
86  shifts_.push_back(OneMETShift(pat::MET::JetEnUp, level, baseTag, consumesCollector(), readFromMiniAOD, false, true));
87  shifts_.push_back(OneMETShift(pat::MET::JetEnDown, level, baseTag, consumesCollector(), readFromMiniAOD, false, true));
88  shifts_.push_back(OneMETShift(pat::MET::MuonEnUp, level, baseTag, consumesCollector(), readFromMiniAOD, false, true));
89  shifts_.push_back(OneMETShift(pat::MET::MuonEnDown, level, baseTag, consumesCollector(), readFromMiniAOD, false, true));
90  shifts_.push_back(OneMETShift(pat::MET::ElectronEnUp, level, baseTag, consumesCollector(), readFromMiniAOD, false, true));
91  shifts_.push_back(OneMETShift(pat::MET::ElectronEnDown, level, baseTag, consumesCollector(), readFromMiniAOD, false, true));
92  shifts_.push_back(OneMETShift(pat::MET::PhotonEnUp, level, baseTag, consumesCollector(), readFromMiniAOD, false, true));
93  shifts_.push_back(OneMETShift(pat::MET::PhotonEnDown, level, baseTag, consumesCollector(), readFromMiniAOD, false, true));
94  shifts_.push_back(OneMETShift(pat::MET::TauEnUp, level, baseTag, consumesCollector(), readFromMiniAOD, false, true));
95  shifts_.push_back(OneMETShift(pat::MET::TauEnDown, level, baseTag, consumesCollector(), readFromMiniAOD, false, true));
96  shifts_.push_back(OneMETShift(pat::MET::UnclusteredEnUp, level, baseTag, consumesCollector(), readFromMiniAOD, false, true));
97  shifts_.push_back(OneMETShift(pat::MET::UnclusteredEnDown, level, baseTag, consumesCollector(), readFromMiniAOD, false, true));
98  }
99  else if(level==pat::MET::Smear) {
100  shifts_.push_back(OneMETShift(pat::MET::NoShift, level, baseTag, consumesCollector(), readFromMiniAOD, true, false, true));
101  shifts_.push_back(OneMETShift(pat::MET::JetResUp, level, baseTag, consumesCollector(), readFromMiniAOD, false, true, true));
102  shifts_.push_back(OneMETShift(pat::MET::JetResDown, level, baseTag, consumesCollector(), readFromMiniAOD, false, true, true));
103  }
104  else {
105  shifts_.push_back(OneMETShift(pat::MET::NoShift, level, baseTag, consumesCollector(), readFromMiniAOD, true, false));
106  }
107  }
108 
109 }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
std::vector< OneMETShift > shifts_
void pat::PATMETSlimmer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
override

Definition at line 141 of file PATMETSlimmer.cc.

References edm::Event::getByToken(), RazorAnalyzer::met, eostools::move(), MillePedeFileConverter_cfg::out, edm::Event::put(), pat::PATMETSlimmer::OneMETShift::shift, shifts_, TrackRefitter_38T_cff::src, and src_.

Referenced by ~PATMETSlimmer().

141  {
142  using namespace edm;
143  using namespace std;
144 
146  iEvent.getByToken(src_, src);
147  if (src->size() != 1) throw cms::Exception("CorruptData", "More than one MET in the collection");
148 
149  auto out = std::make_unique<std::vector<pat::MET>>(1, src->front());
150  pat::MET & met = out->back();
151 
152  for (const OneMETShift &shift : shifts_) {
153  shift.readAndSet(iEvent, met);
154  }
155 
156  iEvent.put(std::move(out));
157 
158 }
Analysis-level MET class.
Definition: MET.h:43
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
const edm::EDGetTokenT< pat::METCollection > src_
met
===> hadronic RAZOR
HLT enums.
static unsigned int const shift
std::vector< OneMETShift > shifts_
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

const bool pat::PATMETSlimmer::onMiniAOD_
private

Definition at line 48 of file PATMETSlimmer.cc.

Referenced by PATMETSlimmer().

std::vector<OneMETShift> pat::PATMETSlimmer::shifts_
private

Definition at line 46 of file PATMETSlimmer.cc.

Referenced by maybeReadShifts(), and produce().

const edm::EDGetTokenT<pat::METCollection> pat::PATMETSlimmer::src_
private

Definition at line 45 of file PATMETSlimmer.cc.

Referenced by produce().