48 #include <boost/algorithm/string.hpp> 51 #include <TObjArray.h> 52 #include <TObjString.h> 60 #include "git-revision.h" 66 #include "TLemRunHeader.h" 67 #include "MuSR_td_PSI_bin.h" 74 #define DH_MUSR_ROOT 0 83 std::cout << std::endl <<
"usage: dump_header [-rn <runNo> | -fn <fileName>] [-ff, --fileFormat <fileFormat>]";
84 std::cout << std::endl <<
" [-y, --year <year>] [-s, --summary] [-i, --instrument <inst>]";
85 std::cout << std::endl <<
" [-c, --counts] | ";
86 std::cout << std::endl <<
" --help | --version";
87 std::cout << std::endl;
88 std::cout << std::endl <<
" Dumps the header information of a given muSR data file onto the standard output.";
89 std::cout << std::endl <<
" If no <fileFormat> info is povided, it will try to guess what <fileFormat> it might be.";
90 std::cout << std::endl <<
" For <runNo> guessing of the file format is not possible. The default assumption here is 'MusrRoot'.";
91 std::cout << std::endl;
92 std::cout << std::endl <<
" -rn, --runNo <runNo> : run number of the header to be dumped.";
93 std::cout << std::endl <<
" -fn, --fileName <fileName> : muSR data file name.";
94 std::cout << std::endl <<
" -ff, --fileFormat <fileFormat> : where <fileFormat> can be:";
95 std::cout << std::endl <<
" MusrRoot (default), NeXus, ROOT (old LEM), PSI-BIN, PSI-MDU, MUD, WKM";
96 std::cout << std::endl <<
" NeXus is only supported if enabled.";
97 std::cout << std::endl <<
" -y, --year <year> : <year> has to be 4 digit, e.g. 2005, if provided it is used to";
98 std::cout << std::endl <<
" generate the file name for the given <runNo>, otherwise the current";
99 std::cout << std::endl <<
" year is used. If a file name is given, this option has no effect.";
100 std::cout << std::endl <<
" -s, --summary : this option is used for LE-uSR data sets only. It will, additionally";
101 std::cout << std::endl <<
" to the header information, print the summary file content.";
102 std::cout << std::endl <<
" -i, --instrument <inst> : where <inst> is the requested instrument:";
103 std::cout << std::endl <<
" lem (default) | gps | ltf | dolly | gpd | hifi | flame.";
104 std::cout << std::endl <<
" -c, --counts : will show detector counts as well.";
105 std::cout << std::endl <<
" -h, --help : will show this help";
106 std::cout << std::endl <<
" -v, --version : will show the current version.";
107 std::cout << std::endl << std::endl;
122 TFile f(fileName.c_str());
124 std::cerr << std::endl;
125 std::cerr <<
"**ERROR** couldn't invoke ROOT/MusrRoot file object." << std::endl;
126 std::cerr << std::endl;
131 UInt_t noOfHistos{0};
135 f.GetObject(
"RunInfo", folder);
137 f.GetObject(
"RunHeader", folder);
139 std::cerr << std::endl <<
"**ERROR** Couldn't neither obtain RunInfo (LEM), nor RunHeader (MusrRoot) from " << fileName << std::endl;
149 std::unique_ptr<TMusrRunHeader> header;
155 TLemRunHeader* runHeader =
dynamic_cast<TLemRunHeader*
>(folder->FindObjectAny(
"TLemRunHeader"));
158 if (runHeader ==
nullptr) {
159 std::cerr << std::endl <<
"**ERROR** Couldn't obtain run header info from ROOT file " << fileName << std::endl;
164 std::cout << std::endl <<
"-------------------";
165 std::cout << std::endl <<
"fileName = " << fileName <<
", fileFormat = ROOT (PSI LEM).";
166 std::cout << std::endl <<
"-------------------";
167 std::cout << std::endl <<
"Run Title : " << runHeader->GetRunTitle().GetString().Data();
168 std::cout << std::endl <<
"Run Number : " << runHeader->GetRunNumber();
169 std::cout << std::endl <<
"Run Start Time : " << runHeader->GetStartTimeString().GetString().Data();
170 std::cout << std::endl <<
"Run Stop Time : " << runHeader->GetStopTimeString().GetString().Data();
171 std::cout << std::endl <<
"Laboratory : PSI";
172 std::cout << std::endl <<
"Instrument : LEM";
173 std::cout << std::endl <<
"Beamline : muE4";
174 std::cout << std::endl <<
"Muon Beam Momentum : 28 MeV/c";
175 std::cout << std::endl <<
"Muon Species : positive muons";
176 std::cout << std::endl <<
"Muon Source : Target E - slow muons";
177 std::cout << std::endl <<
"Setup : " << runHeader->GetLemSetup().GetString().Data();
178 std::cout << std::endl <<
"Comment : n/a";
179 std::cout << std::endl <<
"Sample Name : n/a";
180 std::cout << std::endl <<
"Sample Orientation : n/a";
181 std::cout << std::endl <<
"Sample Temperature : " << runHeader->GetSampleTemperature() <<
"+-" << runHeader->GetSampleTemperatureError() <<
" K";
182 std::cout << std::endl <<
"Sample Mag. Field : " << runHeader->GetSampleBField() <<
"+-" << runHeader->GetSampleBFieldError() <<
" G";
183 std::cout << std::endl <<
"No of Histos : " << runHeader->GetNHist();
184 std::cout << std::endl <<
"Time Resolution : " << runHeader->GetTimeResolution() <<
" ns";
185 std::cout << std::endl <<
"-------------------";
186 std::cout << std::endl <<
"LEM Specific Entries :";
187 std::cout << std::endl <<
"Moderator : " << runHeader->GetModerator().GetString().Data();
188 std::cout << std::endl <<
"Moderator HV : " << runHeader->GetModeratorHV() <<
" kV";
189 std::cout << std::endl <<
"Sample HV : " << runHeader->GetSampleHV() <<
" kV";
190 std::cout << std::endl <<
"Impl. Energy : " << runHeader->GetImpEnergy() <<
" keV";
191 std::cout << std::endl <<
"-------------------";
192 std::cout << std::endl <<
"Detector Info (for all detectors the same): ";
193 std::cout << std::endl <<
"-------------------";
194 std::cout << std::endl <<
"Histo Length : " << runHeader->GetNChannels();
196 timeZero = runHeader->GetTimeZero();
197 std::cout << std::endl <<
"Time Zero Bin : " << timeZero[0];
198 std::cout << std::endl <<
"First Good Bin : " << timeZero[0];
199 std::cout << std::endl <<
"Last Good Bin : " << runHeader->GetNChannels()-1;
200 std::cout << std::endl <<
"-------------------" << std::endl << std::endl;
203 header = std::make_unique<TMusrRunHeader>(fileName.c_str(),
true);
206 if (!header->ExtractAll(folder)) {
207 std::cerr << std::endl <<
"**ERROR** Couldn't invoke MusrRoot RunHeader in file:" << fileName;
208 std::cerr << std::endl;
213 header->DumpHeader();
217 header->Get(
"RunInfo/No of Histos", ival, ok);
220 header->Get(
"RunInfo/RedGreen Offsets", ivec, ok);
222 redGreenOffset = ivec;
228 TObjArray *runSum=
nullptr;
229 runSum =
static_cast<TObjArray*
>(folder->FindObject(
"RunSummary"));
231 std::cerr << std::endl <<
"**ERROR** Couldn't obtain RunSummary " << fileName << std::endl;
235 std::cout <<
"++++++++++++++++++++" << std::endl;
236 std::cout <<
" Run Summary" << std::endl;
237 std::cout <<
"++++++++++++++++++++" << std::endl;
240 for (Int_t i=0; i<runSum->GetEntries(); i++) {
241 tstr =
static_cast<TObjString*
>(runSum->At(i));
242 str = tstr->String();
244 if (!str.Contains(
"\r") && !str.Contains(
"\n"))
245 std::cout << std::endl;
252 std::cout <<
"Detector counts (all, between fgb and lgb)" << std::endl;
253 f.GetObject(
"histos", folder);
254 if ((folder !=
nullptr) && (header !=
nullptr)) {
255 char detectorLabel[64];
256 TH1F *histo{
nullptr};
257 UInt_t total{0}, total_good{0}, ta, tg;
259 for (UInt_t i=0; i<redGreenOffset.size(); i++) {
260 std::cout <<
" Group " << i+1 <<
" (Offset=" << redGreenOffset[i] <<
") : " << std::endl;
263 for (UInt_t j=0; j<noOfHistos; j++) {
266 snprintf(detectorLabel,
sizeof(detectorLabel),
"DetectorInfo/Detector%03d/First Good Bin", redGreenOffset[i]+j+1);
267 header->Get(detectorLabel, ival, ok);
272 snprintf(detectorLabel,
sizeof(detectorLabel),
"DetectorInfo/Detector%03d/Last Good Bin", redGreenOffset[i]+j+1);
273 header->Get(detectorLabel, ival, ok);
278 snprintf(detectorLabel,
sizeof(detectorLabel),
"hDecay%03d", redGreenOffset[i]+j+1);
279 histo = (TH1F*) folder->FindObjectAny(detectorLabel);
280 if (histo !=
nullptr) {
281 ta = histo->Integral(0, histo->GetNbinsX()+1);
282 tg = histo->Integral(fgb, lgb);
283 std::cout <<
" " << histo->GetTitle() <<
":\t " << ta <<
", " << tg << std::endl;
289 std::cout <<
" total counts of group " << i+1 <<
":\t\t\t " << total <<
", " << total_good << std::endl;
291 std::cout <<
" total counts of group " << i+1 <<
":\t\t\t\t\t " << total <<
", " << total_good << std::endl;
294 std::cout <<
"Sorry, no histos folder found" << std::endl;
316 #ifdef PNEXUS_ENABLED 317 std::unique_ptr<PNeXus> nxs_file = std::make_unique<PNeXus>(fileName.c_str());
319 if (nxs_file->IsValid(
false)) {
320 nxs_file->Dump(counts);
322 std::cerr << std::endl;
323 std::cerr <<
"**ERROR** found invalid NeXus file." << std::endl;
324 std::cerr << std::endl;
328 std::cout << std::endl <<
"NeXus not enabled, hence the header information cannot be dumped." << std::endl << std::endl;
344 std::vector<std::string> result;
345 std::string fln(fileName);
346 boost::to_lower(fln);
348 if ((fln.find(
".bin") != std::string::npos) || (fln.find(
".mdu") != std::string::npos)) {
349 if (fln.find(
"_gps_") != std::string::npos) {
350 result.push_back(
"GPS");
351 result.push_back(
"piM3.2");
352 result.push_back(
"28 MeV/c");
353 result.push_back(
"likely to be positive muons");
354 result.push_back(
"Target M");
355 }
else if (fln.find(
"_ltf_") != std::string::npos) {
356 result.push_back(
"LTF");
357 result.push_back(
"piM3.1");
358 result.push_back(
"28 MeV/c");
359 result.push_back(
"likely to be positive muons");
360 result.push_back(
"Target M");
361 }
else if (fln.find(
"_dolly_") != std::string::npos) {
362 result.push_back(
"DOLLY");
363 result.push_back(
"piE1");
364 result.push_back(
"28 MeV/c");
365 result.push_back(
"likely to be positive muons");
366 result.push_back(
"Target E");
367 }
else if (fln.find(
"_alc_") != std::string::npos) {
368 result.push_back(
"ALC");
369 result.push_back(
"piE3");
370 result.push_back(
"28 MeV/c");
371 result.push_back(
"likely to be positive muons");
372 result.push_back(
"Target E");
373 }
else if (fln.find(
"_hifi_") != std::string::npos) {
374 result.push_back(
"HAL9500");
375 result.push_back(
"piE3");
376 result.push_back(
"28 MeV/c");
377 result.push_back(
"likely to be positive muons");
378 result.push_back(
"Target E");
379 }
else if (fln.find(
"_gpd_") != std::string::npos) {
380 result.push_back(
"GPD");
381 result.push_back(
"muE1");
382 result.push_back(
"60-125 MeV/c");
383 result.push_back(
"likely to be positive muons");
384 result.push_back(
"Target E");
386 result.push_back(
"???");
387 result.push_back(
"???");
388 result.push_back(
"??? MeV/c");
389 result.push_back(
"???");
390 result.push_back(
"???");
409 MuSR_td_PSI_bin psiBin;
411 bool success =
false;
414 status = psiBin.Read(fileName.c_str());
420 std::cout << std::endl <<
"**ERROR** couldn't open psi-bin file, or failed while reading the header." << std::endl;
424 std::cout << std::endl <<
"**ERROR** psi-bin file: unsupported version of the data." << std::endl;
428 std::cout << std::endl <<
"**ERROR** psi-bin file: error when allocating data buffer." << std::endl;
432 std::cout << std::endl <<
">> **ERROR** psi-bin file: number of histograms/record not equals 1." << std::endl;
436 std::cout << std::endl <<
">> **ERROR** psi-bin file: no clue why you reached this point." << std::endl;
445 std::vector<std::string> vstr;
446 std::vector<double> dVal, dErrVal;
447 std::cout << std::endl <<
"-------------------";
448 std::cout << std::endl <<
"fileName = " << fileName <<
", fileFormat = " << fileFormat;
449 std::cout << std::endl <<
"-------------------";
450 std::cout << std::endl <<
"Run Title : " << psiBin.GetComment();
451 std::cout << std::endl <<
"Run Number : " << psiBin.GetRunNumberInt();
452 vstr = psiBin.GetTimeStartVector();
453 if (vstr.size() < 2) {
454 std::cout << std::endl <<
"**ERROR** couldn't obtain \"Run Start Time\" will quit." << std::endl << std::endl;
457 std::cout << std::endl <<
"Run Start Time : " << vstr[0] <<
"; " << vstr[1];
458 vstr = psiBin.GetTimeStopVector();
459 if (vstr.size() < 2) {
460 std::cout << std::endl <<
"**ERROR** couldn't obtain \"Run Stop Time\" will quit." << std::endl << std::endl;
463 std::cout << std::endl <<
"Run Stop Time : " << vstr[0] <<
"; " << vstr[1];
464 std::cout << std::endl <<
"Laboratory : PSI";
466 if (vstr.size() < 5) {
467 std::cout << std::endl <<
"**ERROR** couldn't obtain \"Instrument\" will quit." << std::endl << std::endl;
470 std::cout << std::endl <<
"Instrument : " << vstr[0];
471 std::cout << std::endl <<
"Beamline : " << vstr[1];
472 std::cout << std::endl <<
"Muon Beam Momentum : " << vstr[2];
473 std::cout << std::endl <<
"Muon Species : " << vstr[3];
474 std::cout << std::endl <<
"Muon Source : " << vstr[4];
475 std::cout << std::endl <<
"Setup : " << psiBin.GetComment();
476 std::cout << std::endl <<
"Comment : n/a";
477 std::cout << std::endl <<
"Sample Name : " << psiBin.GetSample();
478 std::cout << std::endl <<
"Sample Orientation : " << psiBin.GetOrient();
479 dVal = psiBin.GetTemperaturesVector();
480 dErrVal = psiBin.GetDevTemperaturesVector();
481 if (dVal.size() != dErrVal.size()) {
482 std::cout << std::endl <<
"Sample Temperature : " << psiBin.GetTemp();
484 for (
unsigned int i=0; i<dVal.size(); i++) {
485 std::cout << std::endl <<
"Sample Temp. " << i+1 <<
" : " << dVal[i] <<
" (" << dErrVal[i] <<
") K";
488 std::cout << std::endl <<
"Sample Mag. Field : " << psiBin.GetField();
489 std::cout << std::endl <<
"No of Histos : " << psiBin.GetNumberHistoInt();
490 std::cout << std::endl <<
"Time Resolution : " << psiBin.GetBinWidthNanoSec() <<
" ns";
491 for (
int i=0; i<psiBin.GetNumberHistoInt(); i++) {
492 std::cout << std::endl <<
"-------------------";
493 std::cout << std::endl <<
"Histo No : " << i;
494 std::cout << std::endl <<
"Histo Name : " << psiBin.GetNameHisto(i);
495 std::cout << std::endl <<
"Histo Length : " << psiBin.GetHistoLengthBin();
496 std::cout << std::endl <<
"Time Zero Bin : " << psiBin.GetT0Int(i);
497 std::cout << std::endl <<
"First Good Bin : " << psiBin.GetFirstGoodInt(i);
498 std::cout << std::endl <<
"Last Good Bin : " << psiBin.GetLastGoodInt(i);
500 std::cout << std::endl <<
"No of Events : " << psiBin.GetEventsHistoLong(i);
502 std::cout << std::endl <<
"-------------------" << std::endl << std::endl;
523 strncpy(fln, fileName.c_str(),
sizeof(fln));
524 fh = MUD_openRead(fln, &type);
526 std::cerr << std::endl <<
"**ERROR** Couldn't open mud-file " << fileName <<
", sorry." << std::endl;
530 std::cout << std::endl <<
"-------------------";
531 std::cout << std::endl <<
"fileName = " << fileName <<
", fileFormat = MUD";
532 std::cout << std::endl <<
"-------------------";
534 success = MUD_getTitle( fh, str,
sizeof(str) );
536 std::cout << std::endl <<
"Run Title : " << str;
538 std::cout << std::endl <<
"Run Title : ???";
540 success = MUD_getRunNumber( fh, &val );
542 std::cout << std::endl <<
"Run Number : " << val;
544 std::cout << std::endl <<
"Run Number : ???";
548 success = MUD_getTimeBegin( fh, &val );
549 tval =
static_cast<time_t
>(val);
551 dt = localtime(static_cast<const time_t*>(&tval));
553 strftime(str,
sizeof(str),
"%F; %T", dt);
554 std::cout << std::endl <<
"Run Start Time : " << str;
556 std::cout << std::endl <<
"Run Start Time : ???";
559 success = MUD_getTimeEnd( fh, &val );
560 tval =
static_cast<time_t
>(val);
562 dt = localtime(static_cast<const time_t*>(&tval));
564 strftime(str,
sizeof(str),
"%F; %T", dt);
565 std::cout << std::endl <<
"Run Stop Time : " << str;
567 std::cout << std::endl <<
"Run Stop Time : ???";
570 success = MUD_getLab( fh, str,
sizeof(str) );
572 std::cout << std::endl <<
"Laboratory : " << str;
574 std::cout << std::endl <<
"Laboratory : ???";
576 success = MUD_getApparatus( fh, str,
sizeof(str) );
578 std::cout << std::endl <<
"Instrument : " << str;
580 std::cout << std::endl <<
"Instrument : ???";
582 success = MUD_getArea( fh, str,
sizeof(str) );
584 std::cout << std::endl <<
"Beamline : " << str;
586 std::cout << std::endl <<
"Beamline : ???";
588 std::cout << std::endl <<
"Muon Beam Momentum : ???";
589 std::cout << std::endl <<
"Muon Species : positive muon?";
590 std::cout << std::endl <<
"Muon Source : ???";
593 success = MUD_getMethod( fh, str,
sizeof(str) );
595 std::cout << std::endl <<
"Method : " << str;
597 std::cout << std::endl <<
"Method : ???";
600 success = MUD_getSample( fh, str,
sizeof(str) );
602 std::cout << std::endl <<
"Sample Name : " << str;
604 std::cout << std::endl <<
"Sample Name : ???";
607 success = MUD_getOrient( fh, str,
sizeof(str) );
609 std::cout << std::endl <<
"Sample Orientation : " << str;
611 std::cout << std::endl <<
"Sample Orientation : ???";
614 success = MUD_getTemperature( fh, str,
sizeof(str) );
616 std::cout << std::endl <<
"Sample Temperature : " << str;
618 std::cout << std::endl <<
"Sample Temperature : ???";
621 success = MUD_getField( fh, str,
sizeof(str) );
623 std::cout << std::endl <<
"Sample Magn. Field : " << str;
625 std::cout << std::endl <<
"Sample Magn. Field : ???";
629 success = MUD_getHists(fh, &type, &val);
631 std::cout << std::endl <<
"No of Histos : " << val;
634 std::cout << std::endl <<
"No of Histos : ???";
638 REAL64 timeResolution = 0.0;
639 success = MUD_getHistSecondsPerBin( fh, 1, &timeResolution );
640 timeResolution *= 1.0e9;
642 std::cout << std::endl <<
"Time Resolution : " << timeResolution <<
" ns";
644 std::cout << std::endl <<
"Time Resolution : ??? ns";
647 for (
int i=0; i<noHistos; i++) {
648 std::cout << std::endl <<
"-------------------";
649 std::cout << std::endl <<
"Histo No " << i+1;
651 success = MUD_getHistTitle( fh, i+1, str, 1023);
653 std::cout << std::endl <<
"Histo Name : " << str;
655 std::cout << std::endl <<
"Histo Name : ???";
657 success = MUD_getHistNumBins( fh, i+1, &val );
659 std::cout << std::endl <<
"Histo Length : " << val;
661 std::cout << std::endl <<
"Histo Length : ???";
663 success = MUD_getHistT0_Bin( fh, i+1, &val );
665 std::cout << std::endl <<
"Time Zero Bin : " << val;
667 std::cout << std::endl <<
"Time Zero Bin : ???";
669 success = MUD_getHistGoodBin1( fh, i+1, &val );
671 std::cout << std::endl <<
"First Good Bin : " << val;
673 std::cout << std::endl <<
"First Good Bin : ???";
675 success = MUD_getHistGoodBin2( fh, i+1, &val );
677 std::cout << std::endl <<
"Last Good Bin : " << val;
679 std::cout << std::endl <<
"Last Good Bin : ???";
681 success = MUD_getHistNumEvents( fh, i+1, &val );
683 std::cout << std::endl <<
"#Events : " << val;
688 std::cout << std::endl <<
"-------------------" << std::endl << std::endl;
704 std::ifstream fin(fileName.c_str(), std::ifstream::in);
705 if (!fin.is_open()) {
706 std::cout << std::endl <<
"**ERROR** haven't found \"" << fileName <<
"\", will quit." << std::endl << std::endl;
709 std::cout << std::endl <<
"-------------------";
710 std::cout << std::endl <<
"fileName = " << fileName <<
", fileFormat = WKM";
711 std::cout << std::endl <<
"-------------------";
714 fin.getline(header, 256);
715 if (strlen(header) == 0)
717 std::cout << std::endl << header;
719 std::cout << std::endl <<
"-------------------" << std::endl << std::endl;
740 while (isdigit(s[i]))
762 timeinfo = localtime(&rawtime);
763 strftime(buffer, 32,
"%Y", timeinfo);
778 int main(
int argc,
char *argv[])
785 std::string runNo(
"");
786 std::string fileName(
"");
787 std::string fileFormat(
"");
788 std::string year(
"");
789 std::string instrument(
"lem");
793 for (
int i=1; i<argc; i++) {
794 if (!strcmp(argv[i],
"--help") || !strcmp(argv[i],
"-h")) {
797 }
else if (!strcmp(argv[i],
"--version") || !strcmp(argv[i],
"-v")) {
799 #ifdef HAVE_GIT_REV_H 800 std::cout << std::endl <<
"dump_header version: " << PACKAGE_VERSION <<
", git-branch: " << GIT_BRANCH <<
", git-rev: " << GIT_CURRENT_SHA1 <<
" (" << BUILD_TYPE <<
"), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
802 std::cout << std::endl <<
"dump_header version: " << PACKAGE_VERSION <<
" (" << BUILD_TYPE <<
"), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
805 #ifdef HAVE_GIT_REV_H 806 std::cout << std::endl <<
"dump_header git-branch: " << GIT_BRANCH <<
", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
808 std::cout << std::endl <<
"dump_header version: unknown" << std::endl << std::endl;
812 }
else if (!strcmp(argv[i],
"-rn") || !strcmp(argv[i],
"--runNo")) {
814 std::cerr << std::endl <<
"**ERROR** found -rn, --runNo without <runNo>!" << std::endl;
824 std::cerr << std::endl <<
"**ERROR** found -rn, --runNo without <runNo>, or the provided <runNo> ('" << argv[i+1] <<
"') is not a number!" << std::endl;
829 std::cerr << std::endl <<
"**ERROR** found -rn, --runNo with more than one <runNo>! This is not yet supported." << std::endl;
835 }
else if (!strcmp(argv[i],
"-fn") || !strcmp(argv[i],
"--fileName")) {
837 std::cerr << std::endl <<
"**ERROR** found -fn, --fileName without <fileName>!" << std::endl;
841 fileName = argv[i+1];
843 }
else if (!strcmp(argv[i],
"--fileFormat") || !strcmp(argv[i],
"-ff")) {
845 std::cerr << std::endl <<
"**ERROR** found -ff, --fileFormat without <fileFormat>!" << std::endl;
849 std::string ff(argv[i+1]);
850 if (!boost::iequals(ff,
"MusrRoot") && !boost::iequals(ff,
"NeXus") && !boost::iequals(ff,
"ROOT") &&
851 !boost::iequals(ff,
"PSI-BIN") && !boost::iequals(ff,
"PSI-MDU") && !boost::iequals(ff,
"MUD") &&
852 !boost::iequals(ff,
"WKM")) {
853 std::cerr << std::endl <<
"**ERROR** found unsupported muSR file data format: " << argv[i+1] << std::endl;
857 fileFormat = argv[i+1];
859 }
else if (!strcmp(argv[i],
"-y") || !strcmp(argv[i],
"--year")) {
861 std::cerr << std::endl <<
"**ERROR** found -y, --year without <year>!" << std::endl;
866 std::cerr << std::endl <<
"**ERROR** found -y, --year with sensless <year> '" << argv[i+1] <<
"'!" << std::endl;
870 int yy =
static_cast<int>(strtod(argv[i+1], static_cast<char**>(
nullptr)));
872 std::cerr << std::endl <<
"**ERROR** found -y, --year with <year> '" << yy <<
"'!";
873 std::cerr << std::endl <<
" Well, cannot handle files in the pre-muSR time nor in the future." << std::endl;
879 }
else if (!strcmp(argv[i],
"-s") || !strcmp(argv[i],
"--summary")) {
881 }
else if (!strcmp(argv[i],
"-c") || !strcmp(argv[i],
"--counts")) {
883 }
else if (!strcmp(argv[i],
"-i") || !strcmp(argv[i],
"--instrument")) {
885 std::cerr << std::endl <<
"**ERROR** found option --instrument without <instrument> input!" << std::endl;
889 if (strcmp(argv[i+1],
"lem") && strcmp(argv[i+1],
"gps") && strcmp(argv[i+1],
"ltf") &&
890 strcmp(argv[i+1],
"dolly") && strcmp(argv[i+1],
"gpd") && strcmp(argv[i+1],
"hifi") &&
891 strcmp(argv[i+1],
"flame")) {
892 std::cerr << std::endl <<
"**ERROR** found --instrument with unkown instrument name: '" << argv[i+1] <<
"'!" << std::endl;
896 instrument = argv[i+1];
899 std::cerr << std::endl <<
"**ERROR** found unkown option '" << argv[i] <<
"'." << std::endl;
907 std::stringstream ss;
912 if ((runNo.length() != 0) && (fileName.length() != 0)) {
913 std::cerr << std::endl <<
"**ERROR** currently only either runNo or fileName can be handled, not both simultanously." << std::endl;
920 std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
921 std::unique_ptr<PStartupHandler> startupHandler = std::make_unique<PStartupHandler>();
922 if (!startupHandler->StartupFileFound()) {
923 std::cerr << std::endl <<
">> musrfit **WARNING** couldn't find " << startupHandler->GetStartupFilePath().Data();
924 std::cerr << std::endl;
927 saxParser->ConnectToHandler(
"PStartupHandler", startupHandler.get());
934 std::cerr << std::endl <<
">> musrfit **WARNING** Reading/parsing musrfit_startup.xml failed.";
935 std::cerr << std::endl;
940 std::string pathFln(
"");
941 if (fileName ==
"") {
942 int yy =
static_cast<int>(strtod(year.c_str(),
static_cast<char**
>(
nullptr)));
943 int run =
static_cast<int>(strtod(runNo.c_str(),
static_cast<char**
>(
nullptr)));
944 PFindRun findRun(startupHandler->GetDataPathList(), startupHandler->GetRunNameTemplateList(),
945 instrument, yy, run, fileFormat);
946 if (findRun.FoundPathName()) {
947 pathFln = findRun.GetPathName().Data();
949 std::cout <<
"debug> Couldn't find run: " << run <<
" for instrument " << instrument <<
", and year: " << year << std::endl;
957 if (fileFormat ==
"") {
958 std::string fln(pathFln);
959 boost::to_lower(fln);
960 if (fln.find(
".root") != std::string::npos)
961 fileFormat =
"MusrRoot";
962 else if (fln.find(
".nxs") != std::string::npos)
963 fileFormat =
"NeXus";
964 else if (fln.find(
".bin") != std::string::npos)
965 fileFormat =
"PSI-BIN";
966 else if (fln.find(
".mdu") != std::string::npos)
967 fileFormat =
"PSI-MDU";
968 else if (fln.find(
".msr") != std::string::npos)
970 else if ((fln.find(
".nemu") != std::string::npos) || (fln.find(
".wkm") != std::string::npos))
973 if (fileFormat !=
"")
974 std::cout << std::endl <<
"**INFO** the guessed file format is " << fileFormat << std::endl;
976 if (fileFormat ==
"") {
977 std::cout << std::endl <<
"**ERROR** Couldn't guess your file format. You will need to provide it explicitly" << std::endl << std::endl;
981 boost::to_lower(fileFormat);
983 if (boost::iequals(fileFormat,
"MusrRoot") || boost::iequals(fileFormat,
"ROOT")) {
985 }
else if (boost::iequals(fileFormat,
"NeXus")) {
986 #ifdef PNEXUS_ENABLED 989 std::cout << std::endl <<
"Sorry, NeXus is not enabled, hence I cannot help you." << std::endl;
991 }
else if (boost::iequals(fileFormat,
"PSI-BIN") || boost::iequals(fileFormat,
"PSI-MDU")) {
993 }
else if (boost::iequals(fileFormat,
"MUD")) {
995 }
else if (boost::iequals(fileFormat,
"WKM")) {
int parseXmlFile(TSAXParser *, const char *)
std::vector< Int_t > PIntVector
const char * startup_path_name