CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/Validation/HcalDigis/interface/HcalDigisClient.h

Go to the documentation of this file.
00001 /* 
00002  * File:   HcalDigisClient.h
00003  * Author: fahim
00004  *
00005  * Created on June 11, 2011, 6:38 PM
00006  */
00007 
00008 #ifndef HCALDIGISCLIENT_H
00009 #define HCALDIGISCLIENT_H
00010 
00011 #include <memory>
00012 
00013 // user include files
00014 #include "FWCore/Framework/interface/Frameworkfwd.h"
00015 #include "FWCore/Framework/interface/EDAnalyzer.h"
00016 #include "FWCore/ServiceRegistry/interface/Service.h"
00017 #include "FWCore/Framework/interface/MakerMacros.h"
00018 
00019 #include "FWCore/Framework/interface/Event.h"
00020 #include "FWCore/Framework/interface/MakerMacros.h"
00021 
00022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00023 
00024 #include "DQMServices/Core/interface/DQMStore.h"
00025 #include "DQMServices/Core/interface/MonitorElement.h"
00026 
00027 class HcalDigisClient : public edm::EDAnalyzer {
00028 public:
00029     explicit HcalDigisClient(const edm::ParameterSet&);
00030 
00031     ~HcalDigisClient() {
00032     };
00033 
00034 private:
00035 
00036     virtual void beginJob() {
00037     };
00038     virtual void analyze(const edm::Event&, const edm::EventSetup&);
00039 
00040     virtual void endJob() {
00041         if (outputFile_.size() != 0 && dbe_) dbe_->save(outputFile_);
00042 
00043     };
00044 
00045     virtual void beginRun(edm::Run const&, edm::EventSetup const&) {
00046     };
00047 
00048     virtual void endRun(edm::Run const&, edm::EventSetup const&) {
00049 
00050         if (dbe_) dbe_->setCurrentFolder(dirName_);
00051         runClient();
00052     };
00053 
00054     struct HistLim {
00055 
00056         HistLim(int nbin, double mini, double maxi)
00057         : n(nbin), min(mini), max(maxi) {
00058         }
00059         int n;
00060         double min;
00061         double max;
00062     };
00063 
00064     virtual void runClient();
00065     int HcalDigisEndjob(const std::vector<MonitorElement*> &hcalMEs, std::string subdet_);
00066 
00067     MonitorElement* monitor(std::string name);
00068 
00069     void book1D(std::string name, int n, double min, double max) {
00070         if (!msm_->count(name)) (*msm_)[name] = dbe_->book1D(name.c_str(), name.c_str(), n, min, max);
00071     }
00072 
00073     void book1D(std::string name, HistLim limX) {
00074         if (!msm_->count(name)) (*msm_)[name] = dbe_->book1D(name.c_str(), name.c_str(), limX.n, limX.min, limX.max);
00075     }
00076 
00077     void fill1D(std::string name, double X, double weight = 1) {
00078         msm_->find(name)->second->Fill(X, weight);
00079     }
00080 
00081     void book2D(std::string name, HistLim limX, HistLim limY) {
00082         if (!msm_->count(name)) (*msm_)[name] = dbe_->book2D(name.c_str(), name.c_str(), limX.n, limX.min, limX.max, limY.n, limY.min, limY.max);
00083     }
00084 
00085     void fill2D(std::string name, double X, double Y, double weight = 1) {
00086         msm_->find(name)->second->Fill(X, Y, weight);
00087     }
00088 
00089     void bookPf(std::string name, HistLim limX, HistLim limY) {
00090         if (!msm_->count(name)) (*msm_)[name] = dbe_->bookProfile(name.c_str(), name.c_str(), limX.n, limX.min, limX.max, limY.n, limY.min, limY.max);
00091     }
00092 
00093     void fillPf(std::string name, double X, double Y) {
00094         msm_->find(name)->second->Fill(X, Y);
00095     }
00096 
00097     void booking(std::string subdetopt);
00098 
00099     std::string str(int x);
00100 
00101     double integralMETH2D(MonitorElement* ME, int i0, int i1, int j0, int j1);
00102     void scaleMETH2D(MonitorElement* ME, double s);
00103     std::map<std::string, MonitorElement*> *msm_;
00104     DQMStore* dbe_;
00105     std::string outputFile_;
00106     std::string dirName_;
00107 };
00108 
00109 
00110 
00111 #endif  /* HCALDIGISCLIENT_H */
00112