CMS 3D CMS Logo

SiStripBadModuleByHandBuilder.cc
Go to the documentation of this file.
5 
9 
10 #include <vector>
11 #include <iostream>
12 #include <fstream>
13 #include <ext/hash_map>
14 
15 class SiStripBadModuleByHandBuilder : public ConditionDBWriter<SiStripBadStrip> {
16 public:
18  ~SiStripBadModuleByHandBuilder() override = default;
19 
20 private:
21  std::unique_ptr<SiStripBadStrip> getNewObject() override;
22 
23 private:
26  std::vector<uint32_t> BadModuleList_;
27 };
28 
32  BadModuleList_ = iConfig.getUntrackedParameter<std::vector<uint32_t> >("BadModuleList");
33  printdebug_ = iConfig.getUntrackedParameter<bool>("printDebug", false);
34 }
35 
36 std::unique_ptr<SiStripBadStrip> SiStripBadModuleByHandBuilder::getNewObject() {
37  const auto detInfo = SiStripDetInfoFileReader::read(fp_.fullPath());
38 
39  auto obj = std::make_unique<SiStripBadStrip>();
40 
41  unsigned int firstBadStrip = 0;
42  unsigned short NconsecutiveBadStrips;
43  unsigned int theBadStripRange;
44 
45  for (std::vector<uint32_t>::const_iterator it = BadModuleList_.begin(); it != BadModuleList_.end(); ++it) {
46  std::vector<unsigned int> theSiStripVector;
47 
48  NconsecutiveBadStrips = detInfo.getNumberOfApvsAndStripLength(*it).first * 128;
49  theBadStripRange = obj->encode(firstBadStrip, NconsecutiveBadStrips);
50  if (printdebug_)
51  edm::LogInfo("SiStripBadModuleByHandBuilder")
52  << " BadModule " << *it << " \t"
53  << " firstBadStrip " << firstBadStrip << "\t "
54  << " NconsecutiveBadStrips " << NconsecutiveBadStrips << "\t "
55  << " packed integer " << std::hex << theBadStripRange << std::dec << std::endl;
56 
57  theSiStripVector.push_back(theBadStripRange);
58  SiStripBadStrip::Range range(theSiStripVector.begin(), theSiStripVector.end());
59  if (!obj->put(*it, range))
60  edm::LogError("SiStripBadModuleByHandBuilder")
61  << "[SiStripBadModuleByHandBuilder::analyze] detid already exists" << std::endl;
62  }
63  return obj;
64 }
65 
std::string fullPath() const
Definition: FileInPath.cc:161
~SiStripBadModuleByHandBuilder() override=default
T getUntrackedParameter(std::string const &, T const &) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SiStripDetInfo read(std::string filePath)
std::unique_ptr< SiStripBadStrip > getNewObject() override
Log< level::Info, false > LogInfo
std::pair< ContainerIterator, ContainerIterator > Range
static constexpr char const *const kDefaultFile
SiStripBadModuleByHandBuilder(const edm::ParameterSet &)