CMS 3D CMS Logo

EcalFloatCondObjectContainer_PayloadInspector.cc
Go to the documentation of this file.
6 
7 // the data format of the condition to be inspected
9 
10 #include "TH2F.h"
11 #include "TCanvas.h"
12 #include "TStyle.h"
13 #include "TLine.h"
14 #include "TLatex.h"
15 
16 #include <string>
17 
18 namespace {
19  enum { kEBChannels = 61200, kEEChannels = 14648, kSides = 2, kRMS = 5 };
20  enum { MIN_IETA = 1, MIN_IPHI = 1, MAX_IETA = 85, MAX_IPHI = 360 }; // barrel lower and upper bounds on eta and phi
21  enum { IX_MIN = 1, IY_MIN = 1, IX_MAX = 100, IY_MAX = 100 }; // endcaps lower and upper bounds on x and y
22 
23  /*****************************************************
24  2d plot of ECAL FloatCondObjectContainer of 1 IOV
25  *****************************************************/
26  class EcalFloatCondObjectContainerPlot : public cond::payloadInspector::PlotImage<EcalFloatCondObjectContainer> {
27  public:
28  EcalFloatCondObjectContainerPlot()
29  : cond::payloadInspector::PlotImage<EcalFloatCondObjectContainer>("ECAL FloatCondObjectContainer - 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", MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
35  TH2F* endc_p = new TH2F("EE+", "EE+", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
36  TH2F* endc_m = new TH2F("EE-", "EE-", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
37  double EBmean = 0., EBrms = 0., EEmean = 0., EErms = 0.;
38  int EBtot = 0, EEtot = 0;
39 
40  auto iov = iovs.front();
41  std::shared_ptr<EcalFloatCondObjectContainer> payload = fetchPayload(std::get<1>(iov));
42  unsigned int run = std::get<0>(iov);
43  if (payload.get()) {
44  for (int ieta = -MAX_IETA; ieta <= MAX_IETA; ieta++) {
45  Double_t eta = (Double_t)ieta;
46  if (ieta == 0)
47  continue;
48  else if (ieta > 0.)
49  eta = eta - 0.5; // 0.5 to 84.5
50  else
51  eta = eta + 0.5; // -84.5 to -0.5
52  for (int iphi = 1; iphi <= MAX_IPHI; iphi++) {
53  Double_t phi = (Double_t)iphi - 0.5;
54  EBDetId id(ieta, iphi);
55  double val = (*payload)[id.rawId()];
56  barrel->Fill(phi, eta, val);
57  EBmean = EBmean + val;
58  EBrms = EBrms + val * val;
59  EBtot++;
60  }
61  }
62 
63  for (int sign = 0; sign < kSides; sign++) {
64  int thesign = sign == 1 ? 1 : -1;
65  for (int ix = 1; ix <= IX_MAX; ix++) {
66  for (int iy = 1; iy <= IY_MAX; iy++) {
67  if (!EEDetId::validDetId(ix, iy, thesign))
68  continue;
69  EEDetId id(ix, iy, thesign);
70  double val = (*payload)[id.rawId()];
71  EEmean = EEmean + val;
72  EErms = EErms + val * val;
73  EEtot++;
74  if (thesign == 1)
75  endc_p->Fill(ix, iy, val);
76  else
77  endc_m->Fill(ix, iy, val);
78  } // iy
79  } // ix
80  } // side
81  } // payload
82  double vt = (double)EBtot;
83  EBmean = EBmean / vt;
84  EBrms = EBrms / vt - (EBmean * EBmean);
85  EBrms = sqrt(EBrms);
86  if (EBrms == 0.)
87  EBrms = 0.001;
88  double pEBmin = EBmean - kRMS * EBrms;
89  double pEBmax = EBmean + kRMS * EBrms;
90  // std::cout << " mean " << EBmean << " rms " << EBrms << " entries " << EBtot << " min " << pEBmin << " max " << pEBmax << std::endl;
91  vt = (double)EEtot;
92  EEmean = EEmean / vt;
93  EErms = EErms / vt - (EEmean * EEmean);
94  EErms = sqrt(EErms);
95  if (EErms == 0.)
96  EErms = 0.001;
97  double pEEmin = EEmean - kRMS * EErms;
98  double pEEmax = EEmean + kRMS * EErms;
99  // std::cout << " mean " << EEmean << " rms " << EErms << " entries " << EEtot << " min " << pEEmin << " max " << pEEmax << std::endl;
100 
101  gStyle->SetPalette(1);
102  gStyle->SetOptStat(0);
103  TCanvas canvas("CC map", "CC map", 1600, 450);
104  TLatex t1;
105  t1.SetNDC();
106  t1.SetTextAlign(26);
107  t1.SetTextSize(0.05);
108  t1.DrawLatex(0.5, 0.96, Form("Ecal FloatCondObjectContainer, IOV %i", run));
109 
110  float xmi[3] = {0.0, 0.24, 0.76};
111  float xma[3] = {0.24, 0.76, 1.00};
112  TPad** pad = new TPad*;
113  for (int obj = 0; obj < 3; obj++) {
114  pad[obj] = new TPad(Form("p_%i", obj), Form("p_%i", obj), xmi[obj], 0.0, xma[obj], 0.94);
115  pad[obj]->Draw();
116  }
117 
118  pad[0]->cd();
119  DrawEE(endc_m, pEEmin, pEEmax);
120  pad[1]->cd();
121  DrawEB(barrel, pEBmin, pEBmax);
122  pad[2]->cd();
123  DrawEE(endc_p, pEEmin, pEEmax);
124 
125  std::string ImageName(m_imageFileName);
126  canvas.SaveAs(ImageName.c_str());
127  return true;
128  } // fill method
129  };
130 
131  /************************************************************************
132  2d plot of ECAL FloatCondObjectContainer difference between 2 IOVs
133  ************************************************************************/
134  class EcalFloatCondObjectContainerDiff : public cond::payloadInspector::PlotImage<EcalFloatCondObjectContainer> {
135  public:
136  EcalFloatCondObjectContainerDiff()
137  : cond::payloadInspector::PlotImage<EcalFloatCondObjectContainer>("ECAL FloatCondObjectContainer difference") {
138  setSingleIov(false);
139  }
140 
141  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
142  TH2F* barrel = new TH2F("EB", "EB difference", MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
143  TH2F* endc_p = new TH2F("EE+", "EE+ difference", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
144  TH2F* endc_m = new TH2F("EE-", "EE- difference", IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
145  double EBmean = 0., EBrms = 0., EEmean = 0., EErms = 0.;
146  int EBtot = 0, EEtot = 0;
147 
148  // unsigned int run[2] = {0, 0}, irun = 0;
149  unsigned int run[2], irun = 0;
150  float vEB[kEBChannels], vEE[kEEChannels];
151  for (auto const& iov : iovs) {
152  std::shared_ptr<EcalFloatCondObjectContainer> payload = fetchPayload(std::get<1>(iov));
153  run[irun] = std::get<0>(iov);
154  if (payload.get()) {
155  for (int ieta = -MAX_IETA; ieta <= MAX_IETA; ieta++) {
156  Double_t eta = (Double_t)ieta;
157  if (ieta == 0)
158  continue;
159  else if (ieta > 0.)
160  eta = eta - 0.5; // 0.5 to 84.5
161  else
162  eta = eta + 0.5; // -84.5 to -0.5
163  for (int iphi = 1; iphi <= MAX_IPHI; iphi++) {
164  Double_t phi = (Double_t)iphi - 0.5;
165  EBDetId id(ieta, iphi);
166  int channel = id.hashedIndex();
167  double val = (*payload)[id.rawId()];
168  if (irun == 0)
169  vEB[channel] = val;
170  else {
171  double diff = val - vEB[channel];
172  barrel->Fill(phi, eta, diff);
173  EBmean = EBmean + diff;
174  EBrms = EBrms + diff * diff;
175  EBtot++;
176  // std::cout << " entry " << EBtot << " mean " << EBmean << " rms " << EBrms << std::endl;
177  }
178  }
179  }
180 
181  for (int sign = 0; sign < kSides; sign++) {
182  int thesign = sign == 1 ? 1 : -1;
183  for (int ix = 1; ix <= IX_MAX; ix++) {
184  for (int iy = 1; iy <= IY_MAX; iy++) {
185  if (!EEDetId::validDetId(ix, iy, thesign))
186  continue;
187  EEDetId id(ix, iy, thesign);
188  int channel = id.hashedIndex();
189  double val = (*payload)[id.rawId()];
190  if (irun == 0)
191  vEE[channel] = val;
192  else {
193  double diff = val - vEE[channel];
194  EEmean = EEmean + diff;
195  EErms = EErms + diff * diff;
196  EEtot++;
197  if (thesign == 1)
198  endc_p->Fill(ix, iy, diff);
199  else
200  endc_m->Fill(ix, iy, diff);
201  }
202  } // iy
203  } // ix
204  } // side
205  } // payload
206  else
207  return false;
208  irun++;
209  } // loop over IOVs
210 
211  double vt = (double)EBtot;
212  EBmean = EBmean / vt;
213  EBrms = EBrms / vt - (EBmean * EBmean);
214  EBrms = sqrt(EBrms);
215  if (EBrms == 0.)
216  EBrms = 0.001;
217  double pEBmin = EBmean - kRMS * EBrms;
218  double pEBmax = EBmean + kRMS * EBrms;
219  // std::cout << " mean " << EBmean << " rms " << EBrms << " entries " << EBtot << " min " << pEBmin << " max " << pEBmax << std::endl;
220  vt = (double)EEtot;
221  EEmean = EEmean / vt;
222  EErms = EErms / vt - (EEmean * EEmean);
223  EErms = sqrt(EErms);
224  if (EErms == 0.)
225  EErms = 0.001;
226  double pEEmin = EEmean - kRMS * EErms;
227  double pEEmax = EEmean + kRMS * EErms;
228  // std::cout << " mean " << EEmean << " rms " << EErms << " entries " << EEtot << " min " << pEEmin << " max " << pEEmax << std::endl;
229 
230  gStyle->SetPalette(1);
231  gStyle->SetOptStat(0);
232  TCanvas canvas("CC map", "CC map", 1600, 450);
233  TLatex t1;
234  t1.SetNDC();
235  t1.SetTextAlign(26);
236  t1.SetTextSize(0.05);
237  t1.DrawLatex(0.5, 0.96, Form("Ecal FloatCondObjectContainer, IOV %i - %i", run[1], run[0]));
238 
239  float xmi[3] = {0.0, 0.24, 0.76};
240  float xma[3] = {0.24, 0.76, 1.00};
241  TPad** pad = new TPad*;
242  for (int obj = 0; obj < 3; obj++) {
243  pad[obj] = new TPad(Form("p_%i", obj), Form("p_%i", obj), xmi[obj], 0.0, xma[obj], 0.94);
244  pad[obj]->Draw();
245  }
246 
247  pad[0]->cd();
248  DrawEE(endc_m, pEEmin, pEEmax);
249  pad[1]->cd();
250  DrawEB(barrel, pEBmin, pEBmax);
251  pad[2]->cd();
252  DrawEE(endc_p, pEEmin, pEEmax);
253 
254  std::string ImageName(m_imageFileName);
255  canvas.SaveAs(ImageName.c_str());
256  return true;
257  } // fill method
258  };
259 
260 } // namespace
261 
262 // Register the classes as boost python plugin
264  PAYLOAD_INSPECTOR_CLASS(EcalFloatCondObjectContainerPlot);
265  PAYLOAD_INSPECTOR_CLASS(EcalFloatCondObjectContainerDiff);
266 }
change_name.diff
diff
Definition: change_name.py:13
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
kEEChannels
Definition: EcalFloatCondObjectContainerUtils.h:9
MAX_IPHI
Definition: EcalFloatCondObjectContainerUtils.h:14
IX_MAX
Definition: EcalFloatCondObjectContainerUtils.h:20
IY_MAX
Definition: EcalFloatCondObjectContainerUtils.h:21
EBDetId
Definition: EBDetId.h:17
PayloadInspector.h
EBDetId.h
EEDetId.h
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
PayloadInspectorModule.h
DrawEE
void DrawEE(TH2F *endc, float min, float max)
Definition: EcalDrawUtils.h:29
EcalCondObjectContainer.h
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
DrawEB
void DrawEB(TH2F *ebmap, float min, float max)
Definition: EcalDrawUtils.h:4
PVValHelper::eta
Definition: PVValidationHelpers.h:69
MIN_IETA
Definition: EcalFloatCondObjectContainerUtils.h:11
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
jets_cff.payload
payload
Definition: jets_cff.py:32
PAYLOAD_INSPECTOR_MODULE
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: PayloadInspectorModule.h:8
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
EEDetId
Definition: EEDetId.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond
Definition: plugin.cc:23
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
IY_MIN
Definition: EcalFloatCondObjectContainerUtils.h:19
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
kSides
static const int kSides
Definition: EcalGeomPhiSymHelper.h:9
DDAxes::phi
heppy_batch.val
val
Definition: heppy_batch.py:351
writedatasetfile.run
run
Definition: writedatasetfile.py:27
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
cond::payloadInspector::PlotImpl::fill
virtual bool fill()=0
cond::payloadInspector::PlotImage
Definition: PayloadInspector.h:852
EEDetId::validDetId
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
kEBChannels
Definition: EcalFloatCondObjectContainerUtils.h:9
IX_MIN
Definition: EcalFloatCondObjectContainerUtils.h:18
MAX_IETA
Definition: EcalFloatCondObjectContainerUtils.h:13