00001 #include "DataFormats/HcalDigi/interface/HODataFrame.h" 00002 00003 00004 HODataFrame::HODataFrame() : id_(0), 00005 size_(0), 00006 hcalPresamples_(0) 00007 { 00008 } 00009 00010 HODataFrame::HODataFrame(const HcalDetId& id) : 00011 id_(id), 00012 size_(0), 00013 hcalPresamples_(0) 00014 { 00015 // TODO : test id for HcalOuter 00016 } 00017 00018 void HODataFrame::setSize(int size) { 00019 if (size>MAXSAMPLES) size_=MAXSAMPLES; 00020 else if (size<=0) size_=0; 00021 else size_=size; 00022 } 00023 void HODataFrame::setPresamples(int ps) { 00024 hcalPresamples_|=ps&0xF; 00025 } 00026 void HODataFrame::setReadoutIds(const HcalElectronicsId& eid) { 00027 electronicsId_=eid; 00028 } 00029 00030 bool HODataFrame::validate(int firstSample, int nSamples) const { 00031 int capid=-1; 00032 bool ok=true; 00033 for (int i=0; ok && i<nSamples && i+firstSample<size_; i++) { 00034 if (data_[i+firstSample].er() || !data_[i+firstSample].dv()) ok=false; 00035 if (i==0) capid=data_[i+firstSample].capid(); 00036 if (capid!=data_[i+firstSample].capid()) ok=false; 00037 capid=(capid+1)%4; 00038 } 00039 return ok; 00040 } 00041 00042 void HODataFrame::setZSInfo(bool unsuppressed, bool markAndPass) { 00043 if (markAndPass) hcalPresamples_|=0x10; 00044 if (unsuppressed) hcalPresamples_|=0x20; 00045 } 00046 00047 00048 std::ostream& operator<<(std::ostream& s, const HODataFrame& digi) { 00049 s << digi.id() << " " << digi.size() << " samples " << digi.presamples() << " presamples "; 00050 if (digi.zsUnsuppressed()) s << " zsUS "; 00051 if (digi.zsMarkAndPass()) s << " zsM&P "; 00052 s << std::endl; 00053 for (int i=0; i<digi.size(); i++) 00054 s << " " << digi.sample(i) << std::endl; 00055 return s; 00056 } 00057 00058