CMS 3D CMS Logo

EcalTPGFineGrainEBIdMap_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 #include <cstring>
20 
21 namespace {
22  enum { TEMPLATESAMPLES = 5 };
23  enum { MIN_IETA = 1, MIN_IPHI = 1, MAX_IETA = 17, MAX_IPHI = 72 }; // barrel lower and upper bounds on eta and phi
24 
25  /***********************************************
26  2d plot of EcalTPGFineGrainEBIdMap of 1 IOV
27  ************************************************/
28  class EcalTPGFineGrainEBIdMapPlot : public cond::payloadInspector::PlotImage<EcalTPGFineGrainEBIdMap> {
29  public:
30  EcalTPGFineGrainEBIdMapPlot()
31  : cond::payloadInspector::PlotImage<EcalTPGFineGrainEBIdMap>("Ecal TPGFineGrainEBIdMap - map ") {
32  setSingleIov(true);
33  }
34 
35  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
36  TH2F** barrel = new TH2F*[TEMPLATESAMPLES];
37  double pEBmin[TEMPLATESAMPLES], pEBmax[TEMPLATESAMPLES];
38  std::string text[TEMPLATESAMPLES] = {"ThresholdETLow", "ThresholdETHigh", "RatioLow", "RatioHigh", "LUT"};
39  int EBcnt = 0;
40 
41  for (int s = 0; s < TEMPLATESAMPLES; ++s) {
42  char* y = new char[text[s].length() + 1];
43  std::strcpy(y, text[s].c_str());
44  barrel[s] = new TH2F("EB", y, MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
45  }
46 
47  uint32_t ThresholdETLow = 0;
48  uint32_t ThresholdETHigh = 0;
49  uint32_t RatioLow = 0;
50  uint32_t RatioHigh = 0;
51  uint32_t LUT = 0;
52 
53  auto iov = iovs.front();
54  std::shared_ptr<EcalTPGFineGrainEBIdMap> payload = fetchPayload(std::get<1>(iov));
55  unsigned int run = std::get<0>(iov);
56  if (payload.get()) {
57  const std::map<uint32_t, EcalTPGFineGrainConstEB>& towerMap = (*payload).getMap();
58  std::map<uint32_t, EcalTPGFineGrainConstEB>::const_iterator it = towerMap.begin();
59 
60  for (int iphi = MIN_IPHI - 1; iphi <= MAX_IPHI; iphi++) {
61  for (int ieta = -1 * MAX_IETA; ieta < MAX_IETA; ieta++) {
62  //if(ieta > 0) ieta--;
63 
64  EcalTPGFineGrainConstEB fg = (*it).second;
65 
66  fg.getValues(ThresholdETLow, ThresholdETHigh, RatioLow, RatioHigh, LUT);
67 
68  barrel[0]->Fill(iphi, ieta, ThresholdETLow);
69  barrel[1]->Fill(iphi, ieta, ThresholdETHigh);
70  barrel[2]->Fill(iphi, ieta, RatioLow);
71  barrel[3]->Fill(iphi, ieta, RatioHigh);
72  barrel[4]->Fill(iphi, ieta, LUT);
73 
74  if (ThresholdETLow < pEBmin[0])
75  pEBmin[0] = ThresholdETLow;
76  if (ThresholdETHigh < pEBmin[1])
77  pEBmin[1] = ThresholdETHigh;
78  if (RatioLow < pEBmin[2])
79  pEBmin[2] = RatioLow;
80  if (RatioHigh < pEBmin[3])
81  pEBmin[3] = RatioHigh;
82  if (LUT < pEBmin[4])
83  pEBmin[4] = LUT;
84 
85  if (ThresholdETLow > pEBmax[0])
86  pEBmax[0] = ThresholdETLow;
87  if (ThresholdETHigh > pEBmax[1])
88  pEBmax[1] = ThresholdETHigh;
89  if (RatioLow > pEBmax[2])
90  pEBmax[2] = RatioLow;
91  if (RatioHigh > pEBmax[3])
92  pEBmax[3] = RatioHigh;
93  if (LUT > pEBmax[4])
94  pEBmax[4] = LUT;
95 
96  EBcnt++;
97  }
98  }
99 
100  } // payload
101 
102  gStyle->SetPalette(1);
103  gStyle->SetOptStat(0);
104  TCanvas canvas("CC map", "CC map", 1600, 2800);
105  TLatex t1;
106  t1.SetNDC();
107  t1.SetTextAlign(26);
108  t1.SetTextSize(0.04);
109  t1.DrawLatex(0.5, 0.96, Form("Ecal TPGFine Grain EBIdMap, IOV %i", run));
110 
111  float xmi = 0.24;
112  float xma = 0.76;
113 
114  TPad** pad = new TPad*[TEMPLATESAMPLES];
115  for (int s = 0; s < TEMPLATESAMPLES; s++) {
116  float yma = 0.94 - (0.16 * s);
117  float ymi = yma - 0.14;
118  //pad[s] = new TPad(text[s],Form("Towers %i", EBcnt),xmi, ymi, xma, yma);
119  char* y = new char[text[s].length() + 1];
120  std::strcpy(y, text[s].c_str());
121 
122  pad[s] = new TPad(Form("Towers %i", EBcnt), y, xmi, ymi, xma, yma);
123  pad[s]->Draw();
124  }
125 
126  for (int s = 0; s < TEMPLATESAMPLES; s++) {
127  pad[s]->cd();
128 
129  if (pEBmin[s] == pEBmax[s]) { // same values everywhere!..
130  pEBmin[s] = pEBmin[s] - 1.e-06;
131  pEBmax[s] = pEBmax[s] + 1.e-06;
132  }
133 
134  barrel[s]->SetMaximum(pEBmax[s]);
135  barrel[s]->SetMinimum(pEBmin[s]);
136  barrel[s]->Draw("colz");
137 
138  TLine* l = new TLine(0., 0., 0., 0.);
139  l->SetLineWidth(1);
140  for (int i = 0; i < MAX_IETA; i++) {
141  Double_t x = 4. + (i * 4);
142  l = new TLine(x, -MAX_IETA, x, MAX_IETA);
143  l->Draw();
144  }
145  }
146 
147  std::string ImageName(m_imageFileName);
148  canvas.SaveAs(ImageName.c_str());
149 
150  return true;
151  } // fill method
152  };
153 
154 } // namespace
155 
156 // Register the classes as boost python plugin
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:428
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
MAX_IPHI
Definition: EcalFloatCondObjectContainerUtils.h:14
PayloadInspector.h
EBDetId.h
EEDetId.h
EcalTPGFineGrainEBIdMap.h
EcalTPGFineGrainEBIdMap
Definition: EcalTPGFineGrainEBIdMap.h:10
EcalTPGFineGrainConstEB
Definition: EcalTPGFineGrainConstEB.h:7
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
DDAxes::x
PayloadInspectorModule.h
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
alignCSCRings.s
s
Definition: alignCSCRings.py:92
EcalTPGFineGrainConstEB::getValues
void getValues(uint32_t &ThresholdETLow, uint32_t &ThresholdETHigh, uint32_t &RatioLow, uint32_t &RatioHigh, uint32_t &LUT) const
Definition: EcalTPGFineGrainConstEB.cc:8
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
MIN_IETA
Definition: EcalFloatCondObjectContainerUtils.h:11
jets_cff.payload
payload
Definition: jets_cff.py:32
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
cond::payloadInspector::PlotImage::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:863
MIN_IPHI
Definition: EcalFloatCondObjectContainerUtils.h:12
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
EcalDrawUtils.h
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
writedatasetfile.run
run
Definition: writedatasetfile.py:27
LUT
std::vector< unsigned short int > LUT
Definition: DTTracoLUTs.h:31
cond::payloadInspector::PlotImpl::fill
virtual bool fill()=0
cond::payloadInspector::PlotImage
Definition: PayloadInspector.h:852
runonSM.text
text
Definition: runonSM.py:43
MAX_IETA
Definition: EcalFloatCondObjectContainerUtils.h:13