CMS 3D CMS Logo

EcalTPGLutGroup_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 <string>
18 
19 namespace {
20 
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  enum {
24  IX_MIN = 1,
25  IY_MIN = 1,
26  IX_MAX = 100,
27  IY_MAX = 100,
28  EEhistXMax = 220
29  }; // endcaps lower and upper bounds on x and y
30  /***********************************************
31  2d plot of EcalTPGLutGroup of 1 IOV
32 ************************************************/
33  class EcalTPGLutGroupPlot : public cond::payloadInspector::PlotImage<EcalTPGLutGroup> {
34  public:
35  EcalTPGLutGroupPlot() : cond::payloadInspector::PlotImage<EcalTPGLutGroup>("EcalTPGLutGroup - map ") {
36  setSingleIov(true);
37  }
38 
39  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
40  uint32_t minEB = 0;
41  uint32_t maxEB = 2;
42  uint32_t minEE = 0;
43  uint32_t maxEE = 2;
44 
45  TH2F* barrel = new TH2F("EB", "EB Tower Status", 72, 0, 72, 34, -17, 17);
46  TH2F* endc_p = new TH2F("EE+", "EE+ Tower Status", 22, 0, 22, 22, 0, 22);
47  TH2F* endc_m = new TH2F("EE-", "EE- Tower Status", 22, 0, 22, 22, 0, 22);
48 
49  auto iov = iovs.front();
50  std::shared_ptr<EcalTPGLutGroup> payload = fetchPayload(std::get<1>(iov));
51  unsigned int run = std::get<0>(iov);
52 
53  if (payload.get()) {
54  const EcalTPGLutGroup::EcalTPGGroupsMap& map = (*payload).getMap();
56 
57  for (it = map.begin(); it != map.end(); it++) {
59  EcalTrigTowerDetId ttId_eb(rawid);
60 
61  //std::cout<<ttId.subDet()<< " "<< (*it).second << std::endl;
62 
63  if (ttId_eb.subDet() == 1) {
64  //barrel
65  int ieta = ttId_eb.ieta();
66  if (ieta < 0)
67  ieta--; // -1 to -17
68  int iphi = ttId_eb.iphi() - 1; // 0 to 71
69 
70  if (minEB > (*it).second)
71  minEB = (*it).second;
72 
73  if (maxEB < (*it).second)
74  maxEB = (*it).second;
75 
76  barrel->Fill(iphi, ieta, (*it).second);
77  }
78 
79  if (EcalScDetId::validHashIndex((*it).first)) {
80  EcalScDetId rawid_ee = EcalScDetId::unhashIndex((*it).first);
81  EcalScDetId ttId_ee(rawid_ee);
82 
83  //endcaps
84 
85  int ix = ttId_ee.ix();
86  int iy = ttId_ee.iy();
87  int zside = ttId_ee.zside();
88 
89  if (minEE > (*it).second)
90  minEE = (*it).second;
91 
92  if (maxEE < (*it).second)
93  maxEE = (*it).second;
94 
95  if (zside == 1) {
96  endc_p->Fill(ix, iy, (*it).second);
97  } else {
98  endc_m->Fill(ix, iy, (*it).second);
99  }
100  }
101  }
102 
103  } // payload
104 
105  TCanvas canvas("CC map", "CC map", 800, 800);
106  TLatex t1;
107  t1.SetNDC();
108  t1.SetTextAlign(26);
109  t1.SetTextSize(0.05);
110  t1.DrawLatex(0.5, 0.96, Form("Ecal TPG LutGroup, IOV %i", run));
111 
112  //TPad* padb = new TPad("padb","padb", 0., 0.55, 1., 1.);
113  TPad* padb = new TPad("padb", "padb", 0., 0.45, 1., 0.9);
114  padb->Draw();
115  TPad* padem = new TPad("padem", "padem", 0., 0., 0.45, 0.45);
116  padem->Draw();
117  TPad* padep = new TPad("padep", "padep", 0.55, 0., 1., 0.45);
118  padep->Draw();
119 
120  TLine* l = new TLine(0., 0., 0., 0.);
121  l->SetLineWidth(1);
122  padb->cd();
123  barrel->SetStats(false);
124  barrel->SetMaximum(maxEB);
125  barrel->SetMinimum(minEB);
126  barrel->Draw("colz");
127  //barrel->Draw("col");
128  for (int i = 0; i < 17; i++) {
129  Double_t x = 4. + (i * 4);
130  l = new TLine(x, -17., x, 17.);
131  l->Draw();
132  }
133 
134  l = new TLine(0., 0., 72., 0.);
135  l->Draw();
136 
137  padem->cd();
138  DrawEE_Tower(endc_m, l, minEE, maxEE);
139 
140  padep->cd();
141  DrawEE_Tower(endc_p, l, minEE, maxEE);
142 
143  std::string ImageName(m_imageFileName);
144  canvas.SaveAs(ImageName.c_str());
145  return true;
146  } // fill method
147  };
148 
149 } // namespace
150 
151 // Register the classes as boost python plugin
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
std::map< uint32_t, uint32_t >::const_iterator EcalTPGGroupsMapItr
Definition: EcalTPGGroups.h:20
static EcalScDetId unhashIndex(int hi)
Definition: EcalScDetId.h:117
int zside(DetId const &)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
void DrawEE_Tower(TH2F *endc, TLine *l, double minScale, double maxScale)
Definition: EcalDrawUtils.h:65
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ix(uint32_t id)
static bool validHashIndex(int hi)
Definition: EcalScDetId.h:139
def canvas(sub, attr)
Definition: svgfig.py:482
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t iy(uint32_t id)
std::map< uint32_t, uint32_t > EcalTPGGroupsMap
Definition: EcalTPGGroups.h:19
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)