1 #ifndef CalibTracker_SiPixelESProducers_SiPixelGainCalibrationServiceBase_H
2 #define CalibTracker_SiPixelESProducers_SiPixelGainCalibrationServiceBase_H
31 virtual float getGain (
const uint32_t& detID ,
const int&
col ,
const int& row)=0;
32 virtual float getPedestal (
const uint32_t& detID ,
const int&
col ,
const int& row)=0;
33 virtual bool isDead (
const uint32_t& detID ,
const int&
col ,
const int& row)=0;
34 virtual bool isDeadColumn (
const uint32_t& detID ,
const int&
col ,
const int& row)=0;
35 virtual bool isNoisy (
const uint32_t& detID ,
const int&
col ,
const int& row)=0;
36 virtual bool isNoisyColumn (
const uint32_t& detID ,
const int&
col ,
const int& row)=0;
38 virtual std::vector<uint32_t>
getDetIds()=0;
47 template<
class thePayloadObject,
class theDBRecordType>
55 virtual float getGain(
const uint32_t& detID,
const int&
col,
const int& row)=0;
56 virtual float getPedestal(
const uint32_t& detID,
const int&
col,
const int& row)=0;
58 virtual bool isDead (
const uint32_t& detID,
const int&
col,
const int& row )=0;
59 virtual bool isDeadColumn (
const uint32_t& detID,
const int&
col,
const int& row )=0;
61 virtual bool isNoisy (
const uint32_t& detID,
const int&
col,
const int& row )=0;
62 virtual bool isNoisyColumn (
const uint32_t& detID,
const int&
col,
const int& row )=0;
74 float getPedestalByPixel(
const uint32_t& detID,
const int&
col,
const int& row,
bool& isDeadPixel,
bool& isNoisyPixel) ;
75 float getGainByPixel(
const uint32_t& detID,
const int&
col,
const int& row,
bool& isDeadPixel,
bool& isNoisyPixel) ;
114 template<
class thePayloadObject,
class theDBRecordType>
120 edm::LogInfo(
"SiPixelGainCalibrationServicePayloadGetter") <<
"[SiPixelGainCalibrationServicePayloadGetter::SiPixelGainCalibrationServicePayloadGetter]";
137 template<
class thePayloadObject,
class theDBRecordType>
140 es.
get<theDBRecordType>().
get(ped);
141 numberOfRowsAveragedOver_ = ped->getNumberOfRowsToAverageOver();
146 template<
class thePayloadObject,
class theDBRecordType>
149 std::vector<uint32_t> vdetId_;
150 ped->getDetIds(vdetId_);
155 template<
class thePayloadObject,
class theDBRecordType>
157 double gainLow_ = ped->getGainLow();
161 template<
class thePayloadObject,
class theDBRecordType>
163 double gainHigh_ = ped->getGainHigh();
167 template<
class thePayloadObject,
class theDBRecordType>
169 double pedLow_ = ped->getPedLow();
173 template<
class thePayloadObject,
class theDBRecordType>
175 double pedHigh_ = ped->getPedHigh();
179 template<
class thePayloadObject,
class theDBRecordType>
185 if (detID != old_detID){
187 std::pair<const typename thePayloadObject::Range, const int> rangeAndNCols = ped->getRangeAndNCols(detID);
188 old_range = rangeAndNCols.first;
189 old_cols = rangeAndNCols.second;
192 return ped->getPed(col, row, old_range, old_cols, isDead, isNoisy);
194 <<
"[SiPixelGainCalibrationServicePayloadGetter::getPedestalByPixel] SiPixelGainCalibrationRcd not initialized ";
198 template<
class thePayloadObject,
class theDBRecordType>
204 if (detID != old_detID){
206 std::pair<const typename thePayloadObject::Range, const int> rangeAndNCols = ped->getRangeAndNCols(detID);
207 old_range = rangeAndNCols.first;
208 old_cols = rangeAndNCols.second;
210 return ped->getGain(col, row, old_range, old_cols, isDead, isNoisy);
212 <<
"[SiPixelGainCalibrationServicePayloadGetter::getGainByPixel] SiPixelGainCalibrationRcd not initialized ";
216 template<
class thePayloadObject,
class theDBRecordType>
223 bool inTheSameAveragedDataBlock =
false;
224 if ( row / numberOfRowsAveragedOver_ == oldAveragedBlockDataPed_ )
225 inTheSameAveragedDataBlock =
true;
227 if (detID != old_detID){
229 std::pair<const typename thePayloadObject::Range, const int> rangeAndNCols = ped->getRangeAndNCols(detID);
230 old_range = rangeAndNCols.first;
231 old_cols = rangeAndNCols.second;
233 else if (col == oldColumnIndexPed_ && inTheSameAveragedDataBlock)
235 isDeadColumn = oldThisColumnIsDeadPed_;
236 isNoisyColumn = oldThisColumnIsNoisyPed_;
237 return oldColumnValuePed_;
240 oldColumnIndexPed_ =
col;
241 oldAveragedBlockDataPed_ = row / numberOfRowsAveragedOver_;
242 oldColumnValuePed_ = ped->getPed(col, row, old_range, old_cols, isDeadColumn, isNoisyColumn);
243 oldThisColumnIsDeadPed_ = isDeadColumn;
244 oldThisColumnIsNoisyPed_ = isNoisyColumn;
246 return oldColumnValuePed_;
249 <<
"[SiPixelGainCalibrationServicePayloadGetter::getPedestalByColumn] SiPixelGainCalibrationRcd not initialized ";
253 template<
class thePayloadObject,
class theDBRecordType>
259 bool inTheSameAveragedDataBlock =
false;
260 if ( row / numberOfRowsAveragedOver_ == oldAveragedBlockDataGain_ )
261 inTheSameAveragedDataBlock =
true;
263 if (detID != old_detID){
265 std::pair<const typename thePayloadObject::Range, const int> rangeAndNCols = ped->getRangeAndNCols(detID);
266 old_range = rangeAndNCols.first;
267 old_cols = rangeAndNCols.second;
269 else if (col == oldColumnIndexGain_ && inTheSameAveragedDataBlock)
271 isDeadColumn = oldThisColumnIsDeadGain_;
272 isDeadColumn = oldThisColumnIsNoisyGain_;
273 return oldColumnValueGain_;
276 oldColumnIndexGain_ =
col;
277 oldAveragedBlockDataGain_ = row / numberOfRowsAveragedOver_;
278 oldColumnValueGain_ = ped->getGain(col, row, old_range, old_cols, isDeadColumn, isNoisyColumn);
279 oldThisColumnIsDeadGain_ = isDeadColumn;
280 oldThisColumnIsNoisyGain_ = isNoisyColumn;
282 return oldColumnValueGain_;
285 <<
"[SiPixelGainCalibrationServicePayloadGetter::getGainByColumn] SiPixelGainCalibrationRcd not initialized ";
288 template<
class thePayloadObject,
class theDBRecordType>
291 std::cerr <<
"[SiPixelGainCalibrationServicePayloadGetter::SiPixelGainCalibrationServicePayloadGetter]"
292 <<
"[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: "
293 << 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;
297 edm::LogError(
"SiPixelGainCalibrationService") <<
"[SiPixelGainCalibrationServicePayloadGetter::SiPixelGainCalibrationServicePayloadGetter]"
298 <<
"[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: "
299 << 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()
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
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
PixelRecoRange< float > Range
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
virtual bool isNoisy(const uint32_t &detID, const int &col, const int &row)=0
int oldAveragedBlockDataGain_
bool oldThisColumnIsNoisyGain_