/*************************************************************************** msr2data.cpp Author: Bastian M. Wojek / Andreas Suter e-mail: andreas.suter@psi.ch ***************************************************************************/ /*************************************************************************** * Copyright (C) 2009-2014 by Bastian M. Wojek / 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. * ***************************************************************************/ // note: msr2data is on purpose implemented in a way that shows string handling can be done solely // using std::string, boost and related standard C++ features // This implies, however, occasionally strange constructs when interoperating with PMusr-classes // which mostly rely on ROOT's TString. #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "git-revision.h" #include "PMusr.h" #include "PMsr2Data.h" #include #include #include #include #include #include using namespace std; #include #include // for to_lower() in std::string using namespace boost::algorithm; #include // for atoi-replacement // #include // for a clean way to check if a file exists //-------------------------------------------------------------------------- /** *

Checks if a string is an integer * *

return: * - true if s is a number string * - false otherwise * * \param s string */ bool isNumber(const string &s) { unsigned int number; try { number = boost::lexical_cast(s); return true; } catch(boost::bad_lexical_cast &) { return false; } } //-------------------------------------------------------------------------- /** *

Sends the usage description to the standard output. */ void msr2data_syntax() { cout << endl << "usage 0: msr2data [--version] | [--help]"; cout << endl << "usage 1: msr2data options"; cout << endl << "usage 2: msr2data options"; cout << endl << "usage 3: msr2data \\[\\] options"; cout << endl << "usage 4: msr2data options"; cout << endl; cout << endl << " can be:"; cout << endl << " (i) , , , ... : run numbers, e.g. 123 124"; cout << endl << " (ii) - : a range, e.g. 123-125 -> 123 124 125"; cout << endl << " (iii) :: : a sequence, e.g. 123:127:2 -> 123 125 127"; cout << endl << " will give the step width and has to be a positive number!"; cout << endl << " a can also combine (i)-(iii), e.g. 123 128-130 133, etc."; cout << endl << " : an ASCII file containing a list of run numbers and optional"; cout << endl << " external parameters is passed to msr2data. For details see"; cout << endl << " the online documentation: http://lmu.web.psi.ch/musrfit/user/MUSR/Msr2Data.html"; cout << endl << " : msr-file extension, e.g. _tf_h13 for the file name 8472_tf_h13.msr"; cout << endl; cout << endl << "options:"; cout << endl << " -o : specify the name of the DB or column-data output file; default: out.db/out.dat"; cout << endl << " if the option '-o none' is used, no output file will be written."; cout << endl << " new : before writing a new output file, delete the contents of any existing file with the same name"; cout << endl << " data : instead of to a DB file the data are written to a simple column structure"; cout << endl << " header : force writing of the file header to the output file"; cout << endl << " noheader : no file header is written to the output file"; cout << endl << " If either none or both of the header options are given, the file header will be written"; cout << endl << " if a new file is created, but not if the output file exists already!"; cout << endl << " nosummary : no additional data from the run data file is written to the output file"; cout << endl << " paramList : option used to select the parameters which shall be exported."; cout << endl << " is a list of parameter numbers to be exported. Allowed lists are:"; cout << endl << " 1-16 will export parameters 1 to 16. 1 3 5 will export parameters 1 3 5."; cout << endl << " A combination of both is possible, e.g. 1-16 19 31 62, and so on."; cout << endl << " fit : invoke musrfit to fit the specified runs"; cout << endl << " All msr input files are assumed to be present, none is newly generated!"; cout << endl << " fit-