5 #include "TMatrixTSym.h"
6 #include "TMatrixDSymEigen.h"
13 int main(
int argc,
char** argv ){
15 if(
string(argv[1]) ==
"help" ||
string(argv[1]) ==
"-help" ||
string(argv[1]) ==
"--help" ||
string(argv[1]) ==
"-h") {
16 cout <<
"This program expects the following argument(s) in order: " << endl;
17 cout <<
"Argument 1: path to merged gain_factor_matrices.root" << endl;
22 cout <<
"Error: you must specify the path to your gain_factor_matrices.root file!!!" << endl;
26 TFile* myfile =
new TFile(argv[1]);
27 TH1F* h1D_mC = (TH1F*)myfile->Get(
"h2D_mC");
29 int n_channels = h1D_mC->GetNbinsX();
30 int n_channelsy = h1D_mC->GetNbinsY();
32 if (n_channels != n_channelsy) {
33 cout <<
"*** Non-square matrix***, nchannels=" << n_channels <<
" nchannelsy=" << n_channelsy << endl;
37 cout <<
"Found square matrix m_mc, nchannels=" << n_channels << endl;
42 m_mC.ResizeTo(n_channels,n_channels);
45 cout <<
"Generating Matrix from imported TH1F..." << endl;
46 for(
int i = 0 ; i<n_channels; ++i) {
47 for(
int j = 0 ; j<n_channels; ++j) {
48 m_mC[i][j]=h1D_mC->GetBinContent(i+1,j+1);
53 cout <<
"Getting Eigensystem (this will take a while...) \n";
54 TMatrixDSymEigen mC_eigen(m_mC);
55 TVectorD eval = mC_eigen.GetEigenValues();
56 TMatrixD evec = mC_eigen.GetEigenVectors();
57 cout <<
"Filling Histograms... \n";
60 double mymin=eval.Min();
61 double mymax=eval.Max();
63 TH1F* h1_evals =
new TH1F(
"h1_evals",
"Eigenvalues of C Matrix by Channel Number",n_channels, 0., n_channels );
64 TH2F* h2_evecs =
new TH2F(
"h2_evecs DO NOT PLOT",
"Eigenvectors (good luck drawing this)", n_channels, 0., n_channels, n_channels,0.,n_channels );
65 TH1F* eig =
new TH1F(
"Eigenvalues, unordered",
"Eigenvalues of C matrix" ,100, mymin, mymax/12. );
69 for(
int i = 0 ; i<n_channels; ++i) {
71 if(eval[i]>0.0 &&eval[i]<10000.0) h1_evals->SetBinContent(i+1,eval[i]);
73 for(
int j = 0 ; j<n_channels; ++j) {
74 h2_evecs->SetBinContent(i+1,j+1,evec[i][j]);
78 TFile* m_rootFile =
new TFile(
"C_Eigensystem.root",
"RECREATE" );
87 cout <<
"done" << endl;
int main(int argc, char *argv[])