CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DQMServices/Examples/src/HarvestingAnalyzer.cc

Go to the documentation of this file.
00001 #include "DQMServices/Examples/interface/HarvestingAnalyzer.h"
00002 
00003 HarvestingAnalyzer::HarvestingAnalyzer(const edm::ParameterSet& iPSet)
00004 {
00005   std::string MsgLoggerCat = "HarvestingAnalyzer_HarvestingAnalyzer";
00006 
00007   fName = iPSet.getUntrackedParameter<std::string>("Name");
00008   verbosity = iPSet.getUntrackedParameter<int>("Verbosity");
00009  
00010   if (verbosity >= 0) {
00011     edm::LogInfo(MsgLoggerCat) 
00012       << "\n===============================\n"
00013       << "Initialized as EDAnalyzer with parameter values:\n"
00014       << "    Name          = " << fName << "\n"
00015       << "    Verbosity     = " << verbosity << "\n"
00016       << "===============================\n";
00017   }
00018 }
00019 
00020 HarvestingAnalyzer::~HarvestingAnalyzer() {}
00021 
00022 void HarvestingAnalyzer::beginJob() 
00023 {
00024   return;
00025 }
00026 
00027 void HarvestingAnalyzer::endJob()
00028 {
00029 
00030   dbe = 0;
00031   dbe = edm::Service<DQMStore>().operator->();
00032 
00033   if (dbe) {
00034 
00035     // monitoring element numerator and denominator histogram
00036     MonitorElement *meN = 
00037       dbe->get("ConverterTest/TH1F/Random1DN");
00038     MonitorElement *meD = 
00039       dbe->get("ConverterTest/TH1F/Random1DD"); 
00040 
00041     if (meN && meD) {
00042 
00043       // get the numerator and denominator histogram            
00044       TH1F *numerator = meN->getTH1F();
00045       numerator->Sumw2();
00046       TH1F *denominator = meD->getTH1F();
00047       denominator->Sumw2();
00048 
00049       // set the current directory
00050       dbe->setCurrentFolder("ConverterTest/TH1F");
00051 
00052       // booked the new histogram to contain the results
00053       MonitorElement *me = 
00054         dbe->book1D("Divide","Divide calculation",
00055                     numerator->GetNbinsX(),
00056                     numerator->GetXaxis()->GetXmin(),
00057                     numerator->GetXaxis()->GetXmax());
00058 
00059       // Calculate the efficiency
00060       me->getTH1F()->Divide(numerator, denominator, 1., 1., "B");
00061 
00062     } else {
00063       std::cout << "Monitor elements don't exist" << std::endl;
00064     }
00065   } else {
00066     std::cout << "Don't have a valid DQM back end" << std::endl;
00067   }
00068 
00069   return;
00070 }
00071 
00072 void HarvestingAnalyzer::beginRun(const edm::Run& iRun, 
00073                                 const edm::EventSetup& iSetup)
00074 {
00075   return;
00076 }
00077 
00078 void HarvestingAnalyzer::endRun(const edm::Run& iRun, 
00079                               const edm::EventSetup& iSetup)
00080 {
00081   return;
00082 }
00083 
00084 void HarvestingAnalyzer::analyze(const edm::Event& iEvent, 
00085                                const edm::EventSetup& iSetup)
00086 {
00087   return;
00088 }