CMS 3D CMS Logo

EcalSimComponentShape_PayloadInspector.cc
Go to the documentation of this file.
4 
5 // the data format of the condition to be inspected
7 
8 #include "TProfile.h"
9 #include "TCanvas.h"
10 #include "TStyle.h"
11 #include "TLine.h"
12 #include "TLatex.h"
13 #include "TMarker.h"
14 
15 #include <string>
16 
17 namespace {
18  /********************************************
19  profile of ECAL SimComponentShape for 1 IOV
20  ********************************************/
21  class EcalSimComponentShapeProfile : public cond::payloadInspector::PlotImage<EcalSimComponentShape> {
22  public:
23  EcalSimComponentShapeProfile()
24  : cond::payloadInspector::PlotImage<EcalSimComponentShape>("ECAL SimComponentShape - Profile ") {
25  setSingleIov(true);
26  }
27 
28  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> > &iovs) override {
29  auto iov = iovs.front();
30  std::shared_ptr<EcalSimComponentShape> payload = fetchPayload(std::get<1>(iov));
31  unsigned int run = std::get<0>(iov);
32  std::vector<TProfile *> profiles;
33  std::vector<int> EBnbins;
34  std::vector<double> EBxmaxs;
35  double EBth;
36  int iShape = 0;
37  if (payload.get()) {
38  EBth = (*payload).barrel_thresh;
39  double time = (*payload).time_interval;
40  std::vector<std::vector<float> > EBshapes = (*payload).barrel_shapes;
41  char nameBuffer[50];
42  for (auto EBshape : EBshapes) {
43  EBnbins.push_back(EBshape.size());
44  EBxmaxs.push_back(EBnbins[iShape] * time);
45  sprintf(nameBuffer, "EBComponentShape_%d", iShape);
46  profiles.push_back(new TProfile(nameBuffer, "", EBnbins[iShape], 0, EBxmaxs[iShape]));
47  for (int s = 0; s < EBnbins[iShape]; s++) {
48  double val = EBshape[s];
49  profiles[iShape]->Fill(s, val);
50  }
51  ++iShape;
52  }
53  } // if payload.get()
54  else
55  return false;
56 
57  // gStyle->SetPalette(1);
58  gStyle->SetOptStat(0);
59  gStyle->SetPalette(kThermometer);
60  TCanvas canvas("ESPS", "ESPS", 1000, 500);
61  TLatex t1;
62  t1.SetNDC();
63  t1.SetTextAlign(26);
64  t1.SetTextSize(0.05);
65  t1.DrawLatex(0.5, 0.96, Form("Sim Component Shapes, IOV %i", run));
66 
67  TPad *pad = new TPad("p_0", "p_0", 0.0, 0.0, 1.0, 0.95);
68  pad->Draw();
69  pad->cd();
70  iShape = 0;
71  for (auto profile : profiles) {
72  if (iShape == 0) {
73  profile->SetXTitle("time (ns)");
74  profile->SetYTitle("normalized amplitude (ADC#)");
75  profile->GetXaxis()->SetRangeUser(0., 275.);
76  profile->GetYaxis()->SetRangeUser(0., 1.25);
77  }
78  profile->SetMarkerColor(TColor::GetPalette().At(10 * iShape));
79  profile->SetLineColor(TColor::GetPalette().At(10 * iShape));
80  profile->SetMarkerStyle(20);
81  profile->SetMarkerSize(.25);
82  if (iShape == 0) {
83  profile->Draw("");
84  } else {
85  profile->Draw("SAME");
86  }
87  ++iShape;
88  }
89  pad->BuildLegend(.7, .225, .85, .8);
90  t1.SetTextAlign(12);
91  t1.DrawLatex(0.4, 0.85, Form("EB component shapes, threshold %f", EBth));
92 
93  std::string ImageName(m_imageFileName);
94  canvas.SaveAs(ImageName.c_str());
95  return true;
96  } // fill method
97  };
98 
99 } // namespace
100 
101 // Register the classes as boost python plugin
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: plugin.cc:23
def canvas(sub, attr)
Definition: svgfig.py:482
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)