76 m_record(iConfig.getParameter<
std::
string>(
"record")),
77 printdebug_(iConfig.getUntrackedParameter<
bool>(
"printDebug",
false)),
78 isMC_(iConfig.getUntrackedParameter<
bool>(
"isMC",
true)),
79 removeEmptyPayloads_(iConfig.getUntrackedParameter<
bool>(
"removeEmptyPayloads",
false)) {
81 myQualities = std::make_unique<SiPixelFEDChannelContainer>();
94 unsigned int RunNumber_ =
iEvent.eventAuxiliary().run();
95 unsigned int LuminosityBlockNumber_ =
iEvent.eventAuxiliary().luminosityBlock();
106 edm::LogInfo(
"SiPixelFEDChannelContainerFromQualityConverter")
107 <<
"Found IOV:" << RunNumber_ <<
"(" << LuminosityBlockNumber_ <<
")" << std::endl;
109 auto theSiPixelFEDChannelCollection =
130 for (
const auto&
mod : theDisabledModules) {
133 int coded_badRocs =
mod.BadRocs;
134 std::vector<PixelFEDChannel> disabledChannelsDetSet;
135 std::vector<sipixelobjects::CablingPathToDetUnit>
path = theFedCabling.
pathToDetUnit(
mod.DetID);
137 unsigned int nrocs_inLink(0);
143 throw cms::Exception(
"Inconsistent data") <<
"could not find CablingPathToDetUnit for detId:" <<
mod.DetID;
146 std::bitset<16> bad_rocs(coded_badRocs);
147 unsigned int n_ch = bad_rocs.size() / nrocs_inLink;
149 for (
unsigned int i_roc = 0; i_roc < n_ch; ++i_roc) {
150 unsigned int first_idx = nrocs_inLink * i_roc;
151 unsigned int sec_idx = nrocs_inLink * (i_roc + 1) - 1;
152 unsigned int mask =
pow(2, nrocs_inLink) - 1;
153 unsigned int n_setbits = (coded_badRocs >> (i_roc * nrocs_inLink)) &
mask;
155 if (n_setbits == 0) {
159 if (n_setbits !=
mask) {
161 <<
"Mismatch! DetId: " <<
mod.DetID <<
" " << n_setbits <<
" " <<
mask << std::endl;
166 edm::LogVerbatim(
"SiPixelFEDChannelContainerFromQualityConverter") <<
"passed" << std::endl;
169 unsigned int link_id = 99999;
170 unsigned int fed_id = 99999;
172 for (
auto const&
p :
path) {
176 unsigned int first_roc =
roc->idInDetUnit();
178 if (first_roc == first_idx) {
187 <<
" " << fed_id <<
" " << link_id <<
" " << first_idx <<
" " << sec_idx << std::endl;
191 disabledChannelsDetSet.push_back(ch);
195 << i_roc <<
" " << coded_badRocs <<
" " << first_idx <<
" " << sec_idx << std::endl;
197 <<
"=======================================" << std::endl;
201 if (!disabledChannelsDetSet.empty()) {
202 theBadChannelCollection[
mod.DetID] = disabledChannelsDetSet;
205 return theBadChannelCollection;
212 edm::LogInfo(
"SiPixelFEDChannelContainerFromQualityConverter") <<
"Analyzed " <<
IOVcount_ <<
" IOVs" << std::endl;
213 edm::LogInfo(
"SiPixelFEDChannelContainerFromQualityConverter")
214 <<
"Size of SiPixelFEDChannelContainer object " <<
myQualities->size() << std::endl
218 edm::LogInfo(
"SiPixelFEDChannelContainerFromQualityConverter")
219 <<
"Content of SiPixelFEDChannelContainer " << std::endl;
242 desc.setComment(
"Writes payloads of type SiPixelFEDChannelContainer");
243 desc.addUntracked<
bool>(
"printDebug",
false);
244 desc.addUntracked<
bool>(
"removeEmptyPayloads",
false);
246 descriptions.
add(
"SiPixelFEDChannelContainerFromQualityConverter",
desc);
Log< level::Info, true > LogVerbatim
const PixelFEDLink * link(unsigned int id) const
return link identified by id. Link id's are ranged [1, numberOfLinks]
std::unique_ptr< SiPixelFedCablingTree > cablingTree() const
~SiPixelFEDChannelContainerFromQualityConverter() override
SiPixelFEDChannelContainerFromQualityConverter(const edm::ParameterSet &)
const bool removeEmptyPayloads_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
unsigned int numberOfROCs() const
number of ROCs in fed
edm::ESWatcher< SiPixelQualityFromDbRcd > SiPixelQualityWatcher_
std::vector< sipixelobjects::CablingPathToDetUnit > pathToDetUnit(uint32_t rawDetId) const final
static std::string to_string(const XMLCh *ch)
T const * product() const
const std::vector< disabledModuleType > getBadComponentList() const
unsigned long long Time_t
cond::Time_t currentTime() const
const std::string m_record
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
#define DEFINE_FWK_MODULE(type)
void analyze(const edm::Event &, const edm::EventSetup &) override
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
const edm::ESGetToken< SiPixelQuality, SiPixelQualityFromDbRcd > siPixelQualityToken_
Log< level::Info, false > LogInfo
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::unique_ptr< SiPixelFEDChannelContainer > myQualities
bool check(const edm::EventSetup &iSetup)
const edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcd > siPixelCablingToken_
SiPixelFEDChannelContainer::SiPixelFEDChannelCollection createFromSiPixelQuality(const SiPixelQuality &theQuality, const SiPixelFedCablingMap &theFedCabling)
const PixelROC * roc(unsigned int id) const
return ROC identified by id. ROC ids are ranged [1,numberOfROCs]
std::unordered_map< uint32_t, unsigned int > det2fedMap() const final
Log< level::Warning, false > LogWarning
T mod(const T &a, const T &b)
Power< A, B >::type pow(const A &a, const B &b)
std::map< DetId, std::vector< PixelFEDChannel > > SiPixelFEDChannelCollection