CMS 3D CMS Logo

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