CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
SiStripBadModuleConfigurableFakeESSource Class Reference
Inheritance diagram for SiStripBadModuleConfigurableFakeESSource:
edm::ESProducer edm::EventSetupRecordIntervalFinder edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Types

typedef std::unique_ptr< SiStripBadStripReturnType
 
- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
 
typedef std::vector< EventSetupRecordKeyKeys
 
typedef std::map< EventSetupRecordKey, KeyedProxiesRecordProxies
 

Public Member Functions

ReturnType produce (const SiStripBadModuleRcd &)
 
void setIntervalFor (const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &iov, edm::ValidityInterval &iValidity) override
 
 SiStripBadModuleConfigurableFakeESSource (const edm::ParameterSet &)
 
 ~SiStripBadModuleConfigurableFakeESSource () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer ()(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval) override
 overrides DataProxyProvider method More...
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
 DataProxyProvider ()
 
const ComponentDescriptiondescription () const
 
bool isUsingRecord (const EventSetupRecordKey &) const
 
const KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey) const
 
void resetProxies (const EventSetupRecordKey &iRecordType)
 
void resetProxiesIfTransient (const EventSetupRecordKey &iRecordType)
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () noexcept(false)
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
const eventsetup::ComponentDescriptiondescriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
std::set< eventsetup::EventSetupRecordKeyfindingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder () noexcept(false)
 

Private Types

using Parameters = std::vector< edm::ParameterSet >
 

Private Member Functions

std::vector< std::pair< uint32_t, std::vector< uint32_t > > > selectAPVs () const
 
std::vector< uint32_t > selectDetectors (const TrackerTopology *tTopo, const std::vector< uint32_t > &detIds) const
 

Private Attributes

Parameters m_badAPVsList
 
Parameters m_badComponentList
 
bool m_doByAPVs
 
bool m_printDebug
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::ESProducer
 ESProducer (const ESProducer &)=delete
 
ESProducer const & operator= (const ESProducer &)=delete
 
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 TArg >
ESConsumesCollectorT< TRecord > setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList) override
 override DataProxyProvider method More...
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
void eraseAll (const EventSetupRecordKey &iRecordKey)
 deletes all the Proxies in aStream More...
 
void invalidateProxies (const EventSetupRecordKey &iRecordKey)
 
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &)
 
- 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: Port of SiStripBadModuleGenerator and templated fake ESSource to an edm::ESProducer

Definition at line 26 of file SiStripBadModuleConfigurableFakeESSource.cc.

Member Typedef Documentation

Definition at line 37 of file SiStripBadModuleConfigurableFakeESSource.cc.

Definition at line 33 of file SiStripBadModuleConfigurableFakeESSource.cc.

Constructor & Destructor Documentation

SiStripBadModuleConfigurableFakeESSource::SiStripBadModuleConfigurableFakeESSource ( const edm::ParameterSet iConfig)

Definition at line 52 of file SiStripBadModuleConfigurableFakeESSource.cc.

References edm::ParameterSet::getUntrackedParameter(), m_badAPVsList, m_badComponentList, m_doByAPVs, m_printDebug, and edm::ESProducer::setWhatProduced().

53 {
54  setWhatProduced(this);
55  findingRecord<SiStripBadModuleRcd>();
56 
57  m_badComponentList = iConfig.getUntrackedParameter<Parameters>("BadComponentList");
58  m_doByAPVs = iConfig.getUntrackedParameter<bool>("doByAPVs", false);
59  m_badAPVsList = iConfig.getUntrackedParameter<Parameters>("BadAPVList");
60  m_printDebug = iConfig.getUntrackedParameter<bool>("printDebug", false);
61 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:124
T getUntrackedParameter(std::string const &, T const &) const
vector< ParameterSet > Parameters
SiStripBadModuleConfigurableFakeESSource::~SiStripBadModuleConfigurableFakeESSource ( )
override

Definition at line 63 of file SiStripBadModuleConfigurableFakeESSource.cc.

63 {}

Member Function Documentation

SiStripBadModuleConfigurableFakeESSource::ReturnType SiStripBadModuleConfigurableFakeESSource::produce ( const SiStripBadModuleRcd iRecord)

Definition at line 72 of file SiStripBadModuleConfigurableFakeESSource.cc.

References TauDecayModes::dec, edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getRecord(), mps_fire::i, m_doByAPVs, m_printDebug, edm::ESHandle< T >::product(), jets_cff::quality, matplotRender::reader, selectAPVs(), selectDetectors(), AlCaHLTBitMon_QueryRunRegistry::string, SiStripDetId::TEC, SiStripDetId::TIB, SiStripDetId::TID, SiStripDetId::TOB, and SiStripDetId::UNKNOWN.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

73 {
74  using namespace edm::es;
75 
77  iRecord.getRecord<TrackerTopologyRcd>().get(tTopo);
78 
79  auto quality = std::make_unique<SiStripQuality>();
80 
82 
83  if(!m_doByAPVs){
84  std::vector<uint32_t> selDetIds{selectDetectors(tTopo.product(), reader->getAllDetIds())};
85  edm::LogInfo("SiStripQualityConfigurableFakeESSource")<<"[produce] number of selected dets to be removed " << selDetIds.size() <<std::endl;
86 
87  std::stringstream ss;
88  for ( const auto selId : selDetIds ) {
89  SiStripQuality::InputVector theSiStripVector;
90 
91  unsigned short firstBadStrip{0};
92  unsigned short NconsecutiveBadStrips = reader->getNumberOfApvsAndStripLength(selId).first * 128;
93  unsigned int theBadStripRange{quality->encode(firstBadStrip,NconsecutiveBadStrips)};
94 
95  if (m_printDebug) {
96  ss << "detid " << selId << " \t"
97  << " firstBadStrip " << firstBadStrip << "\t "
98  << " NconsecutiveBadStrips " << NconsecutiveBadStrips << "\t "
99  << " packed integer " << std::hex << theBadStripRange << std::dec
100  << std::endl;
101  }
102 
103  theSiStripVector.push_back(theBadStripRange);
104 
105  if ( ! quality->put(selId,SiStripBadStrip::Range{theSiStripVector.begin(),theSiStripVector.end()}) ) {
106  edm::LogError("SiStripQualityConfigurableFakeESSource") << "[produce] detid already exists";
107  }
108  }
109  if (m_printDebug) {
110  edm::LogInfo("SiStripQualityConfigurableFakeESSource") << ss.str();
111  }
112  quality->cleanUp();
113  //quality->fillBadComponents();
114  } else {
115 
116  std::vector<std::pair<uint32_t,std::vector<uint32_t> > > selAPVs{selectAPVs()};
117  edm::LogInfo("SiStripQualityConfigurableFakeESSource")<<"[produce] number of selected dets to be removed " << selAPVs.size() <<std::endl;
118 
119  std::stringstream ss;
120  for ( const auto selId : selAPVs ) {
121  SiStripQuality::InputVector theSiStripVector;
122  auto the_detid = selId.first;
123 
124  for( const auto apv : selId.second ) {
125 
126  unsigned short firstBadStrip = apv*128;
127  unsigned short NconsecutiveBadStrips = 128;
128  unsigned int theBadStripRange{quality->encode(firstBadStrip,NconsecutiveBadStrips)};
129 
130  if (m_printDebug) {
131  ss << "detid " << the_detid << " \t"
132  << " firstBadStrip " << firstBadStrip << "\t "
133  << " NconsecutiveBadStrips " << NconsecutiveBadStrips << "\t "
134  << " packed integer " << std::hex << theBadStripRange << std::dec
135  << std::endl;
136  }
137 
138  theSiStripVector.push_back(theBadStripRange);
139  }
140 
141  if ( ! quality->put(the_detid,SiStripBadStrip::Range{theSiStripVector.begin(),theSiStripVector.end()}) ) {
142  edm::LogError("SiStripQualityConfigurableFakeESSource") << "[produce] detid already exists";
143  }
144  } // loop on the packed list of detid/apvs
145 
146  if (m_printDebug) {
147  edm::LogInfo("SiStripQualityConfigurableFakeESSource") << ss.str();
148  }
149  quality->cleanUp();
150 
151  } // do it by APVs
152 
153  if (m_printDebug){
154  std::stringstream ss1;
155  for ( const auto& badComp : quality->getBadComponentList() ) {
156  ss1 << "bad module " << badComp.detid << " " << badComp.BadModule << "\n";
157  }
158  edm::LogInfo("SiStripQualityConfigurableFakeESSource") << ss1.str();
159  }
160 
161  return quality;
162 }
std::vector< std::pair< uint32_t, std::vector< uint32_t > > > selectAPVs() const
std::vector< uint32_t > selectDetectors(const TrackerTopology *tTopo, const std::vector< uint32_t > &detIds) const
std::pair< ContainerIterator, ContainerIterator > Range
T const * product() const
Definition: ESHandle.h:86
Container InputVector
std::vector< std::pair< uint32_t, std::vector< uint32_t > > > SiStripBadModuleConfigurableFakeESSource::selectAPVs ( ) const
private

Definition at line 181 of file SiStripBadModuleConfigurableFakeESSource.cc.

References m_badAPVsList.

Referenced by produce().

182 {
183 
184  std::vector<std::pair<uint32_t,std::vector<uint32_t> > > selList;
185  selList.clear();
186 
187  for ( const auto& badAPV : m_badAPVsList ) {
188  const uint32_t det{badAPV.getParameter<uint32_t>("DetId")};
189  std::vector<uint32_t> apvs{badAPV.getParameter<std::vector<uint32_t> >("APVs")};
190  auto pair = std::make_pair(det,apvs);
191  selList.push_back(pair);
192  }
193  return selList;
194 }
std::vector< uint32_t > SiStripBadModuleConfigurableFakeESSource::selectDetectors ( const TrackerTopology tTopo,
const std::vector< uint32_t > &  detIds 
) const
private

Definition at line 197 of file SiStripBadModuleConfigurableFakeESSource.cc.

References gather_cfg::cout, DEFINE_FWK_EVENTSETUP_SOURCE, spr::find(), pfDeepBoostedJetPreprocessParams_cfi::lower_bound, m_badComponentList, m_printDebug, DetId::rawId(), AlCaHLTBitMon_QueryRunRegistry::string, SiStripDetId::TEC, TrackerTopology::tecIsFrontPetal(), TrackerTopology::tecIsStereo(), TrackerTopology::tecIsZPlusSide(), TrackerTopology::tecPetalNumber(), TrackerTopology::tecRing(), TrackerTopology::tecWheel(), SiStripDetId::TIB, TrackerTopology::tibIsInternalString(), TrackerTopology::tibIsRPhi(), TrackerTopology::tibIsStereo(), TrackerTopology::tibIsZPlusSide(), TrackerTopology::tibLayer(), TrackerTopology::tibString(), SiStripDetId::TID, TrackerTopology::tidIsRPhi(), TrackerTopology::tidIsStereo(), TrackerTopology::tidIsZPlusSide(), TrackerTopology::tidRing(), TrackerTopology::tidWheel(), SiStripDetId::TOB, TrackerTopology::tobIsRPhi(), TrackerTopology::tobIsStereo(), TrackerTopology::tobIsZPlusSide(), TrackerTopology::tobLayer(), TrackerTopology::tobRod(), and DetId::Tracker.

Referenced by produce().

198 {
199  std::vector<uint32_t> selList;
200  std::stringstream ss;
201  for ( const auto& badComp : m_badComponentList ) {
202  const std::string subDetStr{badComp.getParameter<std::string>("SubDet")};
203  if (m_printDebug) ss << "Bad SubDet " << subDetStr << " \t";
204  const SiStripDetId::SubDetector subDet = subDetFromString(subDetStr);
205 
206  const std::vector<uint32_t> genericBadDetIds{badComp.getUntrackedParameter<std::vector<uint32_t>>("detidList", std::vector<uint32_t>())};
207  const bool anySubDet{ ! genericBadDetIds.empty() };
208 
209  std::cout << "genericBadDetIds.size() = " << genericBadDetIds.size() << std::endl;
210 
211  using DetIdIt = std::vector<uint32_t>::const_iterator;
212  const DetIdIt beginDetIt = std::lower_bound(detIds.begin(), detIds.end(), DetId(DetId::Tracker, anySubDet ? SiStripDetId::TIB : subDet ).rawId());
213  const DetIdIt endDetIt = std::lower_bound(detIds.begin(), detIds.end(), DetId(DetId::Tracker, anySubDet ? SiStripDetId::TEC+1 : subDet+1).rawId());
214 
215  if ( anySubDet ) {
216  std::copy_if(beginDetIt, endDetIt, std::back_inserter(selList),
217  [&genericBadDetIds] ( uint32_t detId ) {
218  std::cout << "AnySubDet" << detId << std::endl;
219  return std::find(genericBadDetIds.begin(), genericBadDetIds.end(), detId) != genericBadDetIds.end();
220  });
221  } else {
222  switch (subDet) {
223  case SiStripDetId::TIB:
224  std::copy_if(beginDetIt, endDetIt, std::back_inserter(selList),
225  [tTopo,&badComp] ( uint32_t detectorId ) {
226  const DetId detId{detectorId};
227  return ( ( detId.subdetId() == SiStripDetId::TIB )
228  && _isSel(badComp.getParameter<uint32_t>("layer") , tTopo->tibLayer(detId))
229  && _isSel(badComp.getParameter<uint32_t>("bkw_frw"), tTopo->tibIsZPlusSide(detId) ? 2 : 1 )
230  && _isSel(badComp.getParameter<uint32_t>("int_ext"), tTopo->tibIsInternalString(detId) ? 1 : 2 )
231  && _isSel(badComp.getParameter<uint32_t>("ster") , tTopo->tibIsStereo(detId) ? 1 : ( tTopo->tibIsRPhi(detId) ? 2 : -1 ))
232  && _isSel(badComp.getParameter<uint32_t>("string_"), tTopo->tibString(detId))
233  && _isSel(badComp.getParameter<uint32_t>("detid") , detId.rawId())
234  );
235  } );
236  break;
237  case SiStripDetId::TID:
238  std::copy_if(beginDetIt, endDetIt, std::back_inserter(selList),
239  [tTopo,&badComp] ( uint32_t detectorId ) {
240  const DetId detId{detectorId};
241  return ( ( detId.subdetId() == SiStripDetId::TID )
242  && _isSel(badComp.getParameter<uint32_t>("wheel"), tTopo->tidWheel(detId))
243  && _isSel(badComp.getParameter<uint32_t>("side") , tTopo->tidIsZPlusSide(detId) ? 2 : 1 )
244  && _isSel(badComp.getParameter<uint32_t>("ster") , tTopo->tidIsStereo(detId) ? 1 : ( tTopo->tidIsRPhi(detId) ? 2 : -1 ) )
245  && _isSel(badComp.getParameter<uint32_t>("ring") , tTopo->tidRing(detId))
246  && _isSel(badComp.getParameter<uint32_t>("detid"), detId.rawId())
247  );
248  } );
249  break;
250  case SiStripDetId::TOB:
251  std::copy_if(beginDetIt, endDetIt, std::back_inserter(selList),
252  [tTopo,&badComp] ( uint32_t detectorId ) {
253  const DetId detId{detectorId};
254  return ( ( detId.subdetId() == SiStripDetId::TOB )
255  && _isSel(badComp.getParameter<uint32_t>("layer") , tTopo->tobLayer(detId))
256  && _isSel(badComp.getParameter<uint32_t>("bkw_frw"), tTopo->tobIsZPlusSide(detId) ? 2 : 1)
257  && _isSel(badComp.getParameter<uint32_t>("ster") , tTopo->tobIsStereo(detId) ? 1 : ( tTopo->tobIsRPhi(detId) ? 2 : -1 ))
258  && _isSel(badComp.getParameter<uint32_t>("rod") , tTopo->tobRod(detId))
259  && _isSel(badComp.getParameter<uint32_t>("detid") , detId.rawId())
260  );
261  } );
262  break;
263  case SiStripDetId::TEC:
264  std::copy_if(beginDetIt, endDetIt, std::back_inserter(selList),
265  [tTopo,&badComp] ( uint32_t detectorId ) {
266  const DetId detId{detectorId};
267  return ( ( detId.subdetId() == SiStripDetId::TEC )
268  && _isSel(badComp.getParameter<uint32_t>("wheel") , tTopo->tecWheel(detId))
269  && _isSel(badComp.getParameter<uint32_t>("side") , tTopo->tecIsZPlusSide(detId) ? 2 : 1 )
270  && _isSel(badComp.getParameter<uint32_t>("ster") , tTopo->tecIsStereo(detId) ? 1 : 2 )
271  && _isSel(badComp.getParameter<uint32_t>("petal_bkw_frw"), tTopo->tecIsFrontPetal(detId) ? 2 : 2)
272  && _isSel(badComp.getParameter<uint32_t>("petal") , tTopo->tecPetalNumber(detId))
273  && _isSel(badComp.getParameter<uint32_t>("ring") , tTopo->tecRing(detId))
274  && _isSel(badComp.getParameter<uint32_t>("detid") , detId.rawId())
275  );
276  } );
277  break;
278  default:
279  break;
280  }
281  }
282  }
283  if (m_printDebug) {
284  edm::LogInfo("SiStripBadModuleGenerator") << ss.str();
285  }
286  return selList;
287 }
unsigned int tibLayer(const DetId &id) const
unsigned int tibString(const DetId &id) const
unsigned int tidRing(const DetId &id) const
bool tobIsStereo(const DetId &id) const
unsigned int tecRing(const DetId &id) const
ring id
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
unsigned int tidWheel(const DetId &id) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
bool tobIsRPhi(const DetId &id) const
bool tidIsStereo(const DetId &id) const
bool tibIsZPlusSide(const DetId &id) const
bool tecIsStereo(const DetId &id) const
bool tibIsRPhi(const DetId &id) const
bool tobIsZPlusSide(const DetId &id) const
bool tecIsFrontPetal(const DetId &id) const
Definition: DetId.h:18
bool tidIsRPhi(const DetId &id) const
bool tidIsZPlusSide(const DetId &id) const
bool tibIsStereo(const DetId &id) const
bool tecIsZPlusSide(const DetId &id) const
unsigned int tecPetalNumber(const DetId &id) const
unsigned int tobRod(const DetId &id) const
bool tibIsInternalString(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
unsigned int tobLayer(const DetId &id) const
void SiStripBadModuleConfigurableFakeESSource::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey ,
const edm::IOVSyncValue iov,
edm::ValidityInterval iValidity 
)
overridevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 65 of file SiStripBadModuleConfigurableFakeESSource.cc.

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

66 {
67  iValidity = edm::ValidityInterval{iov.beginOfTime(), iov.endOfTime()};
68 }
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88

Member Data Documentation

Parameters SiStripBadModuleConfigurableFakeESSource::m_badAPVsList
private
Parameters SiStripBadModuleConfigurableFakeESSource::m_badComponentList
private
bool SiStripBadModuleConfigurableFakeESSource::m_doByAPVs
private
bool SiStripBadModuleConfigurableFakeESSource::m_printDebug
private