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 43 of file CheckTransitions.cc.

43  {
44  kBeginRun,
45  kBeginLumi,
46  kEvent,
47  kEndLumi,
48  kEndRun
49  };
Enumerator
IsInvalid 
IsStop 
IsFile 
IsRun 
IsLumi 
IsEvent 

Definition at line 51 of file CheckTransitions.cc.

51  {
52  IsInvalid,
53  IsStop,
54  IsFile,
55  IsRun,
56  IsLumi,
57  IsEvent
58  };

Constructor & Destructor Documentation

CheckTransitions::CheckTransitions ( const ParameterSet ,
ActivityRegistry  
)

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

203 {
204  for( auto const& p: iPS.getUntrackedParameter<std::vector<edm::ParameterSet>>("transitions")) {
205  m_expectedTransitions.emplace_back( stringToType(p.getUntrackedParameter<std::string>("type")),
206  p.getUntrackedParameter<EventID>("id"));
207  }
208 
209  iRegistry.watchPreallocate(this, &CheckTransitions::preallocate);
210 
211  iRegistry.watchPostEndJob(this, &CheckTransitions::postEndJob);
212 
213  iRegistry.watchPreOpenFile(this, &CheckTransitions::preOpenFile);
214 
215  iRegistry.watchPreCloseFile(this, &CheckTransitions::preCloseFile);
216 
217  iRegistry.watchPreGlobalBeginRun(this, &CheckTransitions::preGlobalBeginRun);
218 
219  iRegistry.watchPreGlobalEndRun(this, &CheckTransitions::preGlobalEndRun);
220 
221  iRegistry.watchPreStreamBeginRun(this, &CheckTransitions::preStreamBeginRun);
222 
223  iRegistry.watchPreStreamEndRun(this, &CheckTransitions::preStreamEndRun);
224 
225  iRegistry.watchPreGlobalBeginLumi(this, &CheckTransitions::preGlobalBeginLumi);
226 
227  iRegistry.watchPreGlobalEndLumi(this, &CheckTransitions::preGlobalEndLumi);
228 
229  iRegistry.watchPreStreamBeginLumi(this, &CheckTransitions::preStreamBeginLumi);
230 
231  iRegistry.watchPreStreamEndLumi(this, &CheckTransitions::preStreamEndLumi);
232 
233  iRegistry.watchPreEvent(this, &CheckTransitions::preEvent);
234 }
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 236 of file CheckTransitions.cc.

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

236  {
237  if (m_failed) {
238  throw edm::Exception(errors::EventProcessorFailure)<<"incorrect transtions";
239  }
240 }

Member Function Documentation

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

Definition at line 243 of file CheckTransitions.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), edm::ParameterSetDescription::addVPSetUntracked(), edm::ParameterSetDescription::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

243  {
245  desc.setComment("Checks that the transitions specified occur during the job.");
246 
248  trans.addUntracked<std::string>("type");
249  trans.addUntracked<edm::EventID>("id");
250  desc.addVPSetUntracked("transitions",trans, {{}});
251  descriptions.add("CheckTransitions", desc);
252 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void CheckTransitions::postEndJob ( )

Definition at line 260 of file CheckTransitions.cc.

References gather_cfg::cout, mps_fire::i, m_expectedTransitions, m_failed, m_nstreams, m_seenTransitions, and alignCSCRings::s.

Referenced by CheckTransitions().

260  {
261 
262  auto expectedV = expectedValues(m_expectedTransitions,m_nstreams);
263 
264  std::vector<std::tuple<Phase,edm::EventID,int>> orderedSeen;
265  orderedSeen.reserve(m_seenTransitions.size());
266  for(auto const& i: m_seenTransitions) {
267  // std::cout <<i.first.m_run<<" "<<i.first.m_lumi<<" "<<i.first.m_event<<" "<<i.second<<std::endl;
268  auto s = std::get<2>(i);
269  if(std::get<1>(i).event() > 0) {
270  s=-2;
271  }
272  orderedSeen.emplace_back(std::get<0>(i),std::get<1>(i),s);
273  }
274  std::sort(orderedSeen.begin(),orderedSeen.end());
275 
276  auto orderedExpected = expectedV;
277  std::sort(orderedExpected.begin(),orderedExpected.end());
278  /* for(auto const& i: expectedV) {
279  std::cout <<i.first.m_run<<" "<<i.first.m_lumi<<" "<<i.first.m_event<<" "<<i.second<<std::endl;
280  } */
281 
282  auto itOS = orderedSeen.begin();
283  for(auto itOE = orderedExpected.begin(); itOE != orderedExpected.end(); ++itOE) {
284  if(itOS == orderedSeen.end()) {
285  break;
286  }
287  if ( *itOE != *itOS) {
288  auto syncOE = std::get<1>(*itOE);
289  auto syncOS = std::get<1>(*itOS);
290  std::cout <<"Different ordering "<<syncOE<<" "<<std::get<2>(*itOE)<<"\n"
291  <<" "<<syncOS<<" "<<std::get<2>(*itOS)<<"\n";
292  m_failed=true;
293  }
294  ++itOS;
295  }
296 
297  if(orderedSeen.size() != orderedExpected.size()) {
298  std::cout <<"Wrong number of transition "<<orderedSeen.size() <<" "<<orderedExpected.size()<<std::endl;
299  m_failed = true;
300  return;
301  }
302 
303 }
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 255 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

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

Definition at line 310 of file CheckTransitions.cc.

Referenced by CheckTransitions().

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

Definition at line 358 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

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

Definition at line 336 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

336  {
337  auto id =gc.luminosityBlockID();
338  m_seenTransitions.emplace_back(Phase::kBeginLumi,edm::EventID{id.run(),id.luminosityBlock(),0},-1);
339 }
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 314 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

314  {
315  auto id =gc.luminosityBlockID();
316  m_seenTransitions.emplace_back(Phase::kBeginRun,edm::EventID{id.run(),0,0},-1);
317 }
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 342 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

342  {
343  auto id =gc.luminosityBlockID();
344  m_seenTransitions.emplace_back(Phase::kEndLumi,edm::EventID{id.run(),id.luminosityBlock(),0},1000);
345 }
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 320 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

320  {
321  auto id =gc.luminosityBlockID();
322  m_seenTransitions.emplace_back(Phase::kEndRun,edm::EventID{id.run(),0,0},1000);
323 }
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 306 of file CheckTransitions.cc.

Referenced by CheckTransitions().

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

Definition at line 348 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

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

Definition at line 326 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

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

Definition at line 353 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

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

Definition at line 331 of file CheckTransitions.cc.

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

Referenced by CheckTransitions().

331  {
332  m_seenTransitions.emplace_back(Phase::kEndRun,sc.eventID(),sc.streamID());
333 }
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 94 of file CheckTransitions.cc.

Referenced by CheckTransitions(), and postEndJob().

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

Definition at line 96 of file CheckTransitions.cc.

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

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

Definition at line 95 of file CheckTransitions.cc.

Referenced by postEndJob(), and preallocate().

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