added any2many, an attempt to write the universial musr-data-file converter. Still some work needed. Added the possibility to show the t0 saved in the data file.
This commit is contained in:
parent
2735116ab7
commit
452018bedf
@ -6,6 +6,10 @@
|
||||
|
||||
changes since 0.8.0
|
||||
===================================
|
||||
NEW any2many: an attempt to write the universial musr-data-file converter. Just started, needs still some work.
|
||||
NEW musrt0: added the possibility to show the t0 saved in the data file 's'. Furthermore added the option
|
||||
--getT0FromPromptPeak, -g with <firstGoodBinOffset>: will, in non-interactive mode estimate the t0's from
|
||||
the prompt peak and write it into the msr-file (MUSR-133).
|
||||
FIXED musrt0 crash for histogram number out of range (MUSR-157)
|
||||
FIXED fixes the inadequate attempt to use log max likelihood fit for asymmetry/non-muSR fit (MUSR-148)
|
||||
CHANGED less strict handling of empty FUNCTION block
|
||||
|
@ -6,13 +6,14 @@ SUBDIRS = external/TLemRunHeader \
|
||||
classes \
|
||||
external
|
||||
|
||||
bin_PROGRAMS = musrfit musrview musrt0 musrparam msr2msr msr2data
|
||||
bin_PROGRAMS = musrfit musrview musrt0 musrparam msr2msr msr2data any2many
|
||||
musrfit_SOURCES = musrfit.cpp
|
||||
musrview_SOURCES = musrview.cpp
|
||||
musrt0_SOURCES = musrt0.cpp
|
||||
musrparam_SOURCES = musrparam.cpp
|
||||
msr2msr_SOURCES = msr2msr.cpp
|
||||
msr2data_SOURCES = msr2data.cpp
|
||||
any2many_SOURCES = any2many.cpp
|
||||
|
||||
xmldir = $(bindir)
|
||||
xml_DATA = musrfit_startup.xml
|
||||
|
436
src/any2many.cpp
Normal file
436
src/any2many.cpp
Normal file
@ -0,0 +1,436 @@
|
||||
/***************************************************************************
|
||||
|
||||
any2many.cpp
|
||||
|
||||
Author: Andreas Suter
|
||||
e-mail: andreas.suter@psi.ch
|
||||
|
||||
$Id$
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 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 <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
using namespace std;
|
||||
|
||||
#include <TString.h>
|
||||
#include <TSAXParser.h>
|
||||
|
||||
#include "PMusr.h"
|
||||
#include "PStartupHandler.h"
|
||||
#include "PRunDataHandler.h"
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Sends the usage description to the standard output.
|
||||
*/
|
||||
void any2many_syntax()
|
||||
{
|
||||
cout << endl << "usage: any2many [--help] : will show this help.";
|
||||
cout << endl << " any2many --version : will show the svn version.";
|
||||
cout << endl << " any2many -I <filename> | -i <runList-input> -c <convert-options> [-p <output-path>] [-o <output>] [-y <year>]";
|
||||
cout << endl << " [-t <in-template> <out-template>] [-s] [-rebin <n>]";
|
||||
cout << endl << " <filename> : a single file name, e.g. 2010/lem10_his_0111.root, but not starting with a '-'";
|
||||
cout << endl << " <runList-input> : a list of run numbers separated by ' ' of the form: <run1> <run2> <run3> etc.";
|
||||
cout << endl << " or a sequence of runs <runStart>-<runEnd>, e.g. 111-222";
|
||||
cout << endl << " <convert-options> : <inFormat> <outFormat>";
|
||||
cout << endl << " <inFormat> : input data file format. Supported formats are:";
|
||||
cout << endl << " PSI-BIN, ROOT (LEM), MUD, NeXuS, PSI-MDU, WKM";
|
||||
cout << endl << " <outFormat>: ouput data file format. Supported formats are:";
|
||||
cout << endl << " PSI-BIN, ROOT (LEM), MUD, NeXuS, MDU, WKM, ASCII";
|
||||
cout << endl << " <output-path> : output path for the converted files. If nothing is given, the current directory will be used,";
|
||||
cout << endl << " unless the option '-s' is used.";
|
||||
cout << endl << " <output> : single output file name. If <input> is a list of runs, this option";
|
||||
cout << endl << " should be omitted since the file names are generated according to the";
|
||||
cout << endl << " run number and the file format, e.g. 111 -> lemyy_his_0111.root, where yy is";
|
||||
cout << endl << " the current year.";
|
||||
cout << endl << " <year> : if the option -y is used, here a year in the form 'yy' can be given, if this";
|
||||
cout << endl << " is the case, any automatic file name generation needs a year, this number will";
|
||||
cout << endl << " be used.";
|
||||
cout << endl << " <in-template>";
|
||||
cout << endl << " <out-template> : template file name. Needed for run-lists in order to generate the proper file names.";
|
||||
cout << endl << " The following template tags can be used: [yy] for year, and [rrrr] for the run number.";
|
||||
cout << endl << " If the run number tag is used, the number of 'r' will give the number of digits used";
|
||||
cout << endl << " with leading zeros, e.g. [rrrrrr] and run numbe 123 will result in 000123.";
|
||||
cout << endl << " The same is true for the year, i.e. [yyyy] will result in something like 1999.";
|
||||
cout << endl << " -s : with this option the output data file will be sent to the standard output.";
|
||||
cout << endl << " <n> : number of bins to be packed";
|
||||
cout << endl;
|
||||
cout << endl << " If the output option '-o' is missing, the output file name will be generated according to the";
|
||||
cout << endl << " input data file name, and the output data format.";
|
||||
cout << endl;
|
||||
cout << endl << "examples:" << endl;
|
||||
cout << endl << " any2many -I 2010/lem10_his_0123.root -c ROOT ASCII -rebin 25";
|
||||
cout << endl << " Will take the LEM ROOT file '2010/lem10_his_0123.root' rebin it with 25 and convert it to ASCII.";
|
||||
cout << endl << " The output file name will be lem10_his_0123.ascii, and the file will be saved in the current directory.";
|
||||
cout << endl << " any2many -i 123 137 -c PSI-BIN MUD -t d[yyyy]/deltat_tdc_gps_[rrrr].bin [rrrrrr].msr -y 2001";
|
||||
cout << endl << " Will take the run 123 and 137, will generate the input file names d2001/deltat_tdc_gps_0123.bin and";
|
||||
cout << endl << " d2001/deltat_tdc_gps_0137.bin, and output file names 000123.msr and 000137.msr";
|
||||
cout << endl << " any2many -i 100-117 -c PSI-MDU ASCII -t d[yyyy]/deltat_tdc_alc_[rrrr].mdu [rrr].ascii -y 2011 -s";
|
||||
cout << endl << " Will take the runs 100 through 117 and convert the PSI-MDU input files to ASCII output and instead of";
|
||||
cout << endl << " saving them into a file, they will be spit to the standard output.";
|
||||
cout << endl << endl;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>any2many is used to convert any musr-data-file format in any other including ascii.
|
||||
*
|
||||
* <b>return:</b>
|
||||
* - PMUSR_SUCCESS if everthing went smooth
|
||||
* - PMUSR_WRONG_STARTUP_SYNTAX if syntax error is encountered
|
||||
*
|
||||
* \param argc number of input arguments
|
||||
* \param argv list of input arguments
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
bool show_syntax = false;
|
||||
int status;
|
||||
PAny2ManyInfo info;
|
||||
PStringVector inputFormat;
|
||||
PStringVector outputFormat;
|
||||
|
||||
// init inputFormat
|
||||
inputFormat.push_back("psi-bin");
|
||||
inputFormat.push_back("root");
|
||||
inputFormat.push_back("mud");
|
||||
inputFormat.push_back("nexus");
|
||||
inputFormat.push_back("psi-mdu");
|
||||
inputFormat.push_back("wkm");
|
||||
|
||||
// init outputFormat
|
||||
outputFormat.push_back("psi-bin");
|
||||
outputFormat.push_back("root");
|
||||
outputFormat.push_back("mud");
|
||||
outputFormat.push_back("nexus");
|
||||
outputFormat.push_back("psi-mdu");
|
||||
outputFormat.push_back("wkm");
|
||||
outputFormat.push_back("ascii");
|
||||
|
||||
// init info structure
|
||||
info.useStandardOutput = false;
|
||||
info.rebin = 1;
|
||||
|
||||
// call any2many without arguments
|
||||
if (argc == 1) {
|
||||
any2many_syntax();
|
||||
return PMUSR_SUCCESS;
|
||||
}
|
||||
|
||||
// call any2many --help or any2many --version
|
||||
if (argc == 2) {
|
||||
if (strstr(argv[1], "--h"))
|
||||
any2many_syntax();
|
||||
else if (strstr(argv[1], "--v"))
|
||||
cout << endl << "any2many version: $Id$" << endl << endl;
|
||||
else {
|
||||
any2many_syntax();
|
||||
return PMUSR_WRONG_STARTUP_SYNTAX;
|
||||
}
|
||||
return PMUSR_SUCCESS;
|
||||
}
|
||||
|
||||
info.outPath = TString("./");
|
||||
|
||||
// handle the other command options
|
||||
Int_t ival;
|
||||
for (int i=1; i<argc; i++) {
|
||||
|
||||
// handle year option
|
||||
if (strstr(argv[i], "-y")) {
|
||||
if (i+1 < argc) {
|
||||
ival=0;
|
||||
status = sscanf(argv[i+1], "%d", &ival);
|
||||
if (status == 1) {
|
||||
info.year = argv[i+1];
|
||||
i++;
|
||||
} else {
|
||||
cerr << endl << ">> any2many **ERROR** found in option '-y' the argument '" << argv[i+1] << "' which is not a number." << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// handle standard output option '-s'
|
||||
if (strstr(argv[i], "-s"))
|
||||
info.useStandardOutput = true;
|
||||
|
||||
// set input option tag
|
||||
if (strstr(argv[i], "-I")) {
|
||||
if (i+1 < argc) {
|
||||
if (argv[i+1][0] == '-') { // something wrong
|
||||
cerr << endl << ">> any2many **ERROR** found input option '-i' with filename " << argv[i+1] << ". This is not allowed." << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
} else {
|
||||
info.inFileName = argv[i+1];
|
||||
i++; // shift input to the proper place
|
||||
}
|
||||
} else {
|
||||
cerr << endl << ">> any2many **ERROR** found input option '-I' without any arguments" << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (strstr(argv[i], "-i")) {
|
||||
if (i+1 < argc) {
|
||||
// first check for run list sequence of the form <runStartNo>-<runEndNo>
|
||||
int startNo, endNo;
|
||||
status = sscanf(argv[i+1], "%d-%d", &startNo, &endNo);
|
||||
if (status == 2) { // this is run list sequence
|
||||
if (endNo < startNo) {
|
||||
ival = startNo;
|
||||
startNo = endNo;
|
||||
endNo = ival;
|
||||
}
|
||||
for (int j=startNo; j<=endNo; j++)
|
||||
info.runList.push_back(j);
|
||||
} else { // check for run list of the form <run1> <run2> ... <runN>
|
||||
bool done = false;
|
||||
int j = i+1;
|
||||
do {
|
||||
status = sscanf(argv[j], "%d", &ival);
|
||||
if (status == 1) {
|
||||
info.runList.push_back(ival);
|
||||
} else {
|
||||
done = true;
|
||||
}
|
||||
j++;
|
||||
} while (!done && (j<argc));
|
||||
}
|
||||
} else {
|
||||
cerr << endl << ">> any2many **ERROR** found input option '-i' without any arguments" << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// check if any valid input option was found
|
||||
if ((info.inFileName.Length() == 0) && (info.runList.size() == 0)) {
|
||||
cerr << endl << ">> any2many **ERROR** found input option '-i' without any valid arguments" << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// set output option tag
|
||||
if (strstr(argv[i], "-o")) {
|
||||
if (i+1 < argc) {
|
||||
info.outFileName = argv[i+1];
|
||||
} else {
|
||||
cerr << endl << ">> any2many **ERROR** found output option '-o' without any argument." << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// set convert option tag
|
||||
if (strstr(argv[i], "-c")) {
|
||||
bool found = false;
|
||||
string sval;
|
||||
if (i+2 < argc) {
|
||||
sval = argv[i+1];
|
||||
found = false;
|
||||
for (unsigned int j=0; j<inputFormat.size(); j++) {
|
||||
if (!inputFormat[j].CompareTo(sval, TString::kIgnoreCase)) {
|
||||
info.inFormat = sval;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
cerr << endl << ">> any2many **ERROR** found unkown input data file format option '" << sval << "'" << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
sval = argv[i+2];
|
||||
found = false;
|
||||
for (unsigned int j=0; j<outputFormat.size(); j++) {
|
||||
if (!outputFormat[j].CompareTo(sval, TString::kIgnoreCase)) {
|
||||
info.outFormat = sval;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
cerr << endl << ">> any2many **ERROR** found unkown output data file format option '" << sval << "'" << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
i += 2; // shift argument position
|
||||
} else {
|
||||
cerr << endl << ">> any2many **ERROR** found option '-c' with missing arguments" << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// filter output path name flag
|
||||
if (strstr(argv[i], "-p")) {
|
||||
if (i+1 < argc) {
|
||||
info.outPath = argv[i+1];
|
||||
} else {
|
||||
cerr << endl << ">> any2many **ERROR** found output option '-p' without any argument." << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// filter out rebinning option
|
||||
if (strstr(argv[i], "-rebin")) {
|
||||
if (i+1 < argc) {
|
||||
status = sscanf(argv[i+1], "%d", &ival);
|
||||
if (status == 1) {
|
||||
info.rebin = ival;
|
||||
} else {
|
||||
cerr << endl << ">> any2many **ERROR** found in option '-rebin " << argv[i+1] << "' which doesn't make any sense." << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
cerr << endl << ">> any2many **ERROR** found output option '-rebin' without any argument." << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// filter out the input/output file template
|
||||
if (strstr(argv[i], "-t")) {
|
||||
if (i+2 < argc) {
|
||||
if ((argv[i+1][0] == '-') || (argv[i+2][0] == '-')) {
|
||||
cerr << endl << ">> any2many **ERROR** found invalid template in option '-t'" << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
info.inTemplate = argv[i+1];
|
||||
info.outTemplate = argv[i+2];
|
||||
i += 2; // shift argument position
|
||||
} else {
|
||||
cerr << endl << ">> any2many **ERROR** found option '-t' with missing arguments" << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
cout << endl << "debug> info.year='" << info.year << "', info.year.length()=" << info.year.Length();
|
||||
cout << endl << "debug> info.useStandardOutput=" << info.useStandardOutput;
|
||||
cout << endl << "debug> info.inFormat=" << info.inFormat;
|
||||
cout << endl << "debug> info.outFormat=" << info.outFormat;
|
||||
cout << endl << "debug> info.outFileName=" << info.outFileName;
|
||||
cout << endl << "debug> info.inFileName=" << info.inFileName;
|
||||
cout << endl << "debug> info.runList=";
|
||||
for (unsigned int i=0; i<info.runList.size(); i++)
|
||||
cout << info.runList[i] << ", ";
|
||||
cout << endl << "debug> info.outPath=" << info.outPath;
|
||||
cout << endl << "debug> info.rebin=" << info.rebin;
|
||||
cout << endl << "debug> info.inTemplate=" << info.inTemplate;
|
||||
cout << endl << "debug> info.outTemplate=" << info.outTemplate;
|
||||
cout << endl;
|
||||
*/
|
||||
|
||||
if (show_syntax) {
|
||||
info.runList.clear();
|
||||
any2many_syntax();
|
||||
return PMUSR_WRONG_STARTUP_SYNTAX;
|
||||
}
|
||||
|
||||
if (!info.inFormat.CompareTo(info.outFormat, TString::kIgnoreCase)) {
|
||||
info.runList.clear();
|
||||
cout << endl << "**INFO** since input data format == output data format, I will not do anything." << endl;
|
||||
return PMUSR_SUCCESS;
|
||||
}
|
||||
|
||||
// read startup file
|
||||
char startup_path_name[128];
|
||||
TSAXParser *saxParser = new TSAXParser();
|
||||
PStartupHandler *startupHandler = new PStartupHandler();
|
||||
if (!startupHandler->StartupFileFound()) {
|
||||
cerr << endl << "**WARNING** couldn't find " << startupHandler->GetStartupFilePath().Data();
|
||||
cerr << endl;
|
||||
// clean up
|
||||
if (saxParser) {
|
||||
delete saxParser;
|
||||
saxParser = 0;
|
||||
}
|
||||
if (startupHandler) {
|
||||
delete startupHandler;
|
||||
startupHandler = 0;
|
||||
}
|
||||
} else {
|
||||
strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data());
|
||||
saxParser->ConnectToHandler("PStartupHandler", startupHandler);
|
||||
status = saxParser->ParseFile(startup_path_name);
|
||||
// check for parse errors
|
||||
if (status) { // error
|
||||
cerr << endl << "**WARNING** reading/parsing musrfit_startup.xml.";
|
||||
cerr << endl;
|
||||
// clean up
|
||||
if (saxParser) {
|
||||
delete saxParser;
|
||||
saxParser = 0;
|
||||
}
|
||||
if (startupHandler) {
|
||||
delete startupHandler;
|
||||
startupHandler = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// read all the necessary runs (raw data)
|
||||
PRunDataHandler *dataHandler = new PRunDataHandler(&info, startupHandler->GetDataPathList());
|
||||
|
||||
bool success = dataHandler->IsAllDataAvailable();
|
||||
if (!success) {
|
||||
cout << endl << ">> any2many **ERROR** Couldn't read all data files, will quit ..." << endl;
|
||||
}
|
||||
|
||||
// clean up
|
||||
info.runList.clear();
|
||||
if (saxParser) {
|
||||
delete saxParser;
|
||||
saxParser = 0;
|
||||
}
|
||||
if (startupHandler) {
|
||||
delete startupHandler;
|
||||
startupHandler = 0;
|
||||
}
|
||||
if (dataHandler) {
|
||||
delete dataHandler;
|
||||
dataHandler = 0;
|
||||
}
|
||||
|
||||
return PMUSR_SUCCESS;
|
||||
}
|
||||
|
||||
// end ---------------------------------------------------------------------
|
||||
|
@ -820,9 +820,11 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
if (fRuns[runNo].GetDataRange(0) >= 0) {
|
||||
fout.width(16);
|
||||
fout << left << "data";
|
||||
for (UInt_t j=0; j<2; j++) {
|
||||
fout.width(8);
|
||||
fout << left << fRuns[runNo].GetDataRange(j);
|
||||
for (UInt_t j=0; j<4; j++) {
|
||||
if (fRuns[runNo].GetDataRange(j) > 0) {
|
||||
fout.width(8);
|
||||
fout << left << fRuns[runNo].GetDataRange(j);
|
||||
}
|
||||
}
|
||||
fout << endl;
|
||||
}
|
||||
|
@ -222,6 +222,7 @@ void PNonMusrRawRunData::AppendSubErrData(const UInt_t idx, const Double_t dval)
|
||||
PRawRunData::PRawRunData()
|
||||
{
|
||||
fRunName = TString("");
|
||||
fRunNumber = -1;
|
||||
fRunTitle = TString("");
|
||||
fSetup = TString("");
|
||||
fField = PMUSR_UNDEFINED;
|
||||
|
@ -90,6 +90,7 @@ void PMusrT0Data::InitData()
|
||||
for (UInt_t i=0; i<fAddT0.size(); i++)
|
||||
fAddT0[i].clear();
|
||||
fAddT0.clear();
|
||||
fT0Data = -1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@ -260,6 +261,7 @@ PMusrT0::PMusrT0()
|
||||
|
||||
fDataAndBkgEnabled = false;
|
||||
fT0Enabled = false;
|
||||
fShowT0DataChannel = false;
|
||||
|
||||
fDataRange[0] = 0;
|
||||
fDataRange[1] = 0;
|
||||
@ -267,6 +269,7 @@ PMusrT0::PMusrT0()
|
||||
fBkgRange[1] = 0;
|
||||
|
||||
fT0Line = 0;
|
||||
fT0DataLine = 0;
|
||||
fFirstBkgLine = 0;
|
||||
fLastBkgLine = 0;
|
||||
fFirstDataLine = 0;
|
||||
@ -297,6 +300,7 @@ PMusrT0::PMusrT0(PMusrT0Data &data) : fMusrT0Data(data)
|
||||
|
||||
fDataAndBkgEnabled = false;
|
||||
fT0Enabled = false;
|
||||
fShowT0DataChannel = false;
|
||||
|
||||
fDataRange[0] = 0;
|
||||
fDataRange[1] = 0;
|
||||
@ -304,6 +308,7 @@ PMusrT0::PMusrT0(PMusrT0Data &data) : fMusrT0Data(data)
|
||||
fBkgRange[1] = 0;
|
||||
|
||||
fT0Line = 0;
|
||||
fT0DataLine = 0;
|
||||
fFirstBkgLine = 0;
|
||||
fLastBkgLine = 0;
|
||||
fFirstDataLine = 0;
|
||||
@ -583,6 +588,10 @@ PMusrT0::~PMusrT0()
|
||||
delete fT0Line;
|
||||
fT0Line = 0;
|
||||
}
|
||||
if (fT0DataLine) {
|
||||
delete fT0DataLine;
|
||||
fT0DataLine = 0;
|
||||
}
|
||||
if (fFirstBkgLine) {
|
||||
delete fFirstBkgLine;
|
||||
fFirstBkgLine = 0;
|
||||
@ -625,7 +634,9 @@ void PMusrT0::Done(Int_t status)
|
||||
* <p>Currently implemented command keys:
|
||||
* - 'q' close the currently shown canvas
|
||||
* - 'Q' quite the application
|
||||
* - 'u' unzoom to the original range
|
||||
* - 'z' zoom to the region aroung t0
|
||||
* - 's' show/hide (toggle) the t0 of the data file (if present)
|
||||
* - 'T' set t0 channel to the estimated t0
|
||||
* - 't' set t0 channel to the current cursor position
|
||||
* - 'b' set first background channel
|
||||
@ -657,6 +668,12 @@ void PMusrT0::HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected)
|
||||
UnZoom();
|
||||
} else if (x == 'z') { // zoom to the region around t0, and the estimated t0
|
||||
ZoomT0();
|
||||
} else if (x == 's') { // show the t0 of the data file (if present)
|
||||
fShowT0DataChannel = !fShowT0DataChannel;
|
||||
if (fShowT0DataChannel)
|
||||
ShowDataFileT0Channel();
|
||||
else
|
||||
HideDataFileT0Channel();
|
||||
} else if (x == 'T') { // set estimated t0 channel
|
||||
SetEstimatedT0Channel();
|
||||
} else if (x == 't') { // set t0 channel
|
||||
@ -835,6 +852,44 @@ void PMusrT0::InitDataAndBkg()
|
||||
fMainCanvas->Update();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// ShowDataFileT0Channel
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Show the t0 channel from the data file (if present).
|
||||
*/
|
||||
void PMusrT0::ShowDataFileT0Channel()
|
||||
{
|
||||
// t0 line
|
||||
Int_t t0Bin = fMusrT0Data.GetT0Data();
|
||||
Double_t max = fHisto->GetMaximum();
|
||||
|
||||
if (!fT0DataLine) {
|
||||
fT0DataLine = new TLine((Double_t)t0Bin, 0.0, (Double_t)t0Bin, max);
|
||||
fT0DataLine->SetLineStyle(1); // solid
|
||||
fT0DataLine->SetLineColor(kOrange-3);
|
||||
fT0DataLine->SetLineWidth(2);
|
||||
fT0DataLine->Draw();
|
||||
}
|
||||
|
||||
fMainCanvas->Update();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// HideDataFileT0Channel
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Hide the t0 channel from the data file (if currently displayed).
|
||||
*/
|
||||
void PMusrT0::HideDataFileT0Channel()
|
||||
{
|
||||
if (fT0DataLine) {
|
||||
delete fT0DataLine;
|
||||
fT0DataLine = 0;
|
||||
}
|
||||
fMainCanvas->Update();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// SetT0Channel
|
||||
//--------------------------------------------------------------------------
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -276,6 +276,7 @@ class PRawRunData {
|
||||
virtual ~PRawRunData();
|
||||
|
||||
virtual const TString* GetRunName() { return &fRunName; }
|
||||
virtual const Int_t GetRunNumber() { return fRunNumber; }
|
||||
virtual const TString* GetRunTitle() { return &fRunTitle; }
|
||||
virtual const TString* GetSetup() { return &fSetup; }
|
||||
virtual const Double_t GetField() { return fField; }
|
||||
@ -299,6 +300,7 @@ class PRawRunData {
|
||||
virtual const PNonMusrRawRunData* GetDataNonMusr() { return &fDataNonMusr; }
|
||||
|
||||
virtual void SetRunName(const TString &str) { fRunName = str; }
|
||||
virtual void SetRunNumber(const Int_t &val) { fRunNumber = val; }
|
||||
virtual void SetRunTitle(const TString str) { fRunTitle = str; }
|
||||
virtual void SetSetup(const TString str) { fSetup = str; }
|
||||
virtual void SetField(const Double_t dval) { fField = dval; }
|
||||
@ -321,6 +323,7 @@ class PRawRunData {
|
||||
|
||||
private:
|
||||
TString fRunName; ///< name of the run
|
||||
Int_t fRunNumber; ///< run number
|
||||
TString fRunTitle; ///< run title
|
||||
TString fSetup; ///< description of the setup of this run
|
||||
Double_t fField; ///< magnetic field value
|
||||
@ -560,4 +563,22 @@ typedef struct {
|
||||
UInt_t fNdf; ///< number of degrees of freedom
|
||||
} PMsrStatisticStructure;
|
||||
|
||||
//-------------------------------------------------------------
|
||||
/**
|
||||
* <p>Holds the informations for the any2many converter program
|
||||
*/
|
||||
typedef struct {
|
||||
Bool_t useStandardOutput; ///< flag showing if the converted shall be sent to the standard output
|
||||
TString inFormat; ///< holds the information about the input data file format
|
||||
TString outFormat; ///< holds the information about the output data file format
|
||||
TString inTemplate; ///< holds the input file template
|
||||
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
|
||||
TString inFileName; ///< holds the file name of the input data file
|
||||
TString outFileName; ///< holds the file name of the output data file
|
||||
TString outPath; ///< holds the output path
|
||||
UInt_t rebin; ///< holds the number of bins to be packed
|
||||
} PAny2ManyInfo;
|
||||
|
||||
#endif // _PMUSR_H_
|
||||
|
@ -82,6 +82,7 @@ class PMusrT0Data {
|
||||
virtual UInt_t GetAddT0Entries() { return fAddT0.size(); }
|
||||
virtual UInt_t GetAddT0Size(UInt_t idx);
|
||||
virtual Int_t GetAddT0(UInt_t addRunIdx, UInt_t idx);
|
||||
virtual Int_t GetT0Data() { return fT0Data; }
|
||||
|
||||
virtual void SetSingleHisto(const Bool_t flag) { fSingleHisto = flag; }
|
||||
virtual void SetRawRunData(const vector<PRawRunData*> rawRunData) { fRawRunData = rawRunData; }
|
||||
@ -93,6 +94,7 @@ class PMusrT0Data {
|
||||
virtual void SetCmdTag(const UInt_t cmdTag) { fCmdTag = cmdTag; }
|
||||
virtual void SetT0(UInt_t val, UInt_t idx);
|
||||
virtual void SetAddT0(UInt_t val, UInt_t addRunIdx, UInt_t idx);
|
||||
virtual void SetT0Data(UInt_t val) { fT0Data = val; }
|
||||
|
||||
private:
|
||||
Bool_t fSingleHisto; ///< true if single histo fit, false for asymmetry fit
|
||||
@ -105,6 +107,7 @@ class PMusrT0Data {
|
||||
Int_t fCmdTag; ///< command tag. 0=get t0, 1=get data-/bkg-range, 2=get t0, and data-/bkg-range
|
||||
PIntVector fT0; ///< holding the t0's of the run
|
||||
vector<PIntVector> fAddT0; ///< holding the t0's of the addruns
|
||||
Int_t fT0Data; ///< holding the t0 found in the current data set
|
||||
};
|
||||
|
||||
|
||||
@ -150,6 +153,7 @@ class PMusrT0 : public TObject, public TQObject
|
||||
Bool_t fDataAndBkgEnabled; ///< enable/disable data and background range handling (necessary in connection with grouping and addrun)
|
||||
Bool_t fT0Enabled; ///< enable/disable t0 handling (necessary in connection with grouping and addrun)
|
||||
Int_t fT0Estimated; ///< estimated t0 value (in bins)
|
||||
Bool_t fShowT0DataChannel;
|
||||
|
||||
// canvas related variables
|
||||
TCanvas *fMainCanvas; ///< main canvas for the graphical user interface
|
||||
@ -161,6 +165,7 @@ class PMusrT0 : public TObject, public TQObject
|
||||
TLatex *fToDoInfo; ///< clear text user instruction string
|
||||
|
||||
TLine *fT0Line; ///< line showing the position of t0
|
||||
TLine *fT0DataLine; ///< line showing the position of t0 found in the data file
|
||||
TLine *fFirstBkgLine; ///< line showing the start of the background
|
||||
TLine *fLastBkgLine; ///< line showing the end of the background
|
||||
TLine *fFirstDataLine; ///< line showing the start of the data (first good data bin)
|
||||
@ -172,6 +177,8 @@ class PMusrT0 : public TObject, public TQObject
|
||||
Int_t fDataRange[2]; ///< data range (first good bin, last good bin)
|
||||
Int_t fBkgRange[2]; ///< background range (first bkg bin, last bkg bin)
|
||||
|
||||
void ShowDataFileT0Channel();
|
||||
void HideDataFileT0Channel();
|
||||
void SetT0Channel();
|
||||
void SetEstimatedT0Channel();
|
||||
void SetDataFirstChannel();
|
||||
|
@ -46,6 +46,7 @@ using namespace std;
|
||||
class PRunDataHandler
|
||||
{
|
||||
public:
|
||||
PRunDataHandler(PAny2ManyInfo *any2ManyInfo, const PStringVector dataPath);
|
||||
PRunDataHandler(PMsrHandler *msrInfo);
|
||||
PRunDataHandler(PMsrHandler *msrInfo, const PStringVector dataPath);
|
||||
virtual ~PRunDataHandler();
|
||||
@ -55,6 +56,7 @@ class PRunDataHandler
|
||||
|
||||
private:
|
||||
PMsrHandler *fMsrInfo; ///< pointer to the msr-file handler
|
||||
PAny2ManyInfo *fAny2ManyInfo; ///< pointer to the any2many data structure
|
||||
PStringVector fDataPath; ///< vector containing all the search paths where to look for data files
|
||||
|
||||
Bool_t fAllDataAvailable; ///< flag indicating if all data sets could be read
|
||||
@ -62,10 +64,12 @@ class PRunDataHandler
|
||||
TString fRunPathName; ///< current path file name
|
||||
PRawRunDataList fData; ///< keeping all the raw data
|
||||
|
||||
virtual Bool_t ReadFile();
|
||||
virtual Bool_t ReadFilesMsr();
|
||||
virtual Bool_t ReadWriteFilesList();
|
||||
virtual Bool_t FileAlreadyRead(TString runName);
|
||||
virtual Bool_t FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx);
|
||||
virtual Bool_t ReadRootFile(Bool_t notPostPileup);
|
||||
virtual Bool_t FileExistsCheck(const Int_t idx);
|
||||
virtual Bool_t ReadRootFile(UInt_t tag);
|
||||
virtual Bool_t ReadNexusFile();
|
||||
virtual Bool_t ReadWkmFile();
|
||||
virtual Bool_t ReadPsiBinFile();
|
||||
@ -74,11 +78,21 @@ class PRunDataHandler
|
||||
virtual Bool_t ReadAsciiFile();
|
||||
virtual Bool_t ReadDBFile();
|
||||
|
||||
virtual Bool_t WriteRootFile(TString fln="");
|
||||
virtual Bool_t WriteNexusFile(TString fln="");
|
||||
virtual Bool_t WriteWkmFile(TString fln="");
|
||||
virtual Bool_t WritePsiBinFile(TString fln="");
|
||||
virtual Bool_t WritePsiMduFile(TString fln="");
|
||||
virtual Bool_t WriteMudFile(TString fln="");
|
||||
virtual Bool_t WriteAsciiFile(TString fln="");
|
||||
|
||||
virtual Bool_t StripWhitespace(TString &str);
|
||||
virtual Bool_t IsWhitespace(const Char_t *str);
|
||||
virtual Double_t ToDouble(TString &str, Bool_t &ok);
|
||||
virtual Int_t ToInt(TString &str, Bool_t &ok);
|
||||
virtual Int_t GetDataTagIndex(TString &str, const PStringVector* fLabels);
|
||||
|
||||
virtual TString FileNameFromTemplate(TString &fileNameTemplate, Int_t run, TString &year, Bool_t &ok);
|
||||
};
|
||||
|
||||
#endif // _PRUNDATAHANDLER_H_
|
||||
|
431
src/musrt0.cpp
431
src/musrt0.cpp
@ -53,8 +53,12 @@ using namespace std;
|
||||
*/
|
||||
void musrt0_syntax()
|
||||
{
|
||||
cout << endl << "usage: musrt0 <msr-file> | --version | --help";
|
||||
cout << endl << "usage: musrt0 <msr-file> [{--getT0FromPromptPeak | -g} [<firstGoodBinOffset>]] | --version | --help";
|
||||
cout << endl << " <msr-file>: msr input file";
|
||||
cout << endl << " --getT0FromPromptPeak, -g with <firstGoodBinOffset>:";
|
||||
cout << endl << " will, in non-interactive mode estimate the t0's from the prompt peak and write it into the msr-file.";
|
||||
cout << endl << " if <firstGoodBinOffset> is given, to first good bin will be t0+<firstGoodBinOffset>.";
|
||||
cout << endl << " if no <firstGoodBinOffset> is given, only t0 will be set.";
|
||||
cout << endl << " 'musrt0 <msr-file>' will execute musrt0";
|
||||
cout << endl << " 'musrt0' or 'musrt0 --help' will show this help";
|
||||
cout << endl << " 'musrt0 --version' will print the musrt0 version";
|
||||
@ -155,6 +159,28 @@ void musrt0_cleanup(TSAXParser *saxParser, PStartupHandler *startupHandler, PMsr
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* \param data
|
||||
*/
|
||||
Int_t musrt0_getMaxBin(const PDoubleVector *data)
|
||||
{
|
||||
Int_t maxBin = -1;
|
||||
Double_t maxData = -999;
|
||||
|
||||
for (UInt_t i=0; i<data->size(); i++) {
|
||||
if (data->at(i) > maxData) {
|
||||
maxData = data->at(i);
|
||||
maxBin = i;
|
||||
}
|
||||
}
|
||||
|
||||
return maxBin;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>The musrt0 program is used to set graphically t0's, data- and background-ranges.
|
||||
@ -178,6 +204,9 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
Int_t status;
|
||||
Bool_t success = true;
|
||||
Char_t filename[1024];
|
||||
Bool_t getT0FromPromptPeak = false;
|
||||
Bool_t firstGoodBinOffsetPresent = false;
|
||||
Int_t firstGoodBinOffset = 0;
|
||||
|
||||
switch (argc) {
|
||||
case 1:
|
||||
@ -193,13 +222,49 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
} else {
|
||||
// check if filename has extension msr or mlog
|
||||
if (!strstr(argv[1], ".msr")) {
|
||||
cout << endl << "**ERROR** " << argv[1] << " is not a msr-file!" << endl;
|
||||
cerr << endl << "**ERROR** " << argv[1] << " is not a msr-file!" << endl;
|
||||
show_syntax = true;
|
||||
} else {
|
||||
strncpy(filename, argv[1], sizeof(filename));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// check if filename has extension msr or mlog
|
||||
if (!strstr(argv[1], ".msr")) {
|
||||
cerr << endl << "**ERROR** " << argv[1] << " is not a msr-file!" << endl;
|
||||
show_syntax = true;
|
||||
} else {
|
||||
strncpy(filename, argv[1], sizeof(filename));
|
||||
if (!strcmp(argv[2], "-g") || !strcmp(argv[2], "--getT0FromPromptPeak")) {
|
||||
getT0FromPromptPeak = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
// check if filename has extension msr or mlog
|
||||
if (!strstr(argv[1], ".msr")) {
|
||||
cerr << endl << "**ERROR** " << argv[1] << " is not a msr-file!" << endl;
|
||||
show_syntax = true;
|
||||
} else {
|
||||
strncpy(filename, argv[1], sizeof(filename));
|
||||
if (!strcmp(argv[2], "-g") || !strcmp(argv[2], "--getT0FromPromptPeak")) {
|
||||
getT0FromPromptPeak = true;
|
||||
Int_t dval = 0;
|
||||
status = sscanf(argv[3], "%d", &dval);
|
||||
if (status == 1) { // it is a number
|
||||
firstGoodBinOffsetPresent = true;
|
||||
firstGoodBinOffset = dval;
|
||||
} else { // it is not a number
|
||||
cerr << endl << "**ERROR** first good bin offset option found: '" << argv[3] << "', this is not a number." << endl;
|
||||
show_syntax = true;
|
||||
}
|
||||
} else {
|
||||
cerr << endl << "**ERROR** found 4 input arguments, but missing the 'get prompt T0 from peak' option." << endl;
|
||||
show_syntax = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
show_syntax = true;
|
||||
}
|
||||
@ -288,28 +353,290 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (getT0FromPromptPeak) {
|
||||
cout << endl << "debug> in get T0 from peak: firstGoodBinOffset = " << firstGoodBinOffset << endl;
|
||||
|
||||
// set t0's, data-range and bkg-range. There are 4 different cases, namely:
|
||||
// 1. no addruns / no grouping of histos
|
||||
// 2. addruns / no grouping of histos
|
||||
// 3. no addruns / grouping of histos
|
||||
// 4. addruns / grouping of histos
|
||||
// case 1 is different form the others since t0, data-, and bkg-range can be collected for the given histogram
|
||||
// cases 2-4 the procedure will be the following:
|
||||
// 1) set for each given histogram the t0's
|
||||
// 2) build the added up histogram, i.e. add all runs and/or histograms for the msr-run.
|
||||
// 3) set the data-, and bkg-range
|
||||
if (success) {
|
||||
// generate Root application needed for PMusrCanvas
|
||||
TApplication app("App", &argc, argv);
|
||||
Int_t histoNo = -1;
|
||||
UInt_t t0Bin = 0;
|
||||
TString *runName = 0;
|
||||
UInt_t start, end;
|
||||
|
||||
PMusrT0Data musrT0Data;
|
||||
vector<PRawRunData*> rawRunData;
|
||||
PIntVector forwardHistos;
|
||||
PIntVector backwardHistos;
|
||||
// generate vector of all necessary PMusrT0 objects
|
||||
// go through all runs in the msr-file
|
||||
for (UInt_t i=0; i<runList->size(); i++) {
|
||||
switch (runList->at(i).GetFitType()) {
|
||||
case MSR_FITTYPE_SINGLE_HISTO:
|
||||
if ((runList->at(i).GetRunNameSize() == 1) && (runList->at(i).GetForwardHistoNoSize() == 1)) { // no addruns / no grouping
|
||||
// get histo number
|
||||
histoNo = runList->at(i).GetForwardHistoNo()-1;
|
||||
runName = runList->at(i).GetRunName();
|
||||
// get bin position of maximal data
|
||||
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
|
||||
// set t0 to maximum data position
|
||||
runList->at(i).SetT0(t0Bin, 0);
|
||||
// set data range as well if firstGoodBinOffset is given
|
||||
if (firstGoodBinOffsetPresent) {
|
||||
start = t0Bin + firstGoodBinOffset;
|
||||
end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size();
|
||||
runList->at(i).SetDataRange(start, 0);
|
||||
runList->at(i).SetDataRange(end, 1);
|
||||
}
|
||||
} else if ((runList->at(i).GetRunNameSize() > 1) && (runList->at(i).GetForwardHistoNoSize() == 1)) { // addruns / no grouping
|
||||
// get histo number
|
||||
histoNo = runList->at(i).GetForwardHistoNo()-1;
|
||||
runName = runList->at(i).GetRunName();
|
||||
// get bin position of maximal data
|
||||
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
|
||||
// set t0 to maximum data position
|
||||
runList->at(i).SetT0(t0Bin, 0);
|
||||
// set data range as well if firstGoodBinOffset is given
|
||||
if (firstGoodBinOffsetPresent) {
|
||||
start = t0Bin + firstGoodBinOffset;
|
||||
end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size();
|
||||
runList->at(i).SetDataRange(start, 0);
|
||||
runList->at(i).SetDataRange(end, 1);
|
||||
}
|
||||
// handle addruns
|
||||
for (UInt_t j=1; j<runList->at(i).GetRunNameSize(); j++) {
|
||||
runName = runList->at(i).GetRunName(j);
|
||||
// get bin position of maximal data
|
||||
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
|
||||
// set t0 to maximum data position
|
||||
runList->at(i).SetAddT0(t0Bin, j-1, 0);
|
||||
}
|
||||
} else if ((runList->at(i).GetRunNameSize() == 1) && (runList->at(i).GetForwardHistoNoSize() > 1)) { // no addruns / grouping
|
||||
for (UInt_t j=0; j<runList->at(i).GetForwardHistoNoSize(); j++) {
|
||||
// get histo number
|
||||
histoNo = runList->at(i).GetForwardHistoNo(j)-1;
|
||||
runName = runList->at(i).GetRunName();
|
||||
// get bin position of maximal data
|
||||
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
|
||||
// set t0 to maximum data position
|
||||
runList->at(i).SetT0(t0Bin, j);
|
||||
if (firstGoodBinOffsetPresent && (j==0)) {
|
||||
start = t0Bin + firstGoodBinOffset;
|
||||
end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size();
|
||||
runList->at(i).SetDataRange(start, 0);
|
||||
runList->at(i).SetDataRange(end, 1);
|
||||
}
|
||||
}
|
||||
} else { // addruns / grouping
|
||||
for (UInt_t j=0; j<runList->at(i).GetForwardHistoNoSize(); j++) {
|
||||
// get histo number
|
||||
histoNo = runList->at(i).GetForwardHistoNo(j)-1;
|
||||
runName = runList->at(i).GetRunName();
|
||||
// get bin position of maximal data
|
||||
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
|
||||
// set t0 to maximum data position
|
||||
runList->at(i).SetT0(t0Bin, j);
|
||||
if (firstGoodBinOffsetPresent && (j==0)) {
|
||||
start = t0Bin + firstGoodBinOffset;
|
||||
end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size();
|
||||
runList->at(i).SetDataRange(start, 0);
|
||||
runList->at(i).SetDataRange(end, 1);
|
||||
}
|
||||
// handle addruns
|
||||
for (UInt_t k=1; k<runList->at(i).GetRunNameSize(); k++) {
|
||||
runName = runList->at(i).GetRunName(k);
|
||||
// get bin position of maximal data
|
||||
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
|
||||
// set t0 to maximum data position
|
||||
runList->at(i).SetAddT0(t0Bin, k-1, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MSR_FITTYPE_ASYM:
|
||||
if ((runList->at(i).GetRunNameSize() == 1) && (runList->at(i).GetForwardHistoNoSize() == 1)) { // no addruns / no grouping
|
||||
// handle forward histo
|
||||
// get histo number
|
||||
histoNo = runList->at(i).GetForwardHistoNo()-1;
|
||||
runName = runList->at(i).GetRunName();
|
||||
// get bin position of maximal data
|
||||
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
|
||||
// set t0 to maximum data position
|
||||
runList->at(i).SetT0(t0Bin, 0);
|
||||
// set data range as well if firstGoodBinOffset is given
|
||||
if (firstGoodBinOffsetPresent) {
|
||||
start = t0Bin + firstGoodBinOffset;
|
||||
end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size();
|
||||
runList->at(i).SetDataRange(start, 0);
|
||||
runList->at(i).SetDataRange(end, 1);
|
||||
}
|
||||
// handle backward histo
|
||||
// get histo number
|
||||
histoNo = runList->at(i).GetBackwardHistoNo()-1;
|
||||
runName = runList->at(i).GetRunName();
|
||||
// get bin position of maximal data
|
||||
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
|
||||
// set t0 to maximum data position
|
||||
runList->at(i).SetT0(t0Bin, 1);
|
||||
// set data range as well if firstGoodBinOffset is given
|
||||
if (firstGoodBinOffsetPresent) {
|
||||
start = t0Bin + firstGoodBinOffset;
|
||||
end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size();
|
||||
runList->at(i).SetDataRange(start, 2);
|
||||
runList->at(i).SetDataRange(end, 3);
|
||||
}
|
||||
} else if ((runList->at(i).GetRunNameSize() > 1) && (runList->at(i).GetForwardHistoNoSize() == 1)) { // addruns / no grouping
|
||||
// handle forward histo
|
||||
// get histo number
|
||||
histoNo = runList->at(i).GetForwardHistoNo()-1;
|
||||
runName = runList->at(i).GetRunName();
|
||||
// get bin position of maximal data
|
||||
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
|
||||
// set t0 to maximum data position
|
||||
runList->at(i).SetT0(t0Bin, 0);
|
||||
// set data range as well if firstGoodBinOffset is given
|
||||
if (firstGoodBinOffsetPresent) {
|
||||
start = t0Bin + firstGoodBinOffset;
|
||||
end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size();
|
||||
runList->at(i).SetDataRange(start, 0);
|
||||
runList->at(i).SetDataRange(end, 1);
|
||||
}
|
||||
// handle addruns
|
||||
for (UInt_t j=1; j<runList->at(i).GetRunNameSize(); j++) {
|
||||
runName = runList->at(i).GetRunName(j);
|
||||
// get bin position of maximal data
|
||||
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
|
||||
// set t0 to maximum data position
|
||||
runList->at(i).SetAddT0(t0Bin, j-1, 0);
|
||||
}
|
||||
// handle backward histo
|
||||
// get histo number
|
||||
histoNo = runList->at(i).GetBackwardHistoNo()-1;
|
||||
runName = runList->at(i).GetRunName();
|
||||
// get bin position of maximal data
|
||||
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
|
||||
// set t0 to maximum data position
|
||||
runList->at(i).SetT0(t0Bin, 1);
|
||||
// set data range as well if firstGoodBinOffset is given
|
||||
if (firstGoodBinOffsetPresent) {
|
||||
start = t0Bin + firstGoodBinOffset;
|
||||
end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size();
|
||||
runList->at(i).SetDataRange(start, 2);
|
||||
runList->at(i).SetDataRange(end, 3);
|
||||
}
|
||||
// handle addruns
|
||||
for (UInt_t j=1; j<runList->at(i).GetRunNameSize(); j++) {
|
||||
runName = runList->at(i).GetRunName(j);
|
||||
// get bin position of maximal data
|
||||
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
|
||||
// set t0 to maximum data position
|
||||
runList->at(i).SetAddT0(t0Bin, j-1, 1);
|
||||
}
|
||||
} else if ((runList->at(i).GetRunNameSize() == 1) && (runList->at(i).GetForwardHistoNoSize() > 1)) { // no addruns / grouping
|
||||
// handle forward histo
|
||||
for (UInt_t j=0; j<runList->at(i).GetForwardHistoNoSize(); j++) {
|
||||
// get histo number
|
||||
histoNo = runList->at(i).GetForwardHistoNo(j)-1;
|
||||
runName = runList->at(i).GetRunName();
|
||||
// get bin position of maximal data
|
||||
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
|
||||
// set t0 to maximum data position
|
||||
runList->at(i).SetT0(t0Bin, 2*j);
|
||||
if (firstGoodBinOffsetPresent && (j==0)) {
|
||||
start = t0Bin + firstGoodBinOffset;
|
||||
end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size();
|
||||
runList->at(i).SetDataRange(start, 0);
|
||||
runList->at(i).SetDataRange(end, 1);
|
||||
}
|
||||
}
|
||||
// handle backward histo
|
||||
for (UInt_t j=0; j<runList->at(i).GetBackwardHistoNoSize(); j++) {
|
||||
// get histo number
|
||||
histoNo = runList->at(i).GetBackwardHistoNo(j)-1;
|
||||
runName = runList->at(i).GetRunName();
|
||||
// get bin position of maximal data
|
||||
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
|
||||
// set t0 to maximum data position
|
||||
runList->at(i).SetT0(t0Bin, 2*j+1);
|
||||
if (firstGoodBinOffsetPresent && (j==0)) {
|
||||
start = t0Bin + firstGoodBinOffset;
|
||||
end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size();
|
||||
runList->at(i).SetDataRange(start, 2);
|
||||
runList->at(i).SetDataRange(end, 3);
|
||||
}
|
||||
}
|
||||
} else { // addruns / grouping
|
||||
// handle forward histo
|
||||
for (UInt_t j=0; j<runList->at(i).GetForwardHistoNoSize(); j++) {
|
||||
// get histo number
|
||||
histoNo = runList->at(i).GetForwardHistoNo(j)-1;
|
||||
runName = runList->at(i).GetRunName();
|
||||
// get bin position of maximal data
|
||||
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
|
||||
// set t0 to maximum data position
|
||||
runList->at(i).SetT0(t0Bin, 2*j);
|
||||
if (firstGoodBinOffsetPresent && (j==0)) {
|
||||
start = t0Bin + firstGoodBinOffset;
|
||||
end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size();
|
||||
runList->at(i).SetDataRange(start, 0);
|
||||
runList->at(i).SetDataRange(end, 1);
|
||||
}
|
||||
// handle addruns
|
||||
for (UInt_t k=1; k<runList->at(i).GetRunNameSize(); k++) {
|
||||
runName = runList->at(i).GetRunName(k);
|
||||
// get bin position of maximal data
|
||||
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
|
||||
// set t0 to maximum data position
|
||||
runList->at(i).SetAddT0(t0Bin, k-1, 2*j);
|
||||
}
|
||||
}
|
||||
// handle backward histo
|
||||
for (UInt_t j=0; j<runList->at(i).GetBackwardHistoNoSize(); j++) {
|
||||
// get histo number
|
||||
histoNo = runList->at(i).GetBackwardHistoNo(j)-1;
|
||||
runName = runList->at(i).GetRunName();
|
||||
// get bin position of maximal data
|
||||
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
|
||||
// set t0 to maximum data position
|
||||
runList->at(i).SetT0(t0Bin, 2*j+1);
|
||||
if (firstGoodBinOffsetPresent && (j==0)) {
|
||||
start = t0Bin + firstGoodBinOffset;
|
||||
end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size();
|
||||
runList->at(i).SetDataRange(start, 2);
|
||||
runList->at(i).SetDataRange(end, 3);
|
||||
}
|
||||
// handle addruns
|
||||
for (UInt_t k=1; k<runList->at(i).GetRunNameSize(); k++) {
|
||||
runName = runList->at(i).GetRunName(k);
|
||||
// get bin position of maximal data
|
||||
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
|
||||
// set t0 to maximum data position
|
||||
runList->at(i).SetAddT0(t0Bin, k-1, 2*j+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MSR_FITTYPE_MU_MINUS:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// set t0's, data-range and bkg-range. There are 4 different cases, namely:
|
||||
// 1. no addruns / no grouping of histos
|
||||
// 2. addruns / no grouping of histos
|
||||
// 3. no addruns / grouping of histos
|
||||
// 4. addruns / grouping of histos
|
||||
// case 1 is different form the others since t0, data-, and bkg-range can be collected for the given histogram
|
||||
// cases 2-4 the procedure will be the following:
|
||||
// 1) set for each given histogram the t0's
|
||||
// 2) build the added up histogram, i.e. add all runs and/or histograms for the msr-run.
|
||||
// 3) set the data-, and bkg-range
|
||||
if (success) {
|
||||
// generate Root application needed for PMusrCanvas
|
||||
TApplication app("App", &argc, argv);
|
||||
|
||||
PMusrT0Data musrT0Data;
|
||||
vector<PRawRunData*> rawRunData;
|
||||
PIntVector forwardHistos;
|
||||
PIntVector backwardHistos;
|
||||
// generate vector of all necessary PMusrT0 objects
|
||||
for (UInt_t i=0; i<runList->size(); i++) {
|
||||
switch (runList->at(i).GetFitType()) {
|
||||
case MSR_FITTYPE_SINGLE_HISTO:
|
||||
if ((runList->at(i).GetRunNameSize() == 1) && (runList->at(i).GetForwardHistoNoSize() == 1)) { // no addruns / no grouping
|
||||
// feed necessary data
|
||||
@ -318,6 +645,10 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
rawRunData.clear();
|
||||
rawRunData.push_back(dataHandler->GetRunData(*(runList->at(i).GetRunName(0))));
|
||||
musrT0Data.SetRawRunData(rawRunData);
|
||||
// feed data t0 if present
|
||||
if (rawRunData[0]->GetT0Size() > 0) {
|
||||
musrT0Data.SetT0Data(rawRunData[0]->GetT0(runList->at(i).GetForwardHistoNo(0)-1));
|
||||
}
|
||||
musrT0Data.SetRunNo(i);
|
||||
musrT0Data.SetAddRunIdx(0); // no addruns
|
||||
musrT0Data.SetHistoNoIdx(0);
|
||||
@ -332,7 +663,6 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
exit(0);
|
||||
}
|
||||
} else {
|
||||
// get t0's
|
||||
if ((runList->at(i).GetRunNameSize() > 1) && (runList->at(i).GetForwardHistoNoSize() == 1)) { // addruns / no grouping
|
||||
// feed necessary data
|
||||
musrT0Data.InitData();
|
||||
@ -349,6 +679,10 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
rawRunData.push_back(dataHandler->GetRunData(*(runList->at(i).GetRunName(j))));
|
||||
musrT0Data.SetRawRunData(rawRunData);
|
||||
for (UInt_t j=0; j<runList->at(i).GetRunNameSize(); j++) {
|
||||
// feed data t0 if present
|
||||
if (rawRunData[j]->GetT0Size() > 0) {
|
||||
musrT0Data.SetT0Data(rawRunData[j]->GetT0(runList->at(i).GetForwardHistoNo(0)-1));
|
||||
}
|
||||
// feed necessary data
|
||||
musrT0Data.SetAddRunIdx(j); // addruns
|
||||
if (!musrt0_item(app, msrHandler, musrT0Data, j)) {
|
||||
@ -372,6 +706,11 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
musrT0Data.SetRawRunData(rawRunData);
|
||||
musrT0Data.SetAddRunIdx(0);
|
||||
for (UInt_t j=0; j<runList->at(i).GetForwardHistoNoSize(); j++) {
|
||||
// feed data t0 if present
|
||||
if (rawRunData[0]->GetT0Size() > 0) {
|
||||
musrT0Data.SetT0Data(rawRunData[0]->GetT0(runList->at(i).GetForwardHistoNo(j)-1));
|
||||
}
|
||||
// feed necessary data
|
||||
musrT0Data.SetHistoNoIdx(j);
|
||||
if (!musrt0_item(app, msrHandler, musrT0Data, 0)) {
|
||||
musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler);
|
||||
@ -396,6 +735,11 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
for (UInt_t j=0; j<runList->at(i).GetRunNameSize(); j++) { // addrun / grouping
|
||||
musrT0Data.SetAddRunIdx(j); // addruns
|
||||
for (UInt_t k=0; k<runList->at(i).GetForwardHistoNoSize(); k++) { // forward histo grouping
|
||||
// feed data t0 if present
|
||||
if (rawRunData[j]->GetT0Size() > 0) {
|
||||
musrT0Data.SetT0Data(rawRunData[j]->GetT0(runList->at(i).GetForwardHistoNo(k)-1));
|
||||
}
|
||||
// feed necessary data
|
||||
musrT0Data.SetHistoNoIdx(k);
|
||||
if (!musrt0_item(app, msrHandler, musrT0Data, j)) {
|
||||
musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler);
|
||||
@ -427,6 +771,10 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
rawRunData.clear();
|
||||
rawRunData.push_back(dataHandler->GetRunData(*(runList->at(i).GetRunName(0))));
|
||||
musrT0Data.SetRawRunData(rawRunData);
|
||||
// feed data t0 if present
|
||||
if (rawRunData[0]->GetT0Size() > 0) {
|
||||
musrT0Data.SetT0Data(rawRunData[0]->GetT0(runList->at(i).GetForwardHistoNo(0)));
|
||||
}
|
||||
musrT0Data.SetRunNo(i);
|
||||
musrT0Data.SetAddRunIdx(0); // no addruns
|
||||
musrT0Data.SetHistoNoIdx(0);
|
||||
@ -446,6 +794,10 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
rawRunData.clear();
|
||||
rawRunData.push_back(dataHandler->GetRunData(*(runList->at(i).GetRunName(0))));
|
||||
musrT0Data.SetRawRunData(rawRunData);
|
||||
// feed data t0 if present
|
||||
if (rawRunData[0]->GetT0Size() > 0) {
|
||||
musrT0Data.SetT0Data(rawRunData[0]->GetT0(runList->at(i).GetBackwardHistoNo(0)));
|
||||
}
|
||||
musrT0Data.SetRunNo(i);
|
||||
musrT0Data.SetAddRunIdx(0); // no addruns
|
||||
musrT0Data.SetHistoNoIdx(0);
|
||||
@ -477,6 +829,10 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
rawRunData.push_back(dataHandler->GetRunData(*(runList->at(i).GetRunName(j))));
|
||||
musrT0Data.SetRawRunData(rawRunData);
|
||||
for (UInt_t j=0; j<runList->at(i).GetRunNameSize(); j++) {
|
||||
// feed data t0 if present
|
||||
if (rawRunData[j]->GetT0Size() > 0) {
|
||||
musrT0Data.SetT0Data(rawRunData[j]->GetT0(runList->at(i).GetForwardHistoNo(0)-1));
|
||||
}
|
||||
// feed necessary data
|
||||
musrT0Data.SetAddRunIdx(j); // addruns
|
||||
if (!musrt0_item(app, msrHandler, musrT0Data, j)) {
|
||||
@ -499,6 +855,10 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
rawRunData.push_back(dataHandler->GetRunData(*(runList->at(i).GetRunName(j))));
|
||||
musrT0Data.SetRawRunData(rawRunData);
|
||||
for (UInt_t j=0; j<runList->at(i).GetRunNameSize(); j++) {
|
||||
// feed data t0 if present
|
||||
if (rawRunData[j]->GetT0Size() > 0) {
|
||||
musrT0Data.SetT0Data(rawRunData[j]->GetT0(runList->at(i).GetBackwardHistoNo(0)-1));
|
||||
}
|
||||
// feed necessary data
|
||||
musrT0Data.SetAddRunIdx(j); // addruns
|
||||
if (!musrt0_item(app, msrHandler, musrT0Data, j)) {
|
||||
@ -522,6 +882,11 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
musrT0Data.SetRawRunData(rawRunData);
|
||||
musrT0Data.SetAddRunIdx(0);
|
||||
for (UInt_t j=0; j<runList->at(i).GetForwardHistoNoSize(); j++) {
|
||||
// feed data t0 if present
|
||||
if (rawRunData[0]->GetT0Size() > 0) {
|
||||
musrT0Data.SetT0Data(rawRunData[0]->GetT0(runList->at(i).GetForwardHistoNo(j)-1));
|
||||
}
|
||||
// feed necessary data
|
||||
musrT0Data.SetHistoNoIdx(j);
|
||||
if (!musrt0_item(app, msrHandler, musrT0Data, 0)) {
|
||||
musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler);
|
||||
@ -543,6 +908,11 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
musrT0Data.SetRawRunData(rawRunData);
|
||||
musrT0Data.SetAddRunIdx(0);
|
||||
for (UInt_t j=0; j<runList->at(i).GetBackwardHistoNoSize(); j++) {
|
||||
// feed data t0 if present
|
||||
if (rawRunData[0]->GetT0Size() > 0) {
|
||||
musrT0Data.SetT0Data(rawRunData[0]->GetT0(runList->at(i).GetBackwardHistoNo(j)-1));
|
||||
}
|
||||
// feed necessary data
|
||||
musrT0Data.SetHistoNoIdx(j);
|
||||
if (!musrt0_item(app, msrHandler, musrT0Data, 0)) {
|
||||
musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler);
|
||||
@ -567,6 +937,11 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
for (UInt_t j=0; j<runList->at(i).GetRunNameSize(); j++) { // addrun / grouping
|
||||
musrT0Data.SetAddRunIdx(j); // addruns
|
||||
for (UInt_t k=0; k<runList->at(i).GetForwardHistoNoSize(); k++) { // forward histo grouping
|
||||
// feed data t0 if present
|
||||
if (rawRunData[j]->GetT0Size() > 0) {
|
||||
musrT0Data.SetT0Data(rawRunData[j]->GetT0(runList->at(i).GetForwardHistoNo(k)-1));
|
||||
}
|
||||
// feed necessary data
|
||||
musrT0Data.SetHistoNoIdx(k);
|
||||
if (!musrt0_item(app, msrHandler, musrT0Data, j)) {
|
||||
musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler);
|
||||
@ -591,6 +966,11 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
for (UInt_t j=0; j<runList->at(i).GetRunNameSize(); j++) { // addrun / grouping
|
||||
musrT0Data.SetAddRunIdx(j); // addruns
|
||||
for (UInt_t k=0; k<runList->at(i).GetBackwardHistoNoSize(); k++) { // backward histo grouping
|
||||
// feed data t0 if present
|
||||
if (rawRunData[j]->GetT0Size() > 0) {
|
||||
musrT0Data.SetT0Data(rawRunData[j]->GetT0(runList->at(i).GetBackwardHistoNo(k)-1));
|
||||
}
|
||||
// feed necessary data
|
||||
musrT0Data.SetHistoNoIdx(k);
|
||||
if (!musrt0_item(app, msrHandler, musrT0Data, j)) {
|
||||
musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler);
|
||||
@ -626,12 +1006,13 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
// cleanup
|
||||
rawRunData.clear();
|
||||
forwardHistos.clear();
|
||||
backwardHistos.clear();
|
||||
}
|
||||
// cleanup
|
||||
rawRunData.clear();
|
||||
forwardHistos.clear();
|
||||
backwardHistos.clear();
|
||||
}
|
||||
|
||||
// write msr-file
|
||||
|
Loading…
x
Reference in New Issue
Block a user