CMS 3D CMS Logo

SiTrivialDigitalConverter.cc

Go to the documentation of this file.
00001 #include "SimTracker/SiStripDigitizer/interface/SiTrivialDigitalConverter.h"
00002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 
00005 SiTrivialDigitalConverter::SiTrivialDigitalConverter(float in){
00006   electronperADC = in;
00007 }
00008 
00009 SiDigitalConverter::DigitalVecType
00010 SiTrivialDigitalConverter::convert(const std::vector<double>& analogSignal, edm::ESHandle<SiStripGain> & gainHandle, unsigned int detid){
00011   
00012   SiDigitalConverter::DigitalVecType _temp;
00013   _temp.reserve(analogSignal.size());
00014   
00015   SiStripApvGain::Range detGainRange; 
00016   if(gainHandle.isValid()) detGainRange = gainHandle->getRange(detid);
00017 
00018   
00019   for ( unsigned int i=0; i<analogSignal.size(); i++) {
00020     if (analogSignal[i]<=0) continue;
00021     float gainFactor  = (gainHandle.isValid()) ? gainHandle->getStripGain(i, detGainRange) : 1;
00022     
00023     // convert analog amplitude to digital
00024     int adc = convert( gainFactor*(analogSignal[i]) );
00025     
00026     if ( adc > 0) _temp.push_back(SiStripDigi(i, adc));
00027   }
00028   return _temp;
00029 }
00030 
00031 SiDigitalConverter::DigitalRawVecType
00032 SiTrivialDigitalConverter::convertRaw(const std::vector<double>& analogSignal, edm::ESHandle<SiStripGain> & gainHandle, unsigned int detid){
00033   
00034   SiDigitalConverter::DigitalRawVecType _temp;
00035   _temp.reserve(analogSignal.size());
00036   
00037   SiStripApvGain::Range detGainRange; 
00038   if(gainHandle.isValid()) detGainRange = gainHandle->getRange(detid);
00039   
00040   
00041   for ( unsigned int i=0; i<analogSignal.size(); i++) {
00042     // Raw Digis: we need all the channels
00043     //            saturation below the baseline
00044     //            (baseline=0 if we do not add pedestals)
00045     //        --> the following line not needed:
00046     //    if (analogSignal[i]<=0) continue;
00047     // and replace with this:
00048     if (analogSignal[i]<=0) {
00049       _temp.push_back(SiStripRawDigi(0));
00050       continue;
00051     }
00052     
00053     float gainFactor  = (gainHandle.isValid()) ? gainHandle->getStripGain(i, detGainRange) : 1;
00054     
00055     // convert analog amplitude to digital
00056     int adc = convertRaw( gainFactor*(analogSignal[i]));
00057     
00058     _temp.push_back(SiStripRawDigi(adc));
00059   }
00060   return _temp;
00061 }
00062 
00063 
00064 int SiTrivialDigitalConverter::truncate(float in_adc) {
00065   
00066   //Rounding teh ADC number instaed of truncating it
00067   int adc = int(in_adc+0.5);
00068   /*
00069     254 ADC: 254<=raw charge < 511
00070     255 ADC: 512<= raw charge < 1023
00071   */
00072   if (adc > 511 ) return 255;
00073   if (adc > 253) return 254;
00074   //Protection
00075   if (adc < 0) return 0;
00076   return adc;
00077 }
00078 
00079 
00080 int SiTrivialDigitalConverter::truncateRaw(float in_adc) {
00081   
00082   //Rounding the ADC number
00083   int adc = int(in_adc+0.5);
00084 
00085   if (adc > 1023 ) return 1023;
00086   //Protection
00087   if (adc < 0) return 0;
00088   return adc;
00089 }

Generated on Tue Jun 9 17:47:53 2009 for CMSSW by  doxygen 1.5.4