CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
NoiseAlgorithm Class Reference

Histogram-based analysis for pedestal run. More...

#include <NoiseAlgorithm.h>

Inheritance diagram for NoiseAlgorithm:
CommissioningAlgorithm

Public Member Functions

const HistohNoise () const
 
const HistohPeds () const
 
 NoiseAlgorithm (const edm::ParameterSet &pset, NoiseAnalysis *const )
 
virtual ~NoiseAlgorithm ()
 
- Public Member Functions inherited from CommissioningAlgorithm
void analysis (const std::vector< TH1 * > &)
 
 CommissioningAlgorithm (CommissioningAnalysis *const )
 
 CommissioningAlgorithm ()
 
virtual ~CommissioningAlgorithm ()
 

Private Member Functions

void analyse ()
 
void extract (const std::vector< TH1 * > &)
 
 NoiseAlgorithm ()
 

Private Attributes

Histo hNoise_
 
Histo hPeds_
 

Additional Inherited Members

- Public Types inherited from CommissioningAlgorithm
typedef std::pair< TH1
*, std::string > 
Histo
 
- Protected Member Functions inherited from CommissioningAlgorithm
CommissioningAnalysis *const anal () const
 
uint32_t extractFedKey (const TH1 *const )
 

Detailed Description

Histogram-based analysis for pedestal run.

Author
M. Wingham, R.Bainbridge

Definition at line 16 of file NoiseAlgorithm.h.

Constructor & Destructor Documentation

NoiseAlgorithm::NoiseAlgorithm ( const edm::ParameterSet pset,
NoiseAnalysis * const  anal 
)

Definition at line 16 of file NoiseAlgorithm.cc.

17  : CommissioningAlgorithm(anal),
18  hPeds_(0,""),
19  hNoise_(0,"")
20 {;}
virtual NoiseAlgorithm::~NoiseAlgorithm ( )
inlinevirtual

Definition at line 22 of file NoiseAlgorithm.h.

22 {;}
NoiseAlgorithm::NoiseAlgorithm ( )
inlineprivate

Definition at line 30 of file NoiseAlgorithm.h.

30 {;}

Member Function Documentation

void NoiseAlgorithm::analyse ( )
privatevirtual

Performs histogram anaysis.

Implements CommissioningAlgorithm.

Definition at line 84 of file NoiseAlgorithm.cc.

References CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), NoiseAnalysis::dead_, hNoise_, hPeds_, sistrip::invalid_, sistrip::maximum_, sistrip::mlCommissioning_, NoiseAnalysis::noise_, NoiseAnalysis::noiseMax_, NoiseAnalysis::noiseMean_, NoiseAnalysis::noiseMin_, NoiseAnalysis::noiseSpread_, NoiseAnalysis::noisy_, sistrip::nullPtr_, sistrip::numberOfBins_, NoiseAnalysis::peds_, NoiseAnalysis::pedsMax_, NoiseAnalysis::pedsMean_, NoiseAnalysis::pedsMin_, NoiseAnalysis::pedsSpread_, NoiseAnalysis::raw_, NoiseAnalysis::rawMax_, NoiseAnalysis::rawMean_, NoiseAnalysis::rawMin_, NoiseAnalysis::rawSpread_, mathSSE::sqrt(), strip(), and tmp.

84  {
85 
86  if ( !anal() ) {
88  << "[NoiseAlgorithm::" << __func__ << "]"
89  << " NULL pointer to base Analysis object!";
90  return;
91  }
92 
94  NoiseAnalysis* anal = dynamic_cast<NoiseAnalysis*>( tmp );
95  if ( !anal ) {
97  << "[NoiseAlgorithm::" << __func__ << "]"
98  << " NULL pointer to derived Analysis object!";
99  return;
100  }
101 
102  if ( !hPeds_.first ) {
104  return;
105  }
106 
107  if ( !hNoise_.first ) {
109  return;
110  }
111 
112  TProfile* peds_histo = dynamic_cast<TProfile*>(hPeds_.first);
113  TProfile* noise_histo = dynamic_cast<TProfile*>(hNoise_.first);
114 
115  if ( !peds_histo ) {
117  return;
118  }
119 
120  if ( !noise_histo ) {
122  return;
123  }
124 
125  if ( peds_histo->GetNbinsX() != 256 ) {
127  return;
128  }
129 
130  if ( noise_histo->GetNbinsX() != 256 ) {
132  return;
133  }
134 
135  // Iterate through APVs
136  for ( uint16_t iapv = 0; iapv < 2; iapv++ ) {
137 
138  // Used to calc mean and rms for peds and noise
139  float p_sum = 0., p_sum2 = 0., p_max = -1.*sistrip::invalid_, p_min = sistrip::invalid_;
140  float n_sum = 0., n_sum2 = 0., n_max = -1.*sistrip::invalid_, n_min = sistrip::invalid_;
141  float r_sum = 0., r_sum2 = 0., r_max = -1.*sistrip::invalid_, r_min = sistrip::invalid_;
142 
143  // Iterate through strips of APV
144  for ( uint16_t istr = 0; istr < 128; istr++ ) {
145 
146  static uint16_t strip;
147  strip = iapv*128 + istr;
148 
149  // Pedestals and raw noise
150  if ( peds_histo ) {
151  if ( peds_histo->GetBinEntries(strip+1) ) {
152 
153  anal->peds_[iapv][istr] = peds_histo->GetBinContent(strip+1);
154  p_sum += anal->peds_[iapv][istr];
155  p_sum2 += ( anal->peds_[iapv][istr] * anal->peds_[iapv][istr] );
156  if ( anal->peds_[iapv][istr] > p_max ) { p_max = anal->peds_[iapv][istr]; }
157  if ( anal->peds_[iapv][istr] < p_min ) { p_min = anal->peds_[iapv][istr]; }
158 
159  anal->raw_[iapv][istr] = peds_histo->GetBinError(strip+1);
160  r_sum += anal->raw_[iapv][istr];
161  r_sum2 += ( anal->raw_[iapv][istr] * anal->raw_[iapv][istr] );
162  if ( anal->raw_[iapv][istr] > r_max ) { r_max = anal->raw_[iapv][istr]; }
163  if ( anal->raw_[iapv][istr] < r_min ) { r_min = anal->raw_[iapv][istr]; }
164 
165  }
166  }
167 
168  // Noise
169  if ( noise_histo ) {
170  if ( noise_histo->GetBinEntries(strip+1) ) {
171  anal->noise_[iapv][istr] = noise_histo->GetBinContent(strip+1);
172  n_sum += anal->noise_[iapv][istr];
173  n_sum2 += ( anal->noise_[iapv][istr] * anal->noise_[iapv][istr] );
174  if ( anal->noise_[iapv][istr] > n_max ) { n_max = anal->noise_[iapv][istr]; }
175  if ( anal->noise_[iapv][istr] < n_min ) { n_min = anal->noise_[iapv][istr]; }
176  }
177  }
178 
179  } // strip loop
180 
181  // Calc mean and rms for peds
182  if ( !anal->peds_[iapv].empty() ) {
183  p_sum /= static_cast<float>( anal->peds_[iapv].size() );
184  p_sum2 /= static_cast<float>( anal->peds_[iapv].size() );
185  anal->pedsMean_[iapv] = p_sum;
186  anal->pedsSpread_[iapv] = sqrt( fabs(p_sum2 - p_sum*p_sum) );
187  }
188 
189  // Calc mean and rms for noise
190  if ( !anal->noise_[iapv].empty() ) {
191  n_sum /= static_cast<float>( anal->noise_[iapv].size() );
192  n_sum2 /= static_cast<float>( anal->noise_[iapv].size() );
193  anal->noiseMean_[iapv] = n_sum;
194  anal->noiseSpread_[iapv] = sqrt( fabs(n_sum2 - n_sum*n_sum) );
195  }
196 
197  // Calc mean and rms for raw noise
198  if ( !anal->raw_[iapv].empty() ) {
199  r_sum /= static_cast<float>( anal->raw_[iapv].size() );
200  r_sum2 /= static_cast<float>( anal->raw_[iapv].size() );
201  anal->rawMean_[iapv] = r_sum;
202  anal->rawSpread_[iapv] = sqrt( fabs(r_sum2 - r_sum*r_sum) );
203  }
204 
205  // Set max and min values for peds, noise and raw noise
206  if ( p_max > -1.*sistrip::maximum_ ) { anal->pedsMax_[iapv] = p_max; }
207  if ( p_min < 1.*sistrip::maximum_ ) { anal->pedsMin_[iapv] = p_min; }
208  if ( n_max > -1.*sistrip::maximum_ ) { anal->noiseMax_[iapv] = n_max; }
209  if ( n_min < 1.*sistrip::maximum_ ) { anal->noiseMin_[iapv] = n_min; }
210  if ( r_max > -1.*sistrip::maximum_ ) { anal->rawMax_[iapv] = r_max; }
211  if ( r_min < 1.*sistrip::maximum_ ) { anal->rawMin_[iapv] = r_min; }
212 
213  // Set dead and noisy strips
214  for ( uint16_t istr = 0; istr < 128; istr++ ) {
215  if ( anal->noiseMin_[iapv] > sistrip::maximum_ ||
216  anal->noiseMax_[iapv] > sistrip::maximum_ ) { continue; }
217  if ( anal->noise_[iapv][istr] < ( anal->noiseMean_[iapv] - 5. * anal->noiseSpread_[iapv] ) ) {
218  anal->dead_[iapv].push_back(istr); //@@ valid threshold???
219  }
220  else if ( anal->noise_[iapv][istr] > ( anal->noiseMean_[iapv] + 5. * anal->noiseSpread_[iapv] ) ) {
221  anal->noisy_[iapv].push_back(istr); //@@ valid threshold???
222  }
223  }
224 
225  } // apv loop
226 
227 }
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
VFloat pedsMean_
Definition: NoiseAnalysis.h:96
static const char numberOfBins_[]
static const char mlCommissioning_[]
T sqrt(T t)
Definition: SSEVec.h:46
static const uint16_t maximum_
Definition: Constants.h:21
virtual void addErrorCode(const std::string &error)
VVFloat noise_
Definition: NoiseAnalysis.h:80
VFloat noiseSpread_
static const uint16_t invalid_
Definition: Constants.h:17
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
VFloat pedsSpread_
Definition: NoiseAnalysis.h:99
Histogram-based analysis for pedestal run.
Definition: NoiseAnalysis.h:15
Abstract base for derived classes that provide analysis of commissioning histograms.
CommissioningAnalysis *const anal() const
static const char nullPtr_[]
void NoiseAlgorithm::extract ( const std::vector< TH1 * > &  histos)
privatevirtual

Extracts and organises histograms.

Implements CommissioningAlgorithm.

Definition at line 24 of file NoiseAlgorithm.cc.

References a, CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), sistrip::extrainfo::commonMode_, CommissioningAlgorithm::extractFedKey(), CommissioningAnalysis::fedKey(), hNoise_, hPeds_, NoiseAnalysis::legacy_, sistrip::mlCommissioning_, sistrip::NOISE, sistrip::extrainfo::noise_, sistrip::numberOfHistos_, sistrip::extrainfo::pedestals_, sistrip::extrainfo::pedsAndCmSubNoise_, sistrip::extrainfo::pedsAndRawNoise_, indexGen::title, sistrip::unexpectedExtraInfo_, and sistrip::unexpectedTask_.

Referenced by BeautifulSoup.PageElement::_invert(), and BeautifulSoup.Tag::decompose().

24  {
25 
26  if ( !anal() ) {
28  << "[NoiseAlgorithm::" << __func__ << "]"
29  << " NULL pointer to Analysis object!";
30  return;
31  }
32 
33  // Check number of histograms
34  if ( histos.size() != 2 ) {
36  }
37 
38  // Extract FED key from histo title
39  if ( !histos.empty() ) { anal()->fedKey( extractFedKey( histos.front() ) ); }
40 
41  // Extract histograms
42  std::vector<TH1*>::const_iterator ihis = histos.begin();
43  for ( ; ihis != histos.end(); ihis++ ) {
44 
45  // Check for NULL pointer
46  if ( !(*ihis) ) { continue; }
47 
48  // Check run type
49  SiStripHistoTitle title( (*ihis)->GetName() );
50  if ( title.runType() != sistrip::NOISE ) {
52  continue;
53  }
54 
55  // Extract peds and noise histos (check for legacy names first!)
56  if ( title.extraInfo().find(sistrip::extrainfo::pedsAndRawNoise_) != std::string::npos ) {
57  hPeds_.first = *ihis;
58  hPeds_.second = (*ihis)->GetName();
59  NoiseAnalysis* a = dynamic_cast<NoiseAnalysis*>( const_cast<CommissioningAnalysis*>( anal() ) );
60  if ( a ) { a->legacy_ = true; }
61  } else if ( title.extraInfo().find(sistrip::extrainfo::pedsAndCmSubNoise_) != std::string::npos ) {
62  hNoise_.first = *ihis;
63  hNoise_.second = (*ihis)->GetName();
64  NoiseAnalysis* a = dynamic_cast<NoiseAnalysis*>( const_cast<CommissioningAnalysis*>( anal() ) );
65  if ( a ) { a->legacy_ = true; }
66  } else if ( title.extraInfo().find(sistrip::extrainfo::pedestals_) != std::string::npos ) {
67  hPeds_.first = *ihis;
68  hPeds_.second = (*ihis)->GetName();
69  } else if ( title.extraInfo().find(sistrip::extrainfo::noise_) != std::string::npos ) {
70  hNoise_.first = *ihis;
71  hNoise_.second = (*ihis)->GetName();
72  } else if ( title.extraInfo().find(sistrip::extrainfo::commonMode_) != std::string::npos ) {
73  //@@ something here for CM plots?
74  } else {
76  }
77 
78  }
79 
80 }
static const char noise_[]
static const char unexpectedTask_[]
const uint32_t & fedKey() const
static const char pedsAndRawNoise_[]
Utility class that holds histogram title.
static const char numberOfHistos_[]
static const char unexpectedExtraInfo_[]
static const char mlCommissioning_[]
uint32_t extractFedKey(const TH1 *const )
virtual void addErrorCode(const std::string &error)
static const char commonMode_[]
static const char pedestals_[]
static const char pedsAndCmSubNoise_[]
double a
Definition: hdecay.h:121
Histogram-based analysis for pedestal run.
Definition: NoiseAnalysis.h:15
Abstract base for derived classes that provide analysis of commissioning histograms.
CommissioningAnalysis *const anal() const
const NoiseAlgorithm::Histo & NoiseAlgorithm::hNoise ( ) const
inline

Definition at line 52 of file NoiseAlgorithm.h.

References hNoise_.

52 { return hNoise_; }
const NoiseAlgorithm::Histo & NoiseAlgorithm::hPeds ( ) const
inline

Definition at line 50 of file NoiseAlgorithm.h.

References hPeds_.

50 { return hPeds_; }

Member Data Documentation

Histo NoiseAlgorithm::hNoise_
private

Residuals and noise

Definition at line 46 of file NoiseAlgorithm.h.

Referenced by analyse(), extract(), and hNoise().

Histo NoiseAlgorithm::hPeds_
private

Pedestals and raw noise

Definition at line 43 of file NoiseAlgorithm.h.

Referenced by analyse(), extract(), and hPeds().