CMS 3D CMS Logo

SiStripBadFiberBuilder.cc
Go to the documentation of this file.
1 // system include files
2 #include <vector>
3 #include <iostream>
4 #include <fstream>
5 #include <sstream>
6 
7 // user include files
15 
16 class SiStripBadFiberBuilder : public ConditionDBWriter<SiStripBadStrip> {
17 public:
19  ~SiStripBadFiberBuilder() override;
20 
21 private:
22  std::unique_ptr<SiStripBadStrip> getNewObject() override;
23 
25 
26  typedef std::vector<edm::ParameterSet> Parameters;
28 };
29 
32  printdebug_ = iConfig.getUntrackedParameter<bool>("printDebug", false);
33  BadComponentList_ = iConfig.getUntrackedParameter<Parameters>("BadComponentList");
34 }
35 
37 
38 std::unique_ptr<SiStripBadStrip> SiStripBadFiberBuilder::getNewObject() {
39  edm::LogInfo("SiStripBadFiberBuilder") << "... creating dummy SiStripBadStrip Data" << std::endl;
40 
41  auto obj = std::make_unique<SiStripBadStrip>();
42 
43  std::stringstream ss;
44  for (Parameters::iterator iBadComponent = BadComponentList_.begin(); iBadComponent != BadComponentList_.end();
45  ++iBadComponent) {
46  uint32_t BadModule_ = iBadComponent->getParameter<uint32_t>("BadModule");
47  std::vector<uint32_t> BadApvList_ = iBadComponent->getParameter<std::vector<uint32_t> >("BadApvList");
48 
49  std::vector<unsigned int> theSiStripVector;
50 
51  unsigned short firstBadStrip = 0, NconsecutiveBadStrips = 0;
52  unsigned int theBadStripRange;
53 
54  for (std::vector<uint32_t>::const_iterator is = BadApvList_.begin(); is != BadApvList_.end(); ++is) {
55  firstBadStrip = (*is) * 128;
56  NconsecutiveBadStrips = 128;
57 
58  theBadStripRange = obj->encode(firstBadStrip, NconsecutiveBadStrips);
59 
60  if (printdebug_)
61  ss << "detid " << BadModule_ << " \t"
62  << " firstBadStrip " << firstBadStrip << "\t "
63  << " NconsecutiveBadStrips " << NconsecutiveBadStrips << "\t "
64  << " packed integer " << std::hex << theBadStripRange << std::dec << std::endl;
65 
66  theSiStripVector.push_back(theBadStripRange);
67  }
68 
69  SiStripBadStrip::Range range(theSiStripVector.begin(), theSiStripVector.end());
70  if (!obj->put(BadModule_, range))
71  edm::LogError("SiStripBadFiberBuilder") << "[SiStripBadFiberBuilder::analyze] detid already exists" << std::endl;
72  }
73  if (printdebug_)
74  edm::LogInfo("SiStripBadFiberBuilder") << ss.str();
75 
76  return obj;
77 }
78 
81 
std::unique_ptr< SiStripBadStrip > getNewObject() override
SiStripBadFiberBuilder(const edm::ParameterSet &)
T getUntrackedParameter(std::string const &, T const &) const
~SiStripBadFiberBuilder() override
std::vector< edm::ParameterSet > Parameters
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Log< level::Info, false > LogInfo
std::pair< ContainerIterator, ContainerIterator > Range