CMS 3D CMS Logo

SiStripThreshold_PayloadInspector.cc
Go to the documentation of this file.
1 
12 
13 // the data format of the condition to be inspected
19 
20 // needed for the tracker map
22 
23 // auxilliary functions
26 
28 
29 #include <memory>
30 #include <sstream>
31 #include <iostream>
32 
33 // include ROOT
34 #include "TH2F.h"
35 #include "TLegend.h"
36 #include "TCanvas.h"
37 #include "TLine.h"
38 #include "TStyle.h"
39 #include "TLatex.h"
40 #include "TPave.h"
41 #include "TPaveStats.h"
42 
43 using namespace std;
44 
45 namespace {
46 
47  /************************************************
48  test class
49  *************************************************/
50 
51  class SiStripThresholdTest : public cond::payloadInspector::Histogram1D<SiStripThreshold> {
52 
53  public:
54  SiStripThresholdTest() : cond::payloadInspector::Histogram1D<SiStripThreshold>("SiStrip Threshold test",
55  "SiStrip Threshold test", 10,0.0,10.0),
56  m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile(edm::FileInPath("Geometry/TrackerCommonData/data/trackerParameters.xml").fullPath())}
57  {
58  Base::setSingleIov( true );
59  }
60 
61  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
62  for ( auto const & iov: iovs) {
63  std::shared_ptr<SiStripThreshold> payload = Base::fetchPayload( std::get<1>(iov) );
64  if( payload.get() ){
65 
66  fillWithValue(1.);
67 
68  std::stringstream ss;
69  ss << "Summary of strips threshold:" << std::endl;
70 
71  payload->printSummary(ss,&m_trackerTopo);
72 
73  std::vector<uint32_t> detid;
74  payload->getDetIds(detid);
75 
76  std::cout<<ss.str()<<std::endl;
77 
78  }
79  }
80  return true;
81  }// fill
82  private:
83  TrackerTopology m_trackerTopo;
84  };
85 
86  /************************************************************
87  1d histogram of SiStripThresholds of 1 IOV - High Threshold
88  *************************************************************/
89 
90  class SiStripThresholdValueHigh : public cond::payloadInspector::Histogram1D<SiStripThreshold> {
91 
92  public:
93  SiStripThresholdValueHigh() : cond::payloadInspector::Histogram1D<SiStripThreshold>("SiStrip High threshold values (checked per APV)",
94  "SiStrip High threshold values (cheched per APV)", 10,0.0,10){
95  Base::setSingleIov( true );
96  }
97 
98  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
99 
100  edm::FileInPath fp_ = edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat");
102 
103  for ( auto const & iov: iovs) {
104  std::shared_ptr<SiStripThreshold> payload = Base::fetchPayload( std::get<1>(iov) );
105  if( payload.get() ){
106  std::vector<uint32_t> detid;
107  payload->getDetIds(detid);
108 
109  for (const auto & d : detid) {
110  //std::cout<<d<<std::endl;
111  SiStripThreshold::Range range=payload->getRange(d);
112 
113  int nAPVs = reader->getNumberOfApvsAndStripLength(d).first;
114 
115  for( int it=0; it<nAPVs; ++it ){
116 
117  auto hth = payload->getData(it*128,range).getHth();
118  //std::cout<<hth<<std::endl;
119  fillWithValue(hth);
120  }
121  }
122  }
123  }
124 
125  delete reader;
126  return true;
127  }
128  };
129 
130  /************************************************************
131  1d histogram of SiStripThresholds of 1 IOV - Low Threshold
132  *************************************************************/
133 
134  class SiStripThresholdValueLow : public cond::payloadInspector::Histogram1D<SiStripThreshold> {
135 
136  public:
137  SiStripThresholdValueLow() : cond::payloadInspector::Histogram1D<SiStripThreshold>("SiStrip Low threshold values (checked per APV)",
138  "SiStrip Low threshold values (cheched per APV)", 10,0.0,10){
139  Base::setSingleIov( true );
140  }
141 
142  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
143 
144  edm::FileInPath fp_ = edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat");
146 
147  for ( auto const & iov: iovs) {
148  std::shared_ptr<SiStripThreshold> payload = Base::fetchPayload( std::get<1>(iov) );
149  if( payload.get() ){
150  std::vector<uint32_t> detid;
151  payload->getDetIds(detid);
152 
153  for (const auto & d : detid) {
154  //std::cout<<d<<std::endl;
155  SiStripThreshold::Range range=payload->getRange(d);
156 
157  int nAPVs = reader->getNumberOfApvsAndStripLength(d).first;
158 
159  for( int it=0; it<nAPVs; ++it ){
160 
161  auto lth = payload->getData(it*128,range).getLth();
162  //std::cout<<hth<<std::endl;
163  fillWithValue(lth);
164  }
165  }
166  }
167  }
168 
169  delete reader;
170  return true;
171  }
172  };
173 
174 
175 
176 
177 
178 }
179 
181  PAYLOAD_INSPECTOR_CLASS(SiStripThresholdTest);
182  PAYLOAD_INSPECTOR_CLASS(SiStripThresholdValueHigh);
183  PAYLOAD_INSPECTOR_CLASS(SiStripThresholdValueLow);
184 
185 }
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
std::pair< ContainerIterator, ContainerIterator > Range
Definition: plugin.cc:24
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
std::string fullPath() const
Definition: FileInPath.cc:163