Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-28 04:15:46

0001 /*
0002  * =====================================================================================
0003  *
0004  *       Filename:  SiPixelGainCalibrationServic.cc
0005  *
0006  *    Description:  
0007  *
0008  *        Version:  1.0 (some functionality moved from ../interface/SiPixelGainCalibrationService.h)
0009  *        Created:  04/16/2008 10:35:35 AM
0010  *
0011  *         Author:  Evan Friis (evan.klose.friis@cern.ch)
0012  *                  University of California, Davis
0013  *
0014  * =====================================================================================
0015  */
0016 
0017 #include "CalibTracker/SiPixelESProducers/interface/SiPixelGainCalibrationService.h"
0018 
0019 void SiPixelGainCalibrationServiceBase::calibrate(
0020     uint32_t detID, DigiIterator b, DigiIterator e, float conversionFactor, float offset, int* electron) {
0021   int i = 0;
0022   for (DigiIterator di = b; di != e; ++di) {
0023     int row = di->row();
0024     int col = di->column();
0025 
0026     if (isDead(detID, col, row) || isNoisy(detID, col, row))
0027       electron[i++] = 0;
0028     else {
0029       float DBgain = getGain(detID, col, row);
0030       float DBpedestal = getPedestal(detID, col, row) * DBgain;
0031       float vcal = float(di->adc()) * DBgain - DBpedestal;
0032       electron[i++] = int(vcal * conversionFactor + offset);
0033     }
0034   }
0035   assert(i == (e - b));
0036 }
0037 
0038 float SiPixelGainCalibrationService::getPedestal(const uint32_t& detID, const int& col, const int& row) {
0039   bool isDead = false;
0040   bool isNoisy = false;
0041   float pedestalValue = this->getPedestalByPixel(detID, col, row, isDead, isNoisy);
0042   if (isDead || isNoisy) {
0043     this->throwExepctionForBadRead("FullCalibration getPedestal()", detID, col, row, pedestalValue);
0044     return 0.0;
0045   }
0046   return pedestalValue;
0047 }
0048 
0049 float SiPixelGainCalibrationService::getGain(const uint32_t& detID, const int& col, const int& row) {
0050   bool isDead = false;
0051   bool isNoisy = false;
0052   float gainValue = this->getGainByColumn(detID, col, row, isDead, isNoisy);
0053   if (isDead || isNoisy) {
0054     this->throwExepctionForBadRead("FullCalibration getGain()", detID, col, row, gainValue);
0055     return 0.0;
0056   }
0057   return gainValue;
0058 }
0059 
0060 bool SiPixelGainCalibrationService::isDead(const uint32_t& detID, const int& col, const int& row) {
0061   bool isDead = false;
0062   bool isNoisy = false;
0063   try {
0064     this->getPedestalByPixel(detID, col, row, isDead, isNoisy);
0065   } catch (cms::Exception& e) {
0066     // Do not stop processing if you check if a nonexistant pixel is dead
0067     edm::LogInfo("SiPixelGainCalibrationService")
0068         << "Attempting to check if nonexistant pixel is dead.  Exception message: " << e.what();
0069     isDead = false;
0070   }
0071   return isDead;
0072 }
0073 
0074 bool SiPixelGainCalibrationService::isNoisy(const uint32_t& detID, const int& col, const int& row) {
0075   bool isDead = false;
0076   bool isNoisy = false;
0077   try {
0078     this->getPedestalByPixel(detID, col, row, isDead, isNoisy);
0079   } catch (cms::Exception& e) {
0080     // Do not stop processing if you check if a nonexistant pixel is noisy
0081     edm::LogInfo("SiPixelGainCalibrationService")
0082         << "Attempting to check if nonexistant pixel is noisy.  Exception message: " << e.what();
0083     isNoisy = false;
0084   }
0085   return isNoisy;
0086 }
0087 
0088 bool SiPixelGainCalibrationService::isDeadColumn(const uint32_t& detID, const int& col, const int& row) {
0089   edm::LogError("SiPixelGainCalibrationService")
0090       << "You attempted to check if an entire column was dead with a payload that stores information at pixel "
0091          "granularity.  Please check by pixel. THANKS!";
0092   return false;
0093 }
0094 
0095 bool SiPixelGainCalibrationService::isNoisyColumn(const uint32_t& detID, const int& col, const int& row) {
0096   edm::LogError("SiPixelGainCalibrationService")
0097       << "You attempted to check if an entire column was noisy with a payload that stores information at pixel "
0098          "granularity.  Please check by pixel. THANKS!";
0099   return false;
0100 }