CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes
edm::service::CheckTransitions Class Reference

Public Types

enum  Phase {
  Phase::kBeginRun, Phase::kBeginLumi, Phase::kEvent, Phase::kEndLumi,
  Phase::kEndRun
}
 
enum  Transition {
  Transition::IsInvalid, Transition::IsStop, Transition::IsFile, Transition::IsRun,
  Transition::IsLumi, Transition::IsEvent
}
 

Public Member Functions

 CheckTransitions (const ParameterSet &, ActivityRegistry &)
 
void postEndJob ()
 
void preallocate (service::SystemBounds const &)
 
void preBeginJob (PathsAndConsumesOfModulesBase const &, ProcessContext const &)
 
void preCloseFile (std::string const &lfn)
 
void preEvent (StreamContext const &)
 
void preGlobalBeginLumi (GlobalContext const &)
 
void preGlobalBeginRun (GlobalContext const &)
 
void preGlobalEndLumi (GlobalContext const &)
 
void preGlobalEndRun (GlobalContext const &)
 
void preOpenFile (std::string const &)
 
void preStreamBeginLumi (StreamContext const &)
 
void preStreamBeginRun (StreamContext const &)
 
void preStreamEndLumi (StreamContext const &)
 
void preStreamEndRun (StreamContext const &)
 
 ~CheckTransitions () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

std::vector< std::pair< Transition, edm::EventID > > m_expectedTransitions
 
bool m_failed = false
 
int m_nstreams = 0
 
oneapi::tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions
 

Detailed Description

Definition at line 40 of file CheckTransitions.cc.

Member Enumeration Documentation

◆ Phase

Enumerator
kBeginRun 
kBeginLumi 
kEvent 
kEndLumi 
kEndRun 

Definition at line 42 of file CheckTransitions.cc.

42 { kBeginRun, kBeginLumi, kEvent, kEndLumi, kEndRun };

◆ Transition

Enumerator
IsInvalid 
IsStop 
IsFile 
IsRun 
IsLumi 
IsEvent 

Definition at line 44 of file CheckTransitions.cc.

44 { IsInvalid, IsStop, IsFile, IsRun, IsLumi, IsEvent };

Constructor & Destructor Documentation

◆ CheckTransitions()

CheckTransitions::CheckTransitions ( const ParameterSet iPS,
ActivityRegistry iRegistry 
)

Definition at line 191 of file CheckTransitions.cc.

References edm::ParameterSet::getUntrackedParameter(), m_expectedTransitions, AlCaHLTBitMon_ParallelJobs::p, postEndJob(), preallocate(), preCloseFile(), preEvent(), preGlobalBeginLumi(), preGlobalBeginRun(), preGlobalEndLumi(), preGlobalEndRun(), preOpenFile(), preStreamBeginLumi(), preStreamBeginRun(), preStreamEndLumi(), preStreamEndRun(), AlCaHLTBitMon_QueryRunRegistry::string, edm::ActivityRegistry::watchPostEndJob(), edm::ActivityRegistry::watchPreallocate(), edm::ActivityRegistry::watchPreCloseFile(), edm::ActivityRegistry::watchPreEvent(), edm::ActivityRegistry::watchPreGlobalBeginLumi(), edm::ActivityRegistry::watchPreGlobalBeginRun(), edm::ActivityRegistry::watchPreGlobalEndLumi(), edm::ActivityRegistry::watchPreGlobalEndRun(), edm::ActivityRegistry::watchPreOpenFile(), edm::ActivityRegistry::watchPreStreamBeginLumi(), edm::ActivityRegistry::watchPreStreamBeginRun(), edm::ActivityRegistry::watchPreStreamEndLumi(), and edm::ActivityRegistry::watchPreStreamEndRun().

191  {
192  for (auto const& p : iPS.getUntrackedParameter<std::vector<edm::ParameterSet>>("transitions")) {
193  m_expectedTransitions.emplace_back(stringToType(p.getUntrackedParameter<std::string>("type")),
194  p.getUntrackedParameter<EventID>("id"));
195  }
196 
197  iRegistry.watchPreallocate(this, &CheckTransitions::preallocate);
198 
199  iRegistry.watchPostEndJob(this, &CheckTransitions::postEndJob);
200 
201  iRegistry.watchPreOpenFile(this, &CheckTransitions::preOpenFile);
202 
203  iRegistry.watchPreCloseFile(this, &CheckTransitions::preCloseFile);
204 
205  iRegistry.watchPreGlobalBeginRun(this, &CheckTransitions::preGlobalBeginRun);
206 
207  iRegistry.watchPreGlobalEndRun(this, &CheckTransitions::preGlobalEndRun);
208 
209  iRegistry.watchPreStreamBeginRun(this, &CheckTransitions::preStreamBeginRun);
210 
211  iRegistry.watchPreStreamEndRun(this, &CheckTransitions::preStreamEndRun);
212 
213  iRegistry.watchPreGlobalBeginLumi(this, &CheckTransitions::preGlobalBeginLumi);
214 
215  iRegistry.watchPreGlobalEndLumi(this, &CheckTransitions::preGlobalEndLumi);
216 
217  iRegistry.watchPreStreamBeginLumi(this, &CheckTransitions::preStreamBeginLumi);
218 
219  iRegistry.watchPreStreamEndLumi(this, &CheckTransitions::preStreamEndLumi);
220 
221  iRegistry.watchPreEvent(this, &CheckTransitions::preEvent);
222 }
void preStreamEndLumi(StreamContext const &)
void preCloseFile(std::string const &lfn)
std::vector< std::pair< Transition, edm::EventID > > m_expectedTransitions
void preEvent(StreamContext const &)
void preStreamEndRun(StreamContext const &)
void preStreamBeginLumi(StreamContext const &)
void preGlobalEndRun(GlobalContext const &)
void preGlobalBeginRun(GlobalContext const &)
void preGlobalBeginLumi(GlobalContext const &)
void preStreamBeginRun(StreamContext const &)
void preGlobalEndLumi(GlobalContext const &)
void preallocate(service::SystemBounds const &)
void preOpenFile(std::string const &)

◆ ~CheckTransitions()

CheckTransitions::~CheckTransitions ( )
noexcept

Definition at line 224 of file CheckTransitions.cc.

References edm::errors::EventProcessorFailure, Exception, and m_failed.

224  {
225  if (m_failed) {
226  throw edm::Exception(errors::EventProcessorFailure) << "incorrect transtions";
227  }
228 }

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 230 of file CheckTransitions.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

230  {
232  desc.setComment("Checks that the transitions specified occur during the job.");
233 
235  trans.addUntracked<std::string>("type");
236  trans.addUntracked<edm::EventID>("id");
237  desc.addVPSetUntracked("transitions", trans, {{}});
238  descriptions.add("CheckTransitions", desc);
239 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ postEndJob()

void CheckTransitions::postEndJob ( )

Definition at line 243 of file CheckTransitions.cc.

References gather_cfg::cout, mps_fire::i, kBeginLumi, kEndLumi, m_expectedTransitions, m_failed, m_nstreams, m_seenTransitions, alignCSCRings::s, and jetUpdater_cfi::sort.

Referenced by CheckTransitions().

243  {
244  auto expectedV = expectedValues(m_expectedTransitions, m_nstreams);
245 
246  std::vector<std::tuple<Phase, edm::EventID, int>> orderedSeen;
247  orderedSeen.reserve(m_seenTransitions.size());
248  for (auto const& i : m_seenTransitions) {
249  // std::cout <<i.first.m_run<<" "<<i.first.m_lumi<<" "<<i.first.m_event<<" "<<i.second<<std::endl;
250  auto s = std::get<2>(i);
251  if (std::get<1>(i).event() > 0) {
252  s = -2;
253  }
254  orderedSeen.emplace_back(std::get<0>(i), std::get<1>(i), s);
255  }
256  std::sort(orderedSeen.begin(), orderedSeen.end());
257 
258  auto orderedExpected = expectedV;
259  std::sort(orderedExpected.begin(), orderedExpected.end());
260  /* for(auto const& i: expectedV) {
261  std::cout <<i.first.m_run<<" "<<i.first.m_lumi<<" "<<i.first.m_event<<" "<<i.second<<std::endl;
262  } */
263 
264  unsigned int nSkippedStreamLumiTransitions = 0;
265 
266  // Use the next two vectors to test that skipped stream lumi transitions
267  // come in matched begin and end pairs.
268  std::vector<std::tuple<Phase, edm::EventID, int>> expectedSkippedStreamEndLumi;
269  std::vector<std::tuple<Phase, edm::EventID, int>> seenSkippedStreamEndLumi;
270 
271  // Use the next two sets to test that for every global begin lumi there
272  // is at least one stream begin lumi, even when some stream begin lumi
273  // transitions are skipped.
274  std::set<std::tuple<Phase, edm::EventID, int>> seenGlobalBeginLumi;
275  std::set<std::tuple<Phase, edm::EventID, int>> seenStreamBeginLumi;
276 
277  auto itOS = orderedSeen.begin();
278  for (auto itOE = orderedExpected.begin(); itOE != orderedExpected.end(); ++itOE) {
279  if (itOS == orderedSeen.end()) {
280  break;
281  }
282 
283  if (std::get<0>(*itOS) == Phase::kBeginLumi && std::get<2>(*itOS) == -1) {
284  seenGlobalBeginLumi.emplace(*itOS);
285  }
286  if (std::get<0>(*itOS) == Phase::kBeginLumi && (std::get<2>(*itOS) > -1 && std::get<2>(*itOS) < 1000)) {
287  // Note that the third field is falsely filled with the value for a global begin lumi to
288  // make a comparison with seenGlobalBeginLumi easier.
289  seenStreamBeginLumi.emplace(std::get<0>(*itOS), std::get<1>(*itOS), -1);
290  }
291 
292  while (*itOE != *itOS && (std::get<0>(*itOE) == Phase::kBeginLumi || std::get<0>(*itOE) == Phase::kEndLumi) &&
293  (std::get<2>(*itOE) > -1 && std::get<2>(*itOE) < 1000)) {
294  ++nSkippedStreamLumiTransitions;
295  if (std::get<0>(*itOE) == Phase::kBeginLumi) {
296  expectedSkippedStreamEndLumi.emplace_back(Phase::kEndLumi, std::get<1>(*itOE), std::get<2>(*itOE));
297  } else {
298  seenSkippedStreamEndLumi.emplace_back(*itOE);
299  }
300 
301  ++itOE;
302  }
303  if (*itOE != *itOS) {
304  auto syncOE = std::get<1>(*itOE);
305  auto syncOS = std::get<1>(*itOS);
306  std::cout << "Different ordering " << syncOE << " " << std::get<2>(*itOE) << "\n"
307  << " " << syncOS << " " << std::get<2>(*itOS) << "\n";
308  m_failed = true;
309  }
310  ++itOS;
311  }
312 
313  if (seenGlobalBeginLumi != seenStreamBeginLumi) {
314  std::cout << "We didn't see at least one stream begin lumi for every global begin lumi" << std::endl;
315  m_failed = true;
316  }
317 
318  if (expectedSkippedStreamEndLumi != seenSkippedStreamEndLumi) {
319  std::cout << "Skipped stream begin and end lumi transitions do not match" << std::endl;
320  m_failed = true;
321  }
322 
323  if (orderedSeen.size() + nSkippedStreamLumiTransitions != orderedExpected.size()) {
324  std::cout << "Wrong number of transition " << orderedSeen.size() << " " << orderedExpected.size() << std::endl;
325  m_failed = true;
326  return;
327  }
328 }
std::vector< std::pair< Transition, edm::EventID > > m_expectedTransitions
oneapi::tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions

◆ preallocate()

void CheckTransitions::preallocate ( service::SystemBounds const &  bounds)

Definition at line 241 of file CheckTransitions.cc.

References m_nstreams.

Referenced by CheckTransitions().

241 { m_nstreams = bounds.maxNumberOfStreams(); }

◆ preBeginJob()

void edm::service::CheckTransitions::preBeginJob ( PathsAndConsumesOfModulesBase const &  ,
ProcessContext const &   
)

◆ preCloseFile()

void CheckTransitions::preCloseFile ( std::string const &  lfn)

Definition at line 332 of file CheckTransitions.cc.

Referenced by CheckTransitions().

332 {}

◆ preEvent()

void CheckTransitions::preEvent ( StreamContext const &  sc)

Definition at line 370 of file CheckTransitions.cc.

References edm::StreamContext::eventID(), kEvent, m_seenTransitions, and edm::StreamContext::streamID().

Referenced by CheckTransitions().

370  {
371  m_seenTransitions.emplace_back(Phase::kEvent, sc.eventID(), sc.streamID());
372 }
oneapi::tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions

◆ preGlobalBeginLumi()

void CheckTransitions::preGlobalBeginLumi ( GlobalContext const &  gc)

Definition at line 352 of file CheckTransitions.cc.

References kBeginLumi, edm::GlobalContext::luminosityBlockID(), m_seenTransitions, and edm::EventID::run().

Referenced by CheckTransitions().

352  {
353  auto id = gc.luminosityBlockID();
354  m_seenTransitions.emplace_back(Phase::kBeginLumi, edm::EventID{id.run(), id.luminosityBlock(), 0}, -1);
355 }
RunNumber_t run() const
Definition: EventID.h:38
oneapi::tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions

◆ preGlobalBeginRun()

void CheckTransitions::preGlobalBeginRun ( GlobalContext const &  gc)

Definition at line 334 of file CheckTransitions.cc.

References kBeginRun, edm::GlobalContext::luminosityBlockID(), m_seenTransitions, and edm::EventID::run().

Referenced by CheckTransitions().

334  {
335  auto id = gc.luminosityBlockID();
336  m_seenTransitions.emplace_back(Phase::kBeginRun, edm::EventID{id.run(), 0, 0}, -1);
337 }
RunNumber_t run() const
Definition: EventID.h:38
oneapi::tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions

◆ preGlobalEndLumi()

void CheckTransitions::preGlobalEndLumi ( GlobalContext const &  gc)

Definition at line 357 of file CheckTransitions.cc.

References kEndLumi, edm::GlobalContext::luminosityBlockID(), m_seenTransitions, and edm::EventID::run().

Referenced by CheckTransitions().

357  {
358  auto id = gc.luminosityBlockID();
359  m_seenTransitions.emplace_back(Phase::kEndLumi, edm::EventID{id.run(), id.luminosityBlock(), 0}, 1000);
360 }
RunNumber_t run() const
Definition: EventID.h:38
oneapi::tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions

◆ preGlobalEndRun()

void CheckTransitions::preGlobalEndRun ( GlobalContext const &  gc)

Definition at line 339 of file CheckTransitions.cc.

References kEndRun, edm::GlobalContext::luminosityBlockID(), m_seenTransitions, and edm::EventID::run().

Referenced by CheckTransitions().

339  {
340  auto id = gc.luminosityBlockID();
341  m_seenTransitions.emplace_back(Phase::kEndRun, edm::EventID{id.run(), 0, 0}, 1000);
342 }
RunNumber_t run() const
Definition: EventID.h:38
oneapi::tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions

◆ preOpenFile()

void CheckTransitions::preOpenFile ( std::string const &  lfn)

Definition at line 330 of file CheckTransitions.cc.

Referenced by CheckTransitions().

330 {}

◆ preStreamBeginLumi()

void CheckTransitions::preStreamBeginLumi ( StreamContext const &  sc)

Definition at line 362 of file CheckTransitions.cc.

References edm::StreamContext::eventID(), kBeginLumi, m_seenTransitions, and edm::StreamContext::streamID().

Referenced by CheckTransitions().

362  {
363  m_seenTransitions.emplace_back(Phase::kBeginLumi, sc.eventID(), sc.streamID());
364 }
oneapi::tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions

◆ preStreamBeginRun()

void CheckTransitions::preStreamBeginRun ( StreamContext const &  sc)

Definition at line 344 of file CheckTransitions.cc.

References edm::StreamContext::eventID(), kBeginRun, m_seenTransitions, and edm::StreamContext::streamID().

Referenced by CheckTransitions().

344  {
345  m_seenTransitions.emplace_back(Phase::kBeginRun, sc.eventID(), sc.streamID());
346 }
oneapi::tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions

◆ preStreamEndLumi()

void CheckTransitions::preStreamEndLumi ( StreamContext const &  sc)

Definition at line 366 of file CheckTransitions.cc.

References edm::StreamContext::eventID(), kEndLumi, m_seenTransitions, and edm::StreamContext::streamID().

Referenced by CheckTransitions().

366  {
367  m_seenTransitions.emplace_back(Phase::kEndLumi, sc.eventID(), sc.streamID());
368 }
oneapi::tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions

◆ preStreamEndRun()

void CheckTransitions::preStreamEndRun ( StreamContext const &  sc)

Definition at line 348 of file CheckTransitions.cc.

References edm::StreamContext::eventID(), kEndRun, m_seenTransitions, and edm::StreamContext::streamID().

Referenced by CheckTransitions().

348  {
349  m_seenTransitions.emplace_back(Phase::kEndRun, sc.eventID(), sc.streamID());
350 }
oneapi::tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions

Member Data Documentation

◆ m_expectedTransitions

std::vector<std::pair<Transition, edm::EventID> > edm::service::CheckTransitions::m_expectedTransitions
private

Definition at line 80 of file CheckTransitions.cc.

Referenced by CheckTransitions(), and postEndJob().

◆ m_failed

bool edm::service::CheckTransitions::m_failed = false
private

Definition at line 82 of file CheckTransitions.cc.

Referenced by postEndJob(), and ~CheckTransitions().

◆ m_nstreams

int edm::service::CheckTransitions::m_nstreams = 0
private

Definition at line 81 of file CheckTransitions.cc.

Referenced by postEndJob(), and preallocate().

◆ m_seenTransitions

oneapi::tbb::concurrent_vector<std::tuple<Phase, edm::EventID, int> > edm::service::CheckTransitions::m_seenTransitions
private