1 #ifndef CalibTracker_SiPixelESProducers_SiPixelGainCalibrationServiceBase_H
2 #define CalibTracker_SiPixelESProducers_SiPixelGainCalibrationServiceBase_H
43 virtual float getGain(
const uint32_t& detID,
const int&
col,
const int& row) = 0;
44 virtual float getPedestal(
const uint32_t& detID,
const int&
col,
const int& row) = 0;
45 virtual bool isDead(
const uint32_t& detID,
const int&
col,
const int& row) = 0;
46 virtual bool isDeadColumn(
const uint32_t& detID,
const int&
col,
const int& row) = 0;
47 virtual bool isNoisy(
const uint32_t& detID,
const int&
col,
const int& row) = 0;
48 virtual bool isNoisyColumn(
const uint32_t& detID,
const int&
col,
const int& row) = 0;
50 virtual std::vector<uint32_t>
getDetIds() = 0;
58 template <
class thePayloadObject,
class theDBRecordType>
64 float getGain(
const uint32_t& detID,
const int&
col,
const int& row)
override = 0;
65 float getPedestal(
const uint32_t& detID,
const int& col,
const int& row)
override = 0;
67 bool isDead(
const uint32_t& detID,
const int& col,
const int& row)
override = 0;
68 bool isDeadColumn(
const uint32_t& detID,
const int& col,
const int& row)
override = 0;
70 bool isNoisy(
const uint32_t& detID,
const int& col,
const int& row)
override = 0;
71 bool isNoisyColumn(
const uint32_t& detID,
const int& col,
const int& row)
override = 0;
77 std::vector<uint32_t>
getDetIds()
override;
84 float getPedestalByPixel(
const uint32_t& detID,
const int& col,
const int& row,
bool& isDeadPixel,
bool& isNoisyPixel);
85 float getGainByPixel(
const uint32_t& detID,
const int& col,
const int& row,
bool& isDeadPixel,
bool& isNoisyPixel);
98 const thePayloadObject*
ped =
nullptr;
125 template <
class thePayloadObject,
class theDBRecordType>
129 edm::LogInfo(
"SiPixelGainCalibrationServicePayloadGetter")
130 <<
"[SiPixelGainCalibrationServicePayloadGetter::SiPixelGainCalibrationServicePayloadGetter]";
146 template <
class thePayloadObject,
class theDBRecordType>
151 numberOfRowsAveragedOver_ = ped->getNumberOfRowsToAverageOver();
155 template <
class thePayloadObject,
class theDBRecordType>
157 std::vector<uint32_t> vdetId_;
158 ped->getDetIds(vdetId_);
162 template <
class thePayloadObject,
class theDBRecordType>
164 double gainLow_ = ped->getGainLow();
168 template <
class thePayloadObject,
class theDBRecordType>
170 double gainHigh_ = ped->getGainHigh();
174 template <
class thePayloadObject,
class theDBRecordType>
176 double pedLow_ = ped->getPedLow();
180 template <
class thePayloadObject,
class theDBRecordType>
182 double pedHigh_ = ped->getPedHigh();
186 template <
class thePayloadObject,
class theDBRecordType>
188 const uint32_t& detID,
const int&
col,
const int& row,
bool& isDead,
bool& isNoisy) {
193 if (detID != old_detID) {
195 std::pair<const typename thePayloadObject::Range, const int> rangeAndNCols = ped->getRangeAndNCols(detID);
196 old_range = rangeAndNCols.first;
197 old_cols = rangeAndNCols.second;
198 oldColumnIndexGain_ = -1;
201 return ped->getPed(col, row, old_range, old_cols, isDead, isNoisy);
203 throw cms::Exception(
"NullPointer") <<
"[SiPixelGainCalibrationServicePayloadGetter::getPedestalByPixel] "
204 "SiPixelGainCalibrationRcd not initialized ";
207 template <
class thePayloadObject,
class theDBRecordType>
209 const uint32_t& detID,
const int&
col,
const int& row,
bool& isDead,
bool& isNoisy) {
214 if (detID != old_detID) {
216 std::pair<const typename thePayloadObject::Range, const int> rangeAndNCols = ped->getRangeAndNCols(detID);
217 old_range = rangeAndNCols.first;
218 old_cols = rangeAndNCols.second;
219 return oldColumnValuePed_;
221 return ped->getGain(col, row, old_range, old_cols, isDead, isNoisy);
224 <<
"[SiPixelGainCalibrationServicePayloadGetter::getGainByPixel] SiPixelGainCalibrationRcd not initialized ";
227 template <
class thePayloadObject,
class theDBRecordType>
229 const uint32_t& detID,
const int&
col,
const int& row,
bool& isDeadColumn,
bool& isNoisyColumn) {
235 bool inTheSameAveragedDataBlock =
false;
236 if (row / numberOfRowsAveragedOver_ == oldAveragedBlockDataPed_)
237 inTheSameAveragedDataBlock =
true;
239 if (detID != old_detID) {
241 std::pair<const typename thePayloadObject::Range, const int> rangeAndNCols = ped->getRangeAndNCols(detID);
242 old_range = rangeAndNCols.first;
243 old_cols = rangeAndNCols.second;
244 oldColumnIndexGain_ = -1;
245 }
else if (col == oldColumnIndexPed_ && inTheSameAveragedDataBlock)
247 isDeadColumn = oldThisColumnIsDeadPed_;
248 isNoisyColumn = oldThisColumnIsNoisyPed_;
249 return oldColumnValuePed_;
252 oldColumnIndexPed_ =
col;
253 oldAveragedBlockDataPed_ = row / numberOfRowsAveragedOver_;
254 oldColumnValuePed_ = ped->getPed(col, row, old_range, old_cols, isDeadColumn, isNoisyColumn);
255 oldThisColumnIsDeadPed_ = isDeadColumn;
256 oldThisColumnIsNoisyPed_ = isNoisyColumn;
258 return oldColumnValuePed_;
261 throw cms::Exception(
"NullPointer") <<
"[SiPixelGainCalibrationServicePayloadGetter::getPedestalByColumn] "
262 "SiPixelGainCalibrationRcd not initialized ";
265 template <
class thePayloadObject,
class theDBRecordType>
267 const uint32_t& detID,
const int&
col,
const int& row,
bool& isDeadColumn,
bool& isNoisyColumn) {
272 bool inTheSameAveragedDataBlock =
false;
273 if (row / numberOfRowsAveragedOver_ == oldAveragedBlockDataGain_)
274 inTheSameAveragedDataBlock =
true;
276 if (detID != old_detID) {
278 std::pair<const typename thePayloadObject::Range, const int> rangeAndNCols = ped->getRangeAndNCols(detID);
279 old_range = rangeAndNCols.first;
280 old_cols = rangeAndNCols.second;
281 oldColumnIndexPed_ = -1;
282 }
else if (col == oldColumnIndexGain_ && inTheSameAveragedDataBlock)
284 isDeadColumn = oldThisColumnIsDeadGain_;
285 isDeadColumn = oldThisColumnIsNoisyGain_;
286 return oldColumnValueGain_;
289 oldColumnIndexGain_ =
col;
290 oldAveragedBlockDataGain_ = row / numberOfRowsAveragedOver_;
291 oldColumnValueGain_ = ped->getGain(col, row, old_range, old_cols, isDeadColumn, isNoisyColumn);
292 oldThisColumnIsDeadGain_ = isDeadColumn;
293 oldThisColumnIsNoisyGain_ = isNoisyColumn;
295 return oldColumnValueGain_;
299 <<
"[SiPixelGainCalibrationServicePayloadGetter::getGainByColumn] SiPixelGainCalibrationRcd not initialized ";
302 template <
class thePayloadObject,
class theDBRecordType>
305 std::cerr <<
"[SiPixelGainCalibrationServicePayloadGetter::SiPixelGainCalibrationServicePayloadGetter]"
306 <<
"[SiPixelGainCalibrationServicePayloadGetter] ERROR - Slow down, speed racer! You have tried to read "
307 "the ped/gain on a pixel that is flagged as dead/noisy. For payload: "
308 << payload <<
" DETID: " << detID <<
" col: " << col <<
" row: " << row
309 <<
". You must check if the pixel is dead/noisy before asking for the ped/gain value, otherwise you will "
310 "get corrupt data! value: "
311 << value << std::endl;
316 <<
"[SiPixelGainCalibrationServicePayloadGetter::SiPixelGainCalibrationServicePayloadGetter]"
317 <<
"[SiPixelGainCalibrationServicePayloadGetter] ERROR - Slow down, speed racer! You have tried to read the "
318 "ped/gain on a pixel that is flagged as dead/noisy. For payload: "
319 << payload <<
" DETID: " << detID <<
" col: " << col <<
" row: " << row
320 <<
". You must check if the pixel is dead/noisy before asking for the ped/gain value, otherwise you will get "
321 "corrupt data! value: "
322 << value << std::endl;
bool isDeadColumn(const uint32_t &detID, const int &col, const int &row) override=0
thePayloadObject const & payload() const
bool oldThisColumnIsDeadGain_
float getGainByPixel(const uint32_t &detID, const int &col, const int &row, bool &isDeadPixel, bool &isNoisyPixel)
virtual void setESObjects(const edm::EventSetup &es)=0
int numberOfRowsAveragedOver_
SiPixelGainCalibrationServiceBase()
edm::DetSet< PixelDigi >::const_iterator DigiIterator
float getPedestalByPixel(const uint32_t &detID, const int &col, const int &row, bool &isDeadPixel, bool &isNoisyPixel)
virtual bool isDeadColumn(const uint32_t &detID, const int &col, const int &row)=0
PixelRecoRange< float > Range
float getPedestal(const uint32_t &detID, const int &col, const int &row) override=0
virtual std::vector< uint32_t > getDetIds()=0
float getGain(const uint32_t &detID, const int &col, const int &row) override=0
std::vector< uint32_t > getDetIds() override
thePayloadObject::Range old_range
virtual double getGainHigh()=0
virtual double getGainLow()=0
double getGainLow() override
virtual double getPedLow()=0
float oldColumnValueGain_
virtual double getPedHigh()=0
SiPixelGainCalibrationServicePayloadGetter(const edm::ParameterSet &conf, edm::ConsumesCollector iC)
virtual bool isDead(const uint32_t &detID, const int &col, const int &row)=0
Log< level::Error, false > LogError
double getGainHigh() override
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)
bool getData(T &iHolder) const
const thePayloadObject * ped
int oldAveragedBlockDataPed_
bool oldThisColumnIsNoisyPed_
void throwExepctionForBadRead(std::string payload, const uint32_t &detID, const int &col, const int &row, double value=-1) const
double getPedLow() override
bool isNoisy(const uint32_t &detID, const int &col, const int &row) override=0
bool oldThisColumnIsDeadPed_
void setESObjects(const edm::EventSetup &es) override
bool isNoisyColumn(const uint32_t &detID, const int &col, const int &row) override=0
virtual bool isNoisyColumn(const uint32_t &detID, const int &col, const int &row)=0
virtual ~SiPixelGainCalibrationServiceBase()
virtual float getPedestal(const uint32_t &detID, const int &col, const int &row)=0
Log< level::Info, false > LogInfo
static void fillPSetDescription(edm::ParameterSetDescription &desc)
double getPedHigh() 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
collection_type::const_iterator const_iterator
virtual void calibrate(uint32_t detID, DigiIterator b, DigiIterator e, float conversionFactor, float offset, int *electron)
int oldAveragedBlockDataGain_
const edm::ESGetToken< thePayloadObject, theDBRecordType > pedToken_
bool isDead(const uint32_t &detID, const int &col, const int &row) override=0
bool oldThisColumnIsNoisyGain_