CMS 3D CMS Logo

RunInfoPayloadInspectoHelper.h
Go to the documentation of this file.
1 #ifndef CONDCORE_RUNINFOPLUGINS_RUNINFOPAYLOADINSPECTORHELPER_H
2 #define CONDCORE_RUNINFOPLUGINS_RUNINFOPAYLOADINSPECTORHELPER_H
3 
4 #include <vector>
5 #include <string>
6 #include "TH1.h"
7 #include "TH2.h"
8 #include "TStyle.h"
9 #include "TPaveText.h"
10 #include "TStyle.h"
12 
13 namespace RunInfoPI {
14 
15  // values are taken from https://github.com/cms-sw/cmssw/blob/master/MagneticField/GeomBuilder/plugins/VolumeBasedMagneticFieldESProducerFromDB.cc#L74-L75
16  constexpr std::array<int, 7> nominalCurrents{{-1, 0, 9558, 14416, 16819, 18268, 19262}};
17  constexpr std::array<float, 7> nominalFields{{3.8, 0., 2., 3., 3.5, 3.8, 4.}};
18 
19  // all parameter than can be displayed
20  enum parameters {
21  m_run, // int
22  m_start_time_ll, // long long;
23  m_stop_time_ll, // long long
24  m_start_current, // float
25  m_stop_current, // float
26  m_avg_current, // float
27  m_max_current, // float
28  m_min_current, // float
30  m_fedIN, // unsigned int
31  m_BField, // float
33  };
34 
35  /************************************************/
36  float theBField(const float current) {
37  // logic is taken from https://github.com/cms-sw/cmssw/blob/master/MagneticField/GeomBuilder/plugins/VolumeBasedMagneticFieldESProducerFromDB.cc#L156
38 
39  int i = 0;
40  for (; i < (int)nominalFields.size() - 1; i++) {
41  if (2 * current < nominalCurrents[i] + nominalCurrents[i + 1]) {
42  return nominalFields[i];
43  }
44  }
45  return nominalFields[i];
46  }
47 
48  /************************************************/
50  switch (parameter) {
51  case m_run:
52  return "run number";
53  case m_start_time_ll:
54  return "start time";
55  case m_stop_time_ll:
56  return "stop time";
57  case m_start_current:
58  return "start current [A]";
59  case m_stop_current:
60  return "stop current [A]";
61  case m_avg_current:
62  return "average current [A]";
63  case m_max_current:
64  return "max current [A]";
65  case m_min_current:
66  return "min current [A]";
68  return "run duration [#mus]";
69  case m_fedIN:
70  return "n. FEDs";
71  case m_BField:
72  return "B-field intensity [T]";
73  default:
74  return "should never be here";
75  }
76  }
77 
78  /************************************************/
80  static int pcol[20];
81 
82  float rgb[20][3];
83 
84  for (int i = 0; i < 20; i++) {
85  if (i < 17) {
86  rgb[i][0] = 0.80 + 0.01 * i;
87  rgb[i][1] = 0.00 + 0.03 * i;
88  rgb[i][2] = 0.00;
89  } else if (i < 19) {
90  rgb[i][0] = 0.80 + 0.01 * i;
91  rgb[i][1] = 0.00 + 0.03 * i + 0.15 + 0.10 * (i - 17);
92  rgb[i][2] = 0.00;
93  } else if (i == 19) {
94  rgb[i][0] = 0.00;
95  rgb[i][1] = 0.80;
96  rgb[i][2] = 0.00;
97  }
98  pcol[i] = TColor::GetColor(rgb[i][0], rgb[i][1], rgb[i][2]);
99  }
100 
101  gStyle->SetPalette(20, pcol);
102 
103  if (obj) {
104  obj->SetMinimum(-1.e-15);
105  obj->SetMaximum(+1.0);
106  obj->SetOption("colz");
107  }
108  }
109 
110 }; // namespace RunInfoPI
111 #endif
void reportSummaryMapPalette(TH2 *obj)
std::array< float, 7 > nominalFields
std::array< int, 7 > nominalCurrents
std::string getStringFromTypeEnum(const parameters &parameter)
float theBField(const float current)
def rgb(r, g, b, maximum=1.)
Definition: svgfig.py:40
#define constexpr