CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
L1TriggerJSONMonitoring Class Reference
Inheritance diagram for L1TriggerJSONMonitoring:
edm::global::EDAnalyzer<  edm::StreamCache< L1TriggerJSONMonitoringData::stream >, edm::RunCache< L1TriggerJSONMonitoringData::run >, edm::LuminosityBlockSummaryCache< L1TriggerJSONMonitoringData::lumisection > > edm::global::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (edm::StreamID, edm::Event const &, edm::EventSetup const &) const override
 
std::unique_ptr< L1TriggerJSONMonitoringData::streambeginStream (edm::StreamID) const override
 
std::shared_ptr< L1TriggerJSONMonitoringData::lumisectionglobalBeginLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &) const override
 
std::shared_ptr< L1TriggerJSONMonitoringData::runglobalBeginRun (edm::Run const &, edm::EventSetup const &) const override
 
void globalEndLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, L1TriggerJSONMonitoringData::lumisection *) const override
 
void globalEndRun (edm::Run const &, edm::EventSetup const &) const override
 
 L1TriggerJSONMonitoring (const edm::ParameterSet &)
 
void streamBeginLuminosityBlock (edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &) const override
 
void streamEndLuminosityBlockSummary (edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &, L1TriggerJSONMonitoringData::lumisection *) const override
 
 ~L1TriggerJSONMonitoring () override=default
 
- Public Member Functions inherited from edm::global::EDAnalyzer< edm::StreamCache< L1TriggerJSONMonitoringData::stream >, edm::RunCache< L1TriggerJSONMonitoringData::run >, edm::LuminosityBlockSummaryCache< L1TriggerJSONMonitoringData::lumisection > >
 EDAnalyzer ()=default
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Static Private Member Functions

static void writeIniFile (L1TriggerJSONMonitoringData::run const &, unsigned int, std::vector< std::string > const &)
 
static void writeJsdFile (L1TriggerJSONMonitoringData::run const &)
 

Private Attributes

const edm::InputTag level1Results_
 
const edm::EDGetTokenT< GlobalAlgBlkBxCollectionlevel1ResultsToken_
 

Static Private Attributes

static const int kPrescaleConflict = -1
 
static const int kPrescaleUndefined = -2
 
static const char * streamName_ = "streamL1Rates"
 
static const std::array< const char *, 16 > tcdsTriggerTypes_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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: This class outputs JSON files with TCDS and L1T monitoring information.

Definition at line 71 of file L1TriggerJSONMonitoring.cc.

Constructor & Destructor Documentation

L1TriggerJSONMonitoring::L1TriggerJSONMonitoring ( const edm::ParameterSet )
explicit

Definition at line 162 of file L1TriggerJSONMonitoring.cc.

162  :
163  level1Results_(config.getParameter<edm::InputTag>("L1Results")),
164  level1ResultsToken_(consumes<GlobalAlgBlkBxCollection>(level1Results_))
165 {
166 }
const edm::InputTag level1Results_
Definition: config.py:1
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > level1ResultsToken_
L1TriggerJSONMonitoring::~L1TriggerJSONMonitoring ( )
overridedefault

Member Function Documentation

void L1TriggerJSONMonitoring::analyze ( edm::StreamID  sid,
edm::Event const &  event,
edm::EventSetup const &   
) const
overridevirtual

Implements edm::global::EDAnalyzerBase.

Definition at line 231 of file L1TriggerJSONMonitoring.cc.

References BXVector< T >::at(), edm::EventAuxiliary::CalibrationTrigger, edm::InputTag::encode(), edm::Event::getByToken(), cmsBatch::handle, mps_fire::i, edm::HandleBase::isValid(), kPrescaleConflict, kPrescaleUndefined, level1Results_, level1ResultsToken_, GlobalAlgBlk::maxPhysicsTriggers, or, edm::EventAuxiliary::PhysicsTrigger, edm::EventAuxiliary::RandomTrigger, mps_update::results, and tcdsTriggerTypes_.

232 {
233  auto & stream = * streamCache(sid);
234 
235  ++stream.processed;
236  unsigned int eventType = event.experimentType();
237  if (eventType < tcdsTriggerTypes_.size())
238  ++stream.tcdsAccept[eventType];
239  else
240  edm::LogWarning("L1TriggerJSONMonitoring") << "Unexpected event type " << eventType;
241 
242  // get hold of TriggerResults
244  if (not event.getByToken(level1ResultsToken_, handle) or not handle.isValid()){
245  edm::LogError("L1TriggerJSONMonitoring") << "L1 trigger results with label [" + level1Results_.encode() + "] not present or invalid";
246  return;
247  }
248 
249  // The GlobalAlgBlkBxCollection is a vector of vectors, but the second layer can only ever
250  // have one entry since there can't be more than one collection per bunch crossing.
251  // The first "0" here means BX = 0, while the second "0" is used to access the first and only element.
252  auto const& results = handle->at(0, 0);
253  auto const& decision = results.getAlgoDecisionFinal();
254  assert (decision.size() == GlobalAlgBlk::maxPhysicsTriggers);
255 
256  // check the results for each HLT path
257  for (unsigned int i = 0; i < decision.size(); ++i) {
258  if (decision[i]) {
259  ++stream.l1tAccept[i];
260  switch (eventType) {
262  ++stream.l1tAcceptPhysics[i];
263  break;
265  ++stream.l1tAcceptCalibration[i];
266  break;
268  ++stream.l1tAcceptRandom[i];
269  break;
270  default:
271  break;
272  }
273  }
274  }
275 
276  // check for conflicting values in the prescale column index, and store it
277  int prescaleIndex = results.getPreScColumn();
278  if (stream.prescaleIndex == kPrescaleUndefined) {
279  stream.prescaleIndex = prescaleIndex;
280  } else if (stream.prescaleIndex == kPrescaleConflict) {
281  // do nothing
282  } else if (stream.prescaleIndex != prescaleIndex) {
283  edm::LogWarning("L1TriggerJSONMonitoring") <<
284  "Prescale index changed from " << stream.prescaleIndex << " to " << prescaleIndex << " inside lumisection " << event.luminosityBlock();
285  stream.prescaleIndex = kPrescaleConflict;
286  }
287 }
const edm::InputTag level1Results_
std::string encode() const
Definition: InputTag.cc:159
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
bool isValid() const
Definition: HandleBase.h:74
static unsigned int maxPhysicsTriggers
Definition: GlobalAlgBlk.h:54
static const std::array< const char *, 16 > tcdsTriggerTypes_
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > level1ResultsToken_
Definition: event.py:1
const T & at(int bx, unsigned i) const
std::unique_ptr< L1TriggerJSONMonitoringData::stream > L1TriggerJSONMonitoring::beginStream ( edm::StreamID  ) const
override

Definition at line 179 of file L1TriggerJSONMonitoring.cc.

180 {
181  return std::make_unique<L1TriggerJSONMonitoringData::stream>();
182 }
void L1TriggerJSONMonitoring::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 170 of file L1TriggerJSONMonitoring.cc.

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

171 {
173  desc.add<edm::InputTag>("L1Results",edm::InputTag("hltGtStage2Digis"));
174  descriptions.add("L1TriggerJSONMonitoring", desc);
175 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::shared_ptr< L1TriggerJSONMonitoringData::lumisection > L1TriggerJSONMonitoring::globalBeginLuminosityBlockSummary ( edm::LuminosityBlock const &  lumi,
edm::EventSetup const &   
) const
override

Definition at line 292 of file L1TriggerJSONMonitoring.cc.

References mps_fire::i, kPrescaleUndefined, tablePrinter::lumidata, GlobalAlgBlk::maxPhysicsTriggers, and tcdsTriggerTypes_.

293 {
294  // the API of jsoncollector::HistoJ does not really match our use case,
295  // but it is the only vector-like object available in JsonMonitorable.h
296  auto lumidata = std::make_shared<L1TriggerJSONMonitoringData::lumisection>(L1TriggerJSONMonitoringData::lumisection{
297  jsoncollector::HistoJ<unsigned int>(1), // processed
303  });
304  // repeated calls to `update` necessary to set the internal element counter
305  lumidata->processed.update(0);
306  for (unsigned int i = 0; i < GlobalAlgBlk::maxPhysicsTriggers; ++i) lumidata->l1tAccept.update(0);
307  for (unsigned int i = 0; i < GlobalAlgBlk::maxPhysicsTriggers; ++i) lumidata->l1tAcceptPhysics.update(0);
308  for (unsigned int i = 0; i < GlobalAlgBlk::maxPhysicsTriggers; ++i) lumidata->l1tAcceptCalibration.update(0);
309  for (unsigned int i = 0; i < GlobalAlgBlk::maxPhysicsTriggers; ++i) lumidata->l1tAcceptRandom.update(0);
310  for (unsigned int i = 0; i < tcdsTriggerTypes_.size(); ++i) lumidata->tcdsAccept.update(0);
311  lumidata->prescaleIndex = kPrescaleUndefined;
312 
313  return lumidata;
314 }
static unsigned int maxPhysicsTriggers
Definition: GlobalAlgBlk.h:54
static const std::array< const char *, 16 > tcdsTriggerTypes_
std::shared_ptr< L1TriggerJSONMonitoringData::run > L1TriggerJSONMonitoring::globalBeginRun ( edm::Run const &  run,
edm::EventSetup const &  setup 
) const
override

Definition at line 186 of file L1TriggerJSONMonitoring.cc.

References patPFMETCorrections_cff::algo, cmsPerfStripChart::format, edm::EventSetup::get(), L1TUtmTriggerMenu::getAlgorithmMap(), edm::Service< T >::isAvailable(), edm::ESHandleBase::isValid(), GlobalAlgBlk::maxPhysicsTriggers, evf::MergeTypeJSNDATA, edm::RunBase::run(), lumiPlot::rundata, alignCSCRings::s, str, streamName_, writeIniFile(), and writeJsdFile().

187 {
188  auto rundata = std::make_shared<L1TriggerJSONMonitoringData::run>();
189 
190  // set the DAQ parameters
192  rundata->streamDestination = edm::Service<evf::EvFDaqDirector>()->getStreamDestinations(streamName_);
193  rundata->streamMergeType = edm::Service<evf::EvFDaqDirector>()->getStreamMergeType(streamName_, evf::MergeTypeJSNDATA);
194  rundata->baseRunDir = edm::Service<evf::EvFDaqDirector>()->baseRunDir();
195  } else {
196  rundata->streamDestination = "";
197  rundata->streamMergeType = "";
198  rundata->baseRunDir = ".";
199  }
200 
201  // read the L1 trigger names from the EventSetup
202  std::vector<std::string> triggerNames(GlobalAlgBlk::maxPhysicsTriggers, ""s);
204  setup.get<L1TUtmTriggerMenuRcd>().get(menuHandle);
205  if (menuHandle.isValid()) {
206  for (auto const& algo: menuHandle->getAlgorithmMap())
207  triggerNames[algo.second.getIndex()] = algo.first;
208  } else {
209  edm::LogWarning("L1TriggerJSONMonitoring") << "L1TUtmTriggerMenu not found in the EventSetup.\nThe Level 1 Trigger rate monitoring will not include the trigger names.";
210  }
211 
212  // write the per-run .jsd file
213  rundata->jsdFileName = (boost::format("run%06d_ls0000_streamL1Rates_pid%05d.jsd") % run.run() % getpid()).str();
215 
216  // write the per-run .ini file
217  // iniFileName = (boost::format("run%06d_ls0000_streamL1Rates_pid%05d.ini") % run.run() % getpid()).str();
218  writeIniFile(*rundata, run.run(), triggerNames);
219 
220  return rundata;
221 }
static void writeJsdFile(L1TriggerJSONMonitoringData::run const &)
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
static void writeIniFile(L1TriggerJSONMonitoringData::run const &, unsigned int, std::vector< std::string > const &)
bool isAvailable() const
Definition: Service.h:40
format
Some error handling for the usage.
static unsigned int maxPhysicsTriggers
Definition: GlobalAlgBlk.h:54
const std::map< std::string, L1TUtmAlgorithm > & getAlgorithmMap() const
bool isValid() const
Definition: ESHandle.h:44
#define str(s)
void L1TriggerJSONMonitoring::globalEndLuminosityBlockSummary ( edm::LuminosityBlock const &  lumi,
edm::EventSetup const &  ,
L1TriggerJSONMonitoringData::lumisection lumidata 
) const
override

Definition at line 357 of file L1TriggerJSONMonitoring.cc.

References cms::Adler32(), Json::Value::append(), edm::EventAuxiliary::CalibrationTrigger, jsoncollector::DataPoint::DATA, jsoncollector::DataPoint::DEFINITION, cmsPerfStripChart::format, edm::LuminosityBlock::getRun(), edm::Run::index(), L1TriggerJSONMonitoringData::lumisection::l1tAccept, L1TriggerJSONMonitoringData::lumisection::l1tAcceptCalibration, L1TriggerJSONMonitoringData::lumisection::l1tAcceptPhysics, L1TriggerJSONMonitoringData::lumisection::l1tAcceptRandom, eostools::ls(), edm::LuminosityBlockBase::luminosityBlock(), edm::EventAuxiliary::PhysicsTrigger, L1TriggerJSONMonitoringData::lumisection::prescaleIndex, L1TriggerJSONMonitoringData::lumisection::processed, edm::EventAuxiliary::RandomTrigger, mps_fire::result, writedatasetfile::run, edm::LuminosityBlockBase::run(), lumiPlot::rundata, evf::FastMonitoringService::shouldWriteFiles(), jsoncollector::DataPoint::SOURCE, AlCaHLTBitMon_QueryRunRegistry::string, L1TriggerJSONMonitoringData::lumisection::tcdsAccept, jsoncollector::HistoJ< T >::toJsonValue(), jsoncollector::HistoJ< T >::update(), jsoncollector::HistoJ< T >::value(), and cscNeutronWriter_cfi::writer.

358 {
359  unsigned int ls = lumi.luminosityBlock();
360  unsigned int run = lumi.run();
361 
362  bool writeFiles = true;
363  if (edm::Service<evf::MicroStateService>().isAvailable()) {
365  if (fms)
366  writeFiles = fms->shouldWriteFiles(ls);
367  }
368  if (not writeFiles)
369  return;
370 
371  unsigned int processed = lumidata->processed.value().at(0);
372  auto const& rundata = * runCache(lumi.getRun().index());
374 
375  // [SIC]
376  char hostname[33];
377  gethostname(hostname, 32);
378  std::string sourceHost(hostname);
379 
380  // [SIC]
381  std::stringstream sOutDef;
382  sOutDef << rundata.baseRunDir << "/" << "output_" << getpid() << ".jsd";
383 
384  std::string jsndataFileList = "";
385  unsigned int jsndataSize = 0;
386  unsigned int jsndataAdler32 = 1; // adler32 checksum for an empty file
387 
388  if (processed) {
389  // write the .jsndata files which contain the actual rates
390  Json::Value jsndata;
391  jsndata[jsoncollector::DataPoint::SOURCE] = sourceHost;
392  jsndata[jsoncollector::DataPoint::DEFINITION] = rundata.jsdFileName;
398 
399  // write only the number of "physics", "calibration" and "random" events
404  jsndata[jsoncollector::DataPoint::DATA].append(tcdsAccept.toJsonValue());
405  /* FIXME send information for all event types instead of only these three
406  jsndata[jsoncollector::DataPoint::DATA].append(lumidata->tcdsAccept.toJsonValue());
407  */
409 
410  auto jsndataFileName = boost::format("run%06d_ls%04d_streamL1Rates_pid%05d.jsndata") % run % ls % getpid();
411 
412  std::string result = writer.write(jsndata);
413  std::ofstream jsndataFile(rundata.baseRunDir + "/" + jsndataFileName.str());
414  jsndataFile << result;
415  jsndataFile.close();
416 
417  jsndataFileList = jsndataFileName.str();
418  jsndataSize = result.size();
419  jsndataAdler32 = cms::Adler32(result.c_str(), result.size());
420  }
421 
422  // create a metadata json file for the "HLT rates" pseudo-stream
423  unsigned int jsnProcessed = processed;
424  unsigned int jsnAccepted = processed;
425  unsigned int jsnErrorEvents = 0;
426  unsigned int jsnRetCodeMask = 0;
427  std::string jsnInputFiles = "";
428  unsigned int jsnHLTErrorEvents = 0;
429 
430  Json::Value jsn;
431  jsn[jsoncollector::DataPoint::SOURCE] = sourceHost;
432  jsn[jsoncollector::DataPoint::DEFINITION] = sOutDef.str();
433  jsn[jsoncollector::DataPoint::DATA].append(jsnProcessed);
434  jsn[jsoncollector::DataPoint::DATA].append(jsnAccepted);
435  jsn[jsoncollector::DataPoint::DATA].append(jsnErrorEvents);
436  jsn[jsoncollector::DataPoint::DATA].append(jsnRetCodeMask);
437  jsn[jsoncollector::DataPoint::DATA].append(jsndataFileList);
438  jsn[jsoncollector::DataPoint::DATA].append(jsndataSize);
439  jsn[jsoncollector::DataPoint::DATA].append(jsnInputFiles);
440  jsn[jsoncollector::DataPoint::DATA].append(jsndataAdler32);
441  jsn[jsoncollector::DataPoint::DATA].append(rundata.streamDestination);
442  jsn[jsoncollector::DataPoint::DATA].append(rundata.streamMergeType);
443  jsn[jsoncollector::DataPoint::DATA].append(jsnHLTErrorEvents);
444 
445  auto jsnFileName = boost::format("run%06d_ls%04d_streamL1Rates_pid%05d.jsn") % run % ls % getpid();
446  std::ofstream jsnFile( rundata.baseRunDir + "/" + jsnFileName.str() );
447  jsnFile << writer.write(jsn);
448  jsnFile.close();
449 }
jsoncollector::HistoJ< unsigned int > l1tAcceptRandom
jsoncollector::HistoJ< unsigned int > l1tAccept
static const std::string SOURCE
Definition: DataPoint.h:121
bool shouldWriteFiles(unsigned int lumi, unsigned int *proc=0)
Value & append(const Value &value)
Append value to array at the end.
jsoncollector::HistoJ< unsigned int > l1tAcceptCalibration
jsoncollector::HistoJ< unsigned int > processed
Represents a JSON value.
Definition: value.h:111
virtual Json::Value toJsonValue() const
std::vector< T > & value()
static const std::string DATA
Definition: DataPoint.h:123
jsoncollector::HistoJ< unsigned int > tcdsAccept
format
Some error handling for the usage.
jsoncollector::HistoJ< unsigned int > l1tAcceptPhysics
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
def ls(path, rec=False)
Definition: eostools.py:349
Writes a Value in JSON format in a human friendly way.
Definition: writer.h:65
static const std::string DEFINITION
Definition: DataPoint.h:122
void L1TriggerJSONMonitoring::globalEndRun ( edm::Run const &  ,
edm::EventSetup const &   
) const
override

Definition at line 225 of file L1TriggerJSONMonitoring.cc.

226 {
227 }
void L1TriggerJSONMonitoring::streamBeginLuminosityBlock ( edm::StreamID  sid,
edm::LuminosityBlock const &  lumi,
edm::EventSetup const &   
) const
override

Definition at line 318 of file L1TriggerJSONMonitoring.cc.

References kPrescaleUndefined, GlobalAlgBlk::maxPhysicsTriggers, and tcdsTriggerTypes_.

319 {
320  auto & stream = * streamCache(sid);
321 
322  // reset the stream counters
323  stream.processed = 0;
324  stream.l1tAccept.assign(GlobalAlgBlk::maxPhysicsTriggers, 0);
325  stream.l1tAcceptPhysics.assign(GlobalAlgBlk::maxPhysicsTriggers, 0);
326  stream.l1tAcceptCalibration.assign(GlobalAlgBlk::maxPhysicsTriggers, 0);
327  stream.l1tAcceptRandom.assign(GlobalAlgBlk::maxPhysicsTriggers, 0);
328  stream.tcdsAccept.assign(tcdsTriggerTypes_.size(), 0);
329  stream.prescaleIndex = kPrescaleUndefined;
330 }
static unsigned int maxPhysicsTriggers
Definition: GlobalAlgBlk.h:54
static const std::array< const char *, 16 > tcdsTriggerTypes_
void L1TriggerJSONMonitoring::streamEndLuminosityBlockSummary ( edm::StreamID  sid,
edm::LuminosityBlock const &  lumi,
edm::EventSetup const &  ,
L1TriggerJSONMonitoringData::lumisection lumidata 
) const
override

Definition at line 334 of file L1TriggerJSONMonitoring.cc.

References mps_fire::i, kPrescaleConflict, kPrescaleUndefined, L1TriggerJSONMonitoringData::lumisection::l1tAccept, L1TriggerJSONMonitoringData::lumisection::l1tAcceptCalibration, L1TriggerJSONMonitoringData::lumisection::l1tAcceptPhysics, L1TriggerJSONMonitoringData::lumisection::l1tAcceptRandom, GlobalAlgBlk::maxPhysicsTriggers, L1TriggerJSONMonitoringData::lumisection::prescaleIndex, L1TriggerJSONMonitoringData::lumisection::processed, L1TriggerJSONMonitoringData::lumisection::tcdsAccept, tcdsTriggerTypes_, and jsoncollector::HistoJ< T >::value().

335 {
336  auto const& stream = * streamCache(sid);
337  lumidata->processed.value()[0] += stream.processed;
338 
339  for (unsigned int i = 0; i < GlobalAlgBlk::maxPhysicsTriggers; ++i) {
340  lumidata->l1tAccept.value()[i] += stream.l1tAccept[i];
341  lumidata->l1tAcceptPhysics.value()[i] += stream.l1tAcceptPhysics[i];
342  lumidata->l1tAcceptCalibration.value()[i] += stream.l1tAcceptCalibration[i];
343  lumidata->l1tAcceptRandom.value()[i] += stream.l1tAcceptRandom[i];
344  }
345  for (unsigned int i = 0; i < tcdsTriggerTypes_.size(); ++i)
346  lumidata->tcdsAccept.value()[i] += stream.tcdsAccept[i];
347 
348  // check for conflicting values in the prescale column index
349  if (lumidata->prescaleIndex == kPrescaleUndefined)
350  lumidata->prescaleIndex = stream.prescaleIndex;
351  else if (lumidata->prescaleIndex != stream.prescaleIndex)
352  lumidata->prescaleIndex = kPrescaleConflict;
353 }
jsoncollector::HistoJ< unsigned int > l1tAcceptRandom
jsoncollector::HistoJ< unsigned int > l1tAccept
jsoncollector::HistoJ< unsigned int > l1tAcceptCalibration
jsoncollector::HistoJ< unsigned int > processed
std::vector< T > & value()
jsoncollector::HistoJ< unsigned int > tcdsAccept
jsoncollector::HistoJ< unsigned int > l1tAcceptPhysics
static unsigned int maxPhysicsTriggers
Definition: GlobalAlgBlk.h:54
static const std::array< const char *, 16 > tcdsTriggerTypes_
void L1TriggerJSONMonitoring::writeIniFile ( L1TriggerJSONMonitoringData::run const &  rundata,
unsigned int  run,
std::vector< std::string > const &  l1TriggerNames 
)
staticprivate

Definition at line 470 of file L1TriggerJSONMonitoring.cc.

References Json::Value::append(), Json::arrayValue, L1TriggerJSONMonitoringData::run::baseRunDir, edm::EventAuxiliary::CalibrationTrigger, ws_sso_content_reader::content, DEFINE_FWK_MODULE, FrontierConditions_GlobalTag_cff::file, cmsPerfStripChart::format, dataset::name, edm::EventAuxiliary::PhysicsTrigger, edm::EventAuxiliary::RandomTrigger, str, AlCaHLTBitMon_QueryRunRegistry::string, tcdsTriggerTypes_, Json::StyledWriter::write(), and cscNeutronWriter_cfi::writer.

Referenced by globalBeginRun().

471 {
473 
474  Json::Value triggerNames(Json::arrayValue);
475  for (auto const& name: l1TriggerNames)
476  triggerNames.append(name);
477  content["L1-Algo-Names"] = triggerNames;
478 
479  Json::Value eventTypes(Json::arrayValue);
483  /* FIXME send information for all event types instead of only these three
484  for (auto const& name : tcdsTriggerTypes_)
485  eventTypes.append(name);
486  */
487  content["Event-Type"] = eventTypes;
488 
489  std::string iniFileName = (boost::format("run%06d_ls0000_streamL1Rates_pid%05d.ini") % run % getpid()).str();
490  std::ofstream file(rundata.baseRunDir + "/" + iniFileName);
492  file << writer.write(content);
493  file.close();
494 }
Represents a JSON value.
Definition: value.h:111
format
Some error handling for the usage.
static const std::array< const char *, 16 > tcdsTriggerTypes_
std::string write(const Value &root) override
Serialize a Value in JSON format.
Writes a Value in JSON format in a human friendly way.
Definition: writer.h:65
#define str(s)
array value (ordered list)
Definition: value.h:31
void L1TriggerJSONMonitoring::writeJsdFile ( L1TriggerJSONMonitoringData::run const &  rundata)
staticprivate

Definition at line 452 of file L1TriggerJSONMonitoring.cc.

References L1TriggerJSONMonitoringData::run::baseRunDir, FrontierConditions_GlobalTag_cff::file, and L1TriggerJSONMonitoringData::run::jsdFileName.

Referenced by globalBeginRun().

453 {
454  std::ofstream file(rundata.baseRunDir + "/" + rundata.jsdFileName);
455  file << R"""({
456  "data" : [
457  { "name" : "Processed", "type" : "integer", "operation" : "histo"},
458  { "name" : "L1-AlgoAccepted", "type" : "integer", "operation" : "histo"},
459  { "name" : "L1-AlgoAccepted-Physics", "type" : "integer", "operation" : "histo"},
460  { "name" : "L1-AlgoAccepted-Calibration", "type" : "integer", "operation" : "histo"},
461  { "name" : "L1-AlgoAccepted-Random", "type" : "integer", "operation" : "histo"},
462  { "name" : "L1-Global", "type" : "integer", "operation" : "histo"},
463  { "name" : "Prescale-Index", "type" : "integer", "operation" : "sample"}
464  ]
465 })""";
466  file.close();
467 }

Member Data Documentation

const int L1TriggerJSONMonitoring::kPrescaleConflict = -1
staticprivate

Definition at line 145 of file L1TriggerJSONMonitoring.cc.

Referenced by analyze(), and streamEndLuminosityBlockSummary().

const int L1TriggerJSONMonitoring::kPrescaleUndefined = -2
staticprivate
const edm::InputTag L1TriggerJSONMonitoring::level1Results_
private

Definition at line 153 of file L1TriggerJSONMonitoring.cc.

Referenced by analyze().

const edm::EDGetTokenT<GlobalAlgBlkBxCollection> L1TriggerJSONMonitoring::level1ResultsToken_
private

Definition at line 154 of file L1TriggerJSONMonitoring.cc.

Referenced by analyze().

const char* L1TriggerJSONMonitoring::streamName_ = "streamL1Rates"
staticprivate

Definition at line 147 of file L1TriggerJSONMonitoring.cc.

Referenced by globalBeginRun().

const std::array< const char *, 16 > L1TriggerJSONMonitoring::tcdsTriggerTypes_
staticprivate
Initial value:
= {{
"Error",
"Physics",
"Calibration",
"Random",
"Auxiliary",
"",
"",
"",
"Cyclic",
"Bunch-pattern",
"Software",
"TTS",
"",
"",
"",
""
}}

Definition at line 124 of file L1TriggerJSONMonitoring.cc.

Referenced by analyze(), globalBeginLuminosityBlockSummary(), streamBeginLuminosityBlock(), streamEndLuminosityBlockSummary(), and writeIniFile().