67 std::cout << std::endl <<
"usage: musrview <msr-file> [Options]";
68 std::cout << std::endl <<
" <msr-file>: msr/mlog input file";
69 std::cout << std::endl <<
" Options:";
70 std::cout << std::endl <<
" --help : display this help and exit.";
71 std::cout << std::endl <<
" --version : output version information and exit.";
72 std::cout << std::endl <<
" --show-dynamic-path : dumps the dynamic search paths and exit.";
73 std::cout << std::endl <<
" -f, --fourier: will directly present the Fourier transform of the <msr-file>.";
74 std::cout << std::endl <<
" -a, --avg: will directly present the averaged data/Fourier of the <msr-file>.";
75 std::cout << std::endl <<
" -1, --one_to_one: calculate theory points only at data points.";
76 std::cout << std::endl <<
" --<graphic-format-extension>: ";
77 std::cout << std::endl <<
" will produce a graphics-output-file without starting a root session.";
78 std::cout << std::endl <<
" the name is based on the <msr-file>, e.g. 3310.msr -> 3310_0.png";
79 std::cout << std::endl <<
" supported graphic-format-extension:";
80 std::cout << std::endl <<
" eps, pdf, gif, jpg, png, svg, xpm, root";
81 std::cout << std::endl <<
" example: musrview 3310.msr --png, will produce a files 3310_X.png";
82 std::cout << std::endl <<
" where 'X' stands for the plot number (starting form 0)";
83 std::cout << std::endl <<
" --ascii: ";
84 std::cout << std::endl <<
" will produce an ascii dump of the data and fit as plotted.";
85 std::cout << std::endl <<
" --timeout <timeout>: <timeout> given in seconds after which musrview terminates.";
86 std::cout << std::endl <<
" If <timeout> <= 0, no timeout will take place. Default <timeout> is 0.";
87 std::cout << std::endl <<
" -s, --show-errMsgBox: if this tag is defined, error message boxes are shown,";
88 std::cout << std::endl <<
" rather than only stderr output.";
89 std::cout << std::endl << std::endl;
120int main(
int argc,
char *argv[])
123 bool show_syntax{
false};
129 bool theoAtData{
false};
130 bool graphicsOutput{
false};
131 bool asciiOutput{
false};
132 char graphicsExtension[128];
134 bool show_errMsgBox{
false};
135 std::stringstream errMsg;
137 memset(fileName,
'\0',
sizeof(fileName));
138 memset(graphicsExtension,
'\0',
sizeof(graphicsExtension));
141 const char *dsp = gSystem->GetDynamicPath();
142 if (strstr(dsp,
"/usr/local/lib") ==
nullptr)
143 gSystem->AddDynamicPath(
"/usr/local/lib");
150 for (
int i=1; i<argc; i++) {
151 if (strstr(argv[i],
".msr") || strstr(argv[i],
".mlog")) {
152 if (strlen(fileName) == 0) {
153 strncpy(fileName, argv[i],
sizeof(fileName));
155 std::cerr << std::endl <<
"**ERROR** only one file name allowed." << std::endl;
159 }
else if (!strcmp(argv[i],
"--version")) {
162 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;
164 std::cout << std::endl <<
"musrview version: " << PACKAGE_VERSION <<
" (" << BUILD_TYPE <<
"), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
168 std::cout << std::endl <<
"musrview git-branch: " << GIT_BRANCH <<
", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
170 std::cout << std::endl <<
"musrview version: unknown." << std::endl << std::endl;
174 }
else if (!strcmp(argv[i],
"--show-dynamic-path")) {
175 std::cout << std::endl <<
"musrview: internal dynamic search paths for shared libraries/root dictionaries:";
176 std::cout << std::endl <<
" '" << gSystem->GetDynamicPath() <<
"'" << std::endl << std::endl;
178 }
else if (!strcmp(argv[i],
"--help")) {
181 }
else if (!strcmp(argv[i],
"-f") || !strcmp(argv[i],
"--fourier")) {
183 }
else if (!strcmp(argv[i],
"-a") || !strcmp(argv[i],
"--avg")) {
185 }
else if (!strcmp(argv[i],
"-1") || !strcmp(argv[i],
"--one_to_one")) {
187 }
else if (!strcmp(argv[i],
"--eps") || !strcmp(argv[i],
"--pdf") || !strcmp(argv[i],
"--gif") ||
188 !strcmp(argv[i],
"--jpg") || !strcmp(argv[i],
"--png") || !strcmp(argv[i],
"--svg") ||
189 !strcmp(argv[i],
"--xpm") || !strcmp(argv[i],
"--root")) {
191 graphicsOutput =
true;
192 strncpy(graphicsExtension, argv[i]+2,
sizeof(graphicsExtension));
193 }
else if (!strcmp(argv[i],
"--ascii")) {
195 }
else if (!strcmp(argv[i],
"--timeout")) {
197 TString str(argv[i+1]);
209 }
else if (!strcmp(argv[i],
"-s") || !strcmp(argv[i],
"--show-errMsgBox")) {
210 show_errMsgBox =
true;
225 std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
226 std::unique_ptr<PStartupHandler> startupHandler = std::make_unique<PStartupHandler>();
227 if (!startupHandler->StartupFileFound()) {
228 std::cerr << std::endl <<
">> musrview **WARNING** couldn't find " << startupHandler->GetStartupFilePath().Data();
229 std::cerr << std::endl;
232 saxParser->ConnectToHandler(
"PStartupHandler", startupHandler.get());
239 std::cerr << std::endl <<
">> musrview **WARNING** Reading/parsing musrfit_startup.xml failed.";
240 std::cerr << std::endl <<
">> Any graph will appear with random symbols and colors!";
241 std::cerr << std::endl;
243 startupHandler->CheckLists();
248 std::unique_ptr<PMsrHandler> msrHandler = std::make_unique<PMsrHandler>(fileName);
249 status = msrHandler->ReadMsrFile();
251 errMsg << msrHandler->GetLastErrorMsg();
255 errMsg <<
">> musrview **ERROR** couldn't find '" << fileName <<
"'\n\n";
259 errMsg <<
">> musrview **SYNTAX ERROR** in file " << fileName <<
", full stop here.\n\n";
263 errMsg <<
">> musrview **UNKNOWN ERROR** when trying to read the msr-file.\n\n";
266 std::cerr << errMsg.str();
272 PMsrPlotList *msrPlotList = msrHandler->GetMsrPlotList();
275 for (
unsigned int i=0; i<msrPlotList->size(); i++) {
276 for (
unsigned int j=0; j<msrPlotList->at(i).fRuns.size(); j++) {
279 for (
unsigned int k=0; k<plotList.size(); k++) {
280 if (msrPlotList->at(i).fRuns[j] ==
static_cast<int>(plotList[k])) {
286 plotList.push_back(
static_cast<int>(msrPlotList->at(i).fRuns[j]));
292 std::unique_ptr<PRunDataHandler> dataHandler;
294 dataHandler = std::make_unique<PRunDataHandler>(msrHandler.get(), startupHandler->GetDataPathList());
296 dataHandler = std::make_unique<PRunDataHandler>(msrHandler.get());
298 dataHandler->ReadData();
300 success = dataHandler->IsAllDataAvailable();
302 errMsg <<
">> musrview **ERROR** Couldn't read all data files, will quit ...\n";
303 std::cerr << errMsg.str();
310 std::unique_ptr<PRunListCollection> runListCollection;
313 runListCollection = std::make_unique<PRunListCollection>(msrHandler.get(), dataHandler.get(), theoAtData);
314 for (
unsigned int i=0; i<msrHandler->GetMsrRunList()->size(); i++) {
317 for (
unsigned int j=0; j<plotList.size(); j++) {
318 if (
static_cast<unsigned int>(plotList[j]) == i+1) {
324 success = runListCollection->Add(i,
kView);
326 errMsg <<
">> musrview **ERROR** Couldn't handle run no " << i <<
" ";
327 errMsg << (*msrHandler->GetMsrRunList())[i].GetRunName()->Data() <<
"\n";
328 std::cerr << errMsg.str();
341 std::vector<char*> args;
342 args.push_back(argv[0]);
343 if (graphicsOutput || asciiOutput) {
344 args.push_back((
char*)
"-b");
346 int cc = args.size();
347 TApplication app(
"App", &cc, args.data());
349 std::vector<PMusrCanvas*> canvasVector;
353 for (
unsigned int i=0; i<msrHandler->GetMsrPlotList()->size(); i++) {
356 musrCanvas =
new PMusrCanvas(i, msrHandler->GetMsrTitle()->Data(),
357 10+i*100, 10+i*100, 800, 600,
358 startupHandler->GetFourierDefaults(),
359 startupHandler->GetMarkerList(),
360 startupHandler->GetColorList(),
361 graphicsOutput||asciiOutput,
362 fourier, avg, theoAtData);
364 musrCanvas =
new PMusrCanvas(i, msrHandler->GetMsrTitle()->Data(),
365 10+i*100, 10+i*100, 800, 600,
366 graphicsOutput||asciiOutput,
367 fourier, avg, theoAtData);
369 if (musrCanvas ==
nullptr) {
370 errMsg <<
">> musrview **SEVERE ERROR** Couldn't invoke all necessary objects, will quit.\n";
371 std::cerr << errMsg.str();
378 errMsg <<
">> musrview **SEVERE ERROR** Couldn't invoke all necessary objects, will quit.\n";
379 std::cerr << errMsg.str();
402 musrCanvas->Connect(
"Done(Int_t)",
"TApplication", &app,
"Terminate(Int_t)");
404 if (graphicsOutput) {
410 TString str(fileName);
411 str.Remove(str.Last(
'.'));
419 canvasVector.push_back(musrCanvas);
428 for (
unsigned int i=0; i<canvasVector.size(); i++) {
430 snprintf(canvasName,
sizeof(canvasName),
"fMainCanvas%d", i);
431 if (gROOT->GetListOfCanvases()->FindObject(canvasName) !=
nullptr) {
432 canvasVector[i]->~PMusrCanvas();
435 canvasVector.clear();