55 std::unique_ptr<SiStripApvGain>
getNewObject(
const std::map<std::pair<uint32_t, int>,
float>& theMap);
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);
126 if (poolDbService.isAvailable())
129 throw std::runtime_error(
"PoolDBService required.");
140 const std::map<std::pair<uint32_t, int>,
float>& theMap) {
141 std::unique_ptr<SiStripApvGain>
obj = std::make_unique<SiStripApvGain>();
143 std::vector<float> theSiStripVector;
144 uint32_t PreviousDetId = 0;
145 for (
const auto& element : theMap) {
146 uint32_t
DetId = element.first.first;
147 if (DetId != PreviousDetId) {
148 if (!theSiStripVector.empty()) {
150 if (!obj->put(PreviousDetId,
range))
151 printf(
"Bug to put detId = %i\n", PreviousDetId);
153 theSiStripVector.clear();
154 PreviousDetId = DetId;
156 theSiStripVector.push_back(element.second);
159 <<
" DetId: " << DetId <<
" APV: " << element.first.second <<
" Gain: " << element.second << std::endl;
162 if (!theSiStripVector.empty()) {
164 if (!obj->put(PreviousDetId,
range))
165 printf(
"Bug to put detId = %i\n", PreviousDetId);
176 " Utility class to rescale the values of SiStrip G2 by the ratio of G1_old/G1_new: this is useful in the case in "
177 "which a Gain2 payload needs to recycled after a G1 update to keep the G1*G2 product constant."
178 "PoolDBOutputService must be set up for 'SiStripApvGainRcd'.");
181 descriptions.
add(
"rescaleGain2byGain1", desc);
std::unique_ptr< SiStripApvGain > getNewObject(const std::map< std::pair< uint32_t, int >, float > &theMap)
#define DEFINE_FWK_MODULE(type)
SiStripApvGainRescaler(const edm::ParameterSet &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const std::string m_Record
const uint16_t range(const Frame &aFrame)
void analyze(const edm::Event &, const edm::EventSetup &) override
bool getData(T &iHolder) const
void setComment(std::string const &value)
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
std::pair< ContainerIterator, ContainerIterator > Range
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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_