CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SiStripBadChannelPatcher Class Reference
Inheritance diagram for SiStripBadChannelPatcher:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 SiStripBadChannelPatcher (const edm::ParameterSet &iConfig)
 
 ~SiStripBadChannelPatcher () override=default
 
- 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 final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const 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
 
bool wantsStreamRuns () const
 
 ~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 addDetIdsFromExcludedFEDs (const std::vector< uint32_t > &allDetIds)
 
void analyze (const edm::Event &, const edm::EventSetup &) override
 
unsigned int fedFromDetId (const uint32_t &detid)
 
std::unique_ptr< SiStripBadStripgetNewObject (const edm::EventSetup &iSetup)
 

Private Attributes

const edm::ESGetToken< SiStripBadStrip, SiStripBadStripRcdbadStripToken_
 
const edm::ESGetToken< SiStripDetCabling, SiStripDetCablingRcdcablingToken_
 
const SiStripDetCablingdetCabling_
 
std::vector< uint32_t > detIdsToExclude_
 
std::vector< uint32_t > detIdsToInclude_
 
std::vector< unsigned int > fedsToExclude_
 
std::vector< unsigned int > fedsToInclude_
 
const bool printDebug_
 
const std::string record_
 

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

Definition at line 29 of file SiStripBadChannelPatcher.cc.

Constructor & Destructor Documentation

◆ SiStripBadChannelPatcher()

SiStripBadChannelPatcher::SiStripBadChannelPatcher ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 31 of file SiStripBadChannelPatcher.cc.

32  : record_(iConfig.getParameter<std::string>("Record")),
33  printDebug_(iConfig.getParameter<bool>("printDebug")),
34  detIdsToExclude_(iConfig.getParameter<std::vector<unsigned int>>("detIdsToExclude")),
35  detIdsToInclude_(iConfig.getParameter<std::vector<unsigned int>>("detIdsToInclude")),
36  fedsToExclude_(iConfig.getParameter<std::vector<unsigned int>>("FEDsToExclude")),
37  fedsToInclude_(iConfig.getParameter<std::vector<unsigned int>>("FEDsToInclude")),
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::ESGetToken< SiStripBadStrip, SiStripBadStripRcd > badStripToken_
std::vector< unsigned int > fedsToExclude_
std::vector< uint32_t > detIdsToExclude_
std::vector< unsigned int > fedsToInclude_
std::vector< uint32_t > detIdsToInclude_
const edm::ESGetToken< SiStripDetCabling, SiStripDetCablingRcd > cablingToken_

◆ ~SiStripBadChannelPatcher()

SiStripBadChannelPatcher::~SiStripBadChannelPatcher ( )
overridedefault

Member Function Documentation

◆ addDetIdsFromExcludedFEDs()

void SiStripBadChannelPatcher::addDetIdsFromExcludedFEDs ( const std::vector< uint32_t > &  allDetIds)
private

Definition at line 102 of file SiStripBadChannelPatcher.cc.

References submitPVResolutionJobs::count, detIdsToInclude_, fedFromDetId(), and fedsToInclude_.

Referenced by getNewObject().

102  {
103  for (const auto& detid : allDetIds) {
104  const auto& currentFED = this->fedFromDetId(detid);
105  if (std::count(fedsToInclude_.begin(), fedsToInclude_.end(), currentFED)) {
106  detIdsToInclude_.push_back(detid);
107  }
108  }
109 }
unsigned int fedFromDetId(const uint32_t &detid)
std::vector< unsigned int > fedsToInclude_
std::vector< uint32_t > detIdsToInclude_

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 112 of file SiStripBadChannelPatcher.cc.

References cond::service::PoolDBOutputService::currentTime(), getNewObject(), edm::Service< T >::isAvailable(), record_, and cond::service::PoolDBOutputService::writeOneIOV().

112  {
113  using namespace edm;
114 
115  // create the patched bad strips payload
116  std::unique_ptr<SiStripBadStrip> theBadStrips = this->getNewObject(iSetup);
117 
118  // write out the BadStrip record
120 
121  if (poolDbService.isAvailable()) {
122  poolDbService->writeOneIOV(*theBadStrips, poolDbService->currentTime(), record_);
123  } else {
124  throw std::runtime_error("PoolDBService required.");
125  }
126 }
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
HLT enums.
std::unique_ptr< SiStripBadStrip > getNewObject(const edm::EventSetup &iSetup)
bool isAvailable() const
Definition: Service.h:40

◆ fedFromDetId()

unsigned int SiStripBadChannelPatcher::fedFromDetId ( const uint32_t &  detid)
private

Definition at line 77 of file SiStripBadChannelPatcher.cc.

References detCabling_, sistrip::FED_ID_MAX, SiStripDetCabling::getConnections(), LogDebug, and sistrip::NOT_A_FEDID.

Referenced by addDetIdsFromExcludedFEDs(), and getNewObject().

77  {
78  // For the cabled det_id retrieve the FEDid
79  const std::vector<const FedChannelConnection*>& conns = detCabling_->getConnections(detid);
80  if (conns.empty()) {
81  edm::LogWarning("SiStripBadChannelPatcher")
82  << " DetId " << detid << " appears to be uncabled, returning NOT_A_FEDID !";
83  return sistrip::NOT_A_FEDID;
84  }
85  unsigned int lFedId = sistrip::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;
90  if (lFedId < sistrip::FED_ID_MIN || lFedId > sistrip::FED_ID_MAX) {
91  edm::LogWarning("SiStripBadChannelPatcher") << lFedId << " for detid " << detid << " connection " << ch;
92  continue;
93  } else {
94  break;
95  }
96  }
97  }
98  return lFedId;
99 }
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
static const uint16_t NOT_A_FEDID
static const uint16_t FED_ID_MAX
Log< level::Warning, false > LogWarning
const SiStripDetCabling * detCabling_
#define LogDebug(id)

◆ fillDescriptions()

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

Definition at line 63 of file SiStripBadChannelPatcher.cc.

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

63  {
65  desc.setComment(
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");
73  descriptions.addWithDefaultLabel(desc);
74 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ getNewObject()

std::unique_ptr< SiStripBadStrip > SiStripBadChannelPatcher::getNewObject ( const edm::EventSetup iSetup)
private

Definition at line 129 of file SiStripBadChannelPatcher.cc.

References addDetIdsFromExcludedFEDs(), badStripToken_, cablingToken_, submitPVResolutionJobs::count, TauDecayModes::dec, detCabling_, detIdsToExclude_, detIdsToInclude_, fedFromDetId(), fedsToExclude_, SiStripDetInfo::getAllDetIds(), edm::EventSetup::getData(), l1ctLayer2EG_cff::id, SiStripDetInfoFileReader::kDefaultFile, LogDebug, dqmiodumpmetadata::n, getGTfromDQMFile::obj, jetsAK4_Puppi_cff::payload, printDebug_, FastTimerService_cff::range, SiStripDetInfoFileReader::read(), contentValuesCheck::ss, and sistrip::STRIPS_PER_APV.

Referenced by analyze().

129  {
130  edm::LogInfo("SiStripBadChannelPatcher") << "... creating dummy SiStripBadStrip Data";
131 
132  // this is the output object
133  auto obj = std::make_unique<SiStripBadStrip>();
134 
135  // get the cabling object
136  detCabling_ = &iSetup.getData(cablingToken_);
137 
138  // get the strips to add
139  std::vector<uint32_t> detids;
140  const auto& payload = iSetup.getData(badStripToken_);
141  payload.getDetIds(detids);
142 
143  // copy the exisiting channels (excluding the ones to remove)
144  for (const auto& id : detids) {
145  // check on the detids to exclude
146  if (std::count(detIdsToExclude_.begin(), detIdsToExclude_.end(), id)) {
147  edm::LogInfo("SiStripBadChannelPatcher") << "I AM GOING TO EXCLUDE DETID: " << id;
148  continue;
149  } else {
150  LogDebug("SiStripBadChannelPatcher") << "I AM GOING TO KEEP DETID: " << id;
151  }
152 
153  // check on the FEDs to exclude
154  const auto& currentFED = this->fedFromDetId(id);
155  if (std::count(fedsToExclude_.begin(), fedsToExclude_.end(), currentFED)) {
156  edm::LogInfo("SiStripBadChannelPatcher") << "I AM GOING TO EXCLUDE DETID: " << id;
157  continue;
158  } else {
159  LogDebug("SiStripBadChannelPatcher") << "I AM GOING TO KEEP DETID: " << id;
160  }
161 
162  SiStripBadStrip::Range range = payload.getRange(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);
170  }
171  SiStripBadStrip::Range outRange(theSiStripVector.begin(), theSiStripVector.end());
172  if (!obj->put(id, outRange))
173  edm::LogError("SiStripBadChannelPatcher") << "[SiStripBadChannelPatcher::analyze] detid already exists";
174  } // loop on the detids of the original payload
175 
176  const auto& detInfo =
178 
179  // add to the list of DetIds to include also the one from the list of FEDs
180  const std::vector<uint32_t>& allDetIds = detInfo.getAllDetIds();
181  this->addDetIdsFromExcludedFEDs(allDetIds);
182 
183  // add more full bad detids
184  if (!detIdsToInclude_.empty()) {
185  edm::LogInfo("SiStripBadChannelPatcher") << "I AM GOING TO ADD MORE DETIDS";
186 
187  std::stringstream ss;
188  for (const auto& detid : detIdsToInclude_) {
189  edm::LogInfo("SiStripBadChannelPatcher") << "I AM GOING TO ADD DETID: " << detid;
190  const auto& nAPVs = detInfo.getNumberOfApvsAndStripLength(detid).first;
191 
192  std::vector<unsigned int> theSiStripVector;
193  unsigned short firstBadStrip{0}, nConsecutiveBadStrips{0};
194  unsigned int theBadStripRange;
195 
196  for (unsigned int n = 0; n < nAPVs; n++) {
197  firstBadStrip = n * sistrip::STRIPS_PER_APV;
198  nConsecutiveBadStrips = sistrip::STRIPS_PER_APV;
199  theBadStripRange = obj->encode(firstBadStrip, nConsecutiveBadStrips);
200 
201  if (printDebug_) {
202  ss << "detid " << detid << " \t"
203  << " firstBadStrip " << firstBadStrip << "\t "
204  << " nConsecutiveBadStrips " << nConsecutiveBadStrips << "\t "
205  << " packed integer " << std::hex << theBadStripRange << std::dec << std::endl;
206  }
207 
208  theSiStripVector.push_back(theBadStripRange);
209  }
210 
211  SiStripBadStrip::Range outRange(theSiStripVector.begin(), theSiStripVector.end());
212  if (!obj->put(detid, outRange))
213  edm::LogError("SiStripBadChannelPatcher") << "[SiStripBadChannelPatcher::analyze] detid already exists";
214  } // loop on detids to include
215 
216  if (printDebug_) {
217  // print the added strips
218  edm::LogInfo("SiStripBadChannelPatcher") << ss.str();
219  }
220 
221  } // if there is any new channel to append
222 
223  return obj;
224 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
void addDetIdsFromExcludedFEDs(const std::vector< uint32_t > &allDetIds)
const edm::ESGetToken< SiStripBadStrip, SiStripBadStripRcd > badStripToken_
unsigned int fedFromDetId(const uint32_t &detid)
std::vector< unsigned int > fedsToExclude_
SiStripDetInfo read(std::string filePath)
Log< level::Info, false > LogInfo
std::vector< uint32_t > detIdsToExclude_
static const uint16_t STRIPS_PER_APV
std::pair< ContainerIterator, ContainerIterator > Range
static constexpr char const *const kDefaultFile
std::vector< uint32_t > detIdsToInclude_
const std::vector< uint32_t > & getAllDetIds() const noexcept
const edm::ESGetToken< SiStripDetCabling, SiStripDetCablingRcd > cablingToken_
const SiStripDetCabling * detCabling_
#define LogDebug(id)

Member Data Documentation

◆ badStripToken_

const edm::ESGetToken<SiStripBadStrip, SiStripBadStripRcd> SiStripBadChannelPatcher::badStripToken_
private

ES token for the bad strips

Definition at line 58 of file SiStripBadChannelPatcher.cc.

Referenced by getNewObject().

◆ cablingToken_

const edm::ESGetToken<SiStripDetCabling, SiStripDetCablingRcd> SiStripBadChannelPatcher::cablingToken_
private

ES token for the cabling

Definition at line 59 of file SiStripBadChannelPatcher.cc.

Referenced by getNewObject().

◆ detCabling_

const SiStripDetCabling* SiStripBadChannelPatcher::detCabling_
private

Definition at line 51 of file SiStripBadChannelPatcher.cc.

Referenced by fedFromDetId(), and getNewObject().

◆ detIdsToExclude_

std::vector<uint32_t> SiStripBadChannelPatcher::detIdsToExclude_
private

Definition at line 54 of file SiStripBadChannelPatcher.cc.

Referenced by getNewObject().

◆ detIdsToInclude_

std::vector<uint32_t> SiStripBadChannelPatcher::detIdsToInclude_
private

Definition at line 55 of file SiStripBadChannelPatcher.cc.

Referenced by addDetIdsFromExcludedFEDs(), and getNewObject().

◆ fedsToExclude_

std::vector<unsigned int> SiStripBadChannelPatcher::fedsToExclude_
private

Definition at line 56 of file SiStripBadChannelPatcher.cc.

Referenced by getNewObject().

◆ fedsToInclude_

std::vector<unsigned int> SiStripBadChannelPatcher::fedsToInclude_
private

Definition at line 57 of file SiStripBadChannelPatcher.cc.

Referenced by addDetIdsFromExcludedFEDs().

◆ printDebug_

const bool SiStripBadChannelPatcher::printDebug_
private

Definition at line 53 of file SiStripBadChannelPatcher.cc.

Referenced by getNewObject().

◆ record_

const std::string SiStripBadChannelPatcher::record_
private

Definition at line 52 of file SiStripBadChannelPatcher.cc.

Referenced by analyze().