switched libPhotoMeissner to the new centralized PRgeHandler.
This commit is contained in:
parent
bd75f25ee6
commit
c2719c4996
@ -21,16 +21,6 @@ root_generate_dictionary(
|
||||
LINKDEF ${PHOTO_MEISSNER_INC}/PPhotoMeissnerLinkDef.h
|
||||
MODULE PPhotoMeissner
|
||||
)
|
||||
root_generate_dictionary(
|
||||
PStartupHandler_PMDict
|
||||
PStartupHandler_PM.h
|
||||
OPTIONS
|
||||
-I${MUSRFIT_INC}
|
||||
-I${PHOTO_MEISSNER_INC}
|
||||
-inlineInputHeader
|
||||
LINKDEF ${PHOTO_MEISSNER_INC}/PStartupHandler_PMLinkDef.h
|
||||
MODULE PStartupHandler_PM
|
||||
)
|
||||
|
||||
#--- create pkg-config info ---------------------------------------------------
|
||||
set(prefix "${CMAKE_INSTALL_PREFIX}")
|
||||
@ -45,8 +35,6 @@ configure_file("PPhotoMeissner.pc.in" "PPhotoMeissner.pc" @ONLY)
|
||||
add_library(PPhotoMeissner SHARED
|
||||
PPhotoMeissner.cpp
|
||||
PPhotoMeissnerDict.cxx
|
||||
PStartupHandler_PM.cpp
|
||||
PStartupHandler_PMDict.cxx
|
||||
)
|
||||
|
||||
#--- set target properties, e.g. version --------------------------------------
|
||||
@ -67,7 +55,7 @@ target_include_directories(
|
||||
|
||||
#--- add library dependencies -------------------------------------------------
|
||||
target_link_libraries(PPhotoMeissner
|
||||
${FFTW3_LIBRARY} ${GSL_LIBRARY} ${ROOT_LIBRARIES} PUserFcnBase
|
||||
${FFTW3_LIBRARY} ${GSL_LIBRARY} ${ROOT_LIBRARIES} PRgeHandler PUserFcnBase
|
||||
)
|
||||
|
||||
#--- install PPhotoMeissner solib ---------------------------------------------
|
||||
@ -77,8 +65,6 @@ install(TARGETS PPhotoMeissner DESTINATION lib)
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/libPPhotoMeissner_rdict.pcm
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libPPhotoMeissner.rootmap
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libPStartupHandler_PM_rdict.pcm
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libPStartupHandler_PM.rootmap
|
||||
DESTINATION lib
|
||||
)
|
||||
|
||||
@ -86,7 +72,6 @@ install(
|
||||
install(
|
||||
FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../include/PPhotoMeissner.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../include/PStartupHandler_PM.h
|
||||
DESTINATION
|
||||
include
|
||||
)
|
||||
|
@ -8,7 +8,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 by Andreas Suter *
|
||||
* Copyright (C) 2013-2021 by Andreas Suter *
|
||||
* andreas.suter@psi.ch *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@ -30,15 +30,11 @@
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
#include <gsl/gsl_sf_bessel.h>
|
||||
|
||||
#include <TSAXParser.h>
|
||||
|
||||
#include "PMusr.h"
|
||||
|
||||
#include "../include/PPhotoMeissner.h"
|
||||
#include "PPhotoMeissner.h"
|
||||
|
||||
|
||||
ClassImp(PPhotoMeissner) // for ROOT dictionary
|
||||
@ -51,38 +47,14 @@ ClassImp(PPhotoMeissner) // for ROOT dictionary
|
||||
*/
|
||||
PPhotoMeissner::PPhotoMeissner()
|
||||
{
|
||||
// init
|
||||
fStartupHandler = 0;
|
||||
fValid = true;
|
||||
|
||||
// read XML startup file
|
||||
char startup_path_name[128];
|
||||
TSAXParser *saxParser = new TSAXParser();
|
||||
fStartupHandler = new PStartupHandler_PM();
|
||||
strcpy(startup_path_name, fStartupHandler->GetStartupFilePath().Data());
|
||||
saxParser->ConnectToHandler("PStartupHandler_PM", fStartupHandler);
|
||||
//Int_t status = saxParser->ParseFile(startup_path_name);
|
||||
// parsing the file as above seems to lead to problems in certain environments;
|
||||
// use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition)
|
||||
Int_t status = parseXmlFile(saxParser, startup_path_name);
|
||||
// check for parse errors
|
||||
if (status) { // error
|
||||
cout << endl << ">> PPhotoMeissner::PPhotoMeissner: **WARNING** Reading/parsing photoMeissner_startup.xml failed.";
|
||||
cout << endl;
|
||||
fValid = false;
|
||||
}
|
||||
|
||||
// clean up
|
||||
if (saxParser) {
|
||||
delete saxParser;
|
||||
saxParser = 0;
|
||||
}
|
||||
fRgeHandler = new PRgeHandler("./photoMeissner_startup.xml");
|
||||
|
||||
// check if everything went fine with the startup handler
|
||||
if (!fStartupHandler->IsValid()) {
|
||||
cout << endl << ">> PPhotoMeissner::PPhotoMeissner **PANIC ERROR**";
|
||||
cout << endl << ">> startup handler too unhappy. Will terminate unfriendly, sorry.";
|
||||
cout << endl;
|
||||
if (!fRgeHandler->IsValid()) {
|
||||
std::cout << std::endl << ">> PPhotoMeissner::PPhotoMeissner **PANIC ERROR**";
|
||||
std::cout << std::endl << ">> startup handler too unhappy. Will terminate unfriendly, sorry.";
|
||||
std::cout << std::endl;
|
||||
fValid = false;
|
||||
}
|
||||
}
|
||||
@ -95,8 +67,8 @@ PPhotoMeissner::PPhotoMeissner()
|
||||
*/
|
||||
PPhotoMeissner::~PPhotoMeissner()
|
||||
{
|
||||
if (fStartupHandler)
|
||||
delete fStartupHandler;
|
||||
if (fRgeHandler)
|
||||
delete fRgeHandler;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@ -108,9 +80,9 @@ PPhotoMeissner::~PPhotoMeissner()
|
||||
* \param t
|
||||
* \param par
|
||||
*/
|
||||
Double_t PPhotoMeissner::operator()(Double_t t, const vector<Double_t> &par) const
|
||||
Double_t PPhotoMeissner::operator()(Double_t t, const std::vector<Double_t> &par) const
|
||||
{
|
||||
// expected parameters: (0) implantation energy (kV), (1) dead layer (nm), (2) Bext (G), (3) lambdaLondon (nm),
|
||||
// expected parameters: (0) implantation energy (eV), (1) dead layer (nm), (2) Bext (G), (3) lambdaLondon (nm),
|
||||
// (4) lambdaPhoto (nm), (5) z0 (nm), (6) detector phase (°), [(7) layer thickness]
|
||||
assert((par.size() == 7) || (par.size() == 8));
|
||||
|
||||
@ -122,39 +94,33 @@ Double_t PPhotoMeissner::operator()(Double_t t, const vector<Double_t> &par) con
|
||||
Double_t dz = 1.0; // go in 1A steps
|
||||
Double_t zz = 0.0;
|
||||
Double_t nn = 0.0;
|
||||
Double_t sum = 0.0;
|
||||
Double_t BB = 0.0;
|
||||
Double_t gamma = fTwoPi*GAMMA_BAR_MUON;
|
||||
int idx = fRgeHandler->GetEnergyIndex(par[0]);
|
||||
|
||||
int done = 0;
|
||||
if (par.size() == 7) { // semi-infinite sample
|
||||
do {
|
||||
nn = fStartupHandler->GetRgeValue(par[0], zz);
|
||||
nn = fRgeHandler->Get_n(idx, zz);
|
||||
BB = FieldHalfSpace(zz, par);
|
||||
result += nn*cos(gamma*BB*t+fDegToRad*par[6]);
|
||||
zz += dz;
|
||||
sum += nn;
|
||||
if (nn == 0.0)
|
||||
done++;
|
||||
} while (done < 5);
|
||||
} else { // film
|
||||
do {
|
||||
nn = fStartupHandler->GetRgeValue(par[0], zz);
|
||||
nn = fRgeHandler->Get_n(idx, zz);
|
||||
BB = FieldFilm(zz, par);
|
||||
result += nn*cos(gamma*BB*t+fDegToRad*par[6]);
|
||||
zz += dz;
|
||||
sum += nn;
|
||||
if (nn == 0.0)
|
||||
done++;
|
||||
} while (done < 5);
|
||||
}
|
||||
|
||||
if (sum == 0.0) {
|
||||
cerr << endl << ">> PPhotoMeissner::operator(): **PANIC ERROR** sum of RGE values == 0!" << endl;
|
||||
assert(0);
|
||||
}
|
||||
|
||||
return result/sum;
|
||||
return result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@ -180,7 +146,7 @@ Double_t PPhotoMeissner::InuMinus(const Double_t nu, const Double_t x) const
|
||||
*
|
||||
* \param par
|
||||
*/
|
||||
Double_t PPhotoMeissner::FieldFilm(const Double_t z, const vector<Double_t> &par) const
|
||||
Double_t PPhotoMeissner::FieldFilm(const Double_t z, const std::vector<Double_t> &par) const
|
||||
{
|
||||
// prevent dividing by zero
|
||||
double lamL = par[3];
|
||||
@ -217,7 +183,7 @@ Double_t PPhotoMeissner::FieldFilm(const Double_t z, const vector<Double_t> &par
|
||||
*
|
||||
* \param par
|
||||
*/
|
||||
Double_t PPhotoMeissner::FieldHalfSpace(const Double_t z, const vector<Double_t> &par) const
|
||||
Double_t PPhotoMeissner::FieldHalfSpace(const Double_t z, const std::vector<Double_t> &par) const
|
||||
{
|
||||
// prevent dividing by zero
|
||||
double lamL = par[3];
|
||||
|
@ -1,507 +0,0 @@
|
||||
/***************************************************************************
|
||||
|
||||
PStartupHandler_PM.cpp
|
||||
|
||||
Author: Andreas Suter
|
||||
e-mail: andreas.suter@psi.ch
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013-2021 by Andreas Suter *
|
||||
* andreas.suter@psi.ch *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include "PStartupHandler_PM.h"
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
PRgeHandler_PM::PRgeHandler_PM(const PStringVector &rgeDataPathList, const PDoubleVector &rgeDataEnergyList)
|
||||
{
|
||||
fIsValid = false;
|
||||
|
||||
fIsValid = LoadRgeData(rgeDataPathList, rgeDataEnergyList);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Destructor
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
PRgeHandler_PM::~PRgeHandler_PM()
|
||||
{
|
||||
fRgeDataList.clear();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetRgeEnergyIndex
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
* \param energy in (keV)
|
||||
*/
|
||||
Int_t PRgeHandler_PM::GetRgeEnergyIndex(const Double_t energy)
|
||||
{
|
||||
Int_t idx = -1;
|
||||
|
||||
for (UInt_t i=0; i<fRgeDataList.size(); i++) {
|
||||
if (energy == fRgeDataList[i].energy) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetRgeValue
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
* \param energy in (keV)
|
||||
* \param dist in (nm)
|
||||
*/
|
||||
Double_t PRgeHandler_PM::GetRgeValue(const Int_t index, const Double_t dist)
|
||||
{
|
||||
Double_t rgeVal = 0.0;
|
||||
|
||||
UInt_t distIdx = static_cast<UInt_t>(dist/(fRgeDataList[index].stoppingDistance[1]-fRgeDataList[index].stoppingDistance[0]));
|
||||
|
||||
if (distIdx >= fRgeDataList[index].stoppingDistance.size()) {
|
||||
rgeVal = 0.0;
|
||||
} else {
|
||||
rgeVal = fRgeDataList[index].stoppingAmplitude[distIdx] +
|
||||
(fRgeDataList[index].stoppingAmplitude[distIdx+1] - fRgeDataList[index].stoppingAmplitude[distIdx]) *
|
||||
(dist-fRgeDataList[index].stoppingDistance[distIdx])/(fRgeDataList[index].stoppingDistance[distIdx+1]-fRgeDataList[index].stoppingDistance[distIdx]);
|
||||
}
|
||||
|
||||
return rgeVal;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetRgeValue
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
* \param energy in (keV)
|
||||
* \param dist in (nm)
|
||||
*/
|
||||
Double_t PRgeHandler_PM::GetRgeValue(const Double_t energy, const Double_t dist)
|
||||
{
|
||||
// check if energy is present in rge data list
|
||||
Int_t idx = -1;
|
||||
|
||||
for (UInt_t i=0; i<fRgeDataList.size(); i++) {
|
||||
if (energy == fRgeDataList[i].energy) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// energy not found
|
||||
if (idx == -1)
|
||||
return -1.0;
|
||||
|
||||
return GetRgeValue(idx, dist);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// LoadRgeData
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
Bool_t PRgeHandler_PM::LoadRgeData(const PStringVector &rgeDataPathList, const PDoubleVector &rgeDataEnergyList)
|
||||
{
|
||||
std::ifstream fin;
|
||||
PRgeData_PM data;
|
||||
Int_t idx=0;
|
||||
TString dataName, tstr;
|
||||
char line[512];
|
||||
int result;
|
||||
double dist, val;
|
||||
|
||||
for (UInt_t i=0; i<rgeDataPathList.size(); i++) {
|
||||
// open rge-file for reading
|
||||
fin.open(rgeDataPathList[i].Data(), std::iostream::in);
|
||||
if (!fin.is_open()) {
|
||||
std::cerr << std::endl << "PRgeHandler_PM::LoadRgeData **ERROR**";
|
||||
std::cerr << std::endl << " Could not open file " << rgeDataPathList[i].Data();
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// keep energy (in keV)
|
||||
data.energy = rgeDataEnergyList[i]/1000.0;
|
||||
|
||||
// read msr-file
|
||||
idx = 0;
|
||||
while (!fin.eof()) {
|
||||
// read a line
|
||||
fin.getline(line, sizeof(line));
|
||||
idx++;
|
||||
|
||||
// ignore first line
|
||||
if (idx <= 1)
|
||||
continue;
|
||||
|
||||
// ignore empty lines
|
||||
tstr = line;
|
||||
if (tstr.IsWhitespace())
|
||||
continue;
|
||||
|
||||
|
||||
// get values
|
||||
result = sscanf(line, "%lf %lf", &dist, &val);
|
||||
// check if data are valid
|
||||
if (result != 2) {
|
||||
fin.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
// feed fRgeDataList
|
||||
data.stoppingDistance.push_back(dist/10.0); // keep distancies in (nm)
|
||||
data.stoppingAmplitude.push_back(val);
|
||||
}
|
||||
|
||||
// normalize stopping distribution
|
||||
Double_t norm = 0.0;
|
||||
for (UInt_t j=0; j<data.stoppingAmplitude.size(); j++)
|
||||
norm += data.stoppingAmplitude[j];
|
||||
norm *= (data.stoppingDistance[1] - data.stoppingDistance[0]);
|
||||
for (UInt_t j=0; j<data.stoppingAmplitude.size(); j++)
|
||||
data.stoppingAmplitude[j] /= norm;
|
||||
|
||||
// keep data
|
||||
fRgeDataList.push_back(data);
|
||||
|
||||
// clean up
|
||||
data.stoppingAmplitude.clear();
|
||||
data.stoppingDistance.clear();
|
||||
|
||||
fin.close();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
ClassImpQ(PStartupHandler_PM)
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
PStartupHandler_PM::PStartupHandler_PM()
|
||||
{
|
||||
fIsValid = true;
|
||||
|
||||
fStartupFileFound = false;
|
||||
fStartupFilePath = "";
|
||||
|
||||
// get default path (for the moment only linux like)
|
||||
char startup_path_name[512];
|
||||
char *home_path=0;
|
||||
|
||||
// check if the startup file is found in the current directory
|
||||
strcpy(startup_path_name, "./photoMeissner_startup.xml");
|
||||
if (StartupFileExists(startup_path_name)) {
|
||||
fStartupFileFound = true;
|
||||
fStartupFilePath = TString(startup_path_name);
|
||||
} else { // startup file is not found in the current directory
|
||||
std::cout << std::endl << ">> PStartupHandler_PM(): **WARNING** Couldn't find photoMeissner_startup.xml in the current directory, will try default one." << std::endl;
|
||||
home_path = getenv("HOME");
|
||||
snprintf(startup_path_name, sizeof(startup_path_name), "%s/.musrfit/external/photoMeissner_startup.xml", home_path);
|
||||
if (StartupFileExists(startup_path_name)) {
|
||||
fStartupFileFound = true;
|
||||
fStartupFilePath = TString(startup_path_name);
|
||||
}
|
||||
}
|
||||
|
||||
// init RGE handler
|
||||
fRgeHandler = nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// OnStartDocument
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*/
|
||||
void PStartupHandler_PM::OnStartDocument()
|
||||
{
|
||||
fKey = eEmpty;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// OnEndDocument
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*/
|
||||
void PStartupHandler_PM::OnEndDocument()
|
||||
{
|
||||
if (!fIsValid)
|
||||
return;
|
||||
|
||||
// generate the file path list
|
||||
TString str;
|
||||
for (unsigned int i=0; i<fRgeDataEnergyList.size(); i++) {
|
||||
str = fRgePath;
|
||||
str += fRgeDataEnergyList[i];
|
||||
str += ".rge";
|
||||
fRgeFilePathList.push_back(str);
|
||||
}
|
||||
|
||||
|
||||
fRgeHandler = new PRgeHandler_PM(fRgeFilePathList, fRgeDataEnergyList);
|
||||
if (fRgeHandler == nullptr) { // severe problem
|
||||
fIsValid = false;
|
||||
std::cerr << std::endl << ">> PStartupHandler_PM::OnEndDocument(): **ERROR** couldn't invoke RGE handler." << std::endl << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fRgeHandler->IsValid()) { // severe problem
|
||||
fIsValid = false;
|
||||
std::cerr << std::endl << ">> PStartupHandler_PM::OnEndDocument(): **ERROR** RGE handler not valid." << std::endl << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// OnStartElement
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* \param str
|
||||
* \param attributes
|
||||
*/
|
||||
void PStartupHandler_PM::OnStartElement(const char *str, const TList *attributes)
|
||||
{
|
||||
if (!strcmp(str, "data_path")) {
|
||||
fKey = eDataPath;
|
||||
} else if (!strcmp(str, "energy")) {
|
||||
fKey = eEnergy;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// OnEndElement
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* \param str
|
||||
*/
|
||||
void PStartupHandler_PM::OnEndElement(const char *str)
|
||||
{
|
||||
fKey = eEmpty;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// OnCharacters
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* \param str
|
||||
*/
|
||||
void PStartupHandler_PM::OnCharacters(const char *str)
|
||||
{
|
||||
TString tstr;
|
||||
Double_t dval;
|
||||
|
||||
switch (fKey) {
|
||||
case eDataPath:
|
||||
fRgePath = str;
|
||||
break;
|
||||
case eEnergy:
|
||||
tstr = str;
|
||||
if (tstr.IsFloat()) {
|
||||
dval = tstr.Atof();
|
||||
fRgeDataEnergyList.push_back(dval);
|
||||
} else {
|
||||
std::cerr << std::endl << "PStartupHandler_PM::OnCharacters: **ERROR** when finding energy:";
|
||||
std::cerr << std::endl << "\"" << str << "\" is not a floating point number, will ignore it.";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// OnComment
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* \param str
|
||||
*/
|
||||
void PStartupHandler_PM::OnComment(const char *str)
|
||||
{
|
||||
// nothing to be done for now
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// OnWarning
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* \param str
|
||||
*/
|
||||
void PStartupHandler_PM::OnWarning(const char *str)
|
||||
{
|
||||
std::cerr << std::endl << "PStartupHandler_PM **WARNING** " << str;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// OnError
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* \param str
|
||||
*/
|
||||
void PStartupHandler_PM::OnError(const char *str)
|
||||
{
|
||||
std::cerr << std::endl << "PStartupHandler_PM **ERROR** " << str;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// OnFatalError
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* \param str
|
||||
*/
|
||||
void PStartupHandler_PM::OnFatalError(const char *str)
|
||||
{
|
||||
std::cerr << std::endl << "PStartupHandler_PM **FATAL ERROR** " << str;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// OnCdataBlock
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* \param str
|
||||
*/
|
||||
void PStartupHandler_PM::OnCdataBlock(const char *str, Int_t len)
|
||||
{
|
||||
// nothing to be done for now
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetRgeEnergyIndex
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* \param energy
|
||||
*/
|
||||
Int_t PStartupHandler_PM::GetRgeEnergyIndex(const Double_t energy)
|
||||
{
|
||||
Int_t result = -1;
|
||||
if (fIsValid)
|
||||
result = fRgeHandler->GetRgeEnergyIndex(energy);
|
||||
return result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetRgeValue
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* \param energy
|
||||
* \param dist
|
||||
*/
|
||||
Double_t PStartupHandler_PM::GetRgeValue(const Double_t energy, const Double_t dist)
|
||||
{
|
||||
Double_t result = 0.0;
|
||||
if (fIsValid)
|
||||
result = fRgeHandler->GetRgeValue(energy, dist);
|
||||
return result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetRgeValue
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* \param index
|
||||
* \param dist
|
||||
*/
|
||||
Double_t PStartupHandler_PM::GetRgeValue(const Int_t index, const Double_t dist)
|
||||
{
|
||||
Double_t result = 0.0;
|
||||
if (fIsValid)
|
||||
result = fRgeHandler->GetRgeValue(index, dist);
|
||||
return result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// StartupFileExists
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
*/
|
||||
bool PStartupHandler_PM::StartupFileExists(char *fln)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
std::ifstream ifile(fln);
|
||||
|
||||
if (ifile.fail()) {
|
||||
result = false;
|
||||
} else {
|
||||
result = true;
|
||||
ifile.close();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// end
|
||||
// -------------------------------------------------------------------------
|
@ -33,7 +33,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "PUserFcnBase.h"
|
||||
#include "PStartupHandler_PM.h"
|
||||
#include "PRgeHandler.h"
|
||||
|
||||
class PPhotoMeissner : public PUserFcnBase
|
||||
{
|
||||
@ -44,12 +44,12 @@ class PPhotoMeissner : public PUserFcnBase
|
||||
virtual Bool_t IsValid() { return fValid; }
|
||||
|
||||
// function operator
|
||||
Double_t operator()(Double_t, const std::vector<Double_t>&) const;
|
||||
Double_t operator()(Double_t t, const std::vector<Double_t> ¶m) const;
|
||||
|
||||
private:
|
||||
PStartupHandler_PM *fStartupHandler;
|
||||
PRgeHandler *fRgeHandler{nullptr};
|
||||
|
||||
Bool_t fValid; ///< flag indicating if initialization went through smoothly
|
||||
Bool_t fValid{true}; ///< flag indicating if initialization went through smoothly
|
||||
|
||||
constexpr static const Double_t fDegToRad = 0.0174532925199432955;
|
||||
constexpr static const Double_t fTwoPi = 6.28318530717958623;
|
||||
|
@ -1,139 +0,0 @@
|
||||
/***************************************************************************
|
||||
|
||||
PStartupHandler_PM.h
|
||||
|
||||
Author: Andreas Suter
|
||||
e-mail: andreas.suter@psi.ch
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013-2021 by Andreas Suter *
|
||||
* andreas.suter@psi.ch *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _PSTARTUPHANDLER_PM_H_
|
||||
#define _PSTARTUPHANDLER_PM_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <TObject.h>
|
||||
#include <TQObject.h>
|
||||
#include <TString.h>
|
||||
|
||||
//-------------------------------------------------------------
|
||||
/**
|
||||
* <p> typedef to make to code more readable.
|
||||
*/
|
||||
typedef std::vector<TString> PStringVector;
|
||||
|
||||
//-------------------------------------------------------------
|
||||
/**
|
||||
* <p> typedef to make to code more readable.
|
||||
*/
|
||||
typedef std::vector<Double_t> PDoubleVector;
|
||||
|
||||
//-------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*/
|
||||
typedef struct {
|
||||
Double_t energy;
|
||||
PDoubleVector stoppingDistance;
|
||||
PDoubleVector stoppingAmplitude;
|
||||
} PRgeData_PM;
|
||||
|
||||
//-------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*/
|
||||
typedef std::vector<PRgeData_PM> PRgeData_PM_List;
|
||||
|
||||
//-------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*/
|
||||
class PRgeHandler_PM
|
||||
{
|
||||
public:
|
||||
PRgeHandler_PM(const PStringVector &rgeDataPathList, const PDoubleVector &rgeDataEnergyList);
|
||||
virtual ~PRgeHandler_PM();
|
||||
|
||||
virtual Bool_t IsValid() { return fIsValid; }
|
||||
virtual Int_t GetRgeEnergyIndex(const Double_t energy);
|
||||
virtual Double_t GetRgeValue(const Double_t energy, const Double_t dist);
|
||||
virtual Double_t GetRgeValue(const Int_t index, const Double_t dist);
|
||||
|
||||
private:
|
||||
Bool_t fIsValid;
|
||||
PRgeData_PM_List fRgeDataList;
|
||||
|
||||
virtual Bool_t LoadRgeData(const PStringVector &rgeDataPathList, const PDoubleVector &rgeDataEnergyList);
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*/
|
||||
class PStartupHandler_PM : public TObject
|
||||
{
|
||||
public:
|
||||
PStartupHandler_PM();
|
||||
virtual ~PStartupHandler_PM() {}
|
||||
|
||||
virtual void OnStartDocument(); // SLOT
|
||||
virtual void OnEndDocument(); // SLOT
|
||||
virtual void OnStartElement(const char*, const TList*); // SLOT
|
||||
virtual void OnEndElement(const char*); // SLOT
|
||||
virtual void OnCharacters(const char*); // SLOT
|
||||
virtual void OnComment(const char*); // SLOT
|
||||
virtual void OnWarning(const char*); // SLOT
|
||||
virtual void OnError(const char*); // SLOT
|
||||
virtual void OnFatalError(const char*); // SLOT
|
||||
virtual void OnCdataBlock(const char*, Int_t); // SLOT
|
||||
|
||||
virtual bool IsValid() { return fIsValid; }
|
||||
virtual TString GetStartupFilePath() { return fStartupFilePath; }
|
||||
|
||||
virtual bool StartupFileFound() { return fStartupFileFound; }
|
||||
|
||||
virtual Int_t GetRgeEnergyIndex(const Double_t energy);
|
||||
virtual Double_t GetRgeValue(const Double_t energy, const Double_t dist);
|
||||
virtual Double_t GetRgeValue(const Int_t index, const Double_t dist);
|
||||
|
||||
private:
|
||||
enum EKeyWords {eEmpty, eDataPath, eEnergy};
|
||||
EKeyWords fKey;
|
||||
|
||||
bool fIsValid;
|
||||
|
||||
bool fStartupFileFound;
|
||||
TString fStartupFilePath;
|
||||
|
||||
TString fRgePath;
|
||||
PStringVector fRgeFilePathList;
|
||||
PDoubleVector fRgeDataEnergyList;
|
||||
|
||||
PRgeHandler_PM *fRgeHandler;
|
||||
|
||||
bool StartupFileExists(char *fln);
|
||||
|
||||
ClassDef(PStartupHandler_PM, 1)
|
||||
};
|
||||
|
||||
#endif // _PSTARTUPHANDLER_PM_H_
|
@ -1,38 +0,0 @@
|
||||
/***************************************************************************
|
||||
|
||||
PStartupHandler_PMLinkDef.h
|
||||
|
||||
Author: Andreas Suter
|
||||
e-mail: andreas.suter@psi.ch
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013-2021 by Andreas Suter *
|
||||
* andreas.suter@psi.ch *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef __CLING__
|
||||
|
||||
#pragma link off all globals;
|
||||
#pragma link off all classes;
|
||||
#pragma link off all functions;
|
||||
|
||||
#pragma link C++ class PStartupHandler_PM+;
|
||||
|
||||
#endif
|
@ -3,8 +3,9 @@
|
||||
<comment>
|
||||
contains the needed trim.sp meta-file information
|
||||
</comment>
|
||||
<trim_sp_part>
|
||||
<data_path>./trimsp/YBCO_E</data_path>
|
||||
<trim_sp>
|
||||
<data_path>./trimsp</data_path>
|
||||
<rge_fln_pre>YBCO_E</rge_fln_pre>
|
||||
<energy_list>
|
||||
<energy>1000</energy>
|
||||
<energy>3000</energy>
|
||||
@ -16,5 +17,5 @@
|
||||
<energy>20300</energy>
|
||||
<energy>24300</energy>
|
||||
</energy_list>
|
||||
</trim_sp_part>
|
||||
</trim_sp>
|
||||
</photo_meissner>
|
||||
|
Loading…
x
Reference in New Issue
Block a user