CMS 3D CMS Logo

SiStripFastLinearCommonModeNoiseSubtraction.cc

Go to the documentation of this file.
00001 // File: SiStripFastLinearCommonModeNoiseSubtraction.cc
00002 // Description:  A fast linear common mode subtraction algorithm by D. Abbaneo to be implemented on FED level
00003 // Author:  Alexander Dierlamm
00004 
00005 #include "CommonTools/SiStripZeroSuppression/interface/SiStripFastLinearCommonModeNoiseSubtraction.h"
00006 #include <sstream>
00007 
00008 void SiStripFastLinearCommonModeNoiseSubtraction::subtract(const uint32_t& detId,std::vector<int16_t>& digis){
00009 #ifdef DEBUG_SiStripZeroSuppression_
00010   LogDebug("SiStripZeroSuppression") << "[SiStripFastLinearCommonModeNoiseSubtraction::subtract] digis.size()= " << digis.size();
00011 #endif
00012 
00013   std::vector<int16_t> APVdiff;
00014   std::vector<int16_t> APVdigis;
00015   std::vector<int16_t>::iterator fs;
00016   std::vector<int16_t>::iterator ls;
00017   APVdiff.reserve(64);
00018   APVdigis.reserve(128);
00019   int nAPV = digis.size()/128;
00020   double slope;
00021   double offset;
00022 
00023 #ifdef DEBUG_SiStripZeroSuppression_
00024   LogDebug("SiStripZeroSuppression") << "[SiStripFastLinearCommonModeNoiseSubtraction::subtract] number of apvs: nAPV= " << nAPV;
00025 #endif
00026 
00027   for (int iAPV=0; iAPV<nAPV; iAPV++){
00028     APVdigis.clear();
00029     fs = digis.begin()+iAPV*128;
00030     ls = digis.begin()+(iAPV+1)*128;
00031     APVdigis.insert(APVdigis.end(), fs, ls );
00032     std::sort(APVdigis.begin(),APVdigis.end());
00033     offset = (APVdigis[63]+APVdigis[64])/2.;
00034 
00035     // Here we get the slope according to a proposal by D. Abbaneo
00036     // Details on https://abbaneo.web.cern.ch/abbaneo/cmode/cm.html
00037     APVdiff.clear();
00038     for(int s=0;s<64;s++)
00039       APVdiff.push_back(digis[s+64+iAPV*128]-digis[s+iAPV*128]);
00040     std::sort(APVdiff.begin(),APVdiff.end());
00041     slope = (APVdiff[31]+APVdiff[32])/2./64.;
00042 
00043 #ifdef DEBUG_SiStripZeroSuppression_
00044     std::stringstream ss;
00045     if (edm::isDebugEnabled())
00046       ss << "[SiStripFastLinearCommonModeNoiseSubtraction::subtract] iApv= " <<iAPV << " slope= " << slope << " offset= " << offset << std::endl;
00047 #endif
00048 
00049     int strip=1;
00050     while (fs < ls) {
00051 #ifdef DEBUG_SiStripZeroSuppression_
00052       if (edm::isDebugEnabled())
00053         ss << "[SiStripFastLinearCommonModeNoiseSubtraction::subtract] initial strip "<<strip<<": " << *fs << " - " << (offset+(strip-64)*slope);
00054 #endif
00055       *fs = (int16_t) (*fs-(offset+(strip-64)*slope));
00056 #ifdef DEBUG_SiStripZeroSuppression_
00057       ss << " ==>>   adc CM subtr " << *fs << std::endl;
00058 #endif
00059       fs++;
00060       strip++;
00061     }
00062 #ifdef DEBUG_SiStripZeroSuppression_
00063     LogDebug("SiStripZeroSuppression") << ss.str().c_str();
00064 #endif
00065   }// end APV loop
00066 
00067 }
00068 

Generated on Tue Jun 9 17:26:02 2009 for CMSSW by  doxygen 1.5.4