1 #ifndef CalibTracker_SiPixelESProducers_SiPixelGainCalibrationServiceBase_H
2 #define CalibTracker_SiPixelESProducers_SiPixelGainCalibrationServiceBase_H
40 virtual float getGain (
const uint32_t& detID ,
const int&
col ,
const int& row)=0;
41 virtual float getPedestal (
const uint32_t& detID ,
const int&
col ,
const int& row)=0;
42 virtual bool isDead (
const uint32_t& detID ,
const int&
col ,
const int& row)=0;
43 virtual bool isDeadColumn (
const uint32_t& detID ,
const int&
col ,
const int& row)=0;
44 virtual bool isNoisy (
const uint32_t& detID ,
const int&
col ,
const int& row)=0;
45 virtual bool isNoisyColumn (
const uint32_t& detID ,
const int&
col ,
const int& row)=0;
47 virtual std::vector<uint32_t>
getDetIds()=0;
57 template<
class thePayloadObject,
class theDBRecordType>
65 virtual float getGain(
const uint32_t& detID,
const int&
col,
const int& row)=0;
66 virtual float getPedestal(
const uint32_t& detID,
const int&
col,
const int& row)=0;
68 virtual bool isDead (
const uint32_t& detID,
const int&
col,
const int& row )=0;
69 virtual bool isDeadColumn (
const uint32_t& detID,
const int&
col,
const int& row )=0;
71 virtual bool isNoisy (
const uint32_t& detID,
const int&
col,
const int& row )=0;
72 virtual bool isNoisyColumn (
const uint32_t& detID,
const int&
col,
const int& row )=0;
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) ;
123 template<
class thePayloadObject,
class theDBRecordType>
129 edm::LogInfo(
"SiPixelGainCalibrationServicePayloadGetter") <<
"[SiPixelGainCalibrationServicePayloadGetter::SiPixelGainCalibrationServicePayloadGetter]";
146 template<
class thePayloadObject,
class theDBRecordType>
149 es.
get<theDBRecordType>().
get(ped);
151 numberOfRowsAveragedOver_ = ped->getNumberOfRowsToAverageOver();
156 template<
class thePayloadObject,
class theDBRecordType>
159 std::vector<uint32_t> vdetId_;
160 ped->getDetIds(vdetId_);
165 template<
class thePayloadObject,
class theDBRecordType>
167 double gainLow_ = ped->getGainLow();
171 template<
class thePayloadObject,
class theDBRecordType>
173 double gainHigh_ = ped->getGainHigh();
177 template<
class thePayloadObject,
class theDBRecordType>
179 double pedLow_ = ped->getPedLow();
183 template<
class thePayloadObject,
class theDBRecordType>
185 double pedHigh_ = ped->getPedHigh();
189 template<
class thePayloadObject,
class theDBRecordType>
195 if (detID != old_detID){
197 std::pair<const typename thePayloadObject::Range, const int> rangeAndNCols = ped->getRangeAndNCols(detID);
198 old_range = rangeAndNCols.first;
199 old_cols = rangeAndNCols.second;
200 oldColumnIndexGain_ = -1;
203 return ped->getPed(col, row, old_range, old_cols, isDead, isNoisy);
205 <<
"[SiPixelGainCalibrationServicePayloadGetter::getPedestalByPixel] SiPixelGainCalibrationRcd not initialized ";
209 template<
class thePayloadObject,
class theDBRecordType>
215 if (detID != old_detID){
217 std::pair<const typename thePayloadObject::Range, const int> rangeAndNCols = ped->getRangeAndNCols(detID);
218 old_range = rangeAndNCols.first;
219 old_cols = rangeAndNCols.second;
220 return oldColumnValuePed_;
222 return ped->getGain(col, row, old_range, old_cols, isDead, isNoisy);
224 <<
"[SiPixelGainCalibrationServicePayloadGetter::getGainByPixel] SiPixelGainCalibrationRcd not initialized ";
228 template<
class thePayloadObject,
class theDBRecordType>
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;
246 else if (col == oldColumnIndexPed_ && inTheSameAveragedDataBlock)
248 isDeadColumn = oldThisColumnIsDeadPed_;
249 isNoisyColumn = oldThisColumnIsNoisyPed_;
250 return oldColumnValuePed_;
253 oldColumnIndexPed_ =
col;
254 oldAveragedBlockDataPed_ = row / numberOfRowsAveragedOver_;
255 oldColumnValuePed_ = ped->getPed(col, row, old_range, old_cols, isDeadColumn, isNoisyColumn);
256 oldThisColumnIsDeadPed_ = isDeadColumn;
257 oldThisColumnIsNoisyPed_ = isNoisyColumn;
259 return oldColumnValuePed_;
262 <<
"[SiPixelGainCalibrationServicePayloadGetter::getPedestalByColumn] SiPixelGainCalibrationRcd not initialized ";
266 template<
class thePayloadObject,
class theDBRecordType>
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;
283 else if (col == oldColumnIndexGain_ && inTheSameAveragedDataBlock)
285 isDeadColumn = oldThisColumnIsDeadGain_;
286 isDeadColumn = oldThisColumnIsNoisyGain_;
287 return oldColumnValueGain_;
290 oldColumnIndexGain_ =
col;
291 oldAveragedBlockDataGain_ = row / numberOfRowsAveragedOver_;
292 oldColumnValueGain_ = ped->getGain(col, row, old_range, old_cols, isDeadColumn, isNoisyColumn);
293 oldThisColumnIsDeadGain_ = isDeadColumn;
294 oldThisColumnIsNoisyGain_ = isNoisyColumn;
296 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 the ped/gain on a pixel that is flagged as dead/noisy. For payload: " << payload <<
" DETID: "
307 << detID <<
" col: " << col <<
" row: " << row <<
". You must check if the pixel is dead/noisy before asking for the ped/gain value, otherwise you will get corrupt data! value: " << value << std::endl;
311 edm::LogError(
"SiPixelGainCalibrationService") <<
"[SiPixelGainCalibrationServicePayloadGetter::SiPixelGainCalibrationServicePayloadGetter]"
312 <<
"[SiPixelGainCalibrationServicePayloadGetter] ERROR - Slow down, speed racer! You have tried to read the ped/gain on a pixel that is flagged as dead/noisy. For payload: " << payload <<
" DETID: "
313 << detID <<
" col: " << col <<
" row: " << row <<
". You must check if the pixel is dead/noisy before asking for the ped/gain value, otherwise you will get corrupt data! value: " << value << std::endl;
virtual ~SiPixelGainCalibrationServicePayloadGetter()
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
virtual bool isNoisyColumn(const uint32_t &detID, const int &col, const int &row)=0
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
virtual bool isDeadColumn(const uint32_t &detID, const int &col, const int &row)=0
PixelRecoRange< float > Range
virtual std::vector< uint32_t > getDetIds()=0
thePayloadObject::Range old_range
virtual float getGain(const uint32_t &detID, const int &col, const int &row)=0
virtual double getGainHigh()=0
virtual double getGainLow()=0
virtual double getPedLow()=0
float oldColumnValueGain_
virtual double getPedHigh()=0
virtual bool isDead(const uint32_t &detID, const int &col, const int &row)=0
virtual bool isDead(const uint32_t &detID, const int &col, const int &row)=0
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)
virtual float getPedestal(const uint32_t &detID, const int &col, const int &row)=0
int oldAveragedBlockDataPed_
bool oldThisColumnIsNoisyPed_
void throwExepctionForBadRead(std::string payload, const uint32_t &detID, const int &col, const int &row, double value=-1) const
bool oldThisColumnIsDeadPed_
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
edm::ESHandle< thePayloadObject > ped
void setESObjects(const edm::EventSetup &es)
SiPixelGainCalibrationServicePayloadGetter(const edm::ParameterSet &conf)
virtual float getGain(const uint32_t &detID, const int &col, const int &row)=0
std::vector< uint32_t > getDetIds()
virtual bool isNoisy(const uint32_t &detID, const int &col, const int &row)=0
volatile std::atomic< bool > shutdown_flag false
collection_type::const_iterator const_iterator
virtual void calibrate(uint32_t detID, DigiIterator b, DigiIterator e, float conversionFactor, float offset, int *electron)
virtual bool isNoisy(const uint32_t &detID, const int &col, const int &row)=0
int oldAveragedBlockDataGain_
bool oldThisColumnIsNoisyGain_