CMS 3D CMS Logo

HcalL1TriggerObjects_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/HcalL1TriggerObjects.h" //or L1TriggerObject.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 HcalL1TriggerObjectContainer : public HcalObjRepresent::HcalDataContainer<HcalL1TriggerObjects,HcalL1TriggerObject> {
27  public:
28  HcalL1TriggerObjectContainer(std::shared_ptr<HcalL1TriggerObjects> payload, unsigned int run) : HcalObjRepresent::HcalDataContainer<HcalL1TriggerObjects,HcalL1TriggerObject>(payload, run) {}
29  float getValue(HcalL1TriggerObject* trig) override {
30  return trig->getRespGain();
31  }
32  };
33 
34  /******************************************
35  2d plot of HCAL L1TriggerObject of 1 IOV
36  ******************************************/
37  class HcalL1TriggerObjectsPlot : public cond::payloadInspector::PlotImage<HcalL1TriggerObjects> {
38  public:
39  HcalL1TriggerObjectsPlot() : cond::payloadInspector::PlotImage<HcalL1TriggerObjects>("HCAL L1TriggerObject 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<HcalL1TriggerObjects> payload = fetchPayload( std::get<1>(iov) );
48  if(payload.get()) {
49  HcalL1TriggerObjectContainer* objContainer = new HcalL1TriggerObjectContainer(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 L1TriggerObject difference between 2 IOVs
58  **********************************************************/
59  class HcalL1TriggerObjectsRatio : public cond::payloadInspector::PlotImage<HcalL1TriggerObjects> {
60 
61  public:
62  HcalL1TriggerObjectsRatio() : cond::payloadInspector::PlotImage<HcalL1TriggerObjects>("HCAL L1TriggerObject 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<HcalL1TriggerObjects> payload1 = fetchPayload( std::get<1>(iov1) );
72  std::shared_ptr<HcalL1TriggerObjects> payload2 = fetchPayload( std::get<1>(iov2) );
73 
74  if(payload1.get() && payload2.get()) {
75  HcalL1TriggerObjectContainer* objContainer1 = new HcalL1TriggerObjectContainer(payload1, std::get<0>(iov1));
76  HcalL1TriggerObjectContainer* objContainer2 = new HcalL1TriggerObjectContainer(payload2, std::get<0>(iov2));
77 
78  objContainer2->Divide(objContainer1);
79 
80 
81 
82  std::string ImageName(m_imageFileName);
83  objContainer2->getCanvasAll()->SaveAs(ImageName.c_str());
84  return true;} else return false;
85 
86 
87  }// fill method
88  };
89  /******************************************
90  2d plot of HCAL L1TriggerObject of 1 IOV
91  ******************************************/
92  class HcalL1TriggerObjectsEtaPlot : public cond::payloadInspector::PlotImage<HcalL1TriggerObjects> {
93  public:
94  HcalL1TriggerObjectsEtaPlot() : cond::payloadInspector::PlotImage<HcalL1TriggerObjects>("HCAL L1TriggerObject Ratios - map ") {
95  setSingleIov( true );
96  }
97 
98  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
99 
100 
101  auto iov = iovs.front();
102  std::shared_ptr<HcalL1TriggerObjects> payload = fetchPayload( std::get<1>(iov) );
103  if(payload.get()) {
104  HcalL1TriggerObjectContainer* objContainer = new HcalL1TriggerObjectContainer(payload, std::get<0>(iov));
105  std::string ImageName(m_imageFileName);
106  objContainer->getCanvasAll("EtaProfile")->SaveAs(ImageName.c_str());
107  return true;} else return false;
108  }// fill method
109  };
110 
111  /**********************************************************
112  2d plot of HCAL L1TriggerObject difference between 2 IOVs
113  **********************************************************/
114  class HcalL1TriggerObjectsEtaRatio : public cond::payloadInspector::PlotImage<HcalL1TriggerObjects> {
115 
116  public:
117  HcalL1TriggerObjectsEtaRatio() : cond::payloadInspector::PlotImage<HcalL1TriggerObjects>("HCAL L1TriggerObject Ratios difference") {
118  setSingleIov(false);
119  }
120 
121  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
122 
123  auto iov1 = iovs.front();
124  auto iov2 = iovs.back();
125 
126  std::shared_ptr<HcalL1TriggerObjects> payload1 = fetchPayload( std::get<1>(iov1) );
127  std::shared_ptr<HcalL1TriggerObjects> payload2 = fetchPayload( std::get<1>(iov2) );
128 
129  if(payload1.get() && payload2.get()) {
130  HcalL1TriggerObjectContainer* objContainer1 = new HcalL1TriggerObjectContainer(payload1, std::get<0>(iov1));
131  HcalL1TriggerObjectContainer* objContainer2 = new HcalL1TriggerObjectContainer(payload2, std::get<0>(iov2));
132 
133  objContainer2->Divide(objContainer1);
134 
135 
136  std::string ImageName(m_imageFileName);
137  objContainer2->getCanvasAll("EtaProfile")->SaveAs(ImageName.c_str());
138  return true;} else return false;
139 
140 
141  }// fill method
142  };
143  /******************************************
144  2d plot of HCAL L1TriggerObject of 1 IOV
145  ******************************************/
146  class HcalL1TriggerObjectsPhiPlot : public cond::payloadInspector::PlotImage<HcalL1TriggerObjects> {
147  public:
148  HcalL1TriggerObjectsPhiPlot() : cond::payloadInspector::PlotImage<HcalL1TriggerObjects>("HCAL L1TriggerObject Ratios - map ") {
149  setSingleIov( true );
150  }
151 
152  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
153 
154 
155  auto iov = iovs.front();
156  std::shared_ptr<HcalL1TriggerObjects> payload = fetchPayload( std::get<1>(iov) );
157  if(payload.get()) {
158  HcalL1TriggerObjectContainer* objContainer = new HcalL1TriggerObjectContainer(payload, std::get<0>(iov));
159  std::string ImageName(m_imageFileName);
160  objContainer->getCanvasAll("PhiProfile")->SaveAs(ImageName.c_str());
161  return true;} else return false;
162  }// fill method
163  };
164 
165  /**********************************************************
166  2d plot of HCAL L1TriggerObject difference between 2 IOVs
167  **********************************************************/
168  class HcalL1TriggerObjectsPhiRatio : public cond::payloadInspector::PlotImage<HcalL1TriggerObjects> {
169 
170  public:
171  HcalL1TriggerObjectsPhiRatio() : cond::payloadInspector::PlotImage<HcalL1TriggerObjects>("HCAL L1TriggerObject Ratios difference") {
172  setSingleIov(false);
173  }
174 
175  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
176 
177  auto iov1 = iovs.front();
178  auto iov2 = iovs.back();
179 
180  std::shared_ptr<HcalL1TriggerObjects> payload1 = fetchPayload( std::get<1>(iov1) );
181  std::shared_ptr<HcalL1TriggerObjects> payload2 = fetchPayload( std::get<1>(iov2) );
182 
183  if(payload1.get() && payload2.get()) {
184  HcalL1TriggerObjectContainer* objContainer1 = new HcalL1TriggerObjectContainer(payload1, std::get<0>(iov1));
185  HcalL1TriggerObjectContainer* objContainer2 = new HcalL1TriggerObjectContainer(payload2, std::get<0>(iov2));
186 
187  objContainer2->Divide(objContainer1);
188 
189 
190  std::string ImageName(m_imageFileName);
191  objContainer2->getCanvasAll("PhiProfile")->SaveAs(ImageName.c_str());
192  return true;} else return false;
193 
194 
195  }// fill method
196  };
197 } // close namespace
198 
199  // Register the classes as boost python plugin
201  PAYLOAD_INSPECTOR_CLASS(HcalL1TriggerObjectsPlot);
202  PAYLOAD_INSPECTOR_CLASS(HcalL1TriggerObjectsRatio);
203  PAYLOAD_INSPECTOR_CLASS(HcalL1TriggerObjectsEtaPlot);
204  PAYLOAD_INSPECTOR_CLASS(HcalL1TriggerObjectsEtaRatio);
205  PAYLOAD_INSPECTOR_CLASS(HcalL1TriggerObjectsPhiPlot);
206  PAYLOAD_INSPECTOR_CLASS(HcalL1TriggerObjectsPhiRatio);
207 }
virtual float getValue(Item *item)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
float getRespGain() const
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: plugin.cc:24