CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
RunLumiEventChecker Class Reference

#include <FWCore/Modules/src/RunLumiEventChecker.cc>

Inheritance diagram for RunLumiEventChecker:
edm::global::EDAnalyzer< edm::RunCache< rlec::Cache >, edm::LuminosityBlockCache< rlec::Cache > > edm::global::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 RunLumiEventChecker (edm::ParameterSet const &)
 
 ~RunLumiEventChecker () override
 
- Public Member Functions inherited from edm::global::EDAnalyzer< edm::RunCache< rlec::Cache >, edm::LuminosityBlockCache< rlec::Cache > >
 EDAnalyzer ()=default
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDAnalyzerBase () override
 
- 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void analyze (edm::StreamID, edm::Event const &, edm::EventSetup const &) const override
 
void beginJob () override
 
void check (edm::EventID const &iID, bool isEvent) const
 
void endJob () override
 
std::shared_ptr< rlec::CacheglobalBeginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &es) const override
 
std::shared_ptr< rlec::CacheglobalBeginRun (edm::Run const &run, edm::EventSetup const &es) const override
 
void globalEndLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &es) const override
 
void globalEndRun (edm::Run const &run, edm::EventSetup const &es) const override
 

Private Attributes

std::vector< edm::EventIDids_
 
std::atomic< unsigned int > index_
 
bool unorderedEvents_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

Description: Checks that the events passed to it come in the order specified in its configuration

Implementation: <Notes on="" implementation>="">

Definition at line 46 of file RunLumiEventChecker.cc.

Constructor & Destructor Documentation

RunLumiEventChecker::RunLumiEventChecker ( edm::ParameterSet const &  iConfig)
explicit

Definition at line 84 of file RunLumiEventChecker.cc.

85  : ids_(iConfig.getUntrackedParameter<std::vector<edm::EventID>>("eventSequence")),
86  index_(0),
87  unorderedEvents_(iConfig.getUntrackedParameter<bool>("unorderedEvents")) {
88  //now do what ever initialization is needed
89 }
std::vector< edm::EventID > ids_
std::atomic< unsigned int > index_
RunLumiEventChecker::~RunLumiEventChecker ( )
override

Definition at line 91 of file RunLumiEventChecker.cc.

91  {
92  // do anything here that needs to be done at desctruction time
93  // (e.g. close files, deallocate resources etc.)
94 }

Member Function Documentation

void RunLumiEventChecker::analyze ( edm::StreamID  ,
edm::Event const &  iEvent,
edm::EventSetup const &   
) const
overrideprivatevirtual

Implements edm::global::EDAnalyzerBase.

Definition at line 120 of file RunLumiEventChecker.cc.

References check(), and edm::EventBase::id().

120  {
121  check(iEvent.id(), true);
122 }
void check(edm::EventID const &iID, bool isEvent) const
int iEvent
Definition: GenABIO.cc:224
void RunLumiEventChecker::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::global::EDAnalyzerBase.

Definition at line 143 of file RunLumiEventChecker.cc.

143 {}
void RunLumiEventChecker::check ( edm::EventID const &  iID,
bool  isEvent 
) const
private

Definition at line 100 of file RunLumiEventChecker.cc.

References Exception, spr::find(), ids_, index_, and unorderedEvents_.

Referenced by analyze(), globalBeginLuminosityBlock(), globalBeginRun(), globalEndLuminosityBlock(), and globalEndRun().

100  {
101  if (index_ >= ids_.size()) {
102  throw cms::Exception("TooManyEvents")
103  << "Was passes " << ids_.size() << " EventIDs but have processed more events than that\n";
104  }
105  if (unorderedEvents_) {
106  auto itFound = std::find(ids_.begin(), ids_.end(), iEventID);
107  if (itFound == ids_.end()) {
108  throw cms::Exception("UnexpecedEvent") << "The event " << iEventID << " was not expected.";
109  }
110  } else {
111  if (iEventID != ids_[index_]) {
112  throw cms::Exception("WrongEvent") << "Was expecting event " << ids_[index_] << " but was given " << iEventID
113  << "\n";
114  }
115  }
116  ++index_;
117 }
std::vector< edm::EventID > ids_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::atomic< unsigned int > index_
void RunLumiEventChecker::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::global::EDAnalyzerBase.

Definition at line 146 of file RunLumiEventChecker.cc.

References Exception, ids_, and index_.

146  {
147  if (index_ != ids_.size()) {
148  throw cms::Exception("WrongNumberOfEvents")
149  << "Saw " << index_ << " events but was supposed to see " << ids_.size() << "\n";
150  }
151 }
std::vector< edm::EventID > ids_
std::atomic< unsigned int > index_
void RunLumiEventChecker::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 154 of file RunLumiEventChecker.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), and DEFINE_FWK_MODULE.

154  {
156  desc.addUntracked<std::vector<edm::EventID>>("eventSequence");
157  desc.addUntracked<bool>("unorderedEvents", false);
158  descriptions.add("runLumiEventIDChecker", desc);
159 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::shared_ptr< rlec::Cache > RunLumiEventChecker::globalBeginLuminosityBlock ( edm::LuminosityBlock const &  lumi,
edm::EventSetup const &  es 
) const
overrideprivate

Definition at line 132 of file RunLumiEventChecker.cc.

References check(), edm::LuminosityBlockBase::id(), edm::LuminosityBlockID::luminosityBlock(), and edm::LuminosityBlockID::run().

133  {
134  check(edm::EventID(lumi.id().run(), lumi.id().luminosityBlock(), 0), false);
135  return std::shared_ptr<rlec::Cache>{};
136 }
void check(edm::EventID const &iID, bool isEvent) const
std::shared_ptr< rlec::Cache > RunLumiEventChecker::globalBeginRun ( edm::Run const &  run,
edm::EventSetup const &  es 
) const
overrideprivate

Definition at line 124 of file RunLumiEventChecker.cc.

References check(), edm::RunBase::id(), and edm::RunID::run().

124  {
125  check(edm::EventID(run.id().run(), 0, 0), false);
126  return std::shared_ptr<rlec::Cache>{};
127 }
void check(edm::EventID const &iID, bool isEvent) const
void RunLumiEventChecker::globalEndLuminosityBlock ( edm::LuminosityBlock const &  lumi,
edm::EventSetup const &  es 
) const
overrideprivate

Definition at line 138 of file RunLumiEventChecker.cc.

References check(), edm::LuminosityBlockBase::id(), edm::LuminosityBlockID::luminosityBlock(), and edm::LuminosityBlockID::run().

138  {
139  check(edm::EventID(lumi.id().run(), lumi.id().luminosityBlock(), 0), false);
140 }
void check(edm::EventID const &iID, bool isEvent) const
void RunLumiEventChecker::globalEndRun ( edm::Run const &  run,
edm::EventSetup const &  es 
) const
overrideprivate

Definition at line 128 of file RunLumiEventChecker.cc.

References check(), edm::RunBase::id(), and edm::RunID::run().

128  {
129  check(edm::EventID(run.id().run(), 0, 0), false);
130 }
void check(edm::EventID const &iID, bool isEvent) const

Member Data Documentation

std::vector<edm::EventID> RunLumiEventChecker::ids_
private

Definition at line 68 of file RunLumiEventChecker.cc.

Referenced by check(), and endJob().

std::atomic<unsigned int> RunLumiEventChecker::index_
mutableprivate

Definition at line 69 of file RunLumiEventChecker.cc.

Referenced by check(), and endJob().

bool RunLumiEventChecker::unorderedEvents_
private

Definition at line 70 of file RunLumiEventChecker.cc.

Referenced by check().