CMS 3D CMS Logo

EcalPFRecHitThresholds_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 PFRec Hit Thresholds of 1 IOV
40 
41  *******************************************************/
42 
43  // inherit from one of the predefined plot class: Histogram2D
44  class EcalPFRecHitThresholdsEBMap : public cond::payloadInspector::Histogram2D<EcalPFRecHitThresholds> {
45  public:
46  EcalPFRecHitThresholdsEBMap()
47  : cond::payloadInspector::Histogram2D<EcalPFRecHitThresholds>("ECAL Barrel PFRec Hit Thresholds- 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<EcalPFRecHitThresholds> 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 PFRec Hit Thresholds, 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 PFRec Hit Thresholds of 1 IOV
96 
97  *******************************************************/
98 
99  class EcalPFRecHitThresholdsEEMap : public cond::payloadInspector::Histogram2D<EcalPFRecHitThresholds> {
100  private:
101  int EEhistSplit = 20;
102 
103  public:
104  EcalPFRecHitThresholdsEEMap()
105  : cond::payloadInspector::Histogram2D<EcalPFRecHitThresholds>("ECAL Endcap PFRec Hit Thresholds- 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<EcalPFRecHitThresholds> 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 PFRec Hit Thresholds of 1 IOV
154  *************************************************/
155  class EcalPFRecHitThresholdsPlot : public cond::payloadInspector::PlotImage<EcalPFRecHitThresholds> {
156  public:
157  EcalPFRecHitThresholdsPlot()
158  : cond::payloadInspector::PlotImage<EcalPFRecHitThresholds>("Ecal PFRec Hit Thresholds - map ") {
159  setSingleIov(true);
160  }
161 
162  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
163  TH2F* barrel = new TH2F("EB", "mean EB", MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
164  TH2F* endc_p = new TH2F("EE+", "mean EE+", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
165  TH2F* endc_m = new TH2F("EE-", "mean EE-", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
166 
167  auto iov = iovs.front();
168  std::shared_ptr<EcalPFRecHitThresholds> payload = fetchPayload(std::get<1>(iov));
169  unsigned int run = std::get<0>(iov);
170 
171  if (payload.get()) {
172  if (payload->barrelItems().empty())
173  return false;
174 
175  fillEBMap_SingleIOV<EcalPFRecHitThresholds>(payload, barrel);
176 
177  if (payload->endcapItems().empty())
178  return false;
179 
180  fillEEMap_SingleIOV<EcalPFRecHitThresholds>(payload, endc_m, endc_p);
181 
182  } // payload
183 
184  gStyle->SetPalette(1);
185  gStyle->SetOptStat(0);
186  TCanvas canvas("CC map", "CC map", 1600, 450);
187  TLatex t1;
188  t1.SetNDC();
189  t1.SetTextAlign(26);
190  t1.SetTextSize(0.05);
191  t1.DrawLatex(0.5, 0.96, Form("Ecal PFRec Hit Thresholds, IOV %i", run));
192 
193  float xmi[3] = {0.0, 0.24, 0.76};
194  float xma[3] = {0.24, 0.76, 1.00};
195  TPad** pad = new TPad*;
196  for (int obj = 0; obj < 3; obj++) {
197  pad[obj] = new TPad(Form("p_%i", obj), Form("p_%i", obj), xmi[obj], 0.0, xma[obj], 0.94);
198  pad[obj]->Draw();
199  }
200  // EcalDrawMaps ICMap;
201  pad[0]->cd();
202  // ICMap.DrawEE(endc_m, 0., 2.);
203  DrawEE(endc_m, 0., 2.5);
204  pad[1]->cd();
205  // ICMap.DrawEB(barrel, 0., 2.);
206  DrawEB(barrel, 0., 2.5);
207  pad[2]->cd();
208  // ICMap.DrawEE(endc_p, 0., 2.);
209  DrawEE(endc_p, 0., 2.5);
210 
211  std::string ImageName(m_imageFileName);
212  canvas.SaveAs(ImageName.c_str());
213  return true;
214  } // fill method
215  };
216 
217  /*****************************************************************
218  2d plot of Ecal PFRec Hit Thresholds between 2 IOVs
219  *****************************************************************/
220  class EcalPFRecHitThresholdsDiff : public cond::payloadInspector::PlotImage<EcalPFRecHitThresholds> {
221  public:
222  EcalPFRecHitThresholdsDiff()
223  : cond::payloadInspector::PlotImage<EcalPFRecHitThresholds>("Ecal PFRec Hit Thresholds difference ") {
224  setSingleIov(false);
225  }
226 
227  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
228  TH2F* barrel = new TH2F("EB", "mean EB", MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
229  TH2F* endc_p = new TH2F("EE+", "mean EE+", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
230  TH2F* endc_m = new TH2F("EE-", "mean EE-", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
231  float pEBmin, pEEmin, pEBmax, pEEmax;
232  pEBmin = 10.;
233  pEEmin = 10.;
234  pEBmax = -10.;
235  pEEmax = -10.;
236 
237  unsigned int run[2], irun = 0;
238  float pEB[kEBChannels], pEE[kEEChannels];
239  for (auto const& iov : iovs) {
240  std::shared_ptr<EcalPFRecHitThresholds> payload = fetchPayload(std::get<1>(iov));
241  run[irun] = std::get<0>(iov);
242 
243  if (payload.get()) {
244  if (payload->barrelItems().empty())
245  return false;
246 
247  fillEBMap_DiffIOV<EcalPFRecHitThresholds>(payload, barrel, irun, pEB, pEBmin, pEBmax);
248 
249  if (payload->endcapItems().empty())
250  return false;
251 
252  fillEEMap_DiffIOV<EcalPFRecHitThresholds>(payload, endc_m, endc_p, irun, pEE, pEEmin, pEEmax);
253 
254  } // payload
255  irun++;
256 
257  } // loop over IOVs
258 
259  gStyle->SetPalette(1);
260  gStyle->SetOptStat(0);
261  TCanvas canvas("CC map", "CC map", 1600, 450);
262  TLatex t1;
263  t1.SetNDC();
264  t1.SetTextAlign(26);
265  t1.SetTextSize(0.05);
266  t1.DrawLatex(0.5, 0.96, Form("Ecal PFRec Hit Thresholds Diff, IOV %i - %i", run[1], run[0]));
267 
268  float xmi[3] = {0.0, 0.24, 0.76};
269  float xma[3] = {0.24, 0.76, 1.00};
270  TPad** pad = new TPad*;
271 
272  for (int obj = 0; obj < 3; obj++) {
273  pad[obj] = new TPad(Form("p_%i", obj), Form("p_%i", obj), xmi[obj], 0.0, xma[obj], 0.94);
274  pad[obj]->Draw();
275  }
276 
277  pad[0]->cd();
278  DrawEE(endc_m, pEEmin, pEEmax);
279  pad[1]->cd();
280  DrawEB(barrel, pEBmin, pEBmax);
281  pad[2]->cd();
282  DrawEE(endc_p, pEEmin, pEEmax);
283 
284  std::string ImageName(m_imageFileName);
285  canvas.SaveAs(ImageName.c_str());
286  return true;
287  } // fill method
288  };
289 
290  /*******************************************************
291  2d plot of Ecal PFRec Hit Thresholds Summary of 1 IOV
292  *******************************************************/
293  class EcalPFRecHitThresholdsSummaryPlot : public cond::payloadInspector::PlotImage<EcalPFRecHitThresholds> {
294  public:
295  EcalPFRecHitThresholdsSummaryPlot()
296  : cond::payloadInspector::PlotImage<EcalPFRecHitThresholds>("Ecal PFRec Hit Thresholds Summary - map ") {
297  setSingleIov(true);
298  }
299 
300  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
301  auto iov = iovs.front();
302  std::shared_ptr<EcalPFRecHitThresholds> payload = fetchPayload(std::get<1>(iov));
303  unsigned int run = std::get<0>(iov);
304  TH2F* align;
305  int NbRows;
306 
307  if (payload.get()) {
308  NbRows = 2;
309  align = new TH2F("", "", 0, 0, 0, 0, 0, 0);
310 
311  float mean_x_EB = 0.0f;
312  float mean_x_EE = 0.0f;
313 
314  float rms_EB = 0.0f;
315  float rms_EE = 0.0f;
316 
317  int num_x_EB = 0;
318  int num_x_EE = 0;
319 
320  payload->summary(mean_x_EB, rms_EB, num_x_EB, mean_x_EE, rms_EE, num_x_EE);
322  align, "Ecal PFRec Hit Thresholds", mean_x_EB, rms_EB, num_x_EB, mean_x_EE, rms_EE, num_x_EE);
323  } else
324  return false;
325 
326  gStyle->SetPalette(1);
327  gStyle->SetOptStat(0);
328  TCanvas canvas("CC map", "CC map", 1000, 1000);
329  TLatex t1;
330  t1.SetNDC();
331  t1.SetTextAlign(26);
332  t1.SetTextSize(0.04);
333  t1.SetTextColor(2);
334  t1.DrawLatex(0.5, 0.96, Form("Ecal PFRec Hit Thresholds Summary, IOV %i", run));
335 
336  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
337  pad->Draw();
338  pad->cd();
339  align->Draw("TEXT");
340 
341  drawTable(NbRows, 4);
342 
343  std::string ImageName(m_imageFileName);
344  canvas.SaveAs(ImageName.c_str());
345 
346  return true;
347  }
348  };
349 
350 } // namespace
351 
352 // Register the classes as boost python plugin
354  PAYLOAD_INSPECTOR_CLASS(EcalPFRecHitThresholdsEBMap);
355  PAYLOAD_INSPECTOR_CLASS(EcalPFRecHitThresholdsEEMap);
356  PAYLOAD_INSPECTOR_CLASS(EcalPFRecHitThresholdsPlot);
357  PAYLOAD_INSPECTOR_CLASS(EcalPFRecHitThresholdsDiff);
358  PAYLOAD_INSPECTOR_CLASS(EcalPFRecHitThresholdsSummaryPlot);
359 }
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
EBDetId.h
EEDetId.h
EBDetId::unhashIndex
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
cond::payloadInspector::Plot3D< PayloadType, float, float, float, IOV_M, 1 >::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:521
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
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
EcalPFRecHitThresholds.h
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:32
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
cond::payloadInspector::Histogram2D
Definition: PayloadInspector.h:797
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
Time.h
IY_MIN
Definition: EcalFloatCondObjectContainerUtils.h:19
cond::payloadInspector::Histogram2D::fillWithValue
void fillWithValue(float xvalue, float yvalue, float weight=1)
Definition: PayloadInspector.h:852
cond::payloadInspector::PlotImage::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:905
MIN_IPHI
Definition: EcalFloatCondObjectContainerUtils.h:12
EEhistXMax
Definition: EcalFloatCondObjectContainerUtils.h:22
EEDetId::validHashIndex
static bool validHashIndex(int i)
Definition: EEDetId.h:239
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
EcalDrawUtils.h
EBhistEtaMax
Definition: EcalFloatCondObjectContainerUtils.h:15
writedatasetfile.run
run
Definition: writedatasetfile.py:27
cond::payloadInspector::PlotImpl::fill
virtual bool fill()=0
drawTable
void drawTable(int nbRows, int nbColumns)
Definition: EcalDrawUtils.h:91
cond::payloadInspector::PlotImage
Definition: PayloadInspector.h:894
EBDetId::kSizeForDenseIndexing
Definition: EBDetId.h:155
EcalCondObjectContainer::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
cond::payloadInspector::Histogram2D::fill
bool fill() override
Definition: PayloadInspector.h:862
MAX_IETA
Definition: EcalFloatCondObjectContainerUtils.h:13