CMS 3D CMS Logo

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