68 std::cout << std::endl <<
"usage: musrview <msr-file> [Options]";
69 std::cout << std::endl <<
" <msr-file>: msr/mlog input file";
70 std::cout << std::endl <<
" Options:";
71 std::cout << std::endl <<
" --help : display this help and exit.";
72 std::cout << std::endl <<
" --version : output version information and exit.";
73 std::cout << std::endl <<
" --show-dynamic-path : dumps the dynamic search paths and exit.";
74 std::cout << std::endl <<
" -f, --fourier: will directly present the Fourier transform of the <msr-file>.";
75 std::cout << std::endl <<
" -a, --avg: will directly present the averaged data/Fourier of the <msr-file>.";
76 std::cout << std::endl <<
" -1, --one_to_one: calculate theory points only at data points.";
77 std::cout << std::endl <<
" --<graphic-format-extension>: ";
78 std::cout << std::endl <<
" will produce a graphics-output-file without starting a root session.";
79 std::cout << std::endl <<
" the name is based on the <msr-file>, e.g. 3310.msr -> 3310_0.png";
80 std::cout << std::endl <<
" supported graphic-format-extension:";
81 std::cout << std::endl <<
" eps, pdf, gif, jpg, png, svg, xpm, root";
82 std::cout << std::endl <<
" example: musrview 3310.msr --png, will produce a files 3310_X.png";
83 std::cout << std::endl <<
" where 'X' stands for the plot number (starting form 0)";
84 std::cout << std::endl <<
" --ascii: ";
85 std::cout << std::endl <<
" will produce an ascii dump of the data and fit as plotted.";
86 std::cout << std::endl <<
" --timeout <timeout>: <timeout> given in seconds after which musrview terminates.";
87 std::cout << std::endl <<
" If <timeout> <= 0, no timeout will take place. Default <timeout> is 0.";
88 std::cout << std::endl <<
" -s, --show-errMsgBox: if this tag is defined, error message boxes are shown,";
89 std::cout << std::endl <<
" rather than only stderr output.";
90 std::cout << std::endl << std::endl;
121int main(
int argc,
char *argv[])
124 bool show_syntax{
false};
127 std::string fileName{};
130 bool theoAtData{
false};
131 bool graphicsOutput{
false};
132 bool asciiOutput{
false};
133 std::string graphicsExtension{};
135 bool show_errMsgBox{
false};
136 std::stringstream errMsg;
139 const char *dsp = gSystem->GetDynamicPath();
140 if (strstr(dsp,
"/usr/local/lib") ==
nullptr)
141 gSystem->AddDynamicPath(
"/usr/local/lib");
148 for (
int i=1; i<argc; i++) {
149 if (strstr(argv[i],
".msr") || strstr(argv[i],
".mlog")) {
150 if (fileName.empty()) {
153 std::cerr << std::endl <<
"**ERROR** only one file name allowed." << std::endl;
157 }
else if (!strcmp(argv[i],
"--version")) {
160 std::cout << std::endl <<
"musrview version: " << PACKAGE_VERSION <<
", git-branch: " << GIT_BRANCH <<
", git-rev: " << GIT_CURRENT_SHA1 <<
" (" << BUILD_TYPE <<
"), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
162 std::cout << std::endl <<
"musrview version: " << PACKAGE_VERSION <<
" (" << BUILD_TYPE <<
"), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
166 std::cout << std::endl <<
"musrview git-branch: " << GIT_BRANCH <<
", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
168 std::cout << std::endl <<
"musrview version: unknown." << std::endl << std::endl;
172 }
else if (!strcmp(argv[i],
"--show-dynamic-path")) {
173 std::cout << std::endl <<
"musrview: internal dynamic search paths for shared libraries/root dictionaries:";
174 std::cout << std::endl <<
" '" << gSystem->GetDynamicPath() <<
"'" << std::endl << std::endl;
176 }
else if (!strcmp(argv[i],
"--help")) {
179 }
else if (!strcmp(argv[i],
"-f") || !strcmp(argv[i],
"--fourier")) {
181 }
else if (!strcmp(argv[i],
"-a") || !strcmp(argv[i],
"--avg")) {
183 }
else if (!strcmp(argv[i],
"-1") || !strcmp(argv[i],
"--one_to_one")) {
185 }
else if (!strcmp(argv[i],
"--eps") || !strcmp(argv[i],
"--pdf") || !strcmp(argv[i],
"--gif") ||
186 !strcmp(argv[i],
"--jpg") || !strcmp(argv[i],
"--png") || !strcmp(argv[i],
"--svg") ||
187 !strcmp(argv[i],
"--xpm") || !strcmp(argv[i],
"--root")) {
189 graphicsOutput =
true;
190 graphicsExtension = argv[i]+2;
191 }
else if (!strcmp(argv[i],
"--ascii")) {
193 }
else if (!strcmp(argv[i],
"--timeout")) {
195 TString str(argv[i+1]);
207 }
else if (!strcmp(argv[i],
"-s") || !strcmp(argv[i],
"--show-errMsgBox")) {
208 show_errMsgBox =
true;
222 std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
223 std::unique_ptr<PStartupHandler> startupHandler = std::make_unique<PStartupHandler>();
224 if (!startupHandler->StartupFileFound()) {
225 std::cerr << std::endl <<
">> musrview **WARNING** couldn't find " << startupHandler->GetStartupFilePath().Data();
226 std::cerr << std::endl;
229 saxParser->ConnectToHandler(
"PStartupHandler", startupHandler.get());
236 std::cerr << std::endl <<
">> musrview **WARNING** Reading/parsing musrfit_startup.xml failed.";
237 std::cerr << std::endl <<
">> Any graph will appear with random symbols and colors!";
238 std::cerr << std::endl;
240 startupHandler->CheckLists();
245 std::unique_ptr<PMsrHandler> msrHandler = std::make_unique<PMsrHandler>(fileName.c_str());
246 status = msrHandler->ReadMsrFile();
248 errMsg << msrHandler->GetLastErrorMsg();
252 errMsg <<
">> musrview **ERROR** couldn't find '" << fileName <<
"'\n\n";
256 errMsg <<
">> musrview **SYNTAX ERROR** in file " << fileName <<
", full stop here.\n\n";
260 errMsg <<
">> musrview **UNKNOWN ERROR** when trying to read the msr-file.\n\n";
263 std::cerr << errMsg.str();
269 PMsrPlotList *msrPlotList = msrHandler->GetMsrPlotList();
272 for (
unsigned int i=0; i<msrPlotList->size(); i++) {
273 for (
unsigned int j=0; j<msrPlotList->at(i).fRuns.size(); j++) {
276 for (
unsigned int k=0; k<plotList.size(); k++) {
277 if (msrPlotList->at(i).fRuns[j] ==
static_cast<int>(plotList[k])) {
283 plotList.push_back(
static_cast<int>(msrPlotList->at(i).fRuns[j]));
289 std::unique_ptr<PRunDataHandler> dataHandler;
291 dataHandler = std::make_unique<PRunDataHandler>(msrHandler.get(), startupHandler->GetDataPathList());
293 dataHandler = std::make_unique<PRunDataHandler>(msrHandler.get());
295 dataHandler->ReadData();
297 success = dataHandler->IsAllDataAvailable();
299 errMsg <<
">> musrview **ERROR** Couldn't read all data files, will quit ...\n";
300 std::cerr << errMsg.str();
307 std::unique_ptr<PRunListCollection> runListCollection;
310 runListCollection = std::make_unique<PRunListCollection>(msrHandler.get(), dataHandler.get(), theoAtData);
311 for (
unsigned int i=0; i<msrHandler->GetMsrRunList()->size(); i++) {
314 for (
unsigned int j=0; j<plotList.size(); j++) {
315 if (
static_cast<unsigned int>(plotList[j]) == i+1) {
321 success = runListCollection->Add(i,
kView);
323 errMsg <<
">> musrview **ERROR** Couldn't handle run no " << i <<
" ";
324 errMsg << (*msrHandler->GetMsrRunList())[i].GetRunName()->Data() <<
"\n";
325 std::cerr << errMsg.str();
338 std::vector<char*> args;
339 args.push_back(argv[0]);
340 if (graphicsOutput || asciiOutput) {
341 args.push_back((
char*)
"-b");
343 int cc = args.size();
344 TApplication app(
"App", &cc, args.data());
346 std::vector<PMusrCanvas*> canvasVector;
350 for (
unsigned int i=0; i<msrHandler->GetMsrPlotList()->size(); i++) {
353 musrCanvas =
new PMusrCanvas(i, msrHandler->GetMsrTitle()->Data(),
354 10+i*100, 10+i*100, 800, 600,
355 startupHandler->GetFourierDefaults(),
356 startupHandler->GetMarkerList(),
357 startupHandler->GetColorList(),
358 graphicsOutput||asciiOutput,
359 fourier, avg, theoAtData);
361 musrCanvas =
new PMusrCanvas(i, msrHandler->GetMsrTitle()->Data(),
362 10+i*100, 10+i*100, 800, 600,
363 graphicsOutput||asciiOutput,
364 fourier, avg, theoAtData);
366 if (musrCanvas ==
nullptr) {
367 errMsg <<
">> musrview **SEVERE ERROR** Couldn't invoke all necessary objects, will quit.\n";
368 std::cerr << errMsg.str();
375 errMsg <<
">> musrview **SEVERE ERROR** Couldn't invoke all necessary objects, will quit.\n";
376 std::cerr << errMsg.str();
399 musrCanvas->Connect(
"Done(Int_t)",
"TApplication", &app,
"Terminate(Int_t)");
401 if (graphicsOutput) {
407 TString str(fileName.c_str());
408 str.Remove(str.Last(
'.'));
416 canvasVector.push_back(musrCanvas);
425 for (
unsigned int i=0; i<canvasVector.size(); i++) {
427 snprintf(canvasName,
sizeof(canvasName),
"fMainCanvas%d", i);
428 if (gROOT->GetListOfCanvases()->FindObject(canvasName) !=
nullptr) {
429 canvasVector[i]->~PMusrCanvas();
432 canvasVector.clear();