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
 
- Public Member Functions inherited from edm::global::EDAnalyzerBase
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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 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 163 of file L1TriggerJSONMonitoring.cc.

163  :
164  level1Results_(config.getParameter<edm::InputTag>("L1Results")),
165  level1ResultsToken_(consumes<GlobalAlgBlkBxCollection>(level1Results_))
166 {
167 }
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 232 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_.

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()){
246  edm::LogError("L1TriggerJSONMonitoring") << "L1 trigger results with label [" + level1Results_.encode() + "] not present or invalid";
247  return;
248  }
249 
250  // The GlobalAlgBlkBxCollection is a vector of vectors, but the second layer can only ever
251  // have one entry since there can't be more than one collection per bunch crossing.
252  // The first "0" here means BX = 0, while the second "0" is used to access the first and only element.
253  auto const& results = handle->at(0, 0);
254  auto const& decision = results.getAlgoDecisionFinal();
255  assert (decision.size() == GlobalAlgBlk::maxPhysicsTriggers);
256 
257  // check the results for each HLT path
258  for (unsigned int i = 0; i < decision.size(); ++i) {
259  if (decision[i]) {
260  ++stream.l1tAccept[i];
261  switch (eventType) {
263  ++stream.l1tAcceptPhysics[i];
264  break;
266  ++stream.l1tAcceptCalibration[i];
267  break;
269  ++stream.l1tAcceptRandom[i];
270  break;
271  default:
272  break;
273  }
274  }
275  }
276 
277  // check for conflicting values in the prescale column index, and store it
278  int prescaleIndex = results.getPreScColumn();
279  if (stream.prescaleIndex == kPrescaleUndefined) {
280  stream.prescaleIndex = prescaleIndex;
281  } else if (stream.prescaleIndex == kPrescaleConflict) {
282  // do nothing
283  } else if (stream.prescaleIndex != prescaleIndex) {
284  edm::LogWarning("L1TriggerJSONMonitoring") <<
285  "Prescale index changed from " << stream.prescaleIndex << " to " << prescaleIndex << " inside lumisection " << event.luminosityBlock();
286  stream.prescaleIndex = kPrescaleConflict;
287  }
288 }
const edm::InputTag level1Results_
std::string encode() const
Definition: InputTag.cc:165
static const unsigned int maxPhysicsTriggers
Definition: GlobalAlgBlk.h:52
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 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 180 of file L1TriggerJSONMonitoring.cc.

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

Definition at line 171 of file L1TriggerJSONMonitoring.cc.

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

172 {
174  desc.add<edm::InputTag>("L1Results",edm::InputTag("hltGtStage2Digis"));
175  descriptions.add("L1TriggerJSONMonitoring", desc);
176 }
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 293 of file L1TriggerJSONMonitoring.cc.

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

294 {
295  // the API of jsoncollector::HistoJ does not really match our use case,
296  // but it is the only vector-like object available in JsonMonitorable.h
297  auto lumidata = std::make_shared<L1TriggerJSONMonitoringData::lumisection>(L1TriggerJSONMonitoringData::lumisection{
298  jsoncollector::HistoJ<unsigned int>(1), // processed
304  });
305  // repeated calls to `update` necessary to set the internal element counter
306  lumidata->processed.update(0);
307  for (unsigned int i = 0; i < GlobalAlgBlk::maxPhysicsTriggers; ++i) lumidata->l1tAccept.update(0);
308  for (unsigned int i = 0; i < GlobalAlgBlk::maxPhysicsTriggers; ++i) lumidata->l1tAcceptPhysics.update(0);
309  for (unsigned int i = 0; i < GlobalAlgBlk::maxPhysicsTriggers; ++i) lumidata->l1tAcceptCalibration.update(0);
310  for (unsigned int i = 0; i < GlobalAlgBlk::maxPhysicsTriggers; ++i) lumidata->l1tAcceptRandom.update(0);
311  for (unsigned int i = 0; i < tcdsTriggerTypes_.size(); ++i) lumidata->tcdsAccept.update(0);
312  lumidata->prescaleIndex = kPrescaleUndefined;
313 
314  return lumidata;
315 }
static const unsigned int maxPhysicsTriggers
Definition: GlobalAlgBlk.h:52
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 187 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, harvestTrackValidationPlots::str, writeIniFile(), and writeJsdFile().

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

Definition at line 358 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, edm::LuminosityBlockBase::run(), findQualityFiles::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.

359 {
360  unsigned int ls = lumi.luminosityBlock();
361  unsigned int run = lumi.run();
362 
363  bool writeFiles = true;
364  if (edm::Service<evf::MicroStateService>().isAvailable()) {
366  if (fms)
367  writeFiles = fms->shouldWriteFiles(ls);
368  }
369  if (not writeFiles)
370  return;
371 
372  unsigned int processed = lumidata->processed.value().at(0);
373  auto const& rundata = * runCache(lumi.getRun().index());
375 
376  // [SIC]
377  char hostname[33];
378  gethostname(hostname, 32);
379  std::string sourceHost(hostname);
380 
381  // [SIC]
382  std::stringstream sOutDef;
383  sOutDef << rundata.baseRunDir << "/" << "output_" << getpid() << ".jsd";
384 
385  std::string jsndataFileList = "";
386  unsigned int jsndataSize = 0;
387  unsigned int jsndataAdler32 = 1; // adler32 checksum for an empty file
388 
389  if (processed) {
390  // write the .jsndata files which contain the actual rates
391  Json::Value jsndata;
392  jsndata[jsoncollector::DataPoint::SOURCE] = sourceHost;
393  jsndata[jsoncollector::DataPoint::DEFINITION] = rundata.jsdFileName;
399 
400  // write only the number of "physics", "calibration" and "random" events
405  jsndata[jsoncollector::DataPoint::DATA].append(tcdsAccept.toJsonValue());
406  /* FIXME send information for all event types instead of only these three
407  jsndata[jsoncollector::DataPoint::DATA].append(lumidata->tcdsAccept.toJsonValue());
408  */
410 
411  auto jsndataFileName = boost::format("run%06d_ls%04d_streamL1Rates_pid%05d.jsndata") % run % ls % getpid();
412 
413  std::string result = writer.write(jsndata);
414  std::ofstream jsndataFile(rundata.baseRunDir + "/" + jsndataFileName.str());
415  jsndataFile << result;
416  jsndataFile.close();
417 
418  jsndataFileList = jsndataFileName.str();
419  jsndataSize = result.size();
420  jsndataAdler32 = cms::Adler32(result.c_str(), result.size());
421  }
422 
423  // create a metadata json file for the "HLT rates" pseudo-stream
424  unsigned int jsnProcessed = processed;
425  unsigned int jsnAccepted = processed;
426  unsigned int jsnErrorEvents = 0;
427  unsigned int jsnRetCodeMask = 0;
428  std::string jsnInputFiles = "";
429  unsigned int jsnHLTErrorEvents = 0;
430 
431  Json::Value jsn;
432  jsn[jsoncollector::DataPoint::SOURCE] = sourceHost;
433  jsn[jsoncollector::DataPoint::DEFINITION] = sOutDef.str();
434  jsn[jsoncollector::DataPoint::DATA].append(jsnProcessed);
435  jsn[jsoncollector::DataPoint::DATA].append(jsnAccepted);
436  jsn[jsoncollector::DataPoint::DATA].append(jsnErrorEvents);
437  jsn[jsoncollector::DataPoint::DATA].append(jsnRetCodeMask);
438  jsn[jsoncollector::DataPoint::DATA].append(jsndataFileList);
439  jsn[jsoncollector::DataPoint::DATA].append(jsndataSize);
440  jsn[jsoncollector::DataPoint::DATA].append(jsnInputFiles);
441  jsn[jsoncollector::DataPoint::DATA].append(jsndataAdler32);
442  jsn[jsoncollector::DataPoint::DATA].append(rundata.streamDestination);
443  jsn[jsoncollector::DataPoint::DATA].append(rundata.streamMergeType);
444  jsn[jsoncollector::DataPoint::DATA].append(jsnHLTErrorEvents);
445 
446  auto jsnFileName = boost::format("run%06d_ls%04d_streamL1Rates_pid%05d.jsn") % run % ls % getpid();
447  std::ofstream jsnFile( rundata.baseRunDir + "/" + jsnFileName.str() );
448  jsnFile << writer.write(jsn);
449  jsnFile.close();
450 }
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:348
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 226 of file L1TriggerJSONMonitoring.cc.

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

Definition at line 319 of file L1TriggerJSONMonitoring.cc.

References kPrescaleUndefined, GlobalAlgBlk::maxPhysicsTriggers, and tcdsTriggerTypes_.

320 {
321  auto & stream = * streamCache(sid);
322 
323  // reset the stream counters
324  stream.processed = 0;
325  stream.l1tAccept.assign(GlobalAlgBlk::maxPhysicsTriggers, 0);
326  stream.l1tAcceptPhysics.assign(GlobalAlgBlk::maxPhysicsTriggers, 0);
327  stream.l1tAcceptCalibration.assign(GlobalAlgBlk::maxPhysicsTriggers, 0);
328  stream.l1tAcceptRandom.assign(GlobalAlgBlk::maxPhysicsTriggers, 0);
329  stream.tcdsAccept.assign(tcdsTriggerTypes_.size(), 0);
330  stream.prescaleIndex = kPrescaleUndefined;
331 }
static const unsigned int maxPhysicsTriggers
Definition: GlobalAlgBlk.h:52
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 335 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().

336 {
337  auto const& stream = * streamCache(sid);
338  lumidata->processed.value()[0] += stream.processed;
339 
340  for (unsigned int i = 0; i < GlobalAlgBlk::maxPhysicsTriggers; ++i) {
341  lumidata->l1tAccept.value()[i] += stream.l1tAccept[i];
342  lumidata->l1tAcceptPhysics.value()[i] += stream.l1tAcceptPhysics[i];
343  lumidata->l1tAcceptCalibration.value()[i] += stream.l1tAcceptCalibration[i];
344  lumidata->l1tAcceptRandom.value()[i] += stream.l1tAcceptRandom[i];
345  }
346  for (unsigned int i = 0; i < tcdsTriggerTypes_.size(); ++i)
347  lumidata->tcdsAccept.value()[i] += stream.tcdsAccept[i];
348 
349  // check for conflicting values in the prescale column index
350  if (lumidata->prescaleIndex == kPrescaleUndefined)
351  lumidata->prescaleIndex = stream.prescaleIndex;
352  else if (lumidata->prescaleIndex != stream.prescaleIndex)
353  lumidata->prescaleIndex = kPrescaleConflict;
354 }
jsoncollector::HistoJ< unsigned int > l1tAcceptRandom
jsoncollector::HistoJ< unsigned int > l1tAccept
jsoncollector::HistoJ< unsigned int > l1tAcceptCalibration
jsoncollector::HistoJ< unsigned int > processed
static const unsigned int maxPhysicsTriggers
Definition: GlobalAlgBlk.h:52
std::vector< T > & value()
jsoncollector::HistoJ< unsigned int > tcdsAccept
jsoncollector::HistoJ< unsigned int > l1tAcceptPhysics
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 471 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, harvestTrackValidationPlots::str, AlCaHLTBitMon_QueryRunRegistry::string, tcdsTriggerTypes_, Json::StyledWriter::write(), and cscNeutronWriter_cfi::writer.

Referenced by globalBeginRun().

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

Definition at line 453 of file L1TriggerJSONMonitoring.cc.

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

Referenced by globalBeginRun().

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

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 154 of file L1TriggerJSONMonitoring.cc.

Referenced by analyze().

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

Definition at line 155 of file L1TriggerJSONMonitoring.cc.

Referenced by analyze().

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

Definition at line 148 of file L1TriggerJSONMonitoring.cc.

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