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 {m_run, // int
21  m_start_time_ll, // long long;
22  m_stop_time_ll, // long long
23  m_start_current, // float
24  m_stop_current, // float
25  m_avg_current, // float
26  m_max_current, // float
27  m_min_current, // float
29  m_fedIN, // unsigned int
30  m_BField, // float
32 
33  /************************************************/
34  float theBField (const float current){
35 
36  // logic is taken from https://github.com/cms-sw/cmssw/blob/master/MagneticField/GeomBuilder/plugins/VolumeBasedMagneticFieldESProducerFromDB.cc#L156
37 
38  int i=0;
39  for(;i<(int)nominalFields.size()-1;i++) {
40  if(2*current < nominalCurrents[i]+nominalCurrents[i+1] ){
41  return nominalFields[i];
42  }
43  }
44  return nominalFields[i];
45  }
46 
47  /************************************************/
49  switch(parameter){
50  case m_run : return "run number";
51  case m_start_time_ll : return "start time";
52  case m_stop_time_ll : return "stop time";
53  case m_start_current : return "start current [A]";
54  case m_stop_current : return "stop current [A]";
55  case m_avg_current : return "average current [A]";
56  case m_max_current : return "max current [A]";
57  case m_min_current : return "min current [A]";
58  case m_run_intervall_micros : return "run duration [#mus]";
59  case m_fedIN : return "n. FEDs";
60  case m_BField : return "B-field intensity [T]";
61  default: return "should never be here";
62  }
63  }
64 
65  /************************************************/
67 
68  static int pcol[20];
69 
70  float rgb[20][3];
71 
72  for( int i=0; i<20; i++ ) {
73  if ( i < 17 ){
74  rgb[i][0] = 0.80+0.01*i;
75  rgb[i][1] = 0.00+0.03*i;
76  rgb[i][2] = 0.00;
77  } else if ( i < 19 ) {
78  rgb[i][0] = 0.80+0.01*i;
79  rgb[i][1] = 0.00+0.03*i+0.15+0.10*(i-17);
80  rgb[i][2] = 0.00;
81  } else if ( i == 19 ){
82  rgb[i][0] = 0.00;
83  rgb[i][1] = 0.80;
84  rgb[i][2] = 0.00;
85  }
86  pcol[i] = TColor::GetColor(rgb[i][0], rgb[i][1], rgb[i][2]);
87  }
88 
89  gStyle->SetPalette(20, pcol);
90 
91  if( obj ){
92  obj->SetMinimum(-1.e-15);
93  obj->SetMaximum(+1.0);
94  obj->SetOption("colz");
95  }
96  }
97 
98 };
99 #endif
void reportSummaryMapPalette(TH2 *obj)
#define constexpr
std::array< float, 7 > nominalFields
std::string getStringFromTypeEnum(const parameters &parameter)
std::array< int, 7 > nominalCurrents
float theBField(const float current)
def rgb(r, g, b, maximum=1.)
Definition: svgfig.py:39