CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
DQMClientExample Class Reference

#include <DQMClientExample.h>

Inheritance diagram for DQMClientExample:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 DQMClientExample (const edm::ParameterSet &ps)
 
 ~DQMClientExample () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
void beginJob () override
 
void beginLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context) override
 
void beginRun (const edm::Run &r, const edm::EventSetup &c) override
 
void endJob () override
 
void endLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
 
void endRun (const edm::Run &r, const edm::EventSetup &c) override
 
void performClient ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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)
 

Private Member Functions

void initialize ()
 

Private Attributes

MonitorElementclientHisto
 
bool clientOnEachEvent
 
bool clientOnEndJob
 
bool clientOnEndLumi
 
bool clientOnEndRun
 
int counterClientOperation
 
int counterEvt_
 
int counterLS_
 
DQMStoredbe_
 
std::string monitorName_
 
edm::ParameterSet parameters_
 
int prescaleEvt_
 
int prescaleLS_
 
std::string QTestName_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 

Detailed Description

Definition at line 29 of file DQMClientExample.h.

Constructor & Destructor Documentation

DQMClientExample::DQMClientExample ( const edm::ParameterSet ps)

Definition at line 35 of file DQMClientExample.cc.

References initialize().

35  {
36  parameters_ = ps;
37  initialize();
38 }
edm::ParameterSet parameters_
DQMClientExample::~DQMClientExample ( )
override

Definition at line 40 of file DQMClientExample.cc.

40 {}

Member Function Documentation

void DQMClientExample::analyze ( const edm::Event e,
const edm::EventSetup c 
)
overrideprotected

Definition at line 111 of file DQMClientExample.cc.

111  {
112  counterEvt_++;
113  if (clientOnEachEvent) {
114  if (prescaleEvt_ > 0 && counterEvt_ % prescaleEvt_ == 0)
115  performClient();
116  }
117 }
void DQMClientExample::beginJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 86 of file DQMClientExample.cc.

References dbe_, and Utilities::operator.

86  {
89 
91  dbe_->setCurrentFolder(monitorName_ + "DQMclient");
92  clientHisto = dbe_->book1D("clientHisto", "Guassian fit results.", 2, 0, 1);
93 }
std::string monitorName_
MonitorElement * clientHisto
void DQMClientExample::beginLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup context 
)
overrideprotected

Definition at line 103 of file DQMClientExample.cc.

103  {
104  // optionally reset histograms here
105  // clientHisto->Reset();
106 }
void DQMClientExample::beginRun ( const edm::Run r,
const edm::EventSetup c 
)
overrideprotected

Definition at line 98 of file DQMClientExample.cc.

98 {}
void DQMClientExample::endJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 140 of file DQMClientExample.cc.

References gather_cfg::cout.

140  {
141  std::cout << "DQMSourceClient::endJob()" << std::endl;
142  if (clientOnEndJob)
143  performClient();
144 }
void DQMClientExample::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
)
overrideprotected

Definition at line 122 of file DQMClientExample.cc.

122  {
123  counterLS_++;
125  if (prescaleLS_ > 0 && counterLS_ % prescaleLS_ == 0)
126  performClient();
127  }
128 }
void DQMClientExample::endRun ( const edm::Run r,
const edm::EventSetup c 
)
overrideprotected

Definition at line 132 of file DQMClientExample.cc.

132  {
133  if (clientOnEndRun)
134  performClient();
135 }
void DQMClientExample::initialize ( )
private

Definition at line 45 of file DQMClientExample.cc.

References gather_cfg::cout, dbe_, and Utilities::operator.

45  {
47  counterEvt_ = 0;
48  counterLS_ = 0;
50 
53 
55  monitorName_ = parameters_.getUntrackedParameter<string>("monitorName", "YourSubsystemName");
56  cout << "DQMClientExample: Monitor name = " << monitorName_ << endl;
57  if (!monitorName_.empty())
58  monitorName_ = monitorName_ + "/";
59 
61  prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
62  cout << "DQMClientExample: DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)" << endl;
63  prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
64  cout << "DQMClientExample: DQM event prescale = " << prescaleEvt_ << " events(s)" << endl;
65 
66  //-- QTestName that is going to bu run on clienHisto, as defined in XML file
67  QTestName_ = parameters_.getUntrackedParameter<string>("QTestName", "exampleQTest");
68  cout << "DQMClientExample: QTest name to be ran on clientHisto = " << QTestName_ << endl;
69  //-- define where to run the Client
70  clientOnEachEvent = parameters_.getUntrackedParameter<bool>("clientOnEachEvent", false);
72  cout << "DQMClientExample: run Client on each event" << endl;
73  clientOnEndLumi = parameters_.getUntrackedParameter<bool>("clientOnEndLumi", true);
74  if (clientOnEndLumi)
75  cout << "DQMClientExample: run Client at the end of each lumi section" << endl;
76  clientOnEndRun = parameters_.getUntrackedParameter<bool>("clientOnEndRun", false);
77  if (clientOnEndRun)
78  cout << "DQMClientExample: run Client at the end of each run" << endl;
79  clientOnEndJob = parameters_.getUntrackedParameter<bool>("clientOnEndJob", false);
80  if (clientOnEndJob)
81  cout << "DQMClientExample: run Client at the end of the job" << endl;
82 }
T getUntrackedParameter(std::string const &, T const &) const
edm::ParameterSet parameters_
std::string QTestName_
std::string monitorName_
void DQMClientExample::performClient ( )
protected

Definition at line 149 of file DQMClientExample.cc.

References gather_cfg::cout, dbe_, connectstrParser::f1, QReport::getBadChannels(), QReport::getMessage(), QReport::getStatus(), MonitorElement::getTH1F(), SiStripPI::mean, and SiStripPI::rms.

149  {
150  std::cout << "***** run Client operations as defined in: *****" << std::endl;
151  std::cout << "***** DQMClientExample::performClient ********" << std::endl;
152 
153  //----------------------------------------------------------------------------------------------
154  // example how to retrieve a ME created by the DQM producer (in
155  // Examples/src/DQMSourceExample.cc)
156  //---------------------------------------------------------------------------------------------
157  float mean = 0;
158  float rms = 0;
159 
161  string histoName = monitorName_ + "DQMsource/C1/histo2";
162  MonitorElement *meHisto = dbe_->get(histoName);
164  if (meHisto) {
166  if (TH1F *rootHisto = meHisto->getTH1F()) {
167  if (counterClientOperation < 1)
168  std::cout << "=== DQMClientExample::performClient => the histo is "
169  "found: entries="
170  << rootHisto->GetEntries() << "\n"
171  << " mean=" << rootHisto->GetMean() << " rms=" << rootHisto->GetRMS() << std::endl;
172 
174  TF1 *f1 = new TF1("f1", "gaus", 1, 3);
175  rootHisto->Fit(f1);
176  mean = f1->GetParameter(1);
177  rms = f1->GetParameter(2);
178  }
179  clientHisto->setBinContent(1, mean);
180  clientHisto->setBinContent(2, rms);
181  }
182 
183  else { // when it is not found !
184  clientHisto->setBinContent(1, -1);
185  clientHisto->setBinContent(2, -1);
186  if (counterClientOperation < 1)
187  edm::LogError("DQMClientExample") << "--- The following ME :" << histoName << " cannot be found\n"
188  << "--- on the DQM source side !\n";
189  }
190 
191  //----------------------------------------------------------------------------------------------
192  // example how to access the Quality test result for clientHisto
193  //---------------------------------------------------------------------------------------------
194 
195  // qtest to be ran on clientHisto is defined in Examples/test/QualityTests.xml
196  const QReport *theQReport = clientHisto->getQReport(QTestName_);
197  if (theQReport) {
198  if (counterClientOperation < 1)
199  edm::LogWarning("DQMClientExample") << "*** Summary of Quality Test for clientHisto: \n"
200  //<<"--- value ="<< theQReport->getQTresult()<<"\n"
201  << "--- status =" << theQReport->getStatus() << "\n"
202  << "--- message =" << theQReport->getMessage() << "\n";
203 
204  vector<dqm::me_util::Channel> badChannels = theQReport->getBadChannels();
205  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
206  channel++) {
207  if (counterClientOperation < 1)
208  edm::LogError("DQMClientExample")
209  << " Bad channels: " << (*channel).getBin() << " " << (*channel).getContents();
210  }
211  } else {
212  if (counterClientOperation < 1)
213  edm::LogError("DQMClientExample") << "--- No QReport is found for clientHisto!\n"
214  << "--- Please check your XML and config files -> QTestName ( " << QTestName_
215  << " )must be the same!\n";
216  }
217 
219 }
const QReport * getQReport(const std::string &qtname) const
get QReport corresponding to <qtname> (null pointer if QReport does not exist)
void setBinContent(int binx, double content)
set content of bin (1-D)
const std::vector< DQMChannel > & getBadChannels() const
Definition: QReport.h:33
TH1F * getTH1F() const
std::string QTestName_
std::string monitorName_
const std::string & getMessage() const
get message attached to test
Definition: QReport.h:24
MonitorElement * clientHisto
int getStatus() const
get test status (see Core/interface/QTestStatus.h)
Definition: QReport.h:16

Member Data Documentation

MonitorElement* DQMClientExample::clientHisto
private

Definition at line 82 of file DQMClientExample.h.

bool DQMClientExample::clientOnEachEvent
private

Definition at line 76 of file DQMClientExample.h.

bool DQMClientExample::clientOnEndJob
private

Definition at line 79 of file DQMClientExample.h.

bool DQMClientExample::clientOnEndLumi
private

Definition at line 77 of file DQMClientExample.h.

bool DQMClientExample::clientOnEndRun
private

Definition at line 78 of file DQMClientExample.h.

int DQMClientExample::counterClientOperation
private

Definition at line 71 of file DQMClientExample.h.

int DQMClientExample::counterEvt_
private

Definition at line 72 of file DQMClientExample.h.

int DQMClientExample::counterLS_
private

Definition at line 73 of file DQMClientExample.h.

DQMStore* DQMClientExample::dbe_
private

Definition at line 68 of file DQMClientExample.h.

std::string DQMClientExample::monitorName_
private

Definition at line 69 of file DQMClientExample.h.

edm::ParameterSet DQMClientExample::parameters_
private
int DQMClientExample::prescaleEvt_
private

Definition at line 74 of file DQMClientExample.h.

int DQMClientExample::prescaleLS_
private

Definition at line 75 of file DQMClientExample.h.

std::string DQMClientExample::QTestName_
private

Definition at line 70 of file DQMClientExample.h.