CMS 3D CMS Logo

SiStripApvGain_PayloadInspector.cc
Go to the documentation of this file.
4 
5 // the data format of the condition to be inspected
8 
9 #include <memory>
10 #include <sstream>
11 
12 namespace {
13 
14  /************************************************
15  1d histogram of SiStripApvGains of 1 IOV
16  *************************************************/
17 
18  // inherit from one of the predefined plot class: Histogram1D
19  class SiStripApvGainsValue : public cond::payloadInspector::Histogram1D<SiStripApvGain> {
20 
21  public:
22  SiStripApvGainsValue() : cond::payloadInspector::Histogram1D<SiStripApvGain>("SiStripApv Gains values",
23  "SiStripApv Gains values", 200,0.0,2.0){
24  Base::setSingleIov( true );
25  }
26 
27  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ){
28  for ( auto const & iov: iovs) {
29  std::shared_ptr<SiStripApvGain> payload = Base::fetchPayload( std::get<1>(iov) );
30  if( payload.get() ){
31 
32  std::vector<uint32_t> detid;
33  payload->getDetIds(detid);
34 
35  for (const auto & d : detid) {
36  SiStripApvGain::Range range=payload->getRange(d);
37  for(int it=0;it<range.second-range.first;it++){
38 
39  // to be used to fill the histogram
40  fillWithValue(payload->getApvGain(it,range));
41 
42  }// loop over APVs
43  } // loop over detIds
44  }// payload
45  }// iovs
46  return true;
47  }// fill
48  };
49 
50  /************************************************
51  time history histogram of SiStripApvGains
52  *************************************************/
53 
54  class SiStripApvGainByRunMeans : public cond::payloadInspector::HistoryPlot<SiStripApvGain,float> {
55  public:
56  SiStripApvGainByRunMeans() : cond::payloadInspector::HistoryPlot<SiStripApvGain,float>( "SiStripApv Gains average","average Strip APV gain value"){}
57  virtual ~SiStripApvGainByRunMeans() = default;
58 
59  float getFromPayload( SiStripApvGain& payload ){
60 
61  std::vector<uint32_t> detid;
62  payload.getDetIds(detid);
63 
64  float nAPVs=0;
65  float sumOfGains=0;
66 
67  for (const auto & d : detid) {
68  SiStripApvGain::Range range=payload.getRange(d);
69  for(int it=0;it<range.second-range.first;it++){
70  nAPVs+=1;
71  sumOfGains+=payload.getApvGain(it,range);
72  } // loop over APVs
73  } // loop over detIds
74 
75  return sumOfGains/nAPVs;
76  } // payload
77  };
78 
79  /************************************************
80  time history histogram of TIB SiStripApvGains
81  *************************************************/
82 
83  class SiStripApvTIBGainByRunMeans : public cond::payloadInspector::HistoryPlot<SiStripApvGain,float> {
84  public:
85  SiStripApvTIBGainByRunMeans() : cond::payloadInspector::HistoryPlot<SiStripApvGain,float>( "SiStripApv Gains average","average Tracker Inner Barrel APV gain value"){}
86  virtual ~SiStripApvTIBGainByRunMeans() = default;
87 
88  float getFromPayload( SiStripApvGain& payload ){
89 
90  std::vector<uint32_t> detid;
91  payload.getDetIds(detid);
92 
93  float nAPVs=0;
94  float sumOfGains=0;
95 
96  for (const auto & d : detid) {
97 
98  int subid = DetId(d).subdetId();
99  if(subid!=3) continue;
100 
101  SiStripApvGain::Range range=payload.getRange(d);
102  for(int it=0;it<range.second-range.first;it++){
103  nAPVs+=1;
104  sumOfGains+=payload.getApvGain(it,range);
105  } // loop over APVs
106  } // loop over detIds
107 
108  return sumOfGains/nAPVs;
109 
110  } // payload
111  };
112 
113  /************************************************
114  time history histogram of TOB SiStripApvGains
115  *************************************************/
116 
117  class SiStripApvTOBGainByRunMeans : public cond::payloadInspector::HistoryPlot<SiStripApvGain,float> {
118  public:
119  SiStripApvTOBGainByRunMeans() : cond::payloadInspector::HistoryPlot<SiStripApvGain,float>( "SiStripApv Gains average","average Tracker Outer Barrel gain value"){}
120  virtual ~SiStripApvTOBGainByRunMeans() = default;
121 
122  float getFromPayload( SiStripApvGain& payload ){
123 
124  std::vector<uint32_t> detid;
125  payload.getDetIds(detid);
126 
127  float nAPVs=0;
128  float sumOfGains=0;
129 
130  for (const auto & d : detid) {
131 
132  int subid = DetId(d).subdetId();
133  if(subid!=5) continue;
134 
135  SiStripApvGain::Range range=payload.getRange(d);
136  for(int it=0;it<range.second-range.first;it++){
137  nAPVs+=1;
138  sumOfGains+=payload.getApvGain(it,range);
139  } // loop over APVs
140  } // loop over detIds
141 
142  return sumOfGains/nAPVs;
143 
144  } // payload
145  };
146 
147  /************************************************
148  time history histogram of TID SiStripApvGains
149  *************************************************/
150 
151  class SiStripApvTIDGainByRunMeans : public cond::payloadInspector::HistoryPlot<SiStripApvGain,float> {
152  public:
153  SiStripApvTIDGainByRunMeans() : cond::payloadInspector::HistoryPlot<SiStripApvGain,float>( "SiStripApv Gains average","average Tracker Inner Disks APV gain value"){}
154  virtual ~SiStripApvTIDGainByRunMeans() = default;
155 
156  float getFromPayload( SiStripApvGain& payload ){
157 
158  std::vector<uint32_t> detid;
159  payload.getDetIds(detid);
160 
161  float nAPVs=0;
162  float sumOfGains=0;
163  for (const auto & d : detid) {
164 
165  int subid = DetId(d).subdetId();
166  if(subid!=4) continue;
167 
168  SiStripApvGain::Range range=payload.getRange(d);
169  for(int it=0;it<range.second-range.first;it++){
170  nAPVs+=1;
171  sumOfGains+=payload.getApvGain(it,range);
172  } // loop over APVs
173  } // loop over detIds
174 
175  return sumOfGains/nAPVs;
176 
177  } // payload
178  };
179 
180  /************************************************
181  time history histogram of TEC SiStripApvGains
182  *************************************************/
183 
184  class SiStripApvTECGainByRunMeans : public cond::payloadInspector::HistoryPlot<SiStripApvGain,float> {
185  public:
186  SiStripApvTECGainByRunMeans() : cond::payloadInspector::HistoryPlot<SiStripApvGain,float>( "SiStripApv Gains average in TEC","average Tracker Endcaps APV gain value"){}
187  virtual ~SiStripApvTECGainByRunMeans() = default;
188 
189  float getFromPayload( SiStripApvGain& payload ){
190 
191  std::vector<uint32_t> detid;
192  payload.getDetIds(detid);
193 
194  float nAPVs=0;
195  float sumOfGains=0;
196 
197  for (const auto & d : detid) {
198 
199  int subid = DetId(d).subdetId();
200  if(subid!=6) continue;
201 
202  SiStripApvGain::Range range=payload.getRange(d);
203  for(int it=0;it<range.second-range.first;it++){
204  nAPVs+=1;
205  sumOfGains+=payload.getApvGain(it,range);
206  } // loop over APVs
207  } // loop over detIds
208 
209  return sumOfGains/nAPVs;
210 
211  } // payload
212  };
213 
214 
215 } // close namespace
216 
217 // Register the classes as boost python plugin
219  PAYLOAD_INSPECTOR_CLASS(SiStripApvGainsValue);
220  PAYLOAD_INSPECTOR_CLASS(SiStripApvGainByRunMeans);
221  PAYLOAD_INSPECTOR_CLASS(SiStripApvTIBGainByRunMeans);
222  PAYLOAD_INSPECTOR_CLASS(SiStripApvTIDGainByRunMeans);
223  PAYLOAD_INSPECTOR_CLASS(SiStripApvTOBGainByRunMeans);
224  PAYLOAD_INSPECTOR_CLASS(SiStripApvTECGainByRunMeans);
225 }
static float getApvGain(uint16_t apv, const Range &range)
void getDetIds(std::vector< uint32_t > &DetIds_) const
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
payload
payload postfix for testing
std::pair< ContainerIterator, ContainerIterator > Range
void fillWithValue(float value, float weight=1)
virtual bool fill(const std::vector< std::tuple< cond::Time_t, cond::Hash > > &iovs) override
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Definition: DetId.h:18
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: plugin.cc:24
const Range getRange(const uint32_t detID) const