From 8792445c3f3e44b55719481350fef558783cf0d2 Mon Sep 17 00:00:00 2001 From: nemu Date: Fri, 13 May 2011 11:07:03 +0000 Subject: [PATCH] some improvements when calculating mean values and reading rge-files --- src/tests/nonlocal/Makefile | 2 +- src/tests/nonlocal/nonlocal.cpp | 49 +++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/tests/nonlocal/Makefile b/src/tests/nonlocal/Makefile index fab8d160..71101ed1 100644 --- a/src/tests/nonlocal/Makefile +++ b/src/tests/nonlocal/Makefile @@ -58,7 +58,7 @@ LIBS = $(ROOTLIBS) -lXMLParser GLIBS = $(ROOTGLIBS) -lXMLParser # PSI libs -PSILIBS = -L$(ROOTSYS)/lib -lTLemRunHeader -lPMusr +PSILIBS = -L$(ROOTSYS)/lib -lTLemRunHeader -lPMusr -lPUserFcnBase # Minuit2 lib MNLIB = -L$(ROOTSYS)/lib -lMinuit2 # MathMore lib diff --git a/src/tests/nonlocal/nonlocal.cpp b/src/tests/nonlocal/nonlocal.cpp index 0496fe2c..9851d2d7 100644 --- a/src/tests/nonlocal/nonlocal.cpp +++ b/src/tests/nonlocal/nonlocal.cpp @@ -21,16 +21,16 @@ void syntax() cout << endl << "% input file for nonlocal"; cout << endl << "% --------------------------------"; cout << endl << "% input parameters:"; - cout << endl << "% reduced temperature"; - cout << endl << "% lambda London (nm)"; - cout << endl << "% xi0 (nm)"; - cout << endl << "% mean free path (nm)"; - cout << endl << "% film thickness (nm)"; - cout << endl << "% specular, 1=specular, 0=diffuse"; - cout << endl << "% [Bext in (G)], i.e. this is optional"; - cout << endl << "% [dead layer in (nm)], i.e. this is optional"; - cout << endl << "% [rge input file name], i.e. this is optional"; - cout << endl << "% [output file name], i.e. this is optional"; + cout << endl << "% reducedTemp : reduced temperature"; + cout << endl << "% lambdaL : lambda London (nm)"; + cout << endl << "% xi0 : coherence length (nm)"; + cout << endl << "% meanFreePath : mean free path (nm)"; + cout << endl << "% filmThickness : film thickness (nm)"; + cout << endl << "% specular : 1=specular, 0=diffuse"; + cout << endl << "% [Bext] : external magnetic field (G), i.e. this is optional"; + cout << endl << "% [deadLayer] : dead layer (nm), i.e. this is optional"; + cout << endl << "% [rgeFileName] : rge input file name, i.e. this is optional"; + cout << endl << "% [outputFileName] : output file name, i.e. this is optional"; cout << endl; cout << endl << "reducedTemp = 0.8287"; cout << endl << "lambdaL = 30.0"; @@ -223,17 +223,21 @@ int readRgeFile(const char *fln, vector &x, vector &n) int lineNo = 1; int result; double valX, valN; - // read first line and ignore it since it is the header line - fgets(line, sizeof(line), fp); + int headerCount = 0; while (!feof(fp)) { fgets(line, sizeof(line), fp); result = sscanf(line, "%lf %lf", &valX, &valN); if (result != 2) { - cout << endl << "**ERROR** in line no " << lineNo; - cout << endl << "Couldn't extract x and n(x), will quit."; - cout << endl << endl; - fclose(fp); - return 0; + if (headerCount >= 2) { + cout << endl << "**ERROR** in line no " << lineNo; + cout << endl << "Couldn't extract x and n(x), will quit."; + cout << endl << endl; + fclose(fp); + return 0; + } else { + headerCount++; + continue; + } } x.push_back(valX/10.0); // x in nm n.push_back(valN); @@ -250,10 +254,12 @@ int readRgeFile(const char *fln, vector &x, vector &n) } /* +Double_t xx=0.0; for (unsigned int i=0; i xx=" << xx << endl; */ fclose(fp); @@ -370,6 +376,8 @@ int main(int argc, char *argv[]) for (unsigned int i=0; i params.deadLayer+params.filmThickness) { + meanB += 1.0 * n[i]; } else { BB = pippard->GetMagneticField(x[i]-params.deadLayer); meanB += BB * n[i]; @@ -394,8 +402,7 @@ int main(int argc, char *argv[]) if (params.outputFileName.Length() > 0) pippard->SaveField(); - cout << endl << ">> magnetic field = " << pippard->GetMagneticField(0.0); - cout << endl; + cout << endl << endl; if (pippard) { delete pippard;