adopted to new PSI-BIN lib. Added facility for finding runs via musrfit_startup.xml templates.

This commit is contained in:
suter_a 2022-05-28 14:10:15 +02:00
parent 56820e498f
commit 06d20d4086
10 changed files with 1148 additions and 92 deletions

View File

@ -5,7 +5,7 @@ if (CMAKE_VERSION GREATER_EQUAL 3.12)
cmake_policy(SET CMP0075 NEW) cmake_policy(SET CMP0075 NEW)
endif (CMAKE_VERSION GREATER_EQUAL 3.12) endif (CMAKE_VERSION GREATER_EQUAL 3.12)
project(musrfit VERSION 1.7.6 LANGUAGES C CXX) project(musrfit VERSION 1.8.0 LANGUAGES C CXX)
#--- musrfit specific options ------------------------------------------------- #--- musrfit specific options -------------------------------------------------
option(nexus "build optional NeXus support. Needed for ISIS" OFF) option(nexus "build optional NeXus support. Needed for ISIS" OFF)

View File

@ -55,6 +55,18 @@ endif (IS_GIT_REPO)
#--- end create git-revision.h ------------------------------------------------ #--- end create git-revision.h ------------------------------------------------
#--- add all executables ------------------------------------------------------ #--- add all executables ------------------------------------------------------
add_executable(addRun ${GIT_REV_H} addRun.cpp)
target_compile_options(addRun BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}")
target_include_directories(addRun
BEFORE PRIVATE
$<BUILD_INTERFACE:${Boost_INCLUDE_DIR}>
$<BUILD_INTERFACE:${FFTW3_INCLUDE_DIR}>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src/include>
)
target_link_libraries(addRun ${ROOT_LIBRARIES} ${MUSRFIT_LIBS} ${Boost_LIBRARIES})
add_executable(any2many ${GIT_REV_H} any2many.cpp) add_executable(any2many ${GIT_REV_H} any2many.cpp)
target_compile_options(any2many BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}") target_compile_options(any2many BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}")
target_include_directories(any2many target_include_directories(any2many
@ -176,6 +188,7 @@ target_link_libraries(write_musrRoot_runHeader ${ROOT_LIBRARIES} ${MUSRFIT_LIBS}
#--- installation info -------------------------------------------------------- #--- installation info --------------------------------------------------------
install( install(
TARGETS TARGETS
addRun
any2many any2many
dump_header dump_header
msr2data msr2data

851
src/addRun.cpp Normal file
View File

@ -0,0 +1,851 @@
/***************************************************************************
addRun.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2022 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 HAVE_CONFIG_H
#include "config.h"
#endif
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <fstream>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <TString.h>
#ifdef HAVE_GIT_REV_H
#include "git-revision.h"
#endif
#include "PMusr.h"
#include "PStartupHandler.h"
#include "PRunDataHandler.h"
#include "PFindRun.h"
struct PAddRunInfo {
std::string fPathFileName{""};
PIntVector fT0;
std::string fFileFormat{""};
};
//--------------------------------------------------------------------------
/**
* <p>Sends the usage description to the standard output.
*/
void addRun_syntax()
{
std::cout << std::endl;
std::cout << "usage0: addRun [--help | -h] | [--version | -v]" << std::endl;
std::cout << "usage1: addRun <options1> -rl <runList>" << std::endl;
std::cout << "usage2: addRun <options2> -in <inputFile>" << std::endl;
std::cout << std::endl;
std::cout << " <options1>:" << std::endl;
std::cout << " -t0 <ival>: <ival> is a comma separted list of global t0-bin's, or" << std::endl;
std::cout << " <ival> is a comma separted list of '-1', then it is assumed that there is a prompt peak." << std::endl;
std::cout << " Under this condition the t0-bin will be determined automatically by" << std::endl;
std::cout << " the position of the max-value of the corresponing histograms." << std::endl;
std::cout << " If t0's are not provided, t0-bin will be taken from the file." << std::endl;
std::cout << " -f <format>: <format> is the output file format to be used." << std::endl;
std::cout << " For supported formats see below." << std::endl;
std::cout << " -y <year> : the year at which runs were measured. Format yyyy." << std::endl;
std::cout << " If not provided, the current year is used." << std::endl;
std::cout << " -i <instrument> : <instrument> is one of gps, ltf, flame, gpd, hifi, dolly, lem" << std::endl;
std::cout << " -m <dev> : <dev> is pta or tdc (only needed for bulk). Default: tdc" << std::endl;
std::cout << " -o <fln> : output file name." << std::endl;
std::cout << " -rl <runList> can be:" << std::endl ;
std::cout << " (i) <run0> <run1> <run2> ... <runN> : run numbers, e.g. 123 124" << std::endl;
std::cout << " (ii) <run0>-<runN> : a range, e.g. 123-125 -> 123 124 125" << std::endl;
std::cout << " (iii) <run0>:<runN>:<step> : a sequence, e.g. 123:127:2 -> 123 125 127" << std::endl;
std::cout << " <step> will give the step width and has to be a positive number!" << std::endl;
std::cout << " a <runList> can also combine (i)-(iii), e.g. 123 128-130 133, etc." << std::endl;
std::cout << std::endl;
std::cout << " <options2>:" << std::endl;
std::cout << " -f <format>: <format> is file format of the output-file to be used." << std::endl;
std::cout << " -o <fln> : output file name." << std::endl;
std::cout << " -in <inputFile>: the file name of the file containing the necessary run information" << std::endl;
std::cout << " to add runs with various t0's, fgb's, lgb's, different years, etc." << std::endl;
std::cout << " The structure of the <inputFile> is:" << std::endl;
std::cout << " Lines starting with a '%' and empty lines are ignored." << std::endl;
std::cout << " A single run needs to provide the following information:" << std::endl;
std::cout << " file <path-name>: needs to be a full path name" << std::endl;
std::cout << " t0 <t0-bin> : needs to be the t0 bin or " << std::endl;
std::cout << " 0 to take the t0 bin from the file, or" << std::endl;
std::cout << " -1 for automatic determination via prompt peak (see above)." << std::endl;
std::cout << " Example:" << std::endl;
std::cout << " % file 1. 6 histos present, hence 6 t0-bins" << std::endl;
std::cout << " file /home/test/data/deltat_tdc_gps_4324.bin" << std::endl;
std::cout << " t0 401, 400, 399, 400, 358, 400" << std::endl;
std::cout << " % file 2, take t0-bins from the file" << std::endl;
std::cout << " file /home/test/data/deltat_tdc_gps_4325.bin" << std::endl;
std::cout << " % file 3, deduce to t0-bin's from the prompt peak" << std::endl;
std::cout << " file /home/test/data/deltat_tdc_gps_4325.bin" << std::endl;
std::cout << " t0 -1, -1, -1, -1, -1, -1" << std::endl;
std::cout << std::endl;
std::cout << " Supported uSR file formats:" << std::endl;
std::cout << " MusrRoot, PSI-BIN, PSI-MDU, MUD, NeXus" << std::endl;
std::cout << std::endl;
}
//--------------------------------------------------------------------------
/**
* <p> check if the requested format is supported.
*
* @param format requested format string
*
* @return true if supported, false otherwise
*/
bool addRun_checkFormat(std::string &format) {
bool result = false;
boost::to_lower(format);
if (format == "psi-bin")
format = "psibin";
if (format == "psi-mud")
format = "psimdu";
if (format == "musrroot") {
result = true;
} else if (format == "psibin") {
result = true;
} else if (format == "psimdu") {
result = true;
} else if (format == "mud") {
result = true;
} else if (format == "nexus") {
result = true;
} else if (format == "root") {
result = true;
}
return result;
}
//--------------------------------------------------------------------------
/**
* <p>Reads the inputFile to extract the necessary information.
* @param fileName
* @param infoVec
* @return
*/
bool addRun_readInputFiles(const std::string fileName, std::vector<PAddRunInfo> &infoVec)
{
PAddRunInfo info;
char buf[256], str[256];
std::ifstream fin(fileName.c_str(), std::ifstream::in);
std::string line;
char *tok{nullptr};
int status, ival;
bool lastWasFile{false};
while (fin.good()) {
fin.getline(buf, 256);
line = buf;
boost::trim_left(line);
if (line.empty())
continue;
if (line[0] == '%')
continue;
strcpy(buf, line.c_str());
tok = strtok(buf, " ");
if (!strcmp(tok, "file")) {
if (lastWasFile) {
infoVec.push_back(info);
info.fPathFileName = "";
info.fT0.clear();
}
tok = strtok(NULL, " ");
if (tok == NULL) {
std::cerr << std::endl;
std::cerr << "**ERROR** found label 'file' without argument." << std::endl;
std::cerr << std::endl;
fin.close();
return false;
}
info.fPathFileName = tok;
lastWasFile = true;
} else if (!strcmp(tok, "t0")) {
while ((tok = strtok(NULL, ",")) != NULL) {
status = sscanf(tok, "%d%s", &ival, str);
if (status != 1) {
std::cerr << std::endl;
std::cerr << "**ERROR** found t0 argument '" << tok << "' which is not a number." << std::endl;
std::cerr << std::endl;
fin.close();
return false;
}
info.fT0.push_back(ival);
}
} else {
std::cerr << std::endl;
std::cerr << "**ERROR** found unrecognized token '" << tok << "'." << std::endl;
std::cerr << std::endl;
fin.close();
return false;
}
}
infoVec.push_back(info);
fin.close();
// checks
for (int i=0; i<infoVec.size(); i++) {
if (infoVec[i].fPathFileName.empty()) {
std::cerr << std::endl;
std::cerr << "**ERROR** something is wrong with the inputFile. Found empty pathName." << std::endl;
std::cerr << std::endl;
return false;
}
}
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Automatically determines the t0-bin. This assumes that there is a
* prompt peak in the data!
*
* @param vec histo data
* @return maximum of the histo data
*/
UInt_t addRun_getPromptPeakPos(PDoubleVector *vec)
{
UInt_t pos=0;
Double_t max=vec->at(0);
for (UInt_t i=0; i<vec->size(); i++) {
if (max < vec->at(i)) {
max = vec->at(i);
pos = i;
}
}
return pos;
}
//--------------------------------------------------------------------------
/**
* <p>Filters the t0 arguments. Allowed is a comma separeted list of
* integers > -2.
*
* @param argc argument counter
* @param argv argument list
* @param idx argument index from which to start
* @param t0 vector
*
* @return true on success, false otherwise
*/
bool addRun_filter_t0(int argc, char *argv[], int &idx, PIntVector &t0)
{
int pos{idx}, status, ival;
PIntVector tt0;
// collect run list string from input
for (int i=idx; i<argc; i++) {
pos = i;
if ((argv[i][0] == '-') && isalpha(argv[i][1])) { // next command
pos = i-1;
break;
} else {
status = sscanf(argv[i], "%d", &ival);
if (status != 1) {
std::cerr << std::endl;
std::cerr << "**ERROR** found t0 value '" << argv[i] << "' which is not an integer." << std::endl;
std::cerr << std::endl;
return false;
}
tt0.push_back(ival);
}
}
// make sure that t0's > -2
for (int i=0; i<tt0.size(); i++) {
if (tt0[i] <= -2) {
std::cerr << std::endl;
std::cerr << "**ERROR** found t0 value '" << tt0[i] << "' which is out-of-range." << std::endl;
std::cerr << std::endl;
return false;
}
}
idx = pos;
t0 = tt0;
return true;
}
//--------------------------------------------------------------------------
/**
* <p>Filters the runList arguments. Allowed are: (i) run1 run2 ... runN
* (ii) runStart-runEnd, and (iii) runStart:runEnd:step
*
* @param argc argument counter
* @param argv argument list
* @param idx argument index from which to start
* @param runList vector
*
* @return true on success, false otherwise
*/
bool addRun_filter_runList(int argc, char *argv[], int &idx, PUIntVector &runList)
{
int pos{idx};
std::string runStr{""};
// collect run list string from input
for (int i=idx; i<argc; i++) {
pos = i;
if ((argv[i][0] == '-') && isalpha(argv[i][1])) { // next command
pos = i-1;
break;
} else {
runStr += argv[i];
runStr += " ";
}
}
// extract run list from string
PStringNumberList rl(runStr);
std::string errMsg{""};
if (!rl.Parse(errMsg)) {
std::cerr << "**ERROR** in run list: -rl " << runStr << std::endl;
std::cerr << errMsg << std::endl;
return false;
}
runList = rl.GetList();
idx = pos;
return true;
}
//--------------------------------------------------------------------------
/**
* <p>addRun is used to add various runs.
*
* @param argc number of input arguments
* @param argv list of input arguments
*
* @return PMUSR_SUCCESS if everthing went smooth, otherwise and error number
*/
int main(int argc, char *argv[])
{
// check for --help or --version
if (argc == 2) {
if (!strncmp(argv[1], "--help", 128) || !strncmp(argv[1], "-h", 128)) {
addRun_syntax();
return PMUSR_SUCCESS;
} else if (!strncmp(argv[1], "--version", 128) || !strncmp(argv[1], "-v", 128)) {
#ifdef HAVE_CONFIG_H
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "addRun version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else
std::cout << std::endl << "addRun version: " << PACKAGE_VERSION << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#endif
#else
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "addRun git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#else
std::cout << std::endl << "addRun version: unkown." << std::endl << std::endl;
#endif
#endif
return PMUSR_SUCCESS;
} else {
std::cerr << std::endl;
std::cerr << "**ERROR** missing required input." << std::endl;
std::cerr << std::endl;
addRun_syntax();
return -1;
}
}
// filter arguments
PIntVector t0;
Int_t ival;
UInt_t yearNum{0};
std::string flnOut{""};
std::string format{""}, year{""}, instrument{""}, dev{"tdc"};
PUIntVector runList;
std::string inputFln{""};
int status;
std::vector<PAddRunInfo> addRunInfo;
for (int i=1; i<argc; i++) {
if (!strcmp(argv[i], "-t0")) {
if (i+1 >= argc) {
std::cerr << std::endl;
std::cerr << "**ERROR** found -t0 without value." << std::endl;
std::cerr << std::endl;
return -1;
}
// deal with run-list here
int idx=i+1;
if (!addRun_filter_t0(argc, argv, idx, t0)) {
return -2;
}
i=idx;
} else if (!strcmp(argv[i], "-f")) {
if (i+1 >= argc) {
std::cerr << std::endl;
std::cerr << "**ERROR** found -f without argument." << std::endl;
std::cerr << std::endl;
return -1;
}
format = argv[i+1];
if (!addRun_checkFormat(format)) {
format = "";
std::cerr << std::endl;
std::cerr << "**ERROR** found -f with unsupported format: '" << format << "'" << std::endl;
std::cerr << std::endl;
return -2;
}
i++;
} else if (!strcmp(argv[i], "-y")) {
if (i+1 >= argc) {
std::cerr << std::endl;
std::cerr << "**ERROR** found -y without value." << std::endl;
std::cerr << std::endl;
return -1;
}
status = sscanf(argv[i+1], "%d", &ival);
if (status != 1) {
std::cerr << std::endl;
std::cerr << "**ERROR** found invalid -y value: " << argv[i+1] << "." << std::endl;
std::cerr << std::endl;
return -2;
}
if (1900 - ival > 0) {
std::cerr << std::endl;
std::cerr << "**ERROR** found invalid -y value: " << argv[i+1] << "." << std::endl;
std::cerr << " Format has to be YYYY." << std::endl;
std::cerr << std::endl;
return -2;
}
yearNum = ival;
year = argv[i+1];
i++;
} else if (!strcmp(argv[i], "-i")) {
if (i+1 >= argc) {
std::cerr << std::endl;
std::cerr << "**ERROR** found -i without argument." << std::endl;
std::cerr << std::endl;
return -1;
}
instrument = argv[i+1];
boost::to_lower(instrument);
i++;
} else if (!strcmp(argv[i], "-m")) {
if (i+1 >= argc) {
std::cerr << std::endl;
std::cerr << "**ERROR** found -m without argument." << std::endl;
std::cerr << std::endl;
return -1;
}
std::string str(argv[i+1]);
boost::to_lower(str);
if ((str != "pta") && (str != "tdc")) {
std::cerr << std::endl;
std::cerr << "**ERROR** found -m with unsupported argument '" << argv[i+1] << "'. Possible arguments are 'pta' or 'tdc'." << std::endl;
std::cerr << std::endl;
return -2;
}
dev = str;
i++;
} else if (!strcmp(argv[i], "-o")) {
if (i+1 >= argc) {
std::cerr << std::endl;
std::cerr << "**ERROR** found -o without argument." << std::endl;
std::cerr << std::endl;
return -1;
}
flnOut = argv[i+1];
i++;
} else if (!strcmp(argv[i], "-rl")) {
if (i+1 >= argc) {
std::cerr << std::endl;
std::cerr << "**ERROR** found -rl without argument." << std::endl;
std::cerr << std::endl;
return -1;
}
// deal with run-list here
int idx=i+1;
if (!addRun_filter_runList(argc, argv, idx, runList)) {
return -2;
}
i=idx;
} else if (!strcmp(argv[i], "-in")) {
if (i+1 >= argc) {
std::cerr << std::endl;
std::cerr << "**ERROR** found -in without argument." << std::endl;
std::cerr << std::endl;
return -1;
}
inputFln = argv[i+1];
i++;
} else { // error
std::cerr << std::endl;
std::cerr << "**ERROR** found unexpected command line element '" << argv[i] << "'" << std::endl;
std::cerr << std::endl;
addRun_syntax();
return -1;
}
}
// test for usage1 or usage2
if (inputFln.empty() && (runList.size() == 0)) {
std::cerr << std::endl;
std::cerr << "**ERROR** essential input for usage1 and usage2 is missing." << std::endl;
std::cerr << std::endl;
addRun_syntax();
return -3;
}
if (!inputFln.empty() && (runList.size() > 0)) {
std::cerr << std::endl;
std::cerr << "**ERROR** cannot decide if usage1 or usage2." << std::endl;
std::cerr << std::endl;
addRun_syntax();
return -3;
}
// read startup file
char startup_path_name[128];
TSAXParser *saxParser = new TSAXParser();
PStartupHandler *startupHandler = new PStartupHandler();
if (!startupHandler->StartupFileFound()) {
std::cerr << std::endl << ">> addRun **WARNING** couldn't find " << startupHandler->GetStartupFilePath().Data();
std::cerr << std::endl;
// clean up
if (saxParser) {
delete saxParser;
saxParser = nullptr;
}
if (startupHandler) {
delete startupHandler;
startupHandler = nullptr;
}
} else {
strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data());
saxParser->ConnectToHandler("PStartupHandler", startupHandler);
//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 PStartupHandler.cpp for the definition)
status = parseXmlFile(saxParser, startup_path_name);
// check for parse errors
if (status) { // error
std::cerr << std::endl << ">> addRun **WARNING** Reading/parsing musrfit_startup.xml failed.";
std::cerr << std::endl;
// clean up
if (saxParser) {
delete saxParser;
saxParser = nullptr;
}
if (startupHandler) {
delete startupHandler;
startupHandler = nullptr;
}
} else {
startupHandler->CheckLists();
}
}
// additional tests needed for usage1 (currently for PSI use only)
if (runList.size() > 0) {
if (t0.empty()) {
std::cout << ">> t0 not provided.";
} else {
std::cout << ">> t0: ";
for (int i=0; i<t0.size(); i++)
std::cout << t0[i] << ", ";
}
std::cout << std::endl;
std::cout << ">> format: " << format << std::endl;
std::cout << ">> year: " << year << std::endl;
std::cout << ">> instrument: " << instrument << std::endl;
std::cout << ">> fln out: " << flnOut << std::endl;
std::cout << ">> runList: ";
for (int i=0; i<runList.size(); i++)
std::cout << runList[i] << ", ";
std::cout << std::endl;
PAddRunInfo addRun;
addRun.fT0 = t0;
addRun.fFileFormat = format;
// construct file names
for (int i=0; i<runList.size(); i++) {
PFindRun findRun(startupHandler->GetDataPathList(), startupHandler->GetRunNameTemplateList(), instrument, yearNum, runList[i]);
if (findRun.FoundPathName()) {
std::cout << ">> found path name: " << findRun.GetPathName() << std::endl;
addRun.fPathFileName = findRun.GetPathName();
addRunInfo.push_back(addRun);
} else {
std::cout << "**WARNING** run: " << runList[i] << " for instrument '" << instrument << "' and year '" << year << "' not found" << std::endl;
}
}
}
// additional tests needed for usage2
if (!inputFln.empty()) {
// check if file exists
if (!boost::filesystem::exists(inputFln)) {
std::cerr << std::endl;
std::cerr << "**ERROR** file '" << inputFln << "' seems not to exist." << std::endl;
std::cerr << std::endl;
return -1;
}
// read input-file and data sets
if (!addRun_readInputFiles(inputFln, addRunInfo)) {
return -2;
}
}
for (int i=0; i<addRunInfo.size(); i++) {
std::cout << ">> run " << i+1 << ": " << std::endl;
std::cout << ">> fln : " << addRunInfo[i].fPathFileName << std::endl;
if (addRunInfo[i].fT0.empty()) {
std::cout << ">> t0 not provided.";
} else {
std::cout << ">> t0: ";
for (int j=0; j<addRunInfo[i].fT0.size(); j++) {
std::cout << addRunInfo[i].fT0[j] << ", ";
}
}
std::cout << std::endl;
}
// load the files
std::vector<PRunDataHandler*> runDataHandler;
runDataHandler.resize(addRunInfo.size());
Bool_t isGood{true};
for (UInt_t i=0; i<runDataHandler.size(); i++) {
if (startupHandler != nullptr) {
runDataHandler[i] = new PRunDataHandler(addRunInfo[i].fPathFileName, addRunInfo[i].fFileFormat, startupHandler->GetDataPathList());
if (runDataHandler[i] == nullptr) {
isGood = false;
std::cerr << std::endl;
std::cerr << "**ERROR** couldn't invoke PRunDataHandler (i=" << i << ")." << std::endl;
std::cerr << std::endl;
break;
}
runDataHandler[i]->ReadData();
if (!runDataHandler[i]->IsAllDataAvailable()) {
isGood = false;
std::cerr << std::endl;
std::cerr << "**ERROR** couldn't read data for PRunDataHandler (i=" << i << ")." << std::endl;
std::cerr << std::endl;
break;
}
} else {
runDataHandler[i] = new PRunDataHandler(addRunInfo[i].fPathFileName, addRunInfo[i].fFileFormat);
if (runDataHandler[i] == nullptr) {
isGood = false;
std::cerr << std::endl;
std::cerr << "**ERROR** couldn't invoke PRunDataHandler (i=" << i << ")." << std::endl;
std::cerr << std::endl;
break;
}
runDataHandler[i]->ReadData();
if (!runDataHandler[i]->IsAllDataAvailable()) {
isGood = false;
std::cerr << std::endl;
std::cerr << "**ERROR** couldn't read data for PRunDataHandler (i=" << i << ")." << std::endl;
std::cerr << std::endl;
break;
}
}
}
// make sure that the number of provided t0's are matching the number of histos from the run-file
// 1st make sure all the runs have the same number run data (==1 here)
PAny2ManyInfo *info{nullptr};
PRunDataHandler *dataOut{nullptr};
if (isGood) {
for (UInt_t i=1; i<runDataHandler.size(); i++) {
if (runDataHandler[0]->GetNoOfRunData() != runDataHandler[i]->GetNoOfRunData()) {
isGood = false;
std::cerr << std::endl;
std::cerr << "**ERROR** can only handle same number of run data per run handler." << std::endl;
std::cerr << std::endl;
break;
}
}
info = new PAny2ManyInfo();
if (info == nullptr) {
std::cerr << std::endl;
std::cerr << "**ERROR** couldn't invoke PAny2ManyInfo." << std::endl;
std::cerr << std::endl;
isGood = false;
}
}
if (isGood) {
// prepare for the new added run data sets
info->outFormat = format;
info->year = year;
info->outFileName = flnOut;
dataOut = new PRunDataHandler(info);
if (dataOut == nullptr) {
std::cerr << std::endl;
std::cerr << "**ERROR** couldn't invoke PRunDataHandler for the output file." << std::endl;
std::cerr << std::endl;
isGood = false;
}
}
if (isGood) {
// check that all runs have the same number of histograms
for (UInt_t i=1; i<runDataHandler.size(); i++) {
if (runDataHandler[0]->GetRunData()->GetNoOfHistos() != runDataHandler[0]->GetRunData()->GetNoOfHistos()) {
std::cerr << std::endl;
std::cerr << "**ERROR** can only add runs with the same number of histograms." << std::endl;
std::cerr << std::endl;
isGood = false;
}
}
}
if (isGood) {
// add all the runs
// take first run as the reference for the data
std::vector<PDoubleVector*> addedHistos;
addedHistos.resize(runDataHandler[0]->GetRunData()->GetNoOfHistos());
for (UInt_t i=0; i<runDataHandler[0]->GetRunData()->GetNoOfHistos(); i++) {
addedHistos[i] = runDataHandler[0]->GetRunData()->GetDataSet(i, false)->GetData();
}
// get the t0's for all the reference histos
PIntVector t0Vec;
t0Vec.resize(runDataHandler[0]->GetRunData()->GetNoOfHistos());
if (addRunInfo[0].fT0.empty()) { // i.e. take t0's from data file
for (UInt_t i=0; i<runDataHandler[0]->GetRunData()->GetNoOfHistos(); i++) {
t0Vec[i] = runDataHandler[0]->GetRunData()->GetT0Bin(i+1);
}
addRunInfo[0].fT0 = t0Vec;
} else { // t0 vector present
// make sure that the number of t0's fit the number of histos
if (addRunInfo[0].fT0.size() < runDataHandler[0]->GetRunData()->GetNoOfHistos()) {
UInt_t counts=runDataHandler[0]->GetRunData()->GetNoOfHistos()-addRunInfo[0].fT0.size();
for (UInt_t i=0; i<counts; i++)
addRunInfo[0].fT0.push_back(0);
}
// check t0 data
for (UInt_t i=0; i<addRunInfo[0].fT0.size(); i++) {
if (addRunInfo[0].fT0[i] == 0) { // get t0 from file
addRunInfo[0].fT0[i] = runDataHandler[0]->GetRunData()->GetT0Bin(i+1);
} else if (addRunInfo[0].fT0[i] == -1) { // get t0 from prompt peak
addRunInfo[0].fT0[i] = addRun_getPromptPeakPos(runDataHandler[0]->GetRunData()->GetDataSet(i, false)->GetData());
}
}
}
// loop over the remaining runs, determine t0's if needed and add the data
for (int i=1; i<runDataHandler.size(); i++) {
// get the t0's for all the histos of a run to be added
PIntVector t0Vec;
t0Vec.resize(runDataHandler[i]->GetRunData()->GetNoOfHistos());
if (addRunInfo[i].fT0.empty()) { // i.e. take t0's from data file
for (UInt_t j=0; j<runDataHandler[i]->GetRunData()->GetNoOfHistos(); j++) {
t0Vec[j] = runDataHandler[i]->GetRunData()->GetT0Bin(j+1);
}
addRunInfo[i].fT0 = t0Vec;
} else { // t0 vector present
// make sure that the number of t0's fit the number of histos
if (addRunInfo[i].fT0.size() < runDataHandler[i]->GetRunData()->GetNoOfHistos()) {
UInt_t counts=runDataHandler[i]->GetRunData()->GetNoOfHistos()-addRunInfo[i].fT0.size();
for (UInt_t j=0; j<counts; j++)
addRunInfo[i].fT0.push_back(0);
}
// check t0 data
for (UInt_t j=0; j<addRunInfo[i].fT0.size(); j++) {
if (addRunInfo[i].fT0[j] == 0) { // get t0 from file
addRunInfo[i].fT0[j] = runDataHandler[i]->GetRunData()->GetT0Bin(j+1);
} else if (addRunInfo[i].fT0[j] == -1) { // get t0 from prompt peak
addRunInfo[i].fT0[j] = addRun_getPromptPeakPos(runDataHandler[i]->GetRunData()->GetDataSet(j, false)->GetData());
}
}
}
// calculate the offset due to potential differences in t0's between runs
PIntVector diff;
diff.resize(addRunInfo[i].fT0.size());
for (UInt_t j=0; j<diff.size(); j++) {
diff[j] = addRunInfo[i].fT0[j] - addRunInfo[0].fT0[j];
}
// add all the to be added histos of all remaining runs
PDoubleVector *addData{nullptr};
Int_t idx;
for (int j=0; j<runDataHandler[i]->GetRunData()->GetNoOfHistos(); j++) { // loop over all histos
addData = runDataHandler[i]->GetRunData()->GetDataSet(j, false)->GetData();
for (int k=0; k<addedHistos[j]->size(); k++) { // loop over all elements of a histo
idx = k + diff[j];
if ((idx >= 0) && (idx < addData->size())) {
addedHistos[j]->at(k) += addData->at(idx);
}
}
}
}
// feed all the necessary information for the data file
PRawRunData *rawRunData = new PRawRunData();
rawRunData = runDataHandler[0]->GetRunData(); // copy all
rawRunData->SetGenerator("addRun");
// overwrite the t0 values with the new ones
for (UInt_t i=0; i<rawRunData->GetNoOfHistos(); i++) {
rawRunData->GetDataSet(i, false)->SetTimeZeroBin(addRunInfo[0].fT0[i]);
}
// write histos
for (UInt_t i=0; i<rawRunData->GetNoOfHistos(); i++) {
rawRunData->GetDataSet(i, false)->SetData(*addedHistos[i]);
}
// feed run data handler with new data
if (dataOut->SetRunData(rawRunData)) {
// write output file
dataOut->WriteData();
}
}
// clean up
if (startupHandler) {
delete startupHandler;
}
if (info) {
delete info;
}
if (dataOut) {
delete dataOut;
}
for (int i=0; i<runDataHandler.size(); i++) {
if (runDataHandler[i])
delete runDataHandler[i];
}
runDataHandler.clear();
return PMUSR_SUCCESS;
}

View File

@ -82,6 +82,7 @@ configure_file("PRgeHandler.pc.in" "PRgeHandler.pc" @ONLY)
#--- lib creation ------------------------------------------------------------- #--- lib creation -------------------------------------------------------------
add_library(PMusr SHARED add_library(PMusr SHARED
PFindRun.cpp
PFitter.cpp PFitter.cpp
PFitterFcn.cpp PFitterFcn.cpp
PFourier.cpp PFourier.cpp
@ -195,7 +196,7 @@ endif (OpenMP_FOUND)
target_link_libraries(PUserFcnBase ${ROOT_LIBRARIES}) target_link_libraries(PUserFcnBase ${ROOT_LIBRARIES})
target_link_libraries(PRgeHandler ${Boost_LIBRARIES} ${ROOT_LIBRARIES}) target_link_libraries(PRgeHandler ${Boost_LIBRARIES} ${ROOT_LIBRARIES})
target_link_libraries(PMusr ${DependOnLibs}) target_link_libraries(PMusr ${Boost_LIBRARIES} ${DependOnLibs})
#--- install PUserFcnBase solib ----------------------------------------------- #--- install PUserFcnBase solib -----------------------------------------------
install(TARGETS PUserFcnBase DESTINATION lib) install(TARGETS PUserFcnBase DESTINATION lib)

View File

@ -8,7 +8,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007-2021 by Andreas Suter * * Copyright (C) 2007-2022 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
@ -275,6 +275,21 @@ void PRunDataHandler::ReadData()
else else
fAllDataAvailable = true; fAllDataAvailable = true;
} else if (!fRunPathName.IsWhitespace()) { // i.e. file name triggered } else if (!fRunPathName.IsWhitespace()) { // i.e. file name triggered
if (fFileFormat == "") { // try to guess the file format if fromat hasn't been provided
TString ext=fRunPathName;
Ssiz_t pos=ext.Last('.');
ext.Remove(0, pos+1);
if (!ext.CompareTo("bin", TString::kIgnoreCase))
fFileFormat = "psibin";
else if (!ext.CompareTo("root", TString::kIgnoreCase))
fFileFormat = "musrroot";
else if (!ext.CompareTo("msr", TString::kIgnoreCase))
fFileFormat = "mud";
else if (!ext.CompareTo("nxs", TString::kIgnoreCase))
fFileFormat = "nexus";
else if (!ext.CompareTo("mdu", TString::kIgnoreCase))
fFileFormat = "psimdu";
}
if ((fFileFormat == "MusrRoot") || (fFileFormat == "musrroot")) { if ((fFileFormat == "MusrRoot") || (fFileFormat == "musrroot")) {
fAllDataAvailable = ReadRootFile(); fAllDataAvailable = ReadRootFile();
} else if ((fFileFormat == "NeXus") || (fFileFormat == "nexus")) { } else if ((fFileFormat == "NeXus") || (fFileFormat == "nexus")) {
@ -310,15 +325,102 @@ void PRunDataHandler::ConvertData()
fAllDataAvailable = true; fAllDataAvailable = true;
} }
//--------------------------------------------------------------------------
// SetRunData
//--------------------------------------------------------------------------
/**
* <p>Set a raw run data set.
*
* @param data pointer to the raw run data set
* @param idx index to where to write it.
*
* @return true in case of success, false otherwise.
*/
Bool_t PRunDataHandler::SetRunData(PRawRunData *data, UInt_t idx)
{
if ((idx == 0) && (fData.size() == 0)) {
fData.resize(1);
}
if (idx >= fData.size()) {
std::cerr << std::endl << ">>PRunDataHandler::SetRunData(): **ERROR** idx=" << idx << " is out-of-range (0.." << fData.size() << ")." << std::endl;
return false;
}
fData[idx] = *data;
return true;
}
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// WriteData // WriteData
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* <p>Write data. This routine is used to write a single file. * <p>Write data. This routine is used to write a single file.
*/ */
void PRunDataHandler::WriteData() Bool_t PRunDataHandler::WriteData(TString fileName)
{ {
if ((fAny2ManyInfo == nullptr) && (fileName="")) {
std::cerr << std::endl << ">> PRunDataHandler::WriteData(): **ERROR** insufficient information: no fileName nor fAny2ManyInfo object.";
std::cerr << std::endl << " Cannot write data under this conditions." << std::endl;
return false;
}
// get output file format tag, first try via fAny2ManyInfo
Int_t outTag = A2M_UNDEFINED;
if (fAny2ManyInfo != nullptr) {
if (!fAny2ManyInfo->outFormat.CompareTo("musrroot", TString::kIgnoreCase))
outTag = A2M_MUSR_ROOT;
else if (!fAny2ManyInfo->outFormat.CompareTo("psibin", TString::kIgnoreCase))
outTag = A2M_PSIBIN;
else if (!fAny2ManyInfo->outFormat.CompareTo("psimdu", TString::kIgnoreCase))
outTag = A2M_PSIMDU;
else if (!fAny2ManyInfo->outFormat.CompareTo("mud",TString::kIgnoreCase))
outTag = A2M_MUD;
else if (fAny2ManyInfo->outFormat.BeginsWith("nexus", TString::kIgnoreCase))
outTag = A2M_NEXUS;
else
outTag = A2M_UNDEFINED;
} else { // only fileName is given, try to guess from the extension
// STILL MISSING
}
if (outTag == A2M_UNDEFINED) {
std::cerr << std::endl << ">> PRunDataHandler::WriteData(): **ERROR** no valid output data file format found: '" << fAny2ManyInfo->outFormat.Data() << "'" << std::endl;
return false;
}
Bool_t success{true};
switch (outTag) {
case A2M_MUSR_ROOT:
if (fAny2ManyInfo->outFileName.Length() == 0)
success = WriteMusrRootFile(fileName);
else
success = WriteMusrRootFile(fAny2ManyInfo->outFileName);
break;
case A2M_PSIBIN:
case A2M_PSIMDU:
if (fAny2ManyInfo->outFileName.Length() == 0)
success = WritePsiBinFile(fileName);
else
success = WritePsiBinFile(fAny2ManyInfo->outFileName);
break;
case A2M_MUD:
if (fAny2ManyInfo->outFileName.Length() == 0)
success = WriteMudFile(fileName);
else
success = WriteMudFile(fAny2ManyInfo->outFileName);
break;
case A2M_NEXUS:
if (fAny2ManyInfo->outFileName.Length() == 0)
success = WriteNexusFile(fileName);
else
success = WriteNexusFile(fAny2ManyInfo->outFileName);
break;
default:
break;
}
return success;
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -2683,7 +2785,7 @@ Bool_t PRunDataHandler::ReadPsiBinFile()
Bool_t success; Bool_t success;
// read psi bin file // read psi bin file
status = psiBin.read(fRunPathName.Data()); status = psiBin.Read(fRunPathName.Data());
switch (status) { switch (status) {
case 0: // everything perfect case 0: // everything perfect
success = true; success = true;
@ -2772,32 +2874,32 @@ Bool_t PRunDataHandler::ReadPsiBinFile()
// keep run name // keep run name
runData.SetRunName(fRunName); runData.SetRunName(fRunName);
// get run title // get run title
runData.SetRunTitle(TString(psiBin.get_comment().c_str())); // run title runData.SetRunTitle(TString(psiBin.GetComment().c_str())); // run title
// get run number // get run number
runData.SetRunNumber(psiBin.get_runNumber_int()); runData.SetRunNumber(psiBin.GetRunNumberInt());
// get setup // get setup
runData.SetSetup(TString(psiBin.get_comment().c_str())); runData.SetSetup(TString(psiBin.GetComment().c_str()));
// get sample // get sample
runData.SetSample(TString(psiBin.get_sample().c_str())); runData.SetSample(TString(psiBin.GetSample().c_str()));
// get orientation // get orientation
runData.SetOrientation(TString(psiBin.get_orient().c_str())); runData.SetOrientation(TString(psiBin.GetOrient().c_str()));
// get comment // get comment
runData.SetComment(TString(psiBin.get_comment().c_str())); runData.SetComment(TString(psiBin.GetComment().c_str()));
// set LEM specific information to default value since it is not in the file and not used... // set LEM specific information to default value since it is not in the file and not used...
runData.SetEnergy(PMUSR_UNDEFINED); runData.SetEnergy(PMUSR_UNDEFINED);
runData.SetTransport(PMUSR_UNDEFINED); runData.SetTransport(PMUSR_UNDEFINED);
// get field // get field
Double_t scale = 0.0; Double_t scale = 0.0;
if (psiBin.get_field().rfind("G") != std::string::npos) if (psiBin.GetField().rfind("G") != std::string::npos)
scale = 1.0; scale = 1.0;
if (psiBin.get_field().rfind("T") != std::string::npos) if (psiBin.GetField().rfind("T") != std::string::npos)
scale = 1.0e4; scale = 1.0e4;
status = sscanf(psiBin.get_field().c_str(), "%lf", &dval); status = sscanf(psiBin.GetField().c_str(), "%lf", &dval);
if (status == 1) if (status == 1)
runData.SetField(scale*dval); runData.SetField(scale*dval);
// get temperature // get temperature
PDoubleVector tempVec(psiBin.get_temperatures_vector()); PDoubleVector tempVec(psiBin.GetTemperaturesVector());
PDoubleVector tempDevVec(psiBin.get_devTemperatures_vector()); PDoubleVector tempDevVec(psiBin.GetDevTemperaturesVector());
if ((tempVec.size() > 1) && (tempDevVec.size() > 1) && tempVec[0] && tempVec[1]) { if ((tempVec.size() > 1) && (tempDevVec.size() > 1) && tempVec[0] && tempVec[1]) {
// take only the first two values for now... // take only the first two values for now...
//maybe that's not enough - e.g. in older GPD data I saw the "correct values in the second and third entry..." //maybe that's not enough - e.g. in older GPD data I saw the "correct values in the second and third entry..."
@ -2807,16 +2909,16 @@ Bool_t PRunDataHandler::ReadPsiBinFile()
tempVec.clear(); tempVec.clear();
tempDevVec.clear(); tempDevVec.clear();
} else { } else {
status = sscanf(psiBin.get_temp().c_str(), "%lfK", &dval); status = sscanf(psiBin.GetTemp().c_str(), "%lfK", &dval);
if (status == 1) if (status == 1)
runData.SetTemperature(0, dval, 0.0); runData.SetTemperature(0, dval, 0.0);
} }
// get time resolution (ns) // get time resolution (ns)
runData.SetTimeResolution(psiBin.get_binWidth_ns()); runData.SetTimeResolution(psiBin.GetBinWidthNanoSec());
// get start/stop time // get start/stop time
std::vector<std::string> sDateTime = psiBin.get_timeStart_vector(); std::vector<std::string> sDateTime = psiBin.GetTimeStartVector();
if (sDateTime.size() < 2) { if (sDateTime.size() < 2) {
std::cerr << std::endl << ">> **WARNING** psi-bin file: couldn't obtain run start date/time" << std::endl; std::cerr << std::endl << ">> **WARNING** psi-bin file: couldn't obtain run start date/time" << std::endl;
} }
@ -2830,7 +2932,7 @@ Bool_t PRunDataHandler::ReadPsiBinFile()
runData.SetStartTime(sDateTime[1]); runData.SetStartTime(sDateTime[1]);
sDateTime.clear(); sDateTime.clear();
sDateTime = psiBin.get_timeStop_vector(); sDateTime = psiBin.GetTimeStopVector();
if (sDateTime.size() < 2) { if (sDateTime.size() < 2) {
std::cerr << std::endl << ">> **WARNING** psi-bin file: couldn't obtain run stop date/time" << std::endl; std::cerr << std::endl << ">> **WARNING** psi-bin file: couldn't obtain run stop date/time" << std::endl;
} }
@ -2845,7 +2947,7 @@ Bool_t PRunDataHandler::ReadPsiBinFile()
sDateTime.clear(); sDateTime.clear();
// get t0's // get t0's
PIntVector t0 = psiBin.get_t0_vector(); PIntVector t0 = psiBin.GetT0Vector();
if (t0.empty()) { if (t0.empty()) {
std::cerr << std::endl << ">> **ERROR** psi-bin file: couldn't obtain any t0's"; std::cerr << std::endl << ">> **ERROR** psi-bin file: couldn't obtain any t0's";
@ -2854,7 +2956,7 @@ Bool_t PRunDataHandler::ReadPsiBinFile()
} }
// get first good bin // get first good bin
PIntVector fgb = psiBin.get_firstGood_vector(); PIntVector fgb = psiBin.GetFirstGoodVector();
if (fgb.empty()) { if (fgb.empty()) {
std::cerr << std::endl << ">> **ERROR** psi-bin file: couldn't obtain any fgb's"; std::cerr << std::endl << ">> **ERROR** psi-bin file: couldn't obtain any fgb's";
std::cerr << std::endl; std::cerr << std::endl;
@ -2862,7 +2964,7 @@ Bool_t PRunDataHandler::ReadPsiBinFile()
} }
// get last good bin // get last good bin
PIntVector lgb = psiBin.get_lastGood_vector(); PIntVector lgb = psiBin.GetLastGoodVector();
if (lgb.empty()) { if (lgb.empty()) {
std::cerr << std::endl << ">> **ERROR** psi-bin file: couldn't obtain any lgb's"; std::cerr << std::endl << ">> **ERROR** psi-bin file: couldn't obtain any lgb's";
std::cerr << std::endl; std::cerr << std::endl;
@ -2872,13 +2974,12 @@ Bool_t PRunDataHandler::ReadPsiBinFile()
// fill raw data // fill raw data
PRawRunDataSet dataSet; PRawRunDataSet dataSet;
PDoubleVector histoData; PDoubleVector histoData;
Int_t *histo; std::vector<Int_t> histo;
for (Int_t i=0; i<psiBin.get_numberHisto_int(); i++) { for (Int_t i=0; i<psiBin.GetNumberHistoInt(); i++) {
histo = psiBin.get_histo_array_int(i); histo = psiBin.GetHistoArrayInt(i);
for (Int_t j=0; j<psiBin.get_histoLength_bin(); j++) { for (Int_t j=0; j<psiBin.GetHistoLengthBin(); j++) {
histoData.push_back(histo[j]); histoData.push_back(histo[j]);
} }
delete[] histo;
// estimate T0 from maximum of the data // estimate T0 from maximum of the data
Double_t maxVal = 0.0; Double_t maxVal = 0.0;
@ -2891,7 +2992,7 @@ Bool_t PRunDataHandler::ReadPsiBinFile()
} }
dataSet.Clear(); dataSet.Clear();
dataSet.SetName(psiBin.get_nameHisto(i).c_str()); dataSet.SetName(psiBin.GetNameHisto(i).c_str());
dataSet.SetHistoNo(i+1); // i.e. hist numbering starts at 1 dataSet.SetHistoNo(i+1); // i.e. hist numbering starts at 1
if (i < static_cast<Int_t>(t0.size())) if (i < static_cast<Int_t>(t0.size()))
dataSet.SetTimeZeroBin(t0[i]); dataSet.SetTimeZeroBin(t0[i]);
@ -5195,15 +5296,15 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln)
// fill header information // fill header information
// run number // run number
psibin.put_runNumber_int(fData[0].GetRunNumber()); psibin.PutRunNumberInt(fData[0].GetRunNumber());
// length of histograms // length of histograms
UInt_t histo0 = 1; UInt_t histo0 = 1;
if (fAny2ManyInfo->groupHistoList.size() != 0) { // red/green list found if (fAny2ManyInfo->groupHistoList.size() != 0) { // red/green list found
histo0 = fAny2ManyInfo->groupHistoList[0]+1; // take the first available red/green entry histo0 = fAny2ManyInfo->groupHistoList[0]+1; // take the first available red/green entry
} }
psibin.put_histoLength_bin(static_cast<int>(fData[0].GetDataBin(histo0)->size()/fAny2ManyInfo->rebin)); psibin.PutHistoLengthBin(static_cast<int>(fData[0].GetDataBin(histo0)->size()/fAny2ManyInfo->rebin));
// number of histograms // number of histograms
psibin.put_numberHisto_int(static_cast<int>(fData[0].GetNoOfHistos())); psibin.PutNumberHistoInt(static_cast<int>(fData[0].GetNoOfHistos()));
// run title = sample (10 char) / temp (10 char) / field (10 char) / orientation (10 char) // run title = sample (10 char) / temp (10 char) / field (10 char) / orientation (10 char)
char cstr[11]; char cstr[11];
// sample // sample
@ -5212,35 +5313,35 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln)
else else
strcpy(cstr, "??"); strcpy(cstr, "??");
cstr[10] = '\0'; cstr[10] = '\0';
psibin.put_sample(cstr); psibin.PutSample(cstr);
// temp // temp
if (fData[0].GetNoOfTemperatures() > 0) if (fData[0].GetNoOfTemperatures() > 0)
snprintf(cstr, 10, "%.1f K", fData[0].GetTemperature(0)); snprintf(cstr, 10, "%.1f K", fData[0].GetTemperature(0));
else else
strcpy(cstr, "?? K"); strcpy(cstr, "?? K");
cstr[10] = '\0'; cstr[10] = '\0';
psibin.put_temp(cstr); psibin.PutTemp(cstr);
// field // field
if (fData[0].GetField() > 0) if (fData[0].GetField() > 0)
snprintf(cstr, 10, "%.1f G", fData[0].GetField()); snprintf(cstr, 10, "%.1f G", fData[0].GetField());
else else
strcpy(cstr, "?? G"); strcpy(cstr, "?? G");
cstr[10] = '\0'; cstr[10] = '\0';
psibin.put_field(cstr); psibin.PutField(cstr);
// orientation // orientation
if (fData[0].GetOrientation()->Length() > 0) if (fData[0].GetOrientation()->Length() > 0)
strncpy(cstr, fData[0].GetOrientation()->Data(), 10); strncpy(cstr, fData[0].GetOrientation()->Data(), 10);
else else
strcpy(cstr, "??"); strcpy(cstr, "??");
cstr[10] = '\0'; cstr[10] = '\0';
psibin.put_orient(cstr); psibin.PutOrient(cstr);
// setup // setup
if (fData[0].GetSetup()->Length() > 0) if (fData[0].GetSetup()->Length() > 0)
strncpy(cstr, fData[0].GetSetup()->Data(), 10); strncpy(cstr, fData[0].GetSetup()->Data(), 10);
else else
strcpy(cstr, "??"); strcpy(cstr, "??");
cstr[10] = '\0'; cstr[10] = '\0';
psibin.put_setup(cstr); psibin.PutSetup(cstr);
// handle PSI-BIN start/stop Time/Date. PSI-BIN requires: Time -> HH:MM:SS, and Date -> DD-MMM-YY // handle PSI-BIN start/stop Time/Date. PSI-BIN requires: Time -> HH:MM:SS, and Date -> DD-MMM-YY
// internally given: Time -> HH:MM:SS, and Date -> YYYY-MM-DD // internally given: Time -> HH:MM:SS, and Date -> YYYY-MM-DD
@ -5251,7 +5352,7 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln)
int year, month, day; int year, month, day;
// 28-Aug-2014, TP: the following line does not work, it generates the wrong date // 28-Aug-2014, TP: the following line does not work, it generates the wrong date
//dt.Set(fData[0].GetStartDateTime()); //dt.Set(fData[0].GetStartDateTime()); //as35
// the following generates the correct date entry // the following generates the correct date entry
date.Append(*fData[0].GetStartDate()); date.Append(*fData[0].GetStartDate());
sscanf((const char*)date.Data(),"%04d-%02d-%02d", &year, &month, &day); sscanf((const char*)date.Data(),"%04d-%02d-%02d", &year, &month, &day);
@ -5268,7 +5369,7 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln)
strncpy(cstr, fData[0].GetStartTime()->Data(), 8); strncpy(cstr, fData[0].GetStartTime()->Data(), 8);
cstr[8] = '\0'; cstr[8] = '\0';
svec.push_back(cstr); svec.push_back(cstr);
psibin.put_timeStart_vector(svec); psibin.PutTimeStartVector(svec);
svec.clear(); svec.clear();
// run stop date // run stop date
@ -5291,32 +5392,32 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln)
strncpy(cstr, fData[0].GetStopTime()->Data(), 8); strncpy(cstr, fData[0].GetStopTime()->Data(), 8);
cstr[8] = '\0'; cstr[8] = '\0';
svec.push_back(cstr); svec.push_back(cstr);
psibin.put_timeStop_vector(svec); psibin.PutTimeStopVector(svec);
svec.clear(); svec.clear();
// number of measured temperatures // number of measured temperatures
psibin.put_numberTemperature_int(fData[0].GetNoOfTemperatures()); psibin.PutNumberTemperatureInt(fData[0].GetNoOfTemperatures());
// mean temperatures // mean temperatures
std::vector<double> dvec; std::vector<double> dvec;
for (UInt_t i=0; i<fData[0].GetNoOfTemperatures(); i++) for (UInt_t i=0; i<fData[0].GetNoOfTemperatures(); i++)
dvec.push_back(fData[0].GetTemperature(i)); dvec.push_back(fData[0].GetTemperature(i));
psibin.put_temperatures_vector(dvec); psibin.PutTemperaturesVector(dvec);
// standard deviation of temperatures // standard deviation of temperatures
dvec.clear(); dvec.clear();
for (UInt_t i=0; i<fData[0].GetNoOfTemperatures(); i++) for (UInt_t i=0; i<fData[0].GetNoOfTemperatures(); i++)
dvec.push_back(fData[0].GetTempError(i)); dvec.push_back(fData[0].GetTempError(i));
psibin.put_devTemperatures_vector(dvec); psibin.PutDevTemperaturesVector(dvec);
// write comment // write comment
psibin.put_comment(fData[0].GetRunTitle()->Data()); psibin.PutComment(fData[0].GetRunTitle()->Data());
// write time resolution // write time resolution
psibin.put_binWidth_ns(fData[0].GetTimeResolution()*fAny2ManyInfo->rebin); psibin.PutBinWidthNanoSec(fData[0].GetTimeResolution()*fAny2ManyInfo->rebin);
// write scaler dummies // write scaler dummies
psibin.put_numberScaler_int(0); psibin.PutNumberScalerInt(0);
// feed detector related info like, histogram names, t0, fgb, lgb // feed detector related info like, histogram names, t0, fgb, lgb
Int_t ival = 0; Int_t ival = 0;
@ -5334,16 +5435,16 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln)
str = dataSet->GetName(); str = dataSet->GetName();
if (!str.CompareTo("n/a")) if (!str.CompareTo("n/a"))
str.Form("Detector%3d", i+1); str.Form("Detector%3d", i+1);
psibin.put_nameHisto(str.Data(), i); psibin.PutNameHisto(str.Data(), i);
// time zero bin // time zero bin
ival = static_cast<Int_t>(dataSet->GetTimeZeroBin()/fAny2ManyInfo->rebin); ival = static_cast<Int_t>(dataSet->GetTimeZeroBin()/fAny2ManyInfo->rebin);
psibin.put_t0_int(i, ival); psibin.PutT0Int(i, ival);
// first good bin // first good bin
ival = static_cast<Int_t>(dataSet->GetFirstGoodBin()/fAny2ManyInfo->rebin); ival = static_cast<Int_t>(dataSet->GetFirstGoodBin()/fAny2ManyInfo->rebin);
psibin.put_firstGood_int(i, ival); psibin.PutFirstGoodInt(i, ival);
// last good bin // last good bin
ival = static_cast<Int_t>(dataSet->GetLastGoodBin()/fAny2ManyInfo->rebin); ival = static_cast<Int_t>(dataSet->GetLastGoodBin()/fAny2ManyInfo->rebin);
psibin.put_lastGood_int(i, ival); psibin.PutLastGoodInt(i, ival);
} }
// feed histos // feed histos
@ -5386,19 +5487,19 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln)
} }
} }
} }
status = psibin.put_histo_array_int(histos); status = psibin.PutHistoArrayInt(histos, 2); // tag 2 means: lift histo length restriction on only make sure it is < 32512
if (status != 0) { if (status != 0) {
std::cerr << std::endl << ">> PRunDataHandler::WritePsiBinFile(): " << psibin.ConsistencyStatus() << std::endl; std::cerr << std::endl << ">> PRunDataHandler::WritePsiBinFile(): " << psibin.ConsistencyStatus() << std::endl;
return false; return false;
} }
if (!psibin.CheckDataConsistency()) { if (!psibin.CheckDataConsistency(2)) {
std::cerr << std::endl << ">> PRunDataHandler::WritePsiBinFile(): " << psibin.ConsistencyStatus() << std::endl; std::cerr << std::endl << ">> PRunDataHandler::WritePsiBinFile(): " << psibin.ConsistencyStatus() << std::endl;
return false; return false;
} }
// write data to file // write data to file
status = psibin.write(fln.Data()); status = psibin.Write(fln.Data());
if (status != 0) { if (status != 0) {
std::cerr << std::endl << ">> PRunDataHandler::WritePsiBinFile(): " << psibin.WriteStatus() << std::endl; std::cerr << std::endl << ">> PRunDataHandler::WritePsiBinFile(): " << psibin.WriteStatus() << std::endl;
@ -5959,6 +6060,9 @@ TString PRunDataHandler::GenerateOutputFileName(const TString fileName, const TS
TString fln = fileName; TString fln = fileName;
ok = true; ok = true;
if (fAny2ManyInfo == nullptr)
return fln;
// generate output file name if needed // generate output file name if needed
if (!fAny2ManyInfo->useStandardOutput || (fAny2ManyInfo->compressionTag > 0)) { if (!fAny2ManyInfo->useStandardOutput || (fAny2ManyInfo->compressionTag > 0)) {
if (fln.Length() == 0) { if (fln.Length() == 0) {

View File

@ -37,6 +37,8 @@
#include <TObjArray.h> #include <TObjArray.h>
#include <TObjString.h> #include <TObjString.h>
#include <TColor.h> #include <TColor.h>
#include <TList.h>
#include <TXMLAttr.h>
#include "PStartupHandler.h" #include "PStartupHandler.h"
@ -173,6 +175,7 @@ PStartupHandler::~PStartupHandler()
fDataPathList.clear(); fDataPathList.clear();
fMarkerList.clear(); fMarkerList.clear();
fColorList.clear(); fColorList.clear();
fRunNameTemplate.clear();
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -224,6 +227,15 @@ void PStartupHandler::OnStartElement(const Char_t *str, const TList *attributes)
{ {
if (!strcmp(str, "data_path")) { if (!strcmp(str, "data_path")) {
fKey = eDataPath; fKey = eDataPath;
} else if (!strcmp(str, "run_name_template")) {
fKey = eRunNameTemplate;
TXMLAttr *attr;
TIter next(attributes);
while ((attr = (TXMLAttr*) next())) {
if (!strcmp(attr->GetName(), "inst")) {
fCurrentInstrumentName = attr->GetValue();
}
}
} else if (!strcmp(str, "marker")) { } else if (!strcmp(str, "marker")) {
fKey = eMarker; fKey = eMarker;
} else if (!strcmp(str, "color")) { } else if (!strcmp(str, "color")) {
@ -272,12 +284,19 @@ void PStartupHandler::OnCharacters(const Char_t *str)
TString tstr; TString tstr;
Int_t color, r, g, b, ival; Int_t color, r, g, b, ival;
PRunNameTemplate tmpl;
switch (fKey) { switch (fKey) {
case eDataPath: case eDataPath:
// check that str is a valid path // check that str is a valid path
// add str to the path list // add str to the path list
fDataPathList.push_back(str); fDataPathList.push_back(str);
break; break;
case eRunNameTemplate:
tmpl.instrument = fCurrentInstrumentName;
tmpl.runNameTemplate = str;
fRunNameTemplate.push_back(tmpl);
fCurrentInstrumentName="???";
break;
case eMarker: case eMarker:
// check that str is a number // check that str is a number
tstr = TString(str); tstr = TString(str);
@ -636,6 +655,54 @@ Bool_t PStartupHandler::WriteDefaultStartupFile()
fout << " <data_path>/afs/psi.ch/project/bulkmusr/data/alc</data_path>" << std::endl; fout << " <data_path>/afs/psi.ch/project/bulkmusr/data/alc</data_path>" << std::endl;
fout << " <data_path>/afs/psi.ch/project/bulkmusr/data/hifi</data_path>" << std::endl; fout << " <data_path>/afs/psi.ch/project/bulkmusr/data/hifi</data_path>" << std::endl;
fout << " <data_path>/afs/psi.ch/project/bulkmusr/data/lem</data_path>" << std::endl; fout << " <data_path>/afs/psi.ch/project/bulkmusr/data/lem</data_path>" << std::endl;
fout << " <!-- Dolly/PSI -->" << std::endl;
fout << " <run_name_template inst=\"dolly\">d%yyyy%/pie1/deltat_flc_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"dolly\">d%yyyy%/pie3/deltat_flc_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"dolly\">d%yyyy%/deltat_flc_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"dolly\">d%yyyy%/deltat_pta_dolly_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"dolly\">d%yyyy%/pta/deltat_pta_dolly_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"dolly\">d%yyyy%/pta/deltat_pta_dolly_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"dolly\">d%yyyy%/tdc/deltat_tdc_dolly_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"dolly\">d%yyyy%/tdc/root/deltat_tdc_dolly_%rrrr%.root</run_name_template>" << std::endl;
fout << " <!-- Flame/PSI -->" << std::endl;
fout << " <run_name_template inst=\"flame\">d%yyyy%/tdc/root/deltat_tdc_flame_%yyyy%_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <!-- GPD/PSI -->" << std::endl;
fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_mue1_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_fq_si_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_strobo_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_hp_ni_ht_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_hp_ni_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_ccr2_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_gpd_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_janis_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_janis_gpd_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_pta_gpd_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gpd\">d%yyyy%/tdc/deltat_tdc_gpd_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gpd\">d%yyyy%/tdc/root/deltat_tdc_gpd_%rrrr%.root</run_name_template>" << std::endl;
fout << " <!-- GPS/PSI -->" << std::endl;
fout << " <run_name_template inst=\"gps\">d%yyyy%/deltat_ccr_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gps\">d%yyyy%/deltat_he3_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gps\">d%yyyy%/deltat_stutt_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gps\">d%yyyy%/deltat_ltf_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gps\">d%yyyy%/deltat_flc_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gps\">d%yyyy%/deltat_flc2_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gps\">d%yyyy%/deltat_oven_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gps\">d%yyyy%/deltat_oven2_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gps\">d%yyyy%/deltat_pta_gps_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gps\">d%yyyy%/tdc/deltat_tdc_gps_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"gps\">d%yyyy%/tdc/root/deltat_tdc_gps_%yyyy%_%rrrr%.root</run_name_template>" << std::endl;
fout << " <!-- HAL-9500/PSI == HIFI/PSI -->" << std::endl;
fout << " <run_name_template inst=\"hifi\">d%yyyy%/tdc/deltat_hifi_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"hifi\">d%yyyy%/tdc/tdc_hifi_%yyyy%_%rrrrr%.mdu</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"hifi\">d%yyyy%/tdc/root/deltat_tdc_hifi_%yyyy%_%rrrr%.mdu</run_name_template>" << std::endl;
fout << " <!-- LTF/PSI -->" << std::endl;
fout << " <run_name_template inst=\"ltf\">d%yyyy%/deltat_ltf_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"ltf\">d%yyyy%/deltat_pta_ltf_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"ltf\">d%yyyy%/pta/deltat_pta_ltf_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"ltf\">d%yyyy%/tdc/deltat_tdc_ltf_%rrrr%.bin</run_name_template>" << std::endl;
fout << " <!-- LEM/PSI -->" << std::endl;
fout << " <run_name_template inst=\"lem\">%yyyy%/lem%yy%_his_%rrrr%.root</run_name_template>" << std::endl;
fout << " <run_name_template inst=\"lem\">d%yyyy%/tdc/lem%yy%_his_%rrrr%.root</run_name_template>" << std::endl;
fout << " <fourier_settings>" << std::endl; fout << " <fourier_settings>" << std::endl;
fout << " <units>Gauss</units>" << std::endl; fout << " <units>Gauss</units>" << std::endl;
fout << " <fourier_power>0</fourier_power>" << std::endl; fout << " <fourier_power>0</fourier_power>" << std::endl;

View File

@ -321,7 +321,7 @@ int dump_header_psi_bin(const std::string fileName, const std::string fileFormat
bool success = false; bool success = false;
// read psi bin file // read psi bin file
status = psiBin.read(fileName.c_str()); status = psiBin.Read(fileName.c_str());
switch (status) { switch (status) {
case 0: // everything perfect case 0: // everything perfect
success = true; success = true;
@ -357,15 +357,15 @@ int dump_header_psi_bin(const std::string fileName, const std::string fileFormat
std::cout << std::endl << "-------------------"; std::cout << std::endl << "-------------------";
std::cout << std::endl << "fileName = " << fileName << ", fileFormat = " << fileFormat; std::cout << std::endl << "fileName = " << fileName << ", fileFormat = " << fileFormat;
std::cout << std::endl << "-------------------"; std::cout << std::endl << "-------------------";
std::cout << std::endl << "Run Title : " << psiBin.get_comment(); std::cout << std::endl << "Run Title : " << psiBin.GetComment();
std::cout << std::endl << "Run Number : " << psiBin.get_runNumber_int(); std::cout << std::endl << "Run Number : " << psiBin.GetRunNumberInt();
vstr = psiBin.get_timeStart_vector(); vstr = psiBin.GetTimeStartVector();
if (vstr.size() < 2) { if (vstr.size() < 2) {
std::cout << std::endl << "**ERROR** couldn't obtain \"Run Start Time\" will quit." << std::endl << std::endl; std::cout << std::endl << "**ERROR** couldn't obtain \"Run Start Time\" will quit." << std::endl << std::endl;
return 1; return 1;
} }
std::cout << std::endl << "Run Start Time : " << vstr[0] << "; " << vstr[1]; std::cout << std::endl << "Run Start Time : " << vstr[0] << "; " << vstr[1];
vstr = psiBin.get_timeStop_vector(); vstr = psiBin.GetTimeStopVector();
if (vstr.size() < 2) { if (vstr.size() < 2) {
std::cout << std::endl << "**ERROR** couldn't obtain \"Run Stop Time\" will quit." << std::endl << std::endl; std::cout << std::endl << "**ERROR** couldn't obtain \"Run Stop Time\" will quit." << std::endl << std::endl;
return 1; return 1;
@ -382,31 +382,31 @@ int dump_header_psi_bin(const std::string fileName, const std::string fileFormat
std::cout << std::endl << "Muon Beam Momentum : " << vstr[2]; std::cout << std::endl << "Muon Beam Momentum : " << vstr[2];
std::cout << std::endl << "Muon Species : " << vstr[3]; std::cout << std::endl << "Muon Species : " << vstr[3];
std::cout << std::endl << "Muon Source : " << vstr[4]; std::cout << std::endl << "Muon Source : " << vstr[4];
std::cout << std::endl << "Setup : " << psiBin.get_comment(); std::cout << std::endl << "Setup : " << psiBin.GetComment();
std::cout << std::endl << "Comment : n/a"; std::cout << std::endl << "Comment : n/a";
std::cout << std::endl << "Sample Name : " << psiBin.get_sample(); std::cout << std::endl << "Sample Name : " << psiBin.GetSample();
std::cout << std::endl << "Sample Orientation : " << psiBin.get_orient(); std::cout << std::endl << "Sample Orientation : " << psiBin.GetOrient();
dVal = psiBin.get_temperatures_vector(); dVal = psiBin.GetTemperaturesVector();
dErrVal = psiBin.get_devTemperatures_vector(); dErrVal = psiBin.GetDevTemperaturesVector();
if (dVal.size() != dErrVal.size()) { if (dVal.size() != dErrVal.size()) {
std::cout << std::endl << "Sample Temperature : " << psiBin.get_temp(); std::cout << std::endl << "Sample Temperature : " << psiBin.GetTemp();
} else { } else {
for (unsigned int i=0; i<dVal.size(); i++) { for (unsigned int i=0; i<dVal.size(); i++) {
std::cout << std::endl << "Sample Temp. " << i+1 << " : " << dVal[i] << " (" << dErrVal[i] << ") K"; std::cout << std::endl << "Sample Temp. " << i+1 << " : " << dVal[i] << " (" << dErrVal[i] << ") K";
} }
} }
std::cout << std::endl << "Sample Mag. Field : " << psiBin.get_field(); std::cout << std::endl << "Sample Mag. Field : " << psiBin.GetField();
std::cout << std::endl << "No of Histos : " << psiBin.get_numberHisto_int(); std::cout << std::endl << "No of Histos : " << psiBin.GetNumberHistoInt();
std::cout << std::endl << "Time Resolution : " << psiBin.get_binWidth_ns() << " ns"; std::cout << std::endl << "Time Resolution : " << psiBin.GetBinWidthNanoSec() << " ns";
for (int i=0; i<psiBin.get_numberHisto_int(); i++) { for (int i=0; i<psiBin.GetNumberHistoInt(); i++) {
std::cout << std::endl << "-------------------"; std::cout << std::endl << "-------------------";
std::cout << std::endl << "Histo No : " << i; std::cout << std::endl << "Histo No : " << i;
std::cout << std::endl << "Histo Name : " << psiBin.get_nameHisto(i); std::cout << std::endl << "Histo Name : " << psiBin.GetNameHisto(i);
std::cout << std::endl << "Histo Length : " << psiBin.get_histoLength_bin(); std::cout << std::endl << "Histo Length : " << psiBin.GetHistoLengthBin();
std::cout << std::endl << "Time Zero Bin : " << psiBin.get_t0_int(i); std::cout << std::endl << "Time Zero Bin : " << psiBin.GetT0Int(i);
std::cout << std::endl << "First Good Bin : " << psiBin.get_firstGood_int(i); std::cout << std::endl << "First Good Bin : " << psiBin.GetFirstGoodInt(i);
std::cout << std::endl << "Last Good Bin : " << psiBin.get_lastGood_int(i); std::cout << std::endl << "Last Good Bin : " << psiBin.GetLastGoodInt(i);
std::cout << std::endl << "No of Events : " << psiBin.get_eventsHisto_long(i); std::cout << std::endl << "No of Events : " << psiBin.GetEventsHistoLong(i);
} }
std::cout << std::endl << "-------------------" << std::endl << std::endl; std::cout << std::endl << "-------------------" << std::endl << std::endl;

View File

@ -822,22 +822,22 @@ typedef struct {
* <p>Holds the informations for the any2many converter program * <p>Holds the informations for the any2many converter program
*/ */
typedef struct { typedef struct {
Bool_t useStandardOutput; ///< flag showing if the converted shall be sent to the standard output Bool_t useStandardOutput{false}; ///< flag showing if the converted shall be sent to the standard output
TString inFormat; ///< holds the information about the input data file format TString inFormat{""}; ///< holds the information about the input data file format
TString outFormat; ///< holds the information about the output data file format TString outFormat{""}; ///< holds the information about the output data file format
TString inTemplate; ///< holds the input file template TString inTemplate{""}; ///< holds the input file template
TString outTemplate; ///< holds the output file template TString outTemplate{""}; ///< holds the output file template
TString year; ///< holds the information about the year to be used TString year{""}; ///< holds the information about the year to be used
PUIntVector runList; ///< holds the run number list to be converted PUIntVector runList; ///< holds the run number list to be converted
PIntVector groupHistoList; ///< holds the histo group list offset (used to define for MusrRoot files, what to be exported) PIntVector groupHistoList; ///< holds the histo group list offset (used to define for MusrRoot files, what to be exported)
PStringVector inFileName; ///< holds the file name of the input data file PStringVector inFileName; ///< holds the file name of the input data file
TString outFileName; ///< holds the output file name TString outFileName{""}; ///< holds the output file name
PStringVector outPathFileName; ///< holds the out path/file name PStringVector outPathFileName; ///< holds the out path/file name
TString outPath; ///< holds the output path TString outPath{""}; ///< holds the output path
UInt_t rebin; ///< holds the number of bins to be packed UInt_t rebin{1}; ///< holds the number of bins to be packed
UInt_t compressionTag; ///< 0=no compression, 1=gzip compression, 2=bzip2 compression UInt_t compressionTag{0}; ///< 0=no compression, 1=gzip compression, 2=bzip2 compression
TString compressFileName; ///< holds the name of the outputfile name in case of compression is used TString compressFileName{""}; ///< holds the name of the outputfile name in case of compression is used
UInt_t idf; ///< IDF version for NeXus files. UInt_t idf{0}; ///< IDF version for NeXus files.
} PAny2ManyInfo; } PAny2ManyInfo;
//------------------------------------------------------------- //-------------------------------------------------------------
@ -874,4 +874,19 @@ class PStringNumberList {
virtual void StripSpaces(); virtual void StripSpaces();
}; };
//-------------------------------------------------------------
/**
* <p> Run name template structure.
*/
typedef struct {
TString instrument{""};
TString runNameTemplate{""};
} PRunNameTemplate;
//-------------------------------------------------------------
/**
* <p>typedef to make to code more readable: list of run name templates.
*/
typedef std::vector<PRunNameTemplate> PRunNameTemplateList;
#endif // _PMUSR_H_ #endif // _PMUSR_H_

View File

@ -53,13 +53,15 @@ class PRunDataHandler
virtual void ReadData(); virtual void ReadData();
virtual void ConvertData(); virtual void ConvertData();
virtual void WriteData(); virtual Bool_t WriteData(TString fileName="");
virtual Bool_t IsAllDataAvailable() const { return fAllDataAvailable; } virtual Bool_t IsAllDataAvailable() const { return fAllDataAvailable; }
virtual PRawRunData* GetRunData(const TString &runName); virtual PRawRunData* GetRunData(const TString &runName);
virtual PRawRunData* GetRunData(const UInt_t idx=0); virtual PRawRunData* GetRunData(const UInt_t idx=0);
virtual Int_t GetNoOfRunData() {return fData.size(); } virtual Int_t GetNoOfRunData() {return fData.size(); }
virtual Bool_t SetRunData(PRawRunData *data, UInt_t idx=0);
private: private:
PMsrHandler *fMsrInfo; ///< pointer to the msr-file handler PMsrHandler *fMsrInfo; ///< pointer to the msr-file handler
PAny2ManyInfo *fAny2ManyInfo; ///< pointer to the any2many data structure PAny2ManyInfo *fAny2ManyInfo; ///< pointer to the any2many data structure

View File

@ -74,12 +74,13 @@ class PStartupHandler : public TObject, public TQObject
virtual void CheckLists(); virtual void CheckLists();
virtual PMsrFourierStructure GetFourierDefaults() { return fFourierDefaults; } ///< returns the Fourier defaults virtual PMsrFourierStructure GetFourierDefaults() { return fFourierDefaults; } ///< returns the Fourier defaults
virtual const PRunNameTemplateList GetRunNameTemplateList() { return fRunNameTemplate; }
virtual const PStringVector GetDataPathList() const { return fDataPathList; } ///< returns the search data path list virtual const PStringVector GetDataPathList() const { return fDataPathList; } ///< returns the search data path list
virtual const PIntVector GetMarkerList() const { return fMarkerList; } ///< returns the marker list virtual const PIntVector GetMarkerList() const { return fMarkerList; } ///< returns the marker list
virtual const PIntVector GetColorList() const { return fColorList; } ///< returns the color list virtual const PIntVector GetColorList() const { return fColorList; } ///< returns the color list
private: private:
enum EKeyWords {eEmpty, eComment, eDataPath, eOptions, enum EKeyWords {eEmpty, eComment, eDataPath, eRunNameTemplate, eOptions,
eFourierSettings, eUnits, eFourierPower, eFourierSettings, eUnits, eFourierPower,
eApodization, ePlot, ePhase, ePhaseIncrement, eApodization, ePlot, ePhase, ePhaseIncrement,
eRootSettings, eMarkerList, eMarker, eRootSettings, eMarkerList, eMarker,
@ -88,8 +89,10 @@ class PStartupHandler : public TObject, public TQObject
Bool_t fStartupFileFound; ///< startup file found flag Bool_t fStartupFileFound; ///< startup file found flag
TString fStartupFilePath; ///< full musrfit_startup.xml startup file paths TString fStartupFilePath; ///< full musrfit_startup.xml startup file paths
TString fCurrentInstrumentName; ///< current instrument name
PMsrFourierStructure fFourierDefaults; ///< Fourier defaults PMsrFourierStructure fFourierDefaults; ///< Fourier defaults
PStringVector fDataPathList; ///< search data path list PStringVector fDataPathList; ///< search data path list
PRunNameTemplateList fRunNameTemplate; ///< run name template vector
PIntVector fMarkerList; ///< marker list PIntVector fMarkerList; ///< marker list
PIntVector fColorList; ///< color list PIntVector fColorList; ///< color list