00001 #ifndef MESet_H
00002 #define MESet_H
00003
00004 #include <string>
00005 #include <vector>
00006
00007 #include "DQMServices/Core/interface/MonitorElement.h"
00008 #include "DQMServices/Core/interface/DQMStore.h"
00009
00010 #include "DQM/EcalCommon/interface/EcalDQMBinningService.h"
00011
00012 #include "DataFormats/DetId/interface/DetId.h"
00013
00014 #include "DataFormats/EcalDetId/interface/EcalElectronicsId.h"
00015
00016 typedef EcalDQMBinningService BinService;
00017
00018 namespace ecaldqm
00019 {
00020 struct MEData {
00021 std::string pathName;
00022 BinService::ObjectType otype;
00023 BinService::BinningType btype;
00024 MonitorElement::Kind kind;
00025 BinService::AxisSpecs *xaxis;
00026 BinService::AxisSpecs *yaxis;
00027 BinService::AxisSpecs *zaxis;
00028 MEData() :
00029 pathName(""), otype(BinService::nObjType), btype(BinService::nBinType), kind(MonitorElement::DQM_KIND_INVALID),
00030 xaxis(0), yaxis(0), zaxis(0)
00031 {}
00032 MEData(std::string const& _pathName, BinService::ObjectType _otype, BinService::BinningType _btype, MonitorElement::Kind _kind,
00033 BinService::AxisSpecs const* _xaxis = 0, BinService::AxisSpecs const* _yaxis = 0, BinService::AxisSpecs const* _zaxis = 0) :
00034 pathName(_pathName), otype(_otype), btype(_btype), kind(_kind),
00035 xaxis(_xaxis ? new BinService::AxisSpecs(*_xaxis) : 0),
00036 yaxis(_yaxis ? new BinService::AxisSpecs(*_yaxis) : 0),
00037 zaxis(_zaxis ? new BinService::AxisSpecs(*_zaxis) : 0)
00038 {}
00039 MEData(MEData const& _orig) :
00040 pathName(_orig.pathName), otype(_orig.otype), btype(_orig.btype), kind(_orig.kind),
00041 xaxis(_orig.xaxis ? new BinService::AxisSpecs(*_orig.xaxis) : 0),
00042 yaxis(_orig.yaxis ? new BinService::AxisSpecs(*_orig.yaxis) : 0),
00043 zaxis(_orig.zaxis ? new BinService::AxisSpecs(*_orig.zaxis) : 0)
00044 {}
00045 ~MEData()
00046 {
00047 delete xaxis;
00048 delete yaxis;
00049 delete zaxis;
00050 }
00051
00052 MEData& operator=(MEData const& _rhs)
00053 {
00054 pathName = _rhs.pathName;
00055 otype = _rhs.otype;
00056 btype = _rhs.btype;
00057 kind = _rhs.kind;
00058 xaxis = _rhs.xaxis ? new BinService::AxisSpecs(*_rhs.xaxis) : 0;
00059 yaxis = _rhs.yaxis ? new BinService::AxisSpecs(*_rhs.yaxis) : 0;
00060 zaxis = _rhs.zaxis ? new BinService::AxisSpecs(*_rhs.zaxis) : 0;
00061 return *this;
00062 }
00063 };
00064
00065 class MESet {
00066 public :
00067 MESet(std::string const&, MEData const&, bool _readOnly = false);
00068 virtual ~MESet();
00069
00070 virtual void book();
00071 virtual bool retrieve() const;
00072 virtual void clear() const;
00073
00074
00075 virtual void fill(DetId const&, double _wx = 1., double _wy = 1., double _w = 1.);
00076 virtual void fill(EcalElectronicsId const&, double _wx = 1., double _wy = 1., double _w = 1.);
00077 virtual void fill(unsigned, double _wx = 1., double _wy = 1., double _w = 1.);
00078 virtual void fill(double, double _wy = 1., double _w = 1.);
00079
00080 virtual void setBinContent(DetId const&, double, double _err = 0.);
00081 virtual void setBinContent(EcalElectronicsId const&, double, double _err = 0.);
00082 virtual void setBinContent(unsigned, double, double _err = 0.);
00083
00084 virtual void setBinEntries(DetId const&, double);
00085 virtual void setBinEntries(EcalElectronicsId const&, double);
00086 virtual void setBinEntries(unsigned, double);
00087
00088 virtual double getBinContent(DetId const&, int _bin = 0) const;
00089 virtual double getBinContent(EcalElectronicsId const&, int _bin = 0) const;
00090 virtual double getBinContent(unsigned, int _bin = 0) const;
00091
00092 virtual double getBinError(DetId const&, int _bin = 0) const;
00093 virtual double getBinError(EcalElectronicsId const&, int _bin = 0) const;
00094 virtual double getBinError(unsigned, int _bin = 0) const;
00095
00096 virtual double getBinEntries(DetId const&, int _bin = 0) const;
00097 virtual double getBinEntries(EcalElectronicsId const&, int _bin = 0) const;
00098 virtual double getBinEntries(unsigned, int _bin = 0) const;
00099
00100 virtual void setAxisTitle(std::string const&, int _axis = 1);
00101 virtual void setBinLabel(unsigned, int, std::string const&, int _axis = 1);
00102
00103 virtual void reset(double _content = 0., double _err = 0., double _entries = 0.);
00104 virtual void resetAll(double _content = 0., double _err = 0., double _entries = 0.);
00105
00106 std::string const& getDir() const { return dir_; }
00107 void setDir(std::string const& _dir) { dir_ = _dir; }
00108 std::string const& getName() const { return name_; }
00109 void setName(std::string const& _name) { name_ = _name; }
00110 void name(std::map<std::string, std::string> const&) const;
00111 BinService::ObjectType getObjType() const { return data_->otype; }
00112 BinService::BinningType getBinType() const { return data_->btype; }
00113 bool isActive() const { return active_; }
00114
00115 virtual MonitorElement const* getME(unsigned _offset) const { return (_offset < mes_.size() ? mes_[_offset] : 0); }
00116
00117 protected:
00118 virtual void fill_(unsigned, int, double);
00119 virtual void fill_(unsigned, double, double, double);
00120 virtual void setBinContent_(unsigned, int, double, double);
00121 virtual void setBinEntries_(unsigned, int, double);
00122 virtual double getBinContent_(unsigned, int) const;
00123 virtual double getBinError_(unsigned, int) const;
00124 virtual double getBinEntries_(unsigned, int) const;
00125
00126 static BinService const* binService_;
00127 static DQMStore* dqmStore_;
00128
00129 mutable std::vector<MonitorElement*> mes_;
00130
00131 mutable std::string dir_;
00132 mutable std::string name_;
00133 MEData const* data_;
00134
00135 mutable bool active_;
00136 bool readOnly_;
00137 };
00138
00139 }
00140
00141 #endif