CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelGainCalibrationService.cc
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: SiPixelGainCalibrationServic.cc
5  *
6  * Description:
7  *
8  * Version: 1.0 (some functionality moved from ../interface/SiPixelGainCalibrationService.h)
9  * Created: 04/16/2008 10:35:35 AM
10  *
11  * Author: Evan Friis (evan.klose.friis@cern.ch)
12  * University of California, Davis
13  *
14  * =====================================================================================
15  */
16 
18 
19 
20 
21 void SiPixelGainCalibrationServiceBase::calibrate(uint32_t detID, DigiIterator b, DigiIterator e, float conversionFactor, float offset, int * electron) {
22  int i=0;
23  for(DigiIterator di = b; di != e; ++di) {
24  int row = di->row();
25  int col = di->column();
26 
27  if ( isDead(detID,col,row) || isNoisy(detID,col,row) ) electron[i++] =0;
28  else {
29  float DBgain = getGain(detID, col, row);
30  float DBpedestal = getPedestal(detID, col, row) * DBgain;
31  float vcal = di->adc() * DBgain - DBpedestal;
32  // float vcal = (di->adc() - DBpedestal) * DBgain;
33  electron[i++] = int( vcal * conversionFactor + offset);
34  }
35  }
36  assert(i==(e-b));
37 }
38 
39 
40 
41 float SiPixelGainCalibrationService::getPedestal( const uint32_t& detID,const int& col, const int& row)
42 {
43  bool isDead = false;
44  bool isNoisy = false;
45  float pedestalValue = this->getPedestalByPixel(detID, col, row, isDead, isNoisy);
46  if (isDead || isNoisy)
47  {
48  this->throwExepctionForBadRead("FullCalibration getPedestal()",detID, col, row, pedestalValue);
49  return 0.0;
50  }
51  return pedestalValue;
52 }
53 
54 float SiPixelGainCalibrationService::getGain( const uint32_t& detID,const int& col, const int& row)
55 {
56  bool isDead = false;
57  bool isNoisy = false;
58  float gainValue = this->getGainByColumn(detID, col, row, isDead, isNoisy);
59  if (isDead || isNoisy)
60  {
61  this->throwExepctionForBadRead("FullCalibration getGain()",detID, col, row, gainValue);
62  return 0.0;
63  }
64  return gainValue;
65 }
66 
67 bool SiPixelGainCalibrationService::isDead( const uint32_t& detID,const int& col, const int& row)
68 {
69  bool isDead = false;
70  bool isNoisy = false;
71  try
72  {
73  this->getPedestalByPixel(detID, col, row, isDead, isNoisy);
74  }
75  catch (cms::Exception& e)
76  {
77  // Do not stop processing if you check if a nonexistant pixel is dead
78  edm::LogInfo("SiPixelGainCalibrationService") << "Attempting to check if nonexistant pixel is dead. Exception message: " << e.what();
79  isDead = false;
80  }
81  return isDead;
82 }
83 
84 bool SiPixelGainCalibrationService::isNoisy( const uint32_t& detID,const int& col, const int& row)
85 {
86  bool isDead = false;
87  bool isNoisy = false;
88  try
89  {
90  this->getPedestalByPixel(detID, col, row, isDead, isNoisy);
91  }
92  catch (cms::Exception& e)
93  {
94  // Do not stop processing if you check if a nonexistant pixel is noisy
95  edm::LogInfo("SiPixelGainCalibrationService") << "Attempting to check if nonexistant pixel is noisy. Exception message: " << e.what();
96  isNoisy = false;
97  }
98  return isNoisy;
99 }
100 
101 bool SiPixelGainCalibrationService::isDeadColumn( const uint32_t& detID,const int& col, const int& row)
102 {
103  edm::LogError("SiPixelGainCalibrationService") << "You attempted to check if an entire column was dead with a payload that stores information at pixel granularity. Please check by pixel. THANKS!";
104  return false;
105 }
106 
107 bool SiPixelGainCalibrationService::isNoisyColumn( const uint32_t& detID,const int& col, const int& row)
108 {
109  edm::LogError("SiPixelGainCalibrationService") << "You attempted to check if an entire column was noisy with a payload that stores information at pixel granularity. Please check by pixel. THANKS!";
110  return false;
111 }
virtual char const * what() const
Definition: Exception.cc:141
bool isNoisy(const uint32_t &detID, const int &col, const int &row)
int i
Definition: DBlmapReader.cc:9
edm::DetSet< PixelDigi >::const_iterator DigiIterator
float getPedestalByPixel(const uint32_t &detID, const int &col, const int &row, bool &isDeadPixel, bool &isNoisyPixel)
assert(m_qm.get())
float getGain(const uint32_t &detID, const int &col, const int &row)
bool isNoisyColumn(const uint32_t &detID, const int &col, const int &row)
virtual bool isDead(const uint32_t &detID, const int &col, const int &row)=0
float getPedestal(const uint32_t &detID, const int &col, const int &row)
float getGainByColumn(const uint32_t &detID, const int &col, const int &row, bool &isDeadColumn, bool &isNoisyColumn)
void throwExepctionForBadRead(std::string payload, const uint32_t &detID, const int &col, const int &row, double value=-1) const
bool isDeadColumn(const uint32_t &detID, const int &col, const int &row)
virtual float getPedestal(const uint32_t &detID, const int &col, const int &row)=0
double b
Definition: hdecay.h:120
virtual float getGain(const uint32_t &detID, const int &col, const int &row)=0
virtual bool isNoisy(const uint32_t &detID, const int &col, const int &row)=0
int col
Definition: cuy.py:1008
virtual void calibrate(uint32_t detID, DigiIterator b, DigiIterator e, float conversionFactor, float offset, int *electron)
bool isDead(const uint32_t &detID, const int &col, const int &row)