test
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
L1TriggerJSONMonitoring Class Reference

#include <L1TriggerJSONMonitoring.h>

Inheritance diagram for L1TriggerJSONMonitoring:
edm::stream::EDAnalyzer< edm::RunCache< l1Json::runVars >, edm::LuminosityBlockSummaryCache< l1Json::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 &, l1Json::lumiVars *) const
 
 L1TriggerJSONMonitoring (const edm::ParameterSet &)
 
void resetLumi ()
 
void writeL1DefJson (std::string path)
 
 ~L1TriggerJSONMonitoring ()
 
- Public Member Functions inherited from edm::stream::EDAnalyzer< edm::RunCache< l1Json::runVars >, edm::LuminosityBlockSummaryCache< l1Json::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
< l1Json::lumiVars
globalBeginLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
 
static std::shared_ptr
< l1Json::runVars
globalBeginRun (edm::Run const &, edm::EventSetup const &, void const *)
 
static void globalEndLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *, l1Json::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< unsigned int > L1AlgoAccept_
 
std::vector< unsigned int > L1AlgoAcceptCalibration_
 
std::vector< unsigned int > L1AlgoAcceptPhysics_
 
std::vector< unsigned int > L1AlgoAcceptRandom_
 
std::vector< int > L1AlgoBitNumber_
 
std::vector< std::string > L1AlgoNames_
 
std::vector< unsigned int > L1Global_
 
std::vector< std::string > L1GlobalType_
 
edm::InputTag level1Results_
 
edm::EDGetTokenT
< GlobalAlgBlkBxCollection
level1ResultsToken_
 
unsigned int oldLumi
 
unsigned int oldPrescaleIndex
 
unsigned int prescaleIndex_
 
unsigned int processed_
 
std::string stL1Jsd_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDAnalyzer< edm::RunCache< l1Json::runVars >, edm::LuminosityBlockSummaryCache< l1Json::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 L1 trigger info.

Created: Fri, 11 Mar 2016

Author
Aram Avetisyan

See header file for documentation

Author
Aram Avetisyan

Definition at line 71 of file L1TriggerJSONMonitoring.h.

Constructor & Destructor Documentation

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

Definition at line 23 of file L1TriggerJSONMonitoring.cc.

23  :
24  level1Results_(ps.getParameter<edm::InputTag>("L1Results")),
25  level1ResultsToken_(consumes<GlobalAlgBlkBxCollection>(level1Results_))
26 {
27 
28 
29 }
T getParameter(std::string const &) const
edm::EDGetTokenT< GlobalAlgBlkBxCollection > level1ResultsToken_
L1TriggerJSONMonitoring::~L1TriggerJSONMonitoring ( )

Definition at line 31 of file L1TriggerJSONMonitoring.cc.

32 {
33 }

Member Function Documentation

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

Implements edm::stream::EDAnalyzerBase.

Definition at line 43 of file L1TriggerJSONMonitoring.cc.

References edm::Event::eventAuxiliary(), edm::EventBase::experimentType(), edm::Event::getByToken(), i, L1AlgoAccept_, L1AlgoAcceptCalibration_, L1AlgoAcceptPhysics_, L1AlgoAcceptRandom_, L1Global_, JetPDSkim_cfg::l1tResults, level1ResultsToken_, LogDebug, edm::EventAuxiliary::luminosityBlock(), oldLumi, oldPrescaleIndex, or, prescaleIndex_, and processed_.

44 {
45 
46  using namespace std;
47  using namespace edm;
48 
49  processed_++;
50 
51  int ex = iEvent.experimentType();
52  if (ex == 1) L1Global_[0]++;
53  else if (ex == 2) L1Global_[1]++;
54  else if (ex == 3) L1Global_[2]++;
55  else{
56  LogDebug("L1TriggerJSONMonitoring") << "Not Physics, Calibration or Random. experimentType = " << ex << std::endl;
57  }
58 
59  //Get hold of L1TResults
61  if (not iEvent.getByToken(level1ResultsToken_, l1tResults) or (l1tResults->begin(0) == l1tResults->end(0))){
62  LogDebug("L1TriggerJSONMonitoring") << "Could not get L1 trigger results" << std::endl;
63  return;
64  }
65 
66  //The GlobalAlgBlkBxCollection is a vector of vectors, but the second layer can only ever
67  //have one entry since there can't be more than one collection per bunch crossing. The "0"
68  //here means BX = 0, the "begin" is used to access the first and only element
69  std::vector<GlobalAlgBlk>::const_iterator algBlk = l1tResults->begin(0);
70 
71  for (unsigned int i = 0; i < algBlk->maxPhysicsTriggers; i++){
72  if (algBlk->getAlgoDecisionFinal(i)){
73  L1AlgoAccept_[i]++;
74  if (ex == 1) L1AlgoAcceptPhysics_[i]++;
75  if (ex == 2) L1AlgoAcceptCalibration_[i]++;
76  if (ex == 3) L1AlgoAcceptRandom_[i]++;
77  }
78  }
79 
80  //Prescale index
81  prescaleIndex_ = static_cast<unsigned int>(algBlk->getPreScColumn());
82 
83  //Check that the prescale index hasn't changed inside a lumi section
84  unsigned int newLumi = (unsigned int) iEvent.eventAuxiliary().luminosityBlock();
85  if (oldLumi == newLumi and prescaleIndex_ != oldPrescaleIndex){
86  LogWarning("L1TriggerJSONMonitoring")<<"Prescale index has changed from "<<oldPrescaleIndex<<" to "<<prescaleIndex_<<" inside lumi section "<<newLumi;
87  }
88  oldLumi = newLumi;
90 
91 }//End analyze function
#define LogDebug(id)
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 > L1AlgoAcceptRandom_
std::vector< unsigned int > L1AlgoAccept_
int iEvent
Definition: GenABIO.cc:230
std::vector< unsigned int > L1Global_
edm::EDGetTokenT< GlobalAlgBlkBxCollection > level1ResultsToken_
std::vector< unsigned int > L1AlgoAcceptPhysics_
std::vector< unsigned int > L1AlgoAcceptCalibration_
void L1TriggerJSONMonitoring::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &  iSetup 
)
virtual

Reimplemented from edm::stream::EDAnalyzerBase.

Definition at line 220 of file L1TriggerJSONMonitoring.cc.

References resetLumi().

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

Reimplemented from edm::stream::EDAnalyzerBase.

Definition at line 117 of file L1TriggerJSONMonitoring.cc.

References Json::Value::append(), Json::arrayValue, baseRunDir_, edm::EventSetup::get(), L1TUtmTriggerMenu::getAlgorithmMap(), i, L1AlgoAccept_, L1AlgoAcceptCalibration_, L1AlgoAcceptPhysics_, L1AlgoAcceptRandom_, L1AlgoNames_, L1Global_, L1GlobalType_, GlobalAlgBlk::maxPhysicsTriggers, oldLumi, oldPrescaleIndex, edm::ESHandle< class >::product(), resetLumi(), mps_fire::result, edm::RunBase::run(), stL1Jsd_, AlCaHLTBitMon_QueryRunRegistry::string, interactiveExample::ui, Json::StyledWriter::write(), and writeL1DefJson().

118 {
120  iSetup.get<L1TUtmTriggerMenuRcd>().get(l1GtMenu);
121 
122  //Get the run directory from the EvFDaqDirector
124  else baseRunDir_ = ".";
125 
126  std::string monPath = baseRunDir_ + "/";
127 
128  //Need this to get at maximum number of triggers
129  GlobalAlgBlk alg = GlobalAlgBlk();
130 
131  //Update trigger and dataset names, clear L1 names and counters
132  L1AlgoNames_.resize(alg.maxPhysicsTriggers);
133  for (unsigned int i = 0; i < L1AlgoNames_.size(); i++) {
134  L1AlgoNames_.at(i) = "";
135  }
136 
137  //Get L1 algorithm trigger names -
138  const L1TUtmTriggerMenu* m_l1GtMenu;
139  const std::map<std::string, L1TUtmAlgorithm>* m_algorithmMap;
140 
141  m_l1GtMenu = l1GtMenu.product();
142  m_algorithmMap = &(m_l1GtMenu->getAlgorithmMap());
143 
144  for (std::map<std::string, L1TUtmAlgorithm>::const_iterator itAlgo = m_algorithmMap->begin(); itAlgo != m_algorithmMap->end(); itAlgo++) {
145  int bitNumber = (itAlgo->second).getIndex();
146  L1AlgoNames_.at(bitNumber) = itAlgo->first;
147  }
148 
149  L1GlobalType_.clear();
150  L1Global_.clear();
151 
152  //Set the experimentType -
153  L1GlobalType_.push_back( "Physics" );
154  L1GlobalType_.push_back( "Calibration" );
155  L1GlobalType_.push_back( "Random" );
156 
157  const unsigned int la = L1AlgoNames_.size();
158  const unsigned int lg = L1GlobalType_.size();
159 
160  //Resize per-path counters
161  L1AlgoAccept_.resize(la);
162  L1AlgoAcceptPhysics_.resize(la);
163  L1AlgoAcceptCalibration_.resize(la);
164  L1AlgoAcceptRandom_.resize(la);
165 
166  L1Global_.resize(lg);
167 
168  resetLumi();
169 
170  //Write the once-per-run files if not already written
171  //Eventually must rewrite this with proper multithreading (i.e. globalBeginRun)
172  bool expected = false;
173  if( runCache()->wroteFiles.compare_exchange_strong(expected, true) ){
174  runCache()->wroteFiles = true;
175 
176  unsigned int nRun = iRun.run();
177 
178  //Create definition file for L1 Rates -
179  std::stringstream ssL1Jsd;
180  ssL1Jsd << "run" << std::setfill('0') << std::setw(6) << nRun << "_ls0000";
181  ssL1Jsd << "_streamL1Rates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsd";
182  stL1Jsd_ = ssL1Jsd.str();
183 
185 
186  //Write ini files
187  //L1
188  Json::Value l1Ini;
189  Json::StyledWriter writer;
190 
191  Json::Value l1AlgoNamesVal(Json::arrayValue);
192  for (unsigned int ui = 0; ui < L1AlgoNames_.size(); ui++){
193  l1AlgoNamesVal.append(L1AlgoNames_.at(ui));
194  }
195 
196  Json::Value eventTypeVal(Json::arrayValue);
197  for (unsigned int ui = 0; ui < L1GlobalType_.size(); ui++){
198  eventTypeVal.append(L1GlobalType_.at(ui));
199  }
200 
201  l1Ini["L1-Algo-Names"] = l1AlgoNamesVal;
202  l1Ini["Event-Type"] = eventTypeVal;
203 
204  std::string && result = writer.write(l1Ini);
205 
206  std::stringstream ssL1Ini;
207  ssL1Ini << "run" << std::setfill('0') << std::setw(6) << nRun << "_ls0000_streamL1Rates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".ini";
208 
209  std::ofstream outL1Ini( monPath + ssL1Ini.str() );
210  outL1Ini<<result;
211  outL1Ini.close();
212  }
213 
214  //Initialize variables for verification of prescaleIndex
215  oldLumi = 0;
216  oldPrescaleIndex = 100;
217 
218 }//End beginRun function
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned int > L1AlgoAcceptRandom_
Represents a JSON value.
Definition: value.h:111
std::vector< unsigned int > L1AlgoAccept_
void writeL1DefJson(std::string path)
static const unsigned int maxPhysicsTriggers
Definition: GlobalAlgBlk.h:52
tuple result
Definition: mps_fire.py:84
std::vector< std::string > L1AlgoNames_
std::vector< unsigned int > L1Global_
std::vector< std::string > L1GlobalType_
std::vector< unsigned int > L1AlgoAcceptPhysics_
std::vector< unsigned int > L1AlgoAcceptCalibration_
virtual std::string write(const Value &root)
Serialize a Value in JSON format.
T const * product() const
Definition: ESHandle.h:86
const std::map< std::string, L1TUtmAlgorithm > & getAlgorithmMap() const
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::endLuminosityBlockSummary ( edm::LuminosityBlock const &  iLumi,
edm::EventSetup const &  iEventSetup,
l1Json::lumiVars iSummary 
) const

Definition at line 248 of file L1TriggerJSONMonitoring.cc.

References l1Json::lumiVars::baseRunDir, baseRunDir_, l1Json::lumiVars::L1AlgoAccept, L1AlgoAccept_, l1Json::lumiVars::L1AlgoAcceptCalibration, L1AlgoAcceptCalibration_, l1Json::lumiVars::L1AlgoAcceptPhysics, L1AlgoAcceptPhysics_, l1Json::lumiVars::L1AlgoAcceptRandom, L1AlgoAcceptRandom_, l1Json::lumiVars::L1Global, L1Global_, L1GlobalType_, l1Json::lumiVars::prescaleIndex, prescaleIndex_, l1Json::lumiVars::processed, processed_, l1Json::lumiVars::stL1Jsd, stL1Jsd_, l1Json::lumiVars::streamL1Destination, l1Json::lumiVars::streamL1MergeType, interactiveExample::ui, jsoncollector::HistoJ< T >::update(), and jsoncollector::HistoJ< T >::value().

248  {
249 
250  //Whichever stream gets there first does the initialiazation
251  if (iSummary->L1AlgoAccept->value().size() == 0){
252  iSummary->processed->update(processed_);
253 
254  iSummary->prescaleIndex = prescaleIndex_;
255 
256  iSummary->baseRunDir = baseRunDir_;
257 
258  for (unsigned int ui = 0; ui < L1AlgoAccept_.size(); ui++){
259  iSummary->L1AlgoAccept ->update(L1AlgoAccept_.at(ui));
263  }
264  for (unsigned int ui = 0; ui < L1GlobalType_.size(); ui++){
265  iSummary->L1Global ->update(L1Global_.at(ui));
266  }
267  iSummary->stL1Jsd = stL1Jsd_;
268 
269  iSummary->streamL1Destination = runCache()->streamL1Destination;
270  iSummary->streamL1MergeType = runCache()->streamL1MergeType;
271  }
272 
273  else{
274  iSummary->processed->value().at(0) += processed_;
275 
276  for (unsigned int ui = 0; ui < L1AlgoAccept_.size(); ui++){
277  iSummary->L1AlgoAccept->value().at(ui) += L1AlgoAccept_.at(ui);
278  iSummary->L1AlgoAcceptPhysics->value().at(ui) += L1AlgoAcceptPhysics_.at(ui);
280  iSummary->L1AlgoAcceptRandom->value().at(ui) += L1AlgoAcceptRandom_.at(ui);
281  }
282  for (unsigned int ui = 0; ui < L1Global_.size(); ui++){
283  iSummary->L1Global->value().at(ui) += L1Global_.at(ui);
284  }
285 
286  }
287 
288 }//End endLuminosityBlockSummary function
std::vector< unsigned int > L1AlgoAcceptRandom_
std::vector< unsigned int > L1AlgoAccept_
jsoncollector::HistoJ< unsigned int > * L1AlgoAcceptCalibration
std::vector< T > & value()
std::vector< unsigned int > L1Global_
std::vector< std::string > L1GlobalType_
std::vector< unsigned int > L1AlgoAcceptPhysics_
std::vector< unsigned int > L1AlgoAcceptCalibration_
jsoncollector::HistoJ< unsigned int > * L1Global
jsoncollector::HistoJ< unsigned int > * L1AlgoAccept
jsoncollector::HistoJ< unsigned int > * processed
jsoncollector::HistoJ< unsigned int > * L1AlgoAcceptRandom
jsoncollector::HistoJ< unsigned int > * L1AlgoAcceptPhysics
void L1TriggerJSONMonitoring::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 36 of file L1TriggerJSONMonitoring.cc.

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

36  {
38  desc.add<edm::InputTag>("L1Results",edm::InputTag("hltGtStage2Digis"));
39  descriptions.add("L1TMonitoring", desc);
40 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::shared_ptr< l1Json::lumiVars > L1TriggerJSONMonitoring::globalBeginLuminosityBlockSummary ( edm::LuminosityBlock const &  iLumi,
edm::EventSetup const &  iSetup,
LuminosityBlockContext const *  iContext 
)
static

Definition at line 223 of file L1TriggerJSONMonitoring.cc.

224 {
225  std::shared_ptr<l1Json::lumiVars> iSummary(new l1Json::lumiVars);
226 
227  unsigned int MAXPATHS = 512;
228 
229  iSummary->processed = new HistoJ<unsigned int>(1, 1);
230 
231  iSummary->prescaleIndex = 100;
232 
233  iSummary->L1AlgoAccept = new HistoJ<unsigned int>(1, MAXPATHS);
234  iSummary->L1AlgoAcceptPhysics = new HistoJ<unsigned int>(1, MAXPATHS);
235  iSummary->L1AlgoAcceptCalibration = new HistoJ<unsigned int>(1, MAXPATHS);
236  iSummary->L1AlgoAcceptRandom = new HistoJ<unsigned int>(1, MAXPATHS);
237  iSummary->L1Global = new HistoJ<unsigned int>(1, MAXPATHS);
238 
239  iSummary->baseRunDir = "";
240  iSummary->stL1Jsd = "";
241  iSummary->streamL1Destination = "";
242  iSummary->streamL1MergeType = "";
243 
244  return iSummary;
245 }//End globalBeginLuminosityBlockSummary function
static std::shared_ptr<l1Json::runVars> L1TriggerJSONMonitoring::globalBeginRun ( edm::Run const &  ,
edm::EventSetup const &  ,
void const *   
)
inlinestatic

Definition at line 84 of file L1TriggerJSONMonitoring.h.

References evf::MergeTypeJSNDATA.

84  {
85  std::shared_ptr<l1Json::runVars> rv(new l1Json::runVars);
86  if (edm::Service<evf::EvFDaqDirector>().isAvailable()) {
87  rv->streamL1Destination = edm::Service<evf::EvFDaqDirector>()->getStreamDestinations("streamL1Rates");
88  rv->streamL1MergeType = edm::Service<evf::EvFDaqDirector>()->getStreamMergeType("streamL1Rates",evf::MergeTypeJSNDATA);
89  }
90  rv->wroteFiles = false;
91  return rv;
92  }
void L1TriggerJSONMonitoring::globalEndLuminosityBlockSummary ( edm::LuminosityBlock const &  iLumi,
edm::EventSetup const &  iSetup,
LuminosityBlockContext const *  iContext,
l1Json::lumiVars iSummary 
)
static

Definition at line 292 of file L1TriggerJSONMonitoring.cc.

References cms::Adler32(), Json::Value::append(), l1Json::lumiVars::baseRunDir, cscdqm::DATA, l1Json::lumiVars::L1AlgoAccept, l1Json::lumiVars::L1AlgoAcceptCalibration, l1Json::lumiVars::L1AlgoAcceptPhysics, l1Json::lumiVars::L1AlgoAcceptRandom, l1Json::lumiVars::L1Global, edm::LuminosityBlockBase::luminosityBlock(), l1Json::lumiVars::prescaleIndex, l1Json::lumiVars::processed, mps_fire::result, edm::LuminosityBlockBase::run(), evf::FastMonitoringService::shouldWriteFiles(), runonSM::SOURCE, l1Json::lumiVars::stL1Jsd, l1Json::lumiVars::streamL1Destination, l1Json::lumiVars::streamL1MergeType, AlCaHLTBitMon_QueryRunRegistry::string, jsoncollector::HistoJ< T >::toJsonValue(), jsoncollector::StringJ::update(), jsoncollector::IntJ::value(), jsoncollector::StringJ::value(), jsoncollector::HistoJ< T >::value(), and Json::StyledWriter::write().

293 {
294 
295  unsigned int iLs = iLumi.luminosityBlock();
296  unsigned int iRun = iLumi.run();
297 
298  bool writeFiles=true;
299  if (edm::Service<evf::MicroStateService>().isAvailable()) {
301  if (fms) {
302  writeFiles = fms->shouldWriteFiles(iLumi.luminosityBlock());
303  }
304  }
305 
306  if (writeFiles) {
307  Json::StyledWriter writer;
308 
309  char hostname[33];
310  gethostname(hostname,32);
311  std::string sourceHost(hostname);
312 
313  //Get the output directory
314  std::string monPath = iSummary->baseRunDir + "/";
315 
316  std::stringstream sOutDef;
317  sOutDef << monPath << "output_" << getpid() << ".jsd";
318 
319  //Write the .jsndata files which contain the actual rates
320  //L1 .jsndata file
321  Json::Value l1JsnData;
322  l1JsnData[DataPoint::SOURCE] = sourceHost;
323  l1JsnData[DataPoint::DEFINITION] = iSummary->stL1Jsd;
324 
325  l1JsnData[DataPoint::DATA].append(iSummary->processed->toJsonValue());
326  l1JsnData[DataPoint::DATA].append(iSummary->L1AlgoAccept ->toJsonValue());
327  l1JsnData[DataPoint::DATA].append(iSummary->L1AlgoAcceptPhysics ->toJsonValue());
329  l1JsnData[DataPoint::DATA].append(iSummary->L1AlgoAcceptRandom ->toJsonValue());
330  l1JsnData[DataPoint::DATA].append(iSummary->L1Global ->toJsonValue());
331 
332  l1JsnData[DataPoint::DATA].append(iSummary->prescaleIndex);
333 
334  std::string && result = writer.write(l1JsnData);
335 
336  std::stringstream ssL1JsnData;
337  ssL1JsnData << "run" << std::setfill('0') << std::setw(6) << iRun << "_ls" << std::setfill('0') << std::setw(4) << iLs;
338  ssL1JsnData << "_streamL1Rates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsndata";
339 
340  if (iSummary->processed->value().at(0)!=0) {
341  std::ofstream outL1JsnData( monPath + "/" + ssL1JsnData.str() );
342  outL1JsnData<<result;
343  outL1JsnData.close();
344  }
345 
346  //L1 jsn entries
347  StringJ l1JsnFilelist;
348  IntJ l1JsnFilesize = 0;
349  unsigned int l1JsnFileAdler32 = 1;
350  if (iSummary->processed->value().at(0)!=0) {
351  l1JsnFilelist.update(ssL1JsnData.str());
352  l1JsnFilesize = result.size();
353  l1JsnFileAdler32 = cms::Adler32(result.c_str(),result.size());
354  }
355  StringJ l1JsnInputFiles;
356  l1JsnInputFiles.update("");
357 
358  //Create special DAQ JSON file for L1 and HLT rates pseudo-streams
359  //Only three variables are different between the files:
360  //the file list, the file size and the Adler32 value
361  IntJ daqJsnProcessed = iSummary->processed->value().at(0);
362  IntJ daqJsnAccepted = daqJsnProcessed;
363  IntJ daqJsnErrorEvents = 0;
364  IntJ daqJsnRetCodeMask = 0;
365  IntJ daqJsnHLTErrorEvents = 0;
366 
367  //write out L1 metadata jsn
368  Json::Value l1DaqJsn;
369  l1DaqJsn[DataPoint::SOURCE] = sourceHost;
370  l1DaqJsn[DataPoint::DEFINITION] = sOutDef.str();
371 
372  l1DaqJsn[DataPoint::DATA].append((unsigned int)daqJsnProcessed.value());
373  l1DaqJsn[DataPoint::DATA].append((unsigned int)daqJsnAccepted.value());
374  l1DaqJsn[DataPoint::DATA].append((unsigned int)daqJsnErrorEvents.value());
375  l1DaqJsn[DataPoint::DATA].append((unsigned int)daqJsnRetCodeMask.value());
376  l1DaqJsn[DataPoint::DATA].append(l1JsnFilelist.value());
377  l1DaqJsn[DataPoint::DATA].append((unsigned int)l1JsnFilesize.value());
378  l1DaqJsn[DataPoint::DATA].append(l1JsnInputFiles.value());
379  l1DaqJsn[DataPoint::DATA].append(l1JsnFileAdler32);
380  l1DaqJsn[DataPoint::DATA].append(iSummary->streamL1Destination);
381  l1DaqJsn[DataPoint::DATA].append(iSummary->streamL1MergeType);
382  l1DaqJsn[DataPoint::DATA].append((unsigned int)daqJsnHLTErrorEvents.value());
383 
384  result = writer.write(l1DaqJsn);
385 
386  std::stringstream ssL1DaqJsn;
387  ssL1DaqJsn << "run" << std::setfill('0') << std::setw(6) << iRun << "_ls" << std::setfill('0') << std::setw(4) << iLs;
388  ssL1DaqJsn << "_streamL1Rates_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsn";
389 
390  std::ofstream outL1DaqJsn( monPath + ssL1DaqJsn.str() );
391  outL1DaqJsn<<result;
392  outL1DaqJsn.close();
393  }
394 
395  //Delete the individual HistoJ pointers
396  delete iSummary->processed;
397 
398  delete iSummary->L1AlgoAccept;
399  delete iSummary->L1AlgoAcceptPhysics;
400  delete iSummary->L1AlgoAcceptCalibration;
401  delete iSummary->L1AlgoAcceptRandom;
402  delete iSummary->L1Global;
403 
404  //Note: Do not delete the iSummary pointer. The framework does something with it later on
405  // and deleting it results in a segmentation fault.
406 
407  //Reninitalize HistoJ pointers to nullptr
408  iSummary->processed = nullptr;
409 
410  iSummary->L1AlgoAccept = nullptr;
411  iSummary->L1AlgoAcceptPhysics = nullptr;
412  iSummary->L1AlgoAcceptCalibration = nullptr;
413  iSummary->L1AlgoAcceptRandom = nullptr;
414  iSummary->L1Global = nullptr;
415 
416 }//End globalEndLuminosityBlockSummary function
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 > * L1AlgoAcceptCalibration
virtual Json::Value toJsonValue() const
std::vector< T > & value()
tuple result
Definition: mps_fire.py:84
jsoncollector::HistoJ< unsigned int > * L1Global
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 > * L1AlgoAccept
jsoncollector::HistoJ< unsigned int > * processed
jsoncollector::HistoJ< unsigned int > * L1AlgoAcceptRandom
jsoncollector::HistoJ< unsigned int > * L1AlgoAcceptPhysics
Writes a Value in JSON format in a human friendly way.
Definition: writer.h:65
string SOURCE
Definition: runonSM.py:23
static void L1TriggerJSONMonitoring::globalEndRun ( edm::Run const &  iRun,
edm::EventSetup const &  ,
RunContext const *  iContext 
)
inlinestatic

Definition at line 94 of file L1TriggerJSONMonitoring.h.

94 { }
void L1TriggerJSONMonitoring::resetLumi ( )

Definition at line 94 of file L1TriggerJSONMonitoring.cc.

References i, L1AlgoAccept_, L1AlgoAcceptCalibration_, L1AlgoAcceptPhysics_, L1AlgoAcceptRandom_, L1Global_, L1GlobalType_, prescaleIndex_, and processed_.

Referenced by beginLuminosityBlock(), and beginRun().

94  {
95  //Reset total number of events
96  processed_ = 0;
97 
98  //Reset per-path counters
99  //Reset L1 per-algo counters -
100  for (unsigned int i = 0; i < L1AlgoAccept_.size(); i++) {
101  L1AlgoAccept_[i] = 0;
102  L1AlgoAcceptPhysics_[i] = 0;
104  L1AlgoAcceptRandom_[i] = 0;
105  }
106  //Reset L1 global counters -
107  for (unsigned int i = 0; i < L1GlobalType_.size(); i++) {
108  L1Global_[i] = 0;
109  }
110 
111  //Prescale index
112  prescaleIndex_ = 100;
113 
114 }//End resetLumi function
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned int > L1AlgoAcceptRandom_
std::vector< unsigned int > L1AlgoAccept_
std::vector< unsigned int > L1Global_
std::vector< std::string > L1GlobalType_
std::vector< unsigned int > L1AlgoAcceptPhysics_
std::vector< unsigned int > L1AlgoAcceptCalibration_
void L1TriggerJSONMonitoring::writeL1DefJson ( std::string  path)

Definition at line 419 of file L1TriggerJSONMonitoring.cc.

References timingPdfMaker::outfile.

Referenced by beginRun().

419  {
420 
421  std::ofstream outfile( path );
422  outfile << "{" << std::endl;
423  outfile << " \"data\" : [" << std::endl;
424  outfile << " {" ;
425  outfile << " \"name\" : \"Processed\"," ;
426  outfile << " \"type\" : \"integer\"," ;
427  outfile << " \"operation\" : \"histo\"}," << std::endl;
428 
429  outfile << " {" ;
430  outfile << " \"name\" : \"L1-AlgoAccepted\"," ;
431  outfile << " \"type\" : \"integer\"," ;
432  outfile << " \"operation\" : \"histo\"}," << std::endl;
433 
434  outfile << " {" ;
435  outfile << " \"name\" : \"L1-AlgoAccepted-Physics\"," ;
436  outfile << " \"type\" : \"integer\"," ;
437  outfile << " \"operation\" : \"histo\"}," << std::endl;
438 
439  outfile << " {" ;
440  outfile << " \"name\" : \"L1-AlgoAccepted-Calibration\"," ;
441  outfile << " \"type\" : \"integer\"," ;
442  outfile << " \"operation\" : \"histo\"}," << std::endl;
443 
444  outfile << " {" ;
445  outfile << " \"name\" : \"L1-AlgoAccepted-Random\"," ;
446  outfile << " \"type\" : \"integer\"," ;
447  outfile << " \"operation\" : \"histo\"}," << std::endl;
448 
449  outfile << " {" ;
450  outfile << " \"name\" : \"L1-Global\"," ;
451  outfile << " \"type\" : \"integer\"," ;
452  outfile << " \"operation\" : \"histo\"}," << std::endl;
453 
454  outfile << " {" ;
455  outfile << " \"name\" : \"Prescale-Index\"," ;
456  outfile << " \"type\" : \"integer\"," ;
457  outfile << " \"operation\" : \"sample\"}" << std::endl;
458 
459  outfile << " ]" << std::endl;
460  outfile << "}" << std::endl;
461 
462  outfile.close();
463 }//End writeL1DefJson function

Member Data Documentation

std::string L1TriggerJSONMonitoring::baseRunDir_

Definition at line 121 of file L1TriggerJSONMonitoring.h.

Referenced by beginRun(), and endLuminosityBlockSummary().

std::vector<unsigned int> L1TriggerJSONMonitoring::L1AlgoAccept_

Definition at line 133 of file L1TriggerJSONMonitoring.h.

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

std::vector<unsigned int> L1TriggerJSONMonitoring::L1AlgoAcceptCalibration_

Definition at line 135 of file L1TriggerJSONMonitoring.h.

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

std::vector<unsigned int> L1TriggerJSONMonitoring::L1AlgoAcceptPhysics_

Definition at line 134 of file L1TriggerJSONMonitoring.h.

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

std::vector<unsigned int> L1TriggerJSONMonitoring::L1AlgoAcceptRandom_

Definition at line 136 of file L1TriggerJSONMonitoring.h.

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

std::vector<int> L1TriggerJSONMonitoring::L1AlgoBitNumber_

Definition at line 124 of file L1TriggerJSONMonitoring.h.

std::vector<std::string> L1TriggerJSONMonitoring::L1AlgoNames_

Definition at line 123 of file L1TriggerJSONMonitoring.h.

Referenced by beginRun().

std::vector<unsigned int> L1TriggerJSONMonitoring::L1Global_

Definition at line 137 of file L1TriggerJSONMonitoring.h.

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

std::vector<std::string> L1TriggerJSONMonitoring::L1GlobalType_

Definition at line 125 of file L1TriggerJSONMonitoring.h.

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

edm::InputTag L1TriggerJSONMonitoring::level1Results_

Definition at line 117 of file L1TriggerJSONMonitoring.h.

edm::EDGetTokenT<GlobalAlgBlkBxCollection> L1TriggerJSONMonitoring::level1ResultsToken_

Definition at line 118 of file L1TriggerJSONMonitoring.h.

Referenced by analyze().

unsigned int L1TriggerJSONMonitoring::oldLumi

Definition at line 140 of file L1TriggerJSONMonitoring.h.

Referenced by analyze(), and beginRun().

unsigned int L1TriggerJSONMonitoring::oldPrescaleIndex

Definition at line 141 of file L1TriggerJSONMonitoring.h.

Referenced by analyze(), and beginRun().

unsigned int L1TriggerJSONMonitoring::prescaleIndex_

Definition at line 131 of file L1TriggerJSONMonitoring.h.

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

unsigned int L1TriggerJSONMonitoring::processed_

Definition at line 130 of file L1TriggerJSONMonitoring.h.

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

std::string L1TriggerJSONMonitoring::stL1Jsd_

Definition at line 127 of file L1TriggerJSONMonitoring.h.

Referenced by beginRun(), and endLuminosityBlockSummary().