test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelGainCalibrationForHLTService.cc
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: SiPixelGainCalibrationForHLT.cc
5  *
6  * Description:
7  *
8  * Version: 1.0 (some functionality moved from ../interface/SiPixelGainCalibrationForHLT.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 #include<tuple>
19 
20 void SiPixelGainCalibrationForHLTService::calibrate(uint32_t detID, DigiIterator b, DigiIterator e, float conversionFactor, float offset, int * electron) {
22  int cols;
23  std::tie(range,cols) = ped->getRangeAndNCols(detID);
24  float pedestal=0,gain=0;
25  int i=0;
26  bool isDeadColumn=false, isNoisyColumn=false;
27  int oldCol=-1, oldAveragedBlock=-1;
28  for(DigiIterator di = b; di != e; ++di) {
29  int row = di->row();
30  int col = di->column();
31  int averagedBlock = row / numberOfRowsAveragedOver_;
32  if ( (col!=oldCol) | ( averagedBlock != oldAveragedBlock) ) {
33  oldCol=col; oldAveragedBlock= averagedBlock;
34  std::tie(pedestal,gain) = ped->getPedAndGain(col, row, range, cols, isDeadColumn, isNoisyColumn);
35  }
36  if ( isDeadColumn | isNoisyColumn ) electron[i++] =0;
37  else {
38  float vcal = di->adc() * gain - pedestal*gain;
39  // float vcal = (di->adc() - DBpedestal) * DBgain;
40  electron[i++] = int( vcal * conversionFactor + offset);
41  }
42  }
43  assert(i==(e-b));
44 }
45 
46 
47 
48 
49 float SiPixelGainCalibrationForHLTService::getPedestal( const uint32_t& detID,const int& col, const int& row)
50 {
51  bool isDead = false;
52  bool isNoisy = false;
53  float pedestalValue = this->getPedestalByColumn(detID, col, row, isDead, isNoisy);
54  if (isDead || isNoisy)
55  {
56  this->throwExepctionForBadRead("HLT getPedestal()", detID, col, row, pedestalValue);
57  return 0.0;
58  }
59  return pedestalValue;
60 }
61 
62 float SiPixelGainCalibrationForHLTService::getGain( const uint32_t& detID,const int& col, const int& row)
63 {
64  bool isDead = false;
65  bool isNoisy = false;
66  float gainValue = this->getGainByColumn(detID, col, row, isDead, isNoisy);
67  if (isDead || isNoisy)
68  {
69  this->throwExepctionForBadRead("HLT getGain()", detID, col, row, gainValue);
70  return 0.0;
71  }
72  return gainValue;
73 }
74 
75 bool SiPixelGainCalibrationForHLTService::isDead( const uint32_t& detID,const int& col, const int& row)
76 {
77  bool isDead = false;
78  bool isNoisy = false;
79  try
80  {
81  this->getPedestalByColumn(detID, col, row, isDead, isNoisy); //pedestal stores dead column value as well
82  }
83  catch (cms::Exception& e)
84  {
85  // Do not stop processing if you check if a nonexistant pixel is dead
86  edm::LogInfo("SiPixelGainCalibrationForHLTService") << "Attempting to check if nonexistant pixel is dead. Exception message: " << e.what();
87  isDead = false;
88  }
89  return isDead;
90 }
91 
92 bool SiPixelGainCalibrationForHLTService::isNoisy( const uint32_t& detID,const int& col, const int& row)
93 {
94  bool isDead = false;
95  bool isNoisy = false;
96  try
97  {
98  this->getPedestalByColumn(detID, col, row, isDead, isNoisy); //pedestal stores noisy column value as well
99  }
100  catch (cms::Exception& e)
101  {
102  // Do not stop processing if you check if a nonexistant pixel is noisy
103  edm::LogInfo("SiPixelGainCalibrationForHLTService") << "Attempting to check if nonexistant pixel is noisy. Exception message: " << e.what();
104  isNoisy = false;
105  }
106  return isNoisy;
107 }
108 
109 bool SiPixelGainCalibrationForHLTService::isDeadColumn( const uint32_t& detID,const int& col, const int& row)
110 {
111  bool isDead = false;
112  bool isNoisy = false;
113  try
114  {
115  this->getGainByColumn(detID, col, row, isDead, isNoisy);
116  }
117  catch (cms::Exception& e)
118  {
119  // Do not stop processing if you check if a nonexistant pixel is dead
120  edm::LogInfo("SiPixelGainCalibrationForHLTService") << "Attempting to check if nonexistant pixel is dead. Exception message: " << e.what();
121  isDead = false;
122  }
123  return isDead;
124 }
125 
126 bool SiPixelGainCalibrationForHLTService::isNoisyColumn( const uint32_t& detID,const int& col, const int& row)
127 {
128  bool isDead = false;
129  bool isNoisy = false;
130  try
131  {
132  this->getGainByColumn(detID, col, row, isDead, isNoisy);
133  }
134  catch (cms::Exception& e)
135  {
136  // Do not stop processing if you check if a nonexistant pixel is noisy
137  edm::LogInfo("SiPixelGainCalibrationForHLTService") << "Attempting to check if nonexistant pixel is noisy. Exception message: " << e.what();
138  isNoisy = false;
139  }
140  return isNoisy;
141 }
142 
virtual char const * what() const
Definition: Exception.cc:141
int i
Definition: DBlmapReader.cc:9
edm::DetSet< PixelDigi >::const_iterator DigiIterator
bool isDeadColumn(const uint32_t &detID, const int &col, const int &row)
assert(m_qm.get())
float getGain(const uint32_t &detID, const int &col, const int &row)
std::pair< ContainerIterator, ContainerIterator > Range
float getPedestalByColumn(const uint32_t &detID, const int &col, const int &row, bool &isDeadColumn, bool &isNoisyColumn)
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 isNoisyColumn(const uint32_t &detID, const int &col, const int &row)
bool isDead(const uint32_t &detID, const int &col, const int &row)
float getPedestal(const uint32_t &detID, const int &col, const int &row)
double b
Definition: hdecay.h:120
void calibrate(uint32_t detID, DigiIterator b, DigiIterator e, float conversionFactor, float offset, int *electron)
int col
Definition: cuy.py:1008
bool isNoisy(const uint32_t &detID, const int &col, const int &row)