Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
// -*- C++ -*-
//
// Package:    DQM/SiStripMonitorHardware
// Class:      HistogramBase
//
/**\class HistogramBase DQM/SiStripMonitorHardware/interface/HistogramBase.hh

 Description: DQM source application to produce data integrety histograms for SiStrip data
*/
//
// Original Author:  Nicholas Cripps in plugin file
//         Created:  2008/09/16
// Modified by    :  Anne-Marie Magnan, code copied from plugin to this class
//

#ifndef DQM_SiStripMonitorHardware_HistogramBase_HH
#define DQM_SiStripMonitorHardware_HistogramBase_HH

#include <sstream>

#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "DQM/SiStripCommon/interface/TkHistoMap.h"

#include "DQMServices/Core/interface/DQMStore.h"

class HistogramBase {
public:
  typedef dqm::legacy::DQMStore DQMStore;
  typedef dqm::legacy::MonitorElement MonitorElement;

  struct HistogramConfig {
    HistogramConfig() : globalswitchon(true) {}
    MonitorElement* monitorEle;
    bool enabled;
    unsigned int nBins;
    double min;
    double max;
    bool globalswitchon;
  };

  virtual ~HistogramBase() {}

  //initialise histograms
  //make it pure abstract: implementation in derived class.
  virtual void initialise(const edm::ParameterSet& iConfig, std::ostringstream* pDebugStream) = 0;

  //fill a histogram if the pointer is not NULL (ie if it has been booked)
  static void fillHistogram(HistogramConfig& histogram, double value, double weight = 1.);

  //fill a histogram if the pointer is not NULL (ie if it has been booked)
  static void fillHistogram(MonitorElement* histogram, double value, double weight = 1.);
  //fill a 2D profile trend histogram if the pointer is not NULL (ie if it has been booked)
  static void fillHistogram2D(HistogramConfig& histogram, double value, double trendVar, double weight = 1.);
  //fill tkHistoMap of percentage of bad channels per module
  static void fillTkHistoMap(TkHistoMap* aMap, uint32_t& detid, float value);

  //if one of more histo map, return name and pointer
  virtual bool tkHistoMapEnabled(unsigned int aIndex = 0) = 0;

  virtual TkHistoMap* tkHistoMapPointer(unsigned int aIndex = 0) = 0;

  //load the config for a histogram from PSet called <configName>HistogramConfig (writes a debug message to stream if pointer is non-NULL)
  void getConfigForHistogram(HistogramConfig& aConfig,
                             const std::string& configName,
                             const edm::ParameterSet& psetContainingConfigPSet,
                             std::ostringstream* pDebugStream);

  //book an individual hiostogram if enabled in config
  void bookHistogram(DQMStore::IBooker&,
                     HistogramConfig& aConfig,
                     const std::string& name,
                     const std::string& title,
                     const unsigned int nBins,
                     const double min,
                     const double max,
                     const std::string& xAxisTitle);

  //book an individual hiostogram if enabled in config
  void bookHistogram(DQMStore::IBooker&,
                     HistogramConfig& aConfig,
                     MonitorElement*& aHist,
                     const std::string& name,
                     const std::string& title,
                     const unsigned int nBins,
                     const double min,
                     const double max,
                     const std::string& xAxisTitle);

  //book an individual hiostogram if enabled in config
  void book2DHistogram(DQMStore::IBooker&,
                       HistogramConfig& aConfig,
                       const std::string& name,
                       const std::string& title,
                       const unsigned int nBins,
                       const double min,
                       const double max,
                       const unsigned int nBinsY,
                       const double minY,
                       const double maxY,
                       const std::string& xAxisTitle,
                       const std::string& yAxisTitle);

  //book an individual hiostogram if enabled in config
  void book2DHistogram(DQMStore::IBooker&,
                       HistogramConfig& aConfig,
                       MonitorElement*& aHist,
                       const std::string& name,
                       const std::string& title,
                       const unsigned int nBins,
                       const double min,
                       const double max,
                       const unsigned int nBinsY,
                       const double minY,
                       const double maxY,
                       const std::string& xAxisTitle,
                       const std::string& yAxisTitle);

  //same but using binning from config
  void bookHistogram(DQMStore::IBooker&,
                     HistogramConfig& aConfig,
                     const std::string& name,
                     const std::string& title,
                     const std::string& xAxisTitle);

  void bookProfile(DQMStore::IBooker&,
                   HistogramConfig& aConfig,
                   const std::string& name,
                   const std::string& title,
                   const unsigned int nBins,
                   const double min,
                   const double max,
                   const double minY,
                   const double maxY,
                   const std::string& xAxisTitle,
                   const std::string& yAxisTitle);

  void bookProfile(DQMStore::IBooker&,
                   HistogramConfig& aConfig,
                   const std::string& name,
                   const std::string& title,
                   const double minY,
                   const double maxY,
                   const std::string& xAxisTitle,
                   const std::string& yAxisTitle);
  void bookProfile2D(DQMStore::IBooker&,
                     HistogramConfig& aConfig,
                     const std::string& name,
                     const std::string& title,
                     const unsigned int nBinsx,
                     const double xmin,
                     const double xmax,
                     const unsigned int nBinsy,
                     const double ymin,
                     const double ymax,
                     const std::string& xAxisTitle,
                     const std::string& yAxisTitle);

  void bookProfile2D(DQMStore::IBooker&,
                     HistogramConfig& aConfig,
                     const std::string& name,
                     const std::string& title,
                     const unsigned int nBinsy,
                     const double ymin,
                     const double ymax,
                     const std::string& xAxisTitle,
                     const std::string& yAxisTitle);

protected:
private:
};  //class

#endif  //DQM_SiStripMonitorHardware_HistogramBase_HH