CMS 3D CMS Logo

TrackingUtility.cc
Go to the documentation of this file.
3 
5 //
6 // Get a list of MEs in a folder
7 //
8 int TrackingUtility::getMEList(std::string name, std::vector<std::string>& values) {
9  values.clear();
10  std::string prefix_str = name.substr(0, (name.find(":")));
11  prefix_str += "/";
12  std::string temp_str = name.substr(name.find(":") + 1);
13  split(temp_str, values, ",");
14  for (std::vector<std::string>::iterator it = values.begin(); it != values.end(); it++)
15  (*it).insert(0, prefix_str);
16  return values.size();
17 }
18 //
19 // Get a list of MEs in a folder and the path name
20 //
21 int TrackingUtility::getMEList(std::string name, std::string& dir_path, std::vector<std::string>& values) {
22  values.clear();
23  dir_path = name.substr(0, (name.find(":")));
24  dir_path += "/";
25  std::string temp_str = name.substr(name.find(":") + 1);
26  split(temp_str, values, ",");
27  return values.size();
28 }
29 
30 // Check if the requested ME exists in a folder
32  if (name.find(name) == std::string::npos)
33  return false;
34  std::string prefix_str = name.substr(0, (name.find(":")));
35  prefix_str += "/";
36  std::string temp_str = name.substr(name.find(":") + 1);
37  std::vector<std::string> values;
38  split(temp_str, values, ",");
39  for (std::vector<std::string>::iterator it = values.begin(); it != values.end(); it++) {
40  if ((*it).find(me_name) != std::string::npos) {
41  full_path = prefix_str + (*it);
42  return true;
43  }
44  }
45  return false;
46 }
47 //
48 // -- Split a given string into a number of strings using given
49 // delimiters and fill a vector with splitted strings
50 //
51 void TrackingUtility::split(const std::string& str, std::vector<std::string>& tokens, const std::string& delimiters) {
52  // Skip delimiters at beginning.
53  std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
54 
55  // Find first "non-delimiter".
56  std::string::size_type pos = str.find_first_of(delimiters, lastPos);
57 
58  while (std::string::npos != pos || std::string::npos != lastPos) {
59  // Found a token, add it to the std::vector.
60  tokens.push_back(str.substr(lastPos, pos - lastPos));
61 
62  // Skip delimiters. Note the "not_of"
63  lastPos = str.find_first_not_of(delimiters, pos);
64 
65  // Find next "non-delimiter"
66  pos = str.find_first_of(delimiters, lastPos);
67  }
68 }
69 //
70 // -- Get Color code from Status
71 //
72 void TrackingUtility::getMEStatusColor(int status, int& rval, int& gval, int& bval) {
74  rval = 0;
75  gval = 255;
76  bval = 0;
77  } else if (status == dqm::qstatus::WARNING) {
78  rval = 255;
79  gval = 255;
80  bval = 0;
81  } else if (status == dqm::qstatus::ERROR) {
82  rval = 255;
83  gval = 0;
84  bval = 0;
85  } else if (status == dqm::qstatus::OTHER) {
86  rval = 255;
87  gval = 150;
88  bval = 0;
89  } else {
90  rval = 0;
91  gval = 0;
92  bval = 255;
93  }
94 }
95 //
96 // -- Get Color code from Status
97 //
100  tag = "Ok";
101  icol = 3;
102  } else if (status == dqm::qstatus::WARNING) {
103  tag = "Warning";
104  icol = 5;
105  } else if (status == dqm::qstatus::ERROR) {
106  tag = "Error";
107  icol = 2;
108  } else if (status == dqm::qstatus::OTHER) {
109  tag = "Other";
110  icol = 1;
111  } else {
112  tag = " ";
113  icol = 1;
114  }
115 }
116 
117 //
118 // -- Get Status of Monitor Element
119 //
121  int status = 0;
122  if (me->getQReports().empty()) {
123  status = 0;
124  } else if (me->hasError()) {
126  } else if (me->hasWarning()) {
128  } else if (me->hasOtherReport()) {
130  } else {
132  }
133  return status;
134 }
135 //
136 // -- Fill Module Names
137 //
139  DQMStore::IGetter& igetter,
140  std::vector<std::string>& mfolders) {
141  std::string currDir = ibooker.pwd();
142  if (currDir.find("module_") != std::string::npos) {
143  // std::string mId = currDir.substr(currDir.find("module_")+7, 9);
144  mfolders.push_back(currDir);
145  } else {
146  std::vector<std::string> subdirs = igetter.getSubdirs();
147  for (std::vector<std::string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
148  ibooker.cd(*it);
149  getModuleFolderList(ibooker, igetter, mfolders);
150  ibooker.goUp();
151  }
152  }
153 }
154 //
155 // -- Get Status of Monitor Element
156 //
158  int status = 0;
159  if (me->getQReports().empty()) {
160  status = 0;
161  bad_channels = -1;
162  } else {
163  std::vector<QReport*> qreports = me->getQReports();
164  bad_channels = qreports[0]->getBadChannels().size();
165  if (me->hasError()) {
167  } else if (me->hasWarning()) {
169  } else if (me->hasOtherReport()) {
171  } else {
173  }
174  }
175  return status;
176 }
177 //
178 // -- Get Status of Monitor Element
179 //
181  val = "";
182  if (me) {
183  if (me->kind() == MonitorElement::Kind::REAL) {
184  val = std::to_string(me->getFloatValue());
185  } else if (me->kind() == MonitorElement::Kind::INT) {
186  val = std::to_string(me->getIntValue());
187  }
188  }
189 }
190 //
191 // -- go to a given Directory
192 //
194  std::string currDir = ibooker.pwd();
195  std::string dirName = currDir.substr(currDir.find_last_of("/") + 1);
196  if (dirName.find(name) == 0) {
197  return true;
198  }
199  std::vector<std::string> subDirVec = igetter.getSubdirs();
200  for (std::vector<std::string>::const_iterator ic = subDirVec.begin(); ic != subDirVec.end(); ic++) {
201  std::string fname = (*ic);
202  if ((fname.find("Reference") != std::string::npos) || (fname.find("AlCaReco") != std::string::npos) ||
203  (fname.find("HLT") != std::string::npos))
204  continue;
205  igetter.cd(fname);
206  if (!goToDir(ibooker, igetter, name))
207  ibooker.goUp();
208  else
209  return true;
210  }
211  return false;
212 }
213 //
214 // -- Set Bad Channel Flag from hname
215 //
216 void TrackingUtility::setBadModuleFlag(std::string& hname, uint16_t& flg) {
217  if (hname.find("FractionOfBadChannels") != std::string::npos)
218  flg |= (1 << 0);
219  else if (hname.find("NumberOfDigi") != std::string::npos)
220  flg |= (1 << 1);
221  else if (hname.find("NumberOfCluster") != std::string::npos)
222  flg |= (1 << 2);
223  else if (hname.find("ExcludedFedChannel") != std::string::npos)
224  flg |= (1 << 3);
225  else if (hname.find("DCSError") != std::string::npos)
226  flg |= (1 << 4);
227 }
228 //
229 // -- Get the Status Message from Bad Module Flag
230 //
232  if (flag == 0)
233  message += " No Error";
234  else {
235  // message += " Error from :: ";
236  if (((flag >> 0) & 0x1) > 0)
237  message += " Fed BadChannel : ";
238  if (((flag >> 1) & 0x1) > 0)
239  message += " # of Digi : ";
240  if (((flag >> 2) & 0x1) > 0)
241  message += " # of Clusters :";
242  if (((flag >> 3) & 0x1) > 0)
243  message += " Excluded FED Channel ";
244  if (((flag >> 4) & 0x1) > 0)
245  message += " DCSError ";
246  }
247 }
248 //
249 // -- Set Event Info Folder
250 //
252  DQMStore::IGetter& igetter,
253  std::string top_dir,
254  std::string& path) {
255  path = "";
256  ibooker.cd();
257  if (igetter.dirExists(top_dir)) {
258  ibooker.cd(top_dir);
259  path = ibooker.pwd();
260  } else {
261  if (TrackingUtility::goToDir(ibooker, igetter, top_dir)) {
262  std::string tdir = "TrackParameters";
263  if (TrackingUtility::goToDir(ibooker, igetter, tdir)) {
264  path = ibooker.pwd();
265  path = path.substr(0, path.find(tdir) - 1);
266  }
267  }
268  }
269 }
MonitorElementData::Kind::INT
TrackingUtility::split
static void split(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
Definition: TrackingUtility.cc:51
mps_update.status
status
Definition: mps_update.py:69
TrackingUtility::getTopFolderPath
static void getTopFolderPath(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, std::string top_dir, std::string &path)
Definition: TrackingUtility.cc:251
pos
Definition: PixelAliasList.h:18
TrackingUtility::getMEList
static int getMEList(std::string name, std::vector< std::string > &values)
Definition: TrackingUtility.cc:8
dqm::qstatus::WARNING
static const int WARNING
Definition: MonitorElement.h:53
TrackingUtility::getModuleFolderList
static void getModuleFolderList(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, std::vector< std::string > &m_ids)
Definition: TrackingUtility.cc:138
TrackingUtility::getMEStatusColor
static void getMEStatusColor(int status, int &rval, int &gval, int &bval)
Definition: TrackingUtility.cc:72
DQMStore.h
dqm::implementation::IGetter::getSubdirs
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:678
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
TrackingUtility::getBadModuleStatus
static void getBadModuleStatus(uint16_t flag, std::string &message)
Definition: TrackingUtility.cc:231
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
rval
unsigned long long int rval
Definition: vlib.h:21
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
str
#define str(s)
Definition: TestProcessor.cc:48
dqm::implementation::NavigatorBase::cd
virtual void cd()
Definition: DQMStore.cc:29
dqm::implementation::NavigatorBase::pwd
virtual std::string pwd()
Definition: DQMStore.cc:16
TrackingUtility::setBadModuleFlag
static void setBadModuleFlag(std::string &hname, uint16_t &flg)
Definition: TrackingUtility.cc:216
TrackingUtility::checkME
static bool checkME(std::string element, std::string name, std::string &full_path)
Definition: TrackingUtility.cc:31
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
dqm::qstatus::OTHER
static const int OTHER
Definition: MonitorElement.h:47
TrackingUtility::getMEValue
static void getMEValue(MonitorElement *me, std::string &val)
Definition: TrackingUtility.cc:180
TrackingUtility.h
TrackingUtility::goToDir
static bool goToDir(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, std::string name)
Definition: TrackingUtility.cc:193
TrackingUtility::getMEStatus
static int getMEStatus(MonitorElement *me)
Definition: TrackingUtility.cc:120
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
dqm::implementation::NavigatorBase::goUp
virtual void goUp()
Definition: DQMStore.cc:31
heppy_batch.val
val
Definition: heppy_batch.py:351
dqm::implementation::IGetter
Definition: DQMStore.h:484
TrackerOfflineValidation_Dqm_cff.dirName
dirName
Definition: TrackerOfflineValidation_Dqm_cff.py:55
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
dqm::qstatus::STATUS_OK
static const int STATUS_OK
Definition: MonitorElement.h:52
dqm::implementation::IBooker
Definition: DQMStore.h:43
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
dqm::qstatus::ERROR
static const int ERROR
Definition: MonitorElement.h:54
StripSubdetector.h
MonitorElementData::Kind::REAL
dqm::implementation::IGetter::dirExists
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:707
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116