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 
20 
21  unsigned int run=event.id().run();
22 
23  edm::LogInfo("SiStripBadChannelBuilder") << "... creating dummy SiStripBadStrip Data for Run " << run << "\n " << std::endl;
24 
26 
28 
29  for(Parameters::iterator iBadComponent = BadComponentList_.begin(); iBadComponent != BadComponentList_.end(); ++iBadComponent ) {
30 
31  uint32_t BadModule_ = iBadComponent->getParameter<uint32_t>("BadModule");
32  std::vector<uint32_t> BadChannelList_ = iBadComponent->getParameter<std::vector<uint32_t> >("BadChannelList");
33 
34  std::vector<unsigned int> theSiStripVector;
35  unsigned int NStrips=reader.getNumberOfApvsAndStripLength(BadModule_).first*128;
36 
37  uint32_t lastBad=999;
38  unsigned short firstBadStrip=0, NconsecutiveBadStrips=0;
39  unsigned int theBadStripRange;
40 
41  for(std::vector<uint32_t>::const_iterator is=BadChannelList_.begin(); is!=BadChannelList_.end(); ++is){
42  if (*is>NStrips-1)
43  break;
44  if (*is!=lastBad+1){
45  //new set
46 
47  if ( lastBad!=999 ){
48  //save previous set
49  theBadStripRange = obj->encode(firstBadStrip,NconsecutiveBadStrips);
50 
51  if (printdebug_)
52  edm::LogInfo("SiStripBadChannelBuilder") << "detid " << BadModule_ << " \t"
53  << " firstBadStrip " << firstBadStrip << "\t "
54  << " NconsecutiveBadStrips " << NconsecutiveBadStrips << "\t "
55  << " packed integer " << std::hex << theBadStripRange << std::dec
56  << std::endl;
57 
58  theSiStripVector.push_back(theBadStripRange);
59  }
60 
61  firstBadStrip=*is;
62  NconsecutiveBadStrips=0;
63  }
64  NconsecutiveBadStrips++;
65  lastBad=*is;
66  }
67 
68  theBadStripRange = obj->encode(firstBadStrip,NconsecutiveBadStrips);
69  if (printdebug_)
70  edm::LogInfo("SiStripBadChannelBuilder") << "detid " << BadModule_ << " \t"
71  << " firstBadStrip " << firstBadStrip << "\t "
72  << " NconsecutiveBadStrips " << NconsecutiveBadStrips << "\t "
73  << " packed integer " << std::hex << theBadStripRange << std::dec
74  << std::endl;
75 
76  theSiStripVector.push_back(theBadStripRange);
77 
78  SiStripBadStrip::Range range(theSiStripVector.begin(),theSiStripVector.end());
79  if ( ! obj->put(BadModule_,range) )
80  edm::LogError("SiStripBadChannelBuilder")<<"[SiStripBadChannelBuilder::analyze] detid already exists"<<std::endl;
81  }
82  //End now write sistripbadChannel data in DB
84 
85  if( mydbservice.isAvailable() ){
86  if ( mydbservice->isNewTagRequest("SiStripBadStripRcd") ){
87  mydbservice->createNewIOV<SiStripBadStrip>(obj,mydbservice->beginOfTime(),mydbservice->endOfTime(),"SiStripBadStripRcd");
88  } else {
89  //mydbservice->createNewIOV<SiStripBadStrip>(obj,mydbservice->currentTime(),"SiStripBadStripRcd");
90  mydbservice->appendSinceTime<SiStripBadStrip>(obj,mydbservice->currentTime(),"SiStripBadStripRcd");
91  }
92  }else{
93  edm::LogError("SiStripBadStripBuilder")<<"Service is unavailable"<<std::endl;
94  }
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)
void algoAnalyze(const edm::Event &event, const edm::EventSetup &iSetup) override
std::pair< ContainerIterator, ContainerIterator > Range
std::string fullPath() const
Definition: FileInPath.cc:197
bool put(const uint32_t &detID, const InputVector &vect)
std::vector< edm::ParameterSet > Parameters
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
Definition: event.py:1