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 // ----------------------------------------------------------------------------
13 //
15  : CommissioningAnalysis(key,"PedsFullNoiseAnalysis"),
16  peds_(2,VFloat(128,sistrip::invalid_)),
17  noise_(2,VFloat(128,sistrip::invalid_)),
18  raw_(2,VFloat(128,sistrip::invalid_)),
19  adProbab_(2,VFloat(128,sistrip::invalid_)),
20  ksProbab_(2,VFloat(128,sistrip::invalid_)),
21  jbProbab_(2,VFloat(128,sistrip::invalid_)),
22  chi2Probab_(2,VFloat(128,sistrip::invalid_)),
23  residualRMS_(2,VFloat(128,sistrip::invalid_)),
24  residualSigmaGaus_(2,VFloat(128,sistrip::invalid_)),
25  noiseSignificance_(2,VFloat(128,sistrip::invalid_)),
26  residualMean_(2,VFloat(128,sistrip::invalid_)),
27  residualSkewness_(2,VFloat(128,sistrip::invalid_)),
28  residualKurtosis_(2,VFloat(128,sistrip::invalid_)),
29  residualIntegralNsigma_(2,VFloat(128,sistrip::invalid_)),
30  residualIntegral_(2,VFloat(128,sistrip::invalid_)),
33  deadStrip_(2,VInt(0,sistrip::invalid_)),
34  badStrip_(2,VInt(0,sistrip::invalid_)),
35  shiftedStrip_(2,VInt(0,sistrip::invalid_)),
36  lowNoiseStrip_(2,VInt(0,sistrip::invalid_)),
37  largeNoiseStrip_(2,VInt(0,sistrip::invalid_)),
38  largeNoiseSignificance_(2,VInt(0,sistrip::invalid_)),
39  badFitStatus_(2,VInt(0,sistrip::invalid_)),
40  badADProbab_(2,VInt(0,sistrip::invalid_)),
41  badKSProbab_(2,VInt(0,sistrip::invalid_)),
42  badJBProbab_(2,VInt(0,sistrip::invalid_)),
43  badChi2Probab_(2,VInt(0,sistrip::invalid_)),
44  badTailStrip_(2,VInt(0,sistrip::invalid_)),
45  badDoublePeakStrip_(2,VInt(0,sistrip::invalid_)),
46  pedsMean_(2,sistrip::invalid_),
47  pedsSpread_(2,sistrip::invalid_),
50  rawMean_(2,sistrip::invalid_),
51  rawSpread_(2,sistrip::invalid_),
52  pedsMax_(2,sistrip::invalid_),
53  pedsMin_(2,sistrip::invalid_),
56  rawMax_(2,sistrip::invalid_),
57  rawMin_(2,sistrip::invalid_),
58  legacy_(false)
59 {
60  // for flag bits one reserve at max 128 positions since will be filled with strip id only if the strip is bad
61  for(auto iapv : deadStrip_)
62  iapv.reserve(128);
63  for(auto iapv : badStrip_)
64  iapv.reserve(128);
65  for(auto iapv : shiftedStrip_)
66  iapv.reserve(128);
67  for(auto iapv : lowNoiseStrip_)
68  iapv.reserve(128);
69  for(auto iapv : largeNoiseStrip_)
70  iapv.reserve(128);
71  for(auto iapv : largeNoiseSignificance_)
72  iapv.reserve(128);
73  for(auto iapv : badFitStatus_)
74  iapv.reserve(128);
75  for(auto iapv : badADProbab_)
76  iapv.reserve(128);
77  for(auto iapv : badKSProbab_)
78  iapv.reserve(128);
79  for(auto iapv : badJBProbab_)
80  iapv.reserve(128);
81  for(auto iapv : badChi2Probab_)
82  iapv.reserve(128);
83  for(auto iapv : badTailStrip_)
84  iapv.reserve(128);
85  for(auto iapv : badDoublePeakStrip_)
86  iapv.reserve(128);
87 }
88 
89 // ----------------------------------------------------------------------------
90 //
92  : CommissioningAnalysis("PedsFullNoiseAnalysis"),
93  peds_(2,VFloat(128,sistrip::invalid_)),
94  noise_(2,VFloat(128,sistrip::invalid_)),
95  raw_(2,VFloat(128,sistrip::invalid_)),
133  rawMax_(2,sistrip::invalid_),
135  legacy_(false)
136 {
137  // for flag bits one reserve at max 128 positions since will be filled with strip id only if the strip is bad
138  for(auto iapv : deadStrip_)
139  iapv.reserve(128);
140  for(auto iapv : badStrip_)
141  iapv.reserve(128);
142  for(auto iapv : shiftedStrip_)
143  iapv.reserve(128);
144  for(auto iapv : lowNoiseStrip_)
145  iapv.reserve(128);
146  for(auto iapv : largeNoiseStrip_)
147  iapv.reserve(128);
148  for(auto iapv : largeNoiseSignificance_)
149  iapv.reserve(128);
150  for(auto iapv : badFitStatus_)
151  iapv.reserve(128);
152  for(auto iapv : badADProbab_)
153  iapv.reserve(128);
154  for(auto iapv : badKSProbab_)
155  iapv.reserve(128);
156  for(auto iapv : badJBProbab_)
157  iapv.reserve(128);
158  for(auto iapv : badChi2Probab_)
159  iapv.reserve(128);
160  for(auto iapv : badTailStrip_)
161  iapv.reserve(128);
162  for(auto iapv : badDoublePeakStrip_)
163  iapv.reserve(128);
164 }
165 
166 // ----------------------------------------------------------------------------
167 //
169 
185 
201 
202  // for flag bits one reserve at max 128 positions since will be filled with strip id only if the strip is bad
203  for(auto iapv : deadStrip_)
204  iapv.reserve(128);
205  for(auto iapv : badStrip_)
206  iapv.reserve(128);
207  for(auto iapv : shiftedStrip_)
208  iapv.reserve(128);
209  for(auto iapv : lowNoiseStrip_)
210  iapv.reserve(128);
211  for(auto iapv : largeNoiseStrip_)
212  iapv.reserve(128);
213  for(auto iapv : largeNoiseSignificance_)
214  iapv.reserve(128);
215  for(auto iapv : badFitStatus_)
216  iapv.reserve(128);
217  for(auto iapv : badADProbab_)
218  iapv.reserve(128);
219  for(auto iapv : badKSProbab_)
220  iapv.reserve(128);
221  for(auto iapv : badJBProbab_)
222  iapv.reserve(128);
223  for(auto iapv : badChi2Probab_)
224  iapv.reserve(128);
225  for(auto iapv : badTailStrip_)
226  iapv.reserve(128);
227  for(auto iapv : badDoublePeakStrip_)
228  iapv.reserve(128);
229 
242 
243  legacy_ = false;
244 }
245 
246 // ----------------------------------------------------------------------------
247 //
249  return ( pedsMean_[0] < sistrip::maximum_ &&
269  rawMax_[0] < sistrip::maximum_ &&
270  rawMax_[1] < sistrip::maximum_ &&
271  rawMin_[0] < sistrip::maximum_ &&
272  rawMin_[1] < sistrip::maximum_ &&
273  getErrorCodes().empty() );
274 }
275 
276 // ----------------------------------------------------------------------------
277 //
278 void PedsFullNoiseAnalysis::summary( std::stringstream& ss ) const {
279 
280  SiStripFecKey fec_key( fecKey() );
281  SiStripFedKey fed_key( fedKey() );
282 
284 
285  std::stringstream extra1,extra2,extra3;
286  if ( legacy_ ) {
290  } else {
294  }
295 
297  type,
299  fed_key.key(),
301  fec_key.lldChan(),
302  extra1.str() ).title();
304  type,
306  fed_key.key(),
308  fec_key.lldChan(),
309  extra2.str() ).title();
311  type,
313  fed_key.key(),
314  sistrip::APV,
315  SiStripFecKey::i2cAddr( fec_key.lldChan(), true ),
316  extra3.str() ).title();
318  type,
320  fed_key.key(),
321  sistrip::APV,
322  SiStripFecKey::i2cAddr( fec_key.lldChan(), false ),
323  extra3.str() ).title();
324 
325 
326  ss << " Summary"
327  << ":"
328  << ( isValid() ? "Valid" : "Invalid" )
329  << ":"
330  << sistrip::controlView_ << ":"
331  << fec_key.fecCrate() << "/"
332  << fec_key.fecSlot() << "/"
333  << fec_key.fecRing() << "/"
334  << fec_key.ccuAddr() << "/"
335  << fec_key.ccuChan()
336  << ":"
338  << "Collate" << sistrip::dir_
339  << SiStripFecKey( fec_key.fecCrate(),
340  fec_key.fecSlot(),
341  fec_key.fecRing(),
342  fec_key.ccuAddr(),
343  fec_key.ccuChan() ).path()
344  << ":"
345  << title1 << ";" << title2 << ";" << title3 << ";" << title4
346  << std::endl;
347 
348 }
349 
350 // ----------------------------------------------------------------------------
351 //
352 void PedsFullNoiseAnalysis::print( std::stringstream& ss, uint32_t iapv ) {
353 
354  if ( iapv == 1 || iapv == 2 ) { iapv--; }
355  else { iapv = 0; }
356 
357  if ( peds_[iapv].size() < 128 ||
358  noise_[iapv].size() < 128 ||
359  raw_[iapv].size() < 128 ) {
360 
362  << "[" << myName() << "::" << __func__ << "]"
363  << " Unexpected number of pedestal/noise values: "
364  << peds_[iapv].size() << ", "
365  << noise_[iapv].size() << ", "
366  << raw_[iapv].size();
367  return;
368  }
369 
370  header( ss );
371  ss << " Monitorables for APV number : " << iapv;
372  if ( iapv == 0 ) { ss << " (first of pair)"; }
373  else if ( iapv == 1 ) { ss << " (second of pair)"; }
374  ss << std::endl;
375  ss << std::fixed << std::setprecision(2);
376  ss << " Example peds/noise for strips : "
377  << " 0, 31, 63, 127" << std::endl
378  << " Peds [ADC] : "
379  << std::setw(6) << peds_[iapv][0] << ", "
380  << std::setw(6) << peds_[iapv][31] << ", "
381  << std::setw(6) << peds_[iapv][63] << ", "
382  << std::setw(6) << peds_[iapv][127] << std::endl
383  << " Noise [ADC] : "
384  << std::setw(6) << noise_[iapv][0] << ", "
385  << std::setw(6) << noise_[iapv][31] << ", "
386  << std::setw(6) << noise_[iapv][63] << ", "
387  << std::setw(6) << noise_[iapv][127] << std::endl
388  << " Raw noise [ADC] : "
389  << std::setw(6) << raw_[iapv][0] << ", "
390  << std::setw(6) << raw_[iapv][31] << ", "
391  << std::setw(6) << raw_[iapv][63] << ", "
392  << std::setw(6) << raw_[iapv][127] << std::endl
393  << " Dead strips (<5s) [strip] : (" << deadStrip_[iapv].size() << " in total) ";
394 
395  for ( uint16_t ii = 0; ii < deadStrip_[iapv].size(); ii++ ) {
396  ss << deadStrip_[iapv][ii] << " "; }
397 
398  ss << std::endl;
399  ss << " Bad strips (>5s) [strip] : (" << badStrip_[iapv].size() << " in total) ";
400  for ( uint16_t ii = 0; ii < badStrip_[iapv].size(); ii++ ) {
401  ss << badStrip_[iapv][ii] << " ";
402  }
403  ss << std::endl;
404  ss << " Mean peds +/- spread [ADC] : " << pedsMean_[iapv] << " +/- " << pedsSpread_[iapv] << std::endl
405  << " Min/Max pedestal [ADC] : " << pedsMin_[iapv] << " <-> " << pedsMax_[iapv] << std::endl
406  << " Mean noise +/- spread [ADC] : " << noiseMean_[iapv] << " +/- " << noiseSpread_[iapv] << std::endl
407  << " Min/Max noise [ADC] : " << noiseMin_[iapv] << " <-> " << noiseMax_[iapv] << std::endl
408  << " Mean raw noise +/- spread [ADC] : " << rawMean_[iapv] << " +/- " << rawSpread_[iapv] << std::endl
409  << " Min/Max raw noise [ADC] : " << rawMin_[iapv] << " <-> " << rawMax_[iapv] << std::endl
410  << " Normalised noise : " << "(yet to be implemented...)" << std::endl
411  << std::boolalpha
412  << " isValid : " << isValid() << std::endl
413  << std::noboolalpha
414  << " Error codes (found "
415  << std::setw(2) << std::setfill(' ') << getErrorCodes().size()
416  << ") : ";
417  if ( getErrorCodes().empty() ) { ss << "(none)"; }
418  else {
419  VString::const_iterator istr = getErrorCodes().begin();
420  VString::const_iterator jstr = getErrorCodes().end();
421  for ( ; istr != jstr; ++istr ) { ss << *istr << " "; }
422  }
423  ss << std::endl;
424 }
425 
size
Write out results.
static const char noise_[]
type
Definition: HCALResponse.h:21
VVFloat peds_
Quantitles that are always filled for every strip.
static const char rawNoise_[]
const uint32_t & fedKey() const
const uint16_t & fecRing() 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_[]
static const char noiseMax_[]
const uint16_t & lldChan() const
static const char noiseMin_[]
const uint16_t & fecSlot() const
void summary(std::stringstream &) const override
VVInt deadStrip_
Quantities filled only for bad strips i.e. vectors of strip-id.
const uint16_t & i2cAddr() const
sistrip classes
const uint32_t & key() const
Definition: SiStripKey.h:125
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 &)
std::vector< float > VFloat
static const char mlCommissioning_[]
static const char controlView_[]
static const uint16_t maximum_
Definition: Constants.h:20
static const char dqmRoot_[]
const uint32_t & fecKey() const
static const char noiseSpread_[]
static const char commonMode_[]
std::vector< uint16_t > VInt
ii
Definition: cuy.py:590
const uint16_t & fecCrate() const
static const char pedestals_[]
static const char pedsAndCmSubNoise_[]
std::vector< VInt > VVInt
virtual void header(std::stringstream &) const
static const char deadStripBit_[]
const uint16_t & ccuAddr() const
static const uint16_t invalid_
Definition: Constants.h:16
const uint16_t & ccuChan() const
static const char badStripBit_[]
std::vector< VFloat > VVFloat
Abstract base for derived classes that provide analysis of commissioning histograms.
const VString & getErrorCodes() const
const std::string & myName() const
bool isValid() const override
void print(std::stringstream &, uint32_t apv_number=0) override