File indexing completed on 2024-04-06 12:07:29
0001 #include "DQM/HcalCommon/interface/ContainerSingle1D.h"
0002
0003 namespace hcaldqm {
0004 using namespace quantity;
0005 using namespace constants;
0006 ContainerSingle1D::ContainerSingle1D() {
0007 _qx = nullptr;
0008 _qy = nullptr;
0009 }
0010
0011 ContainerSingle1D::ContainerSingle1D(ContainerSingle1D const &c) : Container(c._folder, c._qname) {
0012 _qx = c._qx->makeCopy();
0013 _qy = c._qy->makeCopy();
0014 }
0015
0016 ContainerSingle1D::ContainerSingle1D(std::string const &folder, Quantity *qx, Quantity *qy)
0017 : Container(folder, qy->name() + "vs" + qx->name()), _qx(qx), _qy(qy) {
0018 _qx->setAxisType(quantity::fXAxis);
0019 _qy->setAxisType(quantity::fYAxis);
0020 }
0021
0022 ContainerSingle1D::ContainerSingle1D(std::string const &folder, std::string const &qname, Quantity *qx, Quantity *qy)
0023 : Container(folder, qname), _qx(qx), _qy(qy) {
0024 _qx->setAxisType(quantity::fXAxis);
0025 _qy->setAxisType(quantity::fYAxis);
0026 }
0027
0028 ContainerSingle1D::~ContainerSingle1D() {
0029 if (_qx != nullptr)
0030 delete _qx;
0031 if (_qy != nullptr)
0032 delete _qy;
0033 _qx = nullptr;
0034 _qy = nullptr;
0035 }
0036
0037 void ContainerSingle1D::initialize(std::string const &folder,
0038 Quantity *qx,
0039 Quantity *qy,
0040 int debug ) {
0041 Container::initialize(folder, qy->name() + "vs" + qx->name(), debug);
0042 _qx = qx;
0043 _qy = qy;
0044 _qx->setAxisType(quantity::fXAxis);
0045 _qy->setAxisType(quantity::fYAxis);
0046 }
0047
0048 void ContainerSingle1D::initialize(
0049 std::string const &folder, std::string const &qname, Quantity *qx, Quantity *qy, int debug ) {
0050 Container::initialize(folder, qname, debug);
0051 _qx = qx;
0052 _qy = qy;
0053 _qx->setAxisType(quantity::fXAxis);
0054 _qy->setAxisType(quantity::fYAxis);
0055 }
0056
0057 void ContainerSingle1D::book(DQMStore::IBooker &ib, std::string subsystem, std::string aux) {
0058 ib.setCurrentFolder(subsystem + "/" + _folder + "/" + _qname);
0059 _me = ib.book1DD(_qname + (aux.empty() ? aux : "_" + aux),
0060 _qname + (aux.empty() ? aux : " " + aux),
0061 _qx->nbins(),
0062 _qx->min(),
0063 _qx->max());
0064 customize();
0065 }
0066
0067 void ContainerSingle1D::customize() {
0068 _me->setAxisTitle(_qx->name(), 1);
0069 _me->setAxisTitle(_qy->name(), 2);
0070
0071 TH1 *h = _me->getTH1();
0072 _qx->setBits(h);
0073 _qy->setBits(h);
0074
0075 std::vector<std::string> xlabels = _qx->getLabels();
0076 for (unsigned int i = 0; i < xlabels.size(); i++)
0077 _me->setBinLabel(i + 1, xlabels[i], 1);
0078 }
0079
0080 void ContainerSingle1D::fill(int x) { _me->Fill(_qx->getValue(x)); }
0081
0082 void ContainerSingle1D::fill(double x) { _me->Fill(_qx->getValue(x)); }
0083
0084 void ContainerSingle1D::fill(int x, int y) { _me->Fill(_qx->getValue(x), _qy->getValue(y)); }
0085
0086 void ContainerSingle1D::fill(int x, double y) { _me->Fill(_qx->getValue(x), _qy->getValue(y)); }
0087
0088 void ContainerSingle1D::fill(double x, int y) { _me->Fill(_qx->getValue(x), _qy->getValue(y)); }
0089
0090 void ContainerSingle1D::fill(double x, double y) { _me->Fill(_qx->getValue(x), _qy->getValue(y)); }
0091
0092 double ContainerSingle1D::getBinContent(int x) { return _me->getBinContent(_qx->getBin(x)); }
0093 double ContainerSingle1D::getBinContent(double x) { return _me->getBinContent(_qx->getBin(x)); }
0094 double ContainerSingle1D::getBinEntries(int x) { return _me->getBinEntries(_qx->getBin(x)); }
0095 double ContainerSingle1D::getBinEntries(double x) { return _me->getBinEntries(_qx->getBin(x)); }
0096 void ContainerSingle1D::setBinContent(int x, int y) { _me->setBinContent(_qx->getBin(x), y); }
0097 void ContainerSingle1D::setBinContent(int x, double y) { _me->setBinContent(_qx->getBin(x), y); }
0098 void ContainerSingle1D::setBinContent(double x, int y) { _me->setBinContent(_qx->getBin(x), y); }
0099 void ContainerSingle1D::setBinContent(double x, double y) { _me->setBinContent(_qx->getBin(x), y); }
0100
0101 void ContainerSingle1D::fill(HcalDetId const &id) { _me->Fill(_qx->getValue(id)); }
0102
0103 void ContainerSingle1D::fill(HcalDetId const &id, double x) {
0104 if (_qx->isCoordinate())
0105 _me->Fill(_qx->getValue(id), _qy->getValue(x));
0106 else
0107 _me->Fill(_qx->getValue(x));
0108 }
0109
0110 void ContainerSingle1D::fill(HcalDetId const &id, double x, double y) {
0111 if (_qx->isCoordinate())
0112 _me->Fill(_qx->getValue(id), _qy->getValue(x), y);
0113 else
0114 _me->Fill(_qy->getValue(x), _qy->getValue(y));
0115 }
0116
0117 double ContainerSingle1D::getBinContent(HcalDetId const &id) {
0118 return _me->getBinContent(_qx->getBin(id));
0119 }
0120 double ContainerSingle1D::getBinEntries(HcalDetId const &id) {
0121 return _me->getBinEntries(_qx->getBin(id));
0122 }
0123
0124 void ContainerSingle1D::setBinContent(HcalDetId const &id, int x) {
0125 _me->setBinContent(_qx->getBin(id), x);
0126 }
0127 void ContainerSingle1D::setBinContent(HcalDetId const &id, double x) {
0128 _me->setBinContent(_qx->getBin(id), x);
0129 }
0130
0131 void ContainerSingle1D::fill(HcalElectronicsId const &id) { _me->Fill(_qx->getValue(id)); }
0132
0133 void ContainerSingle1D::fill(HcalElectronicsId const &id, double x) {
0134 if (_qx->isCoordinate())
0135 _me->Fill(_qx->getValue(id), _qy->getValue(x));
0136 else
0137 _me->Fill(_qx->getValue(x));
0138 }
0139
0140 void ContainerSingle1D::fill(HcalElectronicsId const &id, double x, double y) {
0141 if (_qx->isCoordinate())
0142 _me->Fill(_qx->getValue(id), _qy->getValue(x), y);
0143 else
0144 _me->Fill(_qy->getValue(x), _qy->getValue(y));
0145 }
0146
0147 double ContainerSingle1D::getBinContent(HcalElectronicsId const &id) {
0148 return _me->getBinContent(_qx->getBin(id));
0149 }
0150 double ContainerSingle1D::getBinEntries(HcalElectronicsId const &id) {
0151 return _me->getBinEntries(_qx->getBin(id));
0152 }
0153
0154 void ContainerSingle1D::setBinContent(HcalElectronicsId const &id, int x) {
0155 _me->setBinContent(_qx->getBin(id), x);
0156 }
0157 void ContainerSingle1D::setBinContent(HcalElectronicsId const &id, double x) {
0158 _me->setBinContent(_qx->getBin(id), x);
0159 }
0160
0161 void ContainerSingle1D::fill(HcalTrigTowerDetId const &id) { _me->Fill(_qx->getValue(id)); }
0162
0163 void ContainerSingle1D::fill(HcalTrigTowerDetId const &id, double x) {
0164 if (_qx->isCoordinate())
0165 _me->Fill(_qx->getValue(id), _qy->getValue(x));
0166 else
0167 _me->Fill(_qx->getValue(x));
0168 }
0169
0170 void ContainerSingle1D::fill(HcalTrigTowerDetId const &id, double x, double y) {
0171 if (_qx->isCoordinate())
0172 _me->Fill(_qx->getValue(id), _qy->getValue(x), y);
0173 else
0174 _me->Fill(_qy->getValue(x), _qy->getValue(y));
0175 }
0176
0177 double ContainerSingle1D::getBinContent(HcalTrigTowerDetId const &id) {
0178 return _me->getBinContent(_qx->getBin(id));
0179 }
0180 double ContainerSingle1D::getBinEntries(HcalTrigTowerDetId const &id) {
0181 return _me->getBinEntries(_qx->getBin(id));
0182 }
0183
0184 void ContainerSingle1D::setBinContent(HcalTrigTowerDetId const &id, int x) {
0185 _me->setBinContent(_qx->getBin(id), x);
0186 }
0187 void ContainerSingle1D::setBinContent(HcalTrigTowerDetId const &id, double x) {
0188 _me->setBinContent(_qx->getBin(id), x);
0189 }
0190
0191 void ContainerSingle1D::extendAxisRange(int l) {
0192 if (l < _qx->nbins())
0193 return;
0194
0195 int x = _qx->nbins();
0196 while (l >= x) {
0197 _me->getTH1()->LabelsInflate();
0198 x *= 2;
0199 _qx->setMax(x);
0200 }
0201 }
0202
0203 void ContainerSingle1D::showOverflowX(bool showOverflow) { _qx->showOverflow(showOverflow); }
0204
0205 void ContainerSingle1D::showOverflowY(bool showOverflow) { _qy->showOverflow(showOverflow); }
0206
0207 }