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 dqmEndJob(DQMStore::IBooker& booker, DQMStore::IGetter& getter) override;
17  SiStripBadStrip* getObj() const override;
18 protected:
19  std::string getMetaDataString() const override;
20 private:
23 };
24 
27 
30  , fp_{iConfig.getUntrackedParameter<edm::FileInPath>("file", edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"))}
31 {
32  edm::LogInfo("SiStripBadComponentsDQMService") << "[SiStripBadComponentsDQMService::SiStripBadComponentsDQMService]";
33 }
34 
36 {
37  edm::LogInfo("SiStripBadComponentsDQMService") << "[SiStripBadComponentsDQMService::~SiStripBadComponentsDQMService]";
38 }
39 
41 {
42  std::stringstream ss;
43  ss << SiStripDQMPopConSourceHandler<SiStripBadStrip>::getMetaDataString();
44  getObj()->printSummary(ss);
45  return ss.str();
46 }
47 
48 namespace {
49  void getModuleFolderList( DQMStore::IGetter& getter, const std::string& pwd, std::vector<std::string>& mfolders)
50  {
51  if ( std::string::npos != pwd.find("module_") ) {
52  // std::string mId = pwd.substr(pwd.find("module_")+7, 9);
53  mfolders.push_back(pwd);
54  } else {
55  for ( const auto& subdir : getter.getSubdirs() ) {
56  getter.cd(subdir);
57  getModuleFolderList(getter, subdir, mfolders);
58  getter.cd(); getter.cd(pwd);
59  }
60  }
61  }
62 }
63 
65 {
66  //*LOOP OVER THE LIST OF SUMMARY OBJECTS TO INSERT IN DB*//
67 
69 
71 
72  getter.cd();
73 
74  const std::string mechanicalview_dir = "MechanicalView";
75  if ( ! getter.dirExists(mechanicalview_dir) ) return;
76 
77  const std::vector<std::string> subdet_folder = { "TIB", "TOB", "TEC/side_1", "TEC/side_2", "TID/side_1", "TID/side_2" };
78 
79  int nDetsTotal = 0;
80  int nDetsWithErrorTotal = 0;
81  for ( const auto& im : subdet_folder ) {
82  const std::string dname = mechanicalview_dir + "/" + im;
83  getter.cd();
84  if ( ! getter.dirExists(dname) ) continue;
85  getter.cd(dname);
86 
87  std::vector<std::string> module_folders;
88  getModuleFolderList(getter, dname, module_folders);
89  int nDets = module_folders.size();
90 
91  int nDetsWithError = 0;
92  const std::string bad_module_folder = dname + "/" + "BadModuleList";
93  getter.cd();
94  if ( getter.dirExists(bad_module_folder) ) {
95  for ( const MonitorElement* me : getter.getContents(bad_module_folder) ) {
96  nDetsWithError++;
97  std::cout << me->getName() << " " << me->getIntValue() << std::endl;
98  uint32_t detId = std::stoul(me->getName());
99  short flag = me->getIntValue();
100 
101  std::vector<unsigned int> theSiStripVector;
102 
103  unsigned short firstBadStrip=0, NconsecutiveBadStrips=0;
104  unsigned int theBadStripRange;
105 
106  // for(std::vector<uint32_t>::const_iterator is=BadApvList_.begin(); is!=BadApvList_.end(); ++is){
107 
108  // firstBadStrip=(*is)*128;
109  NconsecutiveBadStrips=reader.getNumberOfApvsAndStripLength(detId).first*128;
110 
111  theBadStripRange = m_obj.encode(firstBadStrip,NconsecutiveBadStrips,flag);
112 
113  LogDebug("SiStripBadComponentsDQMService") << "detid " << detId << " \t"
114  << ", flag " << flag
115  << std::endl;
116 
117  theSiStripVector.push_back(theBadStripRange);
118  // }
119 
120  SiStripBadStrip::Range range(theSiStripVector.begin(),theSiStripVector.end());
121  if ( ! m_obj.put(detId,range) ) {
122  edm::LogError("SiStripBadFiberBuilder")<<"[SiStripBadFiberBuilder::analyze] detid already exists"<<std::endl;
123  }
124  }
125  }
126  nDetsTotal += nDets;
127  nDetsWithErrorTotal += nDetsWithError;
128  }
129  getter.cd();
130 }
131 
133 {
134  return new SiStripBadStrip(m_obj);
135 }
136 
#define LogDebug(id)
std::vector< MonitorElement * > getContents(Args &&...args)
Definition: DQMStore.h:197
T getUntrackedParameter(std::string const &, T const &) const
void cd(void)
Definition: DQMStore.cc:339
void printSummary(std::stringstream &ss) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void dqmEndJob(DQMStore::IBooker &booker, DQMStore::IGetter &getter) override
bool dirExists(const std::string &path)
Definition: DQMStore.cc:335
SiStripPopConBadComponentsHandlerFromDQM(const edm::ParameterSet &iConfig)
std::vector< std::string > getSubdirs(void)
Definition: DQMStore.cc:323
std::pair< ContainerIterator, ContainerIterator > Range
std::string fullPath() const
Definition: FileInPath.cc:184
bool put(const uint32_t &detID, const InputVector &vect)
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)