CMS 3D CMS Logo

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