CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SiPhase2BadStripConfigurableFakeESSource Class Reference
Inheritance diagram for SiPhase2BadStripConfigurableFakeESSource:
edm::ESProducer edm::EventSetupRecordIntervalFinder edm::ESProductResolverFactoryProducer edm::eventsetup::ESProductResolverProvider

Public Types

typedef std::unique_ptr< SiStripBadStripReturnType
 

Public Member Functions

ReturnType produce (const SiPhase2OuterTrackerBadStripRcd &)
 
void setIntervalFor (const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &iov, edm::ValidityInterval &iValidity) override
 
 SiPhase2BadStripConfigurableFakeESSource (const edm::ParameterSet &)
 
 ~SiPhase2BadStripConfigurableFakeESSource () override=default
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ESProducer (const ESProducer &)=delete
 
 ESProducer (ESProducer &&)=delete
 
ESResolverIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProduceroperator= (const ESProducer &)=delete
 
ESProduceroperator= (ESProducer &&)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector< ESResolverIndex > > updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProductResolverFactoryProducer
 ESProductResolverFactoryProducer ()
 
 ESProductResolverFactoryProducer (const ESProductResolverFactoryProducer &)=delete
 
const ESProductResolverFactoryProduceroperator= (const ESProductResolverFactoryProducer &)=delete
 
 ~ESProductResolverFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
void createKeyedResolvers (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
const ComponentDescriptiondescription () const
 
 ESProductResolverProvider ()
 
 ESProductResolverProvider (const ESProductResolverProvider &)=delete
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedResolverskeyedResolvers (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const ESProductResolverProvideroperator= (const ESProductResolverProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~ESProductResolverProvider () noexcept(false)
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
bool concurrentFinder () const
 
const eventsetup::ComponentDescriptiondescriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
 EventSetupRecordIntervalFinder (const EventSetupRecordIntervalFinder &)=delete
 
std::set< eventsetup::EventSetupRecordKeyfindingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
bool nonconcurrentAndIOVNeedsUpdate (const eventsetup::EventSetupRecordKey &key, const IOVSyncValue &syncValue) const
 
const EventSetupRecordIntervalFinderoperator= (const EventSetupRecordIntervalFinder &)=delete
 
void resetInterval (const eventsetup::EventSetupRecordKey &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 
- Static Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
static void prevalidate (ConfigurationDescriptions &)
 

Private Member Functions

std::map< unsigned short, unsigned short > clusterizeBadChannels (const std::vector< Phase2TrackerDigi::PackedDigiType > &maskedChannels)
 

Private Attributes

float badComponentsFraction_
 
std::unique_ptr< CLHEP::HepRandomEngine > engine_
 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordgeomToken_
 
bool printDebug_
 
edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtrackTopoToken_
 

Additional Inherited Members

- Protected Types inherited from edm::ESProductResolverFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::ESProductResolverProvider
using KeyedResolversVector = std::vector< std::pair< DataKey, std::shared_ptr< ESProductResolver > >>
 
- Protected Member Functions inherited from edm::ESProducer
ESConsumesInfoconsumesInfoPushBackNew ()
 
unsigned int consumesInfoSize () const
 
template<typename CallbackT , typename TList , typename TRecord >
void registerProducts (std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>> iCallback, const TList *, const TRecord *iRecord, const es::Label &iLabel)
 
template<typename CallbackT , typename TRecord >
void registerProducts (std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>>, const eventsetup::produce::Null *, const TRecord *, const es::Label &)
 
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
auto setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord , typename TDecorator >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename TFunc >
auto setWhatProduced (TFunc &&func, const es::Label &iLabel={})
 
template<typename TReturn , typename TRecord , typename TFunc , typename TDecorator >
ESConsumesCollectorT< TRecord > setWhatProduced (TFunc &&func, TDecorator &&iDec, const es::Label &iLabel={})
 
void usesResources (std::vector< std::string > const &)
 
- Protected Member Functions inherited from edm::ESProductResolverFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ESProductResolverFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedResolversVector registerResolvers (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::ESProductResolverProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 
- Protected Member Functions inherited from edm::EventSetupRecordIntervalFinder
template<class T >
void findingRecord ()
 
void findingRecordWithKey (const eventsetup::EventSetupRecordKey &)
 

Detailed Description

Description: "fake" SiStripBadStrip ESProducer - configurable list of bad modules

Implementation: Adapted to Phase-2 from CalibTracker/SiStripESProducers/plugins/fake/SiStripBadModuleConfigurableFakeESSource.cc

Definition at line 43 of file SiPhase2BadStripConfigurableFakeESSource.cc.

Member Typedef Documentation

◆ ReturnType

Definition at line 52 of file SiPhase2BadStripConfigurableFakeESSource.cc.

Constructor & Destructor Documentation

◆ SiPhase2BadStripConfigurableFakeESSource()

SiPhase2BadStripConfigurableFakeESSource::SiPhase2BadStripConfigurableFakeESSource ( const edm::ParameterSet iConfig)

Definition at line 73 of file SiPhase2BadStripConfigurableFakeESSource.cc.

References badComponentsFraction_, gpuPixelDoublets::cc, Exception, geomToken_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), printDebug_, edm::ESProducer::setWhatProduced(), and trackTopoToken_.

74  : engine_(new CLHEP::HepJamesRandom(iConfig.getParameter<unsigned int>("seed"))) {
75  auto cc = setWhatProduced(this);
76  trackTopoToken_ = cc.consumes();
77  geomToken_ = cc.consumes();
78 
79  printDebug_ = iConfig.getUntrackedParameter<bool>("printDebug", false);
80  badComponentsFraction_ = iConfig.getParameter<double>("badComponentsFraction");
81 
83  throw cms::Exception("Inconsistent configuration")
84  << "[SiPhase2BadStripChannelBuilder::c'tor] the requested fraction of bad components is unphysical. \n";
85  }
86 
87  findingRecord<SiPhase2OuterTrackerBadStripRcd>();
88 }
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
T getUntrackedParameter(std::string const &, T const &) const
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackTopoToken_

◆ ~SiPhase2BadStripConfigurableFakeESSource()

SiPhase2BadStripConfigurableFakeESSource::~SiPhase2BadStripConfigurableFakeESSource ( )
overridedefault

Member Function Documentation

◆ clusterizeBadChannels()

std::map< unsigned short, unsigned short > SiPhase2BadStripConfigurableFakeESSource::clusterizeBadChannels ( const std::vector< Phase2TrackerDigi::PackedDigiType > &  maskedChannels)
private

Definition at line 192 of file SiPhase2BadStripConfigurableFakeESSource.cc.

References data, HLT_2024v12_cff::distance, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, LogDebug, L1Scalers_cfi::maskedChannels, printDebug_, mps_fire::result, submitPVValidationJobs::text, and to_string().

Referenced by produce().

193  {
194  // Here we will store the result
195  std::map<unsigned short, unsigned short> result{};
196  std::map<int, std::string> printresult{};
197 
198  // Sort and remove duplicates.
199  std::set data(maskedChannels.begin(), maskedChannels.end());
200 
201  // We will start the evaluation at the beginning of our data
202  auto startOfSequence = data.begin();
203 
204  // Find all sequences
205  while (startOfSequence != data.end()) {
206  // Find first value that is not greater than one
207  auto endOfSequence =
208  std::adjacent_find(startOfSequence, data.end(), [](const auto& v1, const auto& v2) { return v2 != v1 + 1; });
209  if (endOfSequence != data.end())
210  std::advance(endOfSequence, 1);
211 
212  auto consecutiveStrips = std::distance(startOfSequence, endOfSequence);
213  result[*startOfSequence] = consecutiveStrips;
214 
215  if (printDebug_) {
216  // Build resulting string
217  std::ostringstream oss{};
218  bool writeDash = false;
219  for (auto it = startOfSequence; it != endOfSequence; ++it) {
220  oss << (writeDash ? "-" : "") << std::to_string(*it);
221  writeDash = true;
222  }
223 
224  // Copy result to map
225  for (auto it = startOfSequence; it != endOfSequence; ++it)
226  printresult[*it] = oss.str();
227  }
228 
229  // Continue to search for the next sequence
230  startOfSequence = endOfSequence;
231  }
232 
233  if (printDebug_) {
234  // Show result on the screen. Or use the map in whichever way you want.
235  for (const auto& [value, text] : printresult)
236  LogDebug("SiPhase2BadStripConfigurableFakeESSource")
237  << std::left << std::setw(2) << value << " -> " << text << "\n";
238  }
239  return result;
240 }
static std::string to_string(const XMLCh *ch)
Definition: value.py:1
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
#define LogDebug(id)

◆ fillDescriptions()

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

Definition at line 242 of file SiPhase2BadStripConfigurableFakeESSource.cc.

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

242  {
244  desc.setComment("Configurable Fake Phase-2 Outer Tracker Bad Strip ESSource");
245  desc.add<unsigned int>("seed", 1)->setComment("random seed");
246  desc.addUntracked<bool>("printDebug", false)->setComment("maximum amount of print-outs");
247  desc.add<double>("badComponentsFraction", 0.01)->setComment("fraction of bad components to populate the ES");
248  descriptions.addWithDefaultLabel(desc);
249 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ produce()

SiPhase2BadStripConfigurableFakeESSource::ReturnType SiPhase2BadStripConfigurableFakeESSource::produce ( const SiPhase2OuterTrackerBadStripRcd iRecord)

Definition at line 97 of file SiPhase2BadStripConfigurableFakeESSource.cc.

References cms::cuda::assert(), badComponentsFraction_, clusterizeBadChannels(), TauDecayModes::dec, DetId::det(), TrackerGeometry::detUnits(), engine_, f, spr::find(), dqmdumpme::first, geomToken_, edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::get(), TrackerGeometry::getDetectorType(), LogDebug, hgcalPlots::ncols, PixelTopology::nrows(), TrackerGeometry::Ph2PSS, TrackerGeometry::Ph2SS, Phase2TrackerDigi::pixelToChannel(), printDebug_, FastTimerService_cff::range, nano_mu_digi_cff::rawId, DetId::rawId(), PixelGeomDetUnit::specificTopology(), DetId::subdetId(), StripSubdetector::TID, StripSubdetector::TOB, and align::Tracker.

98  {
99  using namespace edm::es;
101 
102  //TrackerTopology const& tTopo = iRecord.get(trackTopoToken_);
103  TrackerGeometry const& tGeom = iRecord.get(geomToken_);
104 
105  auto badStrips = std::make_unique<SiStripBadStrip>();
106 
107  // early return with nullptr if fraction is == 0.f
108  if (badComponentsFraction_ == 0.f) {
109  return badStrips;
110  }
111 
112  LogDebug("SiPhase2BadStripConfigurableFakeESSource")
113  << " There are " << tGeom.detUnits().size() << " modules in this geometry.";
114 
115  int counter{0};
116  for (auto const& det_u : tGeom.detUnits()) {
117  const DetId detid = det_u->geographicalId();
118  uint32_t rawId = detid.rawId();
119  int subid = detid.subdetId();
120  if (detid.det() == DetId::Detector::Tracker) {
121  const Phase2TrackerGeomDetUnit* pixdet = dynamic_cast<const Phase2TrackerGeomDetUnit*>(det_u);
122  assert(pixdet);
123  if (subid == StripSubdetector::TOB || subid == StripSubdetector::TID) {
126  const PixelTopology& topol(pixdet->specificTopology());
127 
128  const int nrows = topol.nrows();
129  const int ncols = topol.ncolumns();
130 
131  LogDebug("SiPhase2BadStripConfigurableFakeESSource")
132  << "DetId: " << rawId << " subdet: " << subid << " nrows: " << nrows << " ncols: " << ncols;
133 
134  // auxilliary vector to check if the channels were already used
135  std::vector<Phase2TrackerDigi::PackedDigiType> usedChannels;
136 
137  size_t nmaxBadStrips = std::floor(nrows * ncols * badComponentsFraction_);
138 
139  while (usedChannels.size() < nmaxBadStrips) {
140  unsigned short badStripRow = std::floor(CLHEP::RandFlat::shoot(engine_.get(), 0, nrows));
141  unsigned short badStripCol = std::floor(CLHEP::RandFlat::shoot(engine_.get(), 0, ncols));
142  const auto& badChannel = Phase2TrackerDigi::pixelToChannel(badStripRow, badStripCol);
143  if (std::find(usedChannels.begin(), usedChannels.end(), badChannel) == usedChannels.end()) {
144  usedChannels.push_back(badChannel);
145  }
146  }
147 
148  //usedChannels.push_back(Phase2TrackerDigi::pixelToChannel(0,1)); // useful for testing
149 
150  const auto badChannelsGroups = this->clusterizeBadChannels(usedChannels);
151 
152  LogDebug("SiPhase2BadStripConfigurableFakeESSource")
153  << rawId << " (" << counter << ") "
154  << " masking " << nmaxBadStrips << " strips, used channels size: " << usedChannels.size()
155  << ", clusters size: " << badChannelsGroups.size();
156 
157  std::vector<unsigned int> theSiStripVector;
158 
159  // loop over the groups of bad strips
160  for (const auto& [first, consec] : badChannelsGroups) {
161  unsigned int theBadChannelsRange;
162  theBadChannelsRange = badStrips->encodePhase2(first, consec);
163 
164  if (printDebug_) {
165  edm::LogInfo("SiPhase2BadStripConfigurableFakeESSource")
166  << "detid " << rawId << " \t"
167  << " firstBadStrip " << first << "\t "
168  << " NconsecutiveBadStrips " << consec << "\t "
169  << " packed integer " << std::hex << theBadChannelsRange << std::dec;
170  }
171  theSiStripVector.push_back(theBadChannelsRange);
172  }
173 
174  SiStripBadStrip::Range range(theSiStripVector.begin(), theSiStripVector.end());
175  if (!badStrips->put(rawId, range))
176  edm::LogError("SiPhase2BadStripConfigurableFakeESSource")
177  << "[SiPhase2BadStripConfigurableFakeESSource::produce] detid already exists";
178 
179  counter++;
180 
181  } // if it's a strip module
182  } // if it's OT
183  } // if it's Tracker
184  } // loop on DetIds
185 
186  LogDebug("SiPhase2BadStripConfigurableFakeESSource") << "end of the detId loops";
187 
188  return badStrips;
189 }
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
virtual int nrows() const =0
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
assert(be >=bs)
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
std::map< unsigned short, unsigned short > clusterizeBadChannels(const std::vector< Phase2TrackerDigi::PackedDigiType > &maskedChannels)
ModuleType getDetectorType(DetId) const
static PackedDigiType pixelToChannel(unsigned int row, unsigned int col)
double f[11][100]
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
static constexpr auto TOB
Log< level::Info, false > LogInfo
Definition: DetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
std::pair< ContainerIterator, ContainerIterator > Range
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
static constexpr auto TID
#define LogDebug(id)

◆ setIntervalFor()

void SiPhase2BadStripConfigurableFakeESSource::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey ,
const edm::IOVSyncValue iov,
edm::ValidityInterval iValidity 
)
overridevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 90 of file SiPhase2BadStripConfigurableFakeESSource.cc.

References edm::IOVSyncValue::beginOfTime(), and edm::IOVSyncValue::endOfTime().

92  {
93  iValidity = edm::ValidityInterval{iov.beginOfTime(), iov.endOfTime()};
94 }
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88

Member Data Documentation

◆ badComponentsFraction_

float SiPhase2BadStripConfigurableFakeESSource::badComponentsFraction_
private

◆ engine_

std::unique_ptr<CLHEP::HepRandomEngine> SiPhase2BadStripConfigurableFakeESSource::engine_
private

Definition at line 66 of file SiPhase2BadStripConfigurableFakeESSource.cc.

Referenced by produce().

◆ geomToken_

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> SiPhase2BadStripConfigurableFakeESSource::geomToken_
private

◆ printDebug_

bool SiPhase2BadStripConfigurableFakeESSource::printDebug_
private

◆ trackTopoToken_

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> SiPhase2BadStripConfigurableFakeESSource::trackTopoToken_
private