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, bool primary)
 
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 &, bool)
 
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
 
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.

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 }

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().

◆ ~CheckTransitions()

CheckTransitions::~CheckTransitions ( )
noexcept

Definition at line 224 of file CheckTransitions.cc.

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

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

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 230 of file CheckTransitions.cc.

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 }

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

◆ postEndJob()

void CheckTransitions::postEndJob ( )

Definition at line 243 of file CheckTransitions.cc.

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  auto itOS = orderedSeen.begin();
265  for (auto itOE = orderedExpected.begin(); itOE != orderedExpected.end(); ++itOE) {
266  if (itOS == orderedSeen.end()) {
267  break;
268  }
269  if (*itOE != *itOS) {
270  auto syncOE = std::get<1>(*itOE);
271  auto syncOS = std::get<1>(*itOS);
272  std::cout << "Different ordering " << syncOE << " " << std::get<2>(*itOE) << "\n"
273  << " " << syncOS << " " << std::get<2>(*itOS) << "\n";
274  m_failed = true;
275  }
276  ++itOS;
277  }
278 
279  if (orderedSeen.size() != orderedExpected.size()) {
280  std::cout << "Wrong number of transition " << orderedSeen.size() << " " << orderedExpected.size() << std::endl;
281  m_failed = true;
282  return;
283  }
284 }

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

Referenced by CheckTransitions().

◆ preallocate()

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

Definition at line 241 of file CheckTransitions.cc.

241 { m_nstreams = bounds.maxNumberOfStreams(); }

References m_nstreams, and edm::service::SystemBounds::maxNumberOfStreams().

Referenced by CheckTransitions().

◆ preBeginJob()

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

◆ preCloseFile()

void CheckTransitions::preCloseFile ( std::string const &  lfn,
bool  primary 
)

Definition at line 288 of file CheckTransitions.cc.

288 {}

Referenced by CheckTransitions().

◆ preEvent()

void CheckTransitions::preEvent ( StreamContext const &  sc)

Definition at line 326 of file CheckTransitions.cc.

326  {
327  m_seenTransitions.emplace_back(Phase::kEvent, sc.eventID(), sc.streamID());
328 }

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

Referenced by CheckTransitions().

◆ preGlobalBeginLumi()

void CheckTransitions::preGlobalBeginLumi ( GlobalContext const &  gc)

Definition at line 308 of file CheckTransitions.cc.

308  {
309  auto id = gc.luminosityBlockID();
310  m_seenTransitions.emplace_back(Phase::kBeginLumi, edm::EventID{id.run(), id.luminosityBlock(), 0}, -1);
311 }

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

Referenced by CheckTransitions().

◆ preGlobalBeginRun()

void CheckTransitions::preGlobalBeginRun ( GlobalContext const &  gc)

Definition at line 290 of file CheckTransitions.cc.

290  {
291  auto id = gc.luminosityBlockID();
292  m_seenTransitions.emplace_back(Phase::kBeginRun, edm::EventID{id.run(), 0, 0}, -1);
293 }

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

Referenced by CheckTransitions().

◆ preGlobalEndLumi()

void CheckTransitions::preGlobalEndLumi ( GlobalContext const &  gc)

Definition at line 313 of file CheckTransitions.cc.

313  {
314  auto id = gc.luminosityBlockID();
315  m_seenTransitions.emplace_back(Phase::kEndLumi, edm::EventID{id.run(), id.luminosityBlock(), 0}, 1000);
316 }

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

Referenced by CheckTransitions().

◆ preGlobalEndRun()

void CheckTransitions::preGlobalEndRun ( GlobalContext const &  gc)

Definition at line 295 of file CheckTransitions.cc.

295  {
296  auto id = gc.luminosityBlockID();
297  m_seenTransitions.emplace_back(Phase::kEndRun, edm::EventID{id.run(), 0, 0}, 1000);
298 }

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

Referenced by CheckTransitions().

◆ preOpenFile()

void CheckTransitions::preOpenFile ( std::string const &  lfn,
bool  b 
)

Definition at line 286 of file CheckTransitions.cc.

286 {}

Referenced by CheckTransitions().

◆ preStreamBeginLumi()

void CheckTransitions::preStreamBeginLumi ( StreamContext const &  sc)

Definition at line 318 of file CheckTransitions.cc.

318  {
319  m_seenTransitions.emplace_back(Phase::kBeginLumi, sc.eventID(), sc.streamID());
320 }

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

Referenced by CheckTransitions().

◆ preStreamBeginRun()

void CheckTransitions::preStreamBeginRun ( StreamContext const &  sc)

Definition at line 300 of file CheckTransitions.cc.

300  {
301  m_seenTransitions.emplace_back(Phase::kBeginRun, sc.eventID(), sc.streamID());
302 }

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

Referenced by CheckTransitions().

◆ preStreamEndLumi()

void CheckTransitions::preStreamEndLumi ( StreamContext const &  sc)

Definition at line 322 of file CheckTransitions.cc.

322  {
323  m_seenTransitions.emplace_back(Phase::kEndLumi, sc.eventID(), sc.streamID());
324 }

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

Referenced by CheckTransitions().

◆ preStreamEndRun()

void CheckTransitions::preStreamEndRun ( StreamContext const &  sc)

Definition at line 304 of file CheckTransitions.cc.

304  {
305  m_seenTransitions.emplace_back(Phase::kEndRun, sc.eventID(), sc.streamID());
306 }

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

Referenced by CheckTransitions().

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

tbb::concurrent_vector<std::tuple<Phase, edm::EventID, int> > edm::service::CheckTransitions::m_seenTransitions
private
mps_fire.i
i
Definition: mps_fire.py:428
edm::service::CheckTransitions::m_nstreams
int m_nstreams
Definition: CheckTransitions.cc:81
edm::service::CheckTransitions::preGlobalEndLumi
void preGlobalEndLumi(GlobalContext const &)
Definition: CheckTransitions.cc:313
edm::service::CheckTransitions::preStreamBeginLumi
void preStreamBeginLumi(StreamContext const &)
Definition: CheckTransitions.cc:318
edm::service::CheckTransitions::preGlobalBeginLumi
void preGlobalBeginLumi(GlobalContext const &)
Definition: CheckTransitions.cc:308
edm::service::CheckTransitions::Phase::kEndRun
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::service::CheckTransitions::preGlobalBeginRun
void preGlobalBeginRun(GlobalContext const &)
Definition: CheckTransitions.cc:290
edm::service::CheckTransitions::preallocate
void preallocate(service::SystemBounds const &)
Definition: CheckTransitions.cc:241
edm::service::CheckTransitions::m_failed
bool m_failed
Definition: CheckTransitions.cc:82
edm::service::CheckTransitions::preCloseFile
void preCloseFile(std::string const &lfn, bool primary)
Definition: CheckTransitions.cc:288
edm::service::CheckTransitions::preGlobalEndRun
void preGlobalEndRun(GlobalContext const &)
Definition: CheckTransitions.cc:295
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::service::CheckTransitions::Phase::kEvent
edm::service::CheckTransitions::preStreamBeginRun
void preStreamBeginRun(StreamContext const &)
Definition: CheckTransitions.cc:300
edm::EventID::run
RunNumber_t run() const
Definition: EventID.h:38
edm::service::CheckTransitions::preOpenFile
void preOpenFile(std::string const &, bool)
Definition: CheckTransitions.cc:286
edm::errors::EventProcessorFailure
Definition: EDMException.h:46
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
edmPickEvents.event
event
Definition: edmPickEvents.py:273
edm::service::CheckTransitions::preStreamEndLumi
void preStreamEndLumi(StreamContext const &)
Definition: CheckTransitions.cc:322
edm::service::CheckTransitions::Phase::kBeginRun
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::service::CheckTransitions::preStreamEndRun
void preStreamEndRun(StreamContext const &)
Definition: CheckTransitions.cc:304
edm::service::CheckTransitions::m_seenTransitions
tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions
Definition: CheckTransitions.cc:79
edm::service::CheckTransitions::Phase::kEndLumi
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
Exception
Definition: hltDiff.cc:245
edm::service::CheckTransitions::postEndJob
void postEndJob()
Definition: CheckTransitions.cc:243
ParameterSetDescription
edm::service::CheckTransitions::Phase::kBeginLumi
edm::EventID
Definition: EventID.h:31
edm::service::CheckTransitions::m_expectedTransitions
std::vector< std::pair< Transition, edm::EventID > > m_expectedTransitions
Definition: CheckTransitions.cc:80
edm::service::CheckTransitions::preEvent
void preEvent(StreamContext const &)
Definition: CheckTransitions.cc:326