a more fexible handling of filename list and run list in any2many (see MUSR-166). Still far from production
This commit is contained in:
144
src/any2many.cpp
144
src/any2many.cpp
@ -52,65 +52,61 @@ 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> ";
|
||||
cout << endl << " [-p <output-path>] [-o <output>] [-y <year>]";
|
||||
cout << endl << " [-t <in-template> <out-template>] [-s] [-rebin <n>]";
|
||||
cout << endl << " [-z <compressed>]";
|
||||
cout << endl << " -I <filename> : where <filename> is a single file name,";
|
||||
cout << endl << " e.g. 2010/lem10_his_0111.root, but not starting with a '-'";
|
||||
cout << endl << " -i <runList-input> : where <runList-input> is a list of run numbers";
|
||||
cout << endl << " separated by spaces ' ' of the form: <run1> <run2> <run3>";
|
||||
cout << endl << " etc., or a sequence of runs <runStart>-<runEnd>, e.g. 111-222";
|
||||
cout << endl << " any2many -f <filenameList-input> | -r <runList-input>";
|
||||
cout << endl << " -c <convert-options> [-p <output-path>]";
|
||||
cout << endl << " [-y <year>] [-t <in-template> <out-template>] [-s]";
|
||||
cout << endl << " [-rebin <n>] [-z <compressed>]";
|
||||
cout << endl << " -f <filenameList-input> : where <filenameList-input> is space";
|
||||
cout << endl << " separeted a list of file names (not starting with a '-'),";
|
||||
cout << endl << " e.g. 2010/lem10_his_0111.root 2010/lem10_his_0112.root";
|
||||
cout << endl << " -r <runList-input> : where <runList-input> is a list of run numbers";
|
||||
cout << endl << " separated by spaces ' ' of the form: <run1> <run2> <run3>";
|
||||
cout << endl << " etc., or a sequence of runs <runStart>-<runEnd>, e.g. 111-222";
|
||||
cout << endl << " -c <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 << " 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 << " PSI-BIN, ROOT (LEM), MUD, NeXuS, WKM, ASCII";
|
||||
cout << endl << " -p <output-path> : where <output-path> 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.";
|
||||
cout << endl << " -o <output> : where <output> is a single output file name. If <input>";
|
||||
cout << endl << " is a list of runs, this option should be omitted since the file";
|
||||
cout << endl << " names are generated according to the run number and the file";
|
||||
cout << endl << " format, e.g. 111 -> lemyy_his_0111.root, where yy is the";
|
||||
cout << endl << " current year.";
|
||||
cout << endl << " converted files. If nothing is given, the current directory";
|
||||
cout << endl << " will be used, unless the option '-s' is used.";
|
||||
cout << endl << " -y <year> : if the option -y is used, here a year in the form 'yy' can";
|
||||
cout << endl << " be given, if this is the case, any automatic file name";
|
||||
cout << endl << " generation needs a year, this number will be used.";
|
||||
cout << endl << " be given, if this is the case, any automatic file name";
|
||||
cout << endl << " generation needs a year, this number will be used.";
|
||||
cout << endl << " -t <in-template> <out-template> : ";
|
||||
cout << endl << " <in-/out-template> : template file name. Needed for run-lists in";
|
||||
cout << endl << " order to generate the proper file names. The following template";
|
||||
cout << endl << " 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";
|
||||
cout << endl << " number of digits used with leading zeros, e.g. [rrrrrr] and run";
|
||||
cout << endl << " number 123 will result in 000123. The same is true for the";
|
||||
cout << endl << " year, i.e. [yyyy] will result in something like 1999.";
|
||||
cout << endl << " order to generate the proper file names. The following template";
|
||||
cout << endl << " 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";
|
||||
cout << endl << " number of digits used with leading zeros, e.g. [rrrrrr] and run";
|
||||
cout << endl << " number 123 will result in 000123. The same is true for the";
|
||||
cout << endl << " 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 stdout.";
|
||||
cout << endl << " -rebin <n> : where <n> is the number of bins to be packed";
|
||||
cout << endl << " -z [g|b] <compressed> : where <compressed> is the output file name";
|
||||
cout << endl << " (without extension) of the compressed data collection, and";
|
||||
cout << endl << " 'g' will result in .tar.gz, and 'b' in .tar.bz2 files.";
|
||||
cout << endl << " (without extension) of the compressed data collection, and";
|
||||
cout << endl << " 'g' will result in .tar.gz, and 'b' in .tar.bz2 files.";
|
||||
cout << endl;
|
||||
cout << endl << " If the output option '-o' is missing, the output file name will be";
|
||||
cout << endl << " generated according to the input data file name, and the output data";
|
||||
cout << endl << " format.";
|
||||
cout << endl;
|
||||
cout << endl << "examples:" << endl;
|
||||
cout << endl << " any2many -I 2010/lem10_his_0123.root -c ROOT ASCII -rebin 25";
|
||||
cout << endl << " any2many -f 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";
|
||||
cout << endl << " and convert it to ASCII. The output file name will be";
|
||||
cout << endl << " lem10_his_0123.ascii, and the file will be saved in the current directory." << endl;
|
||||
cout << endl << " any2many -i 123 137 -c PSI-BIN MUD -t d[yyyy]/deltat_tdc_gps_[rrrr].bin \\";
|
||||
cout << endl << " any2many -r 123 137 -c PSI-BIN MUD -t d[yyyy]/deltat_tdc_gps_[rrrr].bin \\";
|
||||
cout << endl << " [rrrrrr].msr -y 2001";
|
||||
cout << endl << " Will take the run 123 and 137, will generate the input file names:";
|
||||
cout << endl << " d2001/deltat_tdc_gps_0123.bin and d2001/deltat_tdc_gps_0137.bin, and";
|
||||
cout << endl << " output file names 000123.msr and 000137.msr" << endl;
|
||||
cout << endl << " any2many -i 100-117 -c PSI-MDU ASCII -t d[yyyy]/deltat_tdc_alc_[rrrr].mdu \\";
|
||||
cout << endl << " any2many -r 100-117 -c PSI-MDU ASCII -t d[yyyy]/deltat_tdc_alc_[rrrr].mdu \\";
|
||||
cout << endl << " [rrr].ascii -y 2011 -s";
|
||||
cout << endl << " Will take the runs 100 through 117 and convert the PSI-MDU input files to";
|
||||
cout << endl << " ASCII output and instead of saving them into a file, they will be spit to";
|
||||
cout << endl << " the standard output." << endl;
|
||||
cout << endl << " any2many -i 100-117 -c NEXUS ROOT -t d[yyyy]/psi_gps_[rrrr].nexus \\";
|
||||
cout << endl << " any2many -r 100-117 -c NEXUS ROOT -t d[yyyy]/psi_gps_[rrrr].nexus \\";
|
||||
cout << endl << " psi_[yyyy]_gps_[rrrr].root -z b psi_gps_run_100to117";
|
||||
cout << endl << " Will take the runs 100 through 117 and convert the PSI-NEXUS input files";
|
||||
cout << endl << " to ROOT output. Afterwards these new files will be collected in a";
|
||||
@ -150,7 +146,6 @@ int main(int argc, char *argv[])
|
||||
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");
|
||||
|
||||
@ -185,7 +180,7 @@ int main(int argc, char *argv[])
|
||||
for (int i=1; i<argc; i++) {
|
||||
|
||||
// handle year option
|
||||
if (strstr(argv[i], "-y")) {
|
||||
if (!strcmp(argv[i], "-y")) {
|
||||
if (i+1 < argc) {
|
||||
ival=0;
|
||||
status = sscanf(argv[i+1], "%d", &ival);
|
||||
@ -204,27 +199,33 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// handle standard output option '-s'
|
||||
if (strstr(argv[i], "-s"))
|
||||
if (!strcmp(argv[i], "-s"))
|
||||
info.useStandardOutput = true;
|
||||
|
||||
// set input option tag
|
||||
if (strstr(argv[i], "-I")) {
|
||||
if (!strcmp(argv[i], "-f")) {
|
||||
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;
|
||||
bool done = false;
|
||||
int j = i+1;
|
||||
do {
|
||||
if (argv[j][0] == '-') { // assuming the next option is found
|
||||
done = true;
|
||||
} else {
|
||||
info.inFileName.push_back(argv[j]);
|
||||
j++; // shift input to the proper place
|
||||
}
|
||||
} while (!done && (j<argc));
|
||||
i = j;
|
||||
if (i >= argc) // make sure that counter is still in range
|
||||
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;
|
||||
cerr << endl << ">> any2many **ERROR** found input option '-f' without any arguments" << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (strstr(argv[i], "-i")) {
|
||||
|
||||
if (!strcmp(argv[i], "-r")) {
|
||||
if (i+1 < argc) {
|
||||
// first check for run list sequence of the form <runStartNo>-<runEndNo>
|
||||
int startNo, endNo;
|
||||
@ -237,6 +238,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
for (int j=startNo; j<=endNo; j++)
|
||||
info.runList.push_back(j);
|
||||
i += 2;
|
||||
} else { // check for run list of the form <run1> <run2> ... <runN>
|
||||
bool done = false;
|
||||
int j = i+1;
|
||||
@ -244,39 +246,31 @@ int main(int argc, char *argv[])
|
||||
status = sscanf(argv[j], "%d", &ival);
|
||||
if (status == 1) {
|
||||
info.runList.push_back(ival);
|
||||
j++;
|
||||
} else {
|
||||
done = true;
|
||||
}
|
||||
j++;
|
||||
} while (!done && (j<argc));
|
||||
i = j;
|
||||
if (i >= argc) // make sure that counter is still in range
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
cerr << endl << ">> any2many **ERROR** found input option '-i' without any arguments" << endl;
|
||||
cerr << endl << ">> any2many **ERROR** found input option '-r' 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;
|
||||
if (info.runList.size() == 0) {
|
||||
cerr << endl << ">> any2many **ERROR** found input option '-r' without any valid arguments" << endl;
|
||||
show_syntax = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// set convert option tag
|
||||
if (strstr(argv[i], "-c")) {
|
||||
if (!strcmp(argv[i], "-c")) {
|
||||
bool found = false;
|
||||
string sval;
|
||||
if (i+2 < argc) {
|
||||
@ -317,7 +311,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// filter output path name flag
|
||||
if (strstr(argv[i], "-p")) {
|
||||
if (!strcmp(argv[i], "-p")) {
|
||||
if (i+1 < argc) {
|
||||
info.outPath = argv[i+1];
|
||||
} else {
|
||||
@ -328,7 +322,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// filter out rebinning option
|
||||
if (strstr(argv[i], "-rebin")) {
|
||||
if (!strcmp(argv[i], "-rebin")) {
|
||||
if (i+1 < argc) {
|
||||
status = sscanf(argv[i+1], "%d", &ival);
|
||||
if (status == 1) {
|
||||
@ -346,7 +340,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// filter out the input/output file template
|
||||
if (strstr(argv[i], "-t")) {
|
||||
if (!strcmp(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;
|
||||
@ -364,7 +358,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// filter out if compression is whished
|
||||
if (strstr(argv[i], "-z")) {
|
||||
if (!strcmp(argv[i], "-z")) {
|
||||
if (i+2 < argc) {
|
||||
if ((argv[i+1][0] == '-') || (argv[i+2][0] == '-')) {
|
||||
cerr << endl << ">> any2many **ERROR** found invalid template in option '-t'" << endl;
|
||||
@ -390,13 +384,23 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
// make sure that either a filenameList or a runList has been provided
|
||||
if ((info.inFileName.size()==0) && (info.runList.size()==0)) {
|
||||
cerr << endl << ">> any2many **ERROR** neither a input filename list, nor a run list was given." << endl;
|
||||
show_syntax = true;
|
||||
}
|
||||
|
||||
// make sure that in/out formats are given
|
||||
if ((info.inFormat.Length() == 0) || (info.outFormat.Length() == 0)) {
|
||||
cerr << endl << ">> any2many **ERROR** conversion information is missing." << endl;
|
||||
show_syntax = true;
|
||||
}
|
||||
|
||||
/*
|
||||
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] << ", ";
|
||||
@ -406,9 +410,9 @@ cout << endl << "debug> info.inTemplate=" << info.inTemplate;
|
||||
cout << endl << "debug> info.outTemplate=" << info.outTemplate;
|
||||
cout << endl << "debug> info.compressionTag=" << info.compressionTag;
|
||||
cout << endl << "debug> info.compressFileName=" << info.compressFileName;
|
||||
cout << endl << "debug> info.outFileList=";
|
||||
for (unsigned int i=0; i<info.outFileList.size(); i++)
|
||||
cout << info.outFileList[i] << ", ";
|
||||
cout << endl << "debug> info.inFileName=";
|
||||
for (unsigned int i=0; i<info.inFileName.size(); i++)
|
||||
cout << info.inFileName[i] << ", ";
|
||||
cout << endl;
|
||||
*/
|
||||
|
||||
|
@ -234,7 +234,7 @@ Bool_t PRunDataHandler::ReadFilesMsr()
|
||||
*/
|
||||
Bool_t PRunDataHandler::ReadWriteFilesList()
|
||||
{
|
||||
if ((fAny2ManyInfo->inFileName.Length() == 0) && (fAny2ManyInfo->runList.size() == 0)) {
|
||||
if ((fAny2ManyInfo->inFileName.size() == 0) && (fAny2ManyInfo->runList.size() == 0)) {
|
||||
cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't obtain run list from fAny2ManyInfo: something VERY fishy";
|
||||
cerr << endl;
|
||||
return false;
|
||||
@ -268,8 +268,6 @@ Bool_t PRunDataHandler::ReadWriteFilesList()
|
||||
outTag = A2M_ROOT;
|
||||
else if (!fAny2ManyInfo->outFormat.CompareTo("psi-bin", TString::kIgnoreCase))
|
||||
outTag = A2M_PSIBIN;
|
||||
else if (!fAny2ManyInfo->outFormat.CompareTo("psi-mdu", TString::kIgnoreCase))
|
||||
outTag = A2M_PSIMDU;
|
||||
else if (!fAny2ManyInfo->outFormat.CompareTo("mud",TString::kIgnoreCase))
|
||||
outTag = A2M_MUD;
|
||||
else if (!fAny2ManyInfo->outFormat.CompareTo("nexus", TString::kIgnoreCase))
|
||||
@ -286,80 +284,85 @@ Bool_t PRunDataHandler::ReadWriteFilesList()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fAny2ManyInfo->inFileName.Length() != 0) { // single file name given
|
||||
if (!FileExistsCheck(-1)) {
|
||||
cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't find file " << fAny2ManyInfo->inFileName.Data() << endl;
|
||||
return false;
|
||||
}
|
||||
if (fAny2ManyInfo->inFileName.size() != 0) { // file name list given
|
||||
|
||||
// read input file
|
||||
Bool_t success = false;
|
||||
switch (inTag) {
|
||||
case A2M_ROOT:
|
||||
success = ReadRootFile(ROOT_ALL);
|
||||
break;
|
||||
case A2M_PSIBIN:
|
||||
success = ReadPsiBinFile();
|
||||
break;
|
||||
case A2M_PSIMDU:
|
||||
success = ReadPsiBinFile();
|
||||
break;
|
||||
case A2M_NEXUS:
|
||||
success = ReadNexusFile();
|
||||
break;
|
||||
case A2M_MUD:
|
||||
success = ReadMudFile();
|
||||
break;
|
||||
case A2M_WKM:
|
||||
success = ReadWkmFile();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// loop over all runs of the run list
|
||||
for (UInt_t i=0; i<fAny2ManyInfo->inFileName.size(); i++) {
|
||||
if (!FileExistsCheck(true, i)) {
|
||||
cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't find file " << fAny2ManyInfo->inFileName[i].Data() << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't read file " << fAny2ManyInfo->inFileName.Data() << endl;
|
||||
return false;
|
||||
}
|
||||
// read input file
|
||||
Bool_t success = false;
|
||||
switch (inTag) {
|
||||
case A2M_ROOT:
|
||||
success = ReadRootFile(ROOT_ALL);
|
||||
break;
|
||||
case A2M_PSIBIN:
|
||||
success = ReadPsiBinFile();
|
||||
break;
|
||||
case A2M_PSIMDU:
|
||||
success = ReadPsiBinFile();
|
||||
break;
|
||||
case A2M_NEXUS:
|
||||
success = ReadNexusFile();
|
||||
break;
|
||||
case A2M_MUD:
|
||||
success = ReadMudFile();
|
||||
break;
|
||||
case A2M_WKM:
|
||||
success = ReadWkmFile();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// write 'converted' output data file
|
||||
success = false;
|
||||
switch (outTag) {
|
||||
case A2M_ROOT:
|
||||
success = WriteRootFile();
|
||||
break;
|
||||
case A2M_PSIBIN:
|
||||
success = WritePsiBinFile();
|
||||
break;
|
||||
case A2M_PSIMDU:
|
||||
success = WritePsiBinFile();
|
||||
break;
|
||||
case A2M_NEXUS:
|
||||
success = WriteNexusFile();
|
||||
break;
|
||||
case A2M_MUD:
|
||||
success = WriteMudFile();
|
||||
break;
|
||||
case A2M_WKM:
|
||||
success = WriteWkmFile();
|
||||
break;
|
||||
case A2M_ASCII:
|
||||
success = WriteAsciiFile();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!success) {
|
||||
cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't read file " << fAny2ManyInfo->inFileName[i].Data() << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (success == false) {
|
||||
cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't write converted output file." << endl;
|
||||
return false;
|
||||
}
|
||||
// write 'converted' output data file
|
||||
success = false;
|
||||
switch (outTag) {
|
||||
case A2M_ROOT:
|
||||
success = WriteRootFile();
|
||||
break;
|
||||
case A2M_PSIBIN:
|
||||
success = WritePsiBinFile();
|
||||
break;
|
||||
case A2M_PSIMDU:
|
||||
success = WritePsiBinFile();
|
||||
break;
|
||||
case A2M_NEXUS:
|
||||
success = WriteNexusFile();
|
||||
break;
|
||||
case A2M_MUD:
|
||||
success = WriteMudFile();
|
||||
break;
|
||||
case A2M_WKM:
|
||||
success = WriteWkmFile();
|
||||
break;
|
||||
case A2M_ASCII:
|
||||
success = WriteAsciiFile();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
} else { // run list given
|
||||
if (success == false) {
|
||||
cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't write converted output file." << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fAny2ManyInfo->runList.size() != 0) { // run list given
|
||||
|
||||
// loop over all runs of the run list
|
||||
for (UInt_t i=0; i<fAny2ManyInfo->runList.size(); i++) {
|
||||
if (!FileExistsCheck(i)) {
|
||||
if (!FileExistsCheck(false, i)) {
|
||||
cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't find run " << fAny2ManyInfo->runList[i] << endl;
|
||||
return false;
|
||||
}
|
||||
@ -390,7 +393,7 @@ Bool_t PRunDataHandler::ReadWriteFilesList()
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't read file " << fAny2ManyInfo->inFileName.Data() << endl;
|
||||
cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't read file " << fRunPathName.Data() << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -438,6 +441,9 @@ Bool_t PRunDataHandler::ReadWriteFilesList()
|
||||
cerr << endl << ">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't write converted output file." << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// throw away the current data set
|
||||
fData.clear();
|
||||
}
|
||||
|
||||
}
|
||||
@ -448,23 +454,23 @@ Bool_t PRunDataHandler::ReadWriteFilesList()
|
||||
|
||||
// currently system call is used, which means this is only running under Linux and Mac OS X but not under Windows
|
||||
char cmd[256];
|
||||
if (fAny2ManyInfo->outFileList.size() == 1) {
|
||||
if (fAny2ManyInfo->outPathFileName.size() == 1) {
|
||||
if (fAny2ManyInfo->compressionTag == 1) // gzip
|
||||
fln += TString(".tar.gz");
|
||||
else // bzip2
|
||||
fln += TString(".tar.bz2");
|
||||
if (fAny2ManyInfo->compressionTag == 1) // gzip
|
||||
sprintf(cmd, "tar -zcf %s %s", fln.Data(), fAny2ManyInfo->outFileList[0].Data());
|
||||
sprintf(cmd, "tar -zcf %s %s", fln.Data(), fAny2ManyInfo->outPathFileName[0].Data());
|
||||
else // bzip2
|
||||
sprintf(cmd, "tar -jcf %s %s", fln.Data(), fAny2ManyInfo->outFileList[0].Data());
|
||||
sprintf(cmd, "tar -jcf %s %s", fln.Data(), fAny2ManyInfo->outPathFileName[0].Data());
|
||||
system(cmd);
|
||||
} else {
|
||||
fln += TString(".tar");
|
||||
for (UInt_t i=0; i<fAny2ManyInfo->outFileList.size(); i++) {
|
||||
for (UInt_t i=0; i<fAny2ManyInfo->outPathFileName.size(); i++) {
|
||||
if (i==0) {
|
||||
sprintf(cmd, "tar -cf %s %s", fln.Data(), fAny2ManyInfo->outFileList[i].Data());
|
||||
sprintf(cmd, "tar -cf %s %s", fln.Data(), fAny2ManyInfo->outPathFileName[i].Data());
|
||||
} else {
|
||||
sprintf(cmd, "tar -rf %s %s", fln.Data(), fAny2ManyInfo->outFileList[i].Data());
|
||||
sprintf(cmd, "tar -rf %s %s", fln.Data(), fAny2ManyInfo->outPathFileName[i].Data());
|
||||
}
|
||||
system(cmd);
|
||||
}
|
||||
@ -518,8 +524,8 @@ Bool_t PRunDataHandler::ReadWriteFilesList()
|
||||
}
|
||||
|
||||
// remove all the converted files
|
||||
for (UInt_t i=0; i<fAny2ManyInfo->outFileList.size(); i++)
|
||||
remove(fAny2ManyInfo->outFileList[i].Data());
|
||||
for (UInt_t i=0; i<fAny2ManyInfo->outPathFileName.size(); i++)
|
||||
remove(fAny2ManyInfo->outPathFileName[i].Data());
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -762,18 +768,26 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx)
|
||||
* - true if data file exists,
|
||||
* - otherwise false.
|
||||
*
|
||||
* \param fileName flag showing if a file name shall be handled or a run number
|
||||
* \param idx index of the run. idx == -1 means that a single input data file name is given.
|
||||
*/
|
||||
Bool_t PRunDataHandler::FileExistsCheck(const Int_t idx)
|
||||
Bool_t PRunDataHandler::FileExistsCheck(const Bool_t fileName, const Int_t idx)
|
||||
{
|
||||
TString pathName("???");
|
||||
TString str("");
|
||||
TString fln("");
|
||||
|
||||
if (idx == -1) { // single input file name
|
||||
fln = fAny2ManyInfo->inFileName;
|
||||
cout << endl << "debug> fln=" << fln << endl;
|
||||
if (fileName) { // single input file name
|
||||
if (idx >= (Int_t)fAny2ManyInfo->inFileName.size()) {
|
||||
cerr << endl << ">> PRunDataHandler::FileExistsCheck(): **ERROR** idx=" << idx << " out of range. (inFileName.size()==" << fAny2ManyInfo->inFileName.size() << ")" << endl;
|
||||
return false;
|
||||
}
|
||||
fln = fAny2ManyInfo->inFileName[idx];
|
||||
} else { // run file list entry shall be handled
|
||||
if (idx >= (Int_t)fAny2ManyInfo->runList.size()) {
|
||||
cerr << endl << ">> PRunDataHandler::FileExistsCheck(): **ERROR** idx=" << idx << " out of range. (inFileName.size()==" << fAny2ManyInfo->runList.size() << ")" << endl;
|
||||
return false;
|
||||
}
|
||||
// check for input/output templates
|
||||
if ((fAny2ManyInfo->inTemplate.Length() == 0) || (fAny2ManyInfo->outTemplate.Length() == 0)) {
|
||||
cerr << endl << ">> PRunDataHandler::FileExistsCheck(): **ERROR** when using run lists, input/ouput templates are needed as well." << endl;
|
||||
@ -793,14 +807,12 @@ cout << endl << "debug> fln=" << fln << endl;
|
||||
|
||||
// check if the file is in the local directory
|
||||
if (gSystem->AccessPathName(fln) != true) { // found in the local dir
|
||||
// pathName = TString("./")+fln;
|
||||
pathName = fln;
|
||||
}
|
||||
// check if the file is found in the directory given in the startup file
|
||||
if (pathName.CompareTo("???") == 0) { // not found in local directory search
|
||||
for (UInt_t i=0; i<fDataPath.size(); i++) {
|
||||
str = fDataPath[i] + TString("/") + fln;
|
||||
//cout << endl << "debug> XML path: str.Data()=" << str.Data();
|
||||
if (gSystem->AccessPathName(str.Data())!=true) { // found
|
||||
pathName = str;
|
||||
break;
|
||||
@ -840,8 +852,6 @@ cout << endl << "debug> fln=" << fln << endl;
|
||||
|
||||
fRunPathName = pathName;
|
||||
|
||||
//cout << endl << "debug> PRunDataHandler::FileExistsCheck: fRunPathName=" << fRunPathName.Data() << endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2822,7 +2832,7 @@ Bool_t PRunDataHandler::WriteRootFile(TString fln)
|
||||
fln.Prepend(fAny2ManyInfo->outPath);
|
||||
}
|
||||
// keep the file name if compression is whished
|
||||
fAny2ManyInfo->outFileList.push_back(fln);
|
||||
fAny2ManyInfo->outPathFileName.push_back(fln);
|
||||
} else {
|
||||
fln = TString("__tmp.root");
|
||||
}
|
||||
@ -3033,7 +3043,7 @@ Bool_t PRunDataHandler::WriteWkmFile(TString fln)
|
||||
fln.Prepend(fAny2ManyInfo->outPath);
|
||||
}
|
||||
// keep the file name if compression is whished
|
||||
fAny2ManyInfo->outFileList.push_back(fln);
|
||||
fAny2ManyInfo->outPathFileName.push_back(fln);
|
||||
|
||||
// write ascii file
|
||||
ofstream fout;
|
||||
@ -3077,7 +3087,7 @@ Bool_t PRunDataHandler::WriteWkmFile(TString fln)
|
||||
cout << endl << "Setup : " << fData[0].GetSetup()->Data();
|
||||
cout << endl << "Groups : " << fData[0].GetNoOfHistos();
|
||||
cout << endl << "Channels : " << static_cast<UInt_t>(fData[0].GetDataBin(0)->size()/fAny2ManyInfo->rebin);
|
||||
cout << endl << "Resolution : " << fData[0].GetTimeResolution();
|
||||
cout << endl << "Resolution : " << fData[0].GetTimeResolution()*fAny2ManyInfo->rebin;
|
||||
|
||||
// write data
|
||||
if (fAny2ManyInfo->rebin == 1) {
|
||||
@ -3195,7 +3205,7 @@ Bool_t PRunDataHandler::WriteMudFile(TString fln)
|
||||
fln.Prepend(fAny2ManyInfo->outPath);
|
||||
}
|
||||
// keep the file name if compression is whished
|
||||
fAny2ManyInfo->outFileList.push_back(fln);
|
||||
fAny2ManyInfo->outPathFileName.push_back(fln);
|
||||
} else {
|
||||
fln = TString("__tmp.msr");
|
||||
}
|
||||
@ -3373,7 +3383,7 @@ Bool_t PRunDataHandler::WriteAsciiFile(TString fln)
|
||||
fln.Prepend(fAny2ManyInfo->outPath);
|
||||
}
|
||||
// keep the file name if compression is whished
|
||||
fAny2ManyInfo->outFileList.push_back(fln);
|
||||
fAny2ManyInfo->outPathFileName.push_back(fln);
|
||||
|
||||
// write ascii file
|
||||
ofstream fout;
|
||||
@ -3417,13 +3427,13 @@ Bool_t PRunDataHandler::WriteAsciiFile(TString fln)
|
||||
if (fData[0].GetTransport() != PMUSR_UNDEFINED)
|
||||
cout << endl << "% transport : " << fData[0].GetTransport() << " (kV)";
|
||||
if (fData[0].GetTimeResolution() != PMUSR_UNDEFINED)
|
||||
cout << endl << "% time resolution : " << fData[0].GetTimeResolution() << " (ns)";
|
||||
cout << endl << "% time resolution : " << fData[0].GetTimeResolution()*fAny2ManyInfo->rebin << " (ns)";
|
||||
if (fData[0].GetT0Size() > 0) {
|
||||
cout << endl << "% t0 : ";
|
||||
for (UInt_t i=0; i<fData[0].GetT0Size()-1; i++) {
|
||||
cout << static_cast<UInt_t>(fData[0].GetT0(i)/fAny2ManyInfo->rebin) << ", ";
|
||||
}
|
||||
cout << fData[0].GetT0(fData[0].GetT0Size()-1);
|
||||
cout << fData[0].GetT0(fData[0].GetT0Size()-1)/fAny2ManyInfo->rebin;
|
||||
}
|
||||
cout << endl << "% # histos : " << fData[0].GetNoOfHistos();
|
||||
cout << endl << "% # of bins : " << static_cast<UInt_t>(fData[0].GetDataBin(0)->size()/fAny2ManyInfo->rebin);
|
||||
|
@ -575,9 +575,8 @@ 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
|
||||
TString inFileName; ///< holds the file name of the input data file
|
||||
TString outFileName; ///< holds the file name of the output data file
|
||||
PStringVector outFileList; ///< holds the out path/file name
|
||||
PStringVector inFileName; ///< holds the file name of the input data file
|
||||
PStringVector outPathFileName; ///< holds the out path/file name
|
||||
TString outPath; ///< holds the output path
|
||||
UInt_t rebin; ///< holds the number of bins to be packed
|
||||
UInt_t compressionTag; ///< 0=no compression, 1=gzip compression, 2=bzip2 compression
|
||||
|
@ -68,7 +68,7 @@ class PRunDataHandler
|
||||
virtual Bool_t ReadWriteFilesList();
|
||||
virtual Bool_t FileAlreadyRead(TString runName);
|
||||
virtual Bool_t FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx);
|
||||
virtual Bool_t FileExistsCheck(const Int_t idx);
|
||||
virtual Bool_t FileExistsCheck(const Bool_t fileName, const Int_t idx);
|
||||
virtual Bool_t ReadRootFile(UInt_t tag);
|
||||
virtual Bool_t ReadNexusFile();
|
||||
virtual Bool_t ReadWkmFile();
|
||||
|
Reference in New Issue
Block a user