25 #include "CLHEP/Random/RandGauss.h" 58 std::unique_ptr<SiStripApvGain>
getNewObject(
const std::map<std::pair<uint32_t, int>,
float>& theMap);
75 m_excludedMods{iConfig.getUntrackedParameter<std::vector<unsigned int>>(
"excludedModules")},
76 m_Record{iConfig.getUntrackedParameter<
std::string>(
"record",
"SiStripApvGainRcd")},
77 m_gainType{iConfig.getUntrackedParameter<uint32_t>(
"gainType", 1)},
78 m_reverseSelect{iConfig.getUntrackedParameter<
bool>(
"reverseSelection",
false)} {
82 sort(m_excludedMods.begin(), m_excludedMods.end());
84 edm::LogInfo(
"ExcludedModules") <<
"Selected module list";
85 for (std::vector<unsigned int>::const_iterator
mod = m_excludedMods.begin();
mod != m_excludedMods.end();
mod++) {
102 std::map<std::pair<uint32_t, int>,
float> theMap, oldPayloadMap;
104 std::vector<uint32_t>
detid;
106 for (
const auto&
d :
detid) {
111 for (
int it = 0;
it < range_new.second - range_new.first;
it++) {
115 std::pair<uint32_t, int>
index = std::make_pair(
d, nAPV);
122 edm::LogInfo(
"ModuleFound") <<
" module " <<
mod <<
" found! Excluded... " << std::endl;
134 theMap[
index] = patchGain;
140 std::unique_ptr<SiStripApvGain> theAPVGains = this->
getNewObject(theMap);
148 throw std::runtime_error(
"PoolDBService required.");
153 const std::map<std::pair<uint32_t, int>,
float>& theMap) {
154 std::unique_ptr<SiStripApvGain>
obj = std::make_unique<SiStripApvGain>();
156 std::vector<float> theSiStripVector;
157 uint32_t PreviousDetId = 0;
158 for (
const auto& element : theMap) {
159 uint32_t
DetId = element.first.first;
160 if (
DetId != PreviousDetId) {
161 if (!theSiStripVector.empty()) {
163 if (!
obj->put(PreviousDetId,
range))
164 printf(
"Bug to put detId = %i\n", PreviousDetId);
166 theSiStripVector.clear();
167 PreviousDetId =
DetId;
169 theSiStripVector.push_back(element.second);
172 <<
" DetId: " <<
DetId <<
" APV: " << element.first.second <<
" Gain: " << element.second << std::endl;
175 if (!theSiStripVector.empty()) {
177 if (!
obj->put(PreviousDetId,
range))
178 printf(
"Bug to put detId = %i\n", PreviousDetId);
187 desc.addUntracked<std::vector<unsigned int>>(
"excludedModules", {});
189 desc.addUntracked<uint32_t>(
"gainType", 1);
190 desc.addUntracked<
bool>(
"reverseSelection",
false);
Log< level::Info, true > LogVerbatim
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
const uint32_t m_gainType
static float getApvGain(uint16_t apv, const Range &range)
~SiStripGainPayloadCopyAndExclude() override=default
const SiStripApvGain::Range getRange(uint32_t detID) const
static float getApvGain(const uint16_t &apv, const SiStripApvGain::Range &range)
void getDetIds(std::vector< uint32_t > &DetIds_) const
cond::Time_t currentTime() const
std::pair< ContainerIterator, ContainerIterator > Range
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
std::vector< unsigned int > m_excludedMods
#define DEFINE_FWK_MODULE(type)
const edm::ESGetToken< SiStripGain, SiStripGainRcd > m_gainToken
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Log< level::Info, false > LogInfo
const std::string m_Record
std::unique_ptr< SiStripApvGain > getNewObject(const std::map< std::pair< uint32_t, int >, float > &theMap)
SiStripGainPayloadCopyAndExclude(const edm::ParameterSet &)
static const std::string kSharedResource
const Range getRange(const uint32_t detID) const
void analyze(const edm::Event &, const edm::EventSetup &) override
const bool m_reverseSelect
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T mod(const T &a, const T &b)
const edm::ESGetToken< SiStripApvGain, SiStripApvGain3Rcd > m_gain3Token