CMS 3D CMS Logo

EcalTPGTowerStatus_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  enum { kEBTotalTowers = 2448, kEETotalTowers = 1584 };
22  enum { MIN_IETA = 1, MIN_IPHI = 1, MAX_IETA = 17, MAX_IPHI = 72 }; // barrel lower and upper bounds on eta and phi
23 
24  /***********************************************
25  2d plot of ECAL TPGTowerStatus of 1 IOV
26  ************************************************/
27  class EcalTPGTowerStatusPlot : public cond::payloadInspector::PlotImage<EcalTPGTowerStatus> {
28  public:
29  EcalTPGTowerStatusPlot() : cond::payloadInspector::PlotImage<EcalTPGTowerStatus>("ECAL TPGTowerStatus - map ") {
30  setSingleIov(true);
31  }
32 
33  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
34  TH2F* barrel = new TH2F("EB", "EB TPG Tower Status", MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
35  int EBstat = 0, EEstat = 0;
36 
37  auto iov = iovs.front();
38  std::shared_ptr<EcalTPGTowerStatus> payload = fetchPayload(std::get<1>(iov));
39  unsigned int run = std::get<0>(iov);
40  if (payload.get()) {
41  const EcalTPGTowerStatusMap& towerMap = (*payload).getMap();
42  // std::cout << " tower map size " << towerMap.size() << std::endl;
44  for (it = towerMap.begin(); it != towerMap.end(); ++it) {
45  if ((*it).second > 0) {
46  EcalTrigTowerDetId ttId((*it).first);
47  int ieta = ttId.ieta();
48  // if(ieta < 0) ieta--; // -1 to -17
49  int iphi = ttId.iphi() - 1; // 0 to 71
50  // std::cout << " sub det " << ttId.subDet() << " phi " << iphi << " eta " << ieta << std::endl;
51  // ieta goes from -18 to -2 and 1 to 17. Change it to -17/-1 and 0/16
52  ieta--;
53  if (ttId.subDet() == 1) { // barrel
54  barrel->Fill(iphi, ieta, (*it).second);
55  EBstat++;
56  } else
57  EEstat++;
58  }
59  }
60  } // payload
61 
62  gStyle->SetPalette(1);
63  gStyle->SetOptStat(0);
64  // TCanvas canvas("CC map","CC map", 1600, 450);
65  Double_t w = 1400;
66  Double_t h = 1200;
67  TCanvas canvas("c", "c", w, h);
68  // canvas.SetWindowSize(w + (w - canvas.GetWw()), h + (h - canvas.GetWh()));
69 
70  TLatex t1;
71  t1.SetNDC();
72  t1.SetTextAlign(26);
73  t1.SetTextSize(0.05);
74  t1.DrawLatex(0.5, 0.96, Form("Ecal TPGTowerStatus, IOV %i", run));
75 
76  TPad** pad = new TPad*;
77  for (int obj = 0; obj < 1; obj++) {
78  pad[obj] = new TPad(Form("p_%i", obj), Form("p_%i", obj), 0.0, 0.04, 1.0, 0.94);
79  pad[obj]->Draw();
80  }
81  t1.SetTextSize(0.03);
82  t1.DrawLatex(0.2, 0.88, Form("%i towers", EBstat));
83  t1.DrawLatex(0.5, 0.02, Form("EE : %i tower(s)", EEstat));
84  // canvas.cd();
85  pad[0]->cd();
86  // barrel->SetStats(false);
87  barrel->Draw("col");
88  TLine* l = new TLine(0., 0., 0., 0.);
89  l->SetLineWidth(1);
90  for (int i = 0; i < MAX_IETA; i++) {
91  Double_t x = 4. + (i * 4);
92  l = new TLine(x, -MAX_IETA, x, MAX_IETA);
93  l->Draw();
94  }
95  l = new TLine(0., 0., 72., 0.);
96  l->Draw();
97 
98  std::string ImageName(m_imageFileName);
99  canvas.SaveAs(ImageName.c_str());
100  return true;
101  } // fill method
102  };
103 
104  /************************************************************************
105  2d plot of ECAL TPGTowerStatus difference between 2 IOVs
106  ************************************************************************/
107  class EcalTPGTowerStatusDiff : public cond::payloadInspector::PlotImage<EcalTPGTowerStatus> {
108  public:
109  EcalTPGTowerStatusDiff() : cond::payloadInspector::PlotImage<EcalTPGTowerStatus>("ECAL TPGTowerStatus difference") {
110  setSingleIov(false);
111  }
112 
113  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
114  TH2F* barrel = new TH2F("EB", "EB difference", MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
115  // int EBstat[2] = {0, 0};
116  int EBstat = 0, EEstat = 0;
117 
118  unsigned int run[2] = {0, 0}, irun = 0, vEB[kEBTotalTowers];
119  // EcalTrigTowerDetId EBId[kEBTotalTowers];
120  for (auto const& iov : iovs) {
121  std::shared_ptr<EcalTPGTowerStatus> payload = fetchPayload(std::get<1>(iov));
122  run[irun] = std::get<0>(iov);
123  if (payload.get()) {
124  const EcalTPGTowerStatusMap& towerMap = (*payload).getMap();
125  // std::cout << " tower map size " << towerMap.size() << std::endl;
127  for (it = towerMap.begin(); it != towerMap.end(); ++it) {
128  EcalTrigTowerDetId ttId((*it).first);
129  int ieta = ttId.ieta();
130  if (ieta < 0)
131  ieta--; // 1 to 17
132  int iphi = ttId.iphi() - 1; // 0 to 71
133  int towerId = ttId.hashedIndex();
134  int stat = (*it).second;
135  if (irun == 0) {
136  if (ttId.subDet() == 1) { // barrel
137  vEB[towerId] = stat;
138  if (stat > 0) { // bad tower
139  if (towerId >= kEBTotalTowers)
140  std::cout << " strange tower Id " << towerId << std::endl;
141  else {
142  // std::cout << " phi " << iphi << " eta " << ieta << std::endl;
143  // EBId[towerId] = ttId;
144  }
145  }
146  } // barrel
147  else if (stat > 0) {
148  // std::cout << " EE phi " << iphi << " eta " << ieta << std::endl;
149  EEstat--;
150  }
151  } // 1st run
152  else { // 2nd run
153  if (ttId.subDet() == 1) { // barrel
154  if (stat > 0) { // bad tower
155  if (towerId >= kEBTotalTowers)
156  std::cout << " strange tower Id " << towerId << std::endl;
157  // else std::cout << " phi " << iphi << " eta " << ieta << std::endl;
158  } // bad tower
159  int diff = stat - vEB[towerId];
160  // ieta goes from -18 to -2 and 1 to 17. Change it to -17/-1 and 0/16
161  ieta--;
162  if (diff != 0)
163  barrel->Fill(iphi, ieta, diff);
164  // vEB[towerId] = 0;
165  EBstat += diff;
166  } // barrel
167  else if (stat > 0) {
168  // std::cout << " EE phi " << iphi << " eta " << ieta << std::endl;
169  EEstat++;
170  }
171  } // 2nd run
172  } // loop over towers
173  } // payload
174  else
175  return false;
176  irun++;
177  } // loop over IOVs
178  /*
179  // now check if towers have disappered
180  for(int it = 0; it < kEBTotalTowers; it++) {
181  if(vEB[it] != 0) {
182  std::cout << " tower " << vEB[it] << " not found in run 2, plot it" << std::endl;
183  EcalTrigTowerDetId ttId = EBId[it];
184  int ieta = ttId.ieta();
185  // ieta goes from -18 to -2 and 1 to 17. Change it to -17/-1 and 0/16
186  ieta--;
187  int iphi = ttId.iphi() - 1; // 0 to 71
188  barrel->Fill(iphi, ieta, vEB[it]);
189  }
190  }
191  */
192  gStyle->SetPalette(1);
193  gStyle->SetOptStat(0);
194  Double_t w = 1400;
195  Double_t h = 1200;
196  TCanvas canvas("c", "c", w, h);
197  // canvas.SetWindowSize(w + (w - canvas.GetWw()), h + (h - canvas.GetWh()));
198 
199  TLatex t1;
200  t1.SetNDC();
201  t1.SetTextAlign(26);
202  t1.SetTextSize(0.05);
203  t1.DrawLatex(0.5, 0.96, Form("Ecal TPGTowerStatus, IOV %i - %i", run[1], run[0]));
204 
205  TPad** pad = new TPad*;
206  for (int obj = 0; obj < 1; obj++) {
207  pad[obj] = new TPad(Form("p_%i", obj), Form("p_%i", obj), 0.0, 0.04, 1.0, 0.94);
208  pad[obj]->Draw();
209  }
210  t1.SetTextSize(0.03);
211  t1.DrawLatex(0.2, 0.88, Form("%i tower(s)", EBstat));
212  t1.DrawLatex(0.5, 0.02, Form("EE : %i tower(s)", EEstat));
213 
214  pad[0]->cd();
215  // barrel->SetStats(false);
216  barrel->Draw("col");
217  TLine* l = new TLine(0., 0., 0., 0.);
218  l->SetLineWidth(1);
219  for (int i = 0; i < MAX_IETA; i++) {
220  Double_t x = 4. + (i * 4);
221  l = new TLine(x, -MAX_IETA, x, MAX_IETA);
222  l->Draw();
223  }
224  l = new TLine(0., 0., 72., 0.);
225  l->Draw();
226 
227  std::string ImageName(m_imageFileName);
228  canvas.SaveAs(ImageName.c_str());
229  return true;
230  } // fill method
231  };
232 
233  /*****************************************
234  2d plot of EcalTPGTowerStatus Error Summary of 1 IOV
235  ******************************************/
236  class EcalTPGTowerStatusSummaryPlot : public cond::payloadInspector::PlotImage<EcalTPGTowerStatus> {
237  public:
238  EcalTPGTowerStatusSummaryPlot()
239  : cond::payloadInspector::PlotImage<EcalTPGTowerStatus>("Ecal TPGTower Status Summary - map ") {
240  setSingleIov(true);
241  }
242 
243  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
244  auto iov = iovs.front(); //get reference to 1st element in the vector iovs
245  std::shared_ptr<EcalTPGTowerStatus> payload =
246  fetchPayload(std::get<1>(iov)); //std::get<1>(iov) refers to the Hash in the tuple iov
247  unsigned int run = std::get<0>(iov); //referes to Time_t in iov.
248  TH2F* align; //pointer to align which is a 2D histogram
249 
250  int NbRows = 1;
251  int NbColumns = 2;
252 
253  if (payload.get()) { //payload is an iov retrieved from payload using hash.
254  const EcalTPGTowerStatusMap& towerMap = (*payload).getMap();
255 
256  align = new TH2F("Ecal TPGTower Status Summary",
257  "Total NumberOfMasked",
258  NbColumns,
259  0,
260  NbColumns,
261  NbRows,
262  0,
263  NbRows);
264 
265  int NbMaskedTT = 0;
266 
267  for (EcalTPGTowerStatusMapIterator it = towerMap.begin(); it != towerMap.end(); ++it)
268  if ((*it).second > 0)
269  NbMaskedTT++;
270 
271  align->Fill(0.5, 0.5, towerMap.size());
272  align->Fill(1.5, 0.5, NbMaskedTT);
273 
274  } // if payload.get()
275  else
276  return false;
277 
278  gStyle->SetPalette(1);
279  gStyle->SetOptStat(0);
280  TCanvas canvas("CC map", "CC map", 1000, 1000);
281  TLatex t1;
282  t1.SetNDC();
283  t1.SetTextAlign(26);
284  t1.SetTextSize(0.04);
285  t1.SetTextColor(2);
286  t1.DrawLatex(0.5, 0.96, Form("Barrel masked Trigger Towers, IOV %i", run));
287 
288  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
289  pad->Draw();
290  pad->cd();
291  align->Draw("TEXT");
292 
293  drawTable(NbRows, NbColumns);
294 
295  align->GetXaxis()->SetTickLength(0.);
296  align->GetXaxis()->SetLabelSize(0.);
297  align->GetYaxis()->SetTickLength(0.);
298  align->GetYaxis()->SetLabelSize(0.);
299 
300  std::string ImageName(m_imageFileName);
301  canvas.SaveAs(ImageName.c_str());
302  return true;
303  } // fill method
304  };
305 
306 } // namespace
307 
308 // Register the classes as boost python plugin
310  PAYLOAD_INSPECTOR_CLASS(EcalTPGTowerStatusPlot);
311  PAYLOAD_INSPECTOR_CLASS(EcalTPGTowerStatusDiff);
312  PAYLOAD_INSPECTOR_CLASS(EcalTPGTowerStatusSummaryPlot);
313 }
change_name.diff
diff
Definition: change_name.py:13
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
mps_fire.i
i
Definition: mps_fire.py:355
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
align
Definition: AlignableIndexer.h:30
MAX_IPHI
Definition: EcalFloatCondObjectContainerUtils.h:14
PayloadInspector.h
EcalTPGTowerStatusMapIterator
std::map< uint32_t, uint16_t >::const_iterator EcalTPGTowerStatusMapIterator
Definition: EcalTPGTowerStatus.h:25
gather_cfg.cout
cout
Definition: gather_cfg.py:144
EBDetId.h
EEDetId.h
ecaldqm::ttId
unsigned ttId(DetId const &)
Definition: EcalDQMCommonUtils.cc:101
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
DDAxes::x
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
PayloadInspectorModule.h
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
hgcalPlots.stat
stat
Definition: hgcalPlots.py:1111
EcalTPGTowerStatusMap
std::map< uint32_t, uint16_t > EcalTPGTowerStatusMap
Definition: EcalTPGTowerStatus.h:24
MIN_IETA
Definition: EcalFloatCondObjectContainerUtils.h:11
w
const double w
Definition: UKUtility.cc:23
jets_cff.payload
payload
Definition: jets_cff.py:34
h
PAYLOAD_INSPECTOR_MODULE
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: PayloadInspectorModule.h:8
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
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
cond::payloadInspector::PlotImage::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:840
MIN_IPHI
Definition: EcalFloatCondObjectContainerUtils.h:12
EcalDrawUtils.h
EcalTPGTowerStatus.h
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
ecaldqm::towerId
unsigned towerId(DetId const &)
Definition: EcalDQMCommonUtils.cc:79
EcalTPGTowerStatus
Definition: EcalTPGTowerStatus.h:9
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
MAX_IETA
Definition: EcalFloatCondObjectContainerUtils.h:13