Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:59:33

0001 /*
0002  * =====================================================================================
0003  *
0004  *       Filename:  SiPixelGainCalibrationForHLT.cc
0005  *
0006  *    Description:  
0007  *
0008  *        Version:  1.0 (some functionality moved from ../interface/SiPixelGainCalibrationForHLT.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/SiPixelGainCalibrationForHLTService.h"
0018 #include <tuple>
0019 
0020 void SiPixelGainCalibrationForHLTService::calibrate(
0021     uint32_t detID, DigiIterator b, DigiIterator e, float conversionFactor, float offset, int* electron) {
0022   SiPixelGainCalibrationForHLT::Range range;
0023   int cols;
0024   std::tie(range, cols) = ped->getRangeAndNCols(detID);
0025   float pedestal = 0, gain = 0;
0026   int i = 0;
0027   bool isDeadColumn = false, isNoisyColumn = false;
0028   int oldCol = -1, oldAveragedBlock = -1;
0029   for (DigiIterator di = b; di != e; ++di) {
0030     int row = di->row();
0031     int col = di->column();
0032     int averagedBlock = row / numberOfRowsAveragedOver_;
0033     if ((col != oldCol) | (averagedBlock != oldAveragedBlock)) {
0034       oldCol = col;
0035       oldAveragedBlock = averagedBlock;
0036       std::tie(pedestal, gain) = ped->getPedAndGain(col, row, range, cols, isDeadColumn, isNoisyColumn);
0037     }
0038     if (isDeadColumn | isNoisyColumn)
0039       electron[i++] = 0;
0040     else {
0041       float vcal = float(di->adc()) * gain - pedestal * gain;
0042       electron[i++] = int(vcal * conversionFactor + offset);
0043     }
0044   }
0045   assert(i == (e - b));
0046 }
0047 
0048 float SiPixelGainCalibrationForHLTService::getPedestal(const uint32_t& detID, const int& col, const int& row) {
0049   bool isDead = false;
0050   bool isNoisy = false;
0051   float pedestalValue = this->getPedestalByColumn(detID, col, row, isDead, isNoisy);
0052   if (isDead || isNoisy) {
0053     this->throwExepctionForBadRead("HLT getPedestal()", detID, col, row, pedestalValue);
0054     return 0.0;
0055   }
0056   return pedestalValue;
0057 }
0058 
0059 float SiPixelGainCalibrationForHLTService::getGain(const uint32_t& detID, const int& col, const int& row) {
0060   bool isDead = false;
0061   bool isNoisy = false;
0062   float gainValue = this->getGainByColumn(detID, col, row, isDead, isNoisy);
0063   if (isDead || isNoisy) {
0064     this->throwExepctionForBadRead("HLT getGain()", detID, col, row, gainValue);
0065     return 0.0;
0066   }
0067   return gainValue;
0068 }
0069 
0070 bool SiPixelGainCalibrationForHLTService::isDead(const uint32_t& detID, const int& col, const int& row) {
0071   bool isDead = false;
0072   bool isNoisy = false;
0073   try {
0074     this->getPedestalByColumn(detID, col, row, isDead, isNoisy);  //pedestal stores dead column value as well
0075   } catch (cms::Exception& e) {
0076     // Do not stop processing if you check if a nonexistant pixel is dead
0077     edm::LogInfo("SiPixelGainCalibrationForHLTService")
0078         << "Attempting to check if nonexistant pixel is dead.  Exception message: " << e.what();
0079     isDead = false;
0080   }
0081   return isDead;
0082 }
0083 
0084 bool SiPixelGainCalibrationForHLTService::isNoisy(const uint32_t& detID, const int& col, const int& row) {
0085   bool isDead = false;
0086   bool isNoisy = false;
0087   try {
0088     this->getPedestalByColumn(detID, col, row, isDead, isNoisy);  //pedestal stores noisy column value as well
0089   } catch (cms::Exception& e) {
0090     // Do not stop processing if you check if a nonexistant pixel is noisy
0091     edm::LogInfo("SiPixelGainCalibrationForHLTService")
0092         << "Attempting to check if nonexistant pixel is noisy.  Exception message: " << e.what();
0093     isNoisy = false;
0094   }
0095   return isNoisy;
0096 }
0097 
0098 bool SiPixelGainCalibrationForHLTService::isDeadColumn(const uint32_t& detID, const int& col, const int& row) {
0099   bool isDead = false;
0100   bool isNoisy = false;
0101   try {
0102     this->getGainByColumn(detID, col, row, isDead, isNoisy);
0103   } catch (cms::Exception& e) {
0104     // Do not stop processing if you check if a nonexistant pixel is dead
0105     edm::LogInfo("SiPixelGainCalibrationForHLTService")
0106         << "Attempting to check if nonexistant pixel is dead.  Exception message: " << e.what();
0107     isDead = false;
0108   }
0109   return isDead;
0110 }
0111 
0112 bool SiPixelGainCalibrationForHLTService::isNoisyColumn(const uint32_t& detID, const int& col, const int& row) {
0113   bool isDead = false;
0114   bool isNoisy = false;
0115   try {
0116     this->getGainByColumn(detID, col, row, isDead, isNoisy);
0117   } catch (cms::Exception& e) {
0118     // Do not stop processing if you check if a nonexistant pixel is noisy
0119     edm::LogInfo("SiPixelGainCalibrationForHLTService")
0120         << "Attempting to check if nonexistant pixel is noisy.  Exception message: " << e.what();
0121     isNoisy = false;
0122   }
0123   return isNoisy;
0124 }