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

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::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
 
- 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 31 of file DQMClientExample.h.

Constructor & Destructor Documentation

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

Definition at line 37 of file DQMClientExample.cc.

References initialize().

38 {
39  parameters_=ps;
40  initialize();
41 }
edm::ParameterSet parameters_
DQMClientExample::~DQMClientExample ( )
virtual

Definition at line 43 of file DQMClientExample.cc.

43  {
44 }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 113 of file DQMClientExample.cc.

113  {
114  counterEvt_++;
115  if(clientOnEachEvent){
117  }
118 }
void DQMClientExample::beginJob ( void  )
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 86 of file DQMClientExample.cc.

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 105 of file DQMClientExample.cc.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 99 of file DQMClientExample.cc.

99  {
100 }
void DQMClientExample::endJob ( void  )
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 139 of file DQMClientExample.cc.

References gather_cfg::cout.

139  {
140  std::cout << "DQMSourceClient::endJob()" << std::endl;
142 }
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 123 of file DQMClientExample.cc.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 132 of file DQMClientExample.cc.

132  {
134 }
void DQMClientExample::initialize ( )
private

Definition at line 49 of file DQMClientExample.cc.

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

49  {
50 
52  counterEvt_=0; counterLS_ = 0;
54 
57 
59  monitorName_ = parameters_.getUntrackedParameter<string>("monitorName","YourSubsystemName");
60  cout << "DQMClientExample: Monitor name = " << monitorName_ << endl;
61  if (monitorName_ != "" ) monitorName_ = monitorName_+"/" ;
62 
64  prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
65  cout << "DQMClientExample: DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< endl;
66  prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
67  cout << "DQMClientExample: DQM event prescale = " << prescaleEvt_ << " events(s)"<< endl;
68 
69  //-- QTestName that is going to bu run on clienHisto, as defined in XML file
70  QTestName_ = parameters_.getUntrackedParameter<string>("QTestName","exampleQTest");
71  cout << "DQMClientExample: QTest name to be ran on clientHisto = " << QTestName_ << endl;
72  //-- define where to run the Client
73  clientOnEachEvent = parameters_.getUntrackedParameter<bool>("clientOnEachEvent",false);
74  if(clientOnEachEvent) cout << "DQMClientExample: run Client on each event" << endl;
75  clientOnEndLumi = parameters_.getUntrackedParameter<bool>("clientOnEndLumi",true);
76  if(clientOnEndLumi) cout << "DQMClientExample: run Client at the end of each lumi section" << endl;
77  clientOnEndRun = parameters_.getUntrackedParameter<bool>("clientOnEndRun",false);
78  if(clientOnEndRun) cout << "DQMClientExample: run Client at the end of each run" << endl;
79  clientOnEndJob = parameters_.getUntrackedParameter<bool>("clientOnEndJob",false);
80  if(clientOnEndJob) cout << "DQMClientExample: run Client at the end of the job" << endl;
81 
82 }
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 148 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().

148  {
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 Examples/src/DQMSourceExample.cc)
155  //---------------------------------------------------------------------------------------------
156  float mean =0; float rms = 0;
157 
159  string histoName = monitorName_ + "DQMsource/C1/histo2";
160  MonitorElement * meHisto = dbe_->get(histoName);
162  if (meHisto) {
164  if (TH1F *rootHisto = meHisto->getTH1F()) {
166  std::cout<<"=== DQMClientExample::performClient => the histo is found: entries="<< rootHisto->GetEntries() << "\n"
167  <<" mean=" << rootHisto->GetMean() << " rms=" << rootHisto->GetRMS() << std::endl;
168 
170  TF1 *f1 = new TF1("f1","gaus",1,3);
171  rootHisto->Fit("f1");
172  mean = f1->GetParameter(1);
173  rms = f1->GetParameter(2);
174  }
175  clientHisto->setBinContent(1,mean);
176  clientHisto->setBinContent(2,rms);
177  }
178 
179  else { //when it is not found !
180  clientHisto->setBinContent(1,-1);
181  clientHisto->setBinContent(2,-1);
182  if(counterClientOperation<1) edm::LogError ("DQMClientExample") <<"--- The following ME :"<< histoName <<" cannot be found\n"
183  <<"--- on the DQM source side !\n";
184  }
185 
186  //----------------------------------------------------------------------------------------------
187  // example how to access the Quality test result for clientHisto
188  //---------------------------------------------------------------------------------------------
189 
190  // qtest to be ran on clientHisto is defined in Examples/test/QualityTests.xml
191  const QReport * theQReport = clientHisto->getQReport(QTestName_);
192  if(theQReport) {
194  edm::LogWarning ("DQMClientExample") <<"*** Summary of Quality Test for clientHisto: \n"
195  //<<"--- value ="<< theQReport->getQTresult()<<"\n"
196  <<"--- status ="<< theQReport->getStatus() << "\n"
197  <<"--- message ="<< theQReport->getMessage() << "\n";
198 
199  vector<dqm::me_util::Channel> badChannels = theQReport->getBadChannels();
200  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin();
201  channel != badChannels.end(); channel++) {
203  edm::LogError ("DQMClientExample") <<" Bad channels: "<<(*channel).getBin()<<" "<<(*channel).getContents();
204  }
205  }
206  else {
207  if(counterClientOperation<1) edm::LogError ("DQMClientExample") <<"--- No QReport is found for clientHisto!\n"
208  << "--- Please check your XML and config files -> QTestName ( " << QTestName_ << " )must be the same!\n";
209  }
210 
212 }
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:1708
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 89 of file DQMClientExample.h.

bool DQMClientExample::clientOnEachEvent
private

Definition at line 83 of file DQMClientExample.h.

bool DQMClientExample::clientOnEndJob
private

Definition at line 86 of file DQMClientExample.h.

bool DQMClientExample::clientOnEndLumi
private

Definition at line 84 of file DQMClientExample.h.

bool DQMClientExample::clientOnEndRun
private

Definition at line 85 of file DQMClientExample.h.

int DQMClientExample::counterClientOperation
private

Definition at line 78 of file DQMClientExample.h.

int DQMClientExample::counterEvt_
private

Definition at line 79 of file DQMClientExample.h.

int DQMClientExample::counterLS_
private

Definition at line 80 of file DQMClientExample.h.

DQMStore* DQMClientExample::dbe_
private

Definition at line 75 of file DQMClientExample.h.

std::string DQMClientExample::monitorName_
private

Definition at line 76 of file DQMClientExample.h.

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

Definition at line 81 of file DQMClientExample.h.

int DQMClientExample::prescaleLS_
private

Definition at line 82 of file DQMClientExample.h.

std::string DQMClientExample::QTestName_
private

Definition at line 77 of file DQMClientExample.h.