Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
#include "DQM/HcalCommon/interface/ContainerSingle1D.h"

namespace hcaldqm {
  using namespace quantity;
  using namespace constants;
  ContainerSingle1D::ContainerSingle1D() {
    _qx = nullptr;
    _qy = nullptr;
  }

  ContainerSingle1D::ContainerSingle1D(ContainerSingle1D const &c) : Container(c._folder, c._qname) {
    _qx = c._qx->makeCopy();
    _qy = c._qy->makeCopy();
  }

  ContainerSingle1D::ContainerSingle1D(std::string const &folder, Quantity *qx, Quantity *qy)
      : Container(folder, qy->name() + "vs" + qx->name()), _qx(qx), _qy(qy) {
    _qx->setAxisType(quantity::fXAxis);
    _qy->setAxisType(quantity::fYAxis);
  }

  ContainerSingle1D::ContainerSingle1D(std::string const &folder, std::string const &qname, Quantity *qx, Quantity *qy)
      : Container(folder, qname), _qx(qx), _qy(qy) {
    _qx->setAxisType(quantity::fXAxis);
    _qy->setAxisType(quantity::fYAxis);
  }

  ContainerSingle1D::~ContainerSingle1D() {
    if (_qx != nullptr)
      delete _qx;
    if (_qy != nullptr)
      delete _qy;
    _qx = nullptr;
    _qy = nullptr;
  }

  /* virtual */ void ContainerSingle1D::initialize(std::string const &folder,
                                                   Quantity *qx,
                                                   Quantity *qy,
                                                   int debug /*=0*/) {
    Container::initialize(folder, qy->name() + "vs" + qx->name(), debug);
    _qx = qx;
    _qy = qy;
    _qx->setAxisType(quantity::fXAxis);
    _qy->setAxisType(quantity::fYAxis);
  }

  /* virtual */ void ContainerSingle1D::initialize(
      std::string const &folder, std::string const &qname, Quantity *qx, Quantity *qy, int debug /*=0*/) {
    Container::initialize(folder, qname, debug);
    _qx = qx;
    _qy = qy;
    _qx->setAxisType(quantity::fXAxis);
    _qy->setAxisType(quantity::fYAxis);
  }

  /* virtual */ void ContainerSingle1D::book(DQMStore::IBooker &ib, std::string subsystem, std::string aux) {
    ib.setCurrentFolder(subsystem + "/" + _folder + "/" + _qname);
    _me = ib.book1DD(_qname + (aux.empty() ? aux : "_" + aux),
                     _qname + (aux.empty() ? aux : " " + aux),
                     _qx->nbins(),
                     _qx->min(),
                     _qx->max());
    customize();
  }

  /* virtual */ void ContainerSingle1D::customize() {
    _me->setAxisTitle(_qx->name(), 1);
    _me->setAxisTitle(_qy->name(), 2);

    TH1 *h = _me->getTH1();
    _qx->setBits(h);
    _qy->setBits(h);

    std::vector<std::string> xlabels = _qx->getLabels();
    for (unsigned int i = 0; i < xlabels.size(); i++)
      _me->setBinLabel(i + 1, xlabels[i], 1);
  }

  /* virtual */ void ContainerSingle1D::fill(int x) { _me->Fill(_qx->getValue(x)); }

  /* virtual */ void ContainerSingle1D::fill(double x) { _me->Fill(_qx->getValue(x)); }

  /* virtual */ void ContainerSingle1D::fill(int x, int y) { _me->Fill(_qx->getValue(x), _qy->getValue(y)); }

  /* virtual */ void ContainerSingle1D::fill(int x, double y) { _me->Fill(_qx->getValue(x), _qy->getValue(y)); }

  /* virtual */ void ContainerSingle1D::fill(double x, int y) { _me->Fill(_qx->getValue(x), _qy->getValue(y)); }

  /* virtual */ void ContainerSingle1D::fill(double x, double y) { _me->Fill(_qx->getValue(x), _qy->getValue(y)); }

  /* virtual */ double ContainerSingle1D::getBinContent(int x) { return _me->getBinContent(_qx->getBin(x)); }
  /* virtual */ double ContainerSingle1D::getBinContent(double x) { return _me->getBinContent(_qx->getBin(x)); }
  /* virtual */ double ContainerSingle1D::getBinEntries(int x) { return _me->getBinEntries(_qx->getBin(x)); }
  /* virtual */ double ContainerSingle1D::getBinEntries(double x) { return _me->getBinEntries(_qx->getBin(x)); }
  /* virtual */ void ContainerSingle1D::setBinContent(int x, int y) { _me->setBinContent(_qx->getBin(x), y); }
  /* virtual */ void ContainerSingle1D::setBinContent(int x, double y) { _me->setBinContent(_qx->getBin(x), y); }
  /* virtual */ void ContainerSingle1D::setBinContent(double x, int y) { _me->setBinContent(_qx->getBin(x), y); }
  /* virtual */ void ContainerSingle1D::setBinContent(double x, double y) { _me->setBinContent(_qx->getBin(x), y); }

  /* virtual */ void ContainerSingle1D::fill(HcalDetId const &id) { _me->Fill(_qx->getValue(id)); }

  /* virtual */ void ContainerSingle1D::fill(HcalDetId const &id, double x) {
    if (_qx->isCoordinate())
      _me->Fill(_qx->getValue(id), _qy->getValue(x));
    else
      _me->Fill(_qx->getValue(x));
  }

  /* virtual */ void ContainerSingle1D::fill(HcalDetId const &id, double x, double y) {
    if (_qx->isCoordinate())
      _me->Fill(_qx->getValue(id), _qy->getValue(x), y);
    else
      _me->Fill(_qy->getValue(x), _qy->getValue(y));
  }

  /* virtual */ double ContainerSingle1D::getBinContent(HcalDetId const &id) {
    return _me->getBinContent(_qx->getBin(id));
  }
  /* virtual */ double ContainerSingle1D::getBinEntries(HcalDetId const &id) {
    return _me->getBinEntries(_qx->getBin(id));
  }

  /* virtual */ void ContainerSingle1D::setBinContent(HcalDetId const &id, int x) {
    _me->setBinContent(_qx->getBin(id), x);
  }
  /* virtual */ void ContainerSingle1D::setBinContent(HcalDetId const &id, double x) {
    _me->setBinContent(_qx->getBin(id), x);
  }

  /* virtual */ void ContainerSingle1D::fill(HcalElectronicsId const &id) { _me->Fill(_qx->getValue(id)); }

  /* virtual */ void ContainerSingle1D::fill(HcalElectronicsId const &id, double x) {
    if (_qx->isCoordinate())
      _me->Fill(_qx->getValue(id), _qy->getValue(x));
    else
      _me->Fill(_qx->getValue(x));
  }

  /* virtual */ void ContainerSingle1D::fill(HcalElectronicsId const &id, double x, double y) {
    if (_qx->isCoordinate())
      _me->Fill(_qx->getValue(id), _qy->getValue(x), y);
    else
      _me->Fill(_qy->getValue(x), _qy->getValue(y));
  }

  /* virtual */ double ContainerSingle1D::getBinContent(HcalElectronicsId const &id) {
    return _me->getBinContent(_qx->getBin(id));
  }
  /* virtual */ double ContainerSingle1D::getBinEntries(HcalElectronicsId const &id) {
    return _me->getBinEntries(_qx->getBin(id));
  }

  /* virtual */ void ContainerSingle1D::setBinContent(HcalElectronicsId const &id, int x) {
    _me->setBinContent(_qx->getBin(id), x);
  }
  /* virtual */ void ContainerSingle1D::setBinContent(HcalElectronicsId const &id, double x) {
    _me->setBinContent(_qx->getBin(id), x);
  }

  /* virtual */ void ContainerSingle1D::fill(HcalTrigTowerDetId const &id) { _me->Fill(_qx->getValue(id)); }

  /* virtual */ void ContainerSingle1D::fill(HcalTrigTowerDetId const &id, double x) {
    if (_qx->isCoordinate())
      _me->Fill(_qx->getValue(id), _qy->getValue(x));
    else
      _me->Fill(_qx->getValue(x));
  }

  /* virtual */ void ContainerSingle1D::fill(HcalTrigTowerDetId const &id, double x, double y) {
    if (_qx->isCoordinate())
      _me->Fill(_qx->getValue(id), _qy->getValue(x), y);
    else
      _me->Fill(_qy->getValue(x), _qy->getValue(y));
  }

  /* virtual */ double ContainerSingle1D::getBinContent(HcalTrigTowerDetId const &id) {
    return _me->getBinContent(_qx->getBin(id));
  }
  /* virtual */ double ContainerSingle1D::getBinEntries(HcalTrigTowerDetId const &id) {
    return _me->getBinEntries(_qx->getBin(id));
  }

  /* virtual */ void ContainerSingle1D::setBinContent(HcalTrigTowerDetId const &id, int x) {
    _me->setBinContent(_qx->getBin(id), x);
  }
  /* virtual */ void ContainerSingle1D::setBinContent(HcalTrigTowerDetId const &id, double x) {
    _me->setBinContent(_qx->getBin(id), x);
  }

  /* virtual */ void ContainerSingle1D::extendAxisRange(int l) {
    if (l < _qx->nbins())
      return;

    int x = _qx->nbins();
    while (l >= x) {
      _me->getTH1()->LabelsInflate();
      x *= 2;
      _qx->setMax(x);
    }
  }

  void ContainerSingle1D::showOverflowX(bool showOverflow) { _qx->showOverflow(showOverflow); }

  void ContainerSingle1D::showOverflowY(bool showOverflow) { _qy->showOverflow(showOverflow); }

}  // namespace hcaldqm