CMS 3D CMS Logo

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 
20  uint32_t detID, DigiIterator b, DigiIterator e, float conversionFactor, float offset, int* electron) {
21  int i = 0;
22  for (DigiIterator di = b; di != e; ++di) {
23  int row = di->row();
24  int col = di->column();
25 
26  if (isDead(detID, col, row) || isNoisy(detID, col, row))
27  electron[i++] = 0;
28  else {
29  float DBgain = getGain(detID, col, row);
30  float DBpedestal = getPedestal(detID, col, row) * DBgain;
31  float vcal = float(di->adc()) * DBgain - DBpedestal;
32  electron[i++] = int(vcal * conversionFactor + offset);
33  }
34  }
35  assert(i == (e - b));
36 }
37 
38 float SiPixelGainCalibrationService::getPedestal(const uint32_t& detID, const int& col, const int& row) {
39  bool isDead = false;
40  bool isNoisy = false;
41  float pedestalValue = this->getPedestalByPixel(detID, col, row, isDead, isNoisy);
42  if (isDead || isNoisy) {
43  this->throwExepctionForBadRead("FullCalibration getPedestal()", detID, col, row, pedestalValue);
44  return 0.0;
45  }
46  return pedestalValue;
47 }
48 
49 float SiPixelGainCalibrationService::getGain(const uint32_t& detID, const int& col, const int& row) {
50  bool isDead = false;
51  bool isNoisy = false;
52  float gainValue = this->getGainByColumn(detID, col, row, isDead, isNoisy);
53  if (isDead || isNoisy) {
54  this->throwExepctionForBadRead("FullCalibration getGain()", detID, col, row, gainValue);
55  return 0.0;
56  }
57  return gainValue;
58 }
59 
60 bool SiPixelGainCalibrationService::isDead(const uint32_t& detID, const int& col, const int& row) {
61  bool isDead = false;
62  bool isNoisy = false;
63  try {
64  this->getPedestalByPixel(detID, col, row, isDead, isNoisy);
65  } catch (cms::Exception& e) {
66  // Do not stop processing if you check if a nonexistant pixel is dead
67  edm::LogInfo("SiPixelGainCalibrationService")
68  << "Attempting to check if nonexistant pixel is dead. Exception message: " << e.what();
69  isDead = false;
70  }
71  return isDead;
72 }
73 
74 bool SiPixelGainCalibrationService::isNoisy(const uint32_t& detID, const int& col, const int& row) {
75  bool isDead = false;
76  bool isNoisy = false;
77  try {
78  this->getPedestalByPixel(detID, col, row, isDead, isNoisy);
79  } catch (cms::Exception& e) {
80  // Do not stop processing if you check if a nonexistant pixel is noisy
81  edm::LogInfo("SiPixelGainCalibrationService")
82  << "Attempting to check if nonexistant pixel is noisy. Exception message: " << e.what();
83  isNoisy = false;
84  }
85  return isNoisy;
86 }
87 
88 bool SiPixelGainCalibrationService::isDeadColumn(const uint32_t& detID, const int& col, const int& row) {
89  edm::LogError("SiPixelGainCalibrationService")
90  << "You attempted to check if an entire column was dead with a payload that stores information at pixel "
91  "granularity. Please check by pixel. THANKS!";
92  return false;
93 }
94 
95 bool SiPixelGainCalibrationService::isNoisyColumn(const uint32_t& detID, const int& col, const int& row) {
96  edm::LogError("SiPixelGainCalibrationService")
97  << "You attempted to check if an entire column was noisy with a payload that stores information at pixel "
98  "granularity. Please check by pixel. THANKS!";
99  return false;
100 }
edm::DetSet< PixelDigi >::const_iterator DigiIterator
float getPedestalByPixel(const uint32_t &detID, const int &col, const int &row, bool &isDeadPixel, bool &isNoisyPixel)
bool isNoisyColumn(const uint32_t &detID, const int &col, const int &row) override
virtual bool isDead(const uint32_t &detID, const int &col, const int &row)=0
Log< level::Error, false > LogError
assert(be >=bs)
float getGainByColumn(const uint32_t &detID, const int &col, const int &row, bool &isDeadColumn, bool &isNoisyColumn)
float getGain(const uint32_t &detID, const int &col, const int &row) override
virtual float getPedestal(const uint32_t &detID, const int &col, const int &row)=0
Log< level::Info, false > LogInfo
bool isDeadColumn(const uint32_t &detID, const int &col, const int &row) override
void throwExepctionForBadRead(std::string payload, const uint32_t &detID, const int &col, const int &row, double value=-1) const
double b
Definition: hdecay.h:118
col
Definition: cuy.py:1009
float getPedestal(const uint32_t &detID, const int &col, const int &row) override
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
bool isDead(const uint32_t &detID, const int &col, const int &row) override
virtual void calibrate(uint32_t detID, DigiIterator b, DigiIterator e, float conversionFactor, float offset, int *electron)
bool isNoisy(const uint32_t &detID, const int &col, const int &row) override