CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/DataFormats/HcalDigi/src/HFDataFrame.cc

Go to the documentation of this file.
00001 #include "DataFormats/HcalDigi/interface/HFDataFrame.h"
00002 
00003 HFDataFrame::HFDataFrame() : id_(0), 
00004                              size_(0),
00005                              hcalPresamples_(0)
00006 {
00007 }
00008 
00009 HFDataFrame::HFDataFrame(const HcalDetId& id) : 
00010   id_(id), 
00011   size_(0),
00012   hcalPresamples_(0)
00013 {
00014   // TODO : test id for HcalForward
00015 }
00016   
00017 void HFDataFrame::setSize(int size) {
00018   if (size>MAXSAMPLES) size_=MAXSAMPLES;
00019   else if (size<=0) size_=0;
00020   else size_=size;
00021 }
00022 void HFDataFrame::setPresamples(int ps) {
00023   hcalPresamples_|=ps&0xF;
00024 }
00025 void HFDataFrame::setReadoutIds(const HcalElectronicsId& eid) {
00026   electronicsId_=eid;
00027 }
00028 
00029 bool HFDataFrame::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 HFDataFrame::setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask) {
00042   hcalPresamples_&=0x7FC00F0F; // preserve actual presamples and fiber idle offset
00043   if (markAndPass) hcalPresamples_|=0x10;
00044   if (unsuppressed) hcalPresamples_|=0x20;
00045   hcalPresamples_|=(crossingMask&0x3FF)<<12; 
00046 }
00047 
00048 int HFDataFrame::fiberIdleOffset() const {
00049   int val=(hcalPresamples_&0xF00)>>8;
00050   return (val==0)?(-1000):(((val&0x8)==0)?(-(val&0x7)):(val&0x7));
00051 }
00052 
00053 void HFDataFrame::setFiberIdleOffset(int offset) {
00054   hcalPresamples_&=0x7FFFF0FF;
00055   if (offset>=7) hcalPresamples_|=0xF00;
00056   else if (offset>=0) hcalPresamples_|=(0x800)|(offset<<8);
00057   else if (offset>=-7) hcalPresamples_|=((-offset)<<8);
00058   else hcalPresamples_|=0x700;
00059 }
00060 
00061 std::ostream& operator<<(std::ostream& s, const HFDataFrame& digi) {
00062   s << digi.id() << " " << digi.size() << " samples  " << digi.presamples() << " presamples ";
00063   if (digi.zsUnsuppressed()) s << " zsUS ";
00064   if (digi.zsMarkAndPass()) s << " zsM&P ";
00065   if (digi.fiberIdleOffset()!=0) {
00066     if (digi.fiberIdleOffset()==-1000) s << " nofiberOffset";
00067     else s << " fiberOffset=" << digi.fiberIdleOffset();
00068   }
00069   s << std::endl;
00070   for (int i=0; i<digi.size(); i++) 
00071     s << "  " << digi.sample(i) << std::endl;
00072   return s;
00073 }
00074   
00075