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 
14 class SiStripBadModuleByHandBuilder : public ConditionDBWriter<SiStripBadStrip> {
15 public:
17  ~SiStripBadModuleByHandBuilder() override = default;
18 
19 private:
20  std::unique_ptr<SiStripBadStrip> getNewObject() override;
21 
22 private:
25  std::vector<uint32_t> BadModuleList_;
26 };
27 
31  BadModuleList_ = iConfig.getUntrackedParameter<std::vector<uint32_t> >("BadModuleList");
32  printdebug_ = iConfig.getUntrackedParameter<bool>("printDebug", false);
33 }
34 
35 std::unique_ptr<SiStripBadStrip> SiStripBadModuleByHandBuilder::getNewObject() {
36  const auto detInfo = SiStripDetInfoFileReader::read(fp_.fullPath());
37 
38  auto obj = std::make_unique<SiStripBadStrip>();
39 
40  unsigned int firstBadStrip = 0;
41  unsigned short NconsecutiveBadStrips;
42  unsigned int theBadStripRange;
43 
44  for (std::vector<uint32_t>::const_iterator it = BadModuleList_.begin(); it != BadModuleList_.end(); ++it) {
45  std::vector<unsigned int> theSiStripVector;
46 
47  NconsecutiveBadStrips = detInfo.getNumberOfApvsAndStripLength(*it).first * 128;
48  theBadStripRange = obj->encode(firstBadStrip, NconsecutiveBadStrips);
49  if (printdebug_)
50  edm::LogInfo("SiStripBadModuleByHandBuilder")
51  << " BadModule " << *it << " \t"
52  << " firstBadStrip " << firstBadStrip << "\t "
53  << " NconsecutiveBadStrips " << NconsecutiveBadStrips << "\t "
54  << " packed integer " << std::hex << theBadStripRange << std::dec << std::endl;
55 
56  theSiStripVector.push_back(theBadStripRange);
57  SiStripBadStrip::Range range(theSiStripVector.begin(), theSiStripVector.end());
58  if (!obj->put(*it, range))
59  edm::LogError("SiStripBadModuleByHandBuilder")
60  << "[SiStripBadModuleByHandBuilder::analyze] detid already exists" << std::endl;
61  }
62  return obj;
63 }
64 
~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
const std::string & fullPath() const
Definition: FileInPath.cc:144
SiStripBadModuleByHandBuilder(const edm::ParameterSet &)