CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/SimRomanPot/SimFP420/src/DigiConverterFP420.cc

Go to the documentation of this file.
00001 
00002 // File: DigiConverterFP420.cc
00003 // Date: 12.2006
00004 // Description: DigiConverterFP420 for FP420
00005 // Modifications: 
00007 #include "SimRomanPot/SimFP420/interface/DigiConverterFP420.h"
00008 
00009 DigiConverterFP420::DigiConverterFP420(float in,int verbosity){
00010 
00011   electronperADC = in;
00012   verbos = verbosity;
00013   
00014   const int defaultBits = 10;
00015   const int largestBits = 30;
00016   
00017   // example is in SiStrips:
00018   // static SimpleConfigurable<int> 
00019   //    adcBits(defaultBits, "DigiConverterFP420:rawDataAdcBits");
00020   adcBits=defaultBits;
00021   
00022   if (adcBits > largestBits || adcBits < 1) adcBits = largestBits;
00023   
00024   theMaxADC = ~(~0 << adcBits);
00025   //      std::cout << "theMaxADC= "<< theMaxADC  << std::endl; // = 1023
00026   if(verbos>0) {
00027     std::cout << " ***DigiConverterFP420: constructor" << std::endl;
00028     std::cout << "with known electronperADC =  " << electronperADC << "the adcBits =  " << adcBits << "  theMaxADC=  " << theMaxADC << "for known defaultBits=  " << defaultBits << " largestBits=  " << largestBits << std::endl;
00029   }
00030 }
00031 
00032 DConverterFP420::DigitalMapType
00033 DigiConverterFP420::convert(const signal_map_type& analogSignal){
00034   
00035   DConverterFP420::DigitalMapType _temp;
00036   
00037   for ( signal_map_type::const_iterator i=analogSignal.begin(); i!=analogSignal.end(); i++) {
00038     
00039     // convert analog amplitude to digital, means integer number simulating ADC digitization!
00040     //with truncation check
00041     int adc = convert((*i).second);
00042     
00043     if(verbos>0) {
00044       std::cout << " ***DigiConverterFP420: convert: after truncation " << std::endl;
00045       std::cout << "adc =  " << adc << " (*i).first =  " << (*i).first << std::endl;
00046     }
00047     if ( adc > 0) _temp.insert( _temp.end(),
00048                                 DigitalMapType::value_type((*i).first, adc));
00049   }
00050   
00051   return _temp;
00052   
00053 }
00054 
00055 
00056 int DigiConverterFP420::truncate(float in_adc) {
00057   
00058   int adc = int(in_adc);
00059   if(verbos>0) {
00060     std::cout << " ***DigiConverterFP420: truncate" << std::endl;
00061     std::cout << "if adc =  " << adc << "bigger theMaxADC =  " << theMaxADC << " adc=theMaxADC !!!"  << std::endl;
00062   }
00063   if (adc > theMaxADC) adc = theMaxADC;
00064   
00065   return adc;
00066 }