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