Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:37

0001 #include "DataFormats/HcalDigi/interface/HcalHistogramDigi.h"
0002 #include <iomanip>
0003 
0004 HcalHistogramDigi::HcalHistogramDigi() : id_(0) {
0005   for (int i = 0; i < BINS_PER_HISTOGRAM * 4; i++)
0006     bins_[i] = 0;
0007 }
0008 
0009 HcalHistogramDigi::HcalHistogramDigi(const HcalDetId& id) : id_(id) {
0010   for (int i = 0; i < BINS_PER_HISTOGRAM * 4; i++)
0011     bins_[i] = 0;
0012 }
0013 
0014 uint16_t HcalHistogramDigi::get(int capid, int bin) const {
0015   return bins_[(capid % 4) * BINS_PER_HISTOGRAM + (bin % BINS_PER_HISTOGRAM)];
0016 }
0017 
0018 int HcalHistogramDigi::getSum(int bin) const {
0019   return (int)(bins_[(bin % BINS_PER_HISTOGRAM)]) + (int)(bins_[BINS_PER_HISTOGRAM + (bin % BINS_PER_HISTOGRAM)]) +
0020          (int)(bins_[BINS_PER_HISTOGRAM * 2 + (bin % BINS_PER_HISTOGRAM)]) +
0021          (int)(bins_[BINS_PER_HISTOGRAM * 3 + (bin % BINS_PER_HISTOGRAM)]);
0022 }
0023 
0024 uint16_t* HcalHistogramDigi::getArray(int capid) {
0025   int offset = (capid % 4) * BINS_PER_HISTOGRAM;
0026   return &(bins_[offset]);
0027 }
0028 
0029 std::ostream& operator<<(std::ostream& s, const HcalHistogramDigi& digi) {
0030   s << digi.id() << std::endl;
0031   for (int i = 0; i < HcalHistogramDigi::BINS_PER_HISTOGRAM; i++) {
0032     s << ' ' << std::setw(2) << i;
0033     for (int capid = 0; capid < 4; capid++)
0034       s << std::setw(6) << digi.get(capid, i) << "  ";
0035     s << std::endl;
0036   }
0037   return s;
0038 }