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
 
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)
 
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 ESProduct , Transition Tr = Transition::Event>
auto esConsumes (eventsetup::EventSetupRecordKey const &, 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 83 of file RunLumiEventChecker.cc.

83  :
84  ids_(iConfig.getUntrackedParameter<std::vector<edm::EventID> >("eventSequence")),
85  index_(0),
86  unorderedEvents_(iConfig.getUntrackedParameter<bool>("unorderedEvents"))
87 {
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 92 of file RunLumiEventChecker.cc.

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

Member Function Documentation

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

Implements edm::global::EDAnalyzerBase.

Definition at line 121 of file RunLumiEventChecker.cc.

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

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

Reimplemented from edm::global::EDAnalyzerBase.

Definition at line 149 of file RunLumiEventChecker.cc.

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

Definition at line 102 of file RunLumiEventChecker.cc.

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

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

102  {
103  if(index_ >= ids_.size()) {
104  throw cms::Exception("TooManyEvents") << "Was passes " << ids_.size() << " EventIDs but have processed more events than that\n";
105  }
106  if(unorderedEvents_) {
107  auto itFound =std::find(ids_.begin(),ids_.end(), iEventID);
108  if(itFound == ids_.end()) {
109  throw cms::Exception("UnexpecedEvent") <<"The event "<<iEventID<<" was not expected.";
110  }
111  } else {
112  if(iEventID != ids_[index_]) {
113  throw cms::Exception("WrongEvent") << "Was expecting event " << ids_[index_] << " but was given " << iEventID << "\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 154 of file RunLumiEventChecker.cc.

References Exception, ids_, and index_.

154  {
155  if(index_ != ids_.size()) {
156  throw cms::Exception("WrongNumberOfEvents")<<"Saw "<<index_<<" events but was supposed to see "<<ids_.size()<<"\n";
157  }
158 }
std::vector< edm::EventID > ids_
std::atomic< unsigned int > index_
void RunLumiEventChecker::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 162 of file RunLumiEventChecker.cc.

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

162  {
164  desc.addUntracked<std::vector<edm::EventID> >("eventSequence");
165  desc.addUntracked<bool>("unorderedEvents",false);
166  descriptions.add("runLumiEventIDChecker", desc);
167 }
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 136 of file RunLumiEventChecker.cc.

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

136  {
137  check(edm::EventID(lumi.id().run(), lumi.id().luminosityBlock(), 0), false);
138  return std::shared_ptr<rlec::Cache>{};
139 }
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 126 of file RunLumiEventChecker.cc.

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

126  {
127  check(edm::EventID(run.id().run(), 0, 0), false);
128  return std::shared_ptr<rlec::Cache>{};
129 }
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 142 of file RunLumiEventChecker.cc.

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

142  {
143  check(edm::EventID(lumi.id().run(), lumi.id().luminosityBlock(), 0), false);
144 }
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 131 of file RunLumiEventChecker.cc.

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

131  {
132  check(edm::EventID(run.id().run(), 0, 0), false);
133 }
void check(edm::EventID const &iID, bool isEvent) const

Member Data Documentation

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

Definition at line 66 of file RunLumiEventChecker.cc.

Referenced by check(), and endJob().

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

Definition at line 67 of file RunLumiEventChecker.cc.

Referenced by check(), and endJob().

bool RunLumiEventChecker::unorderedEvents_
private

Definition at line 68 of file RunLumiEventChecker.cc.

Referenced by check().