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
PedestalsAlgorithm Class Reference

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

#include <PedestalsAlgorithm.h>

Inheritance diagram for PedestalsAlgorithm:
CommissioningAlgorithm

Public Member Functions

const HistohNoise () const
 
const HistohPeds () const
 
 PedestalsAlgorithm (const edm::ParameterSet &pset, PedestalsAnalysis *const )
 
virtual ~PedestalsAlgorithm ()
 
- 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 * > &)
 
 PedestalsAlgorithm ()
 

Private Attributes

float deadStripMax_
 
Histo hNoise_
 
Histo hPeds_
 
float noisyStripMin_
 

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 PedestalsAlgorithm.h.

Constructor & Destructor Documentation

PedestalsAlgorithm::PedestalsAlgorithm ( const edm::ParameterSet pset,
PedestalsAnalysis * const  anal 
)

Definition at line 16 of file PedestalsAlgorithm.cc.

References deadStripMax_, LogDebug, sistrip::mlCommissioning_, and noisyStripMin_.

17  : CommissioningAlgorithm(anal),
18  hPeds_(0,""),
19  hNoise_(0,""),
20  deadStripMax_(pset.getParameter<double>("DeadStripMax")),
21  noisyStripMin_(pset.getParameter<double>("NoisyStripMin"))
22 {
24  << "[PedestalsAlgorithm::" << __func__ << "]"
25  << " Set maximum noise deviation for dead strip determination to: " << deadStripMax_;
27  << "[PedestalsAlgorithm::" << __func__ << "]"
28  << " Set minimal noise deviation for noisy strip determination to: " << noisyStripMin_;
29 }
#define LogDebug(id)
T getParameter(std::string const &) const
static const char mlCommissioning_[]
virtual PedestalsAlgorithm::~PedestalsAlgorithm ( )
inlinevirtual

Definition at line 22 of file PedestalsAlgorithm.h.

22 {;}
PedestalsAlgorithm::PedestalsAlgorithm ( )
inlineprivate

Definition at line 30 of file PedestalsAlgorithm.h.

30 {;}

Member Function Documentation

void PedestalsAlgorithm::analyse ( )
privatevirtual

Performs histogram anaysis.

Implements CommissioningAlgorithm.

Definition at line 93 of file PedestalsAlgorithm.cc.

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

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

Extracts and organises histograms.

Implements CommissioningAlgorithm.

Definition at line 33 of file PedestalsAlgorithm.cc.

References a, CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), sistrip::extrainfo::commonMode_, CommissioningAlgorithm::extractFedKey(), CommissioningAnalysis::fedKey(), hNoise_, hPeds_, PedestalsAnalysis::legacy_, sistrip::mlCommissioning_, sistrip::extrainfo::noise_, sistrip::numberOfHistos_, sistrip::PEDESTALS, 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().

33  {
34 
35  if ( !anal() ) {
37  << "[PedestalsAlgorithm::" << __func__ << "]"
38  << " NULL pointer to Analysis object!";
39  return;
40  }
41 
42  // Check number of histograms
43  if ( histos.size() != 2 ) {
45  }
46 
47  // Extract FED key from histo title
48  if ( !histos.empty() ) { anal()->fedKey( extractFedKey( histos.front() ) ); }
49 
50  // Extract histograms
51  std::vector<TH1*>::const_iterator ihis = histos.begin();
52  for ( ; ihis != histos.end(); ihis++ ) {
53 
54  // Check for NULL pointer
55  if ( !(*ihis) ) { continue; }
56 
57  // Check run type
58  SiStripHistoTitle title( (*ihis)->GetName() );
59  if ( title.runType() != sistrip::PEDESTALS ) {
61  continue;
62  }
63 
64  // Extract peds and noise histos (check for legacy names first!)
65  if ( title.extraInfo().find(sistrip::extrainfo::pedsAndRawNoise_) != std::string::npos ) {
66  hPeds_.first = *ihis;
67  hPeds_.second = (*ihis)->GetName();
68  PedestalsAnalysis* a = dynamic_cast<PedestalsAnalysis*>( const_cast<CommissioningAnalysis*>( anal() ) );
69  if ( a ) { a->legacy_ = true; }
70  } else if ( title.extraInfo().find(sistrip::extrainfo::pedsAndCmSubNoise_) != std::string::npos ) {
71  hNoise_.first = *ihis;
72  hNoise_.second = (*ihis)->GetName();
73  PedestalsAnalysis* a = dynamic_cast<PedestalsAnalysis*>( const_cast<CommissioningAnalysis*>( anal() ) );
74  if ( a ) { a->legacy_ = true; }
75  } else if ( title.extraInfo().find(sistrip::extrainfo::pedestals_) != std::string::npos ) {
76  hPeds_.first = *ihis;
77  hPeds_.second = (*ihis)->GetName();
78  } else if ( title.extraInfo().find(sistrip::extrainfo::noise_) != std::string::npos ) {
79  hNoise_.first = *ihis;
80  hNoise_.second = (*ihis)->GetName();
81  } else if ( title.extraInfo().find(sistrip::extrainfo::commonMode_) != std::string::npos ) {
82  //@@ something here for CM plots?
83  } else {
85  }
86 
87  }
88 
89 }
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 )
Histogram-based analysis for pedestal run.
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
Abstract base for derived classes that provide analysis of commissioning histograms.
CommissioningAnalysis *const anal() const
const PedestalsAlgorithm::Histo & PedestalsAlgorithm::hNoise ( ) const
inline

Definition at line 54 of file PedestalsAlgorithm.h.

References hNoise_.

54 { return hNoise_; }
const PedestalsAlgorithm::Histo & PedestalsAlgorithm::hPeds ( ) const
inline

Definition at line 52 of file PedestalsAlgorithm.h.

References hPeds_.

52 { return hPeds_; }

Member Data Documentation

float PedestalsAlgorithm::deadStripMax_
private

Analysis parameters

Definition at line 47 of file PedestalsAlgorithm.h.

Referenced by analyse(), and PedestalsAlgorithm().

Histo PedestalsAlgorithm::hNoise_
private

Residuals and noise

Definition at line 44 of file PedestalsAlgorithm.h.

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

Histo PedestalsAlgorithm::hPeds_
private

Pedestals and raw noise

Definition at line 41 of file PedestalsAlgorithm.h.

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

float PedestalsAlgorithm::noisyStripMin_
private

Definition at line 48 of file PedestalsAlgorithm.h.

Referenced by analyse(), and PedestalsAlgorithm().