CMS 3D CMS Logo

SiPixelUtility.cc
Go to the documentation of this file.
4 #include <cstdlib>
5 
6 using namespace std;
7 //
8 // Get a list of MEs in a folder
9 //
10 int SiPixelUtility::getMEList(string name, vector<string> &values) {
11  values.clear();
12  string prefix_str = name.substr(0, (name.find(":")));
13  prefix_str += "/";
14  string temp_str = name.substr(name.find(":") + 1);
15  split(temp_str, values, ",");
16  for (vector<string>::iterator it = values.begin(); it != values.end(); it++)
17  (*it).insert(0, prefix_str);
18  return values.size();
19 }
20 //
21 // Get a list of MEs in a folder and the path name
22 //
23 int SiPixelUtility::getMEList(string name, string &dir_path, vector<string> &values) {
24  values.clear();
25  dir_path = name.substr(0, (name.find(":")));
26  dir_path += "/";
27  string temp_str = name.substr(name.find(":") + 1);
28  split(temp_str, values, ",");
29  return values.size();
30 }
31 
32 // Check if the requested ME exists in a folder
33 bool SiPixelUtility::checkME(string name, string me_name, string &full_path) {
34  if (name.find(name) == string::npos)
35  return false;
36  string prefix_str = name.substr(0, (name.find(":")));
37  prefix_str += "/";
38  string temp_str = name.substr(name.find(":") + 1);
39  vector<string> values;
40  split(temp_str, values, ",");
41  for (vector<string>::iterator it = values.begin(); it != values.end(); it++) {
42  if ((*it).find(me_name) != string::npos) {
43  full_path = prefix_str + (*it);
44  return true;
45  }
46  }
47  return false;
48 }
49 //
50 // -- Split a given string into a number of strings using given
51 // delimiters and fill a vector with splitted strings
52 //
53 void SiPixelUtility::split(const string &str, vector<string> &tokens, const string &delimiters) {
54  // Skip delimiters at beginning.
55  string::size_type lastPos = str.find_first_not_of(delimiters, 0);
56 
57  // Find first "non-delimiter".
58  string::size_type pos = str.find_first_of(delimiters, lastPos);
59 
60  while (string::npos != pos || string::npos != lastPos) {
61  // Found a token, add it to the vector.
62  tokens.push_back(str.substr(lastPos, pos - lastPos));
63 
64  // Skip delimiters. Note the "not_of"
65  lastPos = str.find_first_not_of(delimiters, pos);
66 
67  // Find next "non-delimiter"
68  pos = str.find_first_of(delimiters, lastPos);
69  }
70 }
71 //
72 // -- Get Color code from Status
73 //
74 void SiPixelUtility::getStatusColor(int status, int &rval, int &gval, int &bval) {
76  rval = 0;
77  gval = 255;
78  bval = 0;
79  } else if (status == dqm::qstatus::WARNING) {
80  rval = 255;
81  gval = 255;
82  bval = 0;
83  } else if (status == dqm::qstatus::ERROR) {
84  rval = 255;
85  gval = 0;
86  bval = 0;
87  } else if (status == dqm::qstatus::OTHER) {
88  rval = 255;
89  gval = 150;
90  bval = 0;
91  } else {
92  rval = 0;
93  gval = 0;
94  bval = 255;
95  }
96 }
97 //
98 // -- Get Color code from Status
99 //
100 void SiPixelUtility::getStatusColor(int status, int &icol, string &tag) {
102  tag = "Ok";
103  icol = 3;
104  } else if (status == dqm::qstatus::WARNING) {
105  tag = "Warning";
106  icol = 5;
107  } else if (status == dqm::qstatus::ERROR) {
108  tag = "Error";
109  icol = 2;
110  } else if (status == dqm::qstatus::OTHER) {
111  tag = "Other";
112  icol = 1;
113  } else {
114  tag = " ";
115  icol = 1;
116  }
117 }
118 //
119 // -- Get Color code from Status
120 //
121 void SiPixelUtility::getStatusColor(double status, int &rval, int &gval, int &bval) {
123  gval = SiPixelContinuousPalette::g[(int)(status * 100)];
124  bval = SiPixelContinuousPalette::b[(int)(status * 100)];
125 }
126 //
127 // -- Get Status of Monitor Element
128 //
130  int status = 0;
131  if (me->getQReports().empty()) {
132  status = 0;
133  } else if (me->hasError()) {
135  } else if (me->hasWarning()) {
137  } else if (me->hasOtherReport()) {
139  } else {
141  }
142  return status;
143 }
144 
146  vector<string> qtestNameList;
147  return qtestNameList;
148 }
149 
151  int code = 0;
152  switch (status) {
154  code = 1;
155  break;
157  code = 2;
158  break;
159  case dqm::qstatus::ERROR:
160  code = 3;
161  break;
162  } // end switch
163 
164  return code;
165 }
166 
167 int SiPixelUtility::computeHistoBin(string &module_path) {
168  int module_bin = 0;
169 
170  int module = 0;
171  int shell = 0;
172  int layer = 0;
173  int ladder = 0;
174  int halfcylinder = 0;
175  int disk = 0;
176  int blade = 0;
177  int panel = 0;
178 
179  int nbinShell = 192;
180  int nbinLayer = 0;
181  int nbinLadder = 4;
182 
183  int nbinHalfcylinder = 168;
184  int nbinDisk = 84;
185  int nbinBlade = 7;
186  int nbinPanel = 0;
187 
188  vector<string> subDirVector;
189  SiPixelUtility::split(module_path, subDirVector, "/");
190 
191  for (vector<string>::const_iterator it = subDirVector.begin(); it != subDirVector.end(); it++) {
192  if ((*it).find("Collector") != string::npos ||
193  //(*it).find("Collated") != string::npos ||
194  (*it).find("FU") != string::npos || (*it).find("Pixel") != string::npos ||
195  (*it).find("Barrel") != string::npos || (*it).find("Endcap") != string::npos)
196  continue;
197 
198  if ((*it).find("Module") != string::npos) {
199  module = atoi((*it).substr((*it).find("_") + 1).c_str());
200  }
201 
202  if ((*it).find("Shell") != string::npos) {
203  if ((*it).find("mI") != string::npos)
204  shell = 1;
205  if ((*it).find("mO") != string::npos)
206  shell = 2;
207  if ((*it).find("pI") != string::npos)
208  shell = 3;
209  if ((*it).find("pO") != string::npos)
210  shell = 4;
211  }
212  if ((*it).find("Layer") != string::npos) {
213  layer = atoi((*it).substr((*it).find("_") + 1).c_str());
214  if (layer == 1) {
215  nbinLayer = 0;
216  }
217  if (layer == 2) {
218  nbinLayer = 40;
219  }
220  if (layer == 3) {
221  nbinLayer = 40 + 64;
222  }
223  }
224  if ((*it).find("Ladder") != string::npos) {
225  ladder = atoi((*it).substr((*it).find("_") + 1, 2).c_str());
226  }
227  if ((*it).find("HalfCylinder") != string::npos) {
228  if ((*it).find("mI") != string::npos)
229  halfcylinder = 1;
230  if ((*it).find("mO") != string::npos)
231  halfcylinder = 2;
232  if ((*it).find("pI") != string::npos)
233  halfcylinder = 3;
234  if ((*it).find("pO") != string::npos)
235  halfcylinder = 4;
236  }
237  if ((*it).find("Disk") != string::npos) {
238  disk = atoi((*it).substr((*it).find("_") + 1).c_str());
239  }
240  if ((*it).find("Blade") != string::npos) {
241  blade = atoi((*it).substr((*it).find("_") + 1, 2).c_str());
242  }
243  if ((*it).find("Panel") != string::npos) {
244  panel = atoi((*it).substr((*it).find("_") + 1).c_str());
245  if (panel == 1)
246  nbinPanel = 0;
247  if (panel == 2)
248  nbinPanel = 4;
249  }
250  }
251  if (module_path.find("Barrel") != string::npos) {
252  module_bin = module + (ladder - 1) * nbinLadder + nbinLayer + (shell - 1) * nbinShell;
253  }
254  if (module_path.find("Endcap") != string::npos) {
255  module_bin = module + (panel - 1) * nbinPanel + (blade - 1) * nbinBlade + (disk - 1) * nbinDisk +
256  (halfcylinder - 1) * nbinHalfcylinder;
257  }
258 
259  return module_bin;
260 
261  // cout << "leaving SiPixelInformationExtractor::computeHistoBin" << endl;
262 }
263 
264 void SiPixelUtility::fillPaveText(TPaveText *pave, const map<string, pair<int, double>> &messages) {
265  TText *sourceCodeOnCanvas;
266  for (map<string, pair<int, double>>::const_iterator it = messages.begin(); it != messages.end(); it++) {
267  string message = it->first;
268  int color = (it->second).first;
269  double size = (it->second).second;
270  sourceCodeOnCanvas = pave->AddText(message.c_str());
271  sourceCodeOnCanvas->SetTextColor(color);
272  sourceCodeOnCanvas->SetTextSize(size);
273  sourceCodeOnCanvas->SetTextFont(112);
274  }
275 }
276 
277 map<string, string> SiPixelUtility::sourceCodeMap() {
278  map<string, string> sourceCode;
279  for (int iSource = 0; iSource < 5; iSource++) {
280  string type;
281  string code;
282  switch (iSource) {
283  case 0:
284  type = "RAW";
285  code = "1 ";
286  break;
287  case 1:
288  type = "DIG";
289  code = "10 ";
290  break;
291  case 2:
292  type = "CLU";
293  code = "100 ";
294  break;
295  case 3:
296  type = "TRK";
297  code = "1000 ";
298  break;
299  case 4:
300  type = "REC";
301  code = "10000";
302  break;
303  } // end of switch
304  sourceCode[type] = code;
305  }
306  return sourceCode;
307 }
308 
309 void SiPixelUtility::createStatusLegendMessages(map<string, pair<int, double>> &messages) {
310  for (int iStatus = 1; iStatus < 5; iStatus++) {
311  pair<int, double> color_size;
312  int color = 1;
313  double size = 0.03;
314  string code;
315  string type;
316  color_size.second = size;
317  switch (iStatus) {
318  case 1:
319  code = "1";
320  type = "INSUF_STAT";
321  color = kBlue;
322  break;
323  case 2:
324  code = "2";
325  type = "WARNING(S)";
326  color = kYellow;
327  break;
328  case 3:
329  code = "3";
330  type = "ERROR(S) ";
331  color = kRed;
332  break;
333  case 4:
334  code = "4";
335  type = "ERRORS ";
336  color = kMagenta;
337  break;
338  } // end of switch
339  string messageString = code + ": " + type;
340  color_size.first = color;
341  messages[messageString] = color_size;
342  }
343 }
344 
345 //------------------------------------------------------------------------------
346 //
347 // -- Set Drawing Option
348 //
349 void SiPixelUtility::setDrawingOption(TH1 *hist, float xlow, float xhigh) {
350  if (!hist)
351  return;
352 
353  TAxis *xa = hist->GetXaxis();
354  TAxis *ya = hist->GetYaxis();
355 
356  xa->SetTitleOffset(0.7);
357  xa->SetTitleSize(0.06);
358  xa->SetLabelSize(0.04);
359  // xa->SetLabelColor(0);
360 
361  ya->SetTitleOffset(0.7);
362  ya->SetTitleSize(0.06);
363 
364  if (xlow != -1 && xhigh != -1.0) {
365  xa->SetRangeUser(xlow, xhigh);
366  }
367 }
SiPixelUtility::checkME
static bool checkME(std::string element, std::string name, std::string &full_path)
Definition: SiPixelUtility.cc:33
dqm::qstatus::INSUF_STAT
static const int INSUF_STAT
Definition: MonitorElement.h:50
mps_update.status
status
Definition: mps_update.py:69
SiPixelContinuousPalette::g
constexpr int g[]
Definition: SiPixelContinuousPalette.h:23
pos
Definition: PixelAliasList.h:18
SiPixelUtility::setDrawingOption
static void setDrawingOption(TH1 *hist, float xlow=-1., float xhigh=-1.)
Definition: SiPixelUtility.cc:349
SiPixelContinuousPalette::b
constexpr int b[]
Definition: SiPixelContinuousPalette.h:29
dqm::qstatus::WARNING
static const int WARNING
Definition: MonitorElement.h:53
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
SiPixelUtility::getStatusColor
static void getStatusColor(int status, int &rval, int &gval, int &bval)
Definition: SiPixelUtility.cc:74
cms::dd::split
std::vector< std::string_view > split(std::string_view, const char *)
dqmdumpme.first
first
Definition: dqmdumpme.py:55
SiPixelUtility::getQTestNameList
static std::vector< std::string > getQTestNameList(MonitorElement *me)
Definition: SiPixelUtility.cc:145
std::size
constexpr auto size(const C &c) -> decltype(c.size())
Definition: cuda_cxx17.h:13
SiPixelUtility.h
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
SiPixelUtility::createStatusLegendMessages
static void createStatusLegendMessages(std::map< std::string, std::pair< int, double >> &messages)
Definition: SiPixelUtility.cc:309
compare.hist
hist
Definition: compare.py:376
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
SiPixelUtility::computeHistoBin
static int computeHistoBin(std::string &module_path)
Definition: SiPixelUtility.cc:167
SiPixelContinuousPalette.h
SiPixelUtility::split
static void split(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
Definition: SiPixelUtility.cc:53
dqm::qstatus::OTHER
static const int OTHER
Definition: MonitorElement.h:47
SiPixelUtility::sourceCodeMap
static std::map< std::string, std::string > sourceCodeMap()
Definition: SiPixelUtility.cc:277
SiPixelContinuousPalette::r
constexpr int r[]
Definition: SiPixelContinuousPalette.h:16
SiPixelUtility::computeErrorCode
static int computeErrorCode(int status)
Definition: SiPixelUtility.cc:150
createfilelist.int
int
Definition: createfilelist.py:10
SiPixelUtility::fillPaveText
static void fillPaveText(TPaveText *pave, const std::map< std::string, std::pair< int, double >> &messages)
Definition: SiPixelUtility.cc:264
module
Definition: vlib.h:198
shell
Definition: shell.py:1
type
type
Definition: HCALResponse.h:21
std
Definition: JetResolutionObject.h:76
SiPixelUtility::getStatus
static int getStatus(MonitorElement *me)
Definition: SiPixelUtility.cc:129
PVValHelper::ladder
Definition: PVValidationHelpers.h:72
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
contentValuesCheck.messages
messages
Definition: contentValuesCheck.py:44
dqm::qstatus::STATUS_OK
static const int STATUS_OK
Definition: MonitorElement.h:52
genParticles_cff.map
map
Definition: genParticles_cff.py:11
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
SiPixelUtility::getMEList
static int getMEList(std::string name, std::vector< std::string > &values)
dqm::qstatus::ERROR
static const int ERROR
Definition: MonitorElement.h:54