CMS 3D CMS Logo

SiStripPopConBadComponentsDQM.cc
Go to the documentation of this file.
3 
11 {
12 public:
15  // interface methods: implemented in template
16  void initES(const edm::EventSetup&) override;
17  void dqmEndJob(DQMStore::IBooker& booker, DQMStore::IGetter& getter) override;
18  SiStripBadStrip* getObj() const override;
19 protected:
20  std::string getMetaDataString() const override;
21 private:
25 };
26 
30 
33 
36  , fp_{iConfig.getUntrackedParameter<edm::FileInPath>("file", edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"))}
37 {
38  edm::LogInfo("SiStripBadComponentsDQMService") << "[SiStripBadComponentsDQMService::SiStripBadComponentsDQMService]";
39 }
40 
42 {
43  edm::LogInfo("SiStripBadComponentsDQMService") << "[SiStripBadComponentsDQMService::~SiStripBadComponentsDQMService]";
44 }
45 
47 {
49  setup.get<TrackerTopologyRcd>().get(tTopo);
50  trackerTopo_ = tTopo.product();
51 }
52 
54 {
55  std::stringstream ss;
56  ss << SiStripDQMPopConSourceHandler<SiStripBadStrip>::getMetaDataString();
58  return ss.str();
59 }
60 
61 namespace {
62  void getModuleFolderList( DQMStore::IGetter& getter, const std::string& pwd, std::vector<std::string>& mfolders)
63  {
64  if ( std::string::npos != pwd.find("module_") ) {
65  // std::string mId = pwd.substr(pwd.find("module_")+7, 9);
66  mfolders.push_back(pwd);
67  } else {
68  for ( const auto& subdir : getter.getSubdirs() ) {
69  getter.cd(subdir);
70  getModuleFolderList(getter, subdir, mfolders);
71  getter.cd(); getter.cd(pwd);
72  }
73  }
74  }
75 }
76 
78 {
79  //*LOOP OVER THE LIST OF SUMMARY OBJECTS TO INSERT IN DB*//
80 
82 
84 
85  getter.cd();
86 
87  const std::string mechanicalview_dir = "MechanicalView";
88  if ( ! getter.dirExists(mechanicalview_dir) ) return;
89 
90  const std::vector<std::string> subdet_folder = { "TIB", "TOB", "TEC/side_1", "TEC/side_2", "TID/side_1", "TID/side_2" };
91 
92  int nDetsTotal = 0;
93  int nDetsWithErrorTotal = 0;
94  for ( const auto& im : subdet_folder ) {
95  const std::string dname = mechanicalview_dir + "/" + im;
96  getter.cd();
97  if ( ! getter.dirExists(dname) ) continue;
98  getter.cd(dname);
99 
100  std::vector<std::string> module_folders;
101  getModuleFolderList(getter, dname, module_folders);
102  int nDets = module_folders.size();
103 
104  int nDetsWithError = 0;
105  const std::string bad_module_folder = dname + "/" + "BadModuleList";
106  getter.cd();
107  if ( getter.dirExists(bad_module_folder) ) {
108  for ( const MonitorElement* me : getter.getContents(bad_module_folder) ) {
109  nDetsWithError++;
110  std::cout << me->getName() << " " << me->getIntValue() << std::endl;
111  uint32_t detId = std::stoul(me->getName());
112  short flag = me->getIntValue();
113 
114  std::vector<unsigned int> theSiStripVector;
115 
116  unsigned short firstBadStrip=0, NconsecutiveBadStrips=0;
117  unsigned int theBadStripRange;
118 
119  // for(std::vector<uint32_t>::const_iterator is=BadApvList_.begin(); is!=BadApvList_.end(); ++is){
120 
121  // firstBadStrip=(*is)*128;
122  NconsecutiveBadStrips=reader.getNumberOfApvsAndStripLength(detId).first*128;
123 
124  theBadStripRange = m_obj.encode(firstBadStrip,NconsecutiveBadStrips,flag);
125 
126  LogDebug("SiStripBadComponentsDQMService") << "detid " << detId << " \t"
127  << ", flag " << flag
128  << std::endl;
129 
130  theSiStripVector.push_back(theBadStripRange);
131  // }
132 
133  SiStripBadStrip::Range range(theSiStripVector.begin(),theSiStripVector.end());
134  if ( ! m_obj.put(detId,range) ) {
135  edm::LogError("SiStripBadFiberBuilder")<<"[SiStripBadFiberBuilder::analyze] detid already exists"<<std::endl;
136  }
137  }
138  }
139  nDetsTotal += nDets;
140  nDetsWithErrorTotal += nDetsWithError;
141  }
142  getter.cd();
143 }
144 
146 {
147  return new SiStripBadStrip(m_obj);
148 }
149 
#define LogDebug(id)
T getUntrackedParameter(std::string const &, T const &) const
void initES(const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
void dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGetter &getter) override
std::vector< MonitorElement * > getContents(Args &&...args)
Definition: DQMStore.h:192
bool dirExists(std::string const &path)
Definition: DQMStore.cc:343
SiStripPopConBadComponentsHandlerFromDQM(const edm::ParameterSet &iConfig)
std::pair< ContainerIterator, ContainerIterator > Range
T get() const
Definition: EventSetup.h:68
std::vector< std::string > getSubdirs()
Definition: DQMStore.cc:325
std::string fullPath() const
Definition: FileInPath.cc:197
bool put(const uint32_t &detID, const InputVector &vect)
T const * product() const
Definition: ESHandle.h:84
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const