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 \Author Rick Wilkinson, Fedor Ratnikov

Definition at line 15 of file AutocorrelationAnalyzer.h.

Constructor & Destructor Documentation

◆ AutocorrelationAnalyzer()

AutocorrelationAnalyzer::AutocorrelationAnalyzer ( int  size)
explicit

Definition at line 5 of file AutocorrelationAnalyzer.cc.

6  : theSize(size),
7  theNTotal(0),
8  theMeans(size, 0),
11  calculated_(false) {}

Member Function Documentation

◆ analyze()

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

Definition at line 25 of file AutocorrelationAnalyzer.h.

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  }

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

◆ calculate()

void AutocorrelationAnalyzer::calculate ( )
private

Definition at line 34 of file AutocorrelationAnalyzer.cc.

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 }

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

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

◆ correlation()

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

Definition at line 27 of file AutocorrelationAnalyzer.cc.

27  {
28  if (!calculated_)
29  calculate();
30  assert(i <= theSize && j <= theSize);
31  return theCorrelations(i + 1, j + 1);
32 }

References cms::cuda::assert(), calculate(), calculated_, mps_fire::i, dqmiolumiharvest::j, theCorrelations, and theSize.

◆ covariance()

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

Definition at line 20 of file AutocorrelationAnalyzer.cc.

20  {
21  if (!calculated_)
22  calculate();
23  assert(i <= theSize && j <= theSize);
24  return theCovariances(i + 1, j + 1);
25 }

References cms::cuda::assert(), calculate(), calculated_, mps_fire::i, dqmiolumiharvest::j, theCovariances, and theSize.

◆ mean()

double AutocorrelationAnalyzer::mean ( int  i)

indexing starts from 0

Definition at line 13 of file AutocorrelationAnalyzer.cc.

13  {
14  if (!calculated_)
15  calculate();
16  assert(i < theSize);
17  return theMeans[i];
18 }

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 }

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().

mps_fire.i
i
Definition: mps_fire.py:428
AutocorrelationAnalyzer::theNTotal
int theNTotal
Definition: AutocorrelationAnalyzer.h:41
AutocorrelationAnalyzer::calculated_
bool calculated_
Definition: AutocorrelationAnalyzer.h:45
cms::cuda::assert
assert(be >=bs)
AutocorrelationAnalyzer::theSize
int theSize
Definition: AutocorrelationAnalyzer.h:40
AutocorrelationAnalyzer::calculate
void calculate()
Definition: AutocorrelationAnalyzer.cc:34
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
GetRecoTauVFromDQM_MC_cff.kk
kk
Definition: GetRecoTauVFromDQM_MC_cff.py:84
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AutocorrelationAnalyzer::theMeans
CLHEP::HepVector theMeans
Definition: AutocorrelationAnalyzer.h:42
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
cuy.ii
ii
Definition: cuy.py:590
AutocorrelationAnalyzer::theCorrelations
CLHEP::HepSymMatrix theCorrelations
Definition: AutocorrelationAnalyzer.h:44
AutocorrelationAnalyzer::theCovariances
CLHEP::HepSymMatrix theCovariances
Definition: AutocorrelationAnalyzer.h:43
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443