CMS 3D CMS Logo

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)
 
 ~PedestalsAlgorithm () 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
 
 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() [1/2]

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

Definition at line 16 of file PedestalsAlgorithm.cc.

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

18  hPeds_(nullptr, ""),
19  hNoise_(nullptr, ""),
20  deadStripMax_(pset.getParameter<double>("DeadStripMax")),
21  noisyStripMin_(pset.getParameter<double>("NoisyStripMin")) {
22  LogDebug(mlCommissioning_) << "[PedestalsAlgorithm::" << __func__ << "]"
23  << " Set maximum noise deviation for dead strip determination to: " << deadStripMax_;
24  LogDebug(mlCommissioning_) << "[PedestalsAlgorithm::" << __func__ << "]"
25  << " Set minimal noise deviation for noisy strip determination to: " << noisyStripMin_;
26 }
CommissioningAnalysis *const anal() const
static const char mlCommissioning_[]
#define LogDebug(id)

◆ ~PedestalsAlgorithm()

PedestalsAlgorithm::~PedestalsAlgorithm ( )
inlineoverride

Definition at line 20 of file PedestalsAlgorithm.h.

20 { ; }

◆ PedestalsAlgorithm() [2/2]

PedestalsAlgorithm::PedestalsAlgorithm ( )
inlineprivate

Definition at line 27 of file PedestalsAlgorithm.h.

27 { ; }

Member Function Documentation

◆ analyse()

void PedestalsAlgorithm::analyse ( )
overrideprivatevirtual

Performs histogram anaysis.

Implements CommissioningAlgorithm.

Definition at line 93 of file PedestalsAlgorithm.cc.

References CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), deadStripMax_, hNoise_, hPeds_, sistrip::invalid_, sistrip::maximum_, sistrip::mlCommissioning_, noisyStripMin_, sistrip::nullPtr_, sistrip::numberOfBins_, mathSSE::sqrt(), nano_mu_digi_cff::strip, and createJobs::tmp.

93  {
94  if (!anal()) {
95  edm::LogWarning(mlCommissioning_) << "[PedestalsAlgorithm::" << __func__ << "]"
96  << " NULL pointer to base Analysis object!";
97  return;
98  }
99 
101  PedestalsAnalysis* anal = dynamic_cast<PedestalsAnalysis*>(tmp);
102  if (!anal) {
103  edm::LogWarning(mlCommissioning_) << "[PedestalsAlgorithm::" << __func__ << "]"
104  << " NULL pointer to derived Analysis object!";
105  return;
106  }
107 
108  if (!hPeds_.first) {
110  return;
111  }
112 
113  if (!hNoise_.first) {
115  return;
116  }
117 
118  TProfile* peds_histo = dynamic_cast<TProfile*>(hPeds_.first);
119  TProfile* noise_histo = dynamic_cast<TProfile*>(hNoise_.first);
120 
121  if (!peds_histo) {
123  return;
124  }
125 
126  if (!noise_histo) {
128  return;
129  }
130 
131  if (peds_histo->GetNbinsX() != 256) {
133  return;
134  }
135 
136  if (noise_histo->GetNbinsX() != 256) {
138  return;
139  }
140 
141  // Iterate through APVs
142  for (uint16_t iapv = 0; iapv < 2; iapv++) {
143  // Used to calc mean and rms for peds and noise
144  float p_sum = 0., p_sum2 = 0., p_max = -1. * sistrip::invalid_, p_min = sistrip::invalid_;
145  float n_sum = 0., n_sum2 = 0., n_max = -1. * sistrip::invalid_, n_min = sistrip::invalid_;
146  float r_sum = 0., r_sum2 = 0., r_max = -1. * sistrip::invalid_, r_min = sistrip::invalid_;
147 
148  // Iterate through strips of APV
149  for (uint16_t istr = 0; istr < 128; istr++) {
150  uint16_t strip = iapv * 128 + istr;
151 
152  // Pedestals and raw noise
153  if (peds_histo) {
154  if (peds_histo->GetBinEntries(strip + 1)) {
155  anal->peds_[iapv][istr] = peds_histo->GetBinContent(strip + 1);
156  p_sum += anal->peds_[iapv][istr];
157  p_sum2 += (anal->peds_[iapv][istr] * anal->peds_[iapv][istr]);
158  if (anal->peds_[iapv][istr] > p_max) {
159  p_max = anal->peds_[iapv][istr];
160  }
161  if (anal->peds_[iapv][istr] < p_min) {
162  p_min = anal->peds_[iapv][istr];
163  }
164 
165  anal->raw_[iapv][istr] = peds_histo->GetBinError(strip + 1);
166  r_sum += anal->raw_[iapv][istr];
167  r_sum2 += (anal->raw_[iapv][istr] * anal->raw_[iapv][istr]);
168  if (anal->raw_[iapv][istr] > r_max) {
169  r_max = anal->raw_[iapv][istr];
170  }
171  if (anal->raw_[iapv][istr] < r_min) {
172  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) {
184  n_max = anal->noise_[iapv][istr];
185  }
186  if (anal->noise_[iapv][istr] < n_min) {
187  n_min = anal->noise_[iapv][istr];
188  }
189  }
190  }
191 
192  } // strip loop
193 
194  // Calc mean and rms for peds
195  if (!anal->peds_[iapv].empty()) {
196  p_sum /= static_cast<float>(anal->peds_[iapv].size());
197  p_sum2 /= static_cast<float>(anal->peds_[iapv].size());
198  anal->pedsMean_[iapv] = p_sum;
199  anal->pedsSpread_[iapv] = sqrt(fabs(p_sum2 - p_sum * p_sum));
200  }
201 
202  // Calc mean and rms for noise
203  if (!anal->noise_[iapv].empty()) {
204  n_sum /= static_cast<float>(anal->noise_[iapv].size());
205  n_sum2 /= static_cast<float>(anal->noise_[iapv].size());
206  anal->noiseMean_[iapv] = n_sum;
207  anal->noiseSpread_[iapv] = sqrt(fabs(n_sum2 - n_sum * n_sum));
208  }
209 
210  // Calc mean and rms for raw noise
211  if (!anal->raw_[iapv].empty()) {
212  r_sum /= static_cast<float>(anal->raw_[iapv].size());
213  r_sum2 /= static_cast<float>(anal->raw_[iapv].size());
214  anal->rawMean_[iapv] = r_sum;
215  anal->rawSpread_[iapv] = sqrt(fabs(r_sum2 - r_sum * r_sum));
216  }
217 
218  // Set max and min values for peds, noise and raw noise
219  if (p_max > -1. * sistrip::maximum_) {
220  anal->pedsMax_[iapv] = p_max;
221  }
222  if (p_min < 1. * sistrip::maximum_) {
223  anal->pedsMin_[iapv] = p_min;
224  }
225  if (n_max > -1. * sistrip::maximum_) {
226  anal->noiseMax_[iapv] = n_max;
227  }
228  if (n_min < 1. * sistrip::maximum_) {
229  anal->noiseMin_[iapv] = n_min;
230  }
231  if (r_max > -1. * sistrip::maximum_) {
232  anal->rawMax_[iapv] = r_max;
233  }
234  if (r_min < 1. * sistrip::maximum_) {
235  anal->rawMin_[iapv] = r_min;
236  }
237 
238  // Set dead and noisy strips
239  for (uint16_t istr = 0; istr < 128; istr++) {
240  if (anal->noiseMin_[iapv] > sistrip::maximum_ || anal->noiseMax_[iapv] > sistrip::maximum_) {
241  continue;
242  }
243  if (anal->noise_[iapv][istr] < (anal->noiseMean_[iapv] - deadStripMax_ * anal->noiseSpread_[iapv])) {
244  anal->dead_[iapv].push_back(istr);
245  } else if (anal->noise_[iapv][istr] > (anal->noiseMean_[iapv] + noisyStripMin_ * anal->noiseSpread_[iapv])) {
246  anal->noisy_[iapv].push_back(istr);
247  }
248  }
249 
250  } // apv loop
251 }
CommissioningAnalysis *const anal() const
static const char numberOfBins_[]
static const char mlCommissioning_[]
T sqrt(T t)
Definition: SSEVec.h:23
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
Abstract base for derived classes that provide analysis of commissioning histograms.
Log< level::Warning, false > LogWarning
tmp
align.sh
Definition: createJobs.py:716
static const char nullPtr_[]

◆ extract()

void PedestalsAlgorithm::extract ( const std::vector< TH1 *> &  histos)
overrideprivatevirtual

Extracts and organises histograms.

Implements CommissioningAlgorithm.

Definition at line 30 of file PedestalsAlgorithm.cc.

References a, CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), sistrip::extrainfo::commonMode_, CommissioningAlgorithm::extractFedKey(), CommissioningAnalysis::fedKey(), combine::histos, hNoise_, hPeds_, sistrip::mlCommissioning_, sistrip::extrainfo::noise_, sistrip::numberOfHistos_, sistrip::PEDESTALS, sistrip::extrainfo::pedestals_, sistrip::extrainfo::pedsAndCmSubNoise_, sistrip::extrainfo::pedsAndRawNoise_, runGCPTkAlMap::title, sistrip::unexpectedExtraInfo_, and sistrip::unexpectedTask_.

30  {
31  if (!anal()) {
32  edm::LogWarning(mlCommissioning_) << "[PedestalsAlgorithm::" << __func__ << "]"
33  << " NULL pointer to Analysis object!";
34  return;
35  }
36 
37  // Check number of histograms
38  if (histos.size() != 2) {
40  }
41 
42  // Extract FED key from histo title
43  if (!histos.empty()) {
44  anal()->fedKey(extractFedKey(histos.front()));
45  }
46 
47  // Extract histograms
48  std::vector<TH1*>::const_iterator ihis = histos.begin();
49  for (; ihis != histos.end(); ihis++) {
50  // Check for NULL pointer
51  if (!(*ihis)) {
52  continue;
53  }
54 
55  // Check run type
56  SiStripHistoTitle title((*ihis)->GetName());
57  if (title.runType() != sistrip::PEDESTALS) {
59  continue;
60  }
61 
62  // Extract peds and noise histos (check for legacy names first!)
63  if (title.extraInfo().find(sistrip::extrainfo::pedsAndRawNoise_) != std::string::npos) {
64  hPeds_.first = *ihis;
65  hPeds_.second = (*ihis)->GetName();
66  PedestalsAnalysis* a = dynamic_cast<PedestalsAnalysis*>(const_cast<CommissioningAnalysis*>(anal()));
67  if (a) {
68  a->legacy_ = true;
69  }
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) {
75  a->legacy_ = true;
76  }
77  } else if (title.extraInfo().find(sistrip::extrainfo::pedestals_) != std::string::npos) {
78  hPeds_.first = *ihis;
79  hPeds_.second = (*ihis)->GetName();
80  } else if (title.extraInfo().find(sistrip::extrainfo::noise_) != std::string::npos) {
81  hNoise_.first = *ihis;
82  hNoise_.second = (*ihis)->GetName();
83  } else if (title.extraInfo().find(sistrip::extrainfo::commonMode_) != std::string::npos) {
84  //@@ something here for CM plots?
85  } else {
87  }
88  }
89 }
static const char noise_[]
CommissioningAnalysis *const anal() const
static const char unexpectedTask_[]
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_[]
Histogram-based analysis for pedestal run.
virtual void addErrorCode(const std::string &error)
static const char commonMode_[]
const uint32_t & fedKey() const
static const char pedestals_[]
static const char pedsAndCmSubNoise_[]
histos
Definition: combine.py:4
double a
Definition: hdecay.h:121
Abstract base for derived classes that provide analysis of commissioning histograms.
Log< level::Warning, false > LogWarning

◆ hNoise()

const PedestalsAlgorithm::Histo & PedestalsAlgorithm::hNoise ( ) const
inline

Definition at line 49 of file PedestalsAlgorithm.h.

References hNoise_.

49 { return hNoise_; }

◆ hPeds()

const PedestalsAlgorithm::Histo & PedestalsAlgorithm::hPeds ( ) const
inline

Definition at line 47 of file PedestalsAlgorithm.h.

References hPeds_.

47 { return hPeds_; }

Member Data Documentation

◆ deadStripMax_

float PedestalsAlgorithm::deadStripMax_
private

Analysis parameters

Definition at line 43 of file PedestalsAlgorithm.h.

Referenced by analyse(), and PedestalsAlgorithm().

◆ hNoise_

Histo PedestalsAlgorithm::hNoise_
private

Residuals and noise

Definition at line 40 of file PedestalsAlgorithm.h.

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

◆ hPeds_

Histo PedestalsAlgorithm::hPeds_
private

Pedestals and raw noise

Definition at line 37 of file PedestalsAlgorithm.h.

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

◆ noisyStripMin_

float PedestalsAlgorithm::noisyStripMin_
private

Definition at line 44 of file PedestalsAlgorithm.h.

Referenced by analyse(), and PedestalsAlgorithm().