Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-07 23:36:52

0001 #ifndef TauDQMHistPlotter_h
0002 #define TauDQMHistPlotter_h
0003 
0004 /** \class TauDQMHistPlotter
0005  *  
0006  *  Class to plot histograms and create a postscript file
0007  *
0008  *  \author Christian Veelken, UC Davis
0009  */
0010 
0011 // framework & common header files
0012 #include "FWCore/Framework/interface/EDAnalyzer.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 
0017 #include "DQMServices/Core/interface/DQMStore.h"
0018 
0019 #include <TH1.h>
0020 #include <TLegend.h>
0021 #include <TPaveText.h>
0022 
0023 #include <string>
0024 #include <vector>
0025 #include <map>
0026 
0027 class TauDQMHistPlotter : public edm::EDAnalyzer {
0028   typedef dqm::legacy::DQMStore DQMStore;
0029   typedef dqm::legacy::MonitorElement MonitorElement;
0030 
0031   typedef std::vector<std::string> vstring;
0032 
0033   struct cfgEntryProcess {
0034     cfgEntryProcess(const std::string&, const edm::ParameterSet&);
0035     void print() const;
0036     std::string name_;
0037     std::string dqmDirectory_;
0038     std::string legendEntry_;
0039     std::string legendEntryErrorBand_;
0040     std::string type_;
0041   };
0042 
0043   struct cfgEntryAxisX {
0044     explicit cfgEntryAxisX(const std::string&, const edm::ParameterSet&);
0045     void print() const;
0046     void applyTo(TH1*) const;
0047     std::string name_;
0048     double minX_;
0049     double maxX_;
0050     std::string xAxisTitle_;
0051     double xAxisTitleOffset_;
0052     double xAxisTitleSize_;
0053   };
0054 
0055   struct cfgEntryAxisY {
0056     explicit cfgEntryAxisY(const std::string&, const edm::ParameterSet&);
0057     void print() const;
0058     void applyTo(TH1*, double norm) const;
0059     std::string name_;
0060     double minY_linear_;
0061     double minY_log_;
0062     double maxY_linear_;
0063     double maxY_log_;
0064     std::string yScale_;
0065     std::string yAxisTitle_;
0066     double yAxisTitleOffset_;
0067     double yAxisTitleSize_;
0068   };
0069 
0070   struct cfgEntryLegend {
0071     cfgEntryLegend(const std::string&, const edm::ParameterSet&);
0072     void print() const;
0073     void applyTo(TLegend*) const;
0074     std::string name_;
0075     double posX_;
0076     double posY_;
0077     double sizeX_;
0078     double sizeY_;
0079     std::string header_;
0080     std::string option_;
0081     int borderSize_;
0082     int fillColor_;
0083   };
0084 
0085   struct cfgEntryLabel {
0086     cfgEntryLabel(const std::string&, const edm::ParameterSet&);
0087     void print() const;
0088     void applyTo(TPaveText*) const;
0089     std::string name_;
0090     double posX_;
0091     double posY_;
0092     double sizeX_;
0093     double sizeY_;
0094     std::string option_;
0095     int borderSize_;
0096     int fillColor_;
0097     int textColor_;
0098     double textSize_;
0099     int textAlign_;
0100     double textAngle_;
0101     vstring text_;
0102   };
0103 
0104   struct cfgEntryDrawOption {
0105     cfgEntryDrawOption(const std::string&, const edm::ParameterSet&);
0106     cfgEntryDrawOption(const std::string&, const cfgEntryDrawOption&);
0107     void print() const;
0108     void applyTo(TH1*) const;
0109     std::string name_;
0110     int markerColor_;
0111     double markerSize_;
0112     int markerStyle_;
0113     int lineColor_;
0114     int lineStyle_;
0115     int lineWidth_;
0116     int fillColor_;
0117     int fillStyle_;
0118     std::string drawOption_;
0119     std::string drawOptionLegend_;
0120   };
0121 
0122   struct plotDefEntry {
0123     plotDefEntry(
0124         const std::string&, const std::string&, const std::string&, const std::string&, const std::string&, bool);
0125     plotDefEntry(const plotDefEntry&);
0126     void print() const;
0127     std::string dqmMonitorElement_;
0128     std::string drawOptionEntry_;
0129     std::string legendEntry_;
0130     std::string legendEntryErrorBand_;
0131     std::string process_;
0132     bool doStack_;
0133     bool isErrorBand_;
0134   };
0135 
0136   typedef std::list<plotDefEntry> plotDefList;
0137 
0138   struct cfgEntryDrawJob {
0139     cfgEntryDrawJob(const std::string&,
0140                     const plotDefList&,
0141                     const std::string&,
0142                     const std::string&,
0143                     const std::string&,
0144                     const std::string&,
0145                     const vstring&);
0146     void print() const;
0147     std::string name_;
0148     plotDefList plots_;
0149     std::string title_;
0150     std::string xAxis_;
0151     std::string yAxis_;
0152     std::string legend_;
0153     vstring labels_;
0154   };
0155 
0156 public:
0157   explicit TauDQMHistPlotter(const edm::ParameterSet&);
0158   ~TauDQMHistPlotter() override;
0159   void analyze(const edm::Event&, const edm::EventSetup&) override;
0160   void endRun(const edm::Run& r, const edm::EventSetup& c) override;
0161 
0162 private:
0163   std::map<std::string, cfgEntryProcess> processes_;
0164   std::map<std::string, cfgEntryAxisX> xAxes_;
0165   std::map<std::string, cfgEntryAxisY> yAxes_;
0166   std::map<std::string, cfgEntryLegend> legends_;
0167   std::map<std::string, cfgEntryLabel> labels_;
0168   std::map<std::string, cfgEntryDrawOption> drawOptionEntries_;
0169   std::list<cfgEntryDrawJob> drawJobs_;
0170   int canvasSizeX_;
0171   int canvasSizeY_;
0172   std::string outputFilePath_;
0173   std::string outputFileName_;
0174   std::string indOutputFileName_;
0175   int cfgError_;
0176   bool toFile_;
0177 };
0178 
0179 #endif