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 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
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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

Constructor & Destructor Documentation

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

Definition at line 96 of file MulticoreRunLumiEventChecker.cc.

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

Definition at line 108 of file MulticoreRunLumiEventChecker.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 210 of file MulticoreRunLumiEventChecker.cc.

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

210  {
211  check(iEvent.id(), true);
212 }
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 236 of file MulticoreRunLumiEventChecker.cc.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 224 of file MulticoreRunLumiEventChecker.cc.

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

224  {
225  check(edm::EventID(lumi.id().run(), lumi.id().luminosityBlock(), 0), false);
226 }
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 
)
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 215 of file MulticoreRunLumiEventChecker.cc.

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

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

Definition at line 173 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().

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

Reimplemented from edm::EDAnalyzer.

Definition at line 241 of file MulticoreRunLumiEventChecker.cc.

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

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

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

229  {
230  check(edm::EventID(lumi.id().run(), lumi.id().luminosityBlock(), 0), false);
231 }
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 
)
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 219 of file MulticoreRunLumiEventChecker.cc.

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

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

Definition at line 281 of file MulticoreRunLumiEventChecker.cc.

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

281  {
283  desc.addUntracked<std::vector<edm::EventID> >("eventSequence");
284  desc.addUntracked<unsigned int>("multiProcessSequentialEvents", 0U);
285  descriptions.add("eventIDChecker", desc);
286 }
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 298 of file MulticoreRunLumiEventChecker.cc.

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 289 of file MulticoreRunLumiEventChecker.cc.

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

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

Member Data Documentation

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

Definition at line 73 of file MulticoreRunLumiEventChecker.cc.

Referenced by check(), and endJob().

unsigned int MulticoreRunLumiEventChecker::index_
private

Definition at line 74 of file MulticoreRunLumiEventChecker.cc.

Referenced by check(), and endJob().

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

Definition at line 81 of file MulticoreRunLumiEventChecker.cc.

Referenced by endJob(), and postForkReacquireResources().

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

Definition at line 77 of file MulticoreRunLumiEventChecker.cc.

Referenced by check().

bool MulticoreRunLumiEventChecker::mustSearch_
private

Definition at line 79 of file MulticoreRunLumiEventChecker.cc.

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

unsigned int MulticoreRunLumiEventChecker::numberOfEventsLeftBeforeSearch_
private

Definition at line 78 of file MulticoreRunLumiEventChecker.cc.

Referenced by check().

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

Definition at line 75 of file MulticoreRunLumiEventChecker.cc.

Referenced by endJob(), and postForkReacquireResources().