Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:08:37

0001 #ifndef DQM_SiStripCommon_SummaryGenerator_H
0002 #define DQM_SiStripCommon_SummaryGenerator_H
0003 
0004 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
0005 #include <string>
0006 #include <vector>
0007 #include <map>
0008 #include <cstdint>
0009 
0010 class TH1;
0011 
0012 /**
0013    @file DQM/SiStripCommon/interface/SummaryGenerator.h
0014    @class SummaryGenerator
0015    @author M.Wingham, R.Bainbridge
0016    @brief : Fills summary histograms.
0017 */
0018 
0019 class SummaryGenerator {
0020 public:
0021   // ---------- General ----------
0022 
0023   SummaryGenerator(std::string name);
0024   virtual ~SummaryGenerator() { ; }
0025 
0026   // Some useful typedefs
0027   typedef std::pair<float, float> Data;
0028   typedef std::vector<Data> BinData;
0029   typedef std::map<std::string, BinData> HistoData;
0030 
0031   /** Creates instance of derived class based on view parameter. */
0032   static SummaryGenerator* instance(const sistrip::View&);
0033 
0034   // ---------- Contruct name and TObject ----------
0035 
0036   /** Constructs the summary histogram name. */
0037   static std::string name(const sistrip::RunType&,
0038                           const sistrip::Monitorable&,
0039                           const sistrip::Presentation&,
0040                           const sistrip::View&,
0041                           const std::string& directory);
0042 
0043   /** Creates instance of derived class based on view parameter. */
0044   static TH1* histogram(const sistrip::Presentation&, const uint32_t& xbins);
0045 
0046   // ---------- Methods to fill and update histograms ----------
0047 
0048   /** Fills the map that is used to generate the histogram(s). */
0049   void fillMap(const std::string& top_level_dir,
0050                const sistrip::Granularity&,
0051                const uint32_t& key,
0052                const float& value,
0053                const float& error = 0.);
0054 
0055   /** Clear the map that is used to generate the histogram(s). */
0056   void clearMap();
0057 
0058   /** Print contents of map used to generate the histogram(s). */
0059   void printMap();
0060 
0061   /** Creates simple 1D histogram of the parameter values. */
0062   void histo1D(TH1&);
0063 
0064   /** Creates a 1D histogram, with the weighted sum of the parameter
0065       (y-axis) binned as a function of position within the given
0066       logical structure, which is view-dependent (x-axis). */
0067   void histo2DSum(TH1&);
0068 
0069   /** Creates a 2D scatter histogram, with individual values of the
0070       parameter (y-axis) binned as a function of position within the
0071       given logical structure, which is view-dependent (x-axis). */
0072   void histo2DScatter(TH1&);
0073 
0074   /** Creates a profile histogram, with the mean and spread of the
0075       parameter (y-axis) binned as a function of position within the
0076       given logical structure, which is view-dependent (x-axis). */
0077   void profile1D(TH1&);
0078 
0079   // ---------- Histogram formatting ----------
0080 
0081   /** Some generic formatting of histogram. */
0082   void format(const sistrip::RunType&,
0083               const sistrip::Monitorable&,
0084               const sistrip::Presentation&,
0085               const sistrip::View&,
0086               const std::string& directory,
0087               const sistrip::Granularity&,
0088               TH1&);
0089 
0090   /** Optionally set axis label */
0091   inline void axisLabel(const std::string&);
0092 
0093   /** Retrieve size of map (ie, number of bins). */
0094   inline uint32_t nBins() const;
0095   inline uint32_t size() const { return nBins(); }  //@@ TEMPORARY!!!
0096 
0097   // ---------- Utility methods ----------
0098 
0099   /** Returns name of generator object. */
0100   inline const std::string& myName() const;
0101 
0102 protected:
0103   // ---------- Protected methods ----------
0104 
0105   /** Fills the map used to generate the histogram. */
0106   virtual void fill(const std::string& top_level_dir,
0107                     const sistrip::Granularity&,
0108                     const uint32_t& key,
0109                     const float& value,
0110                     const float& error);
0111 
0112 protected:
0113   // ---------- Protected member data ----------
0114 
0115   /** A map designed to holds a set of values. The map containing
0116       these values should be indexed by a key.*/
0117   HistoData map_;
0118 
0119   float entries_;
0120 
0121   float max_;
0122 
0123   float min_;
0124 
0125   std::string label_;
0126 
0127 private:
0128   // ---------- Private member data ----------
0129 
0130   std::string myName_;
0131 };
0132 
0133 const std::string& SummaryGenerator::myName() const { return myName_; }
0134 uint32_t SummaryGenerator::nBins() const { return map_.size(); }
0135 void SummaryGenerator::axisLabel(const std::string& label) { label_ = label; }
0136 
0137 #endif  // DQM_SiStripCommon_SummaryGenerator_H