54 std::unique_ptr<SiStripApvGain>
getNewObject(
const std::map<std::pair<uint32_t, int>,
float>& theMap);
71 m_Record(iConfig.getParameter<
std::string>(
"Record")),
87 std::map<std::pair<uint32_t, int>,
float> theMap;
89 std::vector<uint32_t> detid;
90 g1g2.getDetIds(detid);
91 for (
const auto&
d : detid) {
97 for (
int it = 0;
it < rangeG1_old.second - rangeG1_old.first;
it++) {
100 std::pair<uint32_t, int>
index = std::make_pair(
d, nAPV);
102 float G1_old = g1g2.getApvGain(
it, rangeG1_old);
103 float G2_old = g1g2.getApvGain(
it, rangeG2_old);
104 float G1G2_old = G1_old * G2_old;
105 float G1_new = g3.getApvGain(
it, rangeG1_new);
109 float NewGain = G1G2_old / G1_new;
113 theMap[
index] = NewGain;
121 std::unique_ptr<SiStripApvGain> theAPVGains = this->
getNewObject(theMap);
129 throw std::runtime_error(
"PoolDBService required.");
134 const std::map<std::pair<uint32_t, int>,
float>& theMap) {
135 std::unique_ptr<SiStripApvGain>
obj = std::make_unique<SiStripApvGain>();
137 std::vector<float> theSiStripVector;
138 uint32_t PreviousDetId = 0;
139 unsigned int countDetIds(0);
140 for (
const auto& element : theMap) {
141 uint32_t
DetId = element.first.first;
142 if (
DetId != PreviousDetId) {
143 if (!theSiStripVector.empty()) {
145 if (!
obj->put(PreviousDetId,
range))
146 edm::LogError(
"SiStripApvGainRescaler") <<
"Bug to put detId = " << PreviousDetId <<
"\n";
148 theSiStripVector.clear();
149 PreviousDetId =
DetId;
152 theSiStripVector.push_back(element.second);
156 << __FUNCTION__ <<
" DetId: " <<
DetId <<
" APV: " << element.first.second <<
" Gain: " << element.second;
160 if (!theSiStripVector.empty()) {
162 if (!
obj->put(PreviousDetId,
range))
163 edm::LogError(
"SiStripApvGainRescaler") <<
"Bug to put detId = " << PreviousDetId <<
"\n";
174 " Utility class to rescale the values of SiStrip G2 by the ratio of G1_old/G1_new: this is useful in the case in " 175 "which a Gain2 payload needs to recycled after a G1 update to keep the G1*G2 product constant." 176 "PoolDBOutputService must be set up for 'SiStripApvGainRcd'.");
179 desc.addUntracked<
unsigned int>(
"printDebug", 1);
180 descriptions.
add(
"rescaleGain2byGain1",
desc);
std::unique_ptr< SiStripApvGain > getNewObject(const std::map< std::pair< uint32_t, int >, float > &theMap)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
SiStripApvGainRescaler(const edm::ParameterSet &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const std::string m_Record
const uint32_t m_printdebug
void analyze(const edm::Event &, const edm::EventSetup &) override
T getUntrackedParameter(std::string const &, T const &) const
cond::Time_t currentTime() const
std::pair< ContainerIterator, ContainerIterator > Range
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
#define DEFINE_FWK_MODULE(type)
Log< level::Info, false > LogInfo
~SiStripApvGainRescaler() override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const edm::ESGetToken< SiStripApvGain, SiStripApvGain3Rcd > g3Token_
const edm::ESGetToken< SiStripGain, SiStripGainRcd > g1g2Token_