CMS 3D CMS Logo

PedsFullNoiseAnalysis.cc
Go to the documentation of this file.
5 #include <iostream>
6 #include <iomanip>
7 #include <cmath>
8 
9 using namespace sistrip;
10 
11 // ----------------------------------------------------------------------------
12 //
14  : CommissioningAnalysis(key, "PedsFullNoiseAnalysis"),
15  peds_(2, VFloat(128, sistrip::invalid_)),
16  noise_(2, VFloat(128, sistrip::invalid_)),
17  raw_(2, VFloat(128, sistrip::invalid_)),
18  adProbab_(2, VFloat(128, sistrip::invalid_)),
19  ksProbab_(2, VFloat(128, sistrip::invalid_)),
20  jbProbab_(2, VFloat(128, sistrip::invalid_)),
21  chi2Probab_(2, VFloat(128, sistrip::invalid_)),
22  residualRMS_(2, VFloat(128, sistrip::invalid_)),
23  residualSigmaGaus_(2, VFloat(128, sistrip::invalid_)),
24  noiseSignificance_(2, VFloat(128, sistrip::invalid_)),
25  residualMean_(2, VFloat(128, sistrip::invalid_)),
26  residualSkewness_(2, VFloat(128, sistrip::invalid_)),
27  residualKurtosis_(2, VFloat(128, sistrip::invalid_)),
28  residualIntegralNsigma_(2, VFloat(128, sistrip::invalid_)),
29  residualIntegral_(2, VFloat(128, sistrip::invalid_)),
30  badStripBit_(2, VInt(128, sistrip::invalid_)),
32  deadStrip_(2, VInt(0, sistrip::invalid_)),
33  badStrip_(2, VInt(0, sistrip::invalid_)),
34  shiftedStrip_(2, VInt(0, sistrip::invalid_)),
35  lowNoiseStrip_(2, VInt(0, sistrip::invalid_)),
36  largeNoiseStrip_(2, VInt(0, sistrip::invalid_)),
37  largeNoiseSignificance_(2, VInt(0, sistrip::invalid_)),
38  badFitStatus_(2, VInt(0, sistrip::invalid_)),
39  badADProbab_(2, VInt(0, sistrip::invalid_)),
40  badKSProbab_(2, VInt(0, sistrip::invalid_)),
41  badJBProbab_(2, VInt(0, sistrip::invalid_)),
42  badChi2Probab_(2, VInt(0, sistrip::invalid_)),
43  badTailStrip_(2, VInt(0, sistrip::invalid_)),
44  badDoublePeakStrip_(2, VInt(0, sistrip::invalid_)),
45  pedsMean_(2, sistrip::invalid_),
46  pedsSpread_(2, sistrip::invalid_),
49  rawMean_(2, sistrip::invalid_),
50  rawSpread_(2, sistrip::invalid_),
51  pedsMax_(2, sistrip::invalid_),
52  pedsMin_(2, sistrip::invalid_),
55  rawMax_(2, sistrip::invalid_),
56  rawMin_(2, sistrip::invalid_),
57  legacy_(false) {
58  // for flag bits one reserve at max 128 positions since will be filled with strip id only if the strip is bad
59  for (auto iapv : deadStrip_)
60  iapv.reserve(128);
61  for (auto iapv : badStrip_)
62  iapv.reserve(128);
63  for (auto iapv : shiftedStrip_)
64  iapv.reserve(128);
65  for (auto iapv : lowNoiseStrip_)
66  iapv.reserve(128);
67  for (auto iapv : largeNoiseStrip_)
68  iapv.reserve(128);
69  for (auto iapv : largeNoiseSignificance_)
70  iapv.reserve(128);
71  for (auto iapv : badFitStatus_)
72  iapv.reserve(128);
73  for (auto iapv : badADProbab_)
74  iapv.reserve(128);
75  for (auto iapv : badKSProbab_)
76  iapv.reserve(128);
77  for (auto iapv : badJBProbab_)
78  iapv.reserve(128);
79  for (auto iapv : badChi2Probab_)
80  iapv.reserve(128);
81  for (auto iapv : badTailStrip_)
82  iapv.reserve(128);
83  for (auto iapv : badDoublePeakStrip_)
84  iapv.reserve(128);
85 }
86 
87 // ----------------------------------------------------------------------------
88 //
90  : CommissioningAnalysis("PedsFullNoiseAnalysis"),
91  peds_(2, VFloat(128, sistrip::invalid_)),
92  noise_(2, VFloat(128, sistrip::invalid_)),
93  raw_(2, VFloat(128, sistrip::invalid_)),
94  adProbab_(2, VFloat(128, sistrip::invalid_)),
95  ksProbab_(2, VFloat(128, sistrip::invalid_)),
96  jbProbab_(2, VFloat(128, sistrip::invalid_)),
97  chi2Probab_(2, VFloat(128, sistrip::invalid_)),
98  residualRMS_(2, VFloat(128, sistrip::invalid_)),
99  residualSigmaGaus_(2, VFloat(128, sistrip::invalid_)),
100  noiseSignificance_(2, VFloat(128, sistrip::invalid_)),
101  residualMean_(2, VFloat(128, sistrip::invalid_)),
102  residualSkewness_(2, VFloat(128, sistrip::invalid_)),
103  residualKurtosis_(2, VFloat(128, sistrip::invalid_)),
104  residualIntegralNsigma_(2, VFloat(128, sistrip::invalid_)),
105  residualIntegral_(2, VFloat(128, sistrip::invalid_)),
106  badStripBit_(2, VInt(128, sistrip::invalid_)),
107  deadStripBit_(2, VInt(128, sistrip::invalid_)),
108  deadStrip_(2, VInt(0, sistrip::invalid_)),
109  badStrip_(2, VInt(0, sistrip::invalid_)),
110  shiftedStrip_(2, VInt(0, sistrip::invalid_)),
111  lowNoiseStrip_(2, VInt(0, sistrip::invalid_)),
112  largeNoiseStrip_(2, VInt(0, sistrip::invalid_)),
113  largeNoiseSignificance_(2, VInt(0, sistrip::invalid_)),
114  badFitStatus_(2, VInt(0, sistrip::invalid_)),
115  badADProbab_(2, VInt(0, sistrip::invalid_)),
116  badKSProbab_(2, VInt(0, sistrip::invalid_)),
117  badJBProbab_(2, VInt(0, sistrip::invalid_)),
118  badChi2Probab_(2, VInt(0, sistrip::invalid_)),
119  badTailStrip_(2, VInt(0, sistrip::invalid_)),
120  badDoublePeakStrip_(2, VInt(128, sistrip::invalid_)),
121  pedsMean_(2, sistrip::invalid_),
122  pedsSpread_(2, sistrip::invalid_),
125  rawMean_(2, sistrip::invalid_),
126  rawSpread_(2, sistrip::invalid_),
127  pedsMax_(2, sistrip::invalid_),
128  pedsMin_(2, sistrip::invalid_),
131  rawMax_(2, sistrip::invalid_),
132  rawMin_(2, sistrip::invalid_),
133  legacy_(false) {
134  // for flag bits one reserve at max 128 positions since will be filled with strip id only if the strip is bad
135  for (auto iapv : deadStrip_)
136  iapv.reserve(128);
137  for (auto iapv : badStrip_)
138  iapv.reserve(128);
139  for (auto iapv : shiftedStrip_)
140  iapv.reserve(128);
141  for (auto iapv : lowNoiseStrip_)
142  iapv.reserve(128);
143  for (auto iapv : largeNoiseStrip_)
144  iapv.reserve(128);
145  for (auto iapv : largeNoiseSignificance_)
146  iapv.reserve(128);
147  for (auto iapv : badFitStatus_)
148  iapv.reserve(128);
149  for (auto iapv : badADProbab_)
150  iapv.reserve(128);
151  for (auto iapv : badKSProbab_)
152  iapv.reserve(128);
153  for (auto iapv : badJBProbab_)
154  iapv.reserve(128);
155  for (auto iapv : badChi2Probab_)
156  iapv.reserve(128);
157  for (auto iapv : badTailStrip_)
158  iapv.reserve(128);
159  for (auto iapv : badDoublePeakStrip_)
160  iapv.reserve(128);
161 }
162 
163 // ----------------------------------------------------------------------------
164 //
168  raw_ = VVFloat(2, VFloat(128, sistrip::invalid_));
181 
197 
198  // for flag bits one reserve at max 128 positions since will be filled with strip id only if the strip is bad
199  for (auto iapv : deadStrip_)
200  iapv.reserve(128);
201  for (auto iapv : badStrip_)
202  iapv.reserve(128);
203  for (auto iapv : shiftedStrip_)
204  iapv.reserve(128);
205  for (auto iapv : lowNoiseStrip_)
206  iapv.reserve(128);
207  for (auto iapv : largeNoiseStrip_)
208  iapv.reserve(128);
209  for (auto iapv : largeNoiseSignificance_)
210  iapv.reserve(128);
211  for (auto iapv : badFitStatus_)
212  iapv.reserve(128);
213  for (auto iapv : badADProbab_)
214  iapv.reserve(128);
215  for (auto iapv : badKSProbab_)
216  iapv.reserve(128);
217  for (auto iapv : badJBProbab_)
218  iapv.reserve(128);
219  for (auto iapv : badChi2Probab_)
220  iapv.reserve(128);
221  for (auto iapv : badTailStrip_)
222  iapv.reserve(128);
223  for (auto iapv : badDoublePeakStrip_)
224  iapv.reserve(128);
225 
238 
239  legacy_ = false;
240 }
241 
242 // ----------------------------------------------------------------------------
243 //
254 }
255 
256 // ----------------------------------------------------------------------------
257 //
258 void PedsFullNoiseAnalysis::summary(std::stringstream& ss) const {
259  SiStripFecKey fec_key(fecKey());
260  SiStripFedKey fed_key(fedKey());
261 
263 
264  std::stringstream extra1, extra2, extra3;
265  if (legacy_) {
269  } else {
273  }
274 
276  type,
278  fed_key.key(),
280  fec_key.lldChan(),
281  extra1.str())
282  .title();
284  type,
286  fed_key.key(),
288  fec_key.lldChan(),
289  extra2.str())
290  .title();
292  type,
294  fed_key.key(),
295  sistrip::APV,
296  SiStripFecKey::i2cAddr(fec_key.lldChan(), true),
297  extra3.str())
298  .title();
300  type,
302  fed_key.key(),
303  sistrip::APV,
304  SiStripFecKey::i2cAddr(fec_key.lldChan(), false),
305  extra3.str())
306  .title();
307 
308  ss << " Summary"
309  << ":" << (isValid() ? "Valid" : "Invalid") << ":" << sistrip::controlView_ << ":" << fec_key.fecCrate() << "/"
310  << fec_key.fecSlot() << "/" << fec_key.fecRing() << "/" << fec_key.ccuAddr() << "/" << fec_key.ccuChan() << ":"
311  << sistrip::dqmRoot_ << sistrip::dir_ << "Collate" << sistrip::dir_
312  << SiStripFecKey(fec_key.fecCrate(), fec_key.fecSlot(), fec_key.fecRing(), fec_key.ccuAddr(), fec_key.ccuChan())
313  .path()
314  << ":" << title1 << ";" << title2 << ";" << title3 << ";" << title4 << std::endl;
315 }
316 
317 // ----------------------------------------------------------------------------
318 //
319 void PedsFullNoiseAnalysis::print(std::stringstream& ss, uint32_t iapv) {
320  if (iapv == 1 || iapv == 2) {
321  iapv--;
322  } else {
323  iapv = 0;
324  }
325 
326  if (peds_[iapv].size() < 128 || noise_[iapv].size() < 128 || raw_[iapv].size() < 128) {
327  edm::LogWarning(mlCommissioning_) << "[" << myName() << "::" << __func__ << "]"
328  << " Unexpected number of pedestal/noise values: " << peds_[iapv].size() << ", "
329  << noise_[iapv].size() << ", " << raw_[iapv].size();
330  return;
331  }
332 
333  header(ss);
334  ss << " Monitorables for APV number : " << iapv;
335  if (iapv == 0) {
336  ss << " (first of pair)";
337  } else if (iapv == 1) {
338  ss << " (second of pair)";
339  }
340  ss << std::endl;
341  ss << std::fixed << std::setprecision(2);
342  ss << " Example peds/noise for strips : "
343  << " 0, 31, 63, 127" << std::endl
344  << " Peds [ADC] : " << std::setw(6) << peds_[iapv][0] << ", " << std::setw(6)
345  << peds_[iapv][31] << ", " << std::setw(6) << peds_[iapv][63] << ", " << std::setw(6) << peds_[iapv][127]
346  << std::endl
347  << " Noise [ADC] : " << std::setw(6) << noise_[iapv][0] << ", " << std::setw(6)
348  << noise_[iapv][31] << ", " << std::setw(6) << noise_[iapv][63] << ", " << std::setw(6) << noise_[iapv][127]
349  << std::endl
350  << " Raw noise [ADC] : " << std::setw(6) << raw_[iapv][0] << ", " << std::setw(6) << raw_[iapv][31]
351  << ", " << std::setw(6) << raw_[iapv][63] << ", " << std::setw(6) << raw_[iapv][127] << std::endl
352  << " Dead strips (<5s) [strip] : (" << deadStrip_[iapv].size() << " in total) ";
353 
354  for (uint16_t ii = 0; ii < deadStrip_[iapv].size(); ii++) {
355  ss << deadStrip_[iapv][ii] << " ";
356  }
357 
358  ss << std::endl;
359  ss << " Bad strips (>5s) [strip] : (" << badStrip_[iapv].size() << " in total) ";
360  for (uint16_t ii = 0; ii < badStrip_[iapv].size(); ii++) {
361  ss << badStrip_[iapv][ii] << " ";
362  }
363  ss << std::endl;
364  ss << " Mean peds +/- spread [ADC] : " << pedsMean_[iapv] << " +/- " << pedsSpread_[iapv] << std::endl
365  << " Min/Max pedestal [ADC] : " << pedsMin_[iapv] << " <-> " << pedsMax_[iapv] << std::endl
366  << " Mean noise +/- spread [ADC] : " << noiseMean_[iapv] << " +/- " << noiseSpread_[iapv] << std::endl
367  << " Min/Max noise [ADC] : " << noiseMin_[iapv] << " <-> " << noiseMax_[iapv] << std::endl
368  << " Mean raw noise +/- spread [ADC] : " << rawMean_[iapv] << " +/- " << rawSpread_[iapv] << std::endl
369  << " Min/Max raw noise [ADC] : " << rawMin_[iapv] << " <-> " << rawMax_[iapv] << std::endl
370  << " Normalised noise : "
371  << "(yet to be implemented...)" << std::endl
372  << std::boolalpha << " isValid : " << isValid() << std::endl
373  << std::noboolalpha << " Error codes (found " << std::setw(2) << std::setfill(' ') << getErrorCodes().size()
374  << ") : ";
375  if (getErrorCodes().empty()) {
376  ss << "(none)";
377  } else {
378  VString::const_iterator istr = getErrorCodes().begin();
379  VString::const_iterator jstr = getErrorCodes().end();
380  for (; istr != jstr; ++istr) {
381  ss << *istr << " ";
382  }
383  }
384  ss << std::endl;
385 }
size
Write out results.
static const char noise_[]
const VString & getErrorCodes() const
VVFloat peds_
Quantitles that are always filled for every strip.
static const char rawNoise_[]
const uint16_t & ccuAddr() const
static const char pedsAndRawNoise_[]
static const char dir_[]
Utility class that holds histogram title.
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:56
static const char noiseMean_[]
const uint16_t & ccuChan() const
bool isValid() const override
static const char noiseMax_[]
static const char noiseMin_[]
const uint16_t & lldChan() const
VVInt deadStrip_
Quantities filled only for bad strips i.e. vectors of strip-id.
void summary(std::stringstream &) const override
sistrip classes
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
Definition: SiStripFecKey.h:45
static std::string runType(const sistrip::RunType &)
const std::string & myName() const
std::vector< float > VFloat
static const char mlCommissioning_[]
const uint16_t & i2cAddr() const
static const char controlView_[]
const uint32_t & key() const
Definition: SiStripKey.h:120
static const uint16_t maximum_
Definition: Constants.h:20
static const char dqmRoot_[]
static const char noiseSpread_[]
const uint32_t & fecKey() const
static const char commonMode_[]
const uint32_t & fedKey() const
std::vector< uint16_t > VInt
ii
Definition: cuy.py:589
static const char pedestals_[]
static const char pedsAndCmSubNoise_[]
std::vector< VInt > VVInt
static const char deadStripBit_[]
static const uint16_t invalid_
Definition: Constants.h:16
const uint16_t & fecSlot() const
virtual void header(std::stringstream &) const
static const char badStripBit_[]
std::vector< VFloat > VVFloat
Abstract base for derived classes that provide analysis of commissioning histograms.
Log< level::Warning, false > LogWarning
const uint16_t & fecRing() const
const uint16_t & fecCrate() const
void print(std::stringstream &, uint32_t apv_number=0) override