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 | Private Attributes
TriggerJSONMonitoring Class Reference

#include <TriggerJSONMonitoring.h>

Inheritance diagram for TriggerJSONMonitoring:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void beginRun (edm::Run const &, edm::EventSetup const &)
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
 
void reset (bool changed=false)
 
 TriggerJSONMonitoring (const edm::ParameterSet &)
 
 ~TriggerJSONMonitoring ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 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 (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) 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 Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Private Attributes

std::string baseRunDir
 
HLTConfigProvider hltConfig_
 
std::vector< std::string > hltNames_
 
std::vector< IntJhltPaths_
 
std::string jsonDefinitionFile
 
boost::shared_ptr
< jsoncollector::FastMonitor
jsonMonitor_
 
DataPointDefinition outJson_
 
IntJ processed_
 
edm::InputTag triggerResults_
 
edm::EDGetTokenT
< edm::TriggerResults
triggerResultsToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- 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 trigger info.

Created: Wed, 09 Jul 2014

Author
Aram Avetisyan
Daniel Salerno

See header file for documentation

Author
Aram Avetisyan
Daniel Salerno

Definition at line 36 of file TriggerJSONMonitoring.h.

Constructor & Destructor Documentation

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

Definition at line 22 of file TriggerJSONMonitoring.cc.

References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), triggerResults_, and triggerResultsToken_.

23 {
24  if (ps.exists("triggerResults")) triggerResults_ = ps.getParameter<edm::InputTag> ("triggerResults");
25  else triggerResults_ = edm::InputTag("TriggerResults","","HLT");
26 
27  triggerResultsToken_ = consumes<edm::TriggerResults>(triggerResults_);
28 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
TriggerJSONMonitoring::~TriggerJSONMonitoring ( )

Definition at line 30 of file TriggerJSONMonitoring.cc.

31 {
32 }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 42 of file TriggerJSONMonitoring.cc.

References edm::InputTag::encode(), edm::Event::getByToken(), hltNames_, hltPaths_, i, LogDebug, n, processed_, triggerResults_, triggerResultsToken_, and jsoncollector::IntJ::value().

43 {
44 
45  using namespace std;
46  using namespace edm;
47 
48  processed_.value()++;
49 
50  //Get hold of TriggerResults
52  iEvent.getByToken(triggerResultsToken_, HLTR);
53  if (!HLTR.isValid()) {
54  LogDebug("TriggerJSONMonitoring") << "HLT TriggerResults with label ["+triggerResults_.encode()+"] not found!" << std::endl;
55  return;
56  }
57 
58  // decision for each HLT path
59  const unsigned int n(hltNames_.size());
60  for (unsigned int i=0; i<n; i++) {
61  if (HLTR->accept(i)){
62  hltPaths_[i].value()++;
63  }
64  }
65 
66 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
std::string encode() const
Definition: InputTag.cc:164
std::vector< std::string > hltNames_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
std::vector< IntJ > hltPaths_
void TriggerJSONMonitoring::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 155 of file TriggerJSONMonitoring.cc.

References hltPaths_, i, jsonDefinitionFile, jsonMonitor_, outJson_, processed_, reset(), and AlCaHLTBitMon_QueryRunRegistry::string.

156 {
157 
158  std::string outJsonDefName = jsonDefinitionFile;
159 
161  jsonMonitor_->setDefPath(outJsonDefName);
162  jsonMonitor_->registerGlobalMonitorable(&processed_,false);
163 
164  for(unsigned int i = 0; i < hltPaths_.size(); i++){
165  jsonMonitor_->registerGlobalMonitorable(&hltPaths_[i], false);
166  }
167 
168  jsonMonitor_->commit(nullptr);
169 
170  reset();
171 }
int i
Definition: DBlmapReader.cc:9
DataPointDefinition outJson_
boost::shared_ptr< jsoncollector::FastMonitor > jsonMonitor_
void reset(bool changed=false)
std::vector< IntJ > hltPaths_
void TriggerJSONMonitoring::beginRun ( edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 92 of file TriggerJSONMonitoring.cc.

References jsoncollector::DataPointDefinition::addLegendItem(), baseRunDir, hltConfig_, hltNames_, hltPaths_, i, HLTConfigProvider::init(), j, jsonDefinitionFile, n, getDQMSummary::outfile, outJson_, edm::InputTag::process(), processed_, reset(), edm::RunBase::run(), jsoncollector::DataPointDefinition::setDefaultGroup(), jsoncollector::JsonMonitorable::setName(), SUM, and triggerResults_.

93 {
94 
95  //Get the run directory from the EvFDaqDirector
97 
98  // initialize hltConfig_
99  bool changed = true;
100  if (hltConfig_.init(iRun, iSetup, triggerResults_.process(), changed)) {
101  reset(true);
102  }
103 
104  // set up JSON
105  processed_.setName("Processed");
106 
107  DataPointDefinition outJsonTemp_;
108 
109  outJsonTemp_.setDefaultGroup("data");
110  outJsonTemp_.addLegendItem("Processed","integer",DataPointDefinition::SUM);
111 
112  const unsigned int n = hltNames_.size();
113 
114  for(unsigned int i =0; i<n; i++){
115  hltPaths_[i].setName( hltNames_[i] );
116  outJsonTemp_.addLegendItem(hltNames_[i],"integer",DataPointDefinition::SUM);
117  }
118 
119  outJson_ = outJsonTemp_;
120 
121  // create JSON definition file
122  unsigned int nRun = iRun.run();
123 
124  std::stringstream sjsd;
125  sjsd << baseRunDir << "/mon/HLTRates_run"<< nRun;
126  sjsd << "_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsd";
127  jsonDefinitionFile = sjsd.str();
128 
129  std::ofstream outfile( jsonDefinitionFile );
130  outfile << "{" << std::endl;
131  outfile << " \"data\" : [" << std::endl;
132  outfile << " {" << std::endl;
133  outfile << " \"name\" : \"Processed\"," << std::endl;
134  outfile << " \"operation\" : \"sum\"," << std::endl;
135  outfile << " \"type\" : \"integer\"" << std::endl;
136 
137  for(unsigned int j =0; j<n; j++){
138  outfile << " }," << std::endl;
139  outfile << " {" << std::endl;
140  outfile << " \"name\" : \"" << hltNames_[j] << "\"," << std::endl;
141  outfile << " \"operation\" : \"sum\"," << std::endl;
142  outfile << " \"type\" : \"integer\"" << std::endl;
143  }
144 
145  outfile << " }" << std::endl;
146  outfile << " ]" << std::endl;
147  outfile << "}" << std::endl;
148 
149  outfile.close();
150 
151  //std::cout << "CurrentRunDir is " << RunDir << std::endl; //***
152 }
void addLegendItem(std::string const &name, std::string const &type, std::string const &operation)
int i
Definition: DBlmapReader.cc:9
DataPointDefinition outJson_
virtual void setName(std::string name)
std::vector< std::string > hltNames_
HLTConfigProvider hltConfig_
int j
Definition: DBlmapReader.cc:9
#define SUM(A, B)
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
void reset(bool changed=false)
std::string const & process() const
Definition: InputTag.h:46
void setDefaultGroup(std::string const &group)
std::vector< IntJ > hltPaths_
void TriggerJSONMonitoring::endLuminosityBlock ( edm::LuminosityBlock const &  ls,
edm::EventSetup const &   
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 174 of file TriggerJSONMonitoring.cc.

References baseRunDir, hltNames_, hltPaths_, i, jsonMonitor_, LogDebug, edm::LuminosityBlockBase::luminosityBlock(), edm::LuminosityBlockBase::run(), findQualityFiles::size, contentValuesCheck::ss, and AlCaHLTBitMon_QueryRunRegistry::string.

175 {
176 
177  unsigned int uiLS = ls.luminosityBlock();
178  unsigned int uiRun = ls.run();
179 
180  jsonMonitor_->snap(uiLS);
181 
182  std::stringstream ss;
183  ss << baseRunDir << "/mon/" << "HLTRates";
184  ss << "_run" << uiRun << "_ls" << std::setfill('0') << std::setw(4) << uiLS;
185  ss << "_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsn";
186  std::string outputJsonNameStream = ss.str();
187 
188  jsonMonitor_->outputFullJSON(outputJsonNameStream, uiLS);
189 
190  // Debug output
191  LogDebug("TriggerJSONMonitoring") << "i hltNames #Accepted" << std::endl;
192  const unsigned int size = hltNames_.size();
193  for (unsigned int i = 0; i < size; i++) {
194  LogDebug("TriggerJSONMonitoring") << i << " "
195  << hltNames_[i] << " "
196  << hltPaths_[i].value() << std::endl;
197  }
198 
199 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
boost::shared_ptr< jsoncollector::FastMonitor > jsonMonitor_
std::vector< std::string > hltNames_
std::vector< IntJ > hltPaths_
tuple size
Write out results.
void TriggerJSONMonitoring::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 35 of file TriggerJSONMonitoring.cc.

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

35  {
37  desc.add<edm::InputTag>("triggerResults",edm::InputTag("TriggerResults","","HLT"));
38  descriptions.add("triggerJSONMonitoring", desc);
39 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void TriggerJSONMonitoring::reset ( bool  changed = false)

Definition at line 69 of file TriggerJSONMonitoring.cc.

References hltConfig_, hltNames_, hltPaths_, i, n, processed_, HLTConfigProvider::triggerNames(), and jsoncollector::IntJ::value().

Referenced by beginLuminosityBlock(), and beginRun().

69  {
70 
71  processed_.value() = 0;
72 
73  // update trigger names
74  if (changed) hltNames_ = hltConfig_.triggerNames();
75 
76  const unsigned int n = hltNames_.size();
77 
78  if (changed) {
79  // resize per-path counter
80  hltPaths_.resize(n);
81  }
82 
83  // reset per-path counter
84  for (unsigned int i = 0; i < n; i++) {
85  hltPaths_[i].value() = 0;
86  }
87 
88 }
int i
Definition: DBlmapReader.cc:9
const std::vector< std::string > & triggerNames() const
names of trigger paths
std::vector< std::string > hltNames_
HLTConfigProvider hltConfig_
std::vector< IntJ > hltPaths_

Member Data Documentation

std::string TriggerJSONMonitoring::baseRunDir
private

Definition at line 54 of file TriggerJSONMonitoring.h.

Referenced by beginRun(), and endLuminosityBlock().

HLTConfigProvider TriggerJSONMonitoring::hltConfig_
private

Definition at line 64 of file TriggerJSONMonitoring.h.

Referenced by beginRun(), and reset().

std::vector<std::string> TriggerJSONMonitoring::hltNames_
private

Definition at line 56 of file TriggerJSONMonitoring.h.

Referenced by analyze(), beginRun(), endLuminosityBlock(), and reset().

std::vector<IntJ> TriggerJSONMonitoring::hltPaths_
private
std::string TriggerJSONMonitoring::jsonDefinitionFile
private

Definition at line 59 of file TriggerJSONMonitoring.h.

Referenced by beginLuminosityBlock(), and beginRun().

boost::shared_ptr<jsoncollector::FastMonitor> TriggerJSONMonitoring::jsonMonitor_
private

Definition at line 50 of file TriggerJSONMonitoring.h.

Referenced by beginLuminosityBlock(), and endLuminosityBlock().

DataPointDefinition TriggerJSONMonitoring::outJson_
private

Definition at line 51 of file TriggerJSONMonitoring.h.

Referenced by beginLuminosityBlock(), and beginRun().

IntJ TriggerJSONMonitoring::processed_
private

Definition at line 52 of file TriggerJSONMonitoring.h.

Referenced by analyze(), beginLuminosityBlock(), beginRun(), and reset().

edm::InputTag TriggerJSONMonitoring::triggerResults_
private

Definition at line 61 of file TriggerJSONMonitoring.h.

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

edm::EDGetTokenT<edm::TriggerResults> TriggerJSONMonitoring::triggerResultsToken_
private

Definition at line 62 of file TriggerJSONMonitoring.h.

Referenced by analyze(), and TriggerJSONMonitoring().