57 std::unique_ptr<SiStripApvGain>
getNewObject(
const std::map<std::pair<uint32_t,int>,
float>& theMap);
58 virtual void endJob()
override;
100 std::map<std::pair<uint32_t,int>,
float> theMap;
102 std::vector<uint32_t> detid;
104 for (
const auto &
d : detid) {
111 for(
int it=0;it<rangeG1_old.second-rangeG1_old.first;it++){
114 std::pair<uint32_t,int>
index = std::make_pair(
d,nAPV);
116 float G1_old = g1g2Handle_->
getApvGain(it,rangeG1_old);
117 float G2_old = g1g2Handle_->
getApvGain(it,rangeG2_old);
118 float G1G2_old = G1_old*G2_old;
119 float G1_new = g3Handle_->
getApvGain(it,rangeG1_new);
123 float NewGain = G1G2_old/G1_new;
127 theMap[
index]=NewGain;
135 std::unique_ptr<SiStripApvGain> theAPVGains = this->
getNewObject(theMap);
143 throw std::runtime_error(
"PoolDBService required.");
161 std::unique_ptr<SiStripApvGain>
164 std::unique_ptr<SiStripApvGain>
obj = std::unique_ptr<SiStripApvGain>(
new SiStripApvGain());
166 std::vector<float> theSiStripVector;
167 uint32_t PreviousDetId = 0;
168 for(
const auto &element : theMap){
169 uint32_t
DetId = element.first.first;
170 if(DetId != PreviousDetId){
171 if(!theSiStripVector.empty()){
173 if ( !obj->put(PreviousDetId,range) ) printf(
"Bug to put detId = %i\n",PreviousDetId);
175 theSiStripVector.clear();
176 PreviousDetId = DetId;
178 theSiStripVector.push_back(element.second);
180 edm::LogInfo(
"SiStripApvGainRescaler")<<
" DetId: "<<DetId
181 <<
" APV: "<<element.first.second
182 <<
" Gain: "<<element.second
186 if(!theSiStripVector.empty()){
188 if ( !obj->put(PreviousDetId,range) ) printf(
"Bug to put detId = %i\n",PreviousDetId);
200 desc.
setComment(
" Utility class to rescale the values of SiStrip G2 by the ratio of G1_old/G1_new: this is useful in the case in which a Gain2 payload needs to recycled after a G1 update to keep the G1*G2 product constant." 201 "PoolDBOutputService must be set up for 'SiStripApvGainRcd'.");
204 descriptions.
add(
"rescaleGain2byGain1", desc);
virtual void endJob() override
std::unique_ptr< SiStripApvGain > getNewObject(const std::map< std::pair< uint32_t, int >, float > &theMap)
virtual void beginJob() override
static float getApvGain(uint16_t apv, const Range &range)
SiStripApvGainRescaler(const edm::ParameterSet &)
~SiStripApvGainRescaler()
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const std::string m_Record
static float getApvGain(const uint16_t &apv, const SiStripApvGain::Range &range)
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
void setComment(std::string const &value)
#define DEFINE_FWK_MODULE(type)
std::pair< ContainerIterator, ContainerIterator > Range
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void getDetIds(std::vector< uint32_t > &DetIds_) const
ATTENTION: we assume the detIds are the same as those from the first gain.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
cond::Time_t currentTime() const
const Range getRange(const uint32_t detID) const
const SiStripApvGain::Range getRange(uint32_t detID) const