CMS 3D CMS Logo

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