72 void init(
double conversionFactor,
double conversionFactorL1,
double offset,
double offsetL1) {
105 template <
class tokenType,
class PayloadType>
130 : recordName_(iConfig.getParameter<
std::
string>(
"record")),
131 isForHLT_(iConfig.getParameter<
bool>(
"isForHLT")),
132 verbose_(iConfig.getUntrackedParameter<
bool>(
"verbose",
false)),
140 const unsigned int phase(thePSet.getParameter<
unsigned int>(
"phase"));
144 thePSet.getParameter<
double>(
"conversionFactorL1"),
145 thePSet.getParameter<
double>(
"offset"),
146 thePSet.getParameter<
double>(
"offsetL1"));
151 thePSet.getParameter<
double>(
"conversionFactorL1"),
152 thePSet.getParameter<
double>(
"offset"),
153 thePSet.getParameter<
double>(
"offsetL1"));
177 edm::LogPrint(
"SiPixelGainCalibScaler") <<
" Pixel Gains have a new IOV for run: " <<
run << std::endl;
180 computeAndStorePalyoads<edm::ESGetToken<SiPixelGainCalibrationForHLT, SiPixelGainCalibrationForHLTRcd>,
183 computeAndStorePalyoads<edm::ESGetToken<SiPixelGainCalibrationOffline, SiPixelGainCalibrationOfflineRcd>,
190 template <
class tokenType,
class PayloadType>
198 edm::LogInfo(
"SiPixelGainCalibScaler") <<
"There are: " << pDD->
dets().size() <<
" detectors";
203 edm::LogInfo(
"SiPixelGainCalibScaler") <<
" ==> This is a phase1 IOV";
206 edm::LogInfo(
"SiPixelGainCalibScaler") <<
" ==> This is a phase0 IOV";
213 std::vector<uint32_t> detids;
216 float mingain =
payload->getGainLow();
218 float minped =
payload->getPedLow();
219 float maxped =
payload->getPedHigh() * 1.10;
221 PayloadType SiPixelGainCalibration_(minped, maxped, mingain, maxgain);
230 for (
const auto&
d : detids) {
231 bool isLayer1 =
false;
240 std::vector<char> theSiPixelGainCalibration;
243 int numberOfRowsToAverageOver =
payload->getNumberOfRowsToAverageOver();
245 int nRocsInRow = (
range.second -
range.first) /
ncols / numberOfRowsToAverageOver;
246 unsigned int nRowsForHLT = 1;
247 int nrows =
std::max((
payload->getNumberOfRowsToAverageOver() * nRocsInRow),
250 auto rangeAndCol =
payload->getRangeAndNCols(
d);
256 <<
"NCOLS: " <<
payload->getNCols(
d) <<
" " << rangeAndCol.second <<
" NROWS:" << nrows
257 <<
", RANGES: " << rangeAndCol.first.second - rangeAndCol.first.first
258 <<
", Ratio: " <<
float(rangeAndCol.first.second - rangeAndCol.first.first) / rangeAndCol.second << std::endl;
262 for (
int row = 0; row < nrows; row++) {
263 float gain =
payload->getGain(
col, row, rangeAndCol.first, rangeAndCol.second, isDeadColumn, isNoisyColumn);
264 float ped =
payload->getPed(
col, row, rangeAndCol.first, rangeAndCol.second, isDeadColumn, isNoisyColumn);
267 edm::LogInfo(
"SiPixelGainCalibScaler") <<
"pre-change gain: " <<
gain <<
" pede:" << ped << std::endl;
299 edm::LogInfo(
"SiPixelGainCalibScaler") <<
"post-change gain: " <<
gain <<
" pede:" << ped << std::endl;
301 if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationForHLT>) {
302 SiPixelGainCalibration_.setData(ped,
gain, theSiPixelGainCalibration,
false,
false);
304 SiPixelGainCalibration_.setDataPedestal(ped, theSiPixelGainCalibration);
305 if ((row + 1) % numberOfRowsToAverageOver == 0) {
306 SiPixelGainCalibration_.setDataGain(
gain, numberOfRowsToAverageOver, theSiPixelGainCalibration);
312 typename PayloadType::Range outrange(theSiPixelGainCalibration.begin(), theSiPixelGainCalibration.end());
313 if (!SiPixelGainCalibration_.put(
d, outrange,
ncols))
314 edm::LogError(
"SiPixelGainCalibScaler") <<
"[SiPixelGainCalibScaler::analyze] detid already exists" << std::endl;
337 edm::LogError(
"SiPixelGainCalibScaler") <<
"caught std::exception " << er.what() << std::endl;
339 edm::LogError(
"SiPixelGainCalibScaler") <<
"Funny error" << std::endl;
353 desc.add<
bool>(
"isForHLT",
true);
356 vcalInfos.
add<
unsigned int>(
"phase");
357 vcalInfos.add<
double>(
"conversionFactor");
358 vcalInfos.add<
double>(
"conversionFactorL1");
359 vcalInfos.add<
double>(
"offset");
360 vcalInfos.add<
double>(
"offsetL1");
362 std::vector<edm::ParameterSet>
tmp;
366 phase0VCal.addParameter<
unsigned int>(
"phase", 0);
367 phase0VCal.addParameter<
double>(
"conversionFactor", 65.);
368 phase0VCal.addParameter<
double>(
"conversionFactorL1", 65.);
369 phase0VCal.addParameter<
double>(
"offset", -414.);
370 phase0VCal.addParameter<
double>(
"offsetL1", -414.);
375 phase1VCal.addParameter<
unsigned int>(
"phase", 1);
376 phase1VCal.addParameter<
double>(
"conversionFactor", 47.);
377 phase1VCal.addParameter<
double>(
"conversionFactorL1", 50.);
378 phase1VCal.addParameter<
double>(
"offset", -60.);
379 phase1VCal.addParameter<
double>(
"offsetL1", -670.);
382 desc.addVPSet(
"parameters", vcalInfos,
tmp);
384 desc.addUntracked<
bool>(
"verbose",
false);
386 descriptions.
add(
"siPixelGainCalibScaler",
desc);
Log< level::Info, true > LogVerbatim
~SiPixelGainCalibScaler() override
unsigned int pxbLayer(const DetId &id) const
Base exception class for the object to relational access.
const std::string recordName_
void analyze(const edm::Event &, const edm::EventSetup &) override
PixelRecoRange< float > Range
cond::Time_t beginOfTime() const
double m_conversionFactor
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
void computeAndStorePalyoads(const edm::EventSetup &iSetup, const tokenType &token)
const std::vector< edm::ParameterSet > m_parameters
Log< level::Error, false > LogError
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
constexpr std::array< uint8_t, layerIndexSize > layer
edm::ESWatcher< SiPixelGainCalibrationOfflineRcd > pixelOfflineGainWatcher_
void appendOneIOV(const T &payload, cond::Time_t sinceTime, const std::string &recordName)
double getConversionFactor()
double getConversionFactorL1()
bool isNewTagRequest(const std::string &recordName)
cond::Time_t currentTime() const
bool isThere(GeomDetEnumerators::SubDetector subdet) const
#define DEFINE_FWK_MODULE(type)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool getData(T &iHolder) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Log< level::Warning, true > LogPrint
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
Log< level::Info, false > LogInfo
gainScale::VCalInfo phase0VCal
edm::ESGetToken< SiPixelGainCalibrationOffline, SiPixelGainCalibrationOfflineRcd > gainOfflineCalibToken_
gainScale::VCalInfo phase1VCal
edm::ESWatcher< SiPixelGainCalibrationForHLTRcd > pixelHLTGainWatcher_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tkTopoToken_
edm::ESGetToken< SiPixelGainCalibrationForHLT, SiPixelGainCalibrationForHLTRcd > gainHLTCalibToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool check(const edm::EventSetup &iSetup)
void init(double conversionFactor, double conversionFactorL1, double offset, double offsetL1)
SiPixelGainCalibScaler(const edm::ParameterSet &)
char const * what() const noexcept override
double m_conversionFactorL1
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)