From fab7acfedca9caa9cf6c8dcb740bbbd861fac158 Mon Sep 17 00:00:00 2001 From: Thomas Prokscha Date: Fri, 29 May 2015 15:11:04 +0200 Subject: [PATCH] added a group histo selector in any2many for MusrRoot when exporting to a too limited file format as PSI-BIN. --- src/any2many.cpp | 23 +++++++++++++++++++++-- src/classes/PRunDataHandler.cpp | 30 ++++++++++++++++++++++++++++-- src/include/PMusr.h | 1 + 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/any2many.cpp b/src/any2many.cpp index 652b0421..0fb896fa 100644 --- a/src/any2many.cpp +++ b/src/any2many.cpp @@ -54,7 +54,7 @@ using namespace std; void any2many_syntax() { cout << endl << "usage: any2many [--help] : will show this help."; - cout << endl << " any2many --version : will show the svn version."; + cout << endl << " any2many --version : will show the git version."; cout << endl << " any2many -f | -r "; cout << endl << " -c [-p ] [-y ]"; cout << endl << " [-o | -t ] [-s]"; @@ -83,6 +83,10 @@ void any2many_syntax() cout << endl << " NeXus2-HDF4, NeXus2-HDF5, NeXus2-XML, WKM, ASCII"; cout << endl << " Comment: ROOT is superseeded by MusrRoot. If there is not a very good"; cout << endl << " reason, avoid it!"; + cout << endl << " -h : This option is for MusrRoot input files only!"; + cout << endl << " Select the the histo groups to be exported. is a space"; + cout << endl << " separated list of the histo group, e.g. -h 0, 20 will try to export the histo"; + cout << endl << " 0 (NPP) and 20 (PPC)."; cout << endl << " -p : where is the output path for the"; cout << endl << " converted files. If nothing is given, the current directory"; cout << endl << " will be used, unless the option '-s' is used."; @@ -190,7 +194,7 @@ int main(int argc, char *argv[]) // call any2many --help or any2many --version if (argc == 2) { - if (strstr(argv[1], "--h")) + if (!strncmp(argv[1], "--help", 128)) any2many_syntax(); else if (strstr(argv[1], "--v")) { #ifdef HAVE_CONFIG_H @@ -344,6 +348,21 @@ int main(int argc, char *argv[]) show_syntax = true; break; } + } else if (!strcmp(argv[i], "-h")) { // filter histo group list (for MusrRoot and ROOT (LEM) only!) + bool done = false; + int j = i+1; + do { + status = sscanf(argv[j], "%d", &ival); + if (status == 1) { + info.groupHistoList.push_back(ival); + j++; + } else { + done = true; + } + } while (!done && (j= argc) // make sure that counter is still in range + break; } else if (!strcmp(argv[i], "-p")) { // filter output path name flag if (i+1 < argc) { info.outPath = argv[i+1]; diff --git a/src/classes/PRunDataHandler.cpp b/src/classes/PRunDataHandler.cpp index 4347a67d..092a22ff 100644 --- a/src/classes/PRunDataHandler.cpp +++ b/src/classes/PRunDataHandler.cpp @@ -1734,8 +1734,34 @@ Bool_t PRunDataHandler::ReadRootFile() header->Get("RunInfo/RedGreen Offsets", ivec, ok); if (ok) { - redGreenOffsets = ivec; - runData.SetRedGreenOffset(ivec); + // check if any2many is used and a group histo list is defined, if NOT, only take the 0-offset data! + if (fAny2ManyInfo) { // i.e. any2many is called + if (fAny2ManyInfo->groupHistoList.size() == 0) { // NO group list defined -> use only the 0-offset data + redGreenOffsets.push_back(0); + } else { // group list defined + // make sure that the group list elements is a subset of present RedGreen offsets + Bool_t found = false; + Int_t ival; + for (UInt_t i=0; igroupHistoList.size(); i++) { + found = false; + for (UInt_t j=0; jgroupHistoList[i] == ivec[i]) + found = true; + } + if (!found) { + cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** requested histo group " << fAny2ManyInfo->groupHistoList[i]; + cerr << endl << ">> which is NOT present in the data file." << endl; + return false; + } + } + // found all requested histo groups, hence stuff it to the right places + redGreenOffsets = fAny2ManyInfo->groupHistoList; + runData.SetRedGreenOffset(fAny2ManyInfo->groupHistoList); + } + } else { // not any2many, i.e. musrfit, musrview, ... + redGreenOffsets = ivec; + runData.SetRedGreenOffset(ivec); + } } // check further for LEM specific stuff in RunInfo diff --git a/src/include/PMusr.h b/src/include/PMusr.h index 8a501d59..44ca16c7 100644 --- a/src/include/PMusr.h +++ b/src/include/PMusr.h @@ -780,6 +780,7 @@ typedef struct { TString outTemplate; ///< holds the output file template TString year; ///< holds the information about the year to be used PIntVector 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) PStringVector inFileName; ///< holds the file name of the input data file TString outFileName; ///< holds the output file name PStringVector outPathFileName; ///< holds the out path/file name