vnl_matrix<double> Get4x4(const vnl_double_3x3 &M) { vnl_matrix<double> M4(4,4); M4.set_identity(); //M4 = vnl_matrix<double> (M,1,1); M4(0,0) = M(0,0); M4(0,1) = M(0,1); M4(0,2) = M(0,1); M4(1,0) = M(1,0); M4(1,1) = M(1,1); M4(1,2) = M(1,2); M4(2,0) = M(2,0); M4(2,1) = M(2,1); M4(2,2) = M(2,2); return M4; }
int main (int narg, const char** argv) { typedef Range<false> R; typedef Range<true> CR; Matrix<double> M1(10, 1), M2, M3(M1), M4(3, 4), M6(4, 3), M5(3, 4, 2), M7(3, 4, 2), M8, M9, M10, M11; M1 = 0.0; M2 = M1; for (size_t i = 1; i < M1.Size(); ++i) M1[i] = i; for (size_t i = 1; i < M4.Size(); ++i) M4[i] = i; for (size_t i = 1; i < M5.Size(); ++i) M5[i] = i; M3(R(7,-2,2)) = M1(CR(2,4)); M6(R(3,-2,0),R(0,1)) = M4(CR(0,1),CR(1,2)); M7(R(2,-2,0),R(0,1),R(0,0)) = M5(CR(0,1),CR(1,2),CR(0,0)); M8 = M6(CR(1,-1,0),CR(1,2)); M6(R(0,1),R(1,2)) = M8; M9 = M6(CR("1:-1:0"),CR("1:2")); M10 = M6(CR("1:-1:0,1"),CR("1:2")); M11 = M6(CR(),CR()) * M6(CR(),CR()); M11 = M6 * M6(CR(),CR()); std::cout << M3 << std::endl<< std::endl; std::cout << M4 << std::endl<< std::endl; std::cout << M6 << std::endl<< std::endl; std::cout << M5 << std::endl<< std::endl; std::cout << M7 << std::endl<< std::endl; std::cout << M8 << std::endl<< std::endl; std::cout << M9 << std::endl<< std::endl; std::cout << M10 << std::endl<< std::endl; std::cout << M11 << std::endl<< std::endl; return 0; }
struct DoubleMat44 square_skaled(struct DoubleMat44 A) { double _1_max = 1 / INFTY_NORM16(A); struct DoubleMat44 A2; int row, col; for (row = 0; row < 4; row++) { for (col = 0; col < 4; col++) { M4(A2, row, col) = M4(A, row, 0) * M4(A, 0, col) + M4(A, row, 1) * M4(A, 1, col) + M4(A, row, 2) * M4(A, 2, col) + M4(A, row, 3) * M4(A, 3, col); M4(A2, row, col) *= _1_max; // pays attention that the values don't grow too far } } return A2; }
/* This function generates the "K"-matrix out of an attitude profile matrix * * I don't know the real name of the "K"-Matrix, but everybody (see References from the other functions) * calls it "K", so I do it as well. */ struct DoubleMat44 generate_K_matrix(struct DoubleMat33 B) { struct DoubleMat44 K; double traceB = RMAT_TRACE(B); double z1 = M3(B, 1, 2) - M3(B, 2, 1); double z2 = M3(B, 2, 0) - M3(B, 0, 2); double z3 = M3(B, 0, 1) - M3(B, 1, 0); /** The "K"-Matrix. See the references for it **/ /* Fill the upper triangle matrix */ M4(K, 0, 0) = traceB; M4(K, 0, 1) = z1; M4(K, 0, 2) = z2; M4(K, 0, 3) = z3; M4(K, 1, 1) = 2 * M3(B, 0, 0) - traceB; M4(K, 1, 2) = M3(B, 0, 1) + M3(B, 1, 0); M4(K, 1, 3) = M3(B, 0, 2) + M3(B, 2, 0); M4(K, 2, 2) = 2 * M3(B, 1, 1) - traceB; M4(K, 2, 3) = M3(B, 1, 2) + M3(B, 2, 1); M4(K, 3, 3) = 2 * M3(B, 2, 2) - traceB; /* Copy to lower triangle matrix */ M4(K, 1, 0) = M4(K, 0, 1); M4(K, 2, 0) = M4(K, 0, 2); M4(K, 2, 1) = M4(K, 1, 2); M4(K, 3, 0) = M4(K, 0, 3); M4(K, 3, 1) = M4(K, 1, 3); M4(K, 3, 2) = M4(K, 2, 3); return K; }
void main() //main code { printf("\nRUNGE-KUTTA METHOD\n\nR M Rho\n"); //printing titles for values displayed double c = 10.0; //the parameter rho(c) int n; //the integer steps, n //declare arrays float x[N]; float y[N]; float z[N]; //r,m,p as the radius, mass and density double r,m,p; //declare initial conditons for arrays x[0] = h; //first array is for r=h y[0] = (h*h*h/3)*c; //initial conditon for scaled mass (m) z[0] = c*(1-((h*h*c)/(6*gamma(c)))); //initial conditon for rho //for loop for n=0,1,...,200 for(n=0;n<N;n++) { //declared how x(n+1) relates to x(n), y(n+1) relates to y(n), z(n+1) relates to z(n) x[n+1] = x[n]+h; y[n+1] = y[n]+(h/6)*(M(x[n],y[n],z[n])+2*M2(x[n],y[n],z[n])+2*M3(x[n],y[n],z[n])+M4(x[n],y[n],z[n])); z[n+1] = z[n]+(h/6)*(rho(x[n],y[n],z[n])+2*rho2(x[n],y[n],z[n])+2*rho3(x[n],y[n],z[n])+rho4(x[n],y[n],z[n])); if(isnan(z[n+1])) { break; } //r,m,p will be declared in pg-plot r = x[n+1]; m = y[n+1]; p = z[n+1]; printf("%.2e %.2e %.2e\n",x[n+1],y[n+1],z[n+1]); //printed values for x and y respectively } //Use pg-plot to plot mass and density // cpgbeg starts a plotting page, in this case with 2x1 panels cpgbeg(0,"?",2,1); // sets colour: 1-black, 2-red, 3-green, 4-blue cpgsci(1); // sets line style: 1-solid, 2-dashed, 3-dot-dashed, 4-dotted cpgsls(1); // sets charachter height, larger number = bigger cpgsch(1.); // cpgpage() moves to the next panel cpgpage(); // sets the axes limits in the panel cpgswin(0,r,0,m); // draw the axes cpgbox("BCNST", 0.0, 0, "BCNST", 0.0, 0); // label the bottom axis cpgmtxt("B",2.,.5,.5,"radius"); // label the left axis cpgmtxt("L",2.5,.5,.5,"saclaed mass"); // connect N points in ax and ay with a line cpgline(n,x,y); // cpgpage() moves to the next panel cpgpage(); // sets the axes limits in the panel cpgswin(0,r,0,c); // draw the axes cpgbox("BCNST", 0.0, 0, "BCNST", 0.0, 0); // label the bottom axis cpgmtxt("B",2.,.5,.5,"radius"); // label the left axis cpgmtxt("L",2.5,.5,.5,"density"); // connect N points in ax and ay with a line cpgline(n,x,z); // close all pgplot applications cpgend(); // end program return; }
void main() //main code { double Rs = Y*((7.72*pow(10,8))/(6.95*pow(10,10))); double Ms = Y*Y*((5.67*pow(10,33))/(1.98*pow(10,33))); double c = 82; //the parameter rho(c) printf("\nSIRIUS B\n"); printf("\nRunge-Kutta Method\nMs (solar masses) Rs (solar radii) Rho(c) (solar densities) Y(e)\n"); //printing titles for values displayed int n; //the integer steps, n //declare arrays float x[N]; float y[N]; float z[N]; float x2[N]; float y2[N]; float z2[N]; //r,m,p as the radius, mass and density double r,m,p,r2,m2,p2; //declare initial conditons for arrays x[0] = h; //first array is for r=h y[0] = (h*h*h/3)*c; //initial conditon for scaled mass (m) z[0] = c*(1-((h*h*c)/(6*gamma(c)))); //initial conditon for rho //for loop for n=0,1,...,N for(n=0;n<N;n++) { //declared how x(n+1) relates to x(n), y(n+1) relates to y(n), z(n+1) relates to z(n) x[n+1] = x[n]+h; y[n+1] = y[n]+(h/6)*(M(x[n],y[n],z[n])+2*M2(x[n],y[n],z[n])+2*M3(x[n],y[n],z[n])+M4(x[n],y[n],z[n])); z[n+1] = z[n]+(h/6)*(rho(x[n],y[n],z[n])+2*rho2(x[n],y[n],z[n])+2*rho3(x[n],y[n],z[n])+rho4(x[n],y[n],z[n])); if(isnan(z[n+1])) { break; } //r,m,p will be declared in pg-plot r = x[n+1]; m = y[n+1]; p = z[n+1]; } printf("%.3e %.3e %.2f %.3f\n",y[n]*Ms,x[n]*Rs,c,Y); //printed values for x and y respectively printf("\nEuler Method\nMs (solar masses) Rs (solar radii) Rho(c) (solar densities) Y(e)\n"); //printing titles for values displayed //declare initial conditons for arrays x2[0] = h; //first array is for r=h y2[0] = (h*h*h/3)*c; //initial conditon for scaled mass (m) z2[0] = c*(1-((h*h*c)/(6*gamma(c)))); //initial conditon for rho //for loop for n=0,1,...,200 for(n=0;n<N;n++) { //declared how x2(n+1) relates to x2(n), y2(n+1) relates to y2(n), z2(n+1) relates to z2(n) x2[n+1] = x2[n]+h; y2[n+1] = y2[n]+h*(M(x2[n],y2[n],z2[n])); z2[n+1] = z2[n]+h*(rho(x2[n],y2[n],z2[n])); if(z2[n+1]<0) { break; } //r2,m2,p2 will be declared in pg-plot r2 = x2[n+1]; m2 = y2[n+1]; p2 = z2[n+1]; } //printed values for x and y respectively printf("%.3e %.3e %.2f %.3f\n",y2[n]*Ms,x2[n]*Rs,c,Y); }
void TestMatrix(ostream& os) { // display a headline os << "Matrix test\r\n===========\r\n"; Matrix<int> A(3,3), B(3,3), C(3,3), D(3,3); A(0,0) = 1; A(0,1) = 3; A(0,2) = -4; A(1,0) = 1; A(1,1) = 1; A(1,2) = -2; A(2,0) = -1; A(2,1) = -2; A(2,2) = 5; B(0,0) = 8; B(0,1) = 3; B(0,2) = 0; B(1,0) = 3; B(1,1) = 10; B(1,2) = 2; B(2,0) = 0; B(2,1) = 2; B(2,2) = 6; D(0,0) = 1; D(0,1) = 2; D(0,2) = -1; D(1,0) = 2; D(1,1) = -1; D(1,2) = -3; D(2,0) = 0; D(2,1) = -2; D(2,2) = 4; os << "\r\nMatrix A = \r\n"; ShowMatrix(os,A); os << "\r\nMatrix B = \r\n"; ShowMatrix(os,B); C = A % B; os << "\r\nMatrix C (A % B) = \r\n"; ShowMatrix(os,C); C = A + B; os << "\r\nMatrix C (A + B) = \r\n"; ShowMatrix(os,C); C = A; C += B; os << "\r\nMatrix C (= A, += B) =\r\n"; ShowMatrix(os,C); C = A + 1; os << "\r\nMatrix C (= A + 1) =\r\n"; ShowMatrix(os,C); C += 1; os << "\r\nMatrix C (+= 1) =\r\n"; ShowMatrix(os,C); C = A - B; os << "\r\nMatrix C (A - B) = \r\n"; ShowMatrix(os,C); C = A; C -= B; os << "\r\nMatrix C (= A, -= B) =\r\n"; ShowMatrix(os,C); C = A - 1; os << "\r\nMatrix C (= A - 1) =\r\n"; ShowMatrix(os,C); C -= 1; os << "\r\nMatrix C (-= 1) =\r\n"; ShowMatrix(os,C); C = A * B; os << "\r\nMatrix C (A * B) = \r\n"; ShowMatrix(os,C); C = A; C *= B; os << "\r\nMatrix C (= A, *= B) =\r\n"; ShowMatrix(os,C); C = A * 2; os << "\r\nMatrix C (= A * 2) =\r\n"; ShowMatrix(os,C); C *= 2; os << "\r\nMatrix C (*= 2) =\r\n"; ShowMatrix(os,C); C = B / A; os << "\r\nMatrix C (B / A) = \r\n"; ShowMatrix(os,C); C = B; C /= A; os << "\r\nMatrix C (= B, /= A) =\r\n"; ShowMatrix(os,C); C = A / 2; os << "\r\nMatrix C (= A / 2) =\r\n"; ShowMatrix(os,C); C /= 2; os << "\r\nMatrix C (/= 2) =\r\n"; ShowMatrix(os,C); C = -A; os << "\r\nMatrix C (-A) = \r\n"; ShowMatrix(os,C); // test comparisons os << "\r\nMatrix A = \r\n"; ShowMatrix(os,A); os << "\r\nMatrix D = \r\n"; ShowMatrix(os,D); if (A.Equals(D)) os << "\r\nERROR: A should not equal D"; else os << "\r\nOKAY: A not equal D"; C = A; if (A.Equals(C)) os << "\r\nOKAY: A equals C\r\n"; else os << "\r\nERROR: A should equal C\r\n"; Matrix<bool> I(3,3); I = (A == D); os << "\r\nMatrix I = (A == D)\r\n"; ShowMatrix(os,I); I = (A != D); os << "\r\nMatrix I = (A != D)\r\n"; ShowMatrix(os,I); I = (A < D); os << "\r\nMatrix I = (A < D)\r\n"; ShowMatrix(os,I); I = (A <= D); os << "\r\nMatrix I = (A <= D)\r\n"; ShowMatrix(os,I); I = (A > D); os << "\r\nMatrix I = (A > D)\r\n"; ShowMatrix(os,I); I = (A >= D); os << "\r\nMatrix I = (A >= D)\r\n"; ShowMatrix(os,I); // check fill function C.Fill(9); os << "\r\nC filled with 9 =\r\n"; ShowMatrix(os,C); // check Apply functions C = Apply(A, Times2); os << "\r\nC = A.Apply(Times2)\r\n"; ShowMatrix(os,C); C.Apply(Times2); os << "\r\nApply(C,Times2)\r\n"; ShowMatrix(os,C); // check row and column vector functions Matrix<int> S(1,1); Matrix<int> r1A(3,1); Matrix<int> c0B(1,3); r1A = A.VectorRow(1); c0B = B.VectorCol(0); os << "\r\nMatrix S = \r\n"; ShowMatrix(os,S); os << "\r\nMatrix R1A = \r\n"; ShowMatrix(os,r1A); os << "\r\nMatrix C0B = \r\n"; ShowMatrix(os,c0B); if (r1A.IsRowVector()) os << "\r\nOKAY: R1A is row vector"; else os << "\r\nERROR: R1A should be a row vector"; if (!r1A.IsColVector()) os << "\r\nOKAY: R1A is not a column vector"; else os << "\r\nERROR: R1A should not be a column vector"; if (!c0B.IsRowVector()) os << "\r\nOKAY: C0B is not a row vector"; else os << "\r\nERROR: C0B should not be a row vector"; if (c0B.IsColVector()) os << "\r\nOKAY: C0B is column vector"; else os << "\r\nERROR: C0B should be a column vector"; if (c0B.IsVector()) os << "\r\nOKAY: C0B is a vector"; else os << "\r\nERROR: C0B should be a vector"; if (!A.IsVector()) os << "\r\nOKAY: A is not a vector"; else os << "\r\nERROR: A should not be a vector"; if (!c0B.IsSquare()) os << "\r\nOKAY: C0B is not square"; else os << "\r\nERROR: C0B should not be square"; if (A.IsSquare()) os << "\r\nOKAY: A is square"; else os << "\r\nERROR: A should be square"; B.Fill(0); if (B.IsZero()) os << "\r\nOKAY: B is zero"; else os << "\r\nERROR: B should be zero"; if (!A.IsZero()) os << "\r\nOKAY: A is not zero"; else os << "\r\nERROR: A should not be zero"; // test inner product int ip = r1A.InnerProduct(c0B); os << "\r\n\r\ninner product of R1A and C0B = " << ip << "\r\n"; // make some bigger matrices Matrix<int> M1(5,5), M2(5,5,3), M3(5,5), M4(5,5); const int junk[] = { 1, 5, 3, 0, 1, 0, 2, 0, 4, 5, 1, 0, 0, 2, 3, 7, 1, 3, 0, 0, 2, 1, 0, 4, 6 }; const int ident[] = { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 }; const int tridi[] = { 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1 }; const int utri[] = { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1 }; const int ltri[] = { 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1 }; const int perm[] = { 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0 }; const int det[] = { 3, 5, 3, 8, 1, 2, 6, 3, 4, 5, 1, 4, 5, 2, 3, 7, 1, 3, 6, 8, 2, 4, 1, 4, 9 }; M1 = ident; M3 = M1 * 2; M4 = junk; os << "\r\nmatrix M1 = \r\n"; ShowMatrix(os,M1); os << "\r\nmatrix M2 = \r\n"; ShowMatrix(os,M2); os << "\r\nmatrix M3 = \r\n"; ShowMatrix(os,M3); os << "\r\nmatrix M4 = \r\n"; ShowMatrix(os,M4); if (M1.IsDiagonal()) os << "\r\nOKAY: M1 is diagonal"; else os << "\r\nERROR: M1 should be diagonal"; if (M1.IsIdentity()) os << "\r\nOKAY: M1 is an identity matrix"; else os << "\r\nERROR: M1 should be an identity matrix"; if (!M2.IsDiagonal()) os << "\r\nOKAY: M2 is not diagonal"; else os << "\r\nERROR: M2 should not be diagonal"; if (!M2.IsIdentity()) os << "\r\nOKAY: M2 is not an identity matrix"; else os << "\r\nERROR: M2 should not be an identity matrix"; if (M3.IsDiagonal()) os << "\r\nOKAY: M3 is diagonal"; else os << "\r\nERROR: M3 should be diagonal"; if (!M3.IsIdentity()) os << "\r\nOKAY: M3 is not an identity matrix"; else os << "\r\nERROR: M3 should not be an identity matrix"; if (!M4.IsDiagonal()) os << "\r\nOKAY: M4 is not diagonal"; else os << "\r\nERROR: M4 should not be diagonal"; if (!M4.IsIdentity()) os << "\r\nOKAY: M4 is not an identity matrix"; else os << "\r\nERROR: M4 should not be an identity matrix"; // tridiagonal tests M1 = tridi; os << "\r\n\r\nmatrix M1 = \r\n"; ShowMatrix(os,M1); if (M1.IsTridiagonal()) os << "\r\nOKAY: M1 is tridiagonal"; else os << "\r\nERROR: M1 should be tridiagonal"; if (!M4.IsTridiagonal()) os << "\r\nOKAY: M4 is not tridiagonal"; else os << "\r\nERROR: M1 should not be tridiagonal"; // upper triangular tests M1 = utri; os << "\r\n\r\nmatrix M1 = \r\n"; ShowMatrix(os,M1); if (M1.IsUpperTriangular()) os << "\r\nOKAY: M1 is upper-triangular"; else os << "\r\nERROR: M1 should be upper-triangular"; if (!M4.IsUpperTriangular()) os << "\r\nOKAY: M4 is not upper-triangular"; else os << "\r\nERROR: M4 should not be upper-triangular"; // lower triangular tests M1 = ltri; os << "\r\n\r\nmatrix M1 = \r\n"; ShowMatrix(os,M1); if (M1.IsLowerTriangular()) os << "\r\nOKAY: M1 is lower-triangular"; else os << "\r\nERROR: M1 should be lower-triangular"; if (!M4.IsLowerTriangular()) os << "\r\nOKAY: M4 is not lower-triangular"; else os << "\r\nERROR: M4 should not be lower-triangular"; // permutation tests M1 = perm; os << "\r\n\r\nmatrix M1 = \r\n"; ShowMatrix(os,M1); M2 = ident; os << "\r\n\r\nmatrix M2 = \r\n"; ShowMatrix(os,M2); if (M1.IsPermutation()) os << "\r\nOKAY: M1 is permutation matrix"; else os << "\r\nERROR: M1 should be permutation"; if (M2.IsPermutation()) os << "\r\nOKAY: M2 is permutation matrix"; else os << "\r\nERROR: M2 should be permutation"; if (!M4.IsPermutation()) os << "\r\nOKAY: M4 is not permutation"; else os << "\r\nERROR: M4 should not be permutation"; // check singularity function M1(0,1) = 0; os << "\r\n\r\nmatrix M1 = \r\n"; ShowMatrix(os,M1); if (M1.IsSingular()) os << "\r\nOKAY: M1 is singular"; else os << "\r\nERROR: M1 should be singular"; if (!M2.IsSingular()) os << "\r\nOKAY: M2 is not singular"; else os << "\r\nERROR: M2 should not be singular"; if (!M4.IsSingular()) os << "\r\nOKAY: M4 is not singular"; else os << "\r\nERROR: M4 should not be singular"; // change main window heading os <<endl <<"Matrix Tests (manipulations)" <<endl <<"============================" <<endl; // test minors and determinants os << "\r\n\r\nmatrix M4 = \r\n"; ShowMatrix(os,M4); os << "\r\nminor M4(1,1) = \r\n"; ShowMatrix(os,M4.Minor(1,1)); os << "\r\nminor M4(0,4) = \r\n"; ShowMatrix(os,M4.Minor(0,4)); Matrix<int> M5(2,2), M6(3,3); M5(0,0) = 1; M5(0,1) = 2; M5(1,0) = 3; M5(1,1) = 4; M6(0,0) = 1; M6(0,1) = 3; M6(0,2) = 2; M6(1,0) = 5; M6(1,1) = 4; M6(1,2) = 7; M6(2,0) = 6; M6(2,1) = 9; M6(2,2) = 8; M4 = det; Matrix<int> T4(5,5), T5(2,2), T6(3,3); T4 = M4.Transpose(); T5 = M5.Transpose(); T6 = M6.Transpose(); os << "\r\nmatrix M5 = \r\n"; ShowMatrix(os,M5); os << "\r\ndeterminant of M5 = " << M5.Determinant() << "\r\n"; os << "\r\nmatrix T5 = \r\n"; ShowMatrix(os,T5); os << "\r\ndeterminant of T5 = " << T5.Determinant() << "\r\n"; os << "\r\nmatrix M6 = \r\n"; ShowMatrix(os,M6); os << "\r\ndeterminant of M6 = " << M6.Determinant() << "\r\n"; os << "\r\nmatrix T6 = \r\n"; ShowMatrix(os,T6); os << "\r\ndeterminant of T6 = " << T6.Determinant() << "\r\n"; os << "\r\nmatrix M4 = \r\n"; ShowMatrix(os,M4); os << "\r\ndeterminant of M4 = " << M4.Determinant() << "\r\n"; os << "\r\nmatrix T4 = \r\n"; ShowMatrix(os,T4); os << "\r\ndeterminant of T4 = " << T4.Determinant() << "\r\n"; Matrix<int> R; os << "\r\nMatrix R (def. constr.) = \r\n"; ShowMatrix(os,R); R.Resize(10,10); os << "\r\nMatrix R (now 10x10) = \r\n"; ShowMatrix(os,R); // change main window heading os <<endl <<"Matrix Tests (double)" <<endl <<"=====================" <<endl; // check <double> Matrix os << "\r\nFLOATING POINT!"; Matrix<double> X(3,4), Y(4,3), Z(3,3); X(0,0) = 1.0; X(1,0) = 5.0; X(2,0) = 2.0; X(0,1) = 2.0; X(1,1) = 2.0; X(2,1) = 4.0; X(0,2) = 0.0; X(1,2) = 3.0; X(2,2) = 3.0; X(0,3) = 1.0; X(1,3) = 2.0; X(2,3) = 1.0; Y(0,0) = 0.0; Y(2,0) = 1.0; Y(0,1) = 1.0; Y(2,1) = 0.0; Y(0,2) = 2.0; Y(2,2) = 5.0; Y(1,0) = 1.0; Y(3,0) = 3.0; Y(1,1) = 3.0; Y(3,1) = 1.0; Y(1,2) = 2.0; Y(3,2) = 2.0; os << "\r\nMatrix X = \r\n"; ShowMatrix(os,X); os << "\r\nMatrix Y = \r\n"; ShowMatrix(os,Y); Z = X % Y; os << "\r\nMatrix Z (X % Y) = \r\n"; ShowMatrix(os,Z); // check transposition Matrix<double> tX; tX = X.Transpose(); os << "\r\nOriginal X =\r\n"; ShowMatrix(os,X); os << "\r\nTranspose X =\r\n"; ShowMatrix(os,tX); X(0,0) = 1; X(0,1) = 3; X(0,2) = -4; X(0,3) = 8; X(1,0) = 1; X(1,1) = 1; X(1,2) = -2; X(1,3) = 2; X(2,0) = -1; X(2,1) = -2; X(2,2) = 5; X(2,3) = -1; os << "\r\nOriginal X =\r\n"; ShowMatrix(os,X); Matrix<double> lX(X.LinSolve()); os << "\r\nX after elimination =\r\n"; ShowMatrix(os,X); os << "\r\nlinear equation solution =\r\n"; ShowMatrix(os,lX); X(0,0) = 1.0; X(1,0) = 3.0; X(2,0) = 5.0; X(0,1) = 2.0; X(1,1) = 5.0; X(2,1) = 6.0; X(0,2) = 0.0; X(1,2) = 4.0; X(2,2) = 3.0; X(0,3) = 0.1; X(1,3) = 12.5; X(2,3) = 10.3; os << "\r\nOriginal X =\r\n"; ShowMatrix(os,X); lX = X.LinSolve(); os << "\r\nX after elimination =\r\n"; ShowMatrix(os,X); os << "\r\nlinear equation solution =\r\n"; ShowMatrix(os,lX); Matrix<double> Adbl(3,3), Bdbl(3,1); Adbl(0,0) = 1.0; Adbl(0,1) = 2.0; Adbl(0,2) = 0.0; Adbl(1,0) = 3.0; Adbl(1,1) = 5.0; Adbl(1,2) = 4.0; Adbl(2,0) = 5.0; Adbl(2,1) = 6.0; Adbl(2,2) = 3.0; Bdbl(0,0) = 0.1; Bdbl(1,0) = 12.5; Bdbl(2,0) = 10.3; os << "\r\n\r\nmatrix Adbl = \r\n"; ShowMatrix(os,Adbl); os << "\r\nmatrix Bdbl = \r\n"; ShowMatrix(os,Bdbl); Matrix<double> alup(Adbl); // copy Adbl before LUP decomp os << "\r\nLU decomp of Adbl (before) = \r\n"; ShowMatrix(os,alup); Matrix<size_t> aperm = alup.LUPDecompose(); os << "\r\nLU decomp of Adbl (after) = \r\n"; ShowMatrix(os,alup); os << "\r\nPermutation of Adbl = \r\n"; ShowMatrix(os,aperm); Matrix<double> asol = alup.LUPSolve(aperm,Bdbl); os << "\r\nlinear solution of Adbl and Bdbl = \r\n"; ShowMatrix(os,asol); Matrix<double> ainv = alup.LUPInvert(aperm); os << "\r\ninverse of Adbl and Bdbl = \r\n"; ShowMatrix(os,ainv); Matrix<double> aid = Adbl % ainv; os << "\r\ninverse dot Adbl = \r\n"; ShowMatrix(os,aid); Grid<size_t> iperm = ainv.LUPDecompose(); Matrix<double> invinv = ainv.LUPInvert(iperm); os << "\r\ninverse of inverse =\r\n"; ShowMatrix(os,invinv); }
void main() //main code { //printing titles for values displayed printf("\nRUNGE-KUTTA METHOD\nstep size R M Last Rho iterations\n"); double i; //power order for rho(c) double c = 10; //the parameter rho(c) int n; //the integer steps, n //declare arrays float x[N]; float y[N]; float z[N]; float x2[N]; float y2[N]; float z2[N]; //r,m,p as the radius, mass and density double r,m,p,r2,m2,p2; for(i=-5;i<2;i++) { h = pow(10,i); //how h is varied by i c = 10; //the parameter rho(c) //declare initial conditons for arrays x[0] = h; //first array is for r=h y[0] = (h*h*h/3)*c; //initial conditon for scaled mass (m) z[0] = c*(1-((h*h*c)/(6*gamma(c)))); //initial conditon for rho //for loop for n=0,1,...,when z[n]>1 for(n=0;z[n]>1;n++) { //declared how x(n+1) relates to x(n), y(n+1) relates to y(n), z(n+1) relates to z(n) x[n+1] = x[n]+h; y[n+1] = y[n]+(h/6)*(M(x[n],y[n],z[n])+2*M2(x[n],y[n],z[n])+2*M3(x[n],y[n],z[n])+M4(x[n],y[n],z[n])); z[n+1] = z[n]+(h/6)*(rho(x[n],y[n],z[n])+2*rho2(x[n],y[n],z[n])+2*rho3(x[n],y[n],z[n])+rho4(x[n],y[n],z[n])); //r,m,p will be declared for printf statement r = x[n]; m = y[n]; p = z[n]; } //printed values for x and y respectively printf("%.2e %.2e %.2e %.2e %i\n",h,r,m,p,n); } //printing titles for values displayed printf("\nEULER METHOD\nstep size R M Last Rho iterations\n"); for(i=-5;i<2;i++) { h = pow(10,i); //how h is varied by i c = 10; //the parameter rho(c) //declare initial conditons for arrays x2[0] = h; //first array is for r=h y2[0] = (h*h*h/3)*c; //initial conditon for scaled mass (m) z2[0] = fabs(c*(1-((h*h*c)/(6*gamma(c))))); //initial conditon for rho //for loop for n=0,1,..., when z2[n]>1 for(n=0;z2[n]>1;n++) { //declared how x2(n+1) relates to x2(n), y2(n+1) relates to y2(n), z2(n+1) relates to z2(n) x2[n+1] = x2[n]+h; y2[n+1] = y2[n]+h*(M(x2[n],y2[n],z2[n])); z2[n+1] = z2[n]+h*(rho(x2[n],y2[n],z2[n])); //r2,m2,p2 will be declared in pg-plot r2 = x2[n]; m2 = y2[n]; p2 = z2[n]; } //printed values for x and y respectively printf("%.2e %.2e %.2e %.2e %i\n",h,r2,m2,p2,n); } }
void FastMatmulRecursive(LockAndCounter& locker, MemoryManager<Scalar>& mem_mngr, Matrix<Scalar>& A, Matrix<Scalar>& B, Matrix<Scalar>& C, int total_steps, int steps_left, int start_index, double x, int num_threads, Scalar beta) { // Update multipliers C.UpdateMultiplier(A.multiplier()); C.UpdateMultiplier(B.multiplier()); A.set_multiplier(Scalar(1.0)); B.set_multiplier(Scalar(1.0)); // Base case for recursion if (steps_left == 0) { MatMul(A, B, C); return; } Matrix<Scalar> A11 = A.Subblock(2, 2, 1, 1); Matrix<Scalar> A12 = A.Subblock(2, 2, 1, 2); Matrix<Scalar> A21 = A.Subblock(2, 2, 2, 1); Matrix<Scalar> A22 = A.Subblock(2, 2, 2, 2); Matrix<Scalar> B11 = B.Subblock(2, 2, 1, 1); Matrix<Scalar> B12 = B.Subblock(2, 2, 1, 2); Matrix<Scalar> B21 = B.Subblock(2, 2, 2, 1); Matrix<Scalar> B22 = B.Subblock(2, 2, 2, 2); Matrix<Scalar> C11 = C.Subblock(2, 2, 1, 1); Matrix<Scalar> C12 = C.Subblock(2, 2, 1, 2); Matrix<Scalar> C21 = C.Subblock(2, 2, 2, 1); Matrix<Scalar> C22 = C.Subblock(2, 2, 2, 2); // Matrices to store the results of multiplications. #ifdef _PARALLEL_ Matrix<Scalar> M1(mem_mngr.GetMem(start_index, 1, total_steps - steps_left, M), C11.m(), C11.m(), C11.n(), C.multiplier()); Matrix<Scalar> M2(mem_mngr.GetMem(start_index, 2, total_steps - steps_left, M), C11.m(), C11.m(), C11.n(), C.multiplier()); Matrix<Scalar> M3(mem_mngr.GetMem(start_index, 3, total_steps - steps_left, M), C11.m(), C11.m(), C11.n(), C.multiplier()); Matrix<Scalar> M4(mem_mngr.GetMem(start_index, 4, total_steps - steps_left, M), C11.m(), C11.m(), C11.n(), C.multiplier()); Matrix<Scalar> M5(mem_mngr.GetMem(start_index, 5, total_steps - steps_left, M), C11.m(), C11.m(), C11.n(), C.multiplier()); Matrix<Scalar> M6(mem_mngr.GetMem(start_index, 6, total_steps - steps_left, M), C11.m(), C11.m(), C11.n(), C.multiplier()); Matrix<Scalar> M7(mem_mngr.GetMem(start_index, 7, total_steps - steps_left, M), C11.m(), C11.m(), C11.n(), C.multiplier()); Matrix<Scalar> M8(mem_mngr.GetMem(start_index, 8, total_steps - steps_left, M), C11.m(), C11.m(), C11.n(), C.multiplier()); #else Matrix<Scalar> M1(C11.m(), C11.n(), C.multiplier()); Matrix<Scalar> M2(C11.m(), C11.n(), C.multiplier()); Matrix<Scalar> M3(C11.m(), C11.n(), C.multiplier()); Matrix<Scalar> M4(C11.m(), C11.n(), C.multiplier()); Matrix<Scalar> M5(C11.m(), C11.n(), C.multiplier()); Matrix<Scalar> M6(C11.m(), C11.n(), C.multiplier()); Matrix<Scalar> M7(C11.m(), C11.n(), C.multiplier()); Matrix<Scalar> M8(C11.m(), C11.n(), C.multiplier()); #endif #if defined(_PARALLEL_) && (_PARALLEL_ == _BFS_PAR_ || _PARALLEL_ == _HYBRID_PAR_) bool sequential1 = should_launch_task(8, total_steps, steps_left, start_index, 1, num_threads); bool sequential2 = should_launch_task(8, total_steps, steps_left, start_index, 2, num_threads); bool sequential3 = should_launch_task(8, total_steps, steps_left, start_index, 3, num_threads); bool sequential4 = should_launch_task(8, total_steps, steps_left, start_index, 4, num_threads); bool sequential5 = should_launch_task(8, total_steps, steps_left, start_index, 5, num_threads); bool sequential6 = should_launch_task(8, total_steps, steps_left, start_index, 6, num_threads); bool sequential7 = should_launch_task(8, total_steps, steps_left, start_index, 7, num_threads); bool sequential8 = should_launch_task(8, total_steps, steps_left, start_index, 8, num_threads); #else bool sequential1 = false; bool sequential2 = false; bool sequential3 = false; bool sequential4 = false; bool sequential5 = false; bool sequential6 = false; bool sequential7 = false; bool sequential8 = false; #endif // M1 = (1 * A11) * (1 * B11) #if defined(_PARALLEL_) && (_PARALLEL_ == _BFS_PAR_ || _PARALLEL_ == _HYBRID_PAR_) # pragma omp task if(sequential1) shared(mem_mngr, locker) untied { #endif M1.UpdateMultiplier(Scalar(1)); M1.UpdateMultiplier(Scalar(1)); FastMatmulRecursive(locker, mem_mngr, A11, B11, M1, total_steps, steps_left - 1, (start_index + 1 - 1) * 8, x, num_threads, Scalar(0.0)); #ifndef _PARALLEL_ #endif #if defined(_PARALLEL_) && (_PARALLEL_ == _BFS_PAR_ || _PARALLEL_ == _HYBRID_PAR_) locker.Decrement(); } if (should_task_wait(8, total_steps, steps_left, start_index, 1, num_threads)) { # pragma omp taskwait # if defined(_PARALLEL_) && (_PARALLEL_ == _HYBRID_PAR_) SwitchToDFS(locker, num_threads); # endif } #endif // M2 = (1 * A12) * (1 * B21) #if defined(_PARALLEL_) && (_PARALLEL_ == _BFS_PAR_ || _PARALLEL_ == _HYBRID_PAR_) # pragma omp task if(sequential2) shared(mem_mngr, locker) untied { #endif M2.UpdateMultiplier(Scalar(1)); M2.UpdateMultiplier(Scalar(1)); FastMatmulRecursive(locker, mem_mngr, A12, B21, M2, total_steps, steps_left - 1, (start_index + 2 - 1) * 8, x, num_threads, Scalar(0.0)); #ifndef _PARALLEL_ #endif #if defined(_PARALLEL_) && (_PARALLEL_ == _BFS_PAR_ || _PARALLEL_ == _HYBRID_PAR_) locker.Decrement(); } if (should_task_wait(8, total_steps, steps_left, start_index, 2, num_threads)) { # pragma omp taskwait # if defined(_PARALLEL_) && (_PARALLEL_ == _HYBRID_PAR_) SwitchToDFS(locker, num_threads); # endif } #endif // M3 = (1 * A11) * (1 * B12) #if defined(_PARALLEL_) && (_PARALLEL_ == _BFS_PAR_ || _PARALLEL_ == _HYBRID_PAR_) # pragma omp task if(sequential3) shared(mem_mngr, locker) untied { #endif M3.UpdateMultiplier(Scalar(1)); M3.UpdateMultiplier(Scalar(1)); FastMatmulRecursive(locker, mem_mngr, A11, B12, M3, total_steps, steps_left - 1, (start_index + 3 - 1) * 8, x, num_threads, Scalar(0.0)); #ifndef _PARALLEL_ #endif #if defined(_PARALLEL_) && (_PARALLEL_ == _BFS_PAR_ || _PARALLEL_ == _HYBRID_PAR_) locker.Decrement(); } if (should_task_wait(8, total_steps, steps_left, start_index, 3, num_threads)) { # pragma omp taskwait # if defined(_PARALLEL_) && (_PARALLEL_ == _HYBRID_PAR_) SwitchToDFS(locker, num_threads); # endif } #endif // M4 = (1 * A12) * (1 * B22) #if defined(_PARALLEL_) && (_PARALLEL_ == _BFS_PAR_ || _PARALLEL_ == _HYBRID_PAR_) # pragma omp task if(sequential4) shared(mem_mngr, locker) untied { #endif M4.UpdateMultiplier(Scalar(1)); M4.UpdateMultiplier(Scalar(1)); FastMatmulRecursive(locker, mem_mngr, A12, B22, M4, total_steps, steps_left - 1, (start_index + 4 - 1) * 8, x, num_threads, Scalar(0.0)); #ifndef _PARALLEL_ #endif #if defined(_PARALLEL_) && (_PARALLEL_ == _BFS_PAR_ || _PARALLEL_ == _HYBRID_PAR_) locker.Decrement(); } if (should_task_wait(8, total_steps, steps_left, start_index, 4, num_threads)) { # pragma omp taskwait # if defined(_PARALLEL_) && (_PARALLEL_ == _HYBRID_PAR_) SwitchToDFS(locker, num_threads); # endif } #endif // M5 = (1 * A21) * (1 * B11) #if defined(_PARALLEL_) && (_PARALLEL_ == _BFS_PAR_ || _PARALLEL_ == _HYBRID_PAR_) # pragma omp task if(sequential5) shared(mem_mngr, locker) untied { #endif M5.UpdateMultiplier(Scalar(1)); M5.UpdateMultiplier(Scalar(1)); FastMatmulRecursive(locker, mem_mngr, A21, B11, M5, total_steps, steps_left - 1, (start_index + 5 - 1) * 8, x, num_threads, Scalar(0.0)); #ifndef _PARALLEL_ #endif #if defined(_PARALLEL_) && (_PARALLEL_ == _BFS_PAR_ || _PARALLEL_ == _HYBRID_PAR_) locker.Decrement(); } if (should_task_wait(8, total_steps, steps_left, start_index, 5, num_threads)) { # pragma omp taskwait # if defined(_PARALLEL_) && (_PARALLEL_ == _HYBRID_PAR_) SwitchToDFS(locker, num_threads); # endif } #endif // M6 = (1 * A22) * (1 * B21) #if defined(_PARALLEL_) && (_PARALLEL_ == _BFS_PAR_ || _PARALLEL_ == _HYBRID_PAR_) # pragma omp task if(sequential6) shared(mem_mngr, locker) untied { #endif M6.UpdateMultiplier(Scalar(1)); M6.UpdateMultiplier(Scalar(1)); FastMatmulRecursive(locker, mem_mngr, A22, B21, M6, total_steps, steps_left - 1, (start_index + 6 - 1) * 8, x, num_threads, Scalar(0.0)); #ifndef _PARALLEL_ #endif #if defined(_PARALLEL_) && (_PARALLEL_ == _BFS_PAR_ || _PARALLEL_ == _HYBRID_PAR_) locker.Decrement(); } if (should_task_wait(8, total_steps, steps_left, start_index, 6, num_threads)) { # pragma omp taskwait # if defined(_PARALLEL_) && (_PARALLEL_ == _HYBRID_PAR_) SwitchToDFS(locker, num_threads); # endif } #endif // M7 = (1 * A21) * (1 * B12) #if defined(_PARALLEL_) && (_PARALLEL_ == _BFS_PAR_ || _PARALLEL_ == _HYBRID_PAR_) # pragma omp task if(sequential7) shared(mem_mngr, locker) untied { #endif M7.UpdateMultiplier(Scalar(1)); M7.UpdateMultiplier(Scalar(1)); FastMatmulRecursive(locker, mem_mngr, A21, B12, M7, total_steps, steps_left - 1, (start_index + 7 - 1) * 8, x, num_threads, Scalar(0.0)); #ifndef _PARALLEL_ #endif #if defined(_PARALLEL_) && (_PARALLEL_ == _BFS_PAR_ || _PARALLEL_ == _HYBRID_PAR_) locker.Decrement(); } if (should_task_wait(8, total_steps, steps_left, start_index, 7, num_threads)) { # pragma omp taskwait # if defined(_PARALLEL_) && (_PARALLEL_ == _HYBRID_PAR_) SwitchToDFS(locker, num_threads); # endif } #endif // M8 = (1 * A22) * (1 * B22) #if defined(_PARALLEL_) && (_PARALLEL_ == _BFS_PAR_ || _PARALLEL_ == _HYBRID_PAR_) # pragma omp task if(sequential8) shared(mem_mngr, locker) untied { #endif M8.UpdateMultiplier(Scalar(1)); M8.UpdateMultiplier(Scalar(1)); FastMatmulRecursive(locker, mem_mngr, A22, B22, M8, total_steps, steps_left - 1, (start_index + 8 - 1) * 8, x, num_threads, Scalar(0.0)); #ifndef _PARALLEL_ #endif #if defined(_PARALLEL_) && (_PARALLEL_ == _BFS_PAR_ || _PARALLEL_ == _HYBRID_PAR_) locker.Decrement(); } if (should_task_wait(8, total_steps, steps_left, start_index, 8, num_threads)) { # pragma omp taskwait } #endif M_Add1(M1, M2, C11, x, false, beta); M_Add2(M3, M4, C12, x, false, beta); M_Add3(M5, M6, C21, x, false, beta); M_Add4(M7, M8, C22, x, false, beta); // Handle edge cases with dynamic peeling #if defined(_PARALLEL_) && (_PARALLEL_ == _BFS_PAR_ || _PARALLEL_ == _HYBRID_PAR_) if (total_steps == steps_left) { mkl_set_num_threads_local(num_threads); mkl_set_dynamic(0); } #endif DynamicPeeling(A, B, C, 2, 2, 2, beta); }
int multiple_detector_fit() { std::cout << "Beginning : ... " << std::endl; Int_t npoints = 1000; Double_t emin = 0.2; Double_t emax = 3.0; bool use100m = true; bool use470m = true; bool use600m = true; std::vector<int> baselines; std::vector<double> scales; std::vector<std::string> names; std::vector<double> volume; if (use100m) baselines.push_back(100); if (use470m) baselines.push_back(470); if (use600m) baselines.push_back(600); double NULLVec[2][20]; double OscVec[2][1001][7][20]; for(int i = 0; i < 20; i++){ NULLVec[0][i] = 0; NULLVec[1][i] = 0; } for(int u = 0; u < 1000; u++){ for(int s = 0; s < 7; s++){ for(int i = 0; i < 20; i++){ OscVec[0][u][s][i] = 0; OscVec[1][u][s][i] = 0; } } } int nbinsE = 0; if (use100m){ std::string temp_name = /*"../MatrixFiles/combined_ntuple_100m_nu_processed_numu.root";*/"../MatrixFiles/combined_ntuple_100m_nu_processed_CoreyBins_numu.root"; TFile temp_file(temp_name.c_str()); TH1D *NULL_100; NULL_100 = (TH1D*)(temp_file.Get("NumuCC")); nbinsE = NULL_100->GetNbinsX(); std::cout << nbinsE << std::endl; for(int i = 1; i <= nbinsE; i++){ NULLVec[0][i-1] = (NULL_100->GetBinContent(i)); } for(int u = 0; u < npoints; u++){ for(int s = 0; s < 7; s++){ TH1D *OSC_100; TString upoint = Form("%d",u); TString name = "Universe_"; TString name2 = "_MultiSim_"; TString mul = Form("%d",s); name += upoint; name += name2; name += mul; OSC_100 = (TH1D*)(temp_file.Get(name)); for(int i = 1; i <= nbinsE; i++){ OscVec[0][u][s][i-1] = (OSC_100->GetBinContent(i)); // if(OscVec[0][u][s][i-1] != OscVec[0][u][s][i-1]) std::cout << "erm" <<std::endl; } delete OSC_100; } } delete NULL_100; temp_file.Close(); } if (use470m){ std::string temp_name = /*"../MatrixFiles/combined_ntuple_600m_onaxis_nu_processed_numu.root";*/"../MatrixFiles/combined_ntuple_600m_onaxis_nu_processed_CoreyBins_numu.root"; TFile temp_file(temp_name.c_str()); TH1D *NULL_470; NULL_470 = (TH1D*)(temp_file.Get("NumuCC")); nbinsE = NULL_470->GetNbinsX(); std::cout << nbinsE<< std::endl; for(int i = 1; i <= nbinsE; i++){ NULLVec[1][i-1] = (NULL_470->GetBinContent(i)); } for(int u = 0; u < npoints; u++){ for(int s = 0; s < 7; s++){ TH1D *OSC_470; TString upoint = Form("%d",u);//std::to_string(u); TString name = "Universe_"; TString name2 = "_MultiSim_"; TString mul = Form("%d",s);// = std::to_string(s); name += upoint; name += name2; name += mul; OSC_470 = (TH1D*)(temp_file.Get(name)); for(int i = 1; i <= nbinsE; i++){ OscVec[1][u][s][i-1] = (OSC_470->GetBinContent(i)); if(OscVec[1][u][s][i-1] != OscVec[1][u][s][i-1]) OscVec[1][u][s][i-1] = NULLVec[1][i-1];//std::cout << "erm, u :" << u << " s : " << s << " E : " << i <<std::endl; } delete OSC_470; } } delete NULL_470; temp_file.Close(); } int nL = 2; int mbins = (nbinsE*nL); TMatrix M6 (mbins,mbins); TMatrix M5 (mbins,mbins); TMatrix M4 (mbins,mbins); TMatrix M3 (mbins,mbins); TMatrix M2 (mbins,mbins); TMatrix M1 (mbins,mbins); TMatrix M0 (mbins,mbins); TMatrix C6 (mbins,mbins); TMatrix C5 (mbins,mbins); TMatrix C4 (mbins,mbins); TMatrix C3 (mbins,mbins); TMatrix C2 (mbins,mbins); TMatrix C1 (mbins,mbins); TMatrix C0 (mbins,mbins); int N = 0; TH1D *Fig6 = new TH1D("Fig6",";;",mbins,0,mbins); TH1D *Fig5 = new TH1D("Fig5",";;",mbins,0,mbins); TH1D *Fig4 = new TH1D("Fig4",";;",mbins,0,mbins); TH1D *Fig3 = new TH1D("Fig3",";;",mbins,0,mbins); TH1D *Fig2 = new TH1D("Fig2",";;",mbins,0,mbins); TH1D *Fig1 = new TH1D("Fig1",";;",mbins,0,mbins); TH1D *Fig0 = new TH1D("Fig0",";;",mbins,0,mbins); int Erri = 0, Errj = 0; std::cout << "Filling Error Matrix..." << std::endl; for(int Lrow = 0; Lrow < 2; Lrow++){ for(int Erow = 0; Erow < nbinsE; Erow++){ Errj = 0; for(int Lcol = 0; Lcol < 2; Lcol++){ for(int Ecol = 0; Ecol < nbinsE; Ecol++){ M6 (Erri,Errj) = 0; M5 (Erri,Errj) = 0; M4 (Erri,Errj) = 0; M3 (Erri,Errj) = 0; M2 (Erri,Errj) = 0; M1 (Erri,Errj) = 0; M0 (Erri,Errj) = 0; N = 0; for(int u = 0; u < npoints; u++){ M6 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][6][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][6][Ecol]); M5 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][5][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][5][Ecol]); M4 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][4][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][4][Ecol]); M3 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][3][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][3][Ecol]); M2 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][2][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][2][Ecol]); M1 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][1][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][1][Ecol]); M0 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][0][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][0][Ecol]); N++; } M6 (Erri,Errj) /= N; M5 (Erri,Errj) /= N; M4 (Erri,Errj) /= N; M3 (Erri,Errj) /= N; M2 (Erri,Errj) /= N; M1 (Erri,Errj) /= N; M0 (Erri,Errj) /= N; M6 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M5 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M4 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M3 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M2 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M1 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M0 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; if(Erri == Errj) Fig6->SetBinContent(Erri+1, sqrt(M6 (Erri,Errj))); if(Erri == Errj) Fig5->SetBinContent(Erri+1, sqrt(M5 (Erri,Errj))); if(Erri == Errj) Fig4->SetBinContent(Erri+1, sqrt(M4 (Erri,Errj))); if(Erri == Errj) Fig3->SetBinContent(Erri+1, sqrt(M3 (Erri,Errj))); if(Erri == Errj) Fig2->SetBinContent(Erri+1, sqrt(M2 (Erri,Errj))); if(Erri == Errj) Fig1->SetBinContent(Erri+1, sqrt(M1 (Erri,Errj))); if(Erri == Errj) Fig0->SetBinContent(Erri+1, sqrt(M0 (Erri,Errj))); std::cout << M6 (Erri,Errj) << "\t"; Errj++; }} Erri++; }} for(int i = 0; i < Erri; i++){ for(int j = 0; j < Errj; j++){ C6 (i,j) = M6(i,j) / sqrt(M6 (i,i) * M6 (j,j)); C5 (i,j) = M5(i,j) / sqrt(M5 (i,i) * M5 (j,j)); C4 (i,j) = M4(i,j) / sqrt(M4 (i,i) * M4 (j,j)); C3 (i,j) = M3(i,j) / sqrt(M3 (i,i) * M3 (j,j)); C2 (i,j) = M2(i,j) / sqrt(M2 (i,i) * M2 (j,j)); C1 (i,j) = M1(i,j) / sqrt(M1 (i,i) * M1 (j,j)); C0 (i,j) = M0(i,j) / sqrt(M0 (i,i) * M0 (j,j)); } } std::cout << "...Error Matrix Filled" << std::endl; TCanvas* c6 = new TCanvas("c6","",700,700); c6->SetLeftMargin(.1); c6->SetBottomMargin(.1); c6->SetTopMargin(.075); c6->SetRightMargin(.15); c6->cd(); M6.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); // TMatrixFBase->GetZaxis()->SetRangeUser(-0.05,0.4); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("Fractional Error Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *ND = new TLatex(.15,.01,"LAr1-ND (100m) "); ND->SetNDC(); ND->SetTextFont(62); ND->SetTextSize(0.04); ND->Draw(); TLatex *MD = new TLatex(.5,.01,"T600 (600m, on axis)"); MD->SetNDC(); MD->SetTextFont(62); MD->SetTextSize(0.04); MD->Draw(); TLatex *ND45 = new TLatex(.05,.15,"LAr1-ND (100m) "); ND45->SetNDC(); ND45->SetTextAngle(90); ND45->SetTextFont(62); ND45->SetTextSize(0.04); ND45->Draw(); TLatex *MD45 = new TLatex(.05,.54,"T600 (600m, on axis)"); MD45->SetNDC(); MD45->SetTextAngle(90); MD45->SetTextFont(62); MD45->SetTextSize(0.04); MD45->Draw(); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Flux Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); // c6->Print("total_matrix.pdf"); TCanvas* c61 = new TCanvas("c61","",700,700); c61->SetLeftMargin(.1); c61->SetBottomMargin(.1); c61->SetTopMargin(.075); c61->SetRightMargin(.15); c61->cd(); C6.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Flux Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); // c61->Print("total_correlation_matrix.pdf"); TCanvas* c5 = new TCanvas("c5","",700,700); c5->SetLeftMargin(.1); c5->SetBottomMargin(.1); c5->SetTopMargin(.075); c5->SetRightMargin(.15); c5->cd(); M5.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("K^{+} Covariance Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{+} Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c5->Print("mult5_matrix.pdf"); TCanvas* c51 = new TCanvas("c51","",700,700); c51->SetLeftMargin(.1); c51->SetBottomMargin(.1); c51->SetTopMargin(.075); c51->SetRightMargin(.15); c51->cd(); C5.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{+} Correlation Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{+} Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c51->Print("mult5_correlation_matrix.pdf"); TCanvas* c4 = new TCanvas("c4","",700,700); c4->SetLeftMargin(.1); c4->SetBottomMargin(.1); c4->SetTopMargin(.075); c4->SetRightMargin(.15); c4->cd(); M4.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); //TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{-} Covariance Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{-} Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c4->Print("mult4_matrix.pdf"); TCanvas* c41 = new TCanvas("c41","",700,700); c41->SetLeftMargin(.1); c41->SetBottomMargin(.1); c41->SetTopMargin(.075); c41->SetRightMargin(.15); c41->cd(); C4.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{-} Correlation Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{-} Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c41->Print("mult4_correlation_matrix.pdf"); TCanvas* c3 = new TCanvas("c3","",700,700); c3->SetLeftMargin(.1); c3->SetBottomMargin(.1); c3->SetTopMargin(.075); c3->SetRightMargin(.15); c3->cd(); M3.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); //TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{0} Covariance Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{0} Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c3->Print("mult3_matrix.pdf"); TCanvas* c31 = new TCanvas("c31","",700,700); c31->SetLeftMargin(.1); c31->SetBottomMargin(.1); c31->SetTopMargin(.075); c31->SetRightMargin(.15); c31->cd(); C3.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); //TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{0} Correlation Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{0} Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c31->Print("mult3_correlation_matrix.pdf"); TCanvas* c2 = new TCanvas("c2","",700,700); c2->SetLeftMargin(.1); c2->SetBottomMargin(.1); c2->SetTopMargin(.075); c2->SetRightMargin(.15); c2->cd(); M2.Draw("COLZ"); gStyle->SetPalette(56,0); //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045); TMatrixFBase->SetContour(999); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); //TMatrixFBase->GetZaxis()->SetTitle("#pi#lower[-0.15]{+} Covariance Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} #pi#lower[-0.15]{+} Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c2->Print("mult2_matrix.pdf"); TCanvas* c21 = new TCanvas("c21","",700,700); c21->SetLeftMargin(.1); c21->SetBottomMargin(.1); c21->SetTopMargin(.075); c21->SetRightMargin(.15); c21->cd(); C2.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); //TMatrixFBase->GetZaxis()->SetTitle("#pi#lower[-0.15]{+} Correlation Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} #pi#lower[-0.15]{+} Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c21->Print("mult2_correlation_matrix.pdf"); TCanvas* c1 = new TCanvas("c1","",700,700); c1->SetLeftMargin(.1); c1->SetBottomMargin(.1); c1->SetTopMargin(.075); c1->SetRightMargin(.15); c1->cd(); M1.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); //TMatrixFBase->GetZaxis()->SetTitle("#pi#lower[-0.15]{-} Covariance Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} #pi#lower[-0.15]{-} Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c1->Print("mult1_matrix.pdf"); TCanvas* c11 = new TCanvas("c11","",700,700); c11->SetLeftMargin(.1); c11->SetBottomMargin(.1); c11->SetTopMargin(.075); c11->SetRightMargin(.15); c11->cd(); C1.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("#pi#lower[-0.15]{-} Correlation Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} #pi#lower[-0.15]{-} Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c11->Print("mult1_correlation_matrix.pdf"); TCanvas* c0 = new TCanvas("c0","",700,700); c0->SetLeftMargin(.1); c0->SetBottomMargin(.1); c0->SetTopMargin(.075); c0->SetRightMargin(.15); c0->cd(); M0.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("Beam UniSim Covariance Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Beam Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c0->Print("mult0_matrix.pdf"); TCanvas* c01 = new TCanvas("c01","",700,700); c01->SetLeftMargin(.1); c01->SetBottomMargin(.1); c01->SetTopMargin(.075); c01->SetRightMargin(.15); c01->cd(); C0.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("Beam UniSim Correlation Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Beam Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c01->Print("mult0_correlation_matrix.pdf"); TCanvas* c86 = new TCanvas("c86","",800,400); c86->SetLeftMargin(.1); c86->SetBottomMargin(.1); c86->SetTopMargin(.05); c86->SetRightMargin(.05); c86->cd(); Fig6->GetYaxis()->SetTitle("Fractional Error"); Fig6->GetYaxis()->SetTitleFont(62); Fig6->GetXaxis()->SetTitleFont(62); Fig6->GetYaxis()->SetLabelFont(62); Fig6->GetXaxis()->SetLabelFont(62); Fig6->GetYaxis()->CenterTitle(); Fig6->GetYaxis()->SetTitleSize(0.06); Fig6->GetYaxis()->SetTitleOffset(0.8); Fig6->GetXaxis()->SetLabelSize(0.06); Fig6->GetYaxis()->SetLabelSize(0.06); Fig6->GetXaxis()->SetTitleOffset(1.5); Fig6->SetStats(0); Fig6->SetMinimum(-0.01); Fig6->SetMaximum(0.21); Fig6->SetMarkerStyle(8); Fig6->GetYaxis()->SetNdivisions(509); Fig6->GetXaxis()->SetNdivisions(509); Fig6->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); TLatex *ND = new TLatex(.23,.85,"LAr1-ND (100m) "); ND->SetNDC(); ND->SetTextFont(62); ND->SetTextSize(0.05); ND->Draw(); TLatex *MD = new TLatex(.65,.85,"T600 (600m, on axis)"); MD->SetNDC(); MD->SetTextFont(62); MD->SetTextSize(0.05); MD->Draw(); // c86->Print("FractionalErrors_Total.pdf"); TCanvas* c85 = new TCanvas("c85","",800,400); c85->SetLeftMargin(.1); c85->SetBottomMargin(.1); c85->SetTopMargin(.05); c85->SetRightMargin(.05); c85->cd(); Fig5->GetYaxis()->SetTitle("K#lower[-0.2]{+} Fractional Error"); Fig5->GetYaxis()->SetTitleFont(62); Fig5->GetXaxis()->SetTitleFont(62); Fig5->GetYaxis()->SetLabelFont(62); Fig5->GetXaxis()->SetLabelFont(62); Fig5->GetYaxis()->CenterTitle(); Fig5->GetYaxis()->SetTitleSize(0.06); Fig5->GetYaxis()->SetTitleOffset(0.8); Fig5->GetXaxis()->SetLabelSize(0.06); Fig5->GetYaxis()->SetLabelSize(0.06); Fig5->GetXaxis()->SetTitleOffset(1.5); Fig5->SetStats(0); Fig5->SetMinimum(-0.01); Fig5->SetMaximum(0.21); Fig5->SetMarkerStyle(8); Fig5->GetYaxis()->SetNdivisions(509); Fig5->GetXaxis()->SetNdivisions(509); Fig5->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); ND->Draw(); MD->Draw(); // c85->Print("FractionalErrors_Kplus.pdf"); TCanvas* c84 = new TCanvas("c84","",800,400); c84->SetLeftMargin(.1); c84->SetBottomMargin(.1); c84->SetTopMargin(.05); c84->SetRightMargin(.05); c84->cd(); Fig4->GetYaxis()->SetTitle("K#lower[-0.2]{-} Fractional Error"); Fig4->GetYaxis()->SetTitleFont(62); Fig4->GetXaxis()->SetTitleFont(62); Fig4->GetYaxis()->SetLabelFont(62); Fig4->GetXaxis()->SetLabelFont(62); Fig4->GetYaxis()->CenterTitle(); Fig4->GetYaxis()->SetTitleSize(0.06); Fig4->GetYaxis()->SetTitleOffset(0.8); Fig4->GetXaxis()->SetLabelSize(0.06); Fig4->GetYaxis()->SetLabelSize(0.06); Fig4->GetXaxis()->SetTitleOffset(1.5); Fig4->SetStats(0); Fig4->SetMinimum(-0.01); Fig4->SetMaximum(0.21); Fig4->SetMarkerStyle(8); Fig4->GetYaxis()->SetNdivisions(509); Fig4->GetXaxis()->SetNdivisions(509); Fig4->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); ND->Draw(); MD->Draw(); // c84->Print("FractionalErrors_Kmin.pdf"); TCanvas* c83 = new TCanvas("c83","",800,400); c83->SetLeftMargin(.1); c83->SetBottomMargin(.1); c83->SetTopMargin(.05); c83->SetRightMargin(.05); c83->cd(); Fig3->GetYaxis()->SetTitle("K#lower[-0.2]{0} Fractional Error"); Fig3->GetYaxis()->SetTitleFont(62); Fig3->GetXaxis()->SetTitleFont(62); Fig3->GetYaxis()->SetLabelFont(62); Fig3->GetXaxis()->SetLabelFont(62); Fig3->GetYaxis()->CenterTitle(); Fig3->GetYaxis()->SetTitleSize(0.06); Fig3->GetYaxis()->SetTitleOffset(0.8); Fig3->GetXaxis()->SetLabelSize(0.06); Fig3->GetYaxis()->SetLabelSize(0.06); Fig3->GetXaxis()->SetTitleOffset(1.5); Fig3->SetStats(0); Fig3->SetMinimum(-0.01); Fig3->SetMaximum(0.21); Fig3->SetMarkerStyle(8); Fig3->GetYaxis()->SetNdivisions(509); Fig3->GetXaxis()->SetNdivisions(509); Fig3->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); ND->Draw(); MD->Draw(); // c83->Print("FractionalErrors_K0.pdf"); TCanvas* c82 = new TCanvas("c82","",800,400); c82->SetLeftMargin(.1); c82->SetBottomMargin(.1); c82->SetTopMargin(.05); c82->SetRightMargin(.05); c82->cd(); Fig2->GetYaxis()->SetTitle("#pi#lower[-0.2]{+} Fractional Error"); Fig2->GetYaxis()->SetTitleFont(62); Fig2->GetXaxis()->SetTitleFont(62); Fig2->GetYaxis()->SetLabelFont(62); Fig2->GetXaxis()->SetLabelFont(62); Fig2->GetYaxis()->CenterTitle(); Fig2->GetYaxis()->SetTitleSize(0.06); Fig2->GetYaxis()->SetTitleOffset(0.8); Fig2->GetXaxis()->SetLabelSize(0.06); Fig2->GetYaxis()->SetLabelSize(0.06); Fig2->GetXaxis()->SetTitleOffset(1.5); Fig2->SetStats(0); Fig2->SetMinimum(-0.01); Fig2->SetMaximum(0.21); Fig2->SetMarkerStyle(8); Fig2->GetYaxis()->SetNdivisions(509); Fig2->GetXaxis()->SetNdivisions(509); Fig2->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); ND->Draw(); MD->Draw(); // c82->Print("FractionalErrors_piplus.pdf"); TCanvas* c81 = new TCanvas("c81","",800,400); c81->SetLeftMargin(.1); c81->SetBottomMargin(.1); c81->SetTopMargin(.05); c81->SetRightMargin(.05); c81->cd(); Fig1->GetYaxis()->SetTitle("#pi#lower[-0.2]{-} Fractional Error"); Fig1->GetYaxis()->SetTitleFont(62); Fig1->GetXaxis()->SetTitleFont(62); Fig1->GetYaxis()->SetLabelFont(62); Fig1->GetXaxis()->SetLabelFont(62); Fig1->GetYaxis()->CenterTitle(); Fig1->GetYaxis()->SetTitleSize(0.06); Fig1->GetYaxis()->SetTitleOffset(0.8); Fig1->GetXaxis()->SetLabelSize(0.06); Fig1->GetYaxis()->SetLabelSize(0.06); Fig1->GetXaxis()->SetTitleOffset(1.5); Fig1->SetStats(0); Fig1->SetMinimum(-0.01); Fig1->SetMaximum(0.21); Fig1->SetMarkerStyle(8); Fig1->GetYaxis()->SetNdivisions(509); Fig1->GetXaxis()->SetNdivisions(509); Fig1->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); ND->Draw(); MD->Draw(); // c81->Print("FractionalErrors_pimin.pdf"); TCanvas* c80 = new TCanvas("c80","",800,400); c80->SetLeftMargin(.1); c80->SetBottomMargin(.1); c80->SetTopMargin(.05); c80->SetRightMargin(.05); c80->cd(); Fig0->GetYaxis()->SetTitle("Beam Fractional Error"); Fig0->GetYaxis()->SetTitleFont(62); Fig0->GetXaxis()->SetTitleFont(62); Fig0->GetYaxis()->SetLabelFont(62); Fig0->GetXaxis()->SetLabelFont(62); Fig0->GetYaxis()->CenterTitle(); Fig0->GetYaxis()->SetTitleSize(0.06); Fig0->GetYaxis()->SetTitleOffset(0.8); Fig0->GetXaxis()->SetLabelSize(0.06); Fig0->GetYaxis()->SetLabelSize(0.06); Fig0->GetXaxis()->SetTitleOffset(1.5); Fig0->SetStats(0); Fig0->SetMinimum(-0.01); Fig0->SetMaximum(0.21); Fig0->SetMarkerStyle(8); Fig0->GetYaxis()->SetNdivisions(509); Fig0->GetXaxis()->SetNdivisions(509); Fig0->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); ND->Draw(); MD->Draw(); // c80->Print("FractionalErrors_beam.pdf"); cout<<"\nEnd of routine.\n"; return 0; }
int multiple_detector_fit() { std::cout << "Beginning : ... " << std::endl; Int_t npoints = 1000; Double_t emin = 0.2; Double_t emax = 3.0; bool use100m = false; bool use470m = true; bool use600m = false; std::vector<int> baselines; std::vector<double> scales; std::vector<std::string> names; std::vector<double> volume; if (use100m) baselines.push_back(100); if (use470m) baselines.push_back(470); if (use600m) baselines.push_back(600); int nL = baselines.size(); double NULLVec[3][20]; double OscVec[3][1001][7][20]; for(int i = 0; i < 20; i++){ NULLVec[0][i] = 0; NULLVec[1][i] = 0; NULLVec[2][i] = 0; } for(int u = 0; u < 1000; u++){ for(int s = 0; s < 7; s++){ for(int i = 0; i < 20; i++){ OscVec[0][u][s][i] = 0; OscVec[1][u][s][i] = 0; OscVec[2][u][s][i] = 0; } } } int nbinsE = 0; int counter = 0; if (use100m){ std::string temp_name = "../MatrixFiles/combined_ntuple_100m_nu_processed_numu.root"; TFile temp_file(temp_name.c_str()); TH1D *NULL_100; NULL_100 = (TH1D*)(temp_file.Get("NumuCC")); nbinsE = NULL_100->GetNbinsX(); std::cout << nbinsE << std::endl; for(int i = 1; i <= nbinsE; i++){ NULLVec[counter][i-1] = (NULL_100->GetBinContent(i)); } for(int u = 0; u < npoints; u++){ for(int s = 0; s < 7; s++){ TH1D *OSC_100; TString upoint = Form("%d",u); TString name = "Universe_"; TString name2 = "_MultiSim_"; TString mul = Form("%d",s); name += upoint; name += name2; name += mul; OSC_100 = (TH1D*)(temp_file.Get(name)); for(int i = 1; i <= nbinsE; i++){ OscVec[counter][u][s][i-1] = (OSC_100->GetBinContent(i)); // if(OscVec[0][u][s][i-1] != OscVec[0][u][s][i-1]) std::cout << "erm" <<std::endl; } delete OSC_100; } } counter++; delete NULL_100; temp_file.Close(); } if (use470m){ std::string temp_name = "../MatrixFiles/combined_ntuple_470m_nu_processed_numu.root"; TFile temp_file(temp_name.c_str()); TH1D *NULL_470; NULL_470 = (TH1D*)(temp_file.Get("NumuCC")); nbinsE = NULL_470->GetNbinsX(); std::cout << nbinsE<< std::endl; for(int i = 1; i <= nbinsE; i++){ NULLVec[counter][i-1] = (NULL_470->GetBinContent(i)); } for(int u = 0; u < npoints; u++){ for(int s = 0; s < 7; s++){ TH1D *OSC_470; TString upoint = Form("%d",u);//std::to_string(u); TString name = "Universe_"; TString name2 = "_MultiSim_"; TString mul = Form("%d",s);// = std::to_string(s); name += upoint; name += name2; name += mul; OSC_470 = (TH1D*)(temp_file.Get(name)); for(int i = 1; i <= nbinsE; i++){ OscVec[counter][u][s][i-1] = (OSC_470->GetBinContent(i)); } delete OSC_470; } } counter++; delete NULL_470; temp_file.Close(); } if (use600m){ std::string temp_name = "../MatrixFiles/combined_ntuple_600m_onaxis_nu_processed_numu.root"; TFile temp_file(temp_name.c_str()); TH1D *NULL_600; NULL_600 = (TH1D*)(temp_file.Get("NumuCC")); nbinsE = NULL_600->GetNbinsX(); std::cout << nbinsE<< std::endl; for(int i = 1; i <= nbinsE; i++){ NULLVec[counter][i-1] = (NULL_600->GetBinContent(i)); } for(int u = 0; u < npoints; u++){ for(int s = 0; s < 7; s++){ TH1D *OSC_600; TString upoint = Form("%d",u);//std::to_string(u); TString name = "Universe_"; TString name2 = "_MultiSim_"; TString mul = Form("%d",s);// = std::to_string(s); name += upoint; name += name2; name += mul; OSC_600 = (TH1D*)(temp_file.Get(name)); for(int i = 1; i <= nbinsE; i++){ OscVec[counter][u][s][i-1] = (OSC_600->GetBinContent(i)); } delete OSC_600; } } counter++; delete NULL_600; temp_file.Close(); } // int nL = 3; int mbins = (nbinsE*nL); TMatrix M6 (mbins,mbins); TMatrix M5 (mbins,mbins); TMatrix M4 (mbins,mbins); TMatrix M3 (mbins,mbins); TMatrix M2 (mbins,mbins); TMatrix M1 (mbins,mbins); TMatrix M0 (mbins,mbins); TMatrix C6 (mbins,mbins); TMatrix C5 (mbins,mbins); TMatrix C4 (mbins,mbins); TMatrix C3 (mbins,mbins); TMatrix C2 (mbins,mbins); TMatrix C1 (mbins,mbins); TMatrix C0 (mbins,mbins); int N = 0; TH1D *Fig6 = new TH1D("Fig6",";;",mbins,0,mbins); TH1D *Fig5 = new TH1D("Fig5",";;",mbins,0,mbins); TH1D *Fig4 = new TH1D("Fig4",";;",mbins,0,mbins); TH1D *Fig3 = new TH1D("Fig3",";;",mbins,0,mbins); TH1D *Fig2 = new TH1D("Fig2",";;",mbins,0,mbins); TH1D *Fig1 = new TH1D("Fig1",";;",mbins,0,mbins); TH1D *Fig0 = new TH1D("Fig0",";;",mbins,0,mbins); int Erri = 0, Errj = 0; std::cout << "Filling Error Matrix..." << std::endl; for(int Lrow = 0; Lrow < nL; Lrow++){ for(int Erow = 0; Erow < nbinsE; Erow++){ Errj = 0; for(int Lcol = 0; Lcol < nL; Lcol++){ for(int Ecol = 0; Ecol < nbinsE; Ecol++){ M6 (Erri,Errj) = 0; M5 (Erri,Errj) = 0; M4 (Erri,Errj) = 0; M3 (Erri,Errj) = 0; M2 (Erri,Errj) = 0; M1 (Erri,Errj) = 0; M0 (Erri,Errj) = 0; N = 0; for(int u = 0; u < npoints; u++){ M6 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][6][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][6][Ecol]); M5 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][5][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][5][Ecol]); M4 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][4][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][4][Ecol]); M3 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][3][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][3][Ecol]); M2 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][2][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][2][Ecol]); M1 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][1][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][1][Ecol]); M0 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][0][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][0][Ecol]); N++; } M6 (Erri,Errj) /= N; M5 (Erri,Errj) /= N; M4 (Erri,Errj) /= N; M3 (Erri,Errj) /= N; M2 (Erri,Errj) /= N; M1 (Erri,Errj) /= N; M0 (Erri,Errj) /= N; M6 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M5 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M4 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M3 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M2 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M1 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M0 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; if(Erri == Errj) Fig6->SetBinContent(Erri+1, sqrt(M6 (Erri,Errj))); if(Erri == Errj) Fig5->SetBinContent(Erri+1, sqrt(M5 (Erri,Errj))); if(Erri == Errj) Fig4->SetBinContent(Erri+1, sqrt(M4 (Erri,Errj))); if(Erri == Errj) Fig3->SetBinContent(Erri+1, sqrt(M3 (Erri,Errj))); if(Erri == Errj) Fig2->SetBinContent(Erri+1, sqrt(M2 (Erri,Errj))); if(Erri == Errj) Fig1->SetBinContent(Erri+1, sqrt(M1 (Erri,Errj))); if(Erri == Errj) Fig0->SetBinContent(Erri+1, sqrt(M0 (Erri,Errj))); Errj++; }} Erri++; }} for(int i = 0; i < Erri; i++){ for(int j = 0; j < Errj; j++){ C6 (i,j) = M6(i,j) / sqrt(M6 (i,i) * M6 (j,j)); C5 (i,j) = M5(i,j) / sqrt(M5 (i,i) * M5 (j,j)); C4 (i,j) = M4(i,j) / sqrt(M4 (i,i) * M4 (j,j)); C3 (i,j) = M3(i,j) / sqrt(M3 (i,i) * M3 (j,j)); C2 (i,j) = M2(i,j) / sqrt(M2 (i,i) * M2 (j,j)); C1 (i,j) = M1(i,j) / sqrt(M1 (i,i) * M1 (j,j)); C0 (i,j) = M0(i,j) / sqrt(M0 (i,i) * M0 (j,j)); } } std::cout << "...Error Matrix Filled" << std::endl; TCanvas* c6 = new TCanvas("c6","",700,700); c6->SetLeftMargin(.1); c6->SetBottomMargin(.1); c6->SetTopMargin(.075); c6->SetRightMargin(.15); c6->cd(); M6.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); // TMatrixFBase->GetZaxis()->SetRangeUser(-0.05,0.4); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("Fractional Error Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); add_plot_label(" 0.2 GeV #minus 3.0 GeV ", 0.48,0.07,0.04); TLatex *MD = new TLatex(.3,.01,"MicroBooNE (470m)"); MD->SetNDC(); MD->SetTextFont(62); MD->SetTextSize(0.04); MD->Draw(); TLatex *MD45 = new TLatex(.05,.3,"MicroBooNE (470m)"); MD45->SetNDC(); MD45->SetTextAngle(90); MD45->SetTextFont(62); MD45->SetTextSize(0.04); MD45->Draw(); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Flux Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); c6->Print("total_1Det_matrix.pdf"); TCanvas* c61 = new TCanvas("c61","",700,700); c61->SetLeftMargin(.1); c61->SetBottomMargin(.1); c61->SetTopMargin(.075); c61->SetRightMargin(.15); c61->cd(); C6.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); add_plot_label(" 0.2 GeV #minus 3.0 GeV ", 0.48,0.07,0.04); MD->Draw(); MD45->Draw(); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Flux Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); c61->Print("total_1Det_correlation_matrix.pdf"); cout<<"\nEnd of routine.\n"; return 0; }