CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
virtual ~DQMClientExample ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
 
void beginJob ()
 
void beginLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
 
void beginRun (const edm::Run &r, const edm::EventSetup &c)
 
void endJob ()
 
void endLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
 
void endRun (const edm::Run &r, const edm::EventSetup &c)
 
void performClient ()
 
- Protected Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- 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)
 

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
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Detailed Description

Definition at line 33 of file DQMClientExample.h.

Constructor & Destructor Documentation

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

Definition at line 40 of file DQMClientExample.cc.

41 {
42  parameters_=ps;
43  initialize();
44 }
edm::ParameterSet parameters_
DQMClientExample::~DQMClientExample ( )
virtual

Definition at line 46 of file DQMClientExample.cc.

46  {
47 }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 116 of file DQMClientExample.cc.

116  {
117  counterEvt_++;
118  if(clientOnEachEvent){
120  }
121 }
void DQMClientExample::beginJob ( void  )
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 89 of file DQMClientExample.cc.

References DQMStore::book1D(), dbe_, cppFunctionSkipper::operator, and DQMStore::setCurrentFolder().

89  {
90 
93 
95  dbe_->setCurrentFolder(monitorName_+"DQMclient");
96  clientHisto = dbe_->book1D("clientHisto", "Guassian fit results.", 2, 0, 1);
97 }
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
std::string monitorName_
MonitorElement * clientHisto
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
void DQMClientExample::beginLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup context 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 108 of file DQMClientExample.cc.

108  {
109  // optionally reset histograms here
110  // clientHisto->Reset();
111 }
void DQMClientExample::beginRun ( const edm::Run r,
const edm::EventSetup c 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 102 of file DQMClientExample.cc.

102  {
103 }
void DQMClientExample::endJob ( void  )
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 142 of file DQMClientExample.cc.

References gather_cfg::cout.

142  {
143  std::cout << "DQMSourceClient::endJob()" << std::endl;
145 }
tuple cout
Definition: gather_cfg.py:121
void DQMClientExample::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 126 of file DQMClientExample.cc.

126  {
127  counterLS_ ++;
129  if( prescaleLS_ > 0 && counterLS_ % prescaleLS_ == 0) performClient();
130  }
131 }
void DQMClientExample::endRun ( const edm::Run r,
const edm::EventSetup c 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 135 of file DQMClientExample.cc.

135  {
137 }
void DQMClientExample::initialize ( )
private

Definition at line 52 of file DQMClientExample.cc.

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

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

Definition at line 151 of file DQMClientExample.cc.

References gather_cfg::cout, dbe_, python.connectstrParser::f1, DQMStore::get(), QReport::getBadChannels(), QReport::getMessage(), QReport::getStatus(), MonitorElement::getTH1F(), timingPdfMaker::mean, and plotscripts::rms().

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

Member Data Documentation

MonitorElement* DQMClientExample::clientHisto
private

Definition at line 91 of file DQMClientExample.h.

bool DQMClientExample::clientOnEachEvent
private

Definition at line 85 of file DQMClientExample.h.

bool DQMClientExample::clientOnEndJob
private

Definition at line 88 of file DQMClientExample.h.

bool DQMClientExample::clientOnEndLumi
private

Definition at line 86 of file DQMClientExample.h.

bool DQMClientExample::clientOnEndRun
private

Definition at line 87 of file DQMClientExample.h.

int DQMClientExample::counterClientOperation
private

Definition at line 80 of file DQMClientExample.h.

int DQMClientExample::counterEvt_
private

Definition at line 81 of file DQMClientExample.h.

int DQMClientExample::counterLS_
private

Definition at line 82 of file DQMClientExample.h.

DQMStore* DQMClientExample::dbe_
private

Definition at line 77 of file DQMClientExample.h.

std::string DQMClientExample::monitorName_
private

Definition at line 78 of file DQMClientExample.h.

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

Definition at line 83 of file DQMClientExample.h.

int DQMClientExample::prescaleLS_
private

Definition at line 84 of file DQMClientExample.h.

std::string DQMClientExample::QTestName_
private

Definition at line 79 of file DQMClientExample.h.