Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:09:23

0001 
0002 #include "DQMOffline/EGamma/interface/ElectronDqmAnalyzerBase.h"
0003 //#include "DQMServices/Core/interface/DQMStore.h"
0004 #include "FWCore/ServiceRegistry/interface/Service.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "TMath.h"
0008 #include "TFile.h"
0009 #include "TH1F.h"
0010 #include "TH1I.h"
0011 #include "TH2F.h"
0012 #include "TProfile.h"
0013 #include "TTree.h"
0014 #include <iostream>
0015 #include <algorithm>
0016 #include <sstream>
0017 
0018 ElectronDqmAnalyzerBase::ElectronDqmAnalyzerBase(const edm::ParameterSet &conf)
0019     : bookPrefix_("ele"), bookIndex_(0), histoNamesReady(false) {
0020   verbosity_ = conf.getUntrackedParameter<int>("Verbosity");
0021   finalStep_ = conf.getParameter<std::string>("FinalStep");
0022   inputFile_ = conf.getParameter<std::string>("InputFile");
0023   outputFile_ = conf.getParameter<std::string>("OutputFile");
0024   inputInternalPath_ = conf.getParameter<std::string>("InputFolderName");
0025   outputInternalPath_ = conf.getParameter<std::string>("OutputFolderName");
0026 }
0027 
0028 ElectronDqmAnalyzerBase::~ElectronDqmAnalyzerBase() {}
0029 
0030 void ElectronDqmAnalyzerBase::setBookPrefix(const std::string &prefix) { bookPrefix_ = prefix; }
0031 
0032 void ElectronDqmAnalyzerBase::setBookIndex(short index) { bookIndex_ = index; }
0033 
0034 void ElectronDqmAnalyzerBase::setBookEfficiencyFlag(const bool &eff_flag) { bookEfficiencyFlag_ = eff_flag; }
0035 
0036 void ElectronDqmAnalyzerBase::setBookStatOverflowFlag(const bool &statOverflow_flag) {
0037   bookStatOverflowFlag_ = statOverflow_flag;
0038 }
0039 
0040 std::string ElectronDqmAnalyzerBase::newName(const std::string &name) {
0041   if (bookPrefix_.empty()) {
0042     return name;
0043   }
0044   std::ostringstream oss;
0045   oss << bookPrefix_;
0046   if (bookIndex_ >= 0) {
0047     oss << bookIndex_++;
0048   }
0049   oss << "_" << name;
0050   return oss.str();
0051 }
0052 
0053 void ElectronDqmAnalyzerBase::bookHistograms(DQMStore::IBooker &ibooker_, edm::Run const &, edm::EventSetup const &) {
0054   edm::LogInfo("DQMAnalyzeBase::bookHistograms") << std::endl;
0055 }
0056 
0057 ElectronDqmAnalyzerBase::MonitorElement *ElectronDqmAnalyzerBase::bookH1(DQMStore::IBooker &iBooker,
0058                                                                          const std::string &name,
0059                                                                          const std::string &title,
0060                                                                          int nchX,
0061                                                                          double lowX,
0062                                                                          double highX,
0063                                                                          const std::string &titleX,
0064                                                                          const std::string &titleY,
0065                                                                          Option_t *option) {
0066   iBooker.setCurrentFolder(outputInternalPath_);
0067   MonitorElement *me = iBooker.book1D(newName(name), title, nchX, lowX, highX);
0068   if (!titleX.empty()) {
0069     me->setAxisTitle(titleX);
0070   }
0071   if (!titleY.empty()) {
0072     me->setAxisTitle(titleY, 2);
0073   }
0074   if (TString(option) != "") {
0075     me->setOption(option);
0076   }
0077   if (bookStatOverflowFlag_) {
0078     me->setStatOverflows(kTRUE);
0079   }
0080   return me;
0081 }
0082 
0083 ElectronDqmAnalyzerBase::MonitorElement *ElectronDqmAnalyzerBase::bookH1withSumw2(DQMStore::IBooker &iBooker,
0084                                                                                   const std::string &name,
0085                                                                                   const std::string &title,
0086                                                                                   int nchX,
0087                                                                                   double lowX,
0088                                                                                   double highX,
0089                                                                                   const std::string &titleX,
0090                                                                                   const std::string &titleY,
0091                                                                                   Option_t *option) {
0092   iBooker.setCurrentFolder(outputInternalPath_);
0093   MonitorElement *me = iBooker.book1D(newName(name), title, nchX, lowX, highX);
0094   if (me->getTH1F()->GetSumw2N() == 0)
0095     me->enableSumw2();
0096   if (!titleX.empty()) {
0097     me->setAxisTitle(titleX);
0098   }
0099   if (!titleY.empty()) {
0100     me->setAxisTitle(titleY, 2);
0101   }
0102   if (TString(option) != "") {
0103     me->setOption(option);
0104   }
0105   if (bookStatOverflowFlag_) {
0106     me->setStatOverflows(kTRUE);
0107   }
0108   return me;
0109 }
0110 
0111 ElectronDqmAnalyzerBase::MonitorElement *ElectronDqmAnalyzerBase::bookH2(DQMStore::IBooker &iBooker,
0112                                                                          const std::string &name,
0113                                                                          const std::string &title,
0114                                                                          int nchX,
0115                                                                          double lowX,
0116                                                                          double highX,
0117                                                                          int nchY,
0118                                                                          double lowY,
0119                                                                          double highY,
0120                                                                          const std::string &titleX,
0121                                                                          const std::string &titleY,
0122                                                                          Option_t *option) {
0123   iBooker.setCurrentFolder(outputInternalPath_);
0124   MonitorElement *me = iBooker.book2D(newName(name), title, nchX, lowX, highX, nchY, lowY, highY);
0125   if (!titleX.empty()) {
0126     me->setAxisTitle(titleX);
0127   }
0128   if (!titleY.empty()) {
0129     me->setAxisTitle(titleY, 2);
0130   }
0131   if (TString(option) != "") {
0132     me->setOption(option);
0133   }
0134   if (bookStatOverflowFlag_) {
0135     me->setStatOverflows(kTRUE);
0136   }
0137   return me;
0138 }
0139 
0140 ElectronDqmAnalyzerBase::MonitorElement *ElectronDqmAnalyzerBase::bookH2withSumw2(DQMStore::IBooker &iBooker,
0141                                                                                   const std::string &name,
0142                                                                                   const std::string &title,
0143                                                                                   int nchX,
0144                                                                                   double lowX,
0145                                                                                   double highX,
0146                                                                                   int nchY,
0147                                                                                   double lowY,
0148                                                                                   double highY,
0149                                                                                   const std::string &titleX,
0150                                                                                   const std::string &titleY,
0151                                                                                   Option_t *option) {
0152   iBooker.setCurrentFolder(outputInternalPath_);
0153   MonitorElement *me = iBooker.book2D(newName(name), title, nchX, lowX, highX, nchY, lowY, highY);
0154   if (me->getTH2F()->GetSumw2N() == 0)
0155     me->enableSumw2();
0156   if (!titleX.empty()) {
0157     me->setAxisTitle(titleX);
0158   }
0159   if (!titleY.empty()) {
0160     me->setAxisTitle(titleY, 2);
0161   }
0162   if (TString(option) != "") {
0163     me->setOption(option);
0164   }
0165   if (bookStatOverflowFlag_) {
0166     me->setStatOverflows(kTRUE);
0167   }
0168   return me;
0169 }
0170 
0171 ElectronDqmAnalyzerBase::MonitorElement *ElectronDqmAnalyzerBase::bookP1(DQMStore::IBooker &iBooker,
0172                                                                          const std::string &name,
0173                                                                          const std::string &title,
0174                                                                          int nchX,
0175                                                                          double lowX,
0176                                                                          double highX,
0177                                                                          double lowY,
0178                                                                          double highY,
0179                                                                          const std::string &titleX,
0180                                                                          const std::string &titleY,
0181                                                                          Option_t *option) {
0182   iBooker.setCurrentFolder(outputInternalPath_);
0183   MonitorElement *me = iBooker.bookProfile(newName(name), title, nchX, lowX, highX, lowY, highY, " ");
0184   if (!titleX.empty()) {
0185     me->getTProfile()->GetXaxis()->SetTitle(titleX.c_str());
0186   }
0187   if (!titleY.empty()) {
0188     me->setAxisTitle(titleY, 2);
0189   }
0190   if (TString(option) != "") {
0191     me->getTProfile()->SetOption(option);
0192   }
0193   if (bookStatOverflowFlag_) {
0194     me->setStatOverflows(kTRUE);
0195   }
0196   return me;
0197 }