CMS 3D CMS Logo

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 ()
 
 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 std::shared_ptr< l1Json::lumiVarsglobalBeginLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
 
static std::shared_ptr< l1Json::runVarsglobalBeginRun (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< GlobalAlgBlkBxCollectionlevel1ResultsToken_
 
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, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
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.

References ~L1TriggerJSONMonitoring().

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

Referenced by L1TriggerJSONMonitoring().

Member Function Documentation

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

Implements edm::stream::EDAnalyzerBase.

Definition at line 41 of file L1TriggerJSONMonitoring.cc.

References BXVector< T >::begin(), BXVector< T >::end(), edm::Event::eventAuxiliary(), edm::EventBase::experimentType(), edm::Event::getByToken(), mps_fire::i, createfilelist::int, L1AlgoAccept_, L1AlgoAcceptCalibration_, L1AlgoAcceptPhysics_, L1AlgoAcceptRandom_, L1Global_, SelectingProcedure_cff::l1tResults, level1ResultsToken_, LogDebug, edm::EventAuxiliary::luminosityBlock(), oldLumi, oldPrescaleIndex, or, prescaleIndex_, and processed_.

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

Reimplemented from edm::stream::EDAnalyzerBase.

Definition at line 218 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 115 of file L1TriggerJSONMonitoring.cc.

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

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

Definition at line 246 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().

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

Definition at line 34 of file L1TriggerJSONMonitoring.cc.

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

34  {
36  desc.add<edm::InputTag>("L1Results",edm::InputTag("hltGtStage2Digis"));
37  descriptions.add("L1TMonitoring", desc);
38 }
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 &  ,
edm::EventSetup const &  ,
LuminosityBlockContext const *   
)
static

Definition at line 221 of file L1TriggerJSONMonitoring.cc.

222 {
223  std::shared_ptr<l1Json::lumiVars> iSummary(new l1Json::lumiVars);
224 
225  unsigned int MAXPATHS = 512;
226 
227  iSummary->processed = new HistoJ<unsigned int>(1, 1);
228 
229  iSummary->prescaleIndex = 100;
230 
231  iSummary->L1AlgoAccept = new HistoJ<unsigned int>(1, MAXPATHS);
232  iSummary->L1AlgoAcceptPhysics = new HistoJ<unsigned int>(1, MAXPATHS);
233  iSummary->L1AlgoAcceptCalibration = new HistoJ<unsigned int>(1, MAXPATHS);
234  iSummary->L1AlgoAcceptRandom = new HistoJ<unsigned int>(1, MAXPATHS);
235  iSummary->L1Global = new HistoJ<unsigned int>(1, MAXPATHS);
236 
237  iSummary->baseRunDir = "";
238  iSummary->stL1Jsd = "";
239  iSummary->streamL1Destination = "";
240  iSummary->streamL1MergeType = "";
241 
242  return iSummary;
243 }//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 &  ,
edm::EventSetup const &  ,
LuminosityBlockContext const *  ,
l1Json::lumiVars  
)
static

Definition at line 290 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(), 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(), Json::StyledWriter::write(), and cscNeutronWriter_cfi::writer.

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

Definition at line 94 of file L1TriggerJSONMonitoring.h.

References callgraph::path, and AlCaHLTBitMon_QueryRunRegistry::string.

94 { }
void L1TriggerJSONMonitoring::resetLumi ( )

Definition at line 92 of file L1TriggerJSONMonitoring.cc.

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

Referenced by beginLuminosityBlock(), and beginRun().

92  {
93  //Reset total number of events
94  processed_ = 0;
95 
96  //Reset per-path counters
97  //Reset L1 per-algo counters -
98  for (unsigned int i = 0; i < L1AlgoAccept_.size(); i++) {
99  L1AlgoAccept_[i] = 0;
100  L1AlgoAcceptPhysics_[i] = 0;
102  L1AlgoAcceptRandom_[i] = 0;
103  }
104  //Reset L1 global counters -
105  for (unsigned int i = 0; i < L1GlobalType_.size(); i++) {
106  L1Global_[i] = 0;
107  }
108 
109  //Prescale index
110  prescaleIndex_ = 100;
111 
112 }//End resetLumi function
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 417 of file L1TriggerJSONMonitoring.cc.

References HIPAlignmentAlgorithm_cfi::outfile.

Referenced by beginRun().

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