CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Public Attributes
HLTriggerJSONMonitoring Class Reference

#include <HLTriggerJSONMonitoring.h>

Inheritance diagram for HLTriggerJSONMonitoring:
edm::stream::EDAnalyzer< edm::RunCache< hltJson::runVars >, edm::LuminosityBlockSummaryCache< hltJson::lumiVars > > edm::stream::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (edm::Event const &, edm::EventSetup const &)
 
void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
 
void beginRun (edm::Run const &, edm::EventSetup const &)
 
void endLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, hltJson::lumiVars *) const
 
 HLTriggerJSONMonitoring (const edm::ParameterSet &)
 
void resetLumi ()
 
void resetRun (bool changed)
 
void writeHLTDefJson (std::string path)
 
 ~HLTriggerJSONMonitoring ()
 
- Public Member Functions inherited from edm::stream::EDAnalyzer< edm::RunCache< hltJson::runVars >, edm::LuminosityBlockSummaryCache< hltJson::lumiVars > >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::stream::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
static std::shared_ptr
< hltJson::lumiVars
globalBeginLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
 
static std::shared_ptr
< hltJson::runVars
globalBeginRun (edm::Run const &, edm::EventSetup const &, void const *)
 
static void globalEndLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *, hltJson::lumiVars *)
 
static void globalEndRun (edm::Run const &iRun, edm::EventSetup const &, RunContext const *iContext)
 
- Static Public Member Functions inherited from edm::stream::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Public Attributes

std::string baseRunDir_
 
std::vector< std::vector
< std::string > > 
datasetContents_
 
std::vector< std::string > datasetNames_
 
std::vector< unsigned int > hltAccept_
 
HLTConfigProvider hltConfig_
 
std::vector< unsigned int > hltDatasets_
 
std::vector< unsigned int > hltErrors_
 
std::vector< std::vector
< unsigned int > > 
hltIndex_
 
std::vector< unsigned int > hltL1s_
 
std::vector< std::string > hltNames_
 
std::vector< unsigned int > hltPre_
 
std::vector< unsigned int > hltReject_
 
std::vector< unsigned int > hltWasRun_
 
std::vector< int > posL1s_
 
std::vector< int > posPre_
 
unsigned int processed_
 
std::string stHltJsd_
 
edm::InputTag triggerResults_
 
edm::EDGetTokenT
< edm::TriggerResults
triggerResultsToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDAnalyzer< edm::RunCache< hltJson::runVars >, edm::LuminosityBlockSummaryCache< hltJson::lumiVars > >
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDAnalyzerBase
typedef EDAnalyzerAdaptorBase 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 prints JSON files with HLT info.

Created: Fri, 11 Mar 2016

Author
Aram Avetisyan

See header file for documentation

Author
Aram Avetisyan

Definition at line 65 of file HLTriggerJSONMonitoring.h.

Constructor & Destructor Documentation

HLTriggerJSONMonitoring::HLTriggerJSONMonitoring ( const edm::ParameterSet ps)
explicit

Definition at line 24 of file HLTriggerJSONMonitoring.cc.

24  :
25  triggerResults_(ps.getParameter<edm::InputTag>("triggerResults")),
26  triggerResultsToken_(consumes<edm::TriggerResults>(triggerResults_))
27 {
28 
29 
30 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
HLTriggerJSONMonitoring::~HLTriggerJSONMonitoring ( )

Definition at line 32 of file HLTriggerJSONMonitoring.cc.

33 {
34 }

Member Function Documentation

void HLTriggerJSONMonitoring::analyze ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup 
)
virtual

Implements edm::stream::EDAnalyzerBase.

Definition at line 44 of file HLTriggerJSONMonitoring.cc.

References edm::InputTag::encode(), edm::Event::getByToken(), hltAccept_, hltDatasets_, hltErrors_, hltIndex_, hltL1s_, hltNames_, hltPre_, hltReject_, hltWasRun_, i, cmsHarvester::index, LogDebug, gen::n, or, AlCaHLTBitMon_ParallelJobs::p, posL1s_, posPre_, processed_, triggerResults_, and triggerResultsToken_.

45 {
46 
47  using namespace std;
48  using namespace edm;
49 
50  processed_++;
51 
52  //Get hold of TriggerResults
54  if (not iEvent.getByToken(triggerResultsToken_, HLTR) or not HLTR.isValid()){
55  LogDebug("HLTriggerJSONMonitoring") << "HLT TriggerResults with label ["+triggerResults_.encode()+"] not found!" << std::endl;
56  return;
57  }
58 
59  //Decision for each HLT path
60  const unsigned int n(hltNames_.size());
61  for (unsigned int i=0; i<n; i++) {
62  if (HLTR->wasrun(i)) hltWasRun_[i]++;
63  if (HLTR->accept(i)) hltAccept_[i]++;
64  if (HLTR->wasrun(i) && !HLTR->accept(i)) hltReject_[i]++;
65  if (HLTR->error(i)) hltErrors_[i]++;
66  //Count L1 seeds and Prescales
67  const int index(static_cast<int>(HLTR->index(i)));
68  if (HLTR->accept(i)) {
69  if (index >= posL1s_[i]) hltL1s_[i]++;
70  if (index >= posPre_[i]) hltPre_[i]++;
71  } else {
72  if (index > posL1s_[i]) hltL1s_[i]++;
73  if (index > posPre_[i]) hltPre_[i]++;
74  }
75  }
76 
77  //Decision for each HLT dataset
78  std::vector<bool> acceptedByDS(hltIndex_.size(), false);
79  for (unsigned int ds=0; ds < hltIndex_.size(); ds++) { // ds = index of dataset
80  for (unsigned int p=0; p<hltIndex_[ds].size(); p++) { // p = index of path with dataset ds
81  if (acceptedByDS[ds]>0 || HLTR->accept(hltIndex_[ds][p]) ) {
82  acceptedByDS[ds] = true;
83  }
84  }
85  if (acceptedByDS[ds]) hltDatasets_[ds]++;
86  }
87 
88 }//End analyze function
#define LogDebug(id)
std::vector< std::string > hltNames_
int i
Definition: DBlmapReader.cc:9
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
std::vector< unsigned int > hltDatasets_
std::vector< unsigned int > hltPre_
std::vector< unsigned int > hltAccept_
std::vector< unsigned int > hltReject_
std::string encode() const
Definition: InputTag.cc:164
std::vector< std::vector< unsigned int > > hltIndex_
int iEvent
Definition: GenABIO.cc:230
std::vector< unsigned int > hltL1s_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
std::vector< unsigned int > hltWasRun_
std::vector< unsigned int > hltErrors_
void HLTriggerJSONMonitoring::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &  iSetup 
)
virtual

Reimplemented from edm::stream::EDAnalyzerBase.

Definition at line 230 of file HLTriggerJSONMonitoring.cc.

References resetLumi().

void HLTriggerJSONMonitoring::beginRun ( edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
)
virtual

Reimplemented from edm::stream::EDAnalyzerBase.

Definition at line 168 of file HLTriggerJSONMonitoring.cc.

References Json::Value::append(), Json::arrayValue, baseRunDir_, datasetNames_, hltConfig_, hltNames_, HLTConfigProvider::init(), LogDebug, edm::InputTag::process(), resetRun(), mps_fire::result, edm::RunBase::run(), stHltJsd_, AlCaHLTBitMon_QueryRunRegistry::string, triggerResults_, interactiveExample::ui, Json::StyledWriter::write(), and writeHLTDefJson().

169 {
170  //Get the run directory from the EvFDaqDirector
172  else baseRunDir_ = ".";
173 
174  std::string monPath = baseRunDir_ + "/";
175 
176  //Initialize hltConfig_
177  bool changed = true;
178  if (hltConfig_.init(iRun, iSetup, triggerResults_.process(), changed)) resetRun(changed);
179  else{
180  LogDebug("HLTriggerJSONMonitoring") << "HLTConfigProvider initialization failed!" << std::endl;
181  return;
182  }
183 
184  //Write the once-per-run files if not already written
185  //Eventually must rewrite this with proper multithreading (i.e. globalBeginRun)
186  bool expected = false;
187  if( runCache()->wroteFiles.compare_exchange_strong(expected, true) ){
188  runCache()->wroteFiles = true;
189 
190  unsigned int nRun = iRun.run();
191 
192  //Create definition file for HLT Rates
193  std::stringstream ssHltJsd;
194  ssHltJsd << "run" << std::setfill('0') << std::setw(6) << nRun << "_ls0000";
195  ssHltJsd << "_streamHLTRates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsd";
196  stHltJsd_ = ssHltJsd.str();
197 
199 
200  //Write ini files
201  //HLT
202  Json::Value hltIni;
203  Json::StyledWriter writer;
204 
205  Json::Value hltNamesVal(Json::arrayValue);
206  for (unsigned int ui = 0; ui < hltNames_.size(); ui++){
207  hltNamesVal.append(hltNames_.at(ui));
208  }
209 
210  Json::Value datasetNamesVal(Json::arrayValue);
211  for (unsigned int ui = 0; ui < datasetNames_.size(); ui++){
212  datasetNamesVal.append(datasetNames_.at(ui));
213  }
214 
215  hltIni["Path-Names"] = hltNamesVal;
216  hltIni["Dataset-Names"] = datasetNamesVal;
217 
218  std::string && result = writer.write(hltIni);
219 
220  std::stringstream ssHltIni;
221  ssHltIni << "run" << std::setfill('0') << std::setw(6) << nRun << "_ls0000_streamHLTRates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".ini";
222 
223  std::ofstream outHltIni( monPath + ssHltIni.str() );
224  outHltIni<<result;
225  outHltIni.close();
226  }
227 
228 }//End beginRun function
#define LogDebug(id)
std::vector< std::string > hltNames_
Represents a JSON value.
Definition: value.h:111
tuple result
Definition: mps_fire.py:95
virtual std::string write(const Value &root)
Serialize a Value in JSON format.
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
std::vector< std::string > datasetNames_
std::string const & process() const
Definition: InputTag.h:40
void writeHLTDefJson(std::string path)
Writes a Value in JSON format in a human friendly way.
Definition: writer.h:65
array value (ordered list)
Definition: value.h:31
void HLTriggerJSONMonitoring::endLuminosityBlockSummary ( edm::LuminosityBlock const &  iLumi,
edm::EventSetup const &  iEventSetup,
hltJson::lumiVars iSummary 
) const

Definition at line 258 of file HLTriggerJSONMonitoring.cc.

References hltJson::lumiVars::baseRunDir, baseRunDir_, hltJson::lumiVars::hltAccept, hltAccept_, hltJson::lumiVars::hltDatasets, hltDatasets_, hltJson::lumiVars::hltErrors, hltErrors_, hltJson::lumiVars::hltL1s, hltL1s_, hltJson::lumiVars::hltPre, hltPre_, hltJson::lumiVars::hltReject, hltReject_, hltJson::lumiVars::hltWasRun, hltWasRun_, hltJson::lumiVars::processed, processed_, hltJson::lumiVars::stHltJsd, stHltJsd_, hltJson::lumiVars::streamHLTDestination, interactiveExample::ui, jsoncollector::HistoJ< T >::update(), and jsoncollector::HistoJ< T >::value().

258  {
259 
260  //Whichever stream gets there first does the initialiazation
261  if (iSummary->hltWasRun->value().size() == 0){
262  iSummary->processed->update(processed_);
263 
264  for (unsigned int ui = 0; ui < hltWasRun_.size(); ui++){
265  iSummary->hltWasRun->update(hltWasRun_.at(ui));
266  iSummary->hltL1s ->update(hltL1s_ .at(ui));
267  iSummary->hltPre ->update(hltPre_ .at(ui));
268  iSummary->hltAccept->update(hltAccept_.at(ui));
269  iSummary->hltReject->update(hltReject_.at(ui));
270  iSummary->hltErrors->update(hltErrors_.at(ui));
271  }
272  for (unsigned int ui = 0; ui < hltDatasets_.size(); ui++){
273  iSummary->hltDatasets->update(hltDatasets_.at(ui));
274  }
275 
276  iSummary->stHltJsd = stHltJsd_;
277  iSummary->baseRunDir = baseRunDir_;
278 
279  iSummary->streamHLTDestination = runCache()->streamHLTDestination;
280  }
281 
282  else{
283  iSummary->processed->value().at(0) += processed_;
284 
285  for (unsigned int ui = 0; ui < hltWasRun_.size(); ui++){
286  iSummary->hltWasRun->value().at(ui) += hltWasRun_.at(ui);
287  iSummary->hltL1s ->value().at(ui) += hltL1s_ .at(ui);
288  iSummary->hltPre ->value().at(ui) += hltPre_ .at(ui);
289  iSummary->hltAccept->value().at(ui) += hltAccept_.at(ui);
290  iSummary->hltReject->value().at(ui) += hltReject_.at(ui);
291  iSummary->hltErrors->value().at(ui) += hltErrors_.at(ui);
292  }
293  for (unsigned int ui = 0; ui < hltDatasets_.size(); ui++){
294  iSummary->hltDatasets->value().at(ui) += hltDatasets_.at(ui);
295  }
296  }
297 
298 }//End endLuminosityBlockSummary function
jsoncollector::HistoJ< unsigned int > * hltAccept
std::vector< unsigned int > hltDatasets_
std::vector< unsigned int > hltPre_
std::vector< unsigned int > hltAccept_
std::vector< unsigned int > hltReject_
jsoncollector::HistoJ< unsigned int > * hltWasRun
std::vector< T > & value()
jsoncollector::HistoJ< unsigned int > * hltDatasets
std::vector< unsigned int > hltL1s_
jsoncollector::HistoJ< unsigned int > * hltPre
std::vector< unsigned int > hltWasRun_
jsoncollector::HistoJ< unsigned int > * hltErrors
jsoncollector::HistoJ< unsigned int > * processed
std::vector< unsigned int > hltErrors_
jsoncollector::HistoJ< unsigned int > * hltL1s
jsoncollector::HistoJ< unsigned int > * hltReject
void HLTriggerJSONMonitoring::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 37 of file HLTriggerJSONMonitoring.cc.

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

37  {
39  desc.add<edm::InputTag>("triggerResults",edm::InputTag("TriggerResults","","HLT"));
40  descriptions.add("HLTriggerJSONMonitoring", desc);
41 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::shared_ptr< hltJson::lumiVars > HLTriggerJSONMonitoring::globalBeginLuminosityBlockSummary ( edm::LuminosityBlock const &  iLumi,
edm::EventSetup const &  iSetup,
LuminosityBlockContext const *  iContext 
)
static

Definition at line 233 of file HLTriggerJSONMonitoring.cc.

234 {
235  std::shared_ptr<hltJson::lumiVars> iSummary(new hltJson::lumiVars);
236 
237  unsigned int MAXPATHS = 1000;
238 
239  iSummary->processed = new HistoJ<unsigned int>(1, 1);
240 
241  iSummary->hltWasRun = new HistoJ<unsigned int>(1, MAXPATHS);
242  iSummary->hltL1s = new HistoJ<unsigned int>(1, MAXPATHS);
243  iSummary->hltPre = new HistoJ<unsigned int>(1, MAXPATHS);
244  iSummary->hltAccept = new HistoJ<unsigned int>(1, MAXPATHS);
245  iSummary->hltReject = new HistoJ<unsigned int>(1, MAXPATHS);
246  iSummary->hltErrors = new HistoJ<unsigned int>(1, MAXPATHS);
247 
248  iSummary->hltDatasets = new HistoJ<unsigned int>(1, MAXPATHS);
249 
250  iSummary->baseRunDir = "";
251  iSummary->stHltJsd = "";
252  iSummary->streamHLTDestination = "";
253 
254  return iSummary;
255 }//End globalBeginLuminosityBlockSummary function
static std::shared_ptr<hltJson::runVars> HLTriggerJSONMonitoring::globalBeginRun ( edm::Run const &  ,
edm::EventSetup const &  ,
void const *   
)
inlinestatic

Definition at line 78 of file HLTriggerJSONMonitoring.h.

78  {
79  std::shared_ptr<hltJson::runVars> rv(new hltJson::runVars);
80  if (edm::Service<evf::EvFDaqDirector>().isAvailable()) {
81  rv->streamHLTDestination = edm::Service<evf::EvFDaqDirector>()->getStreamDestinations("streamHLTRates");
82  }
83  rv->wroteFiles = false;
84  return rv;
85  }
void HLTriggerJSONMonitoring::globalEndLuminosityBlockSummary ( edm::LuminosityBlock const &  iLumi,
edm::EventSetup const &  iSetup,
LuminosityBlockContext const *  iContext,
hltJson::lumiVars iSummary 
)
static

Definition at line 302 of file HLTriggerJSONMonitoring.cc.

References cms::Adler32(), Json::Value::append(), hltJson::lumiVars::baseRunDir, cscdqm::DATA, hltJson::lumiVars::hltAccept, hltJson::lumiVars::hltDatasets, hltJson::lumiVars::hltErrors, hltJson::lumiVars::hltL1s, hltJson::lumiVars::hltPre, hltJson::lumiVars::hltReject, hltJson::lumiVars::hltWasRun, edm::LuminosityBlockBase::luminosityBlock(), hltJson::lumiVars::processed, mps_fire::result, edm::LuminosityBlockBase::run(), evf::FastMonitoringService::shouldWriteFiles(), runonSM::SOURCE, hltJson::lumiVars::stHltJsd, hltJson::lumiVars::streamHLTDestination, AlCaHLTBitMon_QueryRunRegistry::string, jsoncollector::HistoJ< T >::toJsonValue(), jsoncollector::StringJ::update(), jsoncollector::IntJ::value(), jsoncollector::StringJ::value(), jsoncollector::HistoJ< T >::value(), and Json::StyledWriter::write().

303 {
304 
305  unsigned int iLs = iLumi.luminosityBlock();
306  unsigned int iRun = iLumi.run();
307 
308  bool writeFiles=true;
309  if (edm::Service<evf::MicroStateService>().isAvailable()) {
311  if (fms) {
312  writeFiles = fms->shouldWriteFiles(iLumi.luminosityBlock());
313  }
314  }
315 
316  if (writeFiles) {
317  Json::StyledWriter writer;
318 
319  char hostname[33];
320  gethostname(hostname,32);
321  std::string sourceHost(hostname);
322 
323  //Get the output directory
324  std::string monPath = iSummary->baseRunDir + "/";
325 
326  std::stringstream sOutDef;
327  sOutDef << monPath << "output_" << getpid() << ".jsd";
328 
329  //Write the .jsndata files which contain the actual rates
330  //HLT .jsndata file
331  Json::Value hltJsnData;
332  hltJsnData[DataPoint::SOURCE] = sourceHost;
333  hltJsnData[DataPoint::DEFINITION] = iSummary->stHltJsd;
334 
335  hltJsnData[DataPoint::DATA].append(iSummary->processed->toJsonValue());
336  hltJsnData[DataPoint::DATA].append(iSummary->hltWasRun->toJsonValue());
337  hltJsnData[DataPoint::DATA].append(iSummary->hltL1s ->toJsonValue());
338  hltJsnData[DataPoint::DATA].append(iSummary->hltPre ->toJsonValue());
339  hltJsnData[DataPoint::DATA].append(iSummary->hltAccept->toJsonValue());
340  hltJsnData[DataPoint::DATA].append(iSummary->hltReject->toJsonValue());
341  hltJsnData[DataPoint::DATA].append(iSummary->hltErrors->toJsonValue());
342 
343  hltJsnData[DataPoint::DATA].append(iSummary->hltDatasets->toJsonValue());
344 
345  std::string && result = writer.write(hltJsnData);
346 
347  std::stringstream ssHltJsnData;
348  ssHltJsnData << "run" << std::setfill('0') << std::setw(6) << iRun << "_ls" << std::setfill('0') << std::setw(4) << iLs;
349  ssHltJsnData << "_streamHLTRates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsndata";
350 
351  if (iSummary->processed->value().at(0)!=0) {
352  std::ofstream outHltJsnData( monPath + ssHltJsnData.str() );
353  outHltJsnData<<result;
354  outHltJsnData.close();
355  }
356 
357  //HLT jsn entries
358  StringJ hltJsnFilelist;
359  IntJ hltJsnFilesize = 0;
360  unsigned int hltJsnFileAdler32 = 1;
361  if (iSummary->processed->value().at(0)!=0) {
362  hltJsnFilelist.update(ssHltJsnData.str());
363  hltJsnFilesize = result.size();
364  hltJsnFileAdler32 = cms::Adler32(result.c_str(),result.size());
365  }
366  StringJ hltJsnInputFiles;
367  hltJsnInputFiles.update("");
368 
369  //Create special DAQ JSON file for L1 and HLT rates pseudo-streams
370  //Only three variables are different between the files:
371  //the file list, the file size and the Adler32 value
372  IntJ daqJsnProcessed = iSummary->processed->value().at(0);
373  IntJ daqJsnAccepted = daqJsnProcessed;
374  IntJ daqJsnErrorEvents = 0;
375  IntJ daqJsnRetCodeMask = 0;
376  IntJ daqJsnHLTErrorEvents = 0;
377 
378  //write out HLT metadata jsn
379  Json::Value hltDaqJsn;
380  hltDaqJsn[DataPoint::SOURCE] = sourceHost;
381  hltDaqJsn[DataPoint::DEFINITION] = sOutDef.str();
382 
383  hltDaqJsn[DataPoint::DATA].append((unsigned int)daqJsnProcessed.value());
384  hltDaqJsn[DataPoint::DATA].append((unsigned int)daqJsnAccepted.value());
385  hltDaqJsn[DataPoint::DATA].append((unsigned int)daqJsnErrorEvents.value());
386  hltDaqJsn[DataPoint::DATA].append((unsigned int)daqJsnRetCodeMask.value());
387  hltDaqJsn[DataPoint::DATA].append(hltJsnFilelist.value());
388  hltDaqJsn[DataPoint::DATA].append((unsigned int)hltJsnFilesize.value());
389  hltDaqJsn[DataPoint::DATA].append(hltJsnInputFiles.value());
390  hltDaqJsn[DataPoint::DATA].append(hltJsnFileAdler32);
391  hltDaqJsn[DataPoint::DATA].append(iSummary->streamHLTDestination);
392  hltDaqJsn[DataPoint::DATA].append((unsigned int)daqJsnHLTErrorEvents.value());
393 
394  result = writer.write(hltDaqJsn);
395 
396  std::stringstream ssHltDaqJsn;
397  ssHltDaqJsn << "run" << std::setfill('0') << std::setw(6) << iRun << "_ls" << std::setfill('0') << std::setw(4) << iLs;
398  ssHltDaqJsn << "_streamHLTRates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsn";
399 
400  std::ofstream outHltDaqJsn( monPath + ssHltDaqJsn.str() );
401  outHltDaqJsn<<result;
402  outHltDaqJsn.close();
403  }
404 
405  //Delete the individual HistoJ pointers
406  delete iSummary->processed;
407 
408  delete iSummary->hltWasRun;
409  delete iSummary->hltL1s ;
410  delete iSummary->hltPre ;
411  delete iSummary->hltAccept;
412  delete iSummary->hltReject;
413  delete iSummary->hltErrors;
414 
415  delete iSummary->hltDatasets;
416 
417  //Note: Do not delete the iSummary pointer. The framework does something with it later on
418  // and deleting it results in a segmentation fault.
419 
420  //Reninitalize HistoJ pointers to nullptr
421  iSummary->processed = nullptr;
422 
423  iSummary->hltWasRun = nullptr;
424  iSummary->hltL1s = nullptr;
425  iSummary->hltPre = nullptr;
426  iSummary->hltAccept = nullptr;
427  iSummary->hltReject = nullptr;
428  iSummary->hltErrors = nullptr;
429 
430  iSummary->hltDatasets = nullptr;
431 
432 }//End globalEndLuminosityBlockSummary function
jsoncollector::HistoJ< unsigned int > * hltAccept
bool shouldWriteFiles(unsigned int lumi, unsigned int *proc=0)
Value & append(const Value &value)
Append value to array at the end.
void update(std::string const &newStr)
Represents a JSON value.
Definition: value.h:111
jsoncollector::HistoJ< unsigned int > * hltWasRun
virtual Json::Value toJsonValue() const
std::vector< T > & value()
tuple result
Definition: mps_fire.py:95
jsoncollector::HistoJ< unsigned int > * hltDatasets
virtual std::string write(const Value &root)
Serialize a Value in JSON format.
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
jsoncollector::HistoJ< unsigned int > * hltPre
jsoncollector::HistoJ< unsigned int > * hltErrors
jsoncollector::HistoJ< unsigned int > * processed
Writes a Value in JSON format in a human friendly way.
Definition: writer.h:65
jsoncollector::HistoJ< unsigned int > * hltL1s
jsoncollector::HistoJ< unsigned int > * hltReject
string SOURCE
Definition: runonSM.py:23
static void HLTriggerJSONMonitoring::globalEndRun ( edm::Run const &  iRun,
edm::EventSetup const &  ,
RunContext const *  iContext 
)
inlinestatic

Definition at line 87 of file HLTriggerJSONMonitoring.h.

87 { }
void HLTriggerJSONMonitoring::resetLumi ( )

Definition at line 147 of file HLTriggerJSONMonitoring.cc.

References hltAccept_, hltDatasets_, hltErrors_, hltL1s_, hltPre_, hltReject_, hltWasRun_, i, and processed_.

Referenced by beginLuminosityBlock(), and resetRun().

147  {
148  //Reset total number of events
149  processed_ = 0;
150 
151  //Reset per-path counters
152  for (unsigned int i = 0; i < hltWasRun_.size(); i++) {
153  hltWasRun_[i] = 0;
154  hltL1s_[i] = 0;
155  hltPre_[i] = 0;
156  hltAccept_[i] = 0;
157  hltReject_[i] = 0;
158  hltErrors_[i] = 0;
159  }
160  //Reset per-dataset counter
161  for (unsigned int i = 0; i < hltDatasets_.size(); i++) {
162  hltDatasets_[i] = 0;
163  }
164 
165 }//End resetLumi function
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned int > hltDatasets_
std::vector< unsigned int > hltPre_
std::vector< unsigned int > hltAccept_
std::vector< unsigned int > hltReject_
std::vector< unsigned int > hltL1s_
std::vector< unsigned int > hltWasRun_
std::vector< unsigned int > hltErrors_
void HLTriggerJSONMonitoring::resetRun ( bool  changed)

Definition at line 91 of file HLTriggerJSONMonitoring.cc.

References ztail::d, HLTConfigProvider::datasetContents(), datasetContents_, HLTConfigProvider::datasetNames(), datasetNames_, hltAccept_, hltConfig_, hltDatasets_, hltErrors_, hltIndex_, hltL1s_, hltNames_, hltPre_, hltReject_, hltWasRun_, i, j, diffTwoXMLs::label, HLTConfigProvider::moduleLabels(), HLTConfigProvider::moduleType(), gen::n, AlCaHLTBitMon_ParallelJobs::p, posL1s_, posPre_, resetLumi(), findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, HLTConfigProvider::triggerIndex(), and HLTConfigProvider::triggerNames().

Referenced by beginRun().

91  {
92 
93  //Update trigger and dataset names, clear L1 names and counters
94  if (changed){
98  }
99 
100  const unsigned int n = hltNames_.size();
101  const unsigned int d = datasetNames_.size();
102 
103  if (changed) {
104  //Resize per-path counters
105  hltWasRun_.resize(n);
106  hltL1s_.resize(n);
107  hltPre_.resize(n);
108  hltAccept_.resize(n);
109  hltReject_.resize(n);
110  hltErrors_.resize(n);
111 
112  //Resize per-dataset counter
113  hltDatasets_.resize(d);
114  //Resize htlIndex
115  hltIndex_.resize(d);
116  //Set-up hltIndex
117  for (unsigned int ds = 0; ds < d; ds++) {
118  unsigned int size = datasetContents_[ds].size();
119  hltIndex_[ds].reserve(size);
120  for (unsigned int p = 0; p < size; p++) {
121  unsigned int i = hltConfig_.triggerIndex(datasetContents_[ds][p]);
122  if (i<n) {
123  hltIndex_[ds].push_back(i);
124  }
125  }
126  }
127  //Find the positions of seeding and prescaler modules
128  posL1s_.resize(n);
129  posPre_.resize(n);
130  for (unsigned int i = 0; i < n; ++i) {
131  posL1s_[i] = -1;
132  posPre_[i] = -1;
133  const std::vector<std::string> & moduleLabels(hltConfig_.moduleLabels(i));
134  for (unsigned int j = 0; j < moduleLabels.size(); ++j) {
135  const std::string & label = hltConfig_.moduleType(moduleLabels[j]);
136  if (label == "HLTLevel1GTSeed")
137  posL1s_[i] = j;
138  else if (label == "HLTPrescaler")
139  posPre_[i] = j;
140  }
141  }
142  }
143  resetLumi();
144 }//End resetRun function
std::vector< std::string > hltNames_
int i
Definition: DBlmapReader.cc:9
const std::string moduleType(const std::string &module) const
C++ class name of module.
std::vector< unsigned int > hltDatasets_
const std::vector< std::string > & triggerNames() const
names of trigger paths
std::vector< unsigned int > hltPre_
std::vector< unsigned int > hltAccept_
std::vector< unsigned int > hltReject_
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
tuple d
Definition: ztail.py:151
std::vector< std::vector< unsigned int > > hltIndex_
int j
Definition: DBlmapReader.cc:9
std::vector< unsigned int > hltL1s_
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
std::vector< std::string > datasetNames_
std::vector< unsigned int > hltWasRun_
const std::vector< std::vector< std::string > > & datasetContents() const
names of trigger paths for all datasets
std::vector< unsigned int > hltErrors_
tuple size
Write out results.
const std::vector< std::string > & datasetNames() const
std::vector< std::vector< std::string > > datasetContents_
void HLTriggerJSONMonitoring::writeHLTDefJson ( std::string  path)

Definition at line 436 of file HLTriggerJSONMonitoring.cc.

References timingPdfMaker::outfile.

Referenced by beginRun().

436  {
437 
438  std::ofstream outfile( path );
439  outfile << "{" << std::endl;
440  outfile << " \"data\" : [" << std::endl;
441  outfile << " {" ;
442  outfile << " \"name\" : \"Processed\"," ; //***
443  outfile << " \"type\" : \"integer\"," ;
444  outfile << " \"operation\" : \"histo\"}," << std::endl;
445 
446  outfile << " {" ;
447  outfile << " \"name\" : \"Path-WasRun\"," ;
448  outfile << " \"type\" : \"integer\"," ;
449  outfile << " \"operation\" : \"histo\"}," << std::endl;
450 
451  outfile << " {" ;
452  outfile << " \"name\" : \"Path-AfterL1Seed\"," ;
453  outfile << " \"type\" : \"integer\"," ;
454  outfile << " \"operation\" : \"histo\"}," << std::endl;
455 
456  outfile << " {" ;
457  outfile << " \"name\" : \"Path-AfterPrescale\"," ;
458  outfile << " \"type\" : \"integer\"," ;
459  outfile << " \"operation\" : \"histo\"}," << std::endl;
460 
461  outfile << " {" ;
462  outfile << " \"name\" : \"Path-Accepted\"," ;
463  outfile << " \"type\" : \"integer\"," ;
464  outfile << " \"operation\" : \"histo\"}," << std::endl;
465 
466  outfile << " {" ;
467  outfile << " \"name\" : \"Path-Rejected\"," ;
468  outfile << " \"type\" : \"integer\"," ;
469  outfile << " \"operation\" : \"histo\"}," << std::endl;
470 
471  outfile << " {" ;
472  outfile << " \"name\" : \"Path-Errors\"," ;
473  outfile << " \"type\" : \"integer\"," ;
474  outfile << " \"operation\" : \"histo\"}," << std::endl;
475 
476  outfile << " {" ;
477  outfile << " \"name\" : \"Dataset-Accepted\"," ;
478  outfile << " \"type\" : \"integer\"," ;
479  outfile << " \"operation\" : \"histo\"}" << std::endl;
480 
481  outfile << " ]" << std::endl;
482  outfile << "}" << std::endl;
483 
484  outfile.close();
485 }//End writeHLTDefJson function

Member Data Documentation

std::string HLTriggerJSONMonitoring::baseRunDir_

Definition at line 117 of file HLTriggerJSONMonitoring.h.

Referenced by beginRun(), and endLuminosityBlockSummary().

std::vector<std::vector<std::string> > HLTriggerJSONMonitoring::datasetContents_

Definition at line 123 of file HLTriggerJSONMonitoring.h.

Referenced by resetRun().

std::vector<std::string> HLTriggerJSONMonitoring::datasetNames_

Definition at line 122 of file HLTriggerJSONMonitoring.h.

Referenced by beginRun(), and resetRun().

std::vector<unsigned int> HLTriggerJSONMonitoring::hltAccept_

Definition at line 136 of file HLTriggerJSONMonitoring.h.

Referenced by analyze(), endLuminosityBlockSummary(), resetLumi(), and resetRun().

HLTConfigProvider HLTriggerJSONMonitoring::hltConfig_

Definition at line 115 of file HLTriggerJSONMonitoring.h.

Referenced by beginRun(), and resetRun().

std::vector<unsigned int> HLTriggerJSONMonitoring::hltDatasets_

Definition at line 140 of file HLTriggerJSONMonitoring.h.

Referenced by analyze(), endLuminosityBlockSummary(), resetLumi(), and resetRun().

std::vector<unsigned int> HLTriggerJSONMonitoring::hltErrors_

Definition at line 138 of file HLTriggerJSONMonitoring.h.

Referenced by analyze(), endLuminosityBlockSummary(), resetLumi(), and resetRun().

std::vector<std::vector<unsigned int> > HLTriggerJSONMonitoring::hltIndex_

Definition at line 120 of file HLTriggerJSONMonitoring.h.

Referenced by analyze(), and resetRun().

std::vector<unsigned int> HLTriggerJSONMonitoring::hltL1s_

Definition at line 134 of file HLTriggerJSONMonitoring.h.

Referenced by analyze(), endLuminosityBlockSummary(), resetLumi(), and resetRun().

std::vector<std::string> HLTriggerJSONMonitoring::hltNames_

Definition at line 121 of file HLTriggerJSONMonitoring.h.

Referenced by analyze(), beginRun(), and resetRun().

std::vector<unsigned int> HLTriggerJSONMonitoring::hltPre_

Definition at line 135 of file HLTriggerJSONMonitoring.h.

Referenced by analyze(), endLuminosityBlockSummary(), resetLumi(), and resetRun().

std::vector<unsigned int> HLTriggerJSONMonitoring::hltReject_

Definition at line 137 of file HLTriggerJSONMonitoring.h.

Referenced by analyze(), endLuminosityBlockSummary(), resetLumi(), and resetRun().

std::vector<unsigned int> HLTriggerJSONMonitoring::hltWasRun_

Definition at line 133 of file HLTriggerJSONMonitoring.h.

Referenced by analyze(), endLuminosityBlockSummary(), resetLumi(), and resetRun().

std::vector<int> HLTriggerJSONMonitoring::posL1s_

Definition at line 125 of file HLTriggerJSONMonitoring.h.

Referenced by analyze(), and resetRun().

std::vector<int> HLTriggerJSONMonitoring::posPre_

Definition at line 126 of file HLTriggerJSONMonitoring.h.

Referenced by analyze(), and resetRun().

unsigned int HLTriggerJSONMonitoring::processed_

Definition at line 131 of file HLTriggerJSONMonitoring.h.

Referenced by analyze(), endLuminosityBlockSummary(), and resetLumi().

std::string HLTriggerJSONMonitoring::stHltJsd_

Definition at line 128 of file HLTriggerJSONMonitoring.h.

Referenced by beginRun(), and endLuminosityBlockSummary().

edm::InputTag HLTriggerJSONMonitoring::triggerResults_

Definition at line 111 of file HLTriggerJSONMonitoring.h.

Referenced by analyze(), and beginRun().

edm::EDGetTokenT<edm::TriggerResults> HLTriggerJSONMonitoring::triggerResultsToken_

Definition at line 112 of file HLTriggerJSONMonitoring.h.

Referenced by analyze().