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

Enumerator
kBeginRun 
kBeginLumi 
kEvent 
kEndLumi 
kEndRun 

Definition at line 42 of file CheckTransitions.cc.

42 { kBeginRun, kBeginLumi, kEvent, kEndLumi, kEndRun };
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 ( const ParameterSet ,
ActivityRegistry  
)

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 &)
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 preOpenFile(std::string const &, bool)
void preStreamBeginRun(StreamContext const &)
void preGlobalEndLumi(GlobalContext const &)
void preallocate(service::SystemBounds const &)
void preCloseFile(std::string const &lfn, bool primary)
CheckTransitions::~CheckTransitions ( )

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

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

Definition at line 230 of file CheckTransitions.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), edm::ParameterSetDescription::addVPSetUntracked(), edm::ParameterSetDescription::setComment(), 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)
void CheckTransitions::postEndJob ( )

Definition at line 243 of file CheckTransitions.cc.

References gather_cfg::cout, mps_fire::i, 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  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 }
std::vector< std::pair< Transition, edm::EventID > > m_expectedTransitions
tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions
void CheckTransitions::preallocate ( service::SystemBounds const &  bounds)

Definition at line 241 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

241 { m_nstreams = bounds.maxNumberOfStreams(); }
void edm::service::CheckTransitions::preBeginJob ( PathsAndConsumesOfModulesBase const &  ,
ProcessContext const &   
)
void CheckTransitions::preCloseFile ( std::string const &  lfn,
bool  primary 
)

Definition at line 288 of file CheckTransitions.cc.

Referenced by CheckTransitions().

288 {}
void CheckTransitions::preEvent ( StreamContext const &  sc)

Definition at line 326 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

326  {
327  m_seenTransitions.emplace_back(Phase::kEvent, sc.eventID(), sc.streamID());
328 }
tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions
void CheckTransitions::preGlobalBeginLumi ( GlobalContext const &  gc)

Definition at line 308 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

308  {
309  auto id = gc.luminosityBlockID();
310  m_seenTransitions.emplace_back(Phase::kBeginLumi, edm::EventID{id.run(), id.luminosityBlock(), 0}, -1);
311 }
RunNumber_t run() const
Definition: EventID.h:39
tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions
void CheckTransitions::preGlobalBeginRun ( GlobalContext const &  gc)

Definition at line 290 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

290  {
291  auto id = gc.luminosityBlockID();
292  m_seenTransitions.emplace_back(Phase::kBeginRun, edm::EventID{id.run(), 0, 0}, -1);
293 }
RunNumber_t run() const
Definition: EventID.h:39
tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions
void CheckTransitions::preGlobalEndLumi ( GlobalContext const &  gc)

Definition at line 313 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

313  {
314  auto id = gc.luminosityBlockID();
315  m_seenTransitions.emplace_back(Phase::kEndLumi, edm::EventID{id.run(), id.luminosityBlock(), 0}, 1000);
316 }
RunNumber_t run() const
Definition: EventID.h:39
tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions
void CheckTransitions::preGlobalEndRun ( GlobalContext const &  gc)

Definition at line 295 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

295  {
296  auto id = gc.luminosityBlockID();
297  m_seenTransitions.emplace_back(Phase::kEndRun, edm::EventID{id.run(), 0, 0}, 1000);
298 }
RunNumber_t run() const
Definition: EventID.h:39
tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions
void CheckTransitions::preOpenFile ( std::string const &  lfn,
bool  b 
)

Definition at line 286 of file CheckTransitions.cc.

Referenced by CheckTransitions().

286 {}
void CheckTransitions::preStreamBeginLumi ( StreamContext const &  sc)

Definition at line 318 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

318  {
319  m_seenTransitions.emplace_back(Phase::kBeginLumi, sc.eventID(), sc.streamID());
320 }
tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions
void CheckTransitions::preStreamBeginRun ( StreamContext const &  sc)

Definition at line 300 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

300  {
301  m_seenTransitions.emplace_back(Phase::kBeginRun, sc.eventID(), sc.streamID());
302 }
tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions
void CheckTransitions::preStreamEndLumi ( StreamContext const &  sc)

Definition at line 322 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

322  {
323  m_seenTransitions.emplace_back(Phase::kEndLumi, sc.eventID(), sc.streamID());
324 }
tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions
void CheckTransitions::preStreamEndRun ( StreamContext const &  sc)

Definition at line 304 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

304  {
305  m_seenTransitions.emplace_back(Phase::kEndRun, sc.eventID(), sc.streamID());
306 }
tbb::concurrent_vector< std::tuple< Phase, edm::EventID, int > > m_seenTransitions

Member Data Documentation

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

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

Definition at line 82 of file CheckTransitions.cc.

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

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

Definition at line 81 of file CheckTransitions.cc.

Referenced by postEndJob(), and preallocate().

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