CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
NoiseAnalysis.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 NoiseAnalysis::NoiseAnalysis( const uint32_t& key )
14  : CommissioningAnalysis(key,"NoiseAnalysis"),
15  peds_(2,VFloat(128,sistrip::invalid_)),
16  noise_(2,VFloat(128,sistrip::invalid_)),
17  raw_(2,VFloat(128,sistrip::invalid_)),
18  dead_(2,VInt(0,sistrip::invalid_)),
19  noisy_(2,VInt(0,sistrip::invalid_)),
20  pedsMean_(2,sistrip::invalid_),
21  pedsSpread_(2,sistrip::invalid_),
22  noiseMean_(2,sistrip::invalid_),
23  noiseSpread_(2,sistrip::invalid_),
24  rawMean_(2,sistrip::invalid_),
25  rawSpread_(2,sistrip::invalid_),
26  pedsMax_(2,sistrip::invalid_),
27  pedsMin_(2,sistrip::invalid_),
28  noiseMax_(2,sistrip::invalid_),
29  noiseMin_(2,sistrip::invalid_),
30  rawMax_(2,sistrip::invalid_),
31  rawMin_(2,sistrip::invalid_),
32  legacy_(false)
33 {
34  dead_[0].reserve(256); dead_[1].reserve(256);
35  noisy_[0].reserve(256); noisy_[1].reserve(256);
36 }
37 
38 // ----------------------------------------------------------------------------
39 //
41  : CommissioningAnalysis("NoiseAnalysis"),
42  peds_(2,VFloat(128,sistrip::invalid_)),
43  noise_(2,VFloat(128,sistrip::invalid_)),
44  raw_(2,VFloat(128,sistrip::invalid_)),
45  dead_(2,VInt(0,sistrip::invalid_)),
46  noisy_(2,VInt(0,sistrip::invalid_)),
47  pedsMean_(2,sistrip::invalid_),
48  pedsSpread_(2,sistrip::invalid_),
49  noiseMean_(2,sistrip::invalid_),
50  noiseSpread_(2,sistrip::invalid_),
51  rawMean_(2,sistrip::invalid_),
52  rawSpread_(2,sistrip::invalid_),
53  pedsMax_(2,sistrip::invalid_),
54  pedsMin_(2,sistrip::invalid_),
55  noiseMax_(2,sistrip::invalid_),
56  noiseMin_(2,sistrip::invalid_),
57  rawMax_(2,sistrip::invalid_),
58  rawMin_(2,sistrip::invalid_),
59  legacy_(false)
60 {
61  dead_[0].reserve(256); dead_[1].reserve(256);
62  noisy_[0].reserve(256); noisy_[1].reserve(256);
63 }
64 
65 // ----------------------------------------------------------------------------
66 //
85  dead_[0].reserve(256);
86  dead_[1].reserve(256);
87  noisy_[0].reserve(256);
88  noisy_[1].reserve(256);
89  legacy_ = false;
90 }
91 
92 // ----------------------------------------------------------------------------
93 //
94 bool NoiseAnalysis::isValid() const {
95  return ( pedsMean_[0] < sistrip::maximum_ &&
115  rawMax_[0] < sistrip::maximum_ &&
116  rawMax_[1] < sistrip::maximum_ &&
117  rawMin_[0] < sistrip::maximum_ &&
118  rawMin_[1] < sistrip::maximum_ &&
119  getErrorCodes().empty() );
120  //noiseMean_[0] <= rawMean_[0] && //@@ temp
121  //noiseMean_[1] <= rawMean_[1] ); //@@ temp
122 }
123 
124 // ----------------------------------------------------------------------------
125 //
126 void NoiseAnalysis::summary( std::stringstream& ss ) const {
127 
128  SiStripFecKey fec_key( fecKey() );
129  SiStripFedKey fed_key( fedKey() );
130 
132 
133  std::stringstream extra1,extra2,extra3;
134  if ( legacy_ ) {
138  } else {
142  }
143 
145  type,
147  fed_key.key(),
149  fec_key.lldChan(),
150  extra1.str() ).title();
152  type,
154  fed_key.key(),
156  fec_key.lldChan(),
157  extra2.str() ).title();
159  type,
161  fed_key.key(),
162  sistrip::APV,
163  SiStripFecKey::i2cAddr( fec_key.lldChan(), true ),
164  extra3.str() ).title();
166  type,
168  fed_key.key(),
169  sistrip::APV,
170  SiStripFecKey::i2cAddr( fec_key.lldChan(), false ),
171  extra3.str() ).title();
172 
173 
174  ss << " Summary"
175  << ":"
176  << ( isValid() ? "Valid" : "Invalid" )
177  << ":"
178  << sistrip::controlView_ << ":"
179  << fec_key.fecCrate() << "/"
180  << fec_key.fecSlot() << "/"
181  << fec_key.fecRing() << "/"
182  << fec_key.ccuAddr() << "/"
183  << fec_key.ccuChan()
184  << ":"
186  << "Collate" << sistrip::dir_
187  << SiStripFecKey( fec_key.fecCrate(),
188  fec_key.fecSlot(),
189  fec_key.fecRing(),
190  fec_key.ccuAddr(),
191  fec_key.ccuChan() ).path()
192  << ":"
193  << title1 << ";" << title2 << ";" << title3 << ";" << title4
194  << std::endl;
195 
196 }
197 
198 // ----------------------------------------------------------------------------
199 //
200 void NoiseAnalysis::print( std::stringstream& ss, uint32_t iapv ) {
201 
202  if ( iapv == 1 || iapv == 2 ) { iapv--; }
203  else { iapv = 0; }
204 
205  if ( peds_[iapv].size() < 128 ||
206  noise_[iapv].size() < 128 ||
207  raw_[iapv].size() < 128 ) {
209  << "[" << myName() << "::" << __func__ << "]"
210  << " Unexpected number of pedestal/noise values: "
211  << peds_[iapv].size() << ", "
212  << noise_[iapv].size() << ", "
213  << raw_[iapv].size();
214  return;
215  }
216 
217  header( ss );
218  ss << " Monitorables for APV number : " << iapv;
219  if ( iapv == 0 ) { ss << " (first of pair)"; }
220  else if ( iapv == 1 ) { ss << " (second of pair)"; }
221  ss << std::endl;
222  ss << std::fixed << std::setprecision(2);
223  ss << " Example peds/noise for strips : "
224  << " 0, 31, 63, 127" << std::endl
225  << " Peds [ADC] : "
226  << std::setw(6) << peds_[iapv][0] << ", "
227  << std::setw(6) << peds_[iapv][31] << ", "
228  << std::setw(6) << peds_[iapv][63] << ", "
229  << std::setw(6) << peds_[iapv][127] << std::endl
230  << " Noise [ADC] : "
231  << std::setw(6) << noise_[iapv][0] << ", "
232  << std::setw(6) << noise_[iapv][31] << ", "
233  << std::setw(6) << noise_[iapv][63] << ", "
234  << std::setw(6) << noise_[iapv][127] << std::endl
235  << " Raw noise [ADC] : "
236  << std::setw(6) << raw_[iapv][0] << ", "
237  << std::setw(6) << raw_[iapv][31] << ", "
238  << std::setw(6) << raw_[iapv][63] << ", "
239  << std::setw(6) << raw_[iapv][127] << std::endl
240  << " Dead strips (<5s) [strip] : (" << dead_[iapv].size() << " in total) ";
241  for ( uint16_t ii = 0; ii < dead_[iapv].size(); ii++ ) {
242  ss << dead_[iapv][ii] << " "; }
243 
244  ss << std::endl;
245  ss << " Noisy strips (>5s) [strip] : (" << noisy_[iapv].size() << " in total) ";
246  for ( uint16_t ii = 0; ii < noisy_[iapv].size(); ii++ ) {
247  ss << noisy_[iapv][ii] << " ";
248  }
249  ss << std::endl;
250  ss << " Mean peds +/- spread [ADC] : " << pedsMean_[iapv] << " +/- " << pedsSpread_[iapv] << std::endl
251  << " Min/Max pedestal [ADC] : " << pedsMin_[iapv] << " <-> " << pedsMax_[iapv] << std::endl
252  << " Mean noise +/- spread [ADC] : " << noiseMean_[iapv] << " +/- " << noiseSpread_[iapv] << std::endl
253  << " Min/Max noise [ADC] : " << noiseMin_[iapv] << " <-> " << noiseMax_[iapv] << std::endl
254  << " Mean raw noise +/- spread [ADC] : " << rawMean_[iapv] << " +/- " << rawSpread_[iapv] << std::endl
255  << " Min/Max raw noise [ADC] : " << rawMin_[iapv] << " <-> " << rawMax_[iapv] << std::endl
256  << " Normalised noise : " << "(yet to be implemented...)" << std::endl
257  << std::boolalpha
258  << " isValid : " << isValid() << std::endl
259  << std::noboolalpha
260  << " Error codes (found "
261  << std::setw(2) << std::setfill(' ') << getErrorCodes().size()
262  << ") : ";
263  if ( getErrorCodes().empty() ) { ss << "(none)"; }
264  else {
265  VString::const_iterator istr = getErrorCodes().begin();
266  VString::const_iterator jstr = getErrorCodes().end();
267  for ( ; istr != jstr; ++istr ) { ss << *istr << " "; }
268  }
269  ss << std::endl;
270 }
271 
static const char noise_[]
type
Definition: HCALResponse.h:21
void summary(std::stringstream &) const
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_[]
VFloat pedsMean_
Definition: NoiseAnalysis.h:96
static const char noiseMax_[]
const uint16_t & lldChan() const
static const char noiseMin_[]
const uint16_t & fecSlot() const
int ii
Definition: cuy.py:588
const uint16_t & i2cAddr() const
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_[]
VVFloat noise_
Definition: NoiseAnalysis.h:80
static const char commonMode_[]
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
std::vector< uint16_t > VInt
const uint16_t & fecCrate() const
static const char pedestals_[]
static const char pedsAndCmSubNoise_[]
VFloat noiseSpread_
std::vector< VInt > VVInt
virtual void header(std::stringstream &) const
const uint16_t & ccuAddr() const
static const uint16_t invalid_
Definition: Constants.h:16
void print(std::stringstream &, uint32_t apv_number=0)
const uint16_t & ccuChan() const
VFloat pedsSpread_
Definition: NoiseAnalysis.h:99
std::vector< VFloat > VVFloat
Abstract base for derived classes that provide analysis of commissioning histograms.
volatile std::atomic< bool > shutdown_flag false
const VString & getErrorCodes() const
const std::string & myName() const
tuple size
Write out results.
bool isValid() const