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 | 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 ( int  size)
explicit

Definition at line 5 of file AutocorrelationAnalyzer.cc.

Member Function Documentation

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

Definition at line 26 of file AutocorrelationAnalyzer.h.

References theCovariances, theMeans, theNTotal, and theSize.

27  {
28  for (int ii = 0; ii < theSize; ii++) {
29  theMeans[ii] += t[ii];
30  for (int ij = ii; ij < theSize; ij++) {
31  theCovariances[ii][ij] += t[ii] * t[ij];
32  }
33  }
34  ++theNTotal;
35  }
CLHEP::HepSymMatrix theCovariances
void AutocorrelationAnalyzer::calculate ( )
private

Definition at line 41 of file AutocorrelationAnalyzer.cc.

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

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

42 {
43  for(int k = 0; k < theSize; ++k)
44  {
45  theMeans[k] /= theNTotal;
46  for (int kk = k; kk < theSize; kk++)
47  {
48  theCovariances[k][kk] /= theNTotal;
49  }
50  }
51 
52  for (int k = 0; k < theSize; k++)
53  {
54  for (int kk = k; kk < theSize; kk++)
55  {
56  theCorrelations[k][kk] = theCovariances[k][kk]
57  / sqrt (theCovariances[k][k]*theCovariances[kk][kk]);
58  }
59  }
60 
61  calculated_ = true;
62 }
T sqrt(T t)
Definition: SSEVec.h:28
int k[5][pyjets_maxn]
CLHEP::HepSymMatrix theCorrelations
CLHEP::HepSymMatrix theCovariances
double AutocorrelationAnalyzer::correlation ( int  i,
int  j 
)

Definition at line 32 of file AutocorrelationAnalyzer.cc.

References calculate(), calculated_, theCorrelations, and theSize.

33 {
34  if(!calculated_) calculate();
35  assert(i<=theSize && j<=theSize);
36  return theCorrelations(i+1,j+1);
37 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
CLHEP::HepSymMatrix theCorrelations
double AutocorrelationAnalyzer::covariance ( int  i,
int  j 
)

Definition at line 24 of file AutocorrelationAnalyzer.cc.

References calculate(), calculated_, theCovariances, and theSize.

25 {
26  if(!calculated_) calculate();
27  assert(i<=theSize && j<=theSize);
28  return theCovariances(i+1,j+1);
29 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
CLHEP::HepSymMatrix theCovariances
double AutocorrelationAnalyzer::mean ( int  i)

indexing starts from 0

Definition at line 16 of file AutocorrelationAnalyzer.cc.

References calculate(), calculated_, i, theMeans, and theSize.

Friends And Related Function Documentation

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

Definition at line 65 of file AutocorrelationAnalyzer.cc.

66 {
67  aa.calculate();
68  os << "Means: " << std::endl << aa.theMeans << std::endl;
69  os << "Covariances: " << std::endl << aa.theCovariances << std::endl;
70  os << "Correlations: " << std::endl << aa.theCorrelations << std::endl;
71  return os;
72 }
CLHEP::HepSymMatrix theCorrelations
CLHEP::HepSymMatrix theCovariances

Member Data Documentation

bool AutocorrelationAnalyzer::calculated_
private

Definition at line 47 of file AutocorrelationAnalyzer.h.

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

CLHEP::HepSymMatrix AutocorrelationAnalyzer::theCorrelations
private

Definition at line 46 of file AutocorrelationAnalyzer.h.

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

CLHEP::HepSymMatrix AutocorrelationAnalyzer::theCovariances
private

Definition at line 45 of file AutocorrelationAnalyzer.h.

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

CLHEP::HepVector AutocorrelationAnalyzer::theMeans
private

Definition at line 44 of file AutocorrelationAnalyzer.h.

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

int AutocorrelationAnalyzer::theNTotal
private

Definition at line 43 of file AutocorrelationAnalyzer.h.

Referenced by analyze(), and calculate().

int AutocorrelationAnalyzer::theSize
private

Definition at line 42 of file AutocorrelationAnalyzer.h.

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