CMS 3D CMS Logo

SiStripBadChannelBuilder.cc
Go to the documentation of this file.
3 
4 #include <iostream>
5 #include <fstream>
6 
10  printdebug_ = iConfig.getUntrackedParameter<bool>("printDebug", false);
11  BadComponentList_ = iConfig.getUntrackedParameter<Parameters>("BadComponentList");
12 }
13 
15 
16 std::unique_ptr<SiStripBadStrip> SiStripBadChannelBuilder::getNewObject() {
17  edm::LogInfo("SiStripBadChannelBuilder") << "... creating dummy SiStripBadStrip Data" << std::endl;
18 
19  auto obj = std::make_unique<SiStripBadStrip>();
20 
21  const auto detInfo = SiStripDetInfoFileReader::read(fp_.fullPath());
22 
23  for (Parameters::iterator iBadComponent = BadComponentList_.begin(); iBadComponent != BadComponentList_.end();
24  ++iBadComponent) {
25  uint32_t BadModule_ = iBadComponent->getParameter<uint32_t>("BadModule");
26  std::vector<uint32_t> BadChannelList_ = iBadComponent->getParameter<std::vector<uint32_t> >("BadChannelList");
27 
28  std::vector<unsigned int> theSiStripVector;
29  unsigned int NStrips = detInfo.getNumberOfApvsAndStripLength(BadModule_).first * 128;
30 
31  uint32_t lastBad = 999;
32  unsigned short firstBadStrip = 0, NconsecutiveBadStrips = 0;
33  unsigned int theBadStripRange;
34 
35  for (std::vector<uint32_t>::const_iterator is = BadChannelList_.begin(); is != BadChannelList_.end(); ++is) {
36  if (*is > NStrips - 1)
37  break;
38  if (*is != lastBad + 1) {
39  //new set
40 
41  if (lastBad != 999) {
42  //save previous set
43  theBadStripRange = obj->encode(firstBadStrip, NconsecutiveBadStrips);
44 
45  if (printdebug_)
46  edm::LogInfo("SiStripBadChannelBuilder")
47  << "detid " << BadModule_ << " \t"
48  << " firstBadStrip " << firstBadStrip << "\t "
49  << " NconsecutiveBadStrips " << NconsecutiveBadStrips << "\t "
50  << " packed integer " << std::hex << theBadStripRange << std::dec << std::endl;
51 
52  theSiStripVector.push_back(theBadStripRange);
53  }
54 
55  firstBadStrip = *is;
56  NconsecutiveBadStrips = 0;
57  }
58  NconsecutiveBadStrips++;
59  lastBad = *is;
60  }
61 
62  theBadStripRange = obj->encode(firstBadStrip, NconsecutiveBadStrips);
63  if (printdebug_)
64  edm::LogInfo("SiStripBadChannelBuilder")
65  << "detid " << BadModule_ << " \t"
66  << " firstBadStrip " << firstBadStrip << "\t "
67  << " NconsecutiveBadStrips " << NconsecutiveBadStrips << "\t "
68  << " packed integer " << std::hex << theBadStripRange << std::dec << std::endl;
69 
70  theSiStripVector.push_back(theBadStripRange);
71 
72  SiStripBadStrip::Range range(theSiStripVector.begin(), theSiStripVector.end());
73  if (!obj->put(BadModule_, range))
74  edm::LogError("SiStripBadChannelBuilder")
75  << "[SiStripBadChannelBuilder::analyze] detid already exists" << std::endl;
76  }
77  //End now write sistripbadChannel data in DB
79 
80  if (mydbservice.isAvailable()) {
81  if (mydbservice->isNewTagRequest("SiStripBadStripRcd")) {
82  mydbservice->createNewIOV<SiStripBadStrip>(
83  obj.get(), mydbservice->beginOfTime(), mydbservice->endOfTime(), "SiStripBadStripRcd");
84  } else {
85  //mydbservice->createNewIOV<SiStripBadStrip>(obj.get(),mydbservice->currentTime(),"SiStripBadStripRcd");
86  mydbservice->appendSinceTime<SiStripBadStrip>(obj.get(), mydbservice->currentTime(), "SiStripBadStripRcd");
87  }
88  } else {
89  edm::LogError("SiStripBadStripBuilder") << "Service is unavailable" << std::endl;
90  }
91 
92  return obj;
93 }
SiStripBadChannelBuilder::getNewObject
std::unique_ptr< SiStripBadStrip > getNewObject() override
Definition: SiStripBadChannelBuilder.cc:16
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
cond::service::PoolDBOutputService::beginOfTime
cond::Time_t beginOfTime() const
Definition: PoolDBOutputService.cc:215
cond::service::PoolDBOutputService::appendSinceTime
void appendSinceTime(const T *payloadObj, cond::Time_t sinceTime, const std::string &recordName)
Definition: PoolDBOutputService.h:141
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
SiStripBadChannelBuilder::~SiStripBadChannelBuilder
~SiStripBadChannelBuilder() override
Definition: SiStripBadChannelBuilder.cc:14
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
SiStripDetInfoFileReader::read
SiStripDetInfo read(std::string filePath)
Definition: SiStripDetInfoFileReader.cc:11
SiStripBadStrip
Definition: SiStripBadStrip.h:30
edm::FileInPath
Definition: FileInPath.h:61
SiStripBadStrip::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripBadStrip.h:53
ConditionDBWriter
Definition: ConditionDBWriter.h:149
cond::service::PoolDBOutputService::createNewIOV
void createNewIOV(const T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t, const std::string &recordName)
Definition: PoolDBOutputService.h:116
SiStripBadChannelBuilder::printdebug_
bool printdebug_
Definition: SiStripBadChannelBuilder.h:28
SiStripDetInfo::getNumberOfApvsAndStripLength
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
Definition: SiStripDetInfo.cc:19
SiStripDetInfoFileReader.h
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripBadChannelBuilder::fp_
edm::FileInPath fp_
Definition: SiStripBadChannelBuilder.h:27
SiStripBadChannelBuilder::SiStripBadChannelBuilder
SiStripBadChannelBuilder(const edm::ParameterSet &)
Definition: SiStripBadChannelBuilder.cc:7
edm::Service< cond::service::PoolDBOutputService >
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SiStripBadChannelBuilder::Parameters
std::vector< edm::ParameterSet > Parameters
Definition: SiStripBadChannelBuilder.h:30
cond::service::PoolDBOutputService::endOfTime
cond::Time_t endOfTime() const
Definition: PoolDBOutputService.cc:213
SiStripDetInfoFileReader::kDefaultFile
constexpr static char const *const kDefaultFile
Definition: SiStripDetInfoFileReader.h:10
cond::service::PoolDBOutputService::isNewTagRequest
bool isNewTagRequest(const std::string &recordName)
Definition: PoolDBOutputService.cc:128
SiStripBadChannelBuilder.h
SiStripBadChannelBuilder::BadComponentList_
Parameters BadComponentList_
Definition: SiStripBadChannelBuilder.h:31
edm::Log
Definition: MessageLogger.h:70
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
cond::service::PoolDBOutputService::currentTime
cond::Time_t currentTime() const
Definition: PoolDBOutputService.cc:217
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161