CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/CalibFormats/CaloObjects/src/CaloSamples.cc

Go to the documentation of this file.
00001 #include "CalibFormats/CaloObjects/interface/CaloSamples.h"
00002 #include <math.h>
00003 
00004 CaloSamples::CaloSamples() : id_(), size_(0), presamples_(0) { setBlank() ; }
00005 
00006 CaloSamples::CaloSamples(const DetId& id, int size) :
00007    id_          ( id   ) , 
00008    size_        ( size ) , 
00009    presamples_  ( 0    ) 
00010 {
00011    setBlank() ;
00012 }
00013 
00014 void
00015 CaloSamples::setPresamples( int pre ) 
00016 {
00017    presamples_ = pre ;
00018 }
00019 
00020 CaloSamples& 
00021 CaloSamples::scale( double value )
00022 {
00023    for (int i=0; i<MAXSAMPLES; i++) data_[i]*=value;
00024    return (*this);
00025 }
00026 
00027 CaloSamples& 
00028 CaloSamples::operator+=(double value) 
00029 {  
00030    for (int i=0; i<MAXSAMPLES; i++) data_[i]+=value;
00031    return (*this);
00032 }
00033 
00034 bool 
00035 CaloSamples::isBlank() const // are the samples blank (zero?)
00036 {
00037    for( int i ( 0 ) ; i != MAXSAMPLES ; ++i )
00038    {
00039       if( 1.e-6 < fabs( data_[i] ) ) return false ;
00040    }
00041    return true ;
00042 }
00043 
00044 void 
00045 CaloSamples::setBlank() // keep id, presamples, size but zero out data
00046 {
00047    std::fill( data_ , data_ + MAXSAMPLES, (double)0.0 ) ;
00048 }
00049 
00050 std::ostream& operator<<(std::ostream& s, const CaloSamples& samples) {
00051   s << "DetId=" << samples.id().rawId();
00052   s << ", "<<  samples.size() << "samples" << std::endl;
00053   for (int i=0; i<samples.size(); i++)
00054     s << i << ":" << samples[i] << std::endl;
00055   return s;
00056 }