CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

Public Member Functions

 MulticoreRunLumiEventChecker (edm::ParameterSet const &)
 
 ~MulticoreRunLumiEventChecker ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

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 &)
 
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 (edm::EventID const &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)
 
virtual void preForkReleaseResources ()
 

Private Attributes

std::vector< edm::EventIDids_
 
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_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

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 53 of file MulticoreRunLumiEventChecker.cc.

Constructor & Destructor Documentation

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

Definition at line 98 of file MulticoreRunLumiEventChecker.cc.

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

Definition at line 110 of file MulticoreRunLumiEventChecker.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 212 of file MulticoreRunLumiEventChecker.cc.

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 238 of file MulticoreRunLumiEventChecker.cc.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 226 of file MulticoreRunLumiEventChecker.cc.

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

226  {
227  check(edm::EventID(lumi.id().run(), lumi.id().luminosityBlock(), 0), false);
228 }
tuple lumi
Definition: fjr2json.py:35
void check(edm::EventID const &iID, bool isEvent)
void MulticoreRunLumiEventChecker::beginRun ( edm::Run const &  run,
edm::EventSetup const &  es 
)
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 217 of file MulticoreRunLumiEventChecker.cc.

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

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

Definition at line 175 of file MulticoreRunLumiEventChecker.cc.

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

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 243 of file MulticoreRunLumiEventChecker.cc.

References edm::hlt::Exception, ids_, index_, listenerThread_, messageQueue_, mustSearch_, seenIDs_, and relativeConstraints::value.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 231 of file MulticoreRunLumiEventChecker.cc.

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

231  {
232  check(edm::EventID(lumi.id().run(), lumi.id().luminosityBlock(), 0), false);
233 }
tuple lumi
Definition: fjr2json.py:35
void check(edm::EventID const &iID, bool isEvent)
void MulticoreRunLumiEventChecker::endRun ( edm::Run const &  run,
edm::EventSetup const &  es 
)
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 221 of file MulticoreRunLumiEventChecker.cc.

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

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

Definition at line 283 of file MulticoreRunLumiEventChecker.cc.

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

283  {
285  desc.addUntracked<std::vector<edm::EventID> >("eventSequence");
286  desc.addUntracked<unsigned int>("multiProcessSequentialEvents", 0U);
287  descriptions.add("eventIDChecker", desc);
288 }
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 
)
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 300 of file MulticoreRunLumiEventChecker.cc.

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 291 of file MulticoreRunLumiEventChecker.cc.

References edm::hlt::Exception, and messageQueue_.

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

Member Data Documentation

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

Definition at line 75 of file MulticoreRunLumiEventChecker.cc.

Referenced by check(), and endJob().

unsigned int MulticoreRunLumiEventChecker::index_
private

Definition at line 76 of file MulticoreRunLumiEventChecker.cc.

Referenced by check(), and endJob().

boost::shared_ptr<boost::thread> MulticoreRunLumiEventChecker::listenerThread_
private

Definition at line 83 of file MulticoreRunLumiEventChecker.cc.

Referenced by endJob(), and postForkReacquireResources().

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

Definition at line 79 of file MulticoreRunLumiEventChecker.cc.

Referenced by check().

bool MulticoreRunLumiEventChecker::mustSearch_
private

Definition at line 81 of file MulticoreRunLumiEventChecker.cc.

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

unsigned int MulticoreRunLumiEventChecker::numberOfEventsLeftBeforeSearch_
private

Definition at line 80 of file MulticoreRunLumiEventChecker.cc.

Referenced by check().

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

Definition at line 77 of file MulticoreRunLumiEventChecker.cc.

Referenced by endJob(), and postForkReacquireResources().