Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:12:55

0001 #ifndef DQMOffline_L1Trigger_HistDefinition_h
0002 #define DQMOffline_L1Trigger_HistDefinition_h
0003 
0004 /**
0005  * \class HistDefinition
0006  *
0007  *
0008  * Description: Class for parsing histogram definitions from a ParameterSet of
0009  * ParameterSets defined in the python configuration. Acceptable parameters are
0010  * all public members of the HistDefinition class.
0011  *
0012  * Python configuration example:
0013  * https://github.com/cms-sw/cmssw/blob/master/DQMOffline/L1Trigger/python/L1THistDefinitions_cff.py
0014  *
0015  * Usage in CMSSW module
0016  * PlotConfig enum, PlotConfigNames map:
0017  * https://github.com/cms-sw/cmssw/blob/master/DQMOffline/L1Trigger/interface/L1TEGammaOffline.h
0018  *
0019  * enum PlotConfig {
0020  *   nVertex
0021  * };
0022  *
0023  * static const std::map<std::string, unsigned int> PlotConfigNames;
0024  *
0025  * https://github.com/cms-sw/cmssw/blob/master/DQMOffline/L1Trigger/src/L1TEGammaOffline.cc
0026  *
0027  * const std::map<std::string, unsigned int> L1TEGammaOffline::PlotConfigNames = {
0028  *  {"nVertex", PlotConfig::nVertex}
0029  * };
0030  * Read from ParameterSet in module constructor:
0031  * histDefinitions_(dqmoffline::l1t::readHistDefinitions(ps.getParameterSet("histDefinitions"), PlotConfigNames)),
0032  *
0033  * Use to create a histogram:
0034  * dqmoffline::l1t::HistDefinition nVertexDef = histDefinitions_[PlotConfig::nVertex];
0035  * h_nVertex_ = ibooker.book1D(
0036  *   nVertexDef.name, nVertexDef.title, nVertexDef.nbinsX, nVertexDef.xmin, nVertexDef.xmax
0037  * );
0038  *
0039  *
0040  * \author: Luke Kreczko - kreczko@cern.ch
0041  *
0042  **/
0043 
0044 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0045 #include <string>
0046 #include <vector>
0047 
0048 namespace dqmoffline {
0049   namespace l1t {
0050 
0051     class HistDefinition;
0052     typedef std::vector<HistDefinition> HistDefinitions;
0053 
0054     class HistDefinition {
0055     public:
0056       HistDefinition();
0057       HistDefinition(const edm::ParameterSet &ps);
0058       ~HistDefinition();
0059       // static HistDefinitions readHistDefinitions(const edm::ParameterSet &ps,
0060       // std::map<std::string, unsigned int>);
0061 
0062       std::string name;
0063       std::string title;
0064       unsigned int nbinsX;
0065       unsigned int nbinsY;
0066       double xmin;
0067       double xmax;
0068       double ymin;
0069       double ymax;
0070       std::vector<double> binsXtmp;
0071       std::vector<double> binsYtmp;
0072       std::vector<float> binsX;
0073       std::vector<float> binsY;
0074     };
0075 
0076     HistDefinitions readHistDefinitions(const edm::ParameterSet &ps,
0077                                         const std::map<std::string, unsigned int> &mapping);
0078 
0079   }  // namespace l1t
0080 }  // namespace dqmoffline
0081 
0082 #endif