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

Histogram-based analysis for connection loop. More...

#include <FastFedCablingAlgorithm.h>

Inheritance diagram for FastFedCablingAlgorithm:
CommissioningAlgorithm

Public Member Functions

 FastFedCablingAlgorithm (const edm::ParameterSet &pset, FastFedCablingAnalysis *const)
 
const Histohisto () const
 
 ~FastFedCablingAlgorithm () 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
 
 FastFedCablingAlgorithm ()
 

Private Attributes

Histo histo_
 

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 connection loop.

Author
R.Bainbridge

Definition at line 16 of file FastFedCablingAlgorithm.h.

Constructor & Destructor Documentation

FastFedCablingAlgorithm::FastFedCablingAlgorithm ( const edm::ParameterSet pset,
FastFedCablingAnalysis * const  anal 
)

Definition at line 17 of file FastFedCablingAlgorithm.cc.

FastFedCablingAlgorithm::~FastFedCablingAlgorithm ( )
inlineoverride

Definition at line 20 of file FastFedCablingAlgorithm.h.

20 { ; }
FastFedCablingAlgorithm::FastFedCablingAlgorithm ( )
inlineprivate

Private constructor.

Definition at line 27 of file FastFedCablingAlgorithm.h.

27 { ; }

Member Function Documentation

void FastFedCablingAlgorithm::analyse ( )
overrideprivatevirtual

Performs histogram anaysis.

Implements CommissioningAlgorithm.

Definition at line 64 of file FastFedCablingAlgorithm.cc.

References CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), relmon_rootfiles_spy::contents, FastFedCablingAnalysis::dcuHardId_, FastFedCablingAnalysis::highMean_, FastFedCablingAnalysis::highMedian_, FastFedCablingAnalysis::highRms_, histo(), histo_, sistrip::invalid32_, sistrip::invalid_, FastFedCablingAnalysis::lldCh_, FastFedCablingAnalysis::lowMean_, FastFedCablingAnalysis::lowMedian_, FastFedCablingAnalysis::lowRms_, FastFedCablingAnalysis::max_, FastFedCablingAnalysis::midRange_, FastFedCablingAnalysis::min_, sistrip::mlCommissioning_, hlt_dqm_clientPB-live_cfg::nbins, FastFedCablingAnalysis::nBitsForDcuId_, FastFedCablingAnalysis::nBitsForLldCh_, sistrip::noEntries_, sistrip::nullPtr_, sistrip::numberOfBins_, FastFedCablingAnalysis::range_, sistrip::smallDataRange_, mathSSE::sqrt(), FastFedCablingAnalysis::threshold_, createJobs::tmp, and sistrip::valid_.

64  {
65  if (!anal()) {
66  edm::LogWarning(mlCommissioning_) << "[FastFedCablingAlgorithm::" << __func__ << "]"
67  << " NULL pointer to base Analysis object!";
68  return;
69  }
70 
73  if (!anal) {
74  edm::LogWarning(mlCommissioning_) << "[FastFedCablingAlgorithm::" << __func__ << "]"
75  << " NULL pointer to derived Analysis object!";
76  return;
77  }
78 
79  if (!histo_.first) {
81  return;
82  }
83 
84  TProfile* histo = dynamic_cast<TProfile*>(histo_.first);
85  if (!histo) {
87  return;
88  }
89 
90  // Initialization
91  uint16_t zero_entries = 0;
92  uint16_t nbins = static_cast<uint16_t>(histo->GetNbinsX());
93  std::vector<float> contents;
94  std::vector<float> errors;
95  std::vector<float> entries;
96  contents.reserve(nbins);
97  errors.reserve(nbins);
98  entries.reserve(nbins);
99 
100  // Copy histo contents to containers and find min/max
101  anal->max_ = -1. * sistrip::invalid_;
102  for (uint16_t ibin = 0; ibin < nbins; ibin++) {
103  contents.push_back(histo->GetBinContent(ibin + 1));
104  errors.push_back(histo->GetBinError(ibin + 1));
105  entries.push_back(histo->GetBinEntries(ibin + 1));
106  if (entries[ibin]) {
107  if (contents[ibin] > anal->max_) {
108  anal->max_ = contents[ibin];
109  }
110  if (contents[ibin] < anal->min_) {
111  anal->min_ = contents[ibin];
112  }
113  } else {
114  zero_entries++;
115  }
116  }
117  if (anal->max_ < -1. * sistrip::valid_) {
118  anal->max_ = sistrip::invalid_;
119  }
120 
121  // Check number of bins
124  return;
125  }
126 
127  // Check for bins with zero entries
128  if (zero_entries) {
130  return;
131  }
132 
133  // Check min and max found
134  if (anal->max_ > sistrip::valid_ || anal->min_ > sistrip::valid_) {
135  return;
136  }
137 
138  // Calculate range and mid-range levels
139  anal->range_ = anal->max_ - anal->min_;
140  anal->midRange_ = anal->min_ + anal->range_ / 2.;
141 
142  // Check if range is above threshold
145  return;
146  }
147 
148  // Identify samples to be either "low" or "high"
149  std::vector<float> high;
150  std::vector<float> low;
151  for (uint16_t ibin = 0; ibin < nbins; ibin++) {
152  if (entries[ibin]) {
153  if (contents[ibin] < anal->midRange_) {
154  low.push_back(contents[ibin]);
155  } else {
156  high.push_back(contents[ibin]);
157  }
158  }
159  }
160 
161  // Find median of high and low levels
162  sort(high.begin(), high.end());
163  sort(low.begin(), low.end());
164  if (!high.empty()) {
165  anal->highMedian_ = high[high.size() % 2 ? high.size() / 2 : high.size() / 2];
166  }
167  if (!low.empty()) {
168  anal->lowMedian_ = low[low.size() % 2 ? low.size() / 2 : low.size() / 2];
169  }
170 
171  // Check if light levels above thresholds
172  //if ( anal->highMedian_ < FastFedCablingAnalysis::dirtyThreshold_ ) { anal->addErrorCode(sistrip::invalidLightLevel_); }
173  //if ( anal->lowMedian_ < FastFedCablingAnalysis::trimDacThreshold_ ) { anal->addErrorCode(sistrip::invalidTrimDacLevel_); }
174 
175  // Find mean and rms in "low" samples
176  anal->lowMean_ = 0.;
177  anal->lowRms_ = 0.;
178  for (uint16_t ibin = 0; ibin < low.size(); ibin++) {
179  anal->lowMean_ += low[ibin];
180  anal->lowRms_ += low[ibin] * low[ibin];
181  }
182  if (!low.empty()) {
183  anal->lowMean_ = anal->lowMean_ / low.size();
184  anal->lowRms_ = anal->lowRms_ / low.size();
185  } else {
186  anal->lowMean_ = 1. * sistrip::invalid_;
187  anal->lowRms_ = 1. * sistrip::invalid_;
188  }
189  if (anal->lowMean_ < sistrip::valid_) {
190  anal->lowRms_ = sqrt(fabs(anal->lowRms_ - anal->lowMean_ * anal->lowMean_));
191  } else {
192  anal->lowMean_ = 1. * sistrip::invalid_;
193  anal->lowRms_ = 1. * sistrip::invalid_;
194  }
195 
196  // Find mean and rms in "high" samples
197  anal->highMean_ = 0.;
198  anal->highRms_ = 0.;
199  for (uint16_t ibin = 0; ibin < high.size(); ibin++) {
200  anal->highMean_ += high[ibin];
201  anal->highRms_ += high[ibin] * high[ibin];
202  }
203  if (!high.empty()) {
204  anal->highMean_ = anal->highMean_ / high.size();
205  anal->highRms_ = anal->highRms_ / high.size();
206  } else {
207  anal->highMean_ = 1. * sistrip::invalid_;
208  anal->highRms_ = 1. * sistrip::invalid_;
209  }
210  if (anal->highMean_ < sistrip::valid_) {
211  anal->highRms_ = sqrt(fabs(anal->highRms_ - anal->highMean_ * anal->highMean_));
212  } else {
213  anal->highMean_ = 1. * sistrip::invalid_;
214  anal->highRms_ = 1. * sistrip::invalid_;
215  }
216 
217  // Check if light levels above thresholds
218  //if ( anal->highMean_ < FastFedCablingAnalysis::dirtyThreshold_ ) { anal->addErrorCode(sistrip::invalidLightLevel_); }
219  //if ( anal->lowMean_ < FastFedCablingAnalysis::trimDacThreshold_ ) { anal->addErrorCode(sistrip::invalidTrimDacLevel_); }
220 
221  // Recalculate range
222  if (anal->highMean_ < 1. * sistrip::valid_ && anal->lowMean_ < 1. * sistrip::valid_) {
223  anal->range_ = anal->highMean_ - anal->lowMean_;
224  anal->midRange_ = anal->lowMean_ + anal->range_ / 2.;
225  } else {
226  anal->range_ = 1. * sistrip::invalid_;
227  anal->midRange_ = 1. * sistrip::invalid_;
228  }
229 
230  // Check if updated range is valid and above threshold
231  if (anal->range_ > 1. * sistrip::valid_ || anal->range_ < FastFedCablingAnalysis::threshold_) {
233  return;
234  }
235 
236  // Extract DCU id
237  anal->dcuHardId_ = 0;
238  for (uint16_t ibin = 0; ibin < FastFedCablingAnalysis::nBitsForDcuId_; ibin++) {
239  if (entries[ibin]) {
240  if (contents[ibin] > anal->midRange_) {
241  anal->dcuHardId_ += 0xFFFFFFFF & (1 << ibin);
242  }
243  }
244  }
245  if (!anal->dcuHardId_) {
247  }
248 
249  // Extract DCU id
250  anal->lldCh_ = 0;
251  for (uint16_t ibin = 0; ibin < FastFedCablingAnalysis::nBitsForLldCh_; ibin++) {
252  if (entries[FastFedCablingAnalysis::nBitsForDcuId_ + ibin]) {
253  if (contents[FastFedCablingAnalysis::nBitsForDcuId_ + ibin] > anal->midRange_) {
254  anal->lldCh_ += (0x3 & (1 << ibin));
255  }
256  }
257  }
258  anal->lldCh_++; // starts from 1
259  if (!anal->lldCh_) {
260  anal->lldCh_ = sistrip::invalid_;
261  }
262 }
static const uint32_t invalid32_
Definition: Constants.h:15
const Histo & histo() const
static const uint16_t nBitsForDcuId_
static const uint16_t valid_
Definition: Constants.h:17
static const char numberOfBins_[]
Histogram-based analysis for connection loop.
static const char mlCommissioning_[]
T sqrt(T t)
Definition: SSEVec.h:19
virtual void addErrorCode(const std::string &error)
static const char noEntries_[]
static const uint16_t invalid_
Definition: Constants.h:16
static const char smallDataRange_[]
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_[]
static const float threshold_
static const uint16_t nBitsForLldCh_
void FastFedCablingAlgorithm::extract ( const std::vector< TH1 * > &  histos)
overrideprivatevirtual

Extracts and organises histograms.

Implements CommissioningAlgorithm.

Definition at line 24 of file FastFedCablingAlgorithm.cc.

References CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), CommissioningAlgorithm::extractFedKey(), sistrip::FAST_CABLING, CommissioningAnalysis::fedKey(), histo_, sistrip::mlCommissioning_, sistrip::numberOfHistos_, runGCPTkAlMap::title, and sistrip::unexpectedTask_.

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

24  {
25  if (!anal()) {
26  edm::LogWarning(mlCommissioning_) << "[FastFedCablingAlgorithm::" << __func__ << "]"
27  << " NULL pointer to Analysis object!";
28  return;
29  }
30 
31  // Check number of histograms
32  if (histos.size() != 1) {
34  }
35 
36  // Extract FED key from histo title
37  if (!histos.empty()) {
38  anal()->fedKey(extractFedKey(histos.front()));
39  }
40 
41  // Extract histograms
42  std::vector<TH1*>::const_iterator ihis = histos.begin();
43  for (; ihis != histos.end(); ihis++) {
44  // Check for NULL pointer
45  if (!(*ihis)) {
46  continue;
47  }
48 
49  // Check name
50  SiStripHistoTitle title((*ihis)->GetName());
51  if (title.runType() != sistrip::FAST_CABLING) {
53  continue;
54  }
55 
56  // Extract cabling histo
57  histo_.first = *ihis;
58  histo_.second = (*ihis)->GetName();
59  }
60 }
static const char unexpectedTask_[]
const uint32_t & fedKey() const
Utility class that holds histogram title.
static const char numberOfHistos_[]
uint32_t extractFedKey(const TH1 *const)
static const char mlCommissioning_[]
virtual void addErrorCode(const std::string &error)
Log< level::Warning, false > LogWarning
CommissioningAnalysis *const anal() const
const FastFedCablingAlgorithm::Histo & FastFedCablingAlgorithm::histo ( ) const
inline

Container of histogram pointer and title.

Definition at line 42 of file FastFedCablingAlgorithm.h.

References histo_.

Referenced by analyse().

Member Data Documentation

Histo FastFedCablingAlgorithm::histo_
private

Histo

Definition at line 37 of file FastFedCablingAlgorithm.h.

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