CMS 3D CMS Logo

HcalPedestalWidths_PayloadInspector.cc
Go to the documentation of this file.
7 
8 // the data format of the condition to be inspected
10 
11 #include "TH2F.h"
12 #include "TCanvas.h"
13 #include "TLine.h"
14 #include "TStyle.h"
15 #include "TLatex.h"
16 #include "TPave.h"
17 #include "TPaveStats.h"
18 #include <string>
19 #include <fstream>
20 
21 namespace {
22 
23  class HcalPedestalWidthContainer : public HcalObjRepresent::HcalDataContainer<HcalPedestalWidths,HcalPedestalWidth> {
24  public:
25  HcalPedestalWidthContainer(std::shared_ptr<HcalPedestalWidths> payload, unsigned int run) : HcalObjRepresent::HcalDataContainer<HcalPedestalWidths,HcalPedestalWidth>(payload, run) {}
26  float getValue(HcalPedestalWidth* ped) override {
27  return (ped->getWidth(0) + ped->getWidth(1) + ped->getWidth(2) + ped->getWidth(3))/4;
28  }
29  };
30 
31  /******************************************
32  2d plot of HCAL PedestalWidth of 1 IOV
33  ******************************************/
34  class HcalPedestalWidthsPlot : public cond::payloadInspector::PlotImage<HcalPedestalWidths> {
35  public:
36  HcalPedestalWidthsPlot() : cond::payloadInspector::PlotImage<HcalPedestalWidths>("HCAL PedestalWidth Ratios - map ") {
37  setSingleIov( true );
38  }
39 
40  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
41  auto iov = iovs.front();
42  std::shared_ptr<HcalPedestalWidths> payload = fetchPayload( std::get<1>(iov) );
43  if(payload.get()) {
44  HcalPedestalWidthContainer* objContainer = new HcalPedestalWidthContainer(payload, std::get<0>(iov));
45  std::string ImageName(m_imageFileName);
46  objContainer->getCanvasAll()->SaveAs(ImageName.c_str());
47  return true;} else return false;
48  }// fill method
49  };
50 
51  /**********************************************************
52  2d plot of HCAL PedestalWidth difference between 2 IOVs
53  **********************************************************/
54  class HcalPedestalWidthsDiff : public cond::payloadInspector::PlotImage<HcalPedestalWidths> {
55 
56  public:
57  HcalPedestalWidthsDiff() : cond::payloadInspector::PlotImage<HcalPedestalWidths>("HCAL PedestalWidth Ratios difference") {
58  setSingleIov(false);
59  }
60 
61  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
62 
63  auto iov1 = iovs.front();
64  auto iov2 = iovs.back();
65 
66  std::shared_ptr<HcalPedestalWidths> payload1 = fetchPayload( std::get<1>(iov1) );
67  std::shared_ptr<HcalPedestalWidths> payload2 = fetchPayload( std::get<1>(iov2) );
68 
69  if(payload1.get() && payload2.get()) {
70  HcalPedestalWidthContainer* objContainer1 = new HcalPedestalWidthContainer(payload1, std::get<0>(iov1));
71  HcalPedestalWidthContainer* objContainer2 = new HcalPedestalWidthContainer(payload2, std::get<0>(iov2));
72  objContainer2->Subtract(objContainer1);
73  std::string ImageName(m_imageFileName);
74  objContainer2->getCanvasAll()->SaveAs(ImageName.c_str());
75  return true;} else return false;
76  }// fill method
77  };
78  /******************************************
79  2d plot of HCAL PedestalWidth of 1 IOV
80  ******************************************/
81  class HcalPedestalWidthsEtaPlot : public cond::payloadInspector::PlotImage<HcalPedestalWidths> {
82  public:
83  HcalPedestalWidthsEtaPlot() : cond::payloadInspector::PlotImage<HcalPedestalWidths>("HCAL PedestalWidth Ratios - map ") {
84  setSingleIov( true );
85  }
86 
87  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
88  auto iov = iovs.front();
89  std::shared_ptr<HcalPedestalWidths> payload = fetchPayload( std::get<1>(iov) );
90  if(payload.get()) {
91  HcalPedestalWidthContainer* objContainer = new HcalPedestalWidthContainer(payload, std::get<0>(iov));
92  std::string ImageName(m_imageFileName);
93  objContainer->getCanvasAll("EtaProfile")->SaveAs(ImageName.c_str());
94  return true;} else return false;
95  }// fill method
96  };
97 
98  /**********************************************************
99  2d plot of HCAL PedestalWidth difference between 2 IOVs
100  **********************************************************/
101  class HcalPedestalWidthsEtaDiff : public cond::payloadInspector::PlotImage<HcalPedestalWidths> {
102 
103  public:
104  HcalPedestalWidthsEtaDiff() : cond::payloadInspector::PlotImage<HcalPedestalWidths>("HCAL PedestalWidth Ratios difference") {
105  setSingleIov(false);
106  }
107 
108  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
109 
110  auto iov1 = iovs.front();
111  auto iov2 = iovs.back();
112 
113  std::shared_ptr<HcalPedestalWidths> payload1 = fetchPayload( std::get<1>(iov1) );
114  std::shared_ptr<HcalPedestalWidths> payload2 = fetchPayload( std::get<1>(iov2) );
115 
116  if(payload1.get() && payload2.get()) {
117  HcalPedestalWidthContainer* objContainer1 = new HcalPedestalWidthContainer(payload1, std::get<0>(iov1));
118  HcalPedestalWidthContainer* objContainer2 = new HcalPedestalWidthContainer(payload2, std::get<0>(iov2));
119  objContainer2->Subtract(objContainer1);
120  std::string ImageName(m_imageFileName);
121  objContainer2->getCanvasAll("EtaProfile")->SaveAs(ImageName.c_str());
122  return true;} else return false;
123  }// fill method
124  };
125  /******************************************
126  2d plot of HCAL PedestalWidth of 1 IOV
127  ******************************************/
128  class HcalPedestalWidthsPhiPlot : public cond::payloadInspector::PlotImage<HcalPedestalWidths> {
129  public:
130  HcalPedestalWidthsPhiPlot() : cond::payloadInspector::PlotImage<HcalPedestalWidths>("HCAL PedestalWidth Ratios - map ") {
131  setSingleIov( true );
132  }
133 
134  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
135  auto iov = iovs.front();
136  std::shared_ptr<HcalPedestalWidths> payload = fetchPayload( std::get<1>(iov) );
137  if(payload.get()) {
138  HcalPedestalWidthContainer* objContainer = new HcalPedestalWidthContainer(payload, std::get<0>(iov));
139  std::string ImageName(m_imageFileName);
140  objContainer->getCanvasAll("PhiProfile")->SaveAs(ImageName.c_str());
141  return true;} else return false;
142  }// fill method
143  };
144 
145  /**********************************************************
146  2d plot of HCAL PedestalWidth difference between 2 IOVs
147  **********************************************************/
148  class HcalPedestalWidthsPhiDiff : public cond::payloadInspector::PlotImage<HcalPedestalWidths> {
149 
150  public:
151  HcalPedestalWidthsPhiDiff() : cond::payloadInspector::PlotImage<HcalPedestalWidths>("HCAL PedestalWidth Ratios difference") {
152  setSingleIov(false);
153  }
154 
155  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
156 
157  auto iov1 = iovs.front();
158  auto iov2 = iovs.back();
159 
160  std::shared_ptr<HcalPedestalWidths> payload1 = fetchPayload( std::get<1>(iov1) );
161  std::shared_ptr<HcalPedestalWidths> payload2 = fetchPayload( std::get<1>(iov2) );
162 
163  if(payload1.get() && payload2.get()) {
164  HcalPedestalWidthContainer* objContainer1 = new HcalPedestalWidthContainer(payload1, std::get<0>(iov1));
165  HcalPedestalWidthContainer* objContainer2 = new HcalPedestalWidthContainer(payload2, std::get<0>(iov2));
166  objContainer2->Subtract(objContainer1);
167  std::string ImageName(m_imageFileName);
168  objContainer2->getCanvasAll("PhiProfile")->SaveAs(ImageName.c_str());
169  return true;} else return false;
170  }// fill method
171  };
172 } // close namespace
173 
174  // Register the classes as boost python plugin
176  PAYLOAD_INSPECTOR_CLASS(HcalPedestalWidthsPlot);
177  PAYLOAD_INSPECTOR_CLASS(HcalPedestalWidthsDiff);
178  PAYLOAD_INSPECTOR_CLASS(HcalPedestalWidthsPhiPlot);
179  PAYLOAD_INSPECTOR_CLASS(HcalPedestalWidthsPhiDiff);
180  PAYLOAD_INSPECTOR_CLASS(HcalPedestalWidthsEtaPlot);
181  PAYLOAD_INSPECTOR_CLASS(HcalPedestalWidthsEtaDiff);
182 }
virtual float getValue(Item *item)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
float getWidth(int fCapId) const
get width (sqrt(sigma_i_i)) for capId = 0..3
Definition: plugin.cc:24