CMS 3D CMS Logo

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 ()
 
 CommissioningAlgorithm (CommissioningAnalysis *const)
 
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() [1/2]

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

Definition at line 17 of file FastFedCablingAlgorithm.cc.

18  : CommissioningAlgorithm(anal), histo_(nullptr, "") {
19  ;
20 }

◆ ~FastFedCablingAlgorithm()

FastFedCablingAlgorithm::~FastFedCablingAlgorithm ( )
inlineoverride

Definition at line 20 of file FastFedCablingAlgorithm.h.

20 { ; }

◆ FastFedCablingAlgorithm() [2/2]

FastFedCablingAlgorithm::FastFedCablingAlgorithm ( )
inlineprivate

Private constructor.

Definition at line 27 of file FastFedCablingAlgorithm.h.

27 { ; }

Member Function Documentation

◆ analyse()

void FastFedCablingAlgorithm::analyse ( )
overrideprivatevirtual

Performs histogram anaysis.

Implements CommissioningAlgorithm.

Definition at line 64 of file FastFedCablingAlgorithm.cc.

64  {
65  if (!anal()) {
66  edm::LogWarning(mlCommissioning_) << "[FastFedCablingAlgorithm::" << __func__ << "]"
67  << " NULL pointer to base Analysis object!";
68  return;
69  }
70 
71  CommissioningAnalysis* tmp = const_cast<CommissioningAnalysis*>(anal());
72  FastFedCablingAnalysis* anal = dynamic_cast<FastFedCablingAnalysis*>(tmp);
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_) {
246  anal->dcuHardId_ = sistrip::invalid32_;
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 }

References CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), relmon_rootfiles_spy::contents, debug_messages_cfi::errors, LaserClient_cfi::high, histo(), histo_, sistrip::invalid32_, sistrip::invalid_, LaserClient_cfi::low, sistrip::mlCommissioning_, LaserClient_cfi::nbins, FastFedCablingAnalysis::nBitsForDcuId_, FastFedCablingAnalysis::nBitsForLldCh_, sistrip::noEntries_, sistrip::nullPtr_, sistrip::numberOfBins_, sistrip::smallDataRange_, mathSSE::sqrt(), FastFedCablingAnalysis::threshold_, createJobs::tmp, and sistrip::valid_.

◆ extract()

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

Extracts and organises histograms.

Implements CommissioningAlgorithm.

Definition at line 24 of file FastFedCablingAlgorithm.cc.

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 }

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

◆ histo()

const FastFedCablingAlgorithm::Histo & FastFedCablingAlgorithm::histo ( ) const
inline

Container of histogram pointer and title.

Definition at line 42 of file FastFedCablingAlgorithm.h.

42 { return histo_; }

References histo_.

Referenced by analyse().

Member Data Documentation

◆ histo_

Histo FastFedCablingAlgorithm::histo_
private

Histo

Definition at line 37 of file FastFedCablingAlgorithm.h.

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

runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
sistrip::FAST_CABLING
Definition: ConstantsForRunType.h:89
sistrip::invalid32_
static const uint32_t invalid32_
Definition: Constants.h:15
CommissioningAlgorithm::extractFedKey
uint32_t extractFedKey(const TH1 *const)
Definition: CommissioningAlgorithm.cc:29
sistrip::unexpectedTask_
static const char unexpectedTask_[]
Definition: ConstantsForCommissioningAnalysis.h:21
CommissioningAnalysis::fedKey
const uint32_t & fedKey() const
Definition: CommissioningAnalysis.h:134
CommissioningAnalysis::addErrorCode
virtual void addErrorCode(const std::string &error)
Definition: CommissioningAnalysis.h:148
sistrip::numberOfHistos_
static const char numberOfHistos_[]
Definition: ConstantsForCommissioningAnalysis.h:16
FastFedCablingAnalysis
Histogram-based analysis for connection loop.
Definition: FastFedCablingAnalysis.h:16
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
sistrip::valid_
static const uint16_t valid_
Definition: Constants.h:17
relmon_rootfiles_spy.contents
contents
Definition: relmon_rootfiles_spy.py:129
sistrip::mlCommissioning_
static const char mlCommissioning_[]
Definition: ConstantsForLogger.h:15
FastFedCablingAnalysis::threshold_
static const float threshold_
Definition: FastFedCablingAnalysis.h:83
errors
Definition: errors.py:1
CommissioningAlgorithm::anal
CommissioningAnalysis *const anal() const
Definition: CommissioningAlgorithm.h:50
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
sistrip::numberOfBins_
static const char numberOfBins_[]
Definition: ConstantsForCommissioningAnalysis.h:18
CommissioningAlgorithm::CommissioningAlgorithm
CommissioningAlgorithm()
Definition: CommissioningAlgorithm.cc:15
FastFedCablingAnalysis::nBitsForDcuId_
static const uint16_t nBitsForDcuId_
Definition: FastFedCablingAnalysis.h:92
sistrip::noEntries_
static const char noEntries_[]
Definition: ConstantsForCommissioningAnalysis.h:20
FastFedCablingAnalysis::nBitsForLldCh_
static const uint16_t nBitsForLldCh_
Definition: FastFedCablingAnalysis.h:95
sistrip::invalid_
static const uint16_t invalid_
Definition: Constants.h:16
combine.histos
histos
Definition: combine.py:4
CommissioningAnalysis
Abstract base for derived classes that provide analysis of commissioning histograms.
Definition: CommissioningAnalysis.h:18
LaserClient_cfi.high
high
Definition: LaserClient_cfi.py:50
FastFedCablingAlgorithm::histo_
Histo histo_
Definition: FastFedCablingAlgorithm.h:37
FastFedCablingAlgorithm::histo
const Histo & histo() const
Definition: FastFedCablingAlgorithm.h:42
sistrip::smallDataRange_
static const char smallDataRange_[]
Definition: ConstantsForCommissioningAnalysis.h:38
SiStripHistoTitle
Utility class that holds histogram title.
Definition: SiStripHistoTitle.h:20
sistrip::nullPtr_
static const char nullPtr_[]
Definition: ConstantsForCommissioningAnalysis.h:17
LaserClient_cfi.low
low
Definition: LaserClient_cfi.py:52
debug_messages_cfi.errors
errors
Definition: debug_messages_cfi.py:54