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
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcdl1tUtmTriggerMenuRcdToken_
 
const edm::InputTag level1Results_
 
const edm::EDGetTokenT< GlobalAlgBlkBxCollectionlevel1ResultsToken_
 

Static Private Attributes

static constexpr const char * streamName_ = "streamL1Rates"
 
static constexpr 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)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: This class outputs JSON files with TCDS and L1T monitoring information.

Definition at line 72 of file L1TriggerJSONMonitoring.cc.

Constructor & Destructor Documentation

◆ L1TriggerJSONMonitoring()

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

Definition at line 163 of file L1TriggerJSONMonitoring.cc.

References Exception, geometryDiff::file, and AlCaHLTBitMon_QueryRunRegistry::string.

164  : level1Results_(config.getParameter<edm::InputTag>("L1Results")),
165  level1ResultsToken_(consumes<GlobalAlgBlkBxCollection>(level1Results_)),
166  l1tUtmTriggerMenuRcdToken_(esConsumes<edm::Transition::BeginRun>()) {
167  if (edm::Service<evf::EvFDaqDirector>().isAvailable()) {
168  //output initemp file. This lets hltd know number of streams early
169  std::string initFileName = edm::Service<evf::EvFDaqDirector>()->getInitTempFilePath("streamL1Rates");
170  std::ofstream file(initFileName);
171  if (!file)
172  throw cms::Exception("L1TriggerJsonMonitoring")
173  << "Cannot create INITEMP file: " << initFileName << " error: " << strerror(errno);
174  file.close();
175  }
176 }
const edm::InputTag level1Results_
Definition: config.py:1
const edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > l1tUtmTriggerMenuRcdToken_
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > level1ResultsToken_

◆ ~L1TriggerJSONMonitoring()

L1TriggerJSONMonitoring::~L1TriggerJSONMonitoring ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::global::EDAnalyzerBase.

Definition at line 233 of file L1TriggerJSONMonitoring.cc.

References cms::cuda::assert(), edm::EventAuxiliary::CalibrationTrigger, edm::InputTag::encode(), QIE11Task_cfi::eventType, patZpeak::handle, mps_fire::i, L1TriggerJSONMonitoringData::kPrescaleConflict, L1TriggerJSONMonitoringData::kPrescaleUndefined, level1Results_, level1ResultsToken_, GlobalAlgBlk::maxPhysicsTriggers, or, edm::EventAuxiliary::PhysicsTrigger, edm::EventAuxiliary::RandomTrigger, mysort::results, cms::cuda::stream, and tcdsTriggerTypes_.

233  {
234  auto& stream = *streamCache(sid);
235 
236  ++stream.processed;
237  unsigned int eventType = event.experimentType();
238  if (eventType < tcdsTriggerTypes_.size())
239  ++stream.tcdsAccept[eventType];
240  else
241  edm::LogWarning("L1TriggerJSONMonitoring") << "Unexpected event type " << eventType;
242 
243  // get hold of TriggerResults
245  if (not event.getByToken(level1ResultsToken_, handle) or not handle.isValid() or handle->isEmpty(0)) {
246  edm::LogError("L1TriggerJSONMonitoring")
247  << "L1 trigger results with label [" + level1Results_.encode() + "] not present or invalid";
248  return;
249  }
250 
251  // The GlobalAlgBlkBxCollection is a vector of vectors, but the second layer can only ever
252  // have one entry since there can't be more than one collection per bunch crossing.
253  // The first "0" here means BX = 0, while the second "0" is used to access the first and only element.
254  auto const& results = handle->at(0, 0);
255  auto const& decision = results.getAlgoDecisionFinal();
256  assert(decision.size() == GlobalAlgBlk::maxPhysicsTriggers);
257 
258  // check the results for each HLT path
259  for (unsigned int i = 0; i < decision.size(); ++i) {
260  if (decision[i]) {
261  ++stream.l1tAccept[i];
262  switch (eventType) {
264  ++stream.l1tAcceptPhysics[i];
265  break;
267  ++stream.l1tAcceptCalibration[i];
268  break;
270  ++stream.l1tAcceptRandom[i];
271  break;
272  default:
273  break;
274  }
275  }
276  }
277 
278  // check for conflicting values in the prescale column index, and store it
279  int prescaleIndex = results.getPreScColumn();
281  stream.prescaleIndex = prescaleIndex;
282  } else if (stream.prescaleIndex == L1TriggerJSONMonitoringData::kPrescaleConflict) {
283  // do nothing
284  } else if (stream.prescaleIndex != prescaleIndex) {
285  edm::LogWarning("L1TriggerJSONMonitoring") << "Prescale index changed from " << stream.prescaleIndex << " to "
286  << prescaleIndex << " inside lumisection " << event.luminosityBlock();
288  }
289 }
static constexpr const int kPrescaleConflict
const edm::InputTag level1Results_
std::string encode() const
Definition: InputTag.cc:159
Log< level::Error, false > LogError
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
assert(be >=bs)
static constexpr const int kPrescaleUndefined
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
static constexpr const std::array< const char *, 16 > tcdsTriggerTypes_
results
Definition: mysort.py:8
static constexpr unsigned int maxPhysicsTriggers
Definition: GlobalAlgBlk.h:52
Log< level::Warning, false > LogWarning
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > level1ResultsToken_
Definition: event.py:1

◆ beginStream()

std::unique_ptr< L1TriggerJSONMonitoringData::stream > L1TriggerJSONMonitoring::beginStream ( edm::StreamID  ) const
override

Definition at line 186 of file L1TriggerJSONMonitoring.cc.

186  {
187  return std::make_unique<L1TriggerJSONMonitoringData::stream>();
188 }

◆ fillDescriptions()

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

Definition at line 179 of file L1TriggerJSONMonitoring.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

179  {
181  desc.add<edm::InputTag>("L1Results", edm::InputTag("hltGtStage2Digis"));
182  descriptions.add("L1TriggerJSONMonitoring", desc);
183 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ globalBeginLuminosityBlockSummary()

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, L1TriggerJSONMonitoringData::kPrescaleUndefined, 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)
307  lumidata->l1tAccept.update(0);
308  for (unsigned int i = 0; i < GlobalAlgBlk::maxPhysicsTriggers; ++i)
309  lumidata->l1tAcceptPhysics.update(0);
310  for (unsigned int i = 0; i < GlobalAlgBlk::maxPhysicsTriggers; ++i)
311  lumidata->l1tAcceptCalibration.update(0);
312  for (unsigned int i = 0; i < GlobalAlgBlk::maxPhysicsTriggers; ++i)
313  lumidata->l1tAcceptRandom.update(0);
314  for (unsigned int i = 0; i < tcdsTriggerTypes_.size(); ++i)
315  lumidata->tcdsAccept.update(0);
316  lumidata->prescaleIndex = L1TriggerJSONMonitoringData::kPrescaleUndefined;
317 
318  return lumidata;
319 }
static constexpr const int kPrescaleUndefined
static constexpr const std::array< const char *, 16 > tcdsTriggerTypes_
static constexpr unsigned int maxPhysicsTriggers
Definition: GlobalAlgBlk.h:52

◆ globalBeginRun()

std::shared_ptr< L1TriggerJSONMonitoringData::run > L1TriggerJSONMonitoring::globalBeginRun ( edm::Run const &  run,
edm::EventSetup const &  setup 
) const
override

Definition at line 191 of file L1TriggerJSONMonitoring.cc.

References edm::Service< T >::isAvailable(), l1tUtmTriggerMenuRcdToken_, GlobalAlgBlk::maxPhysicsTriggers, evf::MergeTypeJSNDATA, writedatasetfile::run, alignCSCRings::s, singleTopDQM_cfi::setup, streamName_, L1TEGammaOffline_cfi::triggerNames, writeIniFile(), and writeJsdFile().

192  {
193  auto rundata = std::make_shared<L1TriggerJSONMonitoringData::run>();
194 
195  // set the DAQ parameters
197  rundata->streamDestination = edm::Service<evf::EvFDaqDirector>()->getStreamDestinations(streamName_);
198  rundata->streamMergeType =
200  rundata->baseRunDir = edm::Service<evf::EvFDaqDirector>()->baseRunDir();
201  } else {
202  rundata->streamDestination = "";
203  rundata->streamMergeType = "";
204  rundata->baseRunDir = ".";
205  }
206 
207  // read the L1 trigger names from the EventSetup
208  std::vector<std::string> triggerNames(GlobalAlgBlk::maxPhysicsTriggers, ""s);
209  auto const& menuHandle = setup.getHandle(l1tUtmTriggerMenuRcdToken_);
210  if (menuHandle.isValid()) {
211  for (auto const& algo : menuHandle->getAlgorithmMap())
212  triggerNames[algo.second.getIndex()] = algo.first;
213  } else {
214  edm::LogWarning("L1TriggerJSONMonitoring") << "L1TUtmTriggerMenu not found in the EventSetup.\nThe Level 1 Trigger "
215  "rate monitoring will not include the trigger names.";
216  }
217 
218  // write the per-run .jsd file
219  rundata->jsdFileName = fmt::sprintf("run%06d_ls0000_streamL1Rates_pid%05d.jsd", run.run(), getpid());
220  writeJsdFile(*rundata);
221 
222  // write the per-run .ini file
223  //iniFileName = fmt::sprintf("run%06d_ls0000_streamL1Rates_pid%05d.ini", run.run(), getpid());
224  writeIniFile(*rundata, run.run(), triggerNames);
225 
226  return rundata;
227 }
static void writeJsdFile(L1TriggerJSONMonitoringData::run const &)
static void writeIniFile(L1TriggerJSONMonitoringData::run const &, unsigned int, std::vector< std::string > const &)
const edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > l1tUtmTriggerMenuRcdToken_
static constexpr unsigned int maxPhysicsTriggers
Definition: GlobalAlgBlk.h:52
bool isAvailable() const
Definition: Service.h:40
Log< level::Warning, false > LogWarning
static constexpr const char * streamName_

◆ globalEndLuminosityBlockSummary()

void L1TriggerJSONMonitoring::globalEndLuminosityBlockSummary ( edm::LuminosityBlock const &  lumi,
edm::EventSetup const &  ,
L1TriggerJSONMonitoringData::lumisection lumidata 
) const
override

Definition at line 362 of file L1TriggerJSONMonitoring.cc.

References cms::Adler32(), jsoncollector::Json::Value::append(), edm::EventAuxiliary::CalibrationTrigger, jsoncollector::DataPoint::DATA, jsoncollector::DataPoint::DEFINITION, L1TriggerJSONMonitoringData::lumisection::l1tAccept, L1TriggerJSONMonitoringData::lumisection::l1tAcceptCalibration, L1TriggerJSONMonitoringData::lumisection::l1tAcceptPhysics, L1TriggerJSONMonitoringData::lumisection::l1tAcceptRandom, eostools::ls(), edm::EventAuxiliary::PhysicsTrigger, L1TriggerJSONMonitoringData::lumisection::prescaleIndex, L1TriggerJSONMonitoringData::lumisection::processed, edm::EventAuxiliary::RandomTrigger, mps_fire::result, writedatasetfile::run, 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 convertToRaw::writer.

364  {
365  unsigned int ls = lumi.luminosityBlock();
366  unsigned int run = lumi.run();
367 
368  bool writeFiles = true;
369  if (edm::Service<evf::MicroStateService>().isAvailable()) {
372  if (fms)
373  writeFiles = fms->shouldWriteFiles(ls);
374  }
375  if (not writeFiles)
376  return;
377 
378  unsigned int processed = lumidata->processed.value().at(0);
379  auto const& rundata = *runCache(lumi.getRun().index());
381 
382  // [SIC]
383  char hostname[33];
384  gethostname(hostname, 32);
385  std::string sourceHost(hostname);
386 
387  // [SIC]
388  std::stringstream sOutDef;
389  sOutDef << rundata.baseRunDir << "/"
390  << "output_" << getpid() << ".jsd";
391 
392  std::string jsndataFileList = "";
393  unsigned int jsndataSize = 0;
394  unsigned int jsndataAdler32 = 1; // adler32 checksum for an empty file
395 
396  if (processed) {
397  // write the .jsndata files which contain the actual rates
398  Json::Value jsndata;
399  jsndata[jsoncollector::DataPoint::SOURCE] = sourceHost;
400  jsndata[jsoncollector::DataPoint::DEFINITION] = rundata.jsdFileName;
406 
407  // write only the number of "physics", "calibration" and "random" events
412  jsndata[jsoncollector::DataPoint::DATA].append(tcdsAccept.toJsonValue());
413  /* FIXME send information for all event types instead of only these three
414  jsndata[jsoncollector::DataPoint::DATA].append(lumidata->tcdsAccept.toJsonValue());
415  */
417 
418  auto jsndataFileName = fmt::sprintf("run%06d_ls%04d_streamL1Rates_pid%05d.jsndata", run, ls, getpid());
419 
420  std::string result = writer.write(jsndata);
421  std::ofstream jsndataFile(rundata.baseRunDir + "/" + jsndataFileName);
422  jsndataFile << result;
423  jsndataFile.close();
424 
425  jsndataFileList = jsndataFileName;
426  jsndataSize = result.size();
427  jsndataAdler32 = cms::Adler32(result.c_str(), result.size());
428  }
429 
430  // create a metadata json file for the "HLT rates" pseudo-stream
431  unsigned int jsnProcessed = processed;
432  unsigned int jsnAccepted = processed;
433  unsigned int jsnErrorEvents = 0;
434  unsigned int jsnRetCodeMask = 0;
435  std::string jsnInputFiles = "";
436  unsigned int jsnHLTErrorEvents = 0;
437 
438  Json::Value jsn;
439  jsn[jsoncollector::DataPoint::SOURCE] = sourceHost;
440  jsn[jsoncollector::DataPoint::DEFINITION] = sOutDef.str();
441  jsn[jsoncollector::DataPoint::DATA].append(jsnProcessed);
442  jsn[jsoncollector::DataPoint::DATA].append(jsnAccepted);
443  jsn[jsoncollector::DataPoint::DATA].append(jsnErrorEvents);
444  jsn[jsoncollector::DataPoint::DATA].append(jsnRetCodeMask);
445  jsn[jsoncollector::DataPoint::DATA].append(jsndataFileList);
446  jsn[jsoncollector::DataPoint::DATA].append(jsndataSize);
447  jsn[jsoncollector::DataPoint::DATA].append(jsnInputFiles);
448  jsn[jsoncollector::DataPoint::DATA].append(jsndataAdler32);
449  jsn[jsoncollector::DataPoint::DATA].append(rundata.streamDestination);
450  jsn[jsoncollector::DataPoint::DATA].append(rundata.streamMergeType);
451  jsn[jsoncollector::DataPoint::DATA].append(jsnHLTErrorEvents);
452 
453  auto jsnFileName = fmt::sprintf("run%06d_ls%04d_streamL1Rates_pid%05d.jsn", run, ls, getpid());
454  std::ofstream jsnFile(rundata.baseRunDir + "/" + jsnFileName);
455  jsnFile << writer.write(jsn);
456  jsnFile.close();
457 }
jsoncollector::HistoJ< unsigned int > l1tAcceptRandom
jsoncollector::HistoJ< unsigned int > l1tAccept
static const std::string SOURCE
Definition: DataPoint.h:116
jsoncollector::HistoJ< unsigned int > l1tAcceptCalibration
jsoncollector::HistoJ< unsigned int > processed
std::vector< T > & value()
static const std::string DATA
Definition: DataPoint.h:118
jsoncollector::HistoJ< unsigned int > tcdsAccept
Writes a Value in JSON format in a human friendly way.
Definition: writer.h:64
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
virtual Json::Value toJsonValue() const
Value & append(const Value &value)
Append value to array at the end.
Represents a JSON value.
Definition: value.h:101
bool shouldWriteFiles(unsigned int lumi, unsigned int *proc=nullptr)
static const std::string DEFINITION
Definition: DataPoint.h:117

◆ globalEndRun()

void L1TriggerJSONMonitoring::globalEndRun ( edm::Run const &  ,
edm::EventSetup const &   
) const
override

Definition at line 230 of file L1TriggerJSONMonitoring.cc.

230 {}

◆ streamBeginLuminosityBlock()

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

Definition at line 322 of file L1TriggerJSONMonitoring.cc.

References L1TriggerJSONMonitoringData::kPrescaleUndefined, GlobalAlgBlk::maxPhysicsTriggers, cms::cuda::stream, and tcdsTriggerTypes_.

324  {
325  auto& stream = *streamCache(sid);
326 
327  // reset the stream counters
328  stream.processed = 0;
329  stream.l1tAccept.assign(GlobalAlgBlk::maxPhysicsTriggers, 0);
330  stream.l1tAcceptPhysics.assign(GlobalAlgBlk::maxPhysicsTriggers, 0);
331  stream.l1tAcceptCalibration.assign(GlobalAlgBlk::maxPhysicsTriggers, 0);
332  stream.l1tAcceptRandom.assign(GlobalAlgBlk::maxPhysicsTriggers, 0);
333  stream.tcdsAccept.assign(tcdsTriggerTypes_.size(), 0);
335 }
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
static constexpr const int kPrescaleUndefined
static constexpr const std::array< const char *, 16 > tcdsTriggerTypes_
static constexpr unsigned int maxPhysicsTriggers
Definition: GlobalAlgBlk.h:52

◆ streamEndLuminosityBlockSummary()

void L1TriggerJSONMonitoring::streamEndLuminosityBlockSummary ( edm::StreamID  sid,
edm::LuminosityBlock const &  lumi,
edm::EventSetup const &  ,
L1TriggerJSONMonitoringData::lumisection lumidata 
) const
override

Definition at line 338 of file L1TriggerJSONMonitoring.cc.

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

341  {
342  auto const& stream = *streamCache(sid);
343  lumidata->processed.value()[0] += stream.processed;
344 
345  for (unsigned int i = 0; i < GlobalAlgBlk::maxPhysicsTriggers; ++i) {
346  lumidata->l1tAccept.value()[i] += stream.l1tAccept[i];
347  lumidata->l1tAcceptPhysics.value()[i] += stream.l1tAcceptPhysics[i];
348  lumidata->l1tAcceptCalibration.value()[i] += stream.l1tAcceptCalibration[i];
349  lumidata->l1tAcceptRandom.value()[i] += stream.l1tAcceptRandom[i];
350  }
351  for (unsigned int i = 0; i < tcdsTriggerTypes_.size(); ++i)
352  lumidata->tcdsAccept.value()[i] += stream.tcdsAccept[i];
353 
354  // check for conflicting values in the prescale column index
356  lumidata->prescaleIndex = stream.prescaleIndex;
357  else if (lumidata->prescaleIndex != stream.prescaleIndex)
359 }
jsoncollector::HistoJ< unsigned int > l1tAcceptRandom
static constexpr const int kPrescaleConflict
jsoncollector::HistoJ< unsigned int > l1tAccept
jsoncollector::HistoJ< unsigned int > l1tAcceptCalibration
jsoncollector::HistoJ< unsigned int > processed
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
std::vector< T > & value()
jsoncollector::HistoJ< unsigned int > tcdsAccept
static constexpr const int kPrescaleUndefined
jsoncollector::HistoJ< unsigned int > l1tAcceptPhysics
static constexpr const std::array< const char *, 16 > tcdsTriggerTypes_
static constexpr unsigned int maxPhysicsTriggers
Definition: GlobalAlgBlk.h:52

◆ writeIniFile()

void L1TriggerJSONMonitoring::writeIniFile ( L1TriggerJSONMonitoringData::run const &  rundata,
unsigned int  run,
std::vector< std::string > const &  l1TriggerNames 
)
staticprivate

Definition at line 475 of file L1TriggerJSONMonitoring.cc.

References jsoncollector::Json::arrayValue, L1TriggerJSONMonitoringData::run::baseRunDir, edm::EventAuxiliary::CalibrationTrigger, Skims_PA_cff::content, RawDataTask_cfi::eventTypes, geometryDiff::file, Skims_PA_cff::name, edm::EventAuxiliary::PhysicsTrigger, edm::EventAuxiliary::RandomTrigger, writedatasetfile::run, AlCaHLTBitMon_QueryRunRegistry::string, tcdsTriggerTypes_, L1TEGammaOffline_cfi::triggerNames, and convertToRaw::writer.

Referenced by globalBeginRun().

477  {
479 
481  for (auto const& name : l1TriggerNames)
482  triggerNames.append(name);
483  content["L1-Algo-Names"] = triggerNames;
484 
489  /* FIXME send information for all event types instead of only these three
490  for (auto const& name : tcdsTriggerTypes_)
491  eventTypes.append(name);
492  */
493  content["Event-Type"] = eventTypes;
494 
495  std::string iniFileName = fmt::sprintf("run%06d_ls0000_streamL1Rates_pid%05d.ini", run, getpid());
496  std::ofstream file(rundata.baseRunDir + "/" + iniFileName);
498  file << writer.write(content);
499  file.close();
500 }
Writes a Value in JSON format in a human friendly way.
Definition: writer.h:64
array value (ordered list)
Definition: value.h:32
static constexpr const std::array< const char *, 16 > tcdsTriggerTypes_
Represents a JSON value.
Definition: value.h:101

◆ writeJsdFile()

void L1TriggerJSONMonitoring::writeJsdFile ( L1TriggerJSONMonitoringData::run const &  rundata)
staticprivate

Definition at line 459 of file L1TriggerJSONMonitoring.cc.

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

Referenced by globalBeginRun().

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

Member Data Documentation

◆ l1tUtmTriggerMenuRcdToken_

const edm::ESGetToken<L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd> L1TriggerJSONMonitoring::l1tUtmTriggerMenuRcdToken_
private

Definition at line 156 of file L1TriggerJSONMonitoring.cc.

Referenced by globalBeginRun().

◆ level1Results_

const edm::InputTag L1TriggerJSONMonitoring::level1Results_
private

Definition at line 154 of file L1TriggerJSONMonitoring.cc.

Referenced by analyze().

◆ level1ResultsToken_

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

Definition at line 155 of file L1TriggerJSONMonitoring.cc.

Referenced by analyze().

◆ streamName_

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

Definition at line 148 of file L1TriggerJSONMonitoring.cc.

Referenced by globalBeginRun().

◆ tcdsTriggerTypes_

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

Definition at line 129 of file L1TriggerJSONMonitoring.cc.

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