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 <ctime>
7 #include "TH1.h"
8 #include "TH2.h"
9 #include "TStyle.h"
10 #include "TPaveText.h"
11 #include "TStyle.h"
13 
14 namespace RunInfoPI {
15 
16  enum state { fake = 0, valid = 1, invalid = 2 };
17 
18  // values are taken from https://github.com/cms-sw/cmssw/blob/master/MagneticField/GeomBuilder/plugins/VolumeBasedMagneticFieldESProducerFromDB.cc#L74-L75
19  constexpr std::array<int, 7> nominalCurrents{{-1, 0, 9558, 14416, 16819, 18268, 19262}};
20  constexpr std::array<float, 7> nominalFields{{3.8, 0., 2., 3., 3.5, 3.8, 4.}};
21 
22  // all parameter than can be displayed
23  enum parameters {
24  m_run, // int
25  m_start_time_ll, // long long;
26  m_stop_time_ll, // long long
27  m_start_current, // float
28  m_stop_current, // float
29  m_avg_current, // float
30  m_max_current, // float
31  m_min_current, // float
33  m_fedIN, // unsigned int
34  m_BField, // float
36  };
37 
38  /************************************************/
39  float theBField(const float current) {
40  // logic is taken from https://github.com/cms-sw/cmssw/blob/master/MagneticField/GeomBuilder/plugins/VolumeBasedMagneticFieldESProducerFromDB.cc#L156
41 
42  int i = 0;
43  for (; i < (int)nominalFields.size() - 1; i++) {
44  if (2 * current < nominalCurrents[i] + nominalCurrents[i + 1]) {
45  return nominalFields[i];
46  }
47  }
48  return nominalFields[i];
49  }
50 
51  /************************************************/
52  float runDuration(const std::shared_ptr<RunInfo>& payload) {
53  // calculation of the run duration in seconds
54  time_t start_time = payload->m_start_time_ll;
55  ctime(&start_time);
56  time_t end_time = payload->m_stop_time_ll;
57  ctime(&end_time);
58  return difftime(end_time, start_time) / 1.0e+6;
59  }
60 
61  /************************************************/
62  std::string runStartTime(const std::shared_ptr<RunInfo>& payload) {
63  const time_t start_time = payload->m_start_time_ll / 1.0e+6;
64  return std::asctime(std::gmtime(&start_time));
65  }
66 
67  /************************************************/
68  std::string runEndTime(const std::shared_ptr<RunInfo>& payload) {
69  const time_t end_time = payload->m_stop_time_ll / 1.0e+6;
70  return std::asctime(std::gmtime(&end_time));
71  }
72 
73  /************************************************/
75  switch (parameter) {
76  case m_run:
77  return "run number";
78  case m_start_time_ll:
79  return "start time";
80  case m_stop_time_ll:
81  return "stop time";
82  case m_start_current:
83  return "start current [A]";
84  case m_stop_current:
85  return "stop current [A]";
86  case m_avg_current:
87  return "average current [A]";
88  case m_max_current:
89  return "max current [A]";
90  case m_min_current:
91  return "min current [A]";
93  return "run duration [s]";
94  case m_fedIN:
95  return "n. FEDs";
96  case m_BField:
97  return "B-field intensity [T]";
98  default:
99  return "should never be here";
100  }
101  }
102 
103  /************************************************/
105  static int pcol[20];
106 
107  float rgb[20][3];
108 
109  for (int i = 0; i < 20; i++) {
110  if (i < 17) {
111  rgb[i][0] = 0.80 + 0.01 * i;
112  rgb[i][1] = 0.00 + 0.03 * i;
113  rgb[i][2] = 0.00;
114  } else if (i < 19) {
115  rgb[i][0] = 0.80 + 0.01 * i;
116  rgb[i][1] = 0.00 + 0.03 * i + 0.15 + 0.10 * (i - 17);
117  rgb[i][2] = 0.00;
118  } else if (i == 19) {
119  rgb[i][0] = 0.00;
120  rgb[i][1] = 0.80;
121  rgb[i][2] = 0.00;
122  }
123  pcol[i] = TColor::GetColor(rgb[i][0], rgb[i][1], rgb[i][2]);
124  }
125 
126  gStyle->SetPalette(20, pcol);
127 
128  if (obj) {
129  obj->SetMinimum(-1.e-15);
130  obj->SetMaximum(+1.0);
131  obj->SetOption("colz");
132  }
133  }
134 
135 }; // namespace RunInfoPI
136 #endif
RunInfoPI::runDuration
float runDuration(const std::shared_ptr< RunInfo > &payload)
Definition: RunInfoPayloadInspectoHelper.h:52
RunInfoPI::m_min_current
Definition: RunInfoPayloadInspectoHelper.h:31
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
RunInfoPI::nominalCurrents
constexpr std::array< int, 7 > nominalCurrents
Definition: RunInfoPayloadInspectoHelper.h:19
pfMETsysShiftCorrections_cfi.parameter
parameter
Definition: pfMETsysShiftCorrections_cfi.py:118
RunInfoPI::invalid
Definition: RunInfoPayloadInspectoHelper.h:16
RunInfoPI::nominalFields
constexpr std::array< float, 7 > nominalFields
Definition: RunInfoPayloadInspectoHelper.h:20
RunInfoPI::m_stop_current
Definition: RunInfoPayloadInspectoHelper.h:28
RunInfoPI::m_start_current
Definition: RunInfoPayloadInspectoHelper.h:27
RunInfoPI::runStartTime
std::string runStartTime(const std::shared_ptr< RunInfo > &payload)
Definition: RunInfoPayloadInspectoHelper.h:62
RunInfoPI::m_run
Definition: RunInfoPayloadInspectoHelper.h:24
jets_cff.payload
payload
Definition: jets_cff.py:32
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RunInfoPI::END_OF_TYPES
Definition: RunInfoPayloadInspectoHelper.h:35
RunInfoPI::m_BField
Definition: RunInfoPayloadInspectoHelper.h:34
RunInfoPI::runEndTime
std::string runEndTime(const std::shared_ptr< RunInfo > &payload)
Definition: RunInfoPayloadInspectoHelper.h:68
createfilelist.int
int
Definition: createfilelist.py:10
RunInfoPI::fake
Definition: RunInfoPayloadInspectoHelper.h:16
RunInfoPI::theBField
float theBField(const float current)
Definition: RunInfoPayloadInspectoHelper.h:39
RunInfoPI::reportSummaryMapPalette
void reportSummaryMapPalette(TH2 *obj)
Definition: RunInfoPayloadInspectoHelper.h:104
RunInfoPI::parameters
parameters
Definition: RunInfoPayloadInspectoHelper.h:23
RunInfoPI
Definition: RunInfoPayloadInspectoHelper.h:14
RunInfoPI::m_max_current
Definition: RunInfoPayloadInspectoHelper.h:30
RunInfoPI::m_avg_current
Definition: RunInfoPayloadInspectoHelper.h:29
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
RunInfoPI::m_fedIN
Definition: RunInfoPayloadInspectoHelper.h:33
RunInfoPI::valid
Definition: RunInfoPayloadInspectoHelper.h:16
RunInfoPI::m_start_time_ll
Definition: RunInfoPayloadInspectoHelper.h:25
svgfig.rgb
def rgb(r, g, b, maximum=1.)
Definition: svgfig.py:40
RunInfoPI::m_stop_time_ll
Definition: RunInfoPayloadInspectoHelper.h:26
RunInfoPI::getStringFromTypeEnum
std::string getStringFromTypeEnum(const parameters &parameter)
Definition: RunInfoPayloadInspectoHelper.h:74
RunInfoPI::m_run_interval_seconds
Definition: RunInfoPayloadInspectoHelper.h:32
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37