#include <FWCore/Modules/src/MulticoreRunLumiEventChecker.cc>
Public Member Functions | |
MulticoreRunLumiEventChecker (edm::ParameterSet const &) | |
~MulticoreRunLumiEventChecker () | |
Static Public Member Functions | |
static void | fillDescriptions (edm::ConfigurationDescriptions &descriptions) |
Private Member Functions | |
virtual void | analyze (edm::Event const &, edm::EventSetup const &) |
virtual void | beginJob () |
virtual void | beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &es) |
virtual void | beginRun (edm::Run const &run, edm::EventSetup const &es) |
void | check (const edm::EventID &iID, bool isEvent) |
virtual void | endJob () |
virtual void | endLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &es) |
virtual void | endRun (edm::Run const &run, edm::EventSetup const &es) |
virtual void | postForkReacquireResources (unsigned int iChildIndex, unsigned int iNumberOfChildren) |
Private Attributes | |
std::vector< edm::EventID > | ids_ |
unsigned int | index_ |
boost::shared_ptr< boost::thread > | listenerThread_ |
int | messageQueue_ |
unsigned int | multiProcessSequentialEvents_ |
bool | mustSearch_ |
unsigned int | numberOfEventsLeftBeforeSearch_ |
std::map< edm::EventID, unsigned int > | seenIDs_ |
Description: Checks that the events passed to it come in the order specified in its configuration
Implementation: <Notes on="" implementation>="">
Definition at line 55 of file MulticoreRunLumiEventChecker.cc.
MulticoreRunLumiEventChecker::MulticoreRunLumiEventChecker | ( | edm::ParameterSet const & | iConfig | ) | [explicit] |
Definition at line 100 of file MulticoreRunLumiEventChecker.cc.
References messageQueue_.
: ids_(iConfig.getUntrackedParameter<std::vector<edm::EventID> >("eventSequence")), index_(0), multiProcessSequentialEvents_(iConfig.getUntrackedParameter<unsigned int>("multiProcessSequentialEvents")), numberOfEventsLeftBeforeSearch_(0), mustSearch_(false), messageQueue_(-1) { //now do what ever initialization is needed messageQueue_ = msgget(IPC_PRIVATE, IPC_CREAT|0660); }
MulticoreRunLumiEventChecker::~MulticoreRunLumiEventChecker | ( | ) |
Definition at line 113 of file MulticoreRunLumiEventChecker.cc.
{ // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) }
void MulticoreRunLumiEventChecker::analyze | ( | edm::Event const & | iEvent, |
edm::EventSetup const & | iSetup | ||
) | [private, virtual] |
Implements edm::EDAnalyzer.
Definition at line 219 of file MulticoreRunLumiEventChecker.cc.
References check(), and edm::EventBase::id().
void MulticoreRunLumiEventChecker::beginJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 245 of file MulticoreRunLumiEventChecker.cc.
{ }
void MulticoreRunLumiEventChecker::beginLuminosityBlock | ( | edm::LuminosityBlock const & | lumi, |
edm::EventSetup const & | es | ||
) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 233 of file MulticoreRunLumiEventChecker.cc.
References check(), and edm::LuminosityBlockBase::id().
{ check(edm::EventID(lumi.id().run(),lumi.id().luminosityBlock(),0),false); }
void MulticoreRunLumiEventChecker::beginRun | ( | edm::Run const & | run, |
edm::EventSetup const & | es | ||
) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 224 of file MulticoreRunLumiEventChecker.cc.
References check(), and edm::RunBase::id().
{ check(edm::EventID(run.id().run(),0,0),false); }
void MulticoreRunLumiEventChecker::check | ( | const edm::EventID & | iID, |
bool | isEvent | ||
) | [private] |
Definition at line 182 of file MulticoreRunLumiEventChecker.cc.
References Exception, spr::find(), ids_, index_, messageQueue_, multiProcessSequentialEvents_, mustSearch_, numberOfEventsLeftBeforeSearch_, and relativeConstraints::value.
Referenced by analyze(), beginLuminosityBlock(), beginRun(), endLuminosityBlock(), and endRun().
{ if(mustSearch_) { if( 0 == numberOfEventsLeftBeforeSearch_) { if(iIsEvent) { numberOfEventsLeftBeforeSearch_ = multiProcessSequentialEvents_; } //the event must be after the last event in our list since multicore doesn't go backwards //std::vector<edm::EventID>::iterator itFind= std::find_if(ids_.begin()+index_,ids_.end(), CompareWithoutLumi(iEventID)); std::vector<edm::EventID>::iterator itFind= std::find(ids_.begin()+index_,ids_.end(), iEventID); if(itFind == ids_.end()) { throw cms::Exception("MissedEvent") << "The event " << iEventID << "is not in the list.\n"; } index_ = itFind-ids_.begin(); } if(iIsEvent) { --numberOfEventsLeftBeforeSearch_; } MsgToListener sndmsg; sndmsg.id = iEventID; errno = 0; int value = msgsnd(messageQueue_,&sndmsg, MsgToListener::sizeForBuffer(),0); if(value != 0) { throw cms::Exception("MessageFailure")<<"Failed to send EventID message "<<strerror(errno); } } if(index_ >= ids_.size()) { throw cms::Exception("TooManyEvents")<<"Was passes "<<ids_.size()<<" EventIDs but have processed more events than that\n"; } if(iEventID != ids_[index_]) { throw cms::Exception("WrongEvent") << "Was expecting event " << ids_[index_] << " but was given " << iEventID << "\n"; } ++index_; }
void MulticoreRunLumiEventChecker::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 250 of file MulticoreRunLumiEventChecker.cc.
References Exception, ids_, listenerThread_, messageQueue_, seenIDs_, and relativeConstraints::value.
{ MsgToListener sndmsg; sndmsg.id = edm::EventID(); errno = 0; int value = msgsnd(messageQueue_,&sndmsg, MsgToListener::sizeForBuffer(),0); if(value != 0) { throw cms::Exception("MessageFailure")<<"Failed to send finished message "<<strerror(errno)<<"\n"; } if(listenerThread_) { listenerThread_->join(); msgctl(messageQueue_, IPC_RMID,0); std::set<edm::EventID> uniqueIDs(ids_.begin(),ids_.end()); if(seenIDs_.size() != uniqueIDs.size()) { throw cms::Exception("WrongNumberOfEvents")<<"Saw "<<seenIDs_.size()<<" events but was supposed to see "<<ids_.size()<<"\n"; } std::set<edm::EventID> duplicates; for(std::map<edm::EventID,unsigned int>::iterator it = seenIDs_.begin(), itEnd = seenIDs_.end(); it != itEnd; ++it) { if (it->second > 1 && it->first.event() != 0) { duplicates.insert(it->first); } } if(duplicates.size() != 0 ) { throw cms::Exception("DuplicateEvents")<<"saw "<<duplicates.size()<<" events\n"; } } }
void MulticoreRunLumiEventChecker::endLuminosityBlock | ( | edm::LuminosityBlock const & | lumi, |
edm::EventSetup const & | es | ||
) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 238 of file MulticoreRunLumiEventChecker.cc.
References check(), and edm::LuminosityBlockBase::id().
{ check(edm::EventID(lumi.id().run(),lumi.id().luminosityBlock(),0),false); }
void MulticoreRunLumiEventChecker::endRun | ( | edm::Run const & | run, |
edm::EventSetup const & | es | ||
) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 228 of file MulticoreRunLumiEventChecker.cc.
References check(), and edm::RunBase::id().
{ check(edm::EventID(run.id().run(),0,0),false); }
void MulticoreRunLumiEventChecker::fillDescriptions | ( | edm::ConfigurationDescriptions & | descriptions | ) | [static] |
Reimplemented from edm::EDAnalyzer.
Definition at line 284 of file MulticoreRunLumiEventChecker.cc.
References edm::ConfigurationDescriptions::add(), and edm::ParameterSetDescription::addUntracked().
{ edm::ParameterSetDescription desc; desc.addUntracked<std::vector<edm::EventID> >("eventSequence"); desc.addUntracked<unsigned int>("multiProcessSequentialEvents", 0U); descriptions.add("eventIDChecker", desc); }
void MulticoreRunLumiEventChecker::postForkReacquireResources | ( | unsigned int | iChildIndex, |
unsigned int | iNumberOfChildren | ||
) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 292 of file MulticoreRunLumiEventChecker.cc.
References edm::disableAllSigs(), listenerThread_, messageQueue_, mustSearch_, edm::reenableSigs(), and seenIDs_.
{ mustSearch_ = true; if (0 == iChildIndex) { //NOTE: must temporarily disable signals so the new thread never tries to process a signal sigset_t oldset; edm::disableAllSigs(&oldset); Listener listener(&seenIDs_,messageQueue_, iNumberOfChildren); listenerThread_ = boost::shared_ptr<boost::thread>( new boost::thread(listener)) ; edm::reenableSigs(&oldset); } }
std::vector<edm::EventID> MulticoreRunLumiEventChecker::ids_ [private] |
Definition at line 77 of file MulticoreRunLumiEventChecker.cc.
unsigned int MulticoreRunLumiEventChecker::index_ [private] |
Definition at line 78 of file MulticoreRunLumiEventChecker.cc.
Referenced by check().
boost::shared_ptr<boost::thread> MulticoreRunLumiEventChecker::listenerThread_ [private] |
Definition at line 85 of file MulticoreRunLumiEventChecker.cc.
Referenced by endJob(), and postForkReacquireResources().
int MulticoreRunLumiEventChecker::messageQueue_ [private] |
Definition at line 86 of file MulticoreRunLumiEventChecker.cc.
Referenced by check(), endJob(), MulticoreRunLumiEventChecker(), and postForkReacquireResources().
unsigned int MulticoreRunLumiEventChecker::multiProcessSequentialEvents_ [private] |
Definition at line 81 of file MulticoreRunLumiEventChecker.cc.
Referenced by check().
bool MulticoreRunLumiEventChecker::mustSearch_ [private] |
Definition at line 83 of file MulticoreRunLumiEventChecker.cc.
Referenced by check(), and postForkReacquireResources().
unsigned int MulticoreRunLumiEventChecker::numberOfEventsLeftBeforeSearch_ [private] |
Definition at line 82 of file MulticoreRunLumiEventChecker.cc.
Referenced by check().
std::map<edm::EventID,unsigned int> MulticoreRunLumiEventChecker::seenIDs_ [private] |
Definition at line 79 of file MulticoreRunLumiEventChecker.cc.
Referenced by endJob(), and postForkReacquireResources().