CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DataFormats/HcalDigi/src/HcalHistogramDigi.cc

Go to the documentation of this file.
00001 #include "DataFormats/HcalDigi/interface/HcalHistogramDigi.h"
00002 #include <iomanip>
00003 
00004 HcalHistogramDigi::HcalHistogramDigi() : id_(0) {
00005   for (int i=0; i<BINS_PER_HISTOGRAM*4; i++) 
00006     bins_[i]=0;
00007 }
00008 
00009 HcalHistogramDigi::HcalHistogramDigi(const HcalDetId& id) : id_(id) {
00010   for (int i=0; i<BINS_PER_HISTOGRAM*4; i++) 
00011     bins_[i]=0;
00012 }
00013 
00014 uint16_t HcalHistogramDigi::get(int capid, int bin) const {
00015   return bins_[(capid%4)*BINS_PER_HISTOGRAM+(bin%BINS_PER_HISTOGRAM)];
00016 }
00017 
00018 int HcalHistogramDigi::getSum(int bin) const {
00019   return (int)(bins_[(bin%BINS_PER_HISTOGRAM)])+
00020     (int)(bins_[BINS_PER_HISTOGRAM+(bin%BINS_PER_HISTOGRAM)])+
00021     (int)(bins_[BINS_PER_HISTOGRAM*2+(bin%BINS_PER_HISTOGRAM)])+
00022     (int)(bins_[BINS_PER_HISTOGRAM*3+(bin%BINS_PER_HISTOGRAM)]);
00023 }
00024 
00025 uint16_t* HcalHistogramDigi::getArray(int capid) {
00026   int offset=(capid%4)*BINS_PER_HISTOGRAM;
00027   return &(bins_[offset]);
00028 }
00029 
00030 std::ostream& operator<<(std::ostream& s, const HcalHistogramDigi& digi) {
00031   s << digi.id() << std::endl;
00032   for (int i=0; i<HcalHistogramDigi::BINS_PER_HISTOGRAM; i++) {
00033     s << ' ' << std::setw(2) << i;
00034     for (int capid=0; capid<4; capid++)
00035       s << std::setw(6) << digi.get(capid,i) << "  ";
00036     s << std::endl;
00037   }
00038   return s;
00039 }