CMS 3D CMS Logo

EcalLaserAPDPNRatiosRef_PayloadInspector.cc
Go to the documentation of this file.
8 // the data format of the condition to be inspected
10 
11 #include "TH2F.h"
12 #include "TCanvas.h"
13 #include "TStyle.h"
14 #include "TLine.h"
15 #include "TLatex.h"
16 
17 #include <memory>
18 #include <sstream>
19 
20 namespace {
21  enum { kEBChannels = 61200, kEEChannels = 14648 };
22  enum {
23  MIN_IETA = 1,
24  MIN_IPHI = 1,
25  MAX_IETA = 85,
26  MAX_IPHI = 360,
27  EBhistEtaMax = 171
28  }; // barrel lower and upper bounds on eta and phi
29  enum {
30  IX_MIN = 1,
31  IY_MIN = 1,
32  IX_MAX = 100,
33  IY_MAX = 100,
34  EEhistXMax = 220
35  }; // endcaps lower and upper bounds on x and y
36 
37  /*******************************************************
38 
39  2d histogram of ECAL barrel Laser APDPN Ratios Ref of 1 IOV
40 
41  *******************************************************/
42 
43  // inherit from one of the predefined plot class: Histogram2D
44  class EcalLaserAPDPNRatiosRefEBMap : public cond::payloadInspector::Histogram2D<EcalLaserAPDPNRatiosRef> {
45  public:
46  EcalLaserAPDPNRatiosRefEBMap()
47  : cond::payloadInspector::Histogram2D<EcalLaserAPDPNRatiosRef>("ECAL Barrel Laser APDPN Ratios Ref- map ",
48  "iphi",
49  MAX_IPHI,
50  MIN_IPHI,
51  MAX_IPHI + 1,
52  "ieta",
54  -MAX_IETA,
55  MAX_IETA + 1) {
56  Base::setSingleIov(true);
57  }
58 
59  // Histogram2D::fill (virtual) needs be overridden - the implementation should use fillWithValue
60  bool fill() override {
61  auto tag = PlotBase::getTag<0>();
62  for (auto const& iov : tag.iovs) {
63  std::shared_ptr<EcalLaserAPDPNRatiosRef> payload = Base::fetchPayload(std::get<1>(iov));
64  if (payload.get()) {
65  // looping over the EB channels, via the dense-index, mapped into EBDetId's
66  if (payload->barrelItems().empty())
67  return false;
68  // set to -1 for ieta 0 (no crystal)
69  for (int iphi = MIN_IPHI; iphi < MAX_IPHI + 1; iphi++)
70  fillWithValue(iphi, 0, -1);
71 
72  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
73  uint32_t rawid = EBDetId::unhashIndex(cellid);
74 
75  // check the existence of ECAL LaserAPDPNRatiosRef, for a given ECAL barrel channel
77  if (value_ptr == payload->end())
78  continue; // cell absent from payload
79 
80  float weight = (float)(*value_ptr);
81 
82  // fill the Histogram2D here
83  fillWithValue((EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), weight);
84  } // loop over cellid
85  } // if payload.get()
86  } // loop over IOV's (1 in this case)
87 
88  return true;
89 
90  } //fill method
91  };
92 
93  /*******************************************************
94 
95  2d histogram of ECAL EndCaps Laser APDPN Ratios Ref of 1 IOV
96 
97  *******************************************************/
98 
99  class EcalLaserAPDPNRatiosRefEEMap : public cond::payloadInspector::Histogram2D<EcalLaserAPDPNRatiosRef> {
100  private:
101  int EEhistSplit = 20;
102 
103  public:
104  EcalLaserAPDPNRatiosRefEEMap()
105  : cond::payloadInspector::Histogram2D<EcalLaserAPDPNRatiosRef>("ECAL Endcap Laser APDPN Ratios Ref- map ",
106  "ix",
107  EEhistXMax,
108  IX_MIN,
109  EEhistXMax + 1,
110  "iy",
111  IY_MAX,
112  IY_MIN,
113  IY_MAX + 1) {
114  Base::setSingleIov(true);
115  }
116 
117  bool fill() override {
118  auto tag = PlotBase::getTag<0>();
119  for (auto const& iov : tag.iovs) {
120  std::shared_ptr<EcalLaserAPDPNRatiosRef> payload = Base::fetchPayload(std::get<1>(iov));
121  if (payload.get()) {
122  if (payload->endcapItems().empty())
123  return false;
124 
125  // set to -1 everywhwere
126  for (int ix = IX_MIN; ix < EEhistXMax + 1; ix++)
127  for (int iy = IY_MAX; iy < IY_MAX + 1; iy++)
128  fillWithValue(ix, iy, -1);
129 
130  for (int cellid = 0; cellid < EEDetId::kSizeForDenseIndexing; ++cellid) { // loop on EE cells
131  if (EEDetId::validHashIndex(cellid)) {
132  uint32_t rawid = EEDetId::unhashIndex(cellid);
133  EcalFloatCondObjectContainer::const_iterator value_ptr = payload->find(rawid);
134  if (value_ptr == payload->end())
135  continue; // cell absent from payload
136 
137  float weight = (float)(*value_ptr);
138  EEDetId myEEId(rawid);
139  if (myEEId.zside() == -1)
140  fillWithValue(myEEId.ix(), myEEId.iy(), weight);
141  else
142  fillWithValue(myEEId.ix() + IX_MAX + EEhistSplit, myEEId.iy(), weight);
143  } // validDetId
144  } // loop over cellid
145 
146  } // payload
147  } // loop over IOV's (1 in this case)
148  return true;
149  } // fill method
150  };
151 
152  /*************************************************
153  2d plot of Ecal Laser APDPN Ratios Ref of 1 IOV
154  *************************************************/
155  class EcalLaserAPDPNRatiosRefPlot : public cond::payloadInspector::PlotImage<EcalLaserAPDPNRatiosRef> {
156  public:
157  EcalLaserAPDPNRatiosRefPlot()
158  : cond::payloadInspector::PlotImage<EcalLaserAPDPNRatiosRef>("Ecal Laser APDPN Ratios Ref - map ") {
159  setSingleIov(true);
160  }
161 
162  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
163  TH2F* barrel =
164  new TH2F("EB", "Laser APDPN Ratios Ref EB", MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
165  TH2F* endc_p =
166  new TH2F("EE+", "Laser APDPN Ratios Ref EE+", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
167  TH2F* endc_m =
168  new TH2F("EE-", "Laser APDPN Ratios Ref EE-", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
169 
170  auto iov = iovs.front();
171  std::shared_ptr<EcalLaserAPDPNRatiosRef> payload = fetchPayload(std::get<1>(iov));
172  unsigned int run = std::get<0>(iov);
173 
174  if (payload.get()) {
175  if (payload->barrelItems().empty())
176  return false;
177 
178  fillEBMap_SingleIOV<EcalLaserAPDPNRatiosRef>(payload, barrel);
179 
180  if (payload->endcapItems().empty())
181  return false;
182 
183  fillEEMap_SingleIOV<EcalLaserAPDPNRatiosRef>(payload, endc_m, endc_p);
184 
185  } // payload
186 
187  gStyle->SetPalette(1);
188  gStyle->SetOptStat(0);
189  TCanvas canvas("CC map", "CC map", 1600, 450);
190  TLatex t1;
191  t1.SetNDC();
192  t1.SetTextAlign(26);
193  t1.SetTextSize(0.04);
194  t1.DrawLatex(0.5, 0.96, Form("Ecal Laser APDPN Ratios Ref, IOV %i", run));
195 
196  float xmi[3] = {0.0, 0.24, 0.76};
197  float xma[3] = {0.24, 0.76, 1.00};
198  TPad** pad = new TPad*;
199  for (int obj = 0; obj < 3; obj++) {
200  pad[obj] = new TPad(Form("p_%i", obj), Form("p_%i", obj), xmi[obj], 0.0, xma[obj], 0.94);
201  pad[obj]->Draw();
202  }
203  // EcalDrawMaps ICMap;
204  pad[0]->cd();
205  // ICMap.DrawEE(endc_m, 0., 2.);
206  DrawEE(endc_m, 0., 2.5);
207  pad[1]->cd();
208  // ICMap.DrawEB(barrel, 0., 2.);
209  DrawEB(barrel, 0., 2.5);
210  pad[2]->cd();
211  // ICMap.DrawEE(endc_p, 0., 2.);
212  DrawEE(endc_p, 0., 2.5);
213 
214  std::string ImageName(m_imageFileName);
215  canvas.SaveAs(ImageName.c_str());
216  return true;
217  } // fill method
218  };
219 
220  /*****************************************************************
221  2d plot of Ecal Laser APDPN Ratios Ref difference between 2 IOVs
222  *****************************************************************/
223  class EcalLaserAPDPNRatiosRefDiff : public cond::payloadInspector::PlotImage<EcalLaserAPDPNRatiosRef> {
224  public:
225  EcalLaserAPDPNRatiosRefDiff()
226  : cond::payloadInspector::PlotImage<EcalLaserAPDPNRatiosRef>("Ecal Laser APDPN Ratios Ref difference ") {
227  setSingleIov(false);
228  }
229 
230  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
231  TH2F* barrel =
232  new TH2F("EB", "Laser APDPN Ratios Ref EB", MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
233  TH2F* endc_p =
234  new TH2F("EE+", "Laser APDPN Ratios Ref EE+", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
235  TH2F* endc_m =
236  new TH2F("EE-", "Laser APDPN Ratios Ref EE-", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
237  float pEBmin, pEEmin, pEBmax, pEEmax;
238  pEBmin = 10.;
239  pEEmin = 10.;
240  pEBmax = -10.;
241  pEEmax = -10.;
242 
243  unsigned int run[2], irun = 0;
244  float pEB[kEBChannels], pEE[kEEChannels];
245  for (auto const& iov : iovs) {
246  std::shared_ptr<EcalLaserAPDPNRatiosRef> payload = fetchPayload(std::get<1>(iov));
247  run[irun] = std::get<0>(iov);
248 
249  if (payload.get()) {
250  if (payload->barrelItems().empty())
251  return false;
252 
253  fillEBMap_DiffIOV<EcalLaserAPDPNRatiosRef>(payload, barrel, irun, pEB, pEBmin, pEBmax);
254 
255  if (payload->endcapItems().empty())
256  return false;
257 
258  fillEEMap_DiffIOV<EcalLaserAPDPNRatiosRef>(payload, endc_m, endc_p, irun, pEE, pEEmin, pEEmax);
259 
260  } // payload
261  irun++;
262 
263  } // loop over IOVs
264 
265  gStyle->SetPalette(1);
266  gStyle->SetOptStat(0);
267  TCanvas canvas("CC map", "CC map", 1600, 450);
268  TLatex t1;
269  t1.SetNDC();
270  t1.SetTextAlign(26);
271  t1.SetTextSize(0.04);
272  t1.DrawLatex(0.5, 0.96, Form("Ecal Laser APDPN Ratios Ref Diff, IOV %i - %i", run[1], run[0]));
273 
274  float xmi[3] = {0.0, 0.24, 0.76};
275  float xma[3] = {0.24, 0.76, 1.00};
276  TPad** pad = new TPad*;
277 
278  for (int obj = 0; obj < 3; obj++) {
279  pad[obj] = new TPad(Form("p_%i", obj), Form("p_%i", obj), xmi[obj], 0.0, xma[obj], 0.94);
280  pad[obj]->Draw();
281  }
282 
283  pad[0]->cd();
284  DrawEE(endc_m, pEEmin, pEEmax);
285  pad[1]->cd();
286  DrawEB(barrel, pEBmin, pEBmax);
287  pad[2]->cd();
288  DrawEE(endc_p, pEEmin, pEEmax);
289 
290  std::string ImageName(m_imageFileName);
291  canvas.SaveAs(ImageName.c_str());
292  return true;
293  } // fill method
294  };
295 
296  /*******************************************************
297  2d plot of Ecal Laser APDPN Ratios Ref Summary of 1 IOV
298  *******************************************************/
299  class EcalLaserAPDPNRatiosRefSummaryPlot : public cond::payloadInspector::PlotImage<EcalLaserAPDPNRatiosRef> {
300  public:
301  EcalLaserAPDPNRatiosRefSummaryPlot()
302  : cond::payloadInspector::PlotImage<EcalLaserAPDPNRatiosRef>("Ecal Laser APDPN RatiosRef Summary- map ") {
303  setSingleIov(true);
304  }
305 
306  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
307  auto iov = iovs.front();
308  std::shared_ptr<EcalLaserAPDPNRatiosRef> payload = fetchPayload(std::get<1>(iov));
309  unsigned int run = std::get<0>(iov);
310  TH2F* align;
311  int NbRows;
312 
313  if (payload.get()) {
314  NbRows = 2;
315  align = new TH2F("", "", 0, 0, 0, 0, 0, 0);
316 
317  float mean_x_EB = 0.0f;
318  float mean_x_EE = 0.0f;
319 
320  float rms_EB = 0.0f;
321  float rms_EE = 0.0f;
322 
323  int num_x_EB = 0;
324  int num_x_EE = 0;
325 
326  payload->summary(mean_x_EB, rms_EB, num_x_EB, mean_x_EE, rms_EE, num_x_EE);
328  align, "Ecal Laser APDPN Ratios Ref", mean_x_EB, rms_EB, num_x_EB, mean_x_EE, rms_EE, num_x_EE);
329 
330  } else
331  return false;
332 
333  gStyle->SetPalette(1);
334  gStyle->SetOptStat(0);
335  TCanvas canvas("CC map", "CC map", 1000, 1000);
336  TLatex t1;
337  t1.SetNDC();
338  t1.SetTextAlign(26);
339  t1.SetTextSize(0.04);
340  t1.SetTextColor(2);
341  t1.DrawLatex(0.5, 0.96, Form("Ecal Laser APDPN Ratios Ref Summary, IOV %i", run));
342 
343  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
344  pad->Draw();
345  pad->cd();
346  align->Draw("TEXT");
347 
348  drawTable(NbRows, 4);
349 
350  std::string ImageName(m_imageFileName);
351  canvas.SaveAs(ImageName.c_str());
352 
353  return true;
354  }
355  };
356 
357 } // namespace
358 
359 // Register the classes as boost python plugin
361  PAYLOAD_INSPECTOR_CLASS(EcalLaserAPDPNRatiosRefEBMap);
362  PAYLOAD_INSPECTOR_CLASS(EcalLaserAPDPNRatiosRefEEMap);
363  PAYLOAD_INSPECTOR_CLASS(EcalLaserAPDPNRatiosRefPlot);
364  PAYLOAD_INSPECTOR_CLASS(EcalLaserAPDPNRatiosRefDiff);
365  PAYLOAD_INSPECTOR_CLASS(EcalLaserAPDPNRatiosRefSummaryPlot);
366 }
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
EcalFloatCondObjectContainerUtils.h
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
align
Definition: AlignableIndexer.h:30
kEEChannels
Definition: EcalFloatCondObjectContainerUtils.h:9
MAX_IPHI
Definition: EcalFloatCondObjectContainerUtils.h:14
IX_MAX
Definition: EcalFloatCondObjectContainerUtils.h:20
IY_MAX
Definition: EcalFloatCondObjectContainerUtils.h:21
EBDetId
Definition: EBDetId.h:17
mps_merge.weight
weight
Definition: mps_merge.py:88
EEDetId::unhashIndex
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
PayloadInspector.h
EcalLaserAPDPNRatiosRef.h
EBDetId.h
EEDetId.h
EBDetId::unhashIndex
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
EcalCondObjectContainer< float >
PayloadInspectorModule.h
DrawEE
void DrawEE(TH2F *endc, float min, float max)
Definition: EcalDrawUtils.h:29
fillTableWithSummary
void fillTableWithSummary(TH2F *&align, std::string title, const float &mean_x_EB, const float &rms_EB, const int &num_x_EB, const float &mean_x_EE, const float &rms_EE, const int &num_x_EE)
Definition: EcalFloatCondObjectContainerUtils.h:142
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
EEDetId::kSizeForDenseIndexing
Definition: EEDetId.h:329
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
DrawEB
void DrawEB(TH2F *ebmap, float min, float max)
Definition: EcalDrawUtils.h:4
MIN_IETA
Definition: EcalFloatCondObjectContainerUtils.h:11
jets_cff.payload
payload
Definition: jets_cff.py:34
PAYLOAD_INSPECTOR_MODULE
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: PayloadInspectorModule.h:8
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
EEDetId
Definition: EEDetId.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond
Definition: plugin.cc:23
ntuplemaker.fill
fill
Definition: ntuplemaker.py:304
cond::payloadInspector::Histogram2D
Definition: PayloadInspector.h:748
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
Time.h
IY_MIN
Definition: EcalFloatCondObjectContainerUtils.h:19
MIN_IPHI
Definition: EcalFloatCondObjectContainerUtils.h:12
EEhistXMax
Definition: EcalFloatCondObjectContainerUtils.h:22
EEDetId::validHashIndex
static bool validHashIndex(int i)
Definition: EEDetId.h:239
EcalDrawUtils.h
EBhistEtaMax
Definition: EcalFloatCondObjectContainerUtils.h:15
writedatasetfile.run
run
Definition: writedatasetfile.py:27
drawTable
void drawTable(int nbRows, int nbColumns)
Definition: EcalDrawUtils.h:91
cond::payloadInspector::PlotImage
Definition: PayloadInspector.h:829
EBDetId::kSizeForDenseIndexing
Definition: EBDetId.h:155
EcalCondObjectContainer< float >::const_iterator
std::vector< Item >::const_iterator const_iterator
Definition: EcalCondObjectContainer.h:19
EBDetId::MIN_HASH
static const int MIN_HASH
Definition: EBDetId.h:149
kEBChannels
Definition: EcalFloatCondObjectContainerUtils.h:9
IX_MIN
Definition: EcalFloatCondObjectContainerUtils.h:18
weight
Definition: weight.py:1
MAX_IETA
Definition: EcalFloatCondObjectContainerUtils.h:13