CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/DataFormats/EcalDigi/src/ESDataFrame.cc

Go to the documentation of this file.
00001 #include "DataFormats/EcalDigi/interface/ESDataFrame.h"
00002 
00003 ESDataFrame::ESDataFrame() : id_(0), 
00004                              size_(0)
00005 {
00006 }
00007 
00008 ESDataFrame::ESDataFrame(const ESDetId& id) : 
00009   id_(id), 
00010   size_(0)
00011 {
00012 }
00013 
00014 ESDataFrame::ESDataFrame(const edm::DataFrame& df) : 
00015    id_   ( df.id()    )
00016 {
00017    setSize( df.size() ) ;
00018    for( int i ( 0 ) ; i != size_ ; ++i )
00019    { 
00020       static const int offset ( 65536 ) ; // for uint16 to int16
00021       static const uint16_t limit  ( 32767 ) ;
00022       const int dint ( limit < df[i] ? (int)df[i] - offset : df[i] ) ;
00023       data_[i] = ESSample( (int16_t)dint ) ;
00024    }
00025 }
00026 
00027 void ESDataFrame::setSize(int size) {
00028   if (size > MAXSAMPLES) size_ = MAXSAMPLES;
00029   else if (size <= 0) size_=0;
00030   else size_ = size;
00031 }
00032 
00033 std::ostream& operator<<(std::ostream& s, const ESDataFrame& digi) {
00034    s << digi.id() << " " << digi.size() 
00035      << " samples " << std::endl;
00036    for (int i=0; i<digi.size(); i++) 
00037     s << "  " << digi.sample(i) << std::endl;
00038   return s;
00039 }