116 edm::LogInfo(
"SiPhase2BadStripChannelBuilder") <<
"... creating dummy SiStripBadStrip Data";
118 auto obj = std::make_unique<SiStripBadStrip>();
126 uint32_t
rawId = pixdet->geographicalId().rawId();
127 int subid = pixdet->geographicalId().subdetId();
131 const int nrows = topol.
nrows();
132 const int ncols = topol.ncolumns();
134 LogDebug(
"SiPhase2BadStripChannelBuilder")
135 <<
"DetId: " <<
rawId <<
" subdet: " << subid <<
" nrows: " << nrows <<
" ncols: " <<
ncols;
137 std::vector<unsigned int> theSiStripVector;
141 LogDebug(
"SiPhase2BadStripChannelBuilder") <<
"using the NAIVE algorithm";
143 auto dis1 = std::uniform_int_distribution<>(0, nrows - 1);
144 auto dis2 = std::uniform_int_distribution<>(1, 10);
146 unsigned short firstBadStrip = std::floor(dis1(
engine_));
147 unsigned short NconsecutiveBadStrips = std::floor(dis2(
engine_));
150 if (firstBadStrip + NconsecutiveBadStrips > nrows) {
151 NconsecutiveBadStrips = nrows - firstBadStrip;
154 unsigned int theBadStripRange;
155 theBadStripRange =
obj->encodePhase2(firstBadStrip, NconsecutiveBadStrips);
159 <<
"detid " <<
rawId <<
" \t" 160 <<
" firstBadStrip " << firstBadStrip <<
"\t " 161 <<
" NconsecutiveBadStrips " << NconsecutiveBadStrips <<
"\t " 162 <<
" packed integer " << std::hex << theBadStripRange <<
std::dec;
164 theSiStripVector.push_back(theBadStripRange);
168 LogDebug(
"SiPhase2BadStripChannelBuilder") <<
"using the RANDOM algorithm";
171 std::vector<Phase2TrackerDigi::PackedDigiType> usedChannels;
175 LogDebug(
"SiPhase2BadStripChannelBuilder")
176 << __FUNCTION__ <<
" " << __LINE__ <<
" will mask: " << nmaxBadStrips <<
" strips";
178 auto disRows = std::uniform_int_distribution<>(0, nrows - 1);
179 auto disCols = std::uniform_int_distribution<>(0,
ncols - 1);
181 while (usedChannels.size() < nmaxBadStrips) {
182 unsigned short badStripRow = std::floor(disRows(
engine_));
183 unsigned short badStripCol = std::floor(disCols(
engine_));
187 LogDebug(
"SiPhase2BadStripChannelBuilder") << __FUNCTION__ <<
" " << __LINE__ <<
": masking channel " 188 << badChannel <<
" (" << badStripRow <<
"," << badStripCol <<
")";
190 if (
std::find(usedChannels.begin(), usedChannels.end(), badChannel) == usedChannels.end()) {
191 usedChannels.push_back(badChannel);
197 for (
const auto& [
first, consec] : badChannelsGroups) {
198 unsigned int theBadChannelsRange;
199 theBadChannelsRange =
obj->encodePhase2(
first, consec);
203 <<
"detid " <<
rawId <<
" \t" 204 <<
" firstBadStrip " <<
first <<
"\t " 205 <<
" NconsecutiveBadStrips " << consec <<
"\t " 206 <<
" packed integer " << std::hex << theBadChannelsRange <<
std::dec;
208 theSiStripVector.push_back(theBadChannelsRange);
215 throw cms::Exception(
"Inconsistent configuration") <<
"Did not specifiy the right algorithm to be run";
221 <<
"[SiPhase2BadStripChannelBuilder::getNewObject] detid already exists";
235 edm::LogError(
"SiPhase2BadStripChannelBuilder") <<
"Service is unavailable";
cond::Time_t beginOfTime() const
virtual int nrows() const =0
Log< level::Error, false > LogError
std::vector< const Phase2TrackerGeomDetUnit * > theOTDets
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
void appendOneIOV(const T &payload, cond::Time_t sinceTime, const std::string &recordName)
bool isNewTagRequest(const std::string &recordName)
cond::Time_t currentTime() const
static PackedDigiType pixelToChannel(unsigned int row, unsigned int col)
Log< level::Info, false > LogInfo
std::map< unsigned short, unsigned short > clusterizeBadChannels(const std::vector< Phase2TrackerDigi::PackedDigiType > &maskedChannels)
std::pair< ContainerIterator, ContainerIterator > Range
const float badComponentsFraction_
badChannelAlgo theBCAlgo_