CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
AutocorrelationAnalyzer Class Reference

#include <AutocorrelationAnalyzer.h>

Public Member Functions

template<class T >
void analyze (const T &t)
 
 AutocorrelationAnalyzer (int size)
 
double correlation (int i, int j)
 
double covariance (int i, int j)
 
double mean (int i)
 indexing starts from 0 More...
 

Private Member Functions

void calculate ()
 

Private Attributes

bool calculated_
 
CLHEP::HepSymMatrix theCorrelations
 
CLHEP::HepSymMatrix theCovariances
 
CLHEP::HepVector theMeans
 
int theNTotal
 
int theSize
 

Friends

std::ostream & operator<< (std::ostream &os, AutocorrelationAnalyzer &aa)
 

Detailed Description

This class accepts objects which support the [] operator, such as a digi or a vector, and calculates the correlation matrix between the components Rick Wilkinson, Fedor Ratnikov

Definition at line 15 of file AutocorrelationAnalyzer.h.

Constructor & Destructor Documentation

◆ AutocorrelationAnalyzer()

AutocorrelationAnalyzer::AutocorrelationAnalyzer ( int  size)
explicit

Member Function Documentation

◆ analyze()

template<class T >
void AutocorrelationAnalyzer::analyze ( const T t)
inline

Definition at line 25 of file AutocorrelationAnalyzer.h.

References cuy::ii, submitPVValidationJobs::t, theCovariances, theMeans, theNTotal, and theSize.

25  {
26  for (int ii = 0; ii < theSize; ii++) {
27  theMeans[ii] += t[ii];
28  for (int ij = ii; ij < theSize; ij++) {
29  theCovariances[ii][ij] += t[ii] * t[ij];
30  }
31  }
32  ++theNTotal;
33  }
ii
Definition: cuy.py:589
CLHEP::HepSymMatrix theCovariances

◆ calculate()

void AutocorrelationAnalyzer::calculate ( )
private

Definition at line 34 of file AutocorrelationAnalyzer.cc.

References calculated_, isotrackApplyRegressor::k, GetRecoTauVFromDQM_MC_cff::kk, mathSSE::sqrt(), theCorrelations, theCovariances, theMeans, theNTotal, and theSize.

Referenced by correlation(), covariance(), mean(), and operator<<().

34  {
35  for (int k = 0; k < theSize; ++k) {
36  theMeans[k] /= theNTotal;
37  for (int kk = k; kk < theSize; kk++) {
39  }
40  }
41 
42  for (int k = 0; k < theSize; k++) {
43  for (int kk = k; kk < theSize; kk++) {
45  }
46  }
47 
48  calculated_ = true;
49 }
T sqrt(T t)
Definition: SSEVec.h:23
CLHEP::HepSymMatrix theCorrelations
CLHEP::HepSymMatrix theCovariances

◆ correlation()

double AutocorrelationAnalyzer::correlation ( int  i,
int  j 
)

◆ covariance()

double AutocorrelationAnalyzer::covariance ( int  i,
int  j 
)

◆ mean()

double AutocorrelationAnalyzer::mean ( int  i)

indexing starts from 0

Definition at line 13 of file AutocorrelationAnalyzer.cc.

References cms::cuda::assert(), calculate(), calculated_, mps_fire::i, theMeans, and theSize.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
AutocorrelationAnalyzer aa 
)
friend

Definition at line 51 of file AutocorrelationAnalyzer.cc.

51  {
52  aa.calculate();
53  os << "Means: " << std::endl << aa.theMeans << std::endl;
54  os << "Covariances: " << std::endl << aa.theCovariances << std::endl;
55  os << "Correlations: " << std::endl << aa.theCorrelations << std::endl;
56  return os;
57 }
CLHEP::HepSymMatrix theCorrelations
CLHEP::HepSymMatrix theCovariances

Member Data Documentation

◆ calculated_

bool AutocorrelationAnalyzer::calculated_
private

Definition at line 45 of file AutocorrelationAnalyzer.h.

Referenced by calculate(), correlation(), covariance(), and mean().

◆ theCorrelations

CLHEP::HepSymMatrix AutocorrelationAnalyzer::theCorrelations
private

Definition at line 44 of file AutocorrelationAnalyzer.h.

Referenced by calculate(), correlation(), and operator<<().

◆ theCovariances

CLHEP::HepSymMatrix AutocorrelationAnalyzer::theCovariances
private

Definition at line 43 of file AutocorrelationAnalyzer.h.

Referenced by analyze(), calculate(), covariance(), and operator<<().

◆ theMeans

CLHEP::HepVector AutocorrelationAnalyzer::theMeans
private

Definition at line 42 of file AutocorrelationAnalyzer.h.

Referenced by analyze(), calculate(), mean(), and operator<<().

◆ theNTotal

int AutocorrelationAnalyzer::theNTotal
private

Definition at line 41 of file AutocorrelationAnalyzer.h.

Referenced by analyze(), and calculate().

◆ theSize

int AutocorrelationAnalyzer::theSize
private

Definition at line 40 of file AutocorrelationAnalyzer.h.

Referenced by analyze(), calculate(), correlation(), covariance(), and mean().