CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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)
 
 ~NoiseAlgorithm () override
 
- Public Member Functions inherited from CommissioningAlgorithm
void analysis (const std::vector< TH1 * > &)
 
 CommissioningAlgorithm (CommissioningAnalysis *const)
 
 CommissioningAlgorithm ()
 
virtual ~CommissioningAlgorithm ()
 

Private Member Functions

void analyse () override
 
void extract (const std::vector< TH1 * > &) override
 
 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), hPeds_(nullptr, ""), hNoise_(nullptr, "") {
18  ;
19 }
NoiseAlgorithm::~NoiseAlgorithm ( )
inlineoverride

Definition at line 20 of file NoiseAlgorithm.h.

20 { ; }
NoiseAlgorithm::NoiseAlgorithm ( )
inlineprivate

Definition at line 27 of file NoiseAlgorithm.h.

27 { ; }

Member Function Documentation

void NoiseAlgorithm::analyse ( )
overrideprivatevirtual

Performs histogram anaysis.

Implements CommissioningAlgorithm.

Definition at line 86 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(), digitizers_cfi::strip, and createJobs::tmp.

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

Extracts and organises histograms.

Implements CommissioningAlgorithm.

Definition at line 23 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_, runGCPTkAlMap::title, sistrip::unexpectedExtraInfo_, and sistrip::unexpectedTask_.

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

23  {
24  if (!anal()) {
25  edm::LogWarning(mlCommissioning_) << "[NoiseAlgorithm::" << __func__ << "]"
26  << " NULL pointer to Analysis object!";
27  return;
28  }
29 
30  // Check number of histograms
31  if (histos.size() != 2) {
33  }
34 
35  // Extract FED key from histo title
36  if (!histos.empty()) {
37  anal()->fedKey(extractFedKey(histos.front()));
38  }
39 
40  // Extract histograms
41  std::vector<TH1*>::const_iterator ihis = histos.begin();
42  for (; ihis != histos.end(); ihis++) {
43  // Check for NULL pointer
44  if (!(*ihis)) {
45  continue;
46  }
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) {
61  a->legacy_ = true;
62  }
63  } else if (title.extraInfo().find(sistrip::extrainfo::pedsAndCmSubNoise_) != std::string::npos) {
64  hNoise_.first = *ihis;
65  hNoise_.second = (*ihis)->GetName();
66  NoiseAnalysis* a = dynamic_cast<NoiseAnalysis*>(const_cast<CommissioningAnalysis*>(anal()));
67  if (a) {
68  a->legacy_ = true;
69  }
70  } else if (title.extraInfo().find(sistrip::extrainfo::pedestals_) != std::string::npos) {
71  hPeds_.first = *ihis;
72  hPeds_.second = (*ihis)->GetName();
73  } else if (title.extraInfo().find(sistrip::extrainfo::noise_) != std::string::npos) {
74  hNoise_.first = *ihis;
75  hNoise_.second = (*ihis)->GetName();
76  } else if (title.extraInfo().find(sistrip::extrainfo::commonMode_) != std::string::npos) {
77  //@@ something here for CM plots?
78  } else {
80  }
81  }
82 }
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_[]
uint32_t extractFedKey(const TH1 *const)
static const char mlCommissioning_[]
virtual void addErrorCode(const std::string &error)
static const char commonMode_[]
static const char pedestals_[]
static const char pedsAndCmSubNoise_[]
double a
Definition: hdecay.h:119
Histogram-based analysis for pedestal run.
Definition: NoiseAnalysis.h:15
Abstract base for derived classes that provide analysis of commissioning histograms.
Log< level::Warning, false > LogWarning
CommissioningAnalysis *const anal() const
const NoiseAlgorithm::Histo & NoiseAlgorithm::hNoise ( ) const
inline

Definition at line 47 of file NoiseAlgorithm.h.

References hNoise_.

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

Definition at line 45 of file NoiseAlgorithm.h.

References hPeds_.

45 { return hPeds_; }

Member Data Documentation

Histo NoiseAlgorithm::hNoise_
private

Residuals and noise

Definition at line 42 of file NoiseAlgorithm.h.

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

Histo NoiseAlgorithm::hPeds_
private

Pedestals and raw noise

Definition at line 39 of file NoiseAlgorithm.h.

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