CMS 3D CMS Logo

EcalDQMTowerStatus_PayloadInspector.cc
Go to the documentation of this file.
8 
9 // the data format of the condition to be inspected
11 
12 #include "TH2F.h"
13 #include "TCanvas.h"
14 #include "TStyle.h"
15 #include "TLine.h"
16 #include "TLatex.h"
17 
18 #include <string>
19 
20 namespace {
21 
22  enum { kEBTotalTowers = 2448, kEETotalTowers = 1584 };
23  enum { MIN_IETA = 1, MIN_IPHI = 1, MAX_IETA = 17, MAX_IPHI = 72 }; // barrel lower and upper bounds on eta and phi
24  enum { IX_MIN = 1, IY_MIN = 1, IX_MAX = 20, IY_MAX = 20 }; // endcaps lower and upper bounds on x and y
25  /***********************************************
26  2d plot of EcalDQMTowerStatus of 1 IOV
27 ************************************************/
28  class EcalDQMTowerStatusPlot : public cond::payloadInspector::PlotImage<EcalDQMTowerStatus> {
29  public:
30  EcalDQMTowerStatusPlot() : cond::payloadInspector::PlotImage<EcalDQMTowerStatus>("EcalDQMTowerStatus - map ") {
31  setSingleIov(true);
32  }
33 
34  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
35  TH2F* barrel = new TH2F("EB", "EB DQM Tower Status", 72, 0, 72, 34, -17, 17);
36  TH2F* endc_p = new TH2F("EE+", "EE+ DQM Tower Status", 22, 0, 22, 22, 0, 22);
37  TH2F* endc_m = new TH2F("EE-", "EE- DQM Tower Status", 22, 0, 22, 22, 0, 22);
38 
39  auto iov = iovs.front();
40  std::shared_ptr<EcalDQMTowerStatus> payload = fetchPayload(std::get<1>(iov));
41  unsigned int run = std::get<0>(iov);
42  double maxEB = 0, maxEE = 0;
43 
44  if (payload.get()) {
45  for (uint cellid = 0; cellid < EcalTrigTowerDetId::kEBTotalTowers; ++cellid) {
46  if (payload->barrelItems().empty())
47  break;
49  if ((*payload).find(rawid) == (*payload).end())
50  continue;
51 
52  int ieta = rawid.ieta();
53  if (ieta > 0)
54  ieta--; // 1 to 17
55  int iphi = rawid.iphi() - 1; // 0 to 71
56  barrel->Fill(iphi, ieta, (*payload)[rawid].getStatusCode());
57 
58  if (maxEB < (*payload)[rawid].getStatusCode())
59  maxEB = (*payload)[rawid].getStatusCode();
60  }
61 
62  if (payload->endcapItems().empty())
63  return false;
64 
65  for (uint cellid = 0; cellid < EcalTrigTowerDetId::kEETotalTowers; ++cellid) {
66  if (EcalScDetId::validHashIndex(cellid)) {
67  EcalScDetId rawid = EcalScDetId::unhashIndex(cellid);
68  if ((*payload).find(rawid) == (*payload).end())
69  continue;
70  int ix = rawid.ix(); // 1 to 20
71  int iy = rawid.iy(); // 1 to 20
72  int side = rawid.zside();
73  if (side == -1)
74  endc_m->Fill(ix, iy, (*payload)[rawid].getStatusCode());
75  else
76  endc_p->Fill(ix, iy, (*payload)[rawid].getStatusCode());
77 
78  if (maxEE < (*payload)[rawid].getStatusCode())
79  maxEE = (*payload)[rawid].getStatusCode();
80  }
81  }
82 
83  } // payload
84 
85  TCanvas canvas("CC map", "CC map", 800, 800);
86  TLatex t1;
87  t1.SetNDC();
88  t1.SetTextAlign(26);
89  t1.SetTextSize(0.05);
90  t1.DrawLatex(0.5, 0.96, Form("Ecal DQM Tower Status, IOV %i", run));
91 
92  //TPad* padb = new TPad("padb","padb", 0., 0.55, 1., 1.);
93  TPad* padb = new TPad("padb", "padb", 0., 0.45, 1., 0.9);
94  padb->Draw();
95  TPad* padem = new TPad("padem", "padem", 0., 0., 0.45, 0.45);
96  padem->Draw();
97  TPad* padep = new TPad("padep", "padep", 0.55, 0., 1., 0.45);
98  padep->Draw();
99 
100  TLine* l = new TLine(0., 0., 0., 0.);
101  l->SetLineWidth(1);
102  padb->cd();
103  barrel->SetStats(false);
104  barrel->SetMaximum(maxEB);
105  barrel->SetMinimum(0);
106  barrel->Draw("colz");
107  //barrel->Draw("col");
108  for (int i = 0; i < 17; i++) {
109  Double_t x = 4. + (i * 4);
110  l = new TLine(x, -17., x, 17.);
111  l->Draw();
112  }
113 
114  l = new TLine(0., 0., 72., 0.);
115  l->Draw();
116 
117  padem->cd();
118  DrawEE_Tower(endc_m, l, 0, maxEE);
119 
120  padep->cd();
121  DrawEE_Tower(endc_p, l, 0, maxEE);
122 
123  std::string ImageName(m_imageFileName);
124  canvas.SaveAs(ImageName.c_str());
125  return true;
126  } // fill method
127  };
128 
129  /***********************************************
130  2d plot of EcalDQMTowerStatus Diff between 2 IOV
131 ************************************************/
132  class EcalDQMTowerStatusDiffPlot : public cond::payloadInspector::PlotImage<EcalDQMTowerStatus> {
133  public:
134  EcalDQMTowerStatusDiffPlot()
135  : cond::payloadInspector::PlotImage<EcalDQMTowerStatus>("EcalDQMTowerStatusDiff - map ") {
136  setSingleIov(false);
137  }
138 
139  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
140  TH2F* barrel = new TH2F("EB", "EB DQM Tower Status", 72, 0, 72, 34, -17, 17);
141  TH2F* endc_p = new TH2F("EE+", "EE+ DQM Tower Status", 22, 0, 22, 22, 0, 22);
142  TH2F* endc_m = new TH2F("EE-", "EE- DQM Tower Status", 22, 0, 22, 22, 0, 22);
143 
144  unsigned int run[2], irun = 0;
145  float pEB[kEBTotalTowers], pEE[kEETotalTowers];
146 
147  for (auto const& iov : iovs) {
148  std::shared_ptr<EcalDQMTowerStatus> payload = fetchPayload(std::get<1>(iov));
149  run[irun] = std::get<0>(iov);
150 
151  if (payload.get()) {
152  for (uint cellid = 0; cellid < EcalTrigTowerDetId::kEBTotalTowers; ++cellid) {
153  if (payload->barrelItems().empty())
154  break;
155 
157  if ((*payload).find(rawid) == (*payload).end())
158  continue;
159 
160  float weight = (*payload)[rawid].getStatusCode();
161 
162  if (irun == 0) {
163  pEB[cellid] = weight;
164  } else {
165  int ieta = rawid.ieta();
166  if (ieta > 0)
167  ieta--; // 1 to 17
168  int iphi = rawid.iphi() - 1; // 0 to 71
169  unsigned int new_status = (*payload)[rawid].getStatusCode();
170  if (new_status != pEB[cellid]) {
171  int tmp3 = 0;
172 
173  if (new_status > pEB[cellid])
174  tmp3 = 1;
175  else
176  tmp3 = -1;
177 
178  barrel->Fill(iphi, ieta, 0.05 + 0.95 * (tmp3 > 0));
179  }
180  }
181  }
182 
183  if (payload->endcapItems().empty())
184  return false;
185 
186  for (uint cellid = 0; cellid < EcalTrigTowerDetId::kEETotalTowers; ++cellid) {
187  if (EcalScDetId::validHashIndex(cellid)) {
188  EcalScDetId rawid = EcalScDetId::unhashIndex(cellid);
189  if ((*payload).find(rawid) == (*payload).end())
190  continue;
191 
192  float weight = (*payload)[rawid].getStatusCode();
193 
194  if (irun == 0) {
195  pEE[cellid] = weight;
196  } else {
197  int ix = rawid.ix(); // 1 to 20
198  int iy = rawid.iy(); // 1 to 20
199  int side = rawid.zside();
200 
201  unsigned int new_status = (*payload)[rawid].getStatusCode();
202  if (new_status != pEE[cellid]) {
203  int tmp3 = 0;
204 
205  if (new_status > pEE[cellid])
206  tmp3 = 1;
207  else
208  tmp3 = -1;
209 
210  if (side == -1)
211  endc_m->Fill(ix, iy, 0.05 + 0.95 * (tmp3 > 0));
212  else
213  endc_p->Fill(ix, iy, 0.05 + 0.95 * (tmp3 > 0));
214  }
215  }
216  }
217  }
218 
219  } // payload
220  irun++;
221  }
222 
223  TCanvas canvas("CC map", "CC map", 800, 800);
224  TLatex t1;
225  t1.SetNDC();
226  t1.SetTextAlign(26);
227  t1.SetTextSize(0.04);
228  t1.DrawLatex(0.5, 0.96, Form("Ecal DQM Tower Status (Diff), IOV %i vs %i", run[0], run[1]));
229 
230  TPad* padb = new TPad("padb", "padb", 0., 0.45, 1., 0.9);
231  padb->Draw();
232  TPad* padem = new TPad("padem", "padem", 0., 0., 0.45, 0.45);
233  padem->Draw();
234  TPad* padep = new TPad("padep", "padep", 0.55, 0., 1., 0.45);
235  padep->Draw();
236 
237  TLine* l = new TLine(0., 0., 0., 0.);
238  l->SetLineWidth(1);
239  padb->cd();
240  barrel->SetStats(false);
241  barrel->SetMaximum(1.15);
242  barrel->SetMinimum(0);
243  barrel->Draw("colz");
244  //barrel->Draw("col");
245  for (int i = 0; i < 17; i++) {
246  Double_t x = 4. + (i * 4);
247  l = new TLine(x, -17., x, 17.);
248  l->Draw();
249  }
250 
251  l = new TLine(0., 0., 72., 0.);
252  l->Draw();
253 
254  padem->cd();
255  DrawEE_Tower(endc_m, l, 0, 1.15);
256 
257  padep->cd();
258  DrawEE_Tower(endc_p, l, 0, 1.15);
259 
260  std::string ImageName(m_imageFileName);
261  canvas.SaveAs(ImageName.c_str());
262  return true;
263  } // fill method
264  };
265 
266 } // namespace
267 
268 // Register the classes as boost python plugin
270  PAYLOAD_INSPECTOR_CLASS(EcalDQMTowerStatusPlot);
271  PAYLOAD_INSPECTOR_CLASS(EcalDQMTowerStatusDiffPlot);
272 }
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
mps_fire.i
i
Definition: mps_fire.py:355
EcalTrigTowerDetId::iphi
int iphi() const
get the tower iphi
Definition: EcalTrigTowerDetId.h:52
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
MAX_IPHI
Definition: EcalFloatCondObjectContainerUtils.h:14
IX_MAX
Definition: EcalFloatCondObjectContainerUtils.h:20
IY_MAX
Definition: EcalFloatCondObjectContainerUtils.h:21
EcalScDetId::zside
int zside() const
Definition: EcalScDetId.h:64
mps_merge.weight
weight
Definition: mps_merge.py:88
PayloadInspector.h
EBDetId.h
EEDetId.h
EcalScDetId::unhashIndex
static EcalScDetId unhashIndex(int hi)
Definition: EcalScDetId.h:117
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
EcalDQMTowerStatus.h
DDAxes::x
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
parallelization.uint
uint
Definition: parallelization.py:124
PayloadInspectorModule.h
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
EcalCondTowerObjectContainer< EcalDQMStatusCode >
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
MIN_IETA
Definition: EcalFloatCondObjectContainerUtils.h:11
EcalScDetId
Definition: EcalScDetId.h:24
jets_cff.payload
payload
Definition: jets_cff.py:34
PAYLOAD_INSPECTOR_MODULE
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: PayloadInspectorModule.h:8
EcalTrigTowerDetId.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalSubdetector.h
cond
Definition: plugin.cc:23
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
IY_MIN
Definition: EcalFloatCondObjectContainerUtils.h:19
DrawEE_Tower
void DrawEE_Tower(TH2F *endc, TLine *l, double minScale, double maxScale)
Definition: EcalDrawUtils.h:65
cond::payloadInspector::PlotImage::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:840
EcalScDetId::validHashIndex
static bool validHashIndex(int hi)
Definition: EcalScDetId.h:139
MIN_IPHI
Definition: EcalFloatCondObjectContainerUtils.h:12
EcalScDetId::iy
int iy() const
Definition: EcalScDetId.h:76
EcalDrawUtils.h
EcalTrigTowerDetId::ieta
int ieta() const
get the tower ieta
Definition: EcalTrigTowerDetId.h:44
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
EcalTrigTowerDetId::kEBTotalTowers
Definition: EcalTrigTowerDetId.h:116
writedatasetfile.run
run
Definition: writedatasetfile.py:27
cond::payloadInspector::PlotImpl::fill
virtual bool fill()=0
cond::payloadInspector::PlotImage
Definition: PayloadInspector.h:829
EcalTrigTowerDetId::detIdFromDenseIndex
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
Definition: EcalTrigTowerDetId.cc:104
EcalTrigTowerDetId::kEETotalTowers
Definition: EcalTrigTowerDetId.h:118
IX_MIN
Definition: EcalFloatCondObjectContainerUtils.h:18
EcalScDetId::ix
int ix() const
Definition: EcalScDetId.h:70
weight
Definition: weight.py:1
MAX_IETA
Definition: EcalFloatCondObjectContainerUtils.h:13