CMS 3D CMS Logo

ESIntercalibConstants_PayloadInspector.cc
Go to the documentation of this file.
4 
5 // the data format of the condition to be inspected
9 
10 #include <memory>
11 #include <sstream>
12 
13 #include "TStyle.h"
14 #include "TH2F.h"
15 #include "TCanvas.h"
16 #include "TLine.h"
17 #include "TLatex.h"
18 
19 namespace {
20  enum { kESChannels = 137216 };
21  enum { IX_MIN = 1, IY_MIN = 1, IX_MAX = 40, IY_MAX = 40 }; // endcaps lower and upper bounds on x and y
22 
23  /*********************************************************
24  2d plot of ES channel status of 1 IOV
25  *********************************************************/
26  class ESIntercalibConstantsPlot : public cond::payloadInspector::PlotImage<ESIntercalibConstants> {
27  public:
28  ESIntercalibConstantsPlot() : cond::payloadInspector::PlotImage<ESIntercalibConstants>("ES IntercalibConstants") {
29  setSingleIov(true);
30  }
31  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
32  TH2F*** esmap = new TH2F**[2];
33  std::string title[2][2] = {{"ES+F", "ES-F"}, {"ES+R", "ES-R"}};
34  for (int plane = 0; plane < 2; plane++) {
35  esmap[plane] = new TH2F*[2];
36  for (int side = 0; side < 2; side++)
37  esmap[plane][side] = new TH2F(
38  Form("esmap%i%i", plane, side), title[plane][side].c_str(), IX_MAX, 0, IX_MAX, IY_MAX, 0, IY_MAX);
39  }
40  unsigned int run = 0;
41  float valmin = 999.;
42  auto iov = iovs.front();
43  std::shared_ptr<ESIntercalibConstants> payload = fetchPayload(std::get<1>(iov));
44  run = std::get<0>(iov);
45  if (payload.get()) {
46  // looping over all the ES channels
47  for (int id = 0; id < kESChannels; id++)
48  if (ESDetId::validHashIndex(id)) {
49  ESDetId myESId = ESDetId::unhashIndex(id);
50  int side = myESId.zside(); // -1, 1
51  if (side < 0)
52  side = 1;
53  else
54  side = 0;
55  int plane = myESId.plane() - 1; // 1, 2
56  if (side < 0 || side > 1 || plane < 0 || plane > 1) {
57  std::cout << " channel " << id << " side " << myESId.zside() << " plane " << myESId.plane() << std::endl;
58  return false;
59  }
60  ESIntercalibConstants::const_iterator IC_it = payload->find(myESId);
61  float value = *IC_it;
62  // if(id < 64) std::cout << " channel " << id << " value " << value << std::endl;
63  if (myESId.strip() == 1) { // we get 32 times the same value, plot it only once!
64  esmap[plane][side]->Fill(myESId.six() - 1, myESId.siy() - 1, value);
65  if (value < valmin)
66  valmin = value;
67  }
68  } // validHashIndex
69  } // payload
70 
71  gStyle->SetOptStat(0);
72  gStyle->SetPalette(1);
73  TCanvas canvas("CC map", "CC map", 1680, 1320);
74  TLatex t1;
75  t1.SetNDC();
76  t1.SetTextAlign(26);
77  t1.SetTextSize(0.05);
78  t1.DrawLatex(0.5, 0.96, Form("ES Intercalib Constants, IOV %i", run));
79  t1.SetTextSize(0.025);
80 
81  float xmi[2] = {0.0, 0.5};
82  float xma[2] = {0.5, 1.0};
83  TPad*** pad = new TPad**[2];
84  for (int plane = 0; plane < 2; plane++) {
85  pad[plane] = new TPad*[2];
86  for (int side = 0; side < 2; side++) {
87  float yma = 0.94 - (0.46 * plane);
88  float ymi = yma - 0.44;
89  pad[plane][side] =
90  new TPad(Form("p_%i_%i", plane, side), Form("p_%i_%i", plane, side), xmi[side], ymi, xma[side], yma);
91  pad[plane][side]->Draw();
92  }
93  }
94 
95  int min = valmin * 10 - 1.;
96  valmin = (float)min / 10.;
97  for (int side = 0; side < 2; side++) {
98  for (int plane = 0; plane < 2; plane++) {
99  pad[plane][side]->cd();
100  esmap[plane][side]->Draw("colz1");
101  esmap[plane][side]->SetMinimum(valmin);
102  DrawES(plane, side);
103  }
104  }
105 
106  std::string ImageName(m_imageFileName);
107  canvas.SaveAs(ImageName.c_str());
108  return true;
109  } // fill method
110  };
111 
112  /************************************************************************
113  2d plot of ES channel status difference between 2 IOVs
114  ************************************************************************/
115  class ESIntercalibConstantsDiff : public cond::payloadInspector::PlotImage<ESIntercalibConstants> {
116  public:
117  ESIntercalibConstantsDiff()
118  : cond::payloadInspector::PlotImage<ESIntercalibConstants>("ES IntercalibConstants difference") {
119  setSingleIov(false);
120  }
121  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
122  TH2F*** esmap = new TH2F**[2];
123  std::string title[2][2] = {{"ES+F", "ES-F"}, {"ES+R", "ES-R"}};
124  for (int plane = 0; plane < 2; plane++) {
125  esmap[plane] = new TH2F*[2];
126  for (int side = 0; side < 2; side++)
127  esmap[plane][side] = new TH2F(
128  Form("esmap%i%i", plane, side), title[plane][side].c_str(), IX_MAX, 0, IX_MAX, IY_MAX, 0, IY_MAX);
129  }
130  unsigned int run[2], irun = 0;
131  float val[kESChannels], valmin = 999.;
132  for (auto const& iov : iovs) {
133  std::shared_ptr<ESIntercalibConstants> payload = fetchPayload(std::get<1>(iov));
134  run[irun] = std::get<0>(iov);
135  // std::cout << " irun " << irun << " IOV " << run[irun] << std::endl;
136  if (payload.get()) {
137  for (int id = 0; id < kESChannels; id++) // looping over all the ES channels
138  if (ESDetId::validHashIndex(id)) {
139  ESDetId myESId = ESDetId::unhashIndex(id);
140  // ESIntercalibConstantsCode status_it = (payload->getMap())[myESId];
141  ESIntercalibConstants::const_iterator IC_it = payload->find(myESId);
142  float value = *IC_it;
143  // int status = status_it.getStatusCode();
144  if (irun == 0)
145  val[id] = value;
146  else {
147  int side = myESId.zside(); // -1, 1
148  if (side < 0)
149  side = 1;
150  else
151  side = 0;
152  int plane = myESId.plane() - 1; // 1, 2
153  if (side < 0 || side > 1 || plane < 0 || plane > 1) {
154  std::cout << " channel " << id << " side " << myESId.zside() << " plane " << myESId.plane()
155  << std::endl;
156  return false;
157  }
158  // int diff = status - stat[id];
159  int diff = value - val[id];
160  if (myESId.strip() == 1) { // we get 32 times the same value, plot it only once!
161  esmap[plane][side]->Fill(myESId.six() - 1, myESId.siy() - 1, diff);
162  if (diff < valmin)
163  valmin = diff;
164  }
165  } // 2nd IOV
166  } // validHashIndex
167  } // payload
168  irun++;
169  } // loop over IOVs
170 
171  gStyle->SetOptStat(0);
172  gStyle->SetPalette(1);
173  TCanvas canvas("CC map", "CC map", 1680, 1320);
174  TLatex t1;
175  t1.SetNDC();
176  t1.SetTextAlign(26);
177  t1.SetTextSize(0.05);
178  t1.DrawLatex(0.5, 0.96, Form("ES Intercalib Constants, IOV %i - %i", run[1], run[0]));
179  t1.SetTextSize(0.025);
180 
181  float xmi[2] = {0.0, 0.5};
182  float xma[2] = {0.5, 1.0};
183  TPad*** pad = new TPad**[2];
184  for (int plane = 0; plane < 2; plane++) {
185  pad[plane] = new TPad*[2];
186  for (int side = 0; side < 2; side++) {
187  float yma = 0.94 - (0.46 * plane);
188  float ymi = yma - 0.44;
189  pad[plane][side] =
190  new TPad(Form("p_%i_%i", plane, side), Form("p_%i_%i", plane, side), xmi[side], ymi, xma[side], yma);
191  pad[plane][side]->Draw();
192  }
193  }
194 
195  int min = valmin * 10 - 1.;
196  valmin = (float)min / 10.;
197  for (int side = 0; side < 2; side++) {
198  for (int plane = 0; plane < 2; plane++) {
199  pad[plane][side]->cd();
200  esmap[plane][side]->Draw("colz1");
201  esmap[plane][side]->SetMinimum(valmin);
202  DrawES(plane, side);
203  }
204  }
205 
206  std::string ImageName(m_imageFileName);
207  canvas.SaveAs(ImageName.c_str());
208  return true;
209  } // fill method
210  };
211 } // namespace
212 
213 // Register the classes as boost python plugin
215  PAYLOAD_INSPECTOR_CLASS(ESIntercalibConstantsPlot);
216  PAYLOAD_INSPECTOR_CLASS(ESIntercalibConstantsDiff);
217 }
change_name.diff
diff
Definition: change_name.py:13
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
ESIntercalibConstants.h
IX_MAX
Definition: EcalFloatCondObjectContainerUtils.h:20
DrawES
void DrawES(int plane, int side)
Definition: ESDrawUtils.h:4
IY_MAX
Definition: EcalFloatCondObjectContainerUtils.h:21
min
T min(T a, T b)
Definition: MathUtil.h:58
PayloadInspector.h
ESDetId::strip
int strip() const
Definition: ESDetId.h:47
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ESDrawUtils.h
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
ESDetId
Definition: ESDetId.h:15
ESDetId.h
PayloadInspectorModule.h
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
ESCondObjectContainer::const_iterator
std::vector< Item >::const_iterator const_iterator
Definition: ESCondObjectContainer.h:17
jets_cff.payload
payload
Definition: jets_cff.py:34
PAYLOAD_INSPECTOR_MODULE
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: PayloadInspectorModule.h:8
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond
Definition: plugin.cc:23
Time.h
IY_MIN
Definition: EcalFloatCondObjectContainerUtils.h:19
cond::payloadInspector::PlotImage::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:840
value
Definition: value.py:1
ESCondObjectContainer
Definition: ESCondObjectContainer.h:11
overlapproblemtsosanalyzer_cfi.title
title
Definition: overlapproblemtsosanalyzer_cfi.py:7
ESDetId::plane
int plane() const
Definition: ESDetId.h:41
ESDetId::six
int six() const
Definition: ESDetId.h:43
heppy_batch.val
val
Definition: heppy_batch.py:351
writedatasetfile.run
run
Definition: writedatasetfile.py:27
ESDetId::unhashIndex
static ESDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: ESDetId.cc:32
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
cond::payloadInspector::PlotImpl::fill
virtual bool fill()=0
relativeConstraints.value
value
Definition: relativeConstraints.py:53
cond::payloadInspector::PlotImage
Definition: PayloadInspector.h:829
ESDetId::validHashIndex
static bool validHashIndex(int hi)
Definition: ESDetId.h:59
ESDetId::siy
int siy() const
Definition: ESDetId.h:45
IX_MIN
Definition: EcalFloatCondObjectContainerUtils.h:18
ESDetId::zside
int zside() const
Definition: ESDetId.h:39