|
|
Go to the documentation of this file. 1 #ifndef CalibTracker_SiPixelESProducers_SiPixelGainCalibrationServiceBase_H
2 #define CalibTracker_SiPixelESProducers_SiPixelGainCalibrationServiceBase_H
42 virtual float getGain(
const uint32_t& detID,
const int&
col,
const int& row) = 0;
43 virtual float getPedestal(
const uint32_t& detID,
const int&
col,
const int& row) = 0;
44 virtual bool isDead(
const uint32_t& detID,
const int&
col,
const int& row) = 0;
45 virtual bool isDeadColumn(
const uint32_t& detID,
const int&
col,
const int& row) = 0;
46 virtual bool isNoisy(
const uint32_t& detID,
const int&
col,
const int& row) = 0;
47 virtual bool isNoisyColumn(
const uint32_t& detID,
const int&
col,
const int& row) = 0;
49 virtual std::vector<uint32_t>
getDetIds() = 0;
57 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);
124 template <
class thePayloadObject,
class theDBRecordType>
127 : conf_(conf), ESetupInit_(
false) {
128 edm::LogInfo(
"SiPixelGainCalibrationServicePayloadGetter")
129 <<
"[SiPixelGainCalibrationServicePayloadGetter::SiPixelGainCalibrationServicePayloadGetter]";
145 template <
class thePayloadObject,
class theDBRecordType>
148 es.
get<theDBRecordType>().
get(ped);
150 numberOfRowsAveragedOver_ = ped->getNumberOfRowsToAverageOver();
154 template <
class thePayloadObject,
class theDBRecordType>
156 std::vector<uint32_t> vdetId_;
157 ped->getDetIds(vdetId_);
161 template <
class thePayloadObject,
class theDBRecordType>
163 double gainLow_ = ped->getGainLow();
167 template <
class thePayloadObject,
class theDBRecordType>
169 double gainHigh_ = ped->getGainHigh();
173 template <
class thePayloadObject,
class theDBRecordType>
175 double pedLow_ = ped->getPedLow();
179 template <
class thePayloadObject,
class theDBRecordType>
181 double pedHigh_ = ped->getPedHigh();
185 template <
class thePayloadObject,
class theDBRecordType>
187 const uint32_t& detID,
const int&
col,
const int& row,
bool& isDead,
bool& isNoisy) {
192 if (detID != old_detID) {
194 std::pair<const typename thePayloadObject::Range, const int> rangeAndNCols = ped->getRangeAndNCols(detID);
195 old_range = rangeAndNCols.first;
196 old_cols = rangeAndNCols.second;
197 oldColumnIndexGain_ = -1;
200 return ped->getPed(
col, row, old_range, old_cols, isDead, isNoisy);
202 throw cms::Exception(
"NullPointer") <<
"[SiPixelGainCalibrationServicePayloadGetter::getPedestalByPixel] "
203 "SiPixelGainCalibrationRcd not initialized ";
206 template <
class thePayloadObject,
class theDBRecordType>
208 const uint32_t& detID,
const int&
col,
const int& row,
bool& isDead,
bool& isNoisy) {
213 if (detID != old_detID) {
215 std::pair<const typename thePayloadObject::Range, const int> rangeAndNCols = ped->getRangeAndNCols(detID);
216 old_range = rangeAndNCols.first;
217 old_cols = rangeAndNCols.second;
218 return oldColumnValuePed_;
220 return ped->getGain(
col, row, old_range, old_cols, isDead, isNoisy);
223 <<
"[SiPixelGainCalibrationServicePayloadGetter::getGainByPixel] SiPixelGainCalibrationRcd not initialized ";
226 template <
class thePayloadObject,
class theDBRecordType>
228 const uint32_t& detID,
const int&
col,
const int& row,
bool& isDeadColumn,
bool& isNoisyColumn) {
234 bool inTheSameAveragedDataBlock =
false;
235 if (row / numberOfRowsAveragedOver_ == oldAveragedBlockDataPed_)
236 inTheSameAveragedDataBlock =
true;
238 if (detID != old_detID) {
240 std::pair<const typename thePayloadObject::Range, const int> rangeAndNCols = ped->getRangeAndNCols(detID);
241 old_range = rangeAndNCols.first;
242 old_cols = rangeAndNCols.second;
243 oldColumnIndexGain_ = -1;
244 }
else if (
col == oldColumnIndexPed_ && inTheSameAveragedDataBlock)
246 isDeadColumn = oldThisColumnIsDeadPed_;
247 isNoisyColumn = oldThisColumnIsNoisyPed_;
248 return oldColumnValuePed_;
251 oldColumnIndexPed_ =
col;
252 oldAveragedBlockDataPed_ = row / numberOfRowsAveragedOver_;
253 oldColumnValuePed_ = ped->getPed(
col, row, old_range, old_cols, isDeadColumn, isNoisyColumn);
254 oldThisColumnIsDeadPed_ = isDeadColumn;
255 oldThisColumnIsNoisyPed_ = isNoisyColumn;
257 return oldColumnValuePed_;
260 throw cms::Exception(
"NullPointer") <<
"[SiPixelGainCalibrationServicePayloadGetter::getPedestalByColumn] "
261 "SiPixelGainCalibrationRcd not initialized ";
264 template <
class thePayloadObject,
class theDBRecordType>
266 const uint32_t& detID,
const int&
col,
const int& row,
bool& isDeadColumn,
bool& isNoisyColumn) {
271 bool inTheSameAveragedDataBlock =
false;
272 if (row / numberOfRowsAveragedOver_ == oldAveragedBlockDataGain_)
273 inTheSameAveragedDataBlock =
true;
275 if (detID != old_detID) {
277 std::pair<const typename thePayloadObject::Range, const int> rangeAndNCols = ped->getRangeAndNCols(detID);
278 old_range = rangeAndNCols.first;
279 old_cols = rangeAndNCols.second;
280 oldColumnIndexPed_ = -1;
281 }
else if (
col == oldColumnIndexGain_ && inTheSameAveragedDataBlock)
283 isDeadColumn = oldThisColumnIsDeadGain_;
284 isDeadColumn = oldThisColumnIsNoisyGain_;
285 return oldColumnValueGain_;
288 oldColumnIndexGain_ =
col;
289 oldAveragedBlockDataGain_ = row / numberOfRowsAveragedOver_;
290 oldColumnValueGain_ = ped->getGain(
col, row, old_range, old_cols, isDeadColumn, isNoisyColumn);
291 oldThisColumnIsDeadGain_ = isDeadColumn;
292 oldThisColumnIsNoisyGain_ = isNoisyColumn;
294 return oldColumnValueGain_;
298 <<
"[SiPixelGainCalibrationServicePayloadGetter::getGainByColumn] SiPixelGainCalibrationRcd not initialized ";
301 template <
class thePayloadObject,
class theDBRecordType>
304 std::cerr <<
"[SiPixelGainCalibrationServicePayloadGetter::SiPixelGainCalibrationServicePayloadGetter]"
305 <<
"[SiPixelGainCalibrationServicePayloadGetter] ERROR - Slow down, speed racer! You have tried to read "
306 "the ped/gain on a pixel that is flagged as dead/noisy. For payload: "
307 <<
payload <<
" DETID: " << detID <<
" col: " <<
col <<
" row: " << row
308 <<
". You must check if the pixel is dead/noisy before asking for the ped/gain value, otherwise you will "
309 "get corrupt data! value: "
310 <<
value << std::endl;
315 <<
"[SiPixelGainCalibrationServicePayloadGetter::SiPixelGainCalibrationServicePayloadGetter]"
316 <<
"[SiPixelGainCalibrationServicePayloadGetter] ERROR - Slow down, speed racer! You have tried to read the "
317 "ped/gain on a pixel that is flagged as dead/noisy. For payload: "
318 <<
payload <<
" DETID: " << detID <<
" col: " <<
col <<
" row: " << row
319 <<
". You must check if the pixel is dead/noisy before asking for the ped/gain value, otherwise you will get "
320 "corrupt data! value: "
321 <<
value << std::endl;
virtual bool isDeadColumn(const uint32_t &detID, const int &col, const int &row)=0
thePayloadObject const & payload() const
PixelRecoRange< float > Range
bool isDeadColumn(const uint32_t &detID, const int &col, const int &row) override=0
virtual double getGainHigh()=0
edm::DetSet< PixelDigi >::const_iterator DigiIterator
~SiPixelGainCalibrationServicePayloadGetter() override
virtual bool isDead(const uint32_t &detID, const int &col, const int &row)=0
virtual float getGain(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)
bool isNoisy(const uint32_t &detID, const int &col, const int &row) override=0
Log< level::Info, false > LogInfo
int numberOfRowsAveragedOver_
float getGainByColumn(const uint32_t &detID, const int &col, const int &row, bool &isDeadColumn, bool &isNoisyColumn)
virtual double getGainLow()=0
void setESObjects(const edm::EventSetup &es) override
float getGainByPixel(const uint32_t &detID, const int &col, const int &row, bool &isDeadPixel, bool &isNoisyPixel)
std::vector< uint32_t > getDetIds() override
edm::ESHandle< thePayloadObject > ped
float getGain(const uint32_t &detID, const int &col, const int &row) override=0
bool isNoisyColumn(const uint32_t &detID, const int &col, const int &row) override=0
float getPedestal(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()
float oldColumnValueGain_
int oldAveragedBlockDataPed_
double getGainHigh() override
SiPixelGainCalibrationServiceBase()
virtual double getPedHigh()=0
bool oldThisColumnIsNoisyPed_
Log< level::Error, false > LogError
virtual std::vector< uint32_t > getDetIds()=0
int oldAveragedBlockDataGain_
bool isDead(const uint32_t &detID, const int &col, const int &row) override=0
double getPedLow() override
static void fillPSetDescription(edm::ParameterSetDescription &desc)
virtual double getPedLow()=0
virtual void setESObjects(const edm::EventSetup &es)=0
bool oldThisColumnIsDeadPed_
double getPedHigh() override
bool oldThisColumnIsDeadGain_
bool oldThisColumnIsNoisyGain_
virtual float getPedestal(const uint32_t &detID, const int &col, const int &row)=0
double getGainLow() override
SiPixelGainCalibrationServicePayloadGetter(const edm::ParameterSet &conf)
void throwExepctionForBadRead(std::string payload, const uint32_t &detID, const int &col, const int &row, double value=-1) const
virtual void calibrate(uint32_t detID, DigiIterator b, DigiIterator e, float conversionFactor, float offset, int *electron)
thePayloadObject::Range old_range
float getPedestalByPixel(const uint32_t &detID, const int &col, const int &row, bool &isDeadPixel, bool &isNoisyPixel)
virtual bool isNoisy(const uint32_t &detID, const int &col, const int &row)=0
collection_type::const_iterator const_iterator