CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SiPixelFEDChannelContainerFromQualityConverter Class Reference

#include <CondFormats/SiPixelObjects/plugins/SiPixelFEDChannelContainerFromQualityConverter.cc>

Inheritance diagram for SiPixelFEDChannelContainerFromQualityConverter:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

SiPixelFEDChannelContainer::SiPixelFEDChannelCollection createFromSiPixelQuality (const SiPixelQuality &theQuality, const SiPixelFedCablingMap &theFedCabling)
 
 SiPixelFEDChannelContainerFromQualityConverter (const edm::ParameterSet &)
 
 ~SiPixelFEDChannelContainerFromQualityConverter () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 

Private Attributes

int IOVcount_
 
const bool isMC_
 
const std::string m_record
 
std::unique_ptr< SiPixelFEDChannelContainermyQualities
 
const bool printdebug_
 
const bool removeEmptyPayloads_
 
const edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcdsiPixelCablingToken_
 
const edm::ESGetToken< SiPixelQuality, SiPixelQualityFromDbRcdsiPixelQualityToken_
 
edm::ESWatcher< SiPixelQualityFromDbRcdSiPixelQualityWatcher_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: class to build the SiPixelFEDChannelContainer payloads

Definition at line 41 of file SiPixelFEDChannelContainerFromQualityConverter.cc.

Constructor & Destructor Documentation

◆ SiPixelFEDChannelContainerFromQualityConverter()

SiPixelFEDChannelContainerFromQualityConverter::SiPixelFEDChannelContainerFromQualityConverter ( const edm::ParameterSet iConfig)
explicit

Definition at line 72 of file SiPixelFEDChannelContainerFromQualityConverter.cc.

References myQualities.

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)) {
80  //now do what ever initialization is needed
81  myQualities = std::make_unique<SiPixelFEDChannelContainer>();
82 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
T getUntrackedParameter(std::string const &, T const &) const
const edm::ESGetToken< SiPixelQuality, SiPixelQualityFromDbRcd > siPixelQualityToken_
const edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcd > siPixelCablingToken_

◆ ~SiPixelFEDChannelContainerFromQualityConverter()

SiPixelFEDChannelContainerFromQualityConverter::~SiPixelFEDChannelContainerFromQualityConverter ( )
overridedefault

Member Function Documentation

◆ analyze()

void SiPixelFEDChannelContainerFromQualityConverter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 91 of file SiPixelFEDChannelContainerFromQualityConverter.cc.

References edm::ESWatcher< T >::check(), createFromSiPixelQuality(), edm::EventSetup::getHandle(), iEvent, IOVcount_, myQualities, edm::ESHandle< T >::product(), removeEmptyPayloads_, siPixelCablingToken_, siPixelQualityToken_, SiPixelQualityWatcher_, AlCaHLTBitMon_QueryRunRegistry::string, and to_string().

91  {
92  using namespace edm;
93 
94  unsigned int RunNumber_ = iEvent.eventAuxiliary().run();
95  unsigned int LuminosityBlockNumber_ = iEvent.eventAuxiliary().luminosityBlock();
96 
97  bool hasQualityIOV = SiPixelQualityWatcher_.check(iSetup);
98 
99  if (hasQualityIOV) {
100  //Retrieve the strip quality from conditions
103 
104  std::string scenario = std::to_string(RunNumber_) + "_" + std::to_string(LuminosityBlockNumber_);
105 
106  edm::LogInfo("SiPixelFEDChannelContainerFromQualityConverter")
107  << "Found IOV:" << RunNumber_ << "(" << LuminosityBlockNumber_ << ")" << std::endl;
108 
109  auto theSiPixelFEDChannelCollection =
110  this->createFromSiPixelQuality(*(siPixelQuality_.product()), *(cablingMapHandle.product()));
111 
112  if (removeEmptyPayloads_ && theSiPixelFEDChannelCollection.empty())
113  return;
114 
115  myQualities->setScenario(scenario, theSiPixelFEDChannelCollection);
116 
117  IOVcount_++;
118  }
119 }
scenario
Definition: constants.h:219
static std::string to_string(const XMLCh *ch)
int iEvent
Definition: GenABIO.cc:224
T const * product() const
Definition: ESHandle.h:86
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
const edm::ESGetToken< SiPixelQuality, SiPixelQualityFromDbRcd > siPixelQualityToken_
Log< level::Info, false > LogInfo
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
const edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcd > siPixelCablingToken_
HLT enums.
SiPixelFEDChannelContainer::SiPixelFEDChannelCollection createFromSiPixelQuality(const SiPixelQuality &theQuality, const SiPixelFedCablingMap &theFedCabling)

◆ beginJob()

void SiPixelFEDChannelContainerFromQualityConverter::beginJob ( )
overrideprivatevirtual

◆ createFromSiPixelQuality()

SiPixelFEDChannelContainer::SiPixelFEDChannelCollection SiPixelFEDChannelContainerFromQualityConverter::createFromSiPixelQuality ( const SiPixelQuality theQuality,
const SiPixelFedCablingMap theFedCabling 
)

Definition at line 123 of file SiPixelFEDChannelContainerFromQualityConverter.cc.

References SiPixelFedCablingMap::cablingTree(), SiPixelFedCablingMap::det2fedMap(), Exception, SiPixelQuality::getBadComponentList(), sipixelobjects::PixelFEDCabling::link(), ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, mod(), sipixelobjects::PixelFEDLink::numberOfROCs(), AlCaHLTBitMon_ParallelJobs::p, EnsembleCalibrationLA_cfg::path, SiPixelFedCablingMap::pathToDetUnit(), funct::pow(), printdebug_, sipixelobjects::PixelFEDLink::roc(), and PixelMapPlotter::roc.

Referenced by analyze().

124  {
125  auto fedid_ = theFedCabling.det2fedMap();
126 
128 
129  auto theDisabledModules = theQuality.getBadComponentList();
130  for (const auto& mod : theDisabledModules) {
131  //mod.DetID, mod.errorType,mod.BadRocs
132 
133  int coded_badRocs = mod.BadRocs;
134  std::vector<PixelFEDChannel> disabledChannelsDetSet;
135  std::vector<sipixelobjects::CablingPathToDetUnit> path = theFedCabling.pathToDetUnit(mod.DetID);
136  auto cabling_ = theFedCabling.cablingTree();
137  unsigned int nrocs_inLink(0);
138  if (!path.empty()) {
139  const sipixelobjects::PixelFEDCabling* aFed = cabling_->fed(path.at(0).fed);
140  const sipixelobjects::PixelFEDLink* link = aFed->link(path.at(0).link);
141  nrocs_inLink = link->numberOfROCs();
142  } else {
143  throw cms::Exception("Inconsistent data") << "could not find CablingPathToDetUnit for detId:" << mod.DetID;
144  }
145 
146  std::bitset<16> bad_rocs(coded_badRocs);
147  unsigned int n_ch = bad_rocs.size() / nrocs_inLink;
148 
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;
154 
155  if (n_setbits == 0) {
156  continue;
157  }
158 
159  if (n_setbits != mask) {
160  edm::LogWarning("SiPixelFEDChannelContainerFromQualityConverter")
161  << "Mismatch! DetId: " << mod.DetID << " " << n_setbits << " " << mask << std::endl;
162  continue;
163  }
164 
165  if (printdebug_) {
166  edm::LogVerbatim("SiPixelFEDChannelContainerFromQualityConverter") << "passed" << std::endl;
167  }
168 
169  unsigned int link_id = 99999;
170  unsigned int fed_id = 99999;
171 
172  for (auto const& p : path) {
173  const sipixelobjects::PixelFEDCabling* aFed = cabling_->fed(p.fed);
174  const sipixelobjects::PixelFEDLink* link = aFed->link(p.link);
175  const sipixelobjects::PixelROC* roc = link->roc(p.roc);
176  unsigned int first_roc = roc->idInDetUnit();
177 
178  if (first_roc == first_idx) {
179  link_id = p.link;
180  fed_id = p.fed;
181  break;
182  }
183  }
184 
185  if (printdebug_) {
186  edm::LogVerbatim("SiPixelFEDChannelContainerFromQualityConverter")
187  << " " << fed_id << " " << link_id << " " << first_idx << " " << sec_idx << std::endl;
188  }
189 
190  PixelFEDChannel ch = {fed_id, link_id, first_idx, sec_idx};
191  disabledChannelsDetSet.push_back(ch);
192 
193  if (printdebug_) {
194  edm::LogVerbatim("SiPixelFEDChannelContainerFromQualityConverter")
195  << i_roc << " " << coded_badRocs << " " << first_idx << " " << sec_idx << std::endl;
196  edm::LogVerbatim("SiPixelFEDChannelContainerFromQualityConverter")
197  << "=======================================" << std::endl;
198  }
199  }
200 
201  if (!disabledChannelsDetSet.empty()) {
202  theBadChannelCollection[mod.DetID] = disabledChannelsDetSet;
203  }
204  }
205  return theBadChannelCollection;
206 }
Log< level::Info, true > LogVerbatim
const PixelFEDLink * link(unsigned int id) const
return link identified by id. Link id&#39;s are ranged [1, numberOfLinks]
std::unique_ptr< SiPixelFedCablingTree > cablingTree() const
std::vector< sipixelobjects::CablingPathToDetUnit > pathToDetUnit(uint32_t rawDetId) const final
const std::vector< disabledModuleType > getBadComponentList() const
std::unordered_map< uint32_t, unsigned int > det2fedMap() const final
Log< level::Warning, false > LogWarning
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
std::map< DetId, std::vector< PixelFEDChannel > > SiPixelFEDChannelCollection

◆ endJob()

void SiPixelFEDChannelContainerFromQualityConverter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 211 of file SiPixelFEDChannelContainerFromQualityConverter.cc.

References cond::service::PoolDBOutputService::currentTime(), IOVcount_, edm::Service< T >::isAvailable(), isMC_, m_record, myQualities, printdebug_, and cond::service::PoolDBOutputService::writeOneIOV().

211  {
212  edm::LogInfo("SiPixelFEDChannelContainerFromQualityConverter") << "Analyzed " << IOVcount_ << " IOVs" << std::endl;
213  edm::LogInfo("SiPixelFEDChannelContainerFromQualityConverter")
214  << "Size of SiPixelFEDChannelContainer object " << myQualities->size() << std::endl
215  << std::endl;
216 
217  if (printdebug_) {
218  edm::LogInfo("SiPixelFEDChannelContainerFromQualityConverter")
219  << "Content of SiPixelFEDChannelContainer " << std::endl;
220 
221  // use built-in method in the CondFormat
222  myQualities->printAll();
223  }
224 
225  // Form the data here
227  if (poolDbService.isAvailable()) {
228  cond::Time_t valid_time = poolDbService->currentTime();
229  // this writes the payload to begin in current run defined in cfg
230  if (!isMC_) {
231  poolDbService->writeOneIOV(*myQualities, valid_time, m_record);
232  } else {
233  // for MC IOV since=1
234  poolDbService->writeOneIOV(*myQualities, 1, m_record);
235  }
236  }
237 }
unsigned long long Time_t
Definition: Time.h:14
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
Log< level::Info, false > LogInfo
bool isAvailable() const
Definition: Service.h:40

◆ fillDescriptions()

void SiPixelFEDChannelContainerFromQualityConverter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 240 of file SiPixelFEDChannelContainerFromQualityConverter.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

240  {
242  desc.setComment("Writes payloads of type SiPixelFEDChannelContainer");
243  desc.addUntracked<bool>("printDebug", false);
244  desc.addUntracked<bool>("removeEmptyPayloads", false);
245  desc.add<std::string>("record", "SiPixelStatusScenariosRcd");
246  descriptions.add("SiPixelFEDChannelContainerFromQualityConverter", desc);
247 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ IOVcount_

int SiPixelFEDChannelContainerFromQualityConverter::IOVcount_
private

Definition at line 65 of file SiPixelFEDChannelContainerFromQualityConverter.cc.

Referenced by analyze(), beginJob(), and endJob().

◆ isMC_

const bool SiPixelFEDChannelContainerFromQualityConverter::isMC_
private

Definition at line 61 of file SiPixelFEDChannelContainerFromQualityConverter.cc.

Referenced by endJob().

◆ m_record

const std::string SiPixelFEDChannelContainerFromQualityConverter::m_record
private

Definition at line 59 of file SiPixelFEDChannelContainerFromQualityConverter.cc.

Referenced by endJob().

◆ myQualities

std::unique_ptr<SiPixelFEDChannelContainer> SiPixelFEDChannelContainerFromQualityConverter::myQualities
private

◆ printdebug_

const bool SiPixelFEDChannelContainerFromQualityConverter::printdebug_
private

◆ removeEmptyPayloads_

const bool SiPixelFEDChannelContainerFromQualityConverter::removeEmptyPayloads_
private

Definition at line 62 of file SiPixelFEDChannelContainerFromQualityConverter.cc.

Referenced by analyze().

◆ siPixelCablingToken_

const edm::ESGetToken<SiPixelFedCablingMap, SiPixelFedCablingMapRcd> SiPixelFEDChannelContainerFromQualityConverter::siPixelCablingToken_
private

Definition at line 57 of file SiPixelFEDChannelContainerFromQualityConverter.cc.

Referenced by analyze().

◆ siPixelQualityToken_

const edm::ESGetToken<SiPixelQuality, SiPixelQualityFromDbRcd> SiPixelFEDChannelContainerFromQualityConverter::siPixelQualityToken_
private

Definition at line 56 of file SiPixelFEDChannelContainerFromQualityConverter.cc.

Referenced by analyze().

◆ SiPixelQualityWatcher_

edm::ESWatcher<SiPixelQualityFromDbRcd> SiPixelFEDChannelContainerFromQualityConverter::SiPixelQualityWatcher_
private

Definition at line 66 of file SiPixelFEDChannelContainerFromQualityConverter.cc.

Referenced by analyze().