detscan.cpp
Go to the documentation of this file.00001 #include "MTTensor.h"
00002 #include <fstream>
00003 #include <iostream>
00004 #include <complex>
00005 #include "CUniformRNG.h"
00006 #include "netcdfcpp.h"
00007
00008 using namespace std;
00009 using namespace gplib;
00010
00011 int main()
00012 {
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 const complex<double> xx(0.00047, 0.00014);
00024 const complex<double> xy(0.11653, 0.08244);
00025 const complex<double> yx(-0.00407, -0.01294);
00026 const complex<double> yy(0.00309, -0.00417);
00027
00028 const MTTensor TestData(xx, xy, yx, yy, 0.001);
00029 const size_t ntestcases = 100;
00030
00031 cerr << "Det Phi: " << TestData.GetdetPhi() << endl;
00032 const double imagmax = 2. * yx.imag();
00033 const double realmax = 2. * yx.real();
00034 const double imagmin = -2.0 * yx.imag();
00035 const double realmin = -2.0 * yx.real();
00036 const double realmin = -2.0 * yx.real();
00037 const double imagstep = (imagmax - imagmin) / ntestcases;
00038 const double realstep = (realmax - realmin) / ntestcases;
00039 cout << "App. res.: " << TestData.GetRhoxx() << " " << TestData.GetRhoxy()
00040 << " " << TestData.GetRhoyx() << " " << TestData.GetRhoyy() << endl;
00041 cout << "Phase: " << TestData.GetPhixx() << " " << TestData.GetPhixy()
00042 << " " << TestData.GetPhiyx() << " " << TestData.GetPhiyy() << endl;
00043 cout << "Phase tensor: " << TestData.GetPhi11() << " "
00044 << TestData.GetPhi12() << " " << TestData.GetPhi21() << " "
00045 << TestData.GetPhi22() << endl;
00046 cout << "GetPi1() " << TestData.GetPi1() << endl;
00047 cout << "GetPi2() " << TestData.GetPi2() << endl;
00048 cout << "GetPhiStrike() " << TestData.GetPhiStrike() << endl;
00049 cout << "GetPhiMaxNew() " << TestData.GetPhiMaxNew() << endl;
00050 cout << "GetPhiMinNew() " << TestData.GetPhiMinNew() << endl;
00051 cout << "GettrPhi() " << TestData.GettrPhi() << endl;
00052 cout << "GetskPhi() " << TestData.GetskPhi() << endl;
00053 cout << "GetdetPhi() " << TestData.GetdetPhi() << endl;
00054 cout << "GetPhi1() " << TestData.GetPhi1() << endl;
00055 cout << "GetPhi2() " << TestData.GetPhi2() << endl;
00056 cout << "GetDetreal() " << TestData.GetDetreal() << endl;
00057
00058 cout << endl << endl;
00059
00060 NcFile combrescdf("det.nc", NcFile::Replace);
00061 NcDim* xd = combrescdf.add_dim("real", ntestcases);
00062 NcDim* yd = combrescdf.add_dim("imag", ntestcases);
00063 NcVar* x = combrescdf.add_var("real", ncFloat, xd);
00064 NcVar* y = combrescdf.add_var("imag", ncFloat, yd);
00065 NcVar* phimin = combrescdf.add_var("PhiMin", ncFloat, xd, yd);
00066 NcVar* phimax = combrescdf.add_var("PhiMax", ncFloat, xd, yd);
00067 NcVar* alpha = combrescdf.add_var("Alpha", ncFloat, xd, yd);
00068 NcVar* beta = combrescdf.add_var("Beta", ncFloat, xd, yd);
00069 NcVar* eta = combrescdf.add_var("Eta", ncFloat, xd, yd);
00070 float *xvals = new float[xd->size()];
00071 float *yvals = new float[yd->size()];
00072 float *phiminvals = new float[xd->size() * yd->size()];
00073 float *phimaxvals = new float[xd->size() * yd->size()];
00074 float *alphavals = new float[xd->size() * yd->size()];
00075 float *betavals = new float[xd->size() * yd->size()];
00076 float *etavals = new float[xd->size() * yd->size()];
00077
00078
00079
00080
00081
00082
00083
00084 ofstream iffile("det.txt");
00085 iffile << ntestcases << " " << ntestcases << " " << 1 << endl;
00086 for (int i = 0; i < ntestcases; ++i)
00087 {
00088 double real = realmin + i * realstep;
00089 xvals[i] = real;
00090 for (int j = 0; j < ntestcases; ++j)
00091 {
00092 double imag = imagmin + j * imagstep;
00093 yvals[j] = imag;
00094 complex<double> newyx(real, imag);
00095 MTTensor ScanData(xx, xy, newyx, yy, 0.001);
00096 phiminvals[i * ntestcases + j] = ScanData.GetPhiMin();
00097 phimaxvals[i * ntestcases + j] = ScanData.GetPhiMax();
00098 alphavals[i * ntestcases + j] = ScanData.GetAlpha_phi();
00099 betavals[i * ntestcases + j] = ScanData.GetBeta_phi();
00100 etavals[i * ntestcases + j] = ScanData.GetEta();
00101 iffile << ScanData.GetPhiMin() << endl;
00102
00103 }
00104 x->put(xvals, xd->size());
00105 y->put(yvals, yd->size());
00106 phimin->put(phiminvals, phimin->edges());
00107 phimax->put(phimaxvals, phimax->edges());
00108 alpha->put(alphavals, alpha->edges());
00109 beta->put(betavals, beta->edges());
00110 eta->put(etavals, eta->edges());
00111 }
00112 delete[] xvals;
00113 delete[] yvals;
00114 delete[] phiminvals;
00115 delete[] phimaxvals;
00116 }