CMS 3D CMS Logo

HcalPedestals_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 HcalPedestalContainer : public HcalObjRepresent::HcalDataContainer<HcalPedestals,HcalPedestal> {
24  public:
25  HcalPedestalContainer(std::shared_ptr<HcalPedestals> payload, unsigned int run) : HcalObjRepresent::HcalDataContainer<HcalPedestals,HcalPedestal>(payload, run) {}
26  float getValue(HcalPedestal* ped) override {
27  return (ped->getValue(0) + ped->getValue(1) + ped->getValue(2) + ped->getValue(3))/4;
28  }
29  };
30 
31  /******************************************
32  2d plot of HCAL Pedestal of 1 IOV
33  ******************************************/
34  class HcalPedestalsPlot : public cond::payloadInspector::PlotImage<HcalPedestals> {
35  public:
36  HcalPedestalsPlot() : cond::payloadInspector::PlotImage<HcalPedestals>("HCAL Pedestal 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<HcalPedestals> payload = fetchPayload( std::get<1>(iov) );
43  if(payload.get()) {
44  HcalPedestalContainer* objContainer = new HcalPedestalContainer(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 Pedestal difference between 2 IOVs
53  **********************************************************/
54  class HcalPedestalsDiff : public cond::payloadInspector::PlotImage<HcalPedestals> {
55 
56  public:
57  HcalPedestalsDiff() : cond::payloadInspector::PlotImage<HcalPedestals>("HCAL Pedestal 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<HcalPedestals> payload1 = fetchPayload( std::get<1>(iov1) );
67  std::shared_ptr<HcalPedestals> payload2 = fetchPayload( std::get<1>(iov2) );
68 
69  if(payload1.get() && payload2.get()) {
70  HcalPedestalContainer* objContainer1 = new HcalPedestalContainer(payload1, std::get<0>(iov1));
71  HcalPedestalContainer* objContainer2 = new HcalPedestalContainer(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 Pedestal of 1 IOV
80  ******************************************/
81  class HcalPedestalsEtaPlot : public cond::payloadInspector::PlotImage<HcalPedestals> {
82  public:
83  HcalPedestalsEtaPlot() : cond::payloadInspector::PlotImage<HcalPedestals>("HCAL Pedestal 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<HcalPedestals> payload = fetchPayload( std::get<1>(iov) );
90  if(payload.get()) {
91  HcalPedestalContainer* objContainer = new HcalPedestalContainer(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 Pedestal difference between 2 IOVs
100  **********************************************************/
101  class HcalPedestalsEtaDiff : public cond::payloadInspector::PlotImage<HcalPedestals> {
102 
103  public:
104  HcalPedestalsEtaDiff() : cond::payloadInspector::PlotImage<HcalPedestals>("HCAL Pedestal 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<HcalPedestals> payload1 = fetchPayload( std::get<1>(iov1) );
114  std::shared_ptr<HcalPedestals> payload2 = fetchPayload( std::get<1>(iov2) );
115 
116  if(payload1.get() && payload2.get()) {
117  HcalPedestalContainer* objContainer1 = new HcalPedestalContainer(payload1, std::get<0>(iov1));
118  HcalPedestalContainer* objContainer2 = new HcalPedestalContainer(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 Pedestal of 1 IOV
127  ******************************************/
128  class HcalPedestalsPhiPlot : public cond::payloadInspector::PlotImage<HcalPedestals> {
129  public:
130  HcalPedestalsPhiPlot() : cond::payloadInspector::PlotImage<HcalPedestals>("HCAL Pedestal 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<HcalPedestals> payload = fetchPayload( std::get<1>(iov) );
137  if(payload.get()) {
138  HcalPedestalContainer* objContainer = new HcalPedestalContainer(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 Pedestal difference between 2 IOVs
147  **********************************************************/
148  class HcalPedestalsPhiDiff : public cond::payloadInspector::PlotImage<HcalPedestals> {
149 
150  public:
151  HcalPedestalsPhiDiff() : cond::payloadInspector::PlotImage<HcalPedestals>("HCAL Pedestal 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<HcalPedestals> payload1 = fetchPayload( std::get<1>(iov1) );
161  std::shared_ptr<HcalPedestals> payload2 = fetchPayload( std::get<1>(iov2) );
162 
163  if(payload1.get() && payload2.get()) {
164  HcalPedestalContainer* objContainer1 = new HcalPedestalContainer(payload1, std::get<0>(iov1));
165  HcalPedestalContainer* objContainer2 = new HcalPedestalContainer(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(HcalPedestalsPlot);
177  PAYLOAD_INSPECTOR_CLASS(HcalPedestalsDiff);
178  PAYLOAD_INSPECTOR_CLASS(HcalPedestalsPhiPlot);
179  PAYLOAD_INSPECTOR_CLASS(HcalPedestalsEtaPlot);
180  PAYLOAD_INSPECTOR_CLASS(HcalPedestalsEtaDiff);
181  PAYLOAD_INSPECTOR_CLASS(HcalPedestalsPhiDiff);
182 }
virtual float getValue(Item *item)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalPedestal.h:21
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: plugin.cc:24