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
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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_
 
unsigned int maxNEvents_ = 0
 
unsigned int minNEvents_ = 0
 
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)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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::RunLumiEventChecker ( edm::ParameterSet const &  iConfig)
explicit

Definition at line 86 of file RunLumiEventChecker.cc.

87  : ids_(iConfig.getUntrackedParameter<std::vector<edm::EventID>>("eventSequence")),
88  index_(0),
89  minNEvents_(iConfig.getUntrackedParameter<unsigned int>("minNumberOfEvents")),
90  maxNEvents_(iConfig.getUntrackedParameter<unsigned int>("maxNumberOfEvents")),
91  unorderedEvents_(iConfig.getUntrackedParameter<bool>("unorderedEvents")) {
92  //now do what ever initialization is needed
93 }
std::vector< edm::EventID > ids_
std::atomic< unsigned int > index_

◆ ~RunLumiEventChecker()

RunLumiEventChecker::~RunLumiEventChecker ( )
override

Definition at line 95 of file RunLumiEventChecker.cc.

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

Member Function Documentation

◆ analyze()

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

Implements edm::global::EDAnalyzerBase.

Definition at line 124 of file RunLumiEventChecker.cc.

References check(), and iEvent.

124  {
125  check(iEvent.id(), true);
126 }
int iEvent
Definition: GenABIO.cc:224
void check(edm::EventID const &iID, bool isEvent) const

◆ beginJob()

void RunLumiEventChecker::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::global::EDAnalyzerBase.

Definition at line 147 of file RunLumiEventChecker.cc.

147 {}

◆ check()

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

Definition at line 104 of file RunLumiEventChecker.cc.

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

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

104  {
105  if (index_ >= ids_.size()) {
106  throw cms::Exception("TooManyEvents")
107  << "Was passes " << ids_.size() << " EventIDs but have processed more events than that\n";
108  }
109  if (unorderedEvents_) {
110  auto itFound = std::find(ids_.begin(), ids_.end(), iEventID);
111  if (itFound == ids_.end()) {
112  throw cms::Exception("UnexpecedEvent") << "The event " << iEventID << " was not expected.";
113  }
114  } else {
115  if (iEventID != ids_[index_]) {
116  throw cms::Exception("WrongEvent") << "Was expecting event " << ids_[index_] << " but was given " << iEventID
117  << "\n";
118  }
119  }
120  ++index_;
121 }
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:19
std::atomic< unsigned int > index_

◆ endJob()

void RunLumiEventChecker::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::global::EDAnalyzerBase.

Definition at line 150 of file RunLumiEventChecker.cc.

References Exception, ids_, index_, maxNEvents_, and minNEvents_.

150  {
151  if (maxNEvents_ == 0 and index_ != ids_.size()) {
152  throw cms::Exception("WrongNumberOfEvents")
153  << "Saw " << index_ << " (begin runs)+(begin lumis)+events+(end lumis)+(end runs) but was supposed to see "
154  << ids_.size() << "\n";
155  }
156  if (maxNEvents_ != 0 and (index_ < minNEvents_ or index_ > maxNEvents_)) {
157  throw cms::Exception("WrongNumberOfEvents")
158  << "Saw " << index_
159  << " (begin runs)+(begin lumis)+events+(end lumis)+(end runs) but was supposed to see between " << minNEvents_
160  << " and " << maxNEvents_;
161  }
162 }
std::vector< edm::EventID > ids_
std::atomic< unsigned int > index_

◆ fillDescriptions()

void RunLumiEventChecker::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 165 of file RunLumiEventChecker.cc.

References edm::ConfigurationDescriptions::add(), and submitPVResolutionJobs::desc.

165  {
167  desc.addUntracked<std::vector<edm::EventID>>("eventSequence");
168  desc.addUntracked<unsigned int>("minNumberOfEvents", 0)
169  ->setComment(
170  "minimum number of Events that must be seen. If max is 0 then this will be ignored and all Events must be "
171  "present");
172  desc.addUntracked<unsigned int>("maxNumberOfEvents", 0)
173  ->setComment("maximum number of Events that must be seen. If set to 0, min and max are ignored");
174  desc.addUntracked<bool>("unorderedEvents", false)
175  ->setComment("set to true if events are not guaranteed to be in same order as 'eventSequence' specifies.");
176  descriptions.add("runLumiEventIDChecker", desc);
177 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ globalBeginLuminosityBlock()

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().

137  {
138  check(edm::EventID(lumi.id().run(), lumi.id().luminosityBlock(), 0), false);
139  return std::shared_ptr<rlec::Cache>{};
140 }
void check(edm::EventID const &iID, bool isEvent) const

◆ globalBeginRun()

std::shared_ptr< rlec::Cache > RunLumiEventChecker::globalBeginRun ( edm::Run const &  run,
edm::EventSetup const &  es 
) const
overrideprivate

Definition at line 128 of file RunLumiEventChecker.cc.

References check(), and writedatasetfile::run.

128  {
129  check(edm::EventID(run.id().run(), 0, 0), false);
130  return std::shared_ptr<rlec::Cache>{};
131 }
void check(edm::EventID const &iID, bool isEvent) const

◆ globalEndLuminosityBlock()

void RunLumiEventChecker::globalEndLuminosityBlock ( edm::LuminosityBlock const &  lumi,
edm::EventSetup const &  es 
) const
overrideprivate

Definition at line 142 of file RunLumiEventChecker.cc.

References check().

142  {
143  check(edm::EventID(lumi.id().run(), lumi.id().luminosityBlock(), 0), false);
144 }
void check(edm::EventID const &iID, bool isEvent) const

◆ globalEndRun()

void RunLumiEventChecker::globalEndRun ( edm::Run const &  run,
edm::EventSetup const &  es 
) const
overrideprivate

Definition at line 132 of file RunLumiEventChecker.cc.

References check(), and writedatasetfile::run.

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

Member Data Documentation

◆ ids_

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

Definition at line 68 of file RunLumiEventChecker.cc.

Referenced by check(), and endJob().

◆ index_

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

Definition at line 69 of file RunLumiEventChecker.cc.

Referenced by check(), and endJob().

◆ maxNEvents_

unsigned int RunLumiEventChecker::maxNEvents_ = 0
private

Definition at line 71 of file RunLumiEventChecker.cc.

Referenced by endJob().

◆ minNEvents_

unsigned int RunLumiEventChecker::minNEvents_ = 0
private

Definition at line 70 of file RunLumiEventChecker.cc.

Referenced by endJob().

◆ unorderedEvents_

bool RunLumiEventChecker::unorderedEvents_
private

Definition at line 72 of file RunLumiEventChecker.cc.

Referenced by check().