CMS 3D CMS Logo

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

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

Inheritance diagram for MulticoreRunLumiEventChecker:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 MulticoreRunLumiEventChecker (edm::ParameterSet const &)
 
 ~MulticoreRunLumiEventChecker ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 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)
 

Static Public Member Functions

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

Private Member Functions

virtual void analyze (edm::Event const &, edm::EventSetup const &) override
 
virtual void beginJob () override
 
virtual void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &es) override
 
virtual void beginRun (edm::Run const &run, edm::EventSetup const &es) override
 
void check (edm::EventID const &iID, bool isEvent)
 
virtual void endJob () override
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &es) override
 
virtual void endRun (edm::Run const &run, edm::EventSetup const &es) override
 
virtual void postForkReacquireResources (unsigned int iChildIndex, unsigned int iNumberOfChildren) override
 
virtual void preForkReleaseResources () override
 

Private Attributes

std::vector< edm::EventIDids_
 
unsigned int index_
 
edm::propagate_const< std::shared_ptr< boost::thread > > listenerThread_
 
int messageQueue_
 
unsigned int multiProcessSequentialEvents_
 
bool mustSearch_
 
unsigned int numberOfEventsLeftBeforeSearch_
 
std::map< edm::EventID, unsigned int > seenIDs_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer 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 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 52 of file MulticoreRunLumiEventChecker.cc.

Constructor & Destructor Documentation

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

Definition at line 97 of file MulticoreRunLumiEventChecker.cc.

97  :
98  ids_(iConfig.getUntrackedParameter<std::vector<edm::EventID> >("eventSequence")),
99  index_(0),
100  multiProcessSequentialEvents_(iConfig.getUntrackedParameter<unsigned int>("multiProcessSequentialEvents")),
102  mustSearch_(false),
103  messageQueue_(-1)
104 {
105  //now do what ever initialization is needed
106 }
MulticoreRunLumiEventChecker::~MulticoreRunLumiEventChecker ( )

Definition at line 109 of file MulticoreRunLumiEventChecker.cc.

References edm::EventID::event(), cmsRelvalreport::exit, hcalTTPDigis_cfi::id, and edm::EventID::run().

109  {
110  // do anything here that needs to be done at desctruction time
111  // (e.g. close files, deallocate resources etc.)
112 }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 211 of file MulticoreRunLumiEventChecker.cc.

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

211  {
212  check(iEvent.id(), true);
213 }
int iEvent
Definition: GenABIO.cc:230
void check(edm::EventID const &iID, bool isEvent)
void MulticoreRunLumiEventChecker::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 237 of file MulticoreRunLumiEventChecker.cc.

237  {
238 }
void MulticoreRunLumiEventChecker::beginLuminosityBlock ( edm::LuminosityBlock const &  lumi,
edm::EventSetup const &  es 
)
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 225 of file MulticoreRunLumiEventChecker.cc.

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

225  {
226  check(edm::EventID(lumi.id().run(), lumi.id().luminosityBlock(), 0), false);
227 }
void check(edm::EventID const &iID, bool isEvent)
void MulticoreRunLumiEventChecker::beginRun ( edm::Run const &  run,
edm::EventSetup const &  es 
)
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 216 of file MulticoreRunLumiEventChecker.cc.

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

216  {
217  check(edm::EventID(run.id().run(), 0, 0), false);
218 }
void check(edm::EventID const &iID, bool isEvent)
void MulticoreRunLumiEventChecker::check ( edm::EventID const &  iID,
bool  isEvent 
)
private

Definition at line 174 of file MulticoreRunLumiEventChecker.cc.

References Exception, spr::find(), ids_, index_, messageQueue_, multiProcessSequentialEvents_, mustSearch_, and numberOfEventsLeftBeforeSearch_.

Referenced by analyze(), beginLuminosityBlock(), beginRun(), endLuminosityBlock(), and endRun().

174  {
175  if(mustSearch_) {
177  if(iIsEvent) {
179  }
180  //the event must be after the last event in our list since multicore doesn't go backwards
181  //std::vector<edm::EventID>::iterator itFind= std::find_if(ids_.begin() + index_, ids_.end(), CompareWithoutLumi(iEventID));
182  std::vector<edm::EventID>::iterator itFind= std::find(ids_.begin() + index_, ids_.end(), iEventID);
183  if(itFind == ids_.end()) {
184  throw cms::Exception("MissedEvent") << "The event " << iEventID << "is not in the list.\n";
185  }
186  index_ = itFind-ids_.begin();
187  }
188  if(iIsEvent) {
190  }
191  MsgToListener sndmsg;
192  sndmsg.id = iEventID;
193  errno = 0;
194  int value = msgsnd(messageQueue_, &sndmsg, MsgToListener::sizeForBuffer(), 0);
195  if(value != 0) {
196  throw cms::Exception("MessageFailure") << "Failed to send EventID message " << strerror(errno);
197  }
198  }
199 
200  if(index_ >= ids_.size()) {
201  throw cms::Exception("TooManyEvents") << "Was passes " << ids_.size() << " EventIDs but have processed more events than that\n";
202  }
203  if(iEventID != ids_[index_]) {
204  throw cms::Exception("WrongEvent") << "Was expecting event " << ids_[index_] << " but was given " << iEventID << "\n";
205  }
206  ++index_;
207 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
Definition: value.py:1
void MulticoreRunLumiEventChecker::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 242 of file MulticoreRunLumiEventChecker.cc.

References Exception, ids_, index_, listenerThread_, messageQueue_, mustSearch_, and seenIDs_.

242  {
243  if(mustSearch_) {
244  MsgToListener sndmsg;
245  sndmsg.id = edm::EventID();
246  errno = 0;
247  int value = msgsnd(messageQueue_,&sndmsg, MsgToListener::sizeForBuffer(),0);
248  if(value != 0) {
249  throw cms::Exception("MessageFailure")<<"Failed to send finished message "<<strerror(errno)<<"\n";
250  }
251  } else {
252  if(index_ != ids_.size()) {
253  throw cms::Exception("WrongNumberOfEvents")<<"Saw "<<index_<<" events but was supposed to see "<<ids_.size()<<"\n";
254  }
255  }
256 
257  if(listenerThread_) {
258  listenerThread_->join();
259  msgctl(messageQueue_, IPC_RMID, 0);
260 
261  std::set<edm::EventID> uniqueIDs(ids_.begin(), ids_.end());
262  if(seenIDs_.size() != uniqueIDs.size()) {
263  throw cms::Exception("WrongNumberOfEvents") << "Saw " << seenIDs_.size() << " events but was supposed to see " << ids_.size() << "\n";
264  }
265 
266  std::set<edm::EventID> duplicates;
267  for(std::map<edm::EventID, unsigned int>::iterator it = seenIDs_.begin(), itEnd = seenIDs_.end();
268  it != itEnd;
269  ++it) {
270  if(it->second > 1 && it->first.event() != 0) {
271  duplicates.insert(it->first);
272  }
273  }
274  if(duplicates.size() != 0) {
275  throw cms::Exception("DuplicateEvents") << "saw " << duplicates.size() << " events\n";
276  }
277  }
278 }
edm::propagate_const< std::shared_ptr< boost::thread > > listenerThread_
Definition: value.py:1
std::map< edm::EventID, unsigned int > seenIDs_
void MulticoreRunLumiEventChecker::endLuminosityBlock ( edm::LuminosityBlock const &  lumi,
edm::EventSetup const &  es 
)
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 230 of file MulticoreRunLumiEventChecker.cc.

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

230  {
231  check(edm::EventID(lumi.id().run(), lumi.id().luminosityBlock(), 0), false);
232 }
void check(edm::EventID const &iID, bool isEvent)
void MulticoreRunLumiEventChecker::endRun ( edm::Run const &  run,
edm::EventSetup const &  es 
)
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 220 of file MulticoreRunLumiEventChecker.cc.

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

220  {
221  check(edm::EventID(run.id().run(), 0, 0), false);
222 }
void check(edm::EventID const &iID, bool isEvent)
void MulticoreRunLumiEventChecker::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 282 of file MulticoreRunLumiEventChecker.cc.

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

282  {
284  desc.addUntracked<std::vector<edm::EventID> >("eventSequence");
285  desc.addUntracked<unsigned int>("multiProcessSequentialEvents", 0U);
286  descriptions.add("eventIDChecker", desc);
287 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void MulticoreRunLumiEventChecker::postForkReacquireResources ( unsigned int  iChildIndex,
unsigned int  iNumberOfChildren 
)
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 299 of file MulticoreRunLumiEventChecker.cc.

References DEFINE_FWK_MODULE, edm::disableAllSigs(), listenerThread_, messageQueue_, mustSearch_, edm::reenableSigs(), and seenIDs_.

299  {
300  mustSearch_ = true;
301 
302  if(0 == iChildIndex) {
303  //NOTE: must temporarily disable signals so the new thread never tries to process a signal
304  sigset_t oldset;
305  edm::disableAllSigs(&oldset);
306 
307  Listener listener(&seenIDs_, messageQueue_, iNumberOfChildren);
308  listenerThread_ = std::make_shared<boost::thread>(listener) ;
309  edm::reenableSigs(&oldset);
310  }
311 }
void disableAllSigs(sigset_t *oldset)
edm::propagate_const< std::shared_ptr< boost::thread > > listenerThread_
void reenableSigs(sigset_t *oldset)
std::map< edm::EventID, unsigned int > seenIDs_
void MulticoreRunLumiEventChecker::preForkReleaseResources ( )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 290 of file MulticoreRunLumiEventChecker.cc.

References Exception, and messageQueue_.

290  {
291  //This queue is used to communicate between children
292  messageQueue_ = msgget(IPC_PRIVATE, IPC_CREAT|0660);
293  if(-1 == messageQueue_) {
294  throw cms::Exception("FailedToCreateQueue")<<" call to 'msgget' failed to create a message queue. errno: "<<errno<<" "<<strerror(errno);
295  }
296 }

Member Data Documentation

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

Definition at line 74 of file MulticoreRunLumiEventChecker.cc.

Referenced by check(), and endJob().

unsigned int MulticoreRunLumiEventChecker::index_
private

Definition at line 75 of file MulticoreRunLumiEventChecker.cc.

Referenced by check(), and endJob().

edm::propagate_const<std::shared_ptr<boost::thread> > MulticoreRunLumiEventChecker::listenerThread_
private

Definition at line 82 of file MulticoreRunLumiEventChecker.cc.

Referenced by endJob(), and postForkReacquireResources().

int MulticoreRunLumiEventChecker::messageQueue_
private
unsigned int MulticoreRunLumiEventChecker::multiProcessSequentialEvents_
private

Definition at line 78 of file MulticoreRunLumiEventChecker.cc.

Referenced by check().

bool MulticoreRunLumiEventChecker::mustSearch_
private

Definition at line 80 of file MulticoreRunLumiEventChecker.cc.

Referenced by check(), endJob(), and postForkReacquireResources().

unsigned int MulticoreRunLumiEventChecker::numberOfEventsLeftBeforeSearch_
private

Definition at line 79 of file MulticoreRunLumiEventChecker.cc.

Referenced by check().

std::map<edm::EventID, unsigned int> MulticoreRunLumiEventChecker::seenIDs_
private

Definition at line 76 of file MulticoreRunLumiEventChecker.cc.

Referenced by endJob(), and postForkReacquireResources().