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

Algorithm for scope mode data. More...

#include <DaqScopeModeAlgorithm.h>

Inheritance diagram for DaqScopeModeAlgorithm:
CommissioningAlgorithm

Public Member Functions

 DaqScopeModeAlgorithm (const edm::ParameterSet &pset, DaqScopeModeAnalysis *const )
 
const float & entries () const
 
const Histohisto () const
 
const float & max () const
 
const float & mean () const
 
const float & median () const
 
const float & min () const
 
const float & mode () const
 
const float & rms () const
 
virtual ~DaqScopeModeAlgorithm ()
 
- Public Member Functions inherited from CommissioningAlgorithm
void analysis (const std::vector< TH1 * > &)
 
 CommissioningAlgorithm (CommissioningAnalysis *const )
 
 CommissioningAlgorithm ()
 
virtual ~CommissioningAlgorithm ()
 

Private Member Functions

void analyse ()
 
 DaqScopeModeAlgorithm ()
 
void extract (const std::vector< TH1 * > &)
 

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

Algorithm for scope mode data.

Author
R.Bainbridge

Definition at line 16 of file DaqScopeModeAlgorithm.h.

Constructor & Destructor Documentation

DaqScopeModeAlgorithm::DaqScopeModeAlgorithm ( const edm::ParameterSet pset,
DaqScopeModeAnalysis * const  anal 
)

Definition at line 15 of file DaqScopeModeAlgorithm.cc.

virtual DaqScopeModeAlgorithm::~DaqScopeModeAlgorithm ( )
inlinevirtual

Definition at line 22 of file DaqScopeModeAlgorithm.h.

22 {;}
DaqScopeModeAlgorithm::DaqScopeModeAlgorithm ( )
inlineprivate

Definition at line 36 of file DaqScopeModeAlgorithm.h.

36 {;}

Member Function Documentation

void DaqScopeModeAlgorithm::analyse ( )
privatevirtual

Performs histogram anaylsis.

Implements CommissioningAlgorithm.

Definition at line 63 of file DaqScopeModeAlgorithm.cc.

References CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), relmon_rootfiles_spy::contents, DaqScopeModeAnalysis::entries_, histo_, sistrip::invalid_, DaqScopeModeAnalysis::max_, sistrip::maximum_, DaqScopeModeAnalysis::mean_, median(), DaqScopeModeAnalysis::median_, DaqScopeModeAnalysis::min_, sistrip::mlCommissioning_, DaqScopeModeAnalysis::mode_, pileupCalc::nbins, sistrip::nullPtr_, DaqScopeModeAnalysis::rms_, python.multivaluedict::sort(), mathSSE::sqrt(), tmp, and relativeConstraints::value.

63  {
64 
65  if ( !anal() ) {
67  << "[DaqScopeModeAlgorithm::" << __func__ << "]"
68  << " NULL pointer to base Analysis object!";
69  return;
70  }
71 
74  if ( !anal ) {
76  << "[DaqScopeModeAlgorithm::" << __func__ << "]"
77  << " NULL pointer to derived Analysis object!";
78  return;
79  }
80 
81  if ( !histo_.first ) {
83  return;
84  }
85 
86  // Some initialization
87  std::vector<float> median;
88  float max_value = -1. * sistrip::invalid_;
89  float max_contents = -1. * sistrip::invalid_;
90  float sum = 0.;
91  float sum2 = 0.;
92 
93  // Entries, min, mode
94  uint16_t nbins = static_cast<uint16_t>( histo_.first->GetNbinsX() );
95  for ( uint16_t ibin = 0; ibin < nbins; ibin++ ) {
96  float value = histo_.first->GetBinLowEdge(ibin+1) + histo_.first->GetBinWidth(ibin+1) / 2.;
97  float contents = histo_.first->GetBinContent(ibin+1);
98  //float errors = histo_.first->GetBinError(ibin+1);
99  if ( contents ) {
100  if ( contents > max_contents ) { anal->mode_ = contents; max_contents = contents; }
101  if ( value > max_value ) { max_value = value; }
102  if ( value < anal->min_ ) { anal->min_ = value; }
103  sum += value * contents;
104  sum2 += value * contents* value * contents;
105  median.insert( median.end(), static_cast<uint32_t>(contents), value );
106  }
107  anal->entries_ += contents;
108  }
109 
110  // Max
111  if ( max_value > -1. * sistrip::maximum_ ) { anal->max_ = max_value; }
112 
113  // Median
114  sort( median.begin(), median.end() );
115  if ( !median.empty() ) { anal->median_ = median[ median.size()%2 ? median.size()/2 : median.size()/2 ]; }
116 
117  // Mean, rms
118  if ( anal->entries_ ) {
119  sum /= static_cast<float>(anal->entries_);
120  sum2 /= static_cast<float>(anal->entries_);
121  anal->mean_ = sum;
122  if ( sum2 > sum*sum ) { anal->rms_ = sqrt( sum2 - sum*sum ); }
123  }
124 
125 }
const float & median() const
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_[]
Analysis for scope mode data.
const float& DaqScopeModeAlgorithm::entries ( ) const
inline
void DaqScopeModeAlgorithm::extract ( const std::vector< TH1 * > &  )
privatevirtual

Extracts and organises histograms.

Implements CommissioningAlgorithm.

Definition at line 22 of file DaqScopeModeAlgorithm.cc.

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

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

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

Definition at line 48 of file DaqScopeModeAlgorithm.h.

References histo_.

48 { return histo_; }
const float& DaqScopeModeAlgorithm::max ( ) const
inline
const float& DaqScopeModeAlgorithm::mean ( ) const
inline
const float& DaqScopeModeAlgorithm::median ( ) const
inline

Referenced by analyse().

const float& DaqScopeModeAlgorithm::min ( ) const
inline
const float& DaqScopeModeAlgorithm::mode ( ) const
inline
const float& DaqScopeModeAlgorithm::rms ( ) const
inline

Member Data Documentation

Histo DaqScopeModeAlgorithm::histo_
private

Histogram of scope mode data.

Definition at line 45 of file DaqScopeModeAlgorithm.h.

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