test
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
PedsOnlyAlgorithm Class Reference

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

#include <PedsOnlyAlgorithm.h>

Inheritance diagram for PedsOnlyAlgorithm:
CommissioningAlgorithm

Public Member Functions

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

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

Constructor & Destructor Documentation

PedsOnlyAlgorithm::PedsOnlyAlgorithm ( const edm::ParameterSet pset,
PedsOnlyAnalysis * const  anal 
)

Definition at line 16 of file PedsOnlyAlgorithm.cc.

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

Definition at line 22 of file PedsOnlyAlgorithm.h.

22 {;}
PedsOnlyAlgorithm::PedsOnlyAlgorithm ( )
inlineprivate

Definition at line 30 of file PedsOnlyAlgorithm.h.

30 {;}

Member Function Documentation

void PedsOnlyAlgorithm::analyse ( )
privatevirtual

Performs histogram anaysis.

Implements CommissioningAlgorithm.

Definition at line 79 of file PedsOnlyAlgorithm.cc.

References CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), hNoise_, hPeds_, sistrip::invalid_, PedsOnlyAnalysis::legacy_, sistrip::maximum_, sistrip::mlCommissioning_, sistrip::nullPtr_, sistrip::numberOfBins_, PedsOnlyAnalysis::peds_, PedsOnlyAnalysis::pedsMax_, PedsOnlyAnalysis::pedsMean_, PedsOnlyAnalysis::pedsMin_, PedsOnlyAnalysis::pedsSpread_, PedsOnlyAnalysis::raw_, PedsOnlyAnalysis::rawMax_, PedsOnlyAnalysis::rawMean_, PedsOnlyAnalysis::rawMin_, PedsOnlyAnalysis::rawSpread_, mathSSE::sqrt(), and tmp.

79  {
80 
81  if ( !anal() ) {
83  << "[PedsOnlyAlgorithm::" << __func__ << "]"
84  << " NULL pointer to base Analysis object!";
85  return;
86  }
87 
89  PedsOnlyAnalysis* anal = dynamic_cast<PedsOnlyAnalysis*>( tmp );
90  if ( !anal ) {
92  << "[PedsOnlyAlgorithm::" << __func__ << "]"
93  << " NULL pointer to derived Analysis object!";
94  return;
95  }
96 
97  if ( !hPeds_.first ) {
99  return;
100  }
101 
102  if ( !hNoise_.first ) {
104  return;
105  }
106 
107  TProfile* peds_histo = dynamic_cast<TProfile*>(hPeds_.first);
108  TProfile* raw_histo = dynamic_cast<TProfile*>(hNoise_.first);
109 
110  if ( !peds_histo ) {
112  return;
113  }
114 
115  if ( !raw_histo ) {
117  return;
118  }
119 
120  if ( peds_histo->GetNbinsX() != 256 ) {
122  return;
123  }
124 
125  if ( raw_histo->GetNbinsX() != 256 ) {
127  return;
128  }
129 
130  // Iterate through APVs
131  for ( uint16_t iapv = 0; iapv < 2; iapv++ ) {
132 
133  // Used to calc mean and rms for peds and noise
134  float p_sum = 0., p_sum2 = 0., p_max = -1.*sistrip::invalid_, p_min = sistrip::invalid_;
135  float r_sum = 0., r_sum2 = 0., r_max = -1.*sistrip::invalid_, r_min = sistrip::invalid_;
136 
137  // Iterate through strips of APV
138  for ( uint16_t istr = 0; istr < 128; istr++ ) {
139 
140  static uint16_t strip;
141  strip = iapv*128 + istr;
142 
143  // Pedestals
144  if ( peds_histo ) {
145  if ( peds_histo->GetBinEntries(strip+1) ) {
146  anal->peds_[iapv][istr] = peds_histo->GetBinContent(strip+1);
147  p_sum += anal->peds_[iapv][istr];
148  p_sum2 += (anal->peds_[iapv][istr] * anal->peds_[iapv][istr]);
149  if ( anal->peds_[iapv][istr] > p_max ) { p_max = anal->peds_[iapv][istr]; }
150  if ( anal->peds_[iapv][istr] < p_min ) { p_min = anal->peds_[iapv][istr]; }
151  }
152  }
153 
154  // Raw noise
155  if ( !anal->legacy_ ) {
156  if ( raw_histo ) {
157  if ( raw_histo->GetBinEntries(strip+1) ) {
158  anal->raw_[iapv][istr] = raw_histo->GetBinContent(strip+1);
159  r_sum += anal->raw_[iapv][istr];
160  r_sum2 += ( anal->raw_[iapv][istr] * anal->raw_[iapv][istr] );
161  if ( anal->raw_[iapv][istr] > r_max ) { r_max = anal->raw_[iapv][istr]; }
162  if ( anal->raw_[iapv][istr] < r_min ) { r_min = anal->raw_[iapv][istr]; }
163  }
164  }
165  } else {
166  if ( peds_histo ) {
167  if ( peds_histo->GetBinEntries(strip+1) ) {
168  anal->raw_[iapv][istr] = raw_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  } // strip loop
178 
179  // Calc mean and rms for peds
180  if ( !anal->peds_[iapv].empty() ) {
181  p_sum /= static_cast<float>( anal->peds_[iapv].size() );
182  p_sum2 /= static_cast<float>( anal->peds_[iapv].size() );
183  anal->pedsMean_[iapv] = p_sum;
184  anal->pedsSpread_[iapv] = sqrt( fabs(p_sum2 - p_sum*p_sum) );
185  }
186 
187  // Calc mean and rms for raw noise
188  if ( !anal->raw_[iapv].empty() ) {
189  r_sum /= static_cast<float>( anal->raw_[iapv].size() );
190  r_sum2 /= static_cast<float>( anal->raw_[iapv].size() );
191  anal->rawMean_[iapv] = r_sum;
192  anal->rawSpread_[iapv] = sqrt( fabs(r_sum2 - r_sum*r_sum) );
193  }
194 
195  // Set max and min values for peds and raw noise
196  if ( p_max > -1.*sistrip::maximum_ ) { anal->pedsMax_[iapv] = p_max; }
197  if ( p_min < 1.*sistrip::maximum_ ) { anal->pedsMin_[iapv] = p_min; }
198  if ( r_max > -1.*sistrip::maximum_ ) { anal->rawMax_[iapv] = r_max; }
199  if ( r_min < 1.*sistrip::maximum_ ) { anal->rawMin_[iapv] = r_min; }
200 
201  } // apv loop
202 
203 }
Histogram-based analysis for pedestal run.
static const char numberOfBins_[]
static const char mlCommissioning_[]
T sqrt(T t)
Definition: SSEVec.h:48
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 PedsOnlyAlgorithm::extract ( const std::vector< TH1 * > &  histos)
privatevirtual

Extracts and organises histograms.

Implements CommissioningAlgorithm.

Definition at line 24 of file PedsOnlyAlgorithm.cc.

References a, CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), CommissioningAlgorithm::extractFedKey(), CommissioningAnalysis::fedKey(), hNoise_, hPeds_, PedsOnlyAnalysis::legacy_, sistrip::mlCommissioning_, sistrip::numberOfHistos_, sistrip::extrainfo::pedestals_, sistrip::PEDS_ONLY, sistrip::extrainfo::pedsAndRawNoise_, sistrip::extrainfo::rawNoise_, indexGen::title, sistrip::unexpectedExtraInfo_, and sistrip::unexpectedTask_.

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

24  {
25 
26  if ( !anal() ) {
28  << "[PedsOnlyAlgorithm::" << __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::PEDS_ONLY ) {
52  continue;
53  }
54 
55  // Extract peds and raw 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  hNoise_.first = *ihis;
60  hNoise_.second = (*ihis)->GetName();
61  PedsOnlyAnalysis* a = dynamic_cast<PedsOnlyAnalysis*>( const_cast<CommissioningAnalysis*>( anal() ) );
62  if ( a ) { a->legacy_ = true; }
63  } else if ( title.extraInfo().find(sistrip::extrainfo::pedestals_) != std::string::npos ) {
64  hPeds_.first = *ihis;
65  hPeds_.second = (*ihis)->GetName();
66  } else if ( title.extraInfo().find(sistrip::extrainfo::rawNoise_) != std::string::npos ) {
67  hNoise_.first = *ihis;
68  hNoise_.second = (*ihis)->GetName();
69  } else {
71  }
72 
73  }
74 
75 }
static const char unexpectedTask_[]
Histogram-based analysis for pedestal run.
static const char rawNoise_[]
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 pedestals_[]
double a
Definition: hdecay.h:121
Abstract base for derived classes that provide analysis of commissioning histograms.
CommissioningAnalysis *const anal() const
const PedsOnlyAlgorithm::Histo & PedsOnlyAlgorithm::hNoise ( ) const
inline

Definition at line 50 of file PedsOnlyAlgorithm.h.

References hNoise_.

50 { return hNoise_; }
const PedsOnlyAlgorithm::Histo & PedsOnlyAlgorithm::hPeds ( ) const
inline

Definition at line 48 of file PedsOnlyAlgorithm.h.

References hPeds_.

48 { return hPeds_; }

Member Data Documentation

Histo PedsOnlyAlgorithm::hNoise_
private

Residuals and noise

Definition at line 44 of file PedsOnlyAlgorithm.h.

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

Histo PedsOnlyAlgorithm::hPeds_
private

Pedestals and raw noise

Definition at line 41 of file PedsOnlyAlgorithm.h.

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