CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

DQMClientExample Class Reference

#include <DQMClientExample.h>

Inheritance diagram for DQMClientExample:
edm::EDAnalyzer

List of all members.

Public Member Functions

 DQMClientExample (const edm::ParameterSet &ps)
virtual ~DQMClientExample ()

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

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_

Detailed Description

* DQM Test Client

Date:
2010/07/19 22:17:41
Revision:
1.8
Author:
M. Zanetti CERN

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.

DQMClientExample::~DQMClientExample ( ) [virtual]

Definition at line 46 of file DQMClientExample.cc.

                                   {
}

Member Function Documentation

void DQMClientExample::analyze ( const edm::Event e,
const edm::EventSetup c 
) [protected, virtual]

Implements edm::EDAnalyzer.

Definition at line 116 of file DQMClientExample.cc.

void DQMClientExample::beginJob ( void  ) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 89 of file DQMClientExample.cc.

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

                               {

  dbe_ = Service<DQMStore>().operator->();

  dbe_->setCurrentFolder(monitorName_+"DQMclient");
  clientHisto = dbe_->book1D("clientHisto", "Guassian fit results.", 2, 0, 1);
}
void DQMClientExample::beginLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup context 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 108 of file DQMClientExample.cc.

                                                                                                     {
   // optionally reset histograms here
   // clientHisto->Reset();
}
void DQMClientExample::beginRun ( const edm::Run r,
const edm::EventSetup c 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 102 of file DQMClientExample.cc.

                                                                       {
}
void DQMClientExample::endJob ( void  ) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 142 of file DQMClientExample.cc.

References gather_cfg::cout.

                             {
   std::cout << "DQMSourceClient::endJob()" << std::endl;
   if(clientOnEndJob) performClient();
}
void DQMClientExample::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 126 of file DQMClientExample.cc.

void DQMClientExample::endRun ( const edm::Run r,
const edm::EventSetup c 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 135 of file DQMClientExample.cc.

void DQMClientExample::initialize ( ) [private]

Definition at line 52 of file DQMClientExample.cc.

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

                                 { 

  counterEvt_=0;   counterLS_  = 0; 
  counterClientOperation = 0;
  
  dbe_ = Service<DQMStore>().operator->();
  
  monitorName_ = parameters_.getUntrackedParameter<string>("monitorName","YourSubsystemName");
  cout << "DQMClientExample: Monitor name = " << monitorName_ << endl;
  if (monitorName_ != "" ) monitorName_ = monitorName_+"/" ;

  prescaleLS_  = parameters_.getUntrackedParameter<int>("prescaleLS",  -1);
  cout << "DQMClientExample: DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< endl;
  prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
  cout << "DQMClientExample: DQM event prescale = " << prescaleEvt_ << " events(s)"<< endl;

  //-- QTestName that is going to bu run on clienHisto, as defined in XML file
  QTestName_ = parameters_.getUntrackedParameter<string>("QTestName","exampleQTest");  
  cout << "DQMClientExample: QTest name to be ran on clientHisto = " << QTestName_ << endl;
  //-- define where to run the Client
  clientOnEachEvent  = parameters_.getUntrackedParameter<bool>("clientOnEachEvent",false);
  if(clientOnEachEvent) cout << "DQMClientExample: run Client on each event" << endl;
  clientOnEndLumi  = parameters_.getUntrackedParameter<bool>("clientOnEndLumi",true);
  if(clientOnEndLumi) cout << "DQMClientExample: run Client at the end of each lumi section" << endl;
  clientOnEndRun   = parameters_.getUntrackedParameter<bool>("clientOnEndRun",false);
  if(clientOnEndRun) cout << "DQMClientExample: run Client at the end of each run" << endl;
  clientOnEndJob   = parameters_.getUntrackedParameter<bool>("clientOnEndJob",false);
  if(clientOnEndJob) cout << "DQMClientExample: run Client at the end of the job" << endl;

}
void DQMClientExample::performClient ( ) [protected]

Definition at line 151 of file DQMClientExample.cc.

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

                                    {

   std::cout << "***** run  Client operations as defined in: *****" << std::endl;
   std::cout << "***** DQMClientExample::performClient    ********" << std::endl;

  //----------------------------------------------------------------------------------------------
  // example how to retrieve a ME created by the DQM producer (in Examples/src/DQMSourceExample.cc) 
  //---------------------------------------------------------------------------------------------
   float mean =0;  float rms = 0;
  
  string histoName = monitorName_ + "DQMsource/C1/histo2";
  MonitorElement * meHisto = dbe_->get(histoName);
  if (meHisto) { 
    if (TH1F *rootHisto = meHisto->getTH1F()) {
      if(counterClientOperation<1)
      std::cout<<"=== DQMClientExample::performClient => the histo is found: entries="<< rootHisto->GetEntries() << "\n" 
              <<" mean=" << rootHisto->GetMean() << " rms=" << rootHisto->GetRMS() << std::endl;

      TF1 *f1 = new TF1("f1","gaus",1,3);
      rootHisto->Fit("f1");
      mean = f1->GetParameter(1);
      rms = f1->GetParameter(2);
    }
  clientHisto->setBinContent(1,mean);
  clientHisto->setBinContent(2,rms);
  }

  else { //when it is not found !
  clientHisto->setBinContent(1,-1);
  clientHisto->setBinContent(2,-1);
 if(counterClientOperation<1)  edm::LogError ("DQMClientExample") <<"--- The following ME :"<< histoName <<" cannot be found\n" 
                               <<"--- on the DQM source side !\n";
  }
 
  //----------------------------------------------------------------------------------------------
  // example  how to access the Quality test result for clientHisto
  //---------------------------------------------------------------------------------------------

 // qtest to be ran on clientHisto is defined in Examples/test/QualityTests.xml
  const QReport * theQReport = clientHisto->getQReport(QTestName_);
  if(theQReport) {
    if(counterClientOperation<1)
    edm::LogWarning ("DQMClientExample") <<"*** Summary of Quality Test for clientHisto: \n"
                                       //<<"---  value  ="<< theQReport->getQTresult()<<"\n"
                                      <<"--- status ="<< theQReport->getStatus() << "\n"
                                      <<"--- message ="<< theQReport->getMessage() << "\n";

   vector<dqm::me_util::Channel> badChannels = theQReport->getBadChannels();
    for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); 
         channel != badChannels.end(); channel++) {
        if(counterClientOperation<1) 
        edm::LogError ("DQMClientExample") <<" Bad channels: "<<(*channel).getBin()<<" "<<(*channel).getContents();
    }
  } 
  else { 
  if(counterClientOperation<1) edm::LogError ("DQMClientExample") <<"--- No QReport is found for clientHisto!\n"
  << "--- Please check your XML and config files -> QTestName ( " << QTestName_ << " )must be the same!\n";
  }

 counterClientOperation++;
}

Member Data Documentation

Definition at line 91 of file DQMClientExample.h.

Definition at line 85 of file DQMClientExample.h.

Definition at line 88 of file DQMClientExample.h.

Definition at line 86 of file DQMClientExample.h.

Definition at line 87 of file DQMClientExample.h.

Definition at line 80 of file DQMClientExample.h.

Definition at line 81 of file DQMClientExample.h.

Definition at line 82 of file DQMClientExample.h.

Definition at line 77 of file DQMClientExample.h.

std::string DQMClientExample::monitorName_ [private]

Definition at line 78 of file DQMClientExample.h.

Definition at line 75 of file DQMClientExample.h.

Definition at line 83 of file DQMClientExample.h.

Definition at line 84 of file DQMClientExample.h.

std::string DQMClientExample::QTestName_ [private]

Definition at line 79 of file DQMClientExample.h.