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