66 "create a SiStripBadStrip payload starting from one in DB and excluding or adding entire modules from a list");
67 desc.add<
std::string>(
"Record",
"SiStripBadStrip")->setComment(
"Record to match in the PoolDBOutputService");
68 desc.add<
bool>(
"printDebug",
false)->setComment(
"full debug printout");
69 desc.add<std::vector<unsigned int>>(
"detIdsToExclude", {})->setComment(
"list of detIds to exclude");
70 desc.add<std::vector<unsigned int>>(
"detIdsToInclude", {})->setComment(
"list of detIds to include");
71 desc.add<std::vector<unsigned int>>(
"FEDsToExclude", {})->setComment(
"list of FEDs to exclude");
72 desc.add<std::vector<unsigned int>>(
"FEDsToInclude", {})->setComment(
"list of FEDs to include");
82 <<
" DetId " <<
detid <<
" appears to be uncabled, returning NOT_A_FEDID !";
86 for (uint32_t ch = 0; ch < conns.size(); ch++) {
87 if (conns[ch] && conns[ch]->isConnected()) {
88 lFedId = conns[ch]->fedId();
89 LogDebug(
"SiStripBadChannelPatcher") <<
"obtained FED id " << ch <<
" " << lFedId;
91 edm::LogWarning(
"SiStripBadChannelPatcher") << lFedId <<
" for detid " <<
detid <<
" connection " << ch;
103 for (
const auto&
detid : allDetIds) {
116 std::unique_ptr<SiStripBadStrip> theBadStrips = this->
getNewObject(iSetup);
124 throw std::runtime_error(
"PoolDBService required.");
130 edm::LogInfo(
"SiStripBadChannelPatcher") <<
"... creating dummy SiStripBadStrip Data";
133 auto obj = std::make_unique<SiStripBadStrip>();
139 std::vector<uint32_t> detids;
144 for (
const auto&
id : detids) {
147 edm::LogInfo(
"SiStripBadChannelPatcher") <<
"I AM GOING TO EXCLUDE DETID: " <<
id;
150 LogDebug(
"SiStripBadChannelPatcher") <<
"I AM GOING TO KEEP DETID: " <<
id;
156 edm::LogInfo(
"SiStripBadChannelPatcher") <<
"I AM GOING TO EXCLUDE DETID: " <<
id;
159 LogDebug(
"SiStripBadChannelPatcher") <<
"I AM GOING TO KEEP DETID: " <<
id;
163 std::vector<unsigned int> theSiStripVector;
164 unsigned int theBadStripRange;
165 for (std::vector<unsigned int>::const_iterator badStrip =
range.first; badStrip !=
range.second; ++badStrip) {
166 unsigned short firstBadStrip =
payload.decode(*badStrip).firstStrip;
167 unsigned short nConsecutiveBadStrips =
payload.decode(*badStrip).range;
168 theBadStripRange =
obj->encode(firstBadStrip, nConsecutiveBadStrips);
169 theSiStripVector.push_back(theBadStripRange);
172 if (!
obj->put(
id, outRange))
173 edm::LogError(
"SiStripBadChannelPatcher") <<
"[SiStripBadChannelPatcher::analyze] detid already exists";
176 const auto& detInfo =
180 const std::vector<uint32_t>& allDetIds = detInfo.
getAllDetIds();
185 edm::LogInfo(
"SiStripBadChannelPatcher") <<
"I AM GOING TO ADD MORE DETIDS";
187 std::stringstream
ss;
189 edm::LogInfo(
"SiStripBadChannelPatcher") <<
"I AM GOING TO ADD DETID: " <<
detid;
190 const auto& nAPVs = detInfo.getNumberOfApvsAndStripLength(
detid).first;
192 std::vector<unsigned int> theSiStripVector;
193 unsigned short firstBadStrip{0}, nConsecutiveBadStrips{0};
194 unsigned int theBadStripRange;
196 for (
unsigned int n = 0;
n < nAPVs;
n++) {
199 theBadStripRange =
obj->encode(firstBadStrip, nConsecutiveBadStrips);
202 ss <<
"detid " <<
detid <<
" \t" 203 <<
" firstBadStrip " << firstBadStrip <<
"\t " 204 <<
" nConsecutiveBadStrips " << nConsecutiveBadStrips <<
"\t " 205 <<
" packed integer " << std::hex << theBadStripRange <<
std::dec << std::endl;
208 theSiStripVector.push_back(theBadStripRange);
213 edm::LogError(
"SiStripBadChannelPatcher") <<
"[SiStripBadChannelPatcher::analyze] detid already exists";
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
void addDetIdsFromExcludedFEDs(const std::vector< uint32_t > &allDetIds)
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
const edm::ESGetToken< SiStripBadStrip, SiStripBadStripRcd > badStripToken_
unsigned int fedFromDetId(const uint32_t &detid)
std::vector< unsigned int > fedsToExclude_
cond::Time_t currentTime() const
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
#define DEFINE_FWK_MODULE(type)
SiStripDetInfo read(std::string filePath)
Log< level::Info, false > LogInfo
~SiStripBadChannelPatcher() override=default
Constants and enumerated types for FED/FEC systems.
static const uint16_t NOT_A_FEDID
std::vector< uint32_t > detIdsToExclude_
SiStripBadChannelPatcher(const edm::ParameterSet &iConfig)
std::unique_ptr< SiStripBadStrip > getNewObject(const edm::EventSetup &iSetup)
static const uint16_t STRIPS_PER_APV
std::pair< ContainerIterator, ContainerIterator > Range
const std::string record_
static constexpr char const *const kDefaultFile
static const uint16_t FED_ID_MAX
Log< level::Warning, false > LogWarning
std::vector< unsigned int > fedsToInclude_
std::vector< uint32_t > detIdsToInclude_
const std::vector< uint32_t > & getAllDetIds() const noexcept
const edm::ESGetToken< SiStripDetCabling, SiStripDetCablingRcd > cablingToken_
void analyze(const edm::Event &, const edm::EventSetup &) override
const SiStripDetCabling * detCabling_