ped_estimator.cc

Go to the documentation of this file.
00001 #ifndef PED_ESTIMATOR_CC
00002 #define PED_ESTIMATOR_CC
00003 
00004 #include "ped_estimator.hh"
00005 
00006 //***************************************************************
00007 ped_estimator::ped_estimator(){
00008 //***************************************************************
00009 
00010   _mean  = -1;
00011 
00012   _sigma = -1;
00013 
00014 }
00015 
00016 //***************************************************************
00017 void ped_estimator::compute_pedestal(const std::vector<UShort_t>* wf, size_t start, size_t nsample){
00018 //***************************************************************
00019   
00020   _mean  = -1;
00021   _sigma = -1;
00022   
00023   if( (start + nsample) > wf->size() ){
00024     Message::send(MSG::WARNING,__FUNCTION__,
00025           Form("Wavelength too short (%zu ADC samples) to compute pedestal! (minimum %zu)",
00026                wf->size(),(start + nsample))
00027           );
00028     return;
00029   }
00030 
00031   for(size_t index=start; index < (start + nsample); ++index)
00032 
00033     _mean += wf->at(index);
00034 
00035   _mean = _mean / ((double)nsample);
00036 
00037   for(size_t index=0; index < (start+nsample); ++index)
00038     
00039     _sigma += pow( (wf->at(index) - _mean), 2 );
00040 
00041   _sigma = sqrt(_sigma/((double)(nsample)));
00042 
00043   return;
00044 
00045 }
00046 
00047 #endif

Generated on Mon Apr 7 15:35:12 2014 for MyProject by  doxygen 1.4.7