34 #include <sys/types.h> 49 #include <TObjArray.h> 50 #include <TObjString.h> 57 #include "TLemRunHeader.h" 58 #include "MuSR_td_PSI_bin.h" 67 #define PRH_MUSR_ROOT 0 68 #define PRH_LEM_ROOT 1 70 #define PRH_NPP_OFFSET 0 71 #define PRH_PPC_OFFSET 20 73 #define A2M_UNDEFINED 0 75 #define A2M_MUSR_ROOT 2 83 #define PHR_INIT_ALL 0 84 #define PHR_INIT_MSR 1 85 #define PHR_INIT_ANY2MANY 2 170 fAny2ManyInfo(any2ManyInfo), fDataPath(dataPath)
199 fMsrInfo(msrInfo), fDataPath(dataPath)
233 for (i=0; i<
fData.size(); i++) {
234 if (!
fData[i].GetRunName()->CompareTo(runName))
238 if (i ==
fData.size())
258 if (idx >=
fData.size())
281 Ssiz_t pos=ext.Last(
'.');
282 ext.Remove(0, pos+1);
283 if (!ext.CompareTo(
"bin", TString::kIgnoreCase))
285 else if (!ext.CompareTo(
"root", TString::kIgnoreCase))
287 else if (!ext.CompareTo(
"msr", TString::kIgnoreCase))
289 else if (!ext.CompareTo(
"nxs", TString::kIgnoreCase))
291 else if (!ext.CompareTo(
"mdu", TString::kIgnoreCase))
306 std::cerr << std::endl <<
">> PRunDataHandler::ReadData(): **ERROR** unkown file format \"" <<
fFileFormat <<
"\" found." << std::endl;
310 std::cerr << std::endl <<
">> PRunDataHandler::ReadData(): **ERROR** Couldn't read files." << std::endl;
342 if ((idx == 0) && (
fData.size() == 0)) {
345 if (idx >=
fData.size()) {
346 std::cerr << std::endl <<
">>PRunDataHandler::SetRunData(): **ERROR** idx=" << idx <<
" is out-of-range (0.." <<
fData.size() <<
")." << std::endl;
364 std::cerr << std::endl <<
">> PRunDataHandler::WriteData(): **ERROR** insufficient information: no fileName nor fAny2ManyInfo object.";
365 std::cerr << std::endl <<
" Cannot write data under this conditions." << std::endl;
389 std::cerr << std::endl <<
">> PRunDataHandler::WriteData(): **ERROR** no valid output data file format found: '" <<
fAny2ManyInfo->
outFormat.Data() <<
"'" << std::endl;
393 Bool_t success{
true};
459 Bool_t success =
true;
464 if (runList ==
nullptr) {
465 std::cerr << std::endl <<
">> PRunDataHandler::ReadFilesMsr(): **ERROR** Couldn't obtain run list from PMsrHandler: something VERY fishy";
466 std::cerr << std::endl;
470 char str[1024], *p_str=
nullptr;
472 TString musrRoot(
"musr-root");
474 for (UInt_t i=0; i<runList->size(); i++) {
475 for (UInt_t j=0; j<runList->at(i).GetRunNameSize(); j++) {
476 fRunName = *(runList->at(i).GetRunName(j));
483 p_str = strstr(str,
"lem");
484 if (p_str !=
nullptr)
485 sscanf(p_str,
"lem%d_his", &year);
488 if (!runList->at(i).GetFileFormat(j)->CompareTo(
"root-npp")) {
491 runList->at(i).SetFileFormat(musrRoot, j);
493 for (UInt_t k=0; k<runList->at(i).GetForwardHistoNoSize(); k++) {
495 runList->at(i).SetForwardHistoNo(runList->at(i).GetForwardHistoNo(k)-
PRH_PPC_OFFSET, k);
497 for (UInt_t k=0; k<runList->at(i).GetBackwardHistoNoSize(); k++) {
499 runList->at(i).SetBackwardHistoNo(runList->at(i).GetBackwardHistoNo(k)-
PRH_PPC_OFFSET, k);
501 }
else if (!runList->at(i).GetFileFormat(j)->CompareTo(
"root-ppc")) {
504 runList->at(i).SetFileFormat(musrRoot, j);
506 for (UInt_t k=0; k<runList->at(i).GetForwardHistoNoSize(); k++) {
508 runList->at(i).SetForwardHistoNo(runList->at(i).GetForwardHistoNo(k)+
PRH_PPC_OFFSET, k);
510 for (UInt_t k=0; k<runList->at(i).GetBackwardHistoNoSize(); k++) {
512 runList->at(i).SetBackwardHistoNo(runList->at(i).GetBackwardHistoNo(k)+
PRH_PPC_OFFSET, k);
520 if (!runList->at(i).GetFileFormat(j)->CompareTo(
"root-npp")) {
522 }
else if (!runList->at(i).GetFileFormat(j)->CompareTo(
"root-ppc")) {
524 }
else if (!runList->at(i).GetFileFormat(j)->CompareTo(
"musr-root")) {
526 }
else if (!runList->at(i).GetFileFormat(j)->CompareTo(
"nexus")) {
528 }
else if (!runList->at(i).GetFileFormat(j)->CompareTo(
"psi-bin")) {
530 }
else if (!runList->at(i).GetFileFormat(j)->CompareTo(
"psi-mdu")) {
532 }
else if (!runList->at(i).GetFileFormat(j)->CompareTo(
"mud")) {
534 }
else if (!runList->at(i).GetFileFormat(j)->CompareTo(
"wkm")) {
536 }
else if (!runList->at(i).GetFileFormat(j)->CompareTo(
"mdu-ascii")) {
538 }
else if (!runList->at(i).GetFileFormat(j)->CompareTo(
"ascii")) {
540 }
else if (!runList->at(i).GetFileFormat(j)->CompareTo(
"db")) {
542 }
else if (!runList->at(i).GetFileFormat(j)->CompareTo(
"dat")) {
569 std::cerr << std::endl <<
">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't obtain run list from fAny2ManyInfo: something VERY fishy";
570 std::cerr << std::endl;
594 std::cerr << std::endl <<
">> PRunDataHandler::ReadWriteFilesList(): **ERROR** no valid input data file format found: '" <<
fAny2ManyInfo->
inFormat.Data() <<
"'" << std::endl;
618 std::cerr << std::endl <<
">> PRunDataHandler::ReadWriteFilesList(): **ERROR** no valid output data file format found: '" <<
fAny2ManyInfo->
outFormat.Data() <<
"'" << std::endl;
627 std::cerr << std::endl <<
">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't find file " <<
fAny2ManyInfo->
inFileName[i].Data() << std::endl;
632 Bool_t success =
false;
656 std::cerr << std::endl <<
">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't read file " <<
fAny2ManyInfo->
inFileName[i].Data() << std::endl;
715 if (success ==
false) {
716 std::cerr << std::endl <<
">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't write converted output file." << std::endl;
730 std::cerr << std::endl <<
">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't find run " <<
fAny2ManyInfo->
runList[i] << std::endl;
735 Bool_t success =
false;
759 std::cerr << std::endl <<
">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't read file " <<
fRunPathName.Data() << std::endl;
765 year += dt.GetYear();
771 std::cerr << std::endl <<
">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't create necessary output file name." << std::endl;
806 if (success ==
false) {
807 std::cerr << std::endl <<
">> PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't write converted output file." << std::endl;
825 fln += TString(
".tar.gz");
827 fln += TString(
".tar.bz2");
832 if (system(cmd) == -1) {
833 std::cerr <<
"**ERROR** cmd: " << cmd <<
" failed." << std::endl;
836 fln += TString(
".tar");
843 if (system(cmd) == -1) {
844 std::cerr <<
"**ERROR** cmd: " << cmd <<
" failed." << std::endl;
848 snprintf(cmd,
sizeof(cmd),
"gzip %s", fln.Data());
851 snprintf(cmd,
sizeof(cmd),
"bzip2 -z %s", fln.Data());
854 if (system(cmd) == -1) {
855 std::cerr <<
"**ERROR** cmd: " << cmd <<
" failed." << std::endl;
866 is.open(fln.Data(), std::ios::binary);
868 std::cerr << std::endl <<
"PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't open the file for streaming." << std::endl;
874 is.seekg(0, std::ios::end);
876 is.seekg(0, std::ios::beg);
879 std::cerr << std::endl <<
"PRunDataHandler::ReadWriteFilesList(): **ERROR** Couldn't determine the file size." << std::endl;
885 buffer =
new char [length];
889 is.read(buffer, length);
890 std::cout.write(buffer, length);
924 for (UInt_t i=0; i<
fData.size(); i++) {
925 if (!
fData[i].GetRunName()->CompareTo(runName)) {
945 TString tmpStr(runName), tmpExt(ext);
948 tmpStr += TString(
".") + ext;
949 if (gSystem->AccessPathName(tmpStr.Data()) !=
true) {
957 tmpStr += TString(
".") + tmpExt;
958 if (gSystem->AccessPathName(tmpStr.Data()) !=
true) {
966 tmpStr += TString(
".") + tmpExt;
967 if (gSystem->AccessPathName(tmpStr.Data()) !=
true) {
973 tmpStr = runName + TString(
".") + tmpExt;
975 if (gSystem->AccessPathName(tmpStr.Data()) !=
true) {
982 if (gSystem->AccessPathName(tmpStr.Data()) !=
true) {
990 if (tmpStr.EndsWith(ext.Data(), TString::kIgnoreCase)) {
991 if (gSystem->AccessPathName(tmpStr.Data()) !=
true) {
998 tmpStr = tmpStr.Replace(static_cast<Ssiz_t>(tmpStr.Length()-tmpExt.Length()), tmpExt.Length(), tmpExt);
999 if (gSystem->AccessPathName(tmpStr.Data()) !=
true) {
1007 tmpStr = tmpStr.Replace(static_cast<Ssiz_t>(tmpStr.Length()-tmpExt.Length()), tmpExt.Length(), tmpExt);
1008 if (gSystem->AccessPathName(tmpStr.Data()) !=
true) {
1016 if (gSystem->AccessPathName(tmpStr.Data()) !=
true) {
1024 if (gSystem->AccessPathName(tmpStr.Data()) !=
true) {
1051 Bool_t success =
true;
1054 TROOT root(
"PRunBase",
"PRunBase",
nullptr);
1055 TString pathName =
"???";
1060 if (pstr ==
nullptr) {
1061 std::cerr << std::endl <<
">> PRunDataHandler::FileExistsCheck: **ERROR** Couldn't obtain beamline data." << std::endl;
1067 if (pstr ==
nullptr) {
1068 std::cerr << std::endl <<
">> PRunDataHandler::FileExistsCheck: **ERROR** Couldn't obtain institute data." << std::endl;
1074 if (pstr ==
nullptr) {
1075 std::cerr << std::endl <<
">> PRunDataHandler::FileExistsCheck: **ERROR** Couldn't obtain file format data." << std::endl;
1083 ext = TString(
"root");
1084 else if (!runInfo.
GetFileFormat(idx)->CompareTo(
"root-ppc"))
1085 ext = TString(
"root");
1086 else if (!runInfo.
GetFileFormat(idx)->CompareTo(
"musr-root"))
1087 ext = TString(
"root");
1089 ext = TString(
"NXS");
1091 ext = TString(
"bin");
1093 ext = TString(
"mdu");
1095 ext = TString(
"msr");
1098 ext = TString(
"nemu");
1102 else if (!runInfo.
GetFileFormat(idx)->CompareTo(
"mdu-ascii"))
1103 ext = TString(
"mdua");
1105 ext = TString(
"dat");
1107 ext = TString(
"db");
1109 ext = TString(
"dat");
1116 if (pstr ==
nullptr) {
1117 std::cerr << std::endl <<
">> PRunDataHandler::FileExistsCheck: **ERROR** Couldn't obtain file format data." << std::endl;
1121 std::cerr << std::endl <<
">> PRunDataHandler::FileExistsCheck: **ERROR** File Format '" << pstr->Data() <<
"' unsupported.";
1122 std::cerr << std::endl <<
">> support file formats are:";
1123 std::cerr << std::endl <<
">> ROOT-NPP -> root not post pileup corrected for lem";
1124 std::cerr << std::endl <<
">> ROOT-PPC -> root post pileup corrected for lem";
1125 std::cerr << std::endl <<
">> MUSR-ROOT -> MusrRoot file format";
1126 std::cerr << std::endl <<
">> NEXUS -> nexus file format, HDF4, HDF5, or XML";
1127 std::cerr << std::endl <<
">> PSI-BIN -> psi bin file format";
1128 std::cerr << std::endl <<
">> PSI-MDU -> psi mdu file format (see also MDU-ASCII)";
1129 std::cerr << std::endl <<
">> MUD -> triumf mud file format";
1130 std::cerr << std::endl <<
">> WKM -> wkm ascii file format";
1131 std::cerr << std::endl <<
">> MDU-ASCII -> psi mdu ascii file format";
1132 std::cerr << std::endl <<
">> ASCII -> column like file format";
1133 std::cerr << std::endl <<
">> DB -> triumf db file \"format\"";
1134 std::cerr << std::endl <<
">> DAT -> csv like file \"format\" as exported by msr2data.";
1135 std::cerr << std::endl;
1142 if (!str.IsNull()) {
1147 if (pathName.CompareTo(
"???") == 0) {
1150 if (!str.IsNull()) {
1156 if (pathName.CompareTo(
"???") == 0) {
1157 for (UInt_t i=0; i<
fDataPath.size(); i++) {
1160 if (!str.IsNull()) {
1168 const Char_t *musrpath = gSystem->Getenv(
"MUSRFULLDATAPATH");
1169 if (pathName.CompareTo(
"???") == 0) {
1170 str = TString(musrpath);
1172 TObjArray *tokens = str.Tokenize(
":");
1174 for (Int_t i=0; i<tokens->GetEntries(); i++) {
1175 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
1176 str = ostr->GetString() + TString(
"/") + *runInfo.
GetRunName(idx);
1178 if (!str.IsNull()) {
1191 if (pathName.CompareTo(
"???") == 0) {
1192 str = TString(musrpath);
1194 TObjArray *tokens = str.Tokenize(
":");
1197 if (pstr ==
nullptr) {
1198 std::cerr << std::endl <<
">> PRunDataHandler::FileExistsCheck: **ERROR** Couldn't obtain institute data." << std::endl;
1204 if (pstr ==
nullptr) {
1205 std::cerr << std::endl <<
">> PRunDataHandler::FileExistsCheck: **ERROR** Couldn't obtain beamline data." << std::endl;
1210 for (Int_t i=0; i<tokens->GetEntries(); i++) {
1211 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
1212 str = ostr->GetString() + TString(
"/DATA/") +
1217 if (!str.IsNull()) {
1230 if (pathName.CompareTo(
"???") == 0) {
1231 std::cerr << std::endl <<
">> PRunDataHandler::FileExistsCheck(): **ERROR** Couldn't find '" << runInfo.
GetRunName(idx)->Data() <<
"' in any standard path.";
1232 std::cerr << std::endl <<
">> standard search pathes are:";
1233 std::cerr << std::endl <<
">> 1. the local directory";
1234 std::cerr << std::endl <<
">> 2. the data directory given in the startup XML file";
1235 std::cerr << std::endl <<
">> 3. the directories listed in MUSRFULLDATAPATH";
1236 std::cerr << std::endl <<
">> 4. default path construct which is described in the manual";
1260 TString pathName(
"???");
1266 std::cerr << std::endl <<
">> PRunDataHandler::FileExistsCheck(): **ERROR** idx=" << idx <<
" out of range. (inFileName.size()==" <<
fAny2ManyInfo->
inFileName.size() <<
")" << std::endl;
1272 std::cerr << std::endl <<
">> PRunDataHandler::FileExistsCheck(): **ERROR** idx=" << idx <<
" out of range. (inFileName.size()==" <<
fAny2ManyInfo->
runList.size() <<
")" << std::endl;
1277 std::cerr << std::endl <<
">> PRunDataHandler::FileExistsCheck(): **ERROR** when using run lists, input/output templates are needed as well." << std::endl;
1283 year += dt.GetYear();
1293 if (gSystem->AccessPathName(fln) !=
true) {
1297 if (pathName.CompareTo(
"???") == 0) {
1298 for (UInt_t i=0; i<
fDataPath.size(); i++) {
1299 str =
fDataPath[i] + TString(
"/") + fln;
1300 if (gSystem->AccessPathName(str.Data())!=
true) {
1307 const Char_t *musrpath = gSystem->Getenv(
"MUSRFULLDATAPATH");
1308 if (pathName.CompareTo(
"???") == 0) {
1309 str = TString(musrpath);
1311 TObjArray *tokens = str.Tokenize(
":");
1313 for (Int_t i=0; i<tokens->GetEntries(); i++) {
1314 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
1315 str = ostr->GetString() + TString(
"/") + fln;
1316 if (gSystem->AccessPathName(str.Data())!=
true) {
1328 if (pathName.CompareTo(
"???") == 0) {
1329 std::cerr << std::endl <<
">> PRunDataHandler::FileExistsCheck(): **ERROR** Couldn't find '" << fln.Data() <<
"' in any standard path.";
1330 std::cerr << std::endl <<
">> standard search pathes are:";
1331 std::cerr << std::endl <<
">> 1. the local directory";
1332 std::cerr << std::endl <<
">> 2. the data directory given in the startup XML file";
1333 std::cerr << std::endl <<
">> 3. the directories listed in MUSRFULLDATAPATH";
1356 TString pathName(
"???");
1360 if (gSystem->AccessPathName(fileName) !=
true) {
1361 pathName = fileName;
1364 if (pathName.CompareTo(
"???") == 0) {
1365 for (UInt_t i=0; i<
fDataPath.size(); i++) {
1366 str =
fDataPath[i] + TString(
"/") + fileName;
1367 if (gSystem->AccessPathName(str.Data())!=
true) {
1374 const Char_t *musrpath = gSystem->Getenv(
"MUSRFULLDATAPATH");
1375 if (pathName.CompareTo(
"???") == 0) {
1376 str = TString(musrpath);
1378 TObjArray *tokens = str.Tokenize(
":");
1380 for (Int_t i=0; i<tokens->GetEntries(); i++) {
1381 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
1382 str = ostr->GetString() + TString(
"/") + fileName;
1383 if (gSystem->AccessPathName(str.Data())!=
true) {
1395 if (pathName.CompareTo(
"???") == 0) {
1396 std::cerr << std::endl <<
">> PRunDataHandler::FileExistsCheck(): **ERROR** Couldn't find '" << fileName.Data() <<
"' in any standard path.";
1397 std::cerr << std::endl <<
">> standard search pathes are:";
1398 std::cerr << std::endl <<
">> 1. the local directory";
1399 std::cerr << std::endl <<
">> 2. the data directory given in the startup XML file";
1400 std::cerr << std::endl <<
">> 3. the directories listed in MUSRFULLDATAPATH";
1434 f.GetObject(
"RunInfo", folder);
1436 f.GetObject(
"RunHeader", folder);
1438 std::cerr << std::endl <<
">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't neither obtain RunInfo (LEM),";
1439 std::cerr << std::endl <<
" nor RunHeader (MusrRoot) from " <<
fRunPathName.Data() << std::endl;
1451 TLemRunHeader *runHeader =
dynamic_cast<TLemRunHeader*
>(folder->FindObjectAny(
"TLemRunHeader"));
1455 std::cerr << std::endl <<
">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't obtain run header info from ROOT file " <<
fRunPathName.Data() << std::endl;
1468 TObjString ostr = runHeader->GetRunTitle();
1472 runData.
SetRunNumber(static_cast<Int_t>(runHeader->GetRunNumber()));
1476 runData.
SetTemperature(0, runHeader->GetSampleTemperature(), runHeader->GetSampleTemperatureError());
1479 runData.
SetField(runHeader->GetSampleBField());
1482 runData.
SetEnergy(runHeader->GetImpEnergy());
1488 runData.
SetSetup(runHeader->GetLemSetup().GetString());
1492 time_t idt =
static_cast<time_t
>(runHeader->GetStartTime());
1494 struct tm *dt = localtime(&idt);
1496 strftime(str,
sizeof(str),
"%F", dt);
1500 memset(str, 0,
sizeof(str));
1501 strftime(str,
sizeof(str),
"%T", dt);
1507 idt =
static_cast<time_t
>(runHeader->GetStopTime());
1509 dt = localtime(&idt);
1510 memset(str, 0,
sizeof(str));
1511 strftime(str,
sizeof(str),
"%F", dt);
1515 memset(str, 0,
sizeof(str));
1516 strftime(str,
sizeof(str),
"%T", dt);
1524 Int_t noOfHistos = runHeader->GetNHist();
1527 Double_t *t0 = runHeader->GetTimeZero();
1530 TObjArray *runSummary =
dynamic_cast<TObjArray*
>(folder->FindObjectAny(
"RunSummary"));
1534 std::cout << std::endl <<
"**INFO** Couldn't obtain run summary info from ROOT file " <<
fRunPathName.Data() << std::endl;
1539 TObjArrayIter summIter(runSummary);
1540 TObjString *os(dynamic_cast<TObjString*>(summIter.Next()));
1541 TObjArray *oa(
nullptr);
1542 TObjString *objTok(
nullptr);
1543 while (os !=
nullptr) {
1544 s = os->GetString();
1546 if (s.Contains(
"RA-L")) {
1547 oa = s.Tokenize(
" ");
1548 TObjArrayIter lineIter(oa);
1549 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1550 while (objTok !=
nullptr) {
1551 if (!objTok->GetString().CompareTo(
"RA-L")) {
1552 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1553 if ((objTok !=
nullptr) && !objTok->GetString().CompareTo(
"=")) {
1554 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1559 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1568 if (s.Contains(
"RA-R")) {
1569 oa = s.Tokenize(
" ");
1570 TObjArrayIter lineIter(oa);
1571 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1572 while (objTok !=
nullptr){
1573 if (!objTok->GetString().CompareTo(
"RA-R")) {
1574 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1575 if (objTok !=
nullptr && !objTok->GetString().CompareTo(
"=")) {
1576 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1581 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1590 if (s.Contains(
"RA-T")) {
1591 oa = s.Tokenize(
" ");
1592 TObjArrayIter lineIter(oa);
1593 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1594 while (objTok !=
nullptr){
1595 if (!objTok->GetString().CompareTo(
"RA-T")) {
1596 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1597 if ((objTok !=
nullptr) && !objTok->GetString().CompareTo(
"=")) {
1598 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1603 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1612 if (s.Contains(
"RA-B")) {
1613 oa = s.Tokenize(
" ");
1614 TObjArrayIter lineIter(oa);
1615 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1616 while (objTok !=
nullptr){
1617 if (!objTok->GetString().CompareTo(
"RA-B")) {
1618 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1619 if ((objTok !=
nullptr) && !objTok->GetString().CompareTo(
"=")) {
1620 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1625 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1634 os =
dynamic_cast<TObjString*
>(summIter.Next());
1641 f.GetObject(
"histos", folder);
1643 std::cerr << std::endl <<
">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't obtain histos from " <<
fRunPathName.Data() << std::endl;
1649 Char_t histoName[32];
1650 for (Int_t i=0; i<noOfHistos; i++) {
1651 snprintf(histoName,
sizeof(histoName),
"hDecay%02d", i);
1652 TH1F *histo =
dynamic_cast<TH1F*
>(folder->FindObjectAny(histoName));
1654 std::cerr << std::endl <<
">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't get histo " << histoName;
1655 std::cerr << std::endl;
1661 for (Int_t j=1; j<=histo->GetNbinsX(); j++) {
1662 histoData.push_back(histo->GetBinContent(j));
1667 dataSet.
SetName(histo->GetTitle());
1681 if (!folder->FindObjectAny(histoName)) {
1682 std::cerr << std::endl <<
">> PRunDataHandler::ReadRootFile: **WARNING** Couldn't get histo " << histoName;
1683 std::cerr << std::endl <<
">> most probably this is an old (2006 or earlier) LEM file without post pileup histos.";
1684 std::cerr << std::endl;
1686 for (Int_t i=0; i<noOfHistos; i++) {
1688 TH1F *histo =
dynamic_cast<TH1F*
>(folder->FindObjectAny(histoName));
1690 std::cerr << std::endl <<
">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't get histo " << histoName;
1691 std::cerr << std::endl;
1697 for (Int_t j=1; j<=histo->GetNbinsX(); j++)
1698 histoData.push_back(histo->GetBinContent(j));
1702 dataSet.
SetName(histo->GetTitle());
1717 std::unique_ptr<TMusrRunHeader> header = std::make_unique<TMusrRunHeader>(
true);
1718 if (header ==
nullptr) {
1719 std::cerr << std::endl <<
">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't invoke MusrRoot RunHeader in file:" <<
fRunPathName;
1720 std::cerr << std::endl;
1726 if (!header->ExtractAll(folder)) {
1727 std::cerr << std::endl <<
">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't invoke MusrRoot RunHeader in file:" <<
fRunPathName;
1728 std::cerr << std::endl;
1735 TString str, path, pathName;
1736 Int_t ival, noOfHistos=0;
1741 header->Get(
"RunInfo/Version", str, ok);
1745 header->Get(
"RunInfo/Generic Validator URL", str, ok);
1749 header->Get(
"RunInfo/Specific Validator URL", str, ok);
1753 header->Get(
"RunInfo/Generator", str, ok);
1757 header->Get(
"RunInfo/File Name", str, ok);
1761 header->Get(
"RunInfo/Run Title", str, ok);
1765 header->Get(
"RunInfo/Run Number", ival, ok);
1769 header->Get(
"RunInfo/Run Start Time", str, ok);
1771 Ssiz_t pos = str.Index(
' ');
1772 TString substr = str;
1773 substr.Remove(pos, str.Length());
1776 substr.Remove(0, pos+1);
1780 header->Get(
"RunInfo/Run Stop Time", str, ok);
1782 Ssiz_t pos = str.Index(
' ');
1783 TString substr = str;
1784 substr.Remove(pos, str.Length());
1787 substr.Remove(0, pos+1);
1791 header->Get(
"RunInfo/Laboratory", str, ok);
1795 header->Get(
"RunInfo/Instrument", str, ok);
1799 header->Get(
"RunInfo/Muon Beam Momentum", prop, ok);
1801 if (!prop.
GetUnit().CompareTo(
"MeV/c"))
1805 header->Get(
"RunInfo/Muon Species", str, ok);
1809 header->Get(
"RunInfo/Muon Source", str, ok);
1813 header->Get(
"RunInfo/Muon Spin Angle", prop, ok);
1818 header->Get(
"RunInfo/Setup", str, ok);
1822 header->Get(
"RunInfo/Comment", str, ok);
1826 header->Get(
"RunInfo/Sample Name", str, ok);
1830 header->Get(
"RunInfo/Sample Temperature", prop, ok);
1834 header->Get(
"RunInfo/Sample Magnetic Field", prop, ok);
1837 if (!prop.
GetUnit().CompareTo(
"G") || !prop.
GetUnit().CompareTo(
"Gauss"))
1839 else if (!prop.
GetUnit().CompareTo(
"T") || !prop.
GetUnit().CompareTo(
"Tesla"))
1844 header->Get(
"RunInfo/No of Histos", ival, ok);
1849 header->Get(
"RunInfo/Time Resolution", prop, ok);
1852 if (!prop.
GetUnit().CompareTo(
"ps") || !prop.
GetUnit().CompareTo(
"picosec"))
1854 else if (!prop.
GetUnit().CompareTo(
"ns") || !prop.
GetUnit().CompareTo(
"nanosec"))
1856 else if (!prop.
GetUnit().CompareTo(
"us") || !prop.
GetUnit().CompareTo(
"microsec"))
1859 std::cerr << std::endl <<
">> PRunDataHandler::ReadRootFile: **ERROR** Found unrecognized Time Resolution unit: " << prop.
GetUnit() << std::endl;
1863 header->Get(
"RunInfo/RedGreen Offsets", ivec, ok);
1868 redGreenOffsets.push_back(0);
1871 Bool_t found =
false;
1874 for (UInt_t j=0; j<ivec.size(); j++) {
1879 std::cerr << std::endl <<
">> PRunDataHandler::ReadRootFile: **ERROR** requested histo group " <<
fAny2ManyInfo->
groupHistoList[i];
1880 std::cerr << std::endl <<
">> which is NOT present in the data file." << std::endl;
1889 redGreenOffsets = ivec;
1896 header->Get(
"RunInfo/Moderator HV", prop, ok);
1900 header->Get(
"RunInfo/Implantation Energy", prop, ok);
1906 header->Get(
"SampleEnvironmentInfo/Cryo", str, ok);
1912 header->Get(
"MagneticFieldEnvironmentInfo/Magnet Name", str, ok);
1918 header->Get(
"BeamlineInfo/Name", str, ok);
1923 TObjArray *runSummary =
dynamic_cast<TObjArray*
>(folder->FindObjectAny(
"RunSummary"));
1927 std::cout << std::endl <<
"**INFO** Couldn't obtain run summary info from ROOT file " <<
fRunPathName.Data() << std::endl;
1932 TObjArrayIter summIter(runSummary);
1933 TObjString *os(dynamic_cast<TObjString*>(summIter.Next()));
1934 TObjArray *oa(
nullptr);
1935 TObjString *objTok(
nullptr);
1936 while (os !=
nullptr) {
1937 s = os->GetString();
1939 if (s.Contains(
"RA-L")) {
1940 oa = s.Tokenize(
" ");
1941 TObjArrayIter lineIter(oa);
1942 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1943 while (objTok !=
nullptr) {
1944 if (!objTok->GetString().CompareTo(
"RA-L")) {
1945 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1946 if ((objTok !=
nullptr) && !objTok->GetString().CompareTo(
"=")) {
1947 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1952 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1961 if (s.Contains(
"RA-R")) {
1962 oa = s.Tokenize(
" ");
1963 TObjArrayIter lineIter(oa);
1964 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1965 while (objTok !=
nullptr){
1966 if (!objTok->GetString().CompareTo(
"RA-R")) {
1967 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1968 if ((objTok !=
nullptr) && !objTok->GetString().CompareTo(
"=")) {
1969 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1974 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1983 if (s.Contains(
"RA-T")) {
1984 oa = s.Tokenize(
" ");
1985 TObjArrayIter lineIter(oa);
1986 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1987 while (objTok !=
nullptr){
1988 if (!objTok->GetString().CompareTo(
"RA-T")) {
1989 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1990 if ((objTok !=
nullptr) && !objTok->GetString().CompareTo(
"=")) {
1991 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
1996 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
2005 if (s.Contains(
"RA-B")) {
2006 oa = s.Tokenize(
" ");
2007 TObjArrayIter lineIter(oa);
2008 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
2009 while (objTok !=
nullptr){
2010 if (!objTok->GetString().CompareTo(
"RA-B")) {
2011 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
2012 if ((objTok !=
nullptr) && !objTok->GetString().CompareTo(
"=")) {
2013 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
2018 objTok =
dynamic_cast<TObjString*
>(lineIter.Next());
2027 os =
dynamic_cast<TObjString*
>(summIter.Next());
2034 f.GetObject(
"histos", folder);
2036 std::cerr << std::endl <<
">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't obtain histos from " <<
fRunPathName.Data() << std::endl;
2042 for (UInt_t i=0; i<redGreenOffsets.size(); i++) {
2043 for (Int_t j=0; j<noOfHistos; j++) {
2044 str.Form(
"hDecay%03d", redGreenOffsets[i]+j+1);
2045 TH1F *histo =
dynamic_cast<TH1F*
>(folder->FindObjectAny(str.Data()));
2047 std::cerr << std::endl <<
">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't get histo " << str;
2048 std::cerr << std::endl;
2054 dataSet.
SetName(histo->GetTitle());
2058 path.Form(
"DetectorInfo/Detector%03d/", redGreenOffsets[i]+j+1);
2059 pathName = path +
"Time Zero Bin";
2060 header->Get(pathName, dval, ok);
2063 pathName = path +
"First Good Bin";
2064 header->Get(pathName, ival, ok);
2067 pathName = path +
"Last Good Bin";
2068 header->Get(pathName, ival, ok);
2074 for (Int_t j=1; j<=histo->GetNbinsX(); j++) {
2075 histoData.push_back(histo->GetBinContent(j));
2092 fData.push_back(runData);
2109 #ifdef PNEXUS_ENABLED 2110 std::cout << std::endl <<
">> PRunDataHandler::ReadNexusFile(): Will read nexus file " <<
fRunPathName.Data() <<
" ...";
2120 std::unique_ptr<PNeXus> nxs_file = std::make_unique<PNeXus>(
fRunPathName.Data());
2121 if (!nxs_file->IsValid()) {
2122 std::cerr << std::endl <<
">> PRunDataHandler::ReadNexusFile(): Not a valid NeXus file.";
2123 std::cerr << std::endl <<
">> Error Message: " << nxs_file->GetErrorMsg().data() << std::endl;
2127 if (nxs_file->GetIdfVersion() == 1) {
2128 if (!nxs_file->IsValid()) {
2129 std::cout << std::endl <<
"**ERROR** invalid NeXus IDF 2 version file found." << std::endl;
2136 str = TString(nxs_file->GetEntryIdf1()->GetLaboratory());
2140 str = TString(nxs_file->GetEntryIdf1()->GetBeamline());
2144 str = TString(nxs_file->GetEntryIdf1()->GetInstrument()->GetName());
2148 str = TString(nxs_file->GetEntryIdf1()->GetTitle());
2152 runData.
SetRunNumber(nxs_file->GetEntryIdf1()->GetRunNumber());
2155 dval = nxs_file->GetEntryIdf1()->GetSample()->GetPhysPropValue(
"temperature", ok);
2160 dval = nxs_file->GetEntryIdf1()->GetSample()->GetPhysPropValue(
"magnetic_field", ok);
2161 nxs_file->GetEntryIdf1()->GetSample()->GetPhysPropUnit(
"magnetic_field", sstr, ok);
2164 Double_t factor=1.0;
2165 if (!str.CompareTo(
"gauss", TString::kIgnoreCase))
2167 else if (!str.CompareTo(
"tesla", TString::kIgnoreCase))
2180 for (UInt_t i=0; i<4; i++)
2184 runData.
SetSetup(nxs_file->GetEntryIdf1()->GetNotes());
2187 runData.
SetSample(nxs_file->GetEntryIdf1()->GetSample()->GetName());
2193 runData.
SetTimeResolution(nxs_file->GetEntryIdf1()->GetData()->GetTimeResolution(
"ns"));
2196 sstr = nxs_file->GetEntryIdf1()->GetStartTime();
2205 sstr = nxs_file->GetEntryIdf1()->GetStopTime();
2214 std::vector<unsigned int> *t0 = nxs_file->GetEntryIdf1()->GetData()->GetT0s();
2215 std::vector<unsigned int> *fgb = nxs_file->GetEntryIdf1()->GetData()->GetFirstGoodBins();
2216 std::vector<unsigned int> *lgb = nxs_file->GetEntryIdf1()->GetData()->GetLastGoodBins();
2219 std::vector<unsigned int> *pdata;
2220 unsigned int max=0, binMax=0;
2222 for (UInt_t i=0; i<nxs_file->GetEntryIdf1()->GetData()->GetNoOfHistos(); i++) {
2223 pdata = nxs_file->GetEntryIdf1()->GetData()->GetHisto(i);
2224 for (UInt_t j=0; j<pdata->size(); j++) {
2225 data.push_back(pdata->at(j));
2226 if (pdata->at(j) > max) {
2262 fData.push_back(runData);
2263 }
else if (nxs_file->GetIdfVersion() == 2) {
2264 if (!nxs_file->IsValid()) {
2265 std::cout << std::endl <<
"**ERROR** invalid NeXus IDF 2 version file found." << std::endl;
2271 str = TString(nxs_file->GetEntryIdf2()->GetInstrument()->GetSource()->GetName());
2275 str = TString(nxs_file->GetEntryIdf2()->GetInstrument()->GetName());
2279 str = TString(nxs_file->GetEntryIdf2()->GetInstrument()->GetName());
2283 str = TString(nxs_file->GetEntryIdf2()->GetInstrument()->GetSource()->GetType());
2287 str = TString(nxs_file->GetEntryIdf2()->GetInstrument()->GetSource()->GetProbe());
2291 str = TString(nxs_file->GetEntryIdf2()->GetTitle());
2295 runData.
SetRunNumber(nxs_file->GetEntryIdf2()->GetRunNumber());
2298 dval = nxs_file->GetEntryIdf2()->GetSample()->GetPhysPropValue(
"temperature", ok);
2303 dval = nxs_file->GetEntryIdf2()->GetSample()->GetPhysPropValue(
"magnetic_field", ok);
2304 nxs_file->GetEntryIdf2()->GetSample()->GetPhysPropUnit(
"magnetic_field", sstr, ok);
2307 Double_t factor=1.0;
2308 if (!str.CompareTo(
"gauss", TString::kIgnoreCase))
2310 else if (!str.CompareTo(
"tesla", TString::kIgnoreCase))
2323 for (UInt_t i=0; i<4; i++)
2327 sstr = nxs_file->GetEntryIdf2()->GetSample()->GetEnvironmentTemp() + std::string(
"/");
2328 sstr += nxs_file->GetEntryIdf2()->GetSample()->GetEnvironmentField();
2333 runData.
SetSample(nxs_file->GetEntryIdf2()->GetSample()->GetName());
2339 runData.
SetTimeResolution(nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetTimeResolution(
"ns"));
2342 sstr = nxs_file->GetEntryIdf2()->GetStartTime();
2351 sstr = nxs_file->GetEntryIdf2()->GetStopTime();
2364 int *histos = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetHistos();
2365 if (nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfPeriods() > 0) {
2366 for (
int i=0; i<nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfPeriods(); i++) {
2367 for (
int j=0; j<nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); j++) {
2368 for (
int k=0; k<nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfBins(); k++) {
2369 data.push_back(*(histos+i*nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra()+j*nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfBins()+k));
2374 ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0(i,j);
2376 ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0();
2379 ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetFirstGoodBin(i,j);
2381 ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetFirstGoodBin();
2384 ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetLastGoodBin(i,j);
2386 ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetLastGoodBin();
2395 if (nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra() > 0) {
2396 for (
int i=0; i<nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); i++) {
2397 for (
int j=0; j<nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfBins(); j++) {
2398 data.push_back(*(histos+i*nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfBins()+j));
2403 ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0(-1,i);
2405 ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0();
2408 ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetFirstGoodBin(-1,i);
2410 ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetFirstGoodBin();
2413 ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetLastGoodBin(-1,i);
2415 ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetLastGoodBin();
2423 for (
int i=0; i<nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfBins(); i++) {
2424 data.push_back(*(histos+i));
2429 ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0();
2432 ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetFirstGoodBin();
2435 ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetLastGoodBin();
2448 fData.push_back(runData);
2450 std::cout << std::endl <<
">> PRunDataHandler::ReadNexusFile(): IDF version " << nxs_file->GetIdfVersion() <<
", not implemented." << std::endl;
2453 std::cout << std::endl <<
">> PRunDataHandler::ReadNexusFile(): Sorry, not enabled at configuration level, i.e. --enable-NeXus when executing configure" << std::endl << std::endl;
2480 std::cerr << std::endl <<
">> PRunDataHandler::ReadWkmFile: **ERROR** Couldn't open run data (" <<
fRunPathName.Data() <<
") file for reading, sorry ...";
2481 std::cerr << std::endl;
2486 Bool_t headerInfo =
true;
2488 TString line, linecp;
2492 Int_t groups = 0, channels = 0;
2496 f.getline(instr,
sizeof(instr));
2497 line = TString(instr);
2498 if (!line.IsWhitespace())
2505 line = TString(instr);
2506 if (line.IsDigit()) {
2509 if (line.Contains(
"Title") || line.Contains(
"Titel")) {
2510 idx = line.Index(
":");
2511 line.Replace(0, idx+1,
nullptr, 0);
2514 }
else if (line.Contains(
"Run:")) {
2515 idx = line.Index(
":");
2516 line.Replace(0, idx+1,
nullptr, 0);
2518 ival =
ToInt(line, ok);
2521 }
else if (line.Contains(
"Field")) {
2522 idx = line.Index(
":");
2523 line.Replace(0, idx+1,
nullptr, 0);
2525 idx = line.Index(
"G");
2531 }
else if (line.Contains(
"Setup")) {
2532 idx = line.Index(
":");
2533 line.Replace(0, idx+1,
nullptr, 0);
2536 }
else if (line.Contains(
"Temp:") || line.Contains(
"Temp(meas1):")) {
2538 idx = line.Index(
":");
2539 line.Replace(0, idx+1,
nullptr, 0);
2541 idx = line.Index(
"+/-");
2544 idx = line.Index(
"K");
2551 idx = linecp.Index(
"+/-");
2552 linecp.Replace(0, idx+3,
nullptr, 0);
2558 }
else if (line.Contains(
"Temp(meas2):")) {
2560 idx = line.Index(
":");
2561 line.Replace(0, idx+1,
nullptr, 0);
2563 idx = line.Index(
"+/-");
2566 idx = line.Index(
"K");
2573 idx = linecp.Index(
"+/-");
2574 linecp.Replace(0, idx+3,
nullptr, 0);
2580 }
else if (line.Contains(
"Groups")) {
2581 idx = line.Index(
":");
2582 line.Replace(0, idx+1,
nullptr, 0);
2584 ival =
ToInt(line, ok);
2587 }
else if (line.Contains(
"Channels")) {
2588 idx = line.Index(
":");
2589 line.Replace(0, idx+1,
nullptr, 0);
2591 ival =
ToInt(line, ok);
2594 }
else if (line.Contains(
"Resolution")) {
2595 idx = line.Index(
":");
2596 line.Replace(0, idx+1,
nullptr, 0);
2605 f.getline(instr,
sizeof(instr));
2606 }
while (headerInfo && !f.eof());
2609 std::cerr << std::endl <<
">> PRunDataHandler::ReadWkmFile(): **ERROR** essential header informations are missing!";
2610 std::cerr << std::endl <<
">> groups = " << groups;
2611 std::cerr << std::endl <<
">> channels = " << channels;
2612 std::cerr << std::endl <<
">> time resolution = " << runData.
GetTimeResolution();
2613 std::cerr << std::endl;
2619 UInt_t group_counter = 0;
2634 Double_t maxVal = 0.0;
2636 for (UInt_t i=0; i<histoData.size(); i++) {
2637 if (histoData[i] > maxVal) {
2638 maxVal = histoData[i];
2650 line = TString(instr);
2652 if (!line.IsDigit()) {
2653 f.getline(instr,
sizeof(instr));
2656 tokens = line.Tokenize(
" ");
2659 std::cerr << std::endl <<
">> PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: coulnd't tokenize run data.";
2662 for (Int_t i=0; i<tokens->GetEntries(); i++) {
2663 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
2664 str = ostr->GetString();
2665 val =
ToInt(str, ok);
2667 histoData.push_back(val);
2669 std::cerr << std::endl <<
">> PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: data line contains non-integer values.";
2682 f.getline(instr,
sizeof(instr));
2687 if (strlen(instr) != 0) {
2689 line = TString(instr);
2690 tokens = line.Tokenize(
" ");
2692 std::cerr << std::endl <<
">> PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: coulnd't tokenize run data.";
2695 for (Int_t i=0; i<tokens->GetEntries(); i++) {
2696 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
2697 str = ostr->GetString();
2698 val =
ToInt(str, ok);
2700 histoData.push_back(val);
2702 std::cerr << std::endl <<
">> PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: data line contains non-integer values.";
2716 if (histoData.size() > 0) {
2722 Double_t maxVal = 0.0;
2724 for (UInt_t i=0; i<histoData.size(); i++) {
2725 if (histoData[i] > maxVal) {
2726 maxVal = histoData[i];
2740 if (static_cast<Int_t>(runData.
GetNoOfHistos()) != groups) {
2741 std::cerr << std::endl <<
">> PRunDataHandler::ReadWkmFile(): **ERROR**";
2742 std::cerr << std::endl <<
">> expected " << groups <<
" histos, but found " << runData.
GetNoOfHistos();
2748 if (static_cast<Int_t>(runData.
GetDataBin(i+1)->size()) != channels) {
2749 std::cerr << std::endl <<
">> PRunDataHandler::ReadWkmFile(): **ERROR**";
2750 std::cerr << std::endl <<
">> expected " << channels <<
" bins in histo " << i+1 <<
", but found " << runData.
GetDataBin(i)->size();
2759 fData.push_back(runData);
2777 MuSR_td_PSI_bin psiBin;
2788 std::cerr << std::endl <<
">> **ERROR** couldn't open psi-bin file, or failed while reading the header";
2789 std::cerr << std::endl;
2793 std::cerr << std::endl <<
">> **ERROR** psi-bin file: unsupported version of the data";
2794 std::cerr << std::endl;
2798 std::cerr << std::endl <<
">> **ERROR** psi-bin file: error when allocating data buffer";
2799 std::cerr << std::endl;
2803 std::cerr << std::endl <<
">> **ERROR** psi-bin file: number of histograms/record not equals 1";
2804 std::cerr << std::endl;
2823 fln.Remove(0, pos+1);
2830 TString instrument(
"n/a"), beamline(
"n/a");
2831 TString muonSource(
"n/a"), muonSpecies(
"n/a");
2832 if (
fRunPathName.Contains(
"_gps_", TString::kIgnoreCase)) {
2834 beamline =
"piM3.2";
2835 muonSource =
"continuous surface muon source";
2836 muonSpecies =
"positive muons";
2837 }
else if (
fRunPathName.Contains(
"_ltf_", TString::kIgnoreCase)) {
2839 beamline =
"piM3.3";
2840 muonSource =
"continuous surface muon source";
2841 muonSpecies =
"positive muons";
2842 }
else if (
fRunPathName.Contains(
"_gpd_", TString::kIgnoreCase)) {
2845 muonSource =
"continuous decay channel muon source";
2846 muonSpecies =
"positive muons";
2847 }
else if (
fRunPathName.Contains(
"_dolly_", TString::kIgnoreCase)) {
2848 instrument =
"DOLLY";
2850 muonSource =
"continuous surface muon source";
2851 muonSpecies =
"positive muons";
2852 }
else if (
fRunPathName.Contains(
"_alc_", TString::kIgnoreCase)) {
2855 muonSource =
"continuous surface muon source";
2856 muonSpecies =
"positive muons";
2857 }
else if (
fRunPathName.Contains(
"_hifi_", TString::kIgnoreCase)) {
2858 instrument =
"HIFI";
2860 muonSource =
"continuous surface muon source";
2861 muonSpecies =
"positive muons";
2871 runData.
SetRunTitle(TString(psiBin.GetComment().c_str()));
2875 runData.
SetSetup(TString(psiBin.GetComment().c_str()));
2877 runData.
SetSample(TString(psiBin.GetSample().c_str()));
2881 runData.
SetComment(TString(psiBin.GetComment().c_str()));
2886 Double_t scale = 0.0;
2887 if (psiBin.GetField().rfind(
"G") != std::string::npos)
2889 if (psiBin.GetField().rfind(
"T") != std::string::npos)
2891 status = sscanf(psiBin.GetField().c_str(),
"%lf", &dval);
2896 PDoubleVector tempDevVec(psiBin.GetDevTemperaturesVector());
2897 if ((tempVec.size() > 1) && (tempDevVec.size() > 1) && tempVec[0] && tempVec[1]) {
2900 for (UInt_t i(0); i<2; i++) {
2906 status = sscanf(psiBin.GetTemp().c_str(),
"%lfK", &dval);
2915 std::vector<std::string> sDateTime = psiBin.GetTimeStartVector();
2916 if (sDateTime.size() < 2) {
2917 std::cerr << std::endl <<
">> **WARNING** psi-bin file: couldn't obtain run start date/time" << std::endl;
2919 std::string date(
"");
2923 std::cerr << std::endl <<
">> **WARNING** failed to convert start date: " << sDateTime[0] <<
" into ISO 8601 date." << std::endl;
2929 sDateTime = psiBin.GetTimeStopVector();
2930 if (sDateTime.size() < 2) {
2931 std::cerr << std::endl <<
">> **WARNING** psi-bin file: couldn't obtain run stop date/time" << std::endl;
2933 date = std::string(
"");
2937 std::cerr << std::endl <<
">> **WARNING** failed to convert stop date: " << sDateTime[0] <<
" into ISO 8601 date." << std::endl;
2947 std::cerr << std::endl <<
">> **ERROR** psi-bin file: couldn't obtain any t0's";
2948 std::cerr << std::endl;
2953 PIntVector fgb = psiBin.GetFirstGoodVector();
2955 std::cerr << std::endl <<
">> **ERROR** psi-bin file: couldn't obtain any fgb's";
2956 std::cerr << std::endl;
2963 std::cerr << std::endl <<
">> **ERROR** psi-bin file: couldn't obtain any lgb's";
2964 std::cerr << std::endl;
2971 std::vector<Int_t> histo;
2972 for (Int_t i=0; i<psiBin.GetNumberHistoInt(); i++) {
2973 histo = psiBin.GetHistoArrayInt(i);
2974 for (Int_t j=0; j<psiBin.GetHistoLengthBin(); j++) {
2975 histoData.push_back(histo[j]);
2979 Double_t maxVal = 0.0;
2981 for (UInt_t j=0; j<histoData.size(); j++) {
2982 if (histoData[j] > maxVal) {
2983 maxVal = histoData[j];
2989 dataSet.
SetName(psiBin.GetNameHisto(i).c_str());
2991 if (i < static_cast<Int_t>(t0.size()))
2994 if (i < static_cast<Int_t>(fgb.size()))
2996 if (i < static_cast<Int_t>(lgb.size()))
3006 fData.push_back(runData);
3033 std::cerr << std::endl <<
">> **ERROR** Couldn't open mud-file " <<
fRunPathName.Data() <<
", sorry.";
3034 std::cerr << std::endl;
3044 success = MUD_getLab( fh, str,
sizeof(str) );
3046 std::cerr << std::endl <<
">> **WARNING** Couldn't obtain the laboratory name of run " <<
fRunName.Data();
3047 std::cerr << std::endl;
3053 success = MUD_getArea( fh, str,
sizeof(str) );
3055 std::cerr << std::endl <<
">> **WARNING** Couldn't obtain the beamline of run " <<
fRunName.Data();
3056 std::cerr << std::endl;
3062 success = MUD_getApparatus( fh, str,
sizeof(str) );
3064 std::cerr << std::endl <<
">> **WARNING** Couldn't obtain the instrument name of run " <<
fRunName.Data();
3065 std::cerr << std::endl;
3071 success = MUD_getTitle( fh, str,
sizeof(str) );
3073 std::cerr << std::endl <<
">> **WARNING** Couldn't obtain the run title of run " <<
fRunName.Data();
3074 std::cerr << std::endl;
3079 success = MUD_getRunNumber( fh, &val );
3088 success = MUD_getTimeBegin( fh, (UINT32*)&tval );
3091 dt = localtime((
const time_t*)&tval);
3095 strftime(str,
sizeof(str),
"%F", dt);
3099 memset(str, 0,
sizeof(str));
3100 strftime(str,
sizeof(str),
"%T", dt);
3104 std::cerr <<
"PRunDataHandler::ReadMudFile: **WARNING** run start time readback wrong, will set it to 1900-01-01, 00:00:00" << std::endl;
3105 stime =
"1900-01-01";
3112 stime = TString(
"");
3113 success = MUD_getTimeEnd( fh, (UINT32*)&tval );
3116 dt = localtime((
const time_t*)&tval);
3120 strftime(str,
sizeof(str),
"%F", dt);
3124 memset(str, 0,
sizeof(str));
3125 strftime(str,
sizeof(str),
"%T", dt);
3129 std::cerr <<
"PRunDataHandler::ReadMudFile: **WARNING** run stop time readback wrong, will set it to 1900-01-01, 00:00:00" << std::endl;
3130 stime =
"1900-01-01";
3139 REAL64 timeResMultiplier = 1.0e9;
3140 success = MUD_getLab( fh, str,
sizeof(str) );
3142 setup = TString(str) + TString(
"/");
3144 success = MUD_getArea( fh, str,
sizeof(str) );
3146 setup += TString(str) + TString(
"/");
3147 if (TString(str) ==
"BNQR" || TString(str) ==
"BNMR") {
3148 std::cerr <<
"PRunDataHandler::ReadMudFile: **INFORMATION** this run was performed on " << str << std::endl;
3149 std::cerr <<
"PRunDataHandler::ReadMudFile: **INFORMATION** apply correction to time resolution" << std::endl;
3151 timeResMultiplier = 1.0e9;
3154 success = MUD_getApparatus( fh, str,
sizeof(str) );
3156 setup += TString(str) + TString(
"/");
3158 success = MUD_getSample( fh, str,
sizeof(str) );
3160 setup += TString(str);
3170 success = MUD_getField( fh, str,
sizeof(str) );
3172 success = sscanf(str,
"%lf G", &dval);
3183 success = MUD_getTemperature( fh, str,
sizeof(str) );
3185 success = sscanf(str,
"%lf K", &dval);
3196 success = MUD_getHists(fh, &type, &val);
3198 std::cerr << std::endl <<
">> **ERROR** Couldn't obtain the number of histograms of run " <<
fRunName.Data();
3199 std::cerr << std::endl;
3203 Int_t noOfHistos =
static_cast<Int_t
>(val);
3209 REAL64 timeResolution = 0.0;
3211 for (Int_t i=1; i<=noOfHistos; i++) {
3212 success = MUD_getHistSecondsPerBin( fh, i, &lrval );
3214 std::cerr << std::endl <<
">> **ERROR** Couldn't obtain the time resolution of run " <<
fRunName.Data();
3215 std::cerr << std::endl <<
">> which is fatal, sorry.";
3216 std::cerr << std::endl;
3221 timeResolution = lrval;
3223 if (lrval != timeResolution) {
3224 std::cerr << std::endl <<
">> **ERROR** various time resolutions found in run " <<
fRunName.Data();
3225 std::cerr << std::endl <<
">> this is currently not supported, sorry.";
3226 std::cerr << std::endl;
3233 runData.
SetTimeResolution(static_cast<Double_t>(timeResolution) * timeResMultiplier);
3246 for (Int_t i=1; i<=noOfHistos; i++) {
3252 success = MUD_getHistT0_Bin( fh, i, &val );
3254 std::cerr << std::endl <<
">> **WARNING** Couldn't get t0 of histo " << i <<
" of run " <<
fRunName.Data();
3255 std::cerr << std::endl;
3260 success = MUD_getHistBkgd1( fh, i, &val );
3262 std::cerr << std::endl <<
">> **WARNING** Couldn't get bkg bin 1 of histo " << i <<
" of run " <<
fRunName.Data();
3263 std::cerr << std::endl;
3268 success = MUD_getHistBkgd2( fh, i, &val );
3270 std::cerr << std::endl <<
">> **WARNING** Couldn't get bkg bin 2 of histo " << i <<
" of run " <<
fRunName.Data();
3271 std::cerr << std::endl;
3277 success = MUD_getHistGoodBin1( fh, i, &val );
3279 std::cerr << std::endl <<
">> **WARNING** Couldn't get good bin 1 of histo " << i <<
" of run " <<
fRunName.Data();
3280 std::cerr << std::endl;
3285 success = MUD_getHistGoodBin2( fh, i, &val );
3287 std::cerr << std::endl <<
">> **WARNING** Couldn't get good bin 2 of histo " << i <<
" of run " <<
fRunName.Data();
3288 std::cerr << std::endl;
3294 success = MUD_getHistNumBins( fh, i, &val );
3296 std::cerr << std::endl <<
">> **ERROR** Couldn't get the number of bins of histo " << i <<
".";
3297 std::cerr << std::endl <<
">> This is fatal, sorry.";
3298 std::cerr << std::endl;
3299 MUD_closeRead( fh );
3302 noOfBins =
static_cast<UInt_t
>(val);
3304 pData = (UINT32*)malloc(noOfBins*
sizeof(pData));
3305 if (pData ==
nullptr) {
3306 std::cerr << std::endl <<
">> **ERROR** Couldn't allocate memory for data.";
3307 std::cerr << std::endl <<
">> This is fatal, sorry.";
3308 std::cerr << std::endl;
3309 MUD_closeRead( fh );
3314 success = MUD_getHistData( fh, i, pData );
3316 std::cerr << std::endl <<
">> **ERROR** Couldn't get histo no " << i <<
".";
3317 std::cerr << std::endl <<
">> This is fatal, sorry.";
3318 std::cerr << std::endl;
3319 MUD_closeRead( fh );
3323 for (UInt_t j=0; j<noOfBins; j++) {
3324 histoData.push_back(pData[j]);
3329 Double_t maxVal = 0.0;
3331 for (UInt_t j=0; j<histoData.size(); j++) {
3332 if (histoData[j] > maxVal) {
3333 maxVal = histoData[j];
3349 fData.push_back(runData);
3385 Bool_t success =
true;
3393 std::cerr << std::endl <<
">> PRunDataHandler::ReadMduAsciiFile **ERROR** Couldn't open data file (" <<
fRunPathName.Data() <<
") for reading, sorry ...";
3394 std::cerr << std::endl;
3405 TString line, workStr;
3406 Bool_t headerTag =
false;
3407 Bool_t dataTag =
false;
3408 Int_t dataLineCounter = 0;
3410 TObjArray *tokens =
nullptr;
3414 Double_t dval = 0.0, unitScaling = 0.0;
3415 std::vector<PDoubleVector> data;
3418 f.getline(instr,
sizeof(instr));
3419 line = TString(instr);
3423 if (line.BeginsWith(
"#") || line.BeginsWith(
"%"))
3427 if (line.IsWhitespace())
3432 workStr.Remove(TString::kLeading,
' ');
3433 if (workStr.BeginsWith(
"header", TString::kIgnoreCase)) {
3441 workStr.Remove(TString::kLeading,
' ');
3442 if (workStr.BeginsWith(
"data", TString::kIgnoreCase)) {
3450 workStr.Remove(TString::kLeading,
' ');
3451 if (workStr.BeginsWith(
"title:", TString::kIgnoreCase)) {
3452 runData.
SetRunTitle(TString(workStr.Data()+workStr.First(
":")+2));
3453 }
else if (workStr.BeginsWith(
"field:", TString::kIgnoreCase)) {
3454 tokens = workStr.Tokenize(
":(");
3456 if (tokens->GetEntries() != 3) {
3457 std::cerr << std::endl <<
">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo <<
", invalid field entry in header.";
3458 std::cerr << std::endl <<
">> " << line.Data();
3459 std::cerr << std::endl;
3464 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3465 if (ostr->GetString().IsFloat()) {
3466 dval = ostr->GetString().Atof();
3468 std::cerr << std::endl <<
">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo <<
", field value is not float/doulbe.";
3469 std::cerr << std::endl <<
">> " << line.Data();
3470 std::cerr << std::endl;
3475 ostr =
dynamic_cast<TObjString*
>(tokens->At(2));
3476 if (ostr->GetString().Contains(
"G"))
3478 else if (ostr->GetString().Contains(
"T"))
3479 unitScaling = 1.0e4;
3481 std::cerr << std::endl <<
">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo <<
", unkown field units.";
3482 std::cerr << std::endl <<
">> " << line.Data();
3483 std::cerr << std::endl;
3487 runData.
SetField(dval*unitScaling);
3494 }
else if (workStr.BeginsWith(
"temp:", TString::kIgnoreCase)) {
3495 tokens = workStr.Tokenize(
":(");
3497 if (tokens->GetEntries() != 3) {
3498 std::cerr << std::endl <<
">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo <<
", invalid temperatue entry in header.";
3499 std::cerr << std::endl <<
">> " << line.Data();
3500 std::cerr << std::endl;
3505 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3506 if (ostr->GetString().IsFloat()) {
3507 dval = ostr->GetString().Atof();
3509 std::cerr << std::endl <<
">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo <<
", temperature value is not float/doulbe.";
3510 std::cerr << std::endl <<
">> " << line.Data();
3511 std::cerr << std::endl;
3522 }
else if (workStr.BeginsWith(
"setup:", TString::kIgnoreCase)) {
3523 runData.
SetSetup(TString(workStr.Data()+workStr.First(
":")+2));
3524 }
else if (workStr.BeginsWith(
"groups:", TString::kIgnoreCase)) {
3525 workStr = TString(workStr.Data()+workStr.First(
":")+2);
3526 groups = workStr.Atoi();
3528 std::cerr << std::endl <<
">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo <<
", groups is not a number or 0.";
3529 std::cerr << std::endl;
3533 data.resize(groups);
3534 }
else if (workStr.BeginsWith(
"channels:", TString::kIgnoreCase)) {
3535 workStr = TString(workStr.Data()+workStr.First(
":")+2);
3536 channels = workStr.Atoi();
3537 if (channels == 0) {
3538 std::cerr << std::endl <<
">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo <<
", channels is not a number or 0.";
3539 std::cerr << std::endl;
3543 }
else if (workStr.BeginsWith(
"resolution:", TString::kIgnoreCase)) {
3544 tokens = workStr.Tokenize(
":(");
3546 if (tokens->GetEntries() != 3) {
3547 std::cerr << std::endl <<
">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo <<
", invalid time resolution entry in header.";
3548 std::cerr << std::endl << line.Data();
3549 std::cerr << std::endl;
3554 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3555 if (ostr->GetString().IsFloat()) {
3556 dval = ostr->GetString().Atof();
3558 std::cerr << std::endl <<
">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo <<
", time resolution value is not float/doulbe.";
3559 std::cerr << std::endl <<
">> " << line.Data();
3560 std::cerr << std::endl;
3565 ostr =
dynamic_cast<TObjString*
>(tokens->At(2));
3566 if (ostr->GetString().Contains(
"fs"))
3567 unitScaling = 1.0e-6;
3568 else if (ostr->GetString().Contains(
"ps"))
3569 unitScaling = 1.0e-3;
3570 else if (ostr->GetString().Contains(
"ns"))
3572 else if (ostr->GetString().Contains(
"us"))
3573 unitScaling = 1.0e3;
3575 std::cerr << std::endl <<
">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo <<
", unkown time resolution units.";
3576 std::cerr << std::endl <<
">> " << line.Data();
3577 std::cerr << std::endl;
3589 std::cerr << std::endl <<
">> PRunDataHandler::ReadMduAsciiFile **ERROR** line no " << lineNo <<
", illegal header line.";
3590 std::cerr << std::endl;
3594 }
else if (dataTag) {
3596 tokens = line.Tokenize(
" ,\t");
3598 if (tokens->GetEntries() != groups+1) {
3599 std::cerr << std::endl <<
">> PRunDataHandler::ReadMduAsciiFile **ERROR** found data line with a wrong data format, cannot be handled (line no " << lineNo <<
")";
3600 std::cerr << std::endl <<
">> line:";
3601 std::cerr << std::endl <<
">> " << line.Data();
3602 std::cerr << std::endl;
3607 for (Int_t i=1; i<tokens->GetEntries(); i++) {
3608 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
3609 data[i-1].push_back(ostr->GetString().Atof());
3624 for (UInt_t i=0; i<data.size(); i++) {
3630 Double_t maxVal = 0.0;
3632 for (UInt_t j=0; j<data[i].size(); j++) {
3633 if (data[i][j] > maxVal) {
3634 maxVal = data[i][j];
3643 for (UInt_t i=0; i<data.size(); i++)
3647 if (dataLineCounter != channels) {
3648 std::cerr << std::endl <<
">> PRunDataHandler::ReadMduAsciiFile **WARNING** found " << dataLineCounter <<
" data bins,";
3649 std::cerr << std::endl <<
">> expected " << channels <<
" according to the header." << std::endl;
3652 fData.push_back(runData);
3698 Bool_t success =
true;
3706 std::cerr << std::endl <<
">> PRunDataHandler::ReadAsciiFile **ERROR** Couldn't open data file (" <<
fRunPathName.Data() <<
") for reading, sorry ...";
3707 std::cerr << std::endl;
3722 TString line, workStr;
3723 Bool_t headerTag =
false;
3724 Bool_t dataTag =
false;
3729 f.getline(instr,
sizeof(instr));
3730 line = TString(instr);
3734 if (line.BeginsWith(
"#") || line.BeginsWith(
"%"))
3739 workStr.Remove(TString::kLeading,
' ');
3740 if (workStr.BeginsWith(
"header", TString::kIgnoreCase)) {
3748 workStr.Remove(TString::kLeading,
' ');
3749 if (workStr.BeginsWith(
"data", TString::kIgnoreCase)) {
3756 if (line.IsWhitespace())
3759 workStr.Remove(TString::kLeading,
' ');
3760 if (workStr.BeginsWith(
"title:", TString::kIgnoreCase)) {
3761 runData.
SetRunTitle(TString(workStr.Data()+workStr.First(
":")+2));
3762 }
else if (workStr.BeginsWith(
"setup:", TString::kIgnoreCase)) {
3763 runData.
SetSetup(TString(workStr.Data()+workStr.First(
":")+2));
3764 }
else if (workStr.BeginsWith(
"field:", TString::kIgnoreCase)) {
3765 workStr = TString(workStr.Data()+workStr.First(
":")+2);
3766 if (!workStr.IsFloat()) {
3767 std::cerr << std::endl <<
">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo <<
", field is not a number.";
3768 std::cerr << std::endl;
3773 }
else if (workStr.BeginsWith(
"x-axis-title:", TString::kIgnoreCase)) {
3775 }
else if (workStr.BeginsWith(
"y-axis-title:", TString::kIgnoreCase)) {
3777 }
else if (workStr.BeginsWith(
"temp:", TString::kIgnoreCase)) {
3778 workStr = TString(workStr.Data()+workStr.First(
":")+2);
3779 if (!workStr.IsFloat()) {
3780 std::cerr << std::endl <<
">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo <<
", temperature is not a number.";
3781 std::cerr << std::endl;
3786 }
else if (workStr.BeginsWith(
"energy:", TString::kIgnoreCase)) {
3787 workStr = TString(workStr.Data()+workStr.First(
":")+2);
3788 if (!workStr.IsFloat()) {
3789 std::cerr << std::endl <<
">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo <<
", energy is not a number.";
3790 std::cerr << std::endl;
3797 std::cerr << std::endl <<
">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo <<
", illegal header line.";
3798 std::cerr << std::endl;
3802 }
else if (dataTag) {
3803 if (line.IsWhitespace())
3809 line.Remove(TString::kTrailing,
'\r');
3812 tokens = line.Tokenize(
" ,\t");
3814 if ((tokens->GetEntries() != 2) && (tokens->GetEntries() != 3)) {
3815 std::cerr << std::endl <<
">> PRunDataHandler::ReadAsciiFile **ERROR** found data line with a structure different than \"x, y [, error y]\", cannot be handled (line no " << lineNo <<
")";
3816 std::cerr << std::endl;
3822 ostr =
dynamic_cast<TObjString*
>(tokens->At(0));
3823 if (!ostr->GetString().IsFloat()) {
3824 std::cerr << std::endl <<
">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo <<
": x = " << ostr->GetString().Data() <<
" is not a number, sorry.";
3825 std::cerr << std::endl;
3829 x = ostr->GetString().Atof();
3832 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3833 if (!ostr->GetString().IsFloat()) {
3834 std::cerr << std::endl <<
">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo <<
": y = " << ostr->GetString().Data() <<
" is not a number, sorry.";
3835 std::cerr << std::endl;
3839 y = ostr->GetString().Atof();
3842 if (tokens->GetEntries() == 3) {
3843 ostr =
dynamic_cast<TObjString*
>(tokens->At(2));
3844 if (!ostr->GetString().IsFloat()) {
3845 std::cerr << std::endl <<
">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo <<
": error y = " << ostr->GetString().Data() <<
" is not a number, sorry.";
3846 std::cerr << std::endl;
3850 ey = ostr->GetString().Atof();
3863 exVec.push_back(1.0);
3865 eyVec.push_back(ey);
3868 std::cerr << std::endl <<
">> PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo <<
" neither header nor data line. No idea how to handle it!";
3869 std::cerr << std::endl;
3883 fData.push_back(runData);
4009 Bool_t success =
true;
4017 std::cerr << std::endl <<
">> PRunDataHandler::ReadDBFile **ERROR** Couldn't open data file (" <<
fRunPathName.Data() <<
") for reading, sorry ...";
4018 std::cerr << std::endl;
4030 TString line, workStr;
4032 Bool_t firstData =
true;
4033 Bool_t labelledFormat =
true;
4034 Bool_t dataTagsRead =
false;
4039 TObjArray *tokens =
nullptr;
4043 f.getline(instr,
sizeof(instr));
4044 line = TString(instr);
4048 if (line.BeginsWith(
"#") || line.BeginsWith(
"%"))
4052 if (line.IsWhitespace())
4057 workStr.Remove(TString::kLeading,
' ');
4058 if (workStr.BeginsWith(
"title", TString::kIgnoreCase)) {
4061 }
else if (workStr.BeginsWith(
"abstract", TString::kIgnoreCase)) {
4064 }
else if (workStr.BeginsWith(
"comments", TString::kIgnoreCase)) {
4067 }
else if (workStr.BeginsWith(
"label", TString::kIgnoreCase)) {
4070 }
else if (workStr.BeginsWith(
"data", TString::kIgnoreCase) && !dataTagsRead) {
4071 dataTagsRead =
true;
4075 tokens = workStr.Tokenize(
" ,\t");
4076 for (Int_t i=1; i<tokens->GetEntries(); i++) {
4077 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
4104 if (workStr.BeginsWith(
"\\-e", TString::kIgnoreCase) ||
4105 workStr.BeginsWith(
"\\e", TString::kIgnoreCase) ||
4106 workStr.BeginsWith(
"/-e", TString::kIgnoreCase) ||
4107 workStr.BeginsWith(
"/e", TString::kIgnoreCase)) {
4114 tokens = workStr.Tokenize(
",");
4115 ostr =
dynamic_cast<TObjString*
>(tokens->At(0));
4116 if (!ostr->GetString().IsFloat()) {
4117 labelledFormat =
true;
4119 labelledFormat =
false;
4137 if (labelledFormat) {
4139 const Char_t *str = workStr.Data();
4140 if (isdigit(str[0])) {
4144 std::cerr << std::endl <<
">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo <<
":";
4145 std::cerr << std::endl <<
">> " << workStr.Data();
4146 std::cerr << std::endl <<
">> found potential run data line without run data tag.";
4150 tokens = workStr.Tokenize(
",");
4151 ostr =
dynamic_cast<TObjString*
>(tokens->At(0));
4152 tstr = ostr->GetString();
4153 if (!tstr.IsFloat()) {
4154 std::cerr << std::endl <<
">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo <<
":";
4155 std::cerr << std::endl <<
">> " << workStr.Data();
4156 std::cerr << std::endl <<
">> Expected db-data line with structure: runNo,,, runTitle";
4157 std::cerr << std::endl <<
">> runNo = " << tstr.Data() <<
", seems to be not a number.";
4166 workStr.ReplaceAll(
" ",
"");
4168 tokens = workStr.Tokenize(
"=,");
4169 if (tokens->GetEntries() < 3) {
4170 std::cerr << std::endl <<
">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo <<
":";
4171 std::cerr << std::endl <<
">> " << workStr.Data();
4172 std::cerr << std::endl <<
">> Expected db-data line with structure: tag = val,err1,err2,\\";
4176 ostr =
dynamic_cast<TObjString*
>(tokens->At(0));
4177 tstr = ostr->GetString();
4180 std::cerr << std::endl <<
">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo <<
":";
4181 std::cerr << std::endl <<
">> " << workStr.Data();
4182 std::cerr << std::endl <<
">> data tag error: " << tstr.Data() <<
" seems not present in the data tag list";
4187 switch (tokens->GetEntries()) {
4189 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
4190 tstr = ostr->GetString();
4191 if (!tstr.IsFloat()) {
4192 std::cerr << std::endl <<
">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo <<
":";
4193 std::cerr << std::endl <<
">> " << workStr.Data();
4194 std::cerr << std::endl <<
">> Expected db-data line with structure: tag = val,err1,err2,\\";
4195 std::cerr << std::endl <<
">> val = " << tstr.Data() <<
", seems to be not a number.";
4206 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
4207 tstr = ostr->GetString();
4208 if (!tstr.IsFloat()) {
4209 std::cerr << std::endl <<
">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo <<
":";
4210 std::cerr << std::endl <<
">> " << workStr.Data();
4211 std::cerr << std::endl <<
">> Expected db-data line with structure: tag = val,err1,err2,\\";
4212 std::cerr << std::endl <<
">> val = " << tstr.Data() <<
", seems to be not a number.";
4219 ostr =
dynamic_cast<TObjString*
>(tokens->At(2));
4220 tstr = ostr->GetString();
4221 if (!tstr.IsFloat()) {
4222 std::cerr << std::endl <<
">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo <<
":";
4223 std::cerr << std::endl <<
">> " << workStr.Data();
4224 std::cerr << std::endl <<
">> Expected db-data line with structure: tag = val,err1,err2,\\";
4225 std::cerr << std::endl <<
">> err1 = " << tstr.Data() <<
", seems to be not a number.";
4233 std::cerr << std::endl <<
">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo <<
":";
4234 std::cerr << std::endl <<
">> " << workStr.Data();
4235 std::cerr << std::endl <<
">> Expected db-data line with structure: tag = val,err1,err2,\\";
4243 tokens = workStr.Tokenize(
",");
4245 std::cerr << std::endl <<
">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo <<
":";
4246 std::cerr << std::endl <<
">> " << workStr.Data();
4247 std::cerr << std::endl <<
">> Expected db-data line with structure: val1, err11, err12, ..., valn, errn1, errn2, runNo, , , , runTitle";
4248 std::cerr << std::endl <<
">> found = " << tokens->GetEntries() <<
" tokens, however expected " << 3*runData.
fDataNonMusr.
GetDataTags()->size()+1;
4249 std::cerr << std::endl <<
">> Perhaps there are commas without space inbetween, like 12.3,, 3.2,...";
4255 for (Int_t i=0; i<tokens->GetEntries()-1; i+=3) {
4257 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
4258 tstr = ostr->GetString();
4259 if (!tstr.IsFloat()) {
4260 std::cerr << std::endl <<
">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo <<
":";
4261 std::cerr << std::endl <<
">> " << workStr.Data();
4262 std::cerr << std::endl <<
">> Expected db-data line with structure: val1, err11, err12, ..., valn, errn1, errn2, runNo, , , , runTitle";
4263 std::cerr << std::endl <<
">> value=" << tstr.Data() <<
" seems not to be a number";
4270 ostr =
dynamic_cast<TObjString*
>(tokens->At(i+1));
4271 tstr = ostr->GetString();
4272 if (tstr.IsWhitespace()) {
4274 }
else if (tstr.IsFloat()) {
4277 std::cerr << std::endl <<
">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo <<
":";
4278 std::cerr << std::endl <<
">> " << workStr.Data();
4279 std::cerr << std::endl <<
">> Expected db-data line with structure: val1, err11, err12, ..., valn, errn1, errn2, runNo, , , , runTitle";
4280 std::cerr << std::endl <<
">> error1=" << tstr.Data() <<
" seems not to be a number";
4297 std::cerr << std::endl <<
">> PRunDataHandler::ReadDBFile **ERROR**";
4298 std::cerr << std::endl <<
">> number of LABELS found = " << runData.
fDataNonMusr.
GetLabels()->size();
4300 std::cerr << std::endl <<
">> They have to be equal!!";
4311 std::cerr << std::endl <<
">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo;
4314 std::cerr << std::endl <<
">> They have to be equal!!";
4319 std::cerr << std::endl <<
">> PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo;
4322 std::cerr << std::endl <<
">> They have to be equal!!";
4337 fData.push_back(runData);
4355 Bool_t success =
true;
4363 std::cerr << std::endl <<
">> PRunDataHandler::ReadDatFile **ERROR** Couldn't open data file (" <<
fRunPathName.Data() <<
") for reading, sorry ...";
4364 std::cerr << std::endl;
4374 Bool_t headerInfo=
true;
4379 TObjArray *tokens =
nullptr;
4381 UInt_t noOfDataSets = 0, noOfEntries = 0;
4387 f.getline(instr,
sizeof(instr));
4388 line = TString(instr);
4392 if (line.BeginsWith(
"#") || line.BeginsWith(
"%"))
4396 if (line.IsWhitespace())
4399 tokens = line.Tokenize(
" \t");
4400 if (tokens ==
nullptr) {
4401 std::cerr << std::endl <<
">> PRunDataHandler::ReadDatFile **ERROR** couldn't tokenize the line, in lineNo: " << lineNo;
4402 std::cerr << std::endl <<
">> line: '" << line <<
"'.";
4403 std::cerr << std::endl;
4413 noOfEntries = tokens->GetEntries();
4414 for (Int_t i=0; i<noOfEntries; i++) {
4415 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
4416 tstr = ostr->GetString();
4417 if (!tstr.EndsWith(
"Err", TString::kExact)) {
4419 isData.push_back(
true);
4423 isData.push_back(
false);
4429 if (noOfEntries == 0) {
4430 std::cerr << std::endl <<
">> PRunDataHandler::ReadDatFile **ERROR** header information is missing.";
4431 std::cerr << std::endl;
4434 if (tokens->GetEntries() != noOfEntries) {
4435 std::cerr << std::endl <<
">> PRunDataHandler::ReadDatFile **ERROR** data set with wrong number of entries: " << tokens->GetEntries() <<
", should be " << noOfEntries <<
".";
4436 std::cerr << std::endl <<
">> in line: " << lineNo;
4437 std::cerr << std::endl <<
">> line: '" << line <<
"'.";
4438 std::cerr << std::endl;
4443 for (UInt_t i=0; i<noOfEntries; i++) {
4445 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
4446 tstr = ostr->GetString();
4447 if (!tstr.IsFloat()) {
4448 std::cerr << std::endl <<
">> PRunDataHandler::ReadDatFile **ERROR** data set entry is not a number: " << tstr.Data();
4449 std::cerr << std::endl <<
">> in line: " << lineNo;
4450 std::cerr << std::endl;
4458 if (isData[i-1] == 1) {
4474 for (UInt_t i=0; i<noOfDataSets; i++) {
4485 fData.push_back(runData);
4510 std::cout << std::endl <<
">> PRunDataHandler::WriteMusrRootFile(): writing a root data file (" << fln.Data() <<
") ... " << std::endl;
4513 TFolder *histosFolder;
4514 TFolder *decayAnaModule;
4517 histosFolder = gROOT->GetRootFolder()->AddFolder(
"histos",
"Histograms");
4518 gROOT->GetListOfBrowsables()->Add(histosFolder,
"histos");
4519 decayAnaModule = histosFolder->AddFolder(
"DecayAnaModule",
"muSR decay histograms");
4521 runHeader = gROOT->GetRootFolder()->AddFolder(
"RunHeader",
"MusrRoot Run Header Info");
4522 gROOT->GetListOfBrowsables()->Add(runHeader,
"RunHeader");
4523 std::unique_ptr<TMusrRunHeader> header = std::make_unique<TMusrRunHeader>(
true);
4524 gROOT->GetListOfBrowsables()->Add(runHeader,
"RunHeader");
4527 TString str, pathName;
4533 str =
fData[0].GetGenericValidatorUrl()->Copy();
4534 header->Set(
"RunInfo/Generic Validator URL", str);
4535 str =
fData[0].GetSpecificValidatorUrl()->Copy();
4536 header->Set(
"RunInfo/Specific Validator URL", str);
4537 str =
fData[0].GetGenerator()->Copy();
4538 header->Set(
"RunInfo/Generator", str);
4539 str =
fData[0].GetFileName()->Copy();
4540 header->Set(
"RunInfo/File Name", str);
4541 str =
fData[0].GetRunTitle()->Copy();
4542 header->Set(
"RunInfo/Run Title", str);
4543 header->Set(
"RunInfo/Run Number",
fData[0].GetRunNumber());
4544 str =
fData[0].GetStartDate()->Copy() +
" " +
fData[0].GetStartTime()->Copy();
4545 header->Set(
"RunInfo/Run Start Time", str);
4546 str =
fData[0].GetStopDate()->Copy() +
" " +
fData[0].GetStopTime()->Copy();
4547 header->Set(
"RunInfo/Run Stop Time", str);
4548 ival =
fData[0].GetStopDateTime() -
fData[0].GetStartDateTime();
4549 prop.
Set(
"Run Duration", ival,
"sec");
4550 header->Set(
"RunInfo/Run Duration", prop);
4551 str =
fData[0].GetLaboratory()->Copy();
4552 header->Set(
"RunInfo/Laboratory", str);
4553 str =
fData[0].GetInstrument()->Copy();
4554 header->Set(
"RunInfo/Instrument", str);
4555 dval[0] =
fData[0].GetMuonBeamMomentum();
4556 prop.
Set(
"Muon Beam Momentum", dval[0],
"MeV/c");
4557 header->Set(
"RunInfo/Muon Beam Momentum", prop);
4558 str =
fData[0].GetMuonSpecies()->Copy();
4559 header->Set(
"RunInfo/Muon Species", str);
4560 str =
fData[0].GetMuonSource()->Copy();
4561 header->Set(
"RunInfo/Muon Source", str);
4562 str =
fData[0].GetSetup()->Copy();
4563 header->Set(
"RunInfo/Setup", str);
4564 str =
fData[0].GetComment()->Copy();
4565 header->Set(
"RunInfo/Comment", str);
4566 str =
fData[0].GetSample()->Copy();
4567 header->Set(
"RunInfo/Sample Name", str);
4568 dval[0] =
fData[0].GetTemperature(0);
4569 dval[1] =
fData[0].GetTempError(0);
4571 header->Set(
"RunInfo/Sample Temperature", prop);
4572 dval[0] =
fData[0].GetField();
4573 prop.
Set(
"Sample Magnetic Field", dval[0],
"G");
4574 header->Set(
"RunInfo/Sample Magnetic Field", prop);
4575 header->Set(
"RunInfo/No of Histos", static_cast<Int_t>(
fData[0].GetNoOfHistos()));
4576 dval[0] =
fData[0].GetTimeResolution();
4577 prop.
Set(
"Time Resolution", dval[0],
"ns");
4578 header->Set(
"RunInfo/Time Resolution", prop);
4579 header->Set(
"RunInfo/RedGreen Offsets",
fData[0].GetRedGreenOffset());
4584 UInt_t size =
fData[0].GetNoOfHistos();
4585 for (UInt_t i=0; i<size; i++) {
4586 dataSet =
fData[0].GetDataSet(i,
false);
4587 if (dataSet ==
nullptr) {
4588 std::cerr << std::endl <<
">> PRunDataHandler::WriteMusrRootFile: **ERROR** Couldn't get data set (idx=" << i <<
")";
4589 std::cerr << std::endl <<
">> something is really wrong!" << std::endl;
4593 pathName.Form(
"DetectorInfo/Detector%03d/Name", histoNo);
4595 if (!str.CompareTo(
"n/a"))
4596 str.Form(
"Detector%3d", histoNo);
4597 header->Set(pathName, str);
4598 pathName.Form(
"DetectorInfo/Detector%03d/Histo Number", histoNo);
4599 header->Set(pathName, histoNo);
4600 pathName.Form(
"DetectorInfo/Detector%03d/Histo Length", histoNo);
4602 pathName.Form(
"DetectorInfo/Detector%03d/Time Zero Bin", histoNo);
4604 pathName.Form(
"DetectorInfo/Detector%03d/First Good Bin", histoNo);
4607 pathName.Form(
"DetectorInfo/Detector%03d/Last Good Bin", histoNo);
4613 str =
fData[0].GetCryoName()->Copy();
4614 header->Set(
"SampleEnvironmentInfo/Cryo", str);
4617 str =
fData[0].GetMagnetName()->Copy();
4618 header->Set(
"MagneticFieldEnvironmentInfo/Magnet Name", str);
4621 str =
fData[0].GetBeamline()->Copy();
4622 header->Set(
"BeamlineInfo/Name", str);
4625 std::vector<TH1F*> histos;
4626 TH1F *histo =
nullptr;
4629 for (UInt_t i=0; i<size; i++) {
4630 dataSet =
fData[0].GetDataSet(i,
false);
4631 if (dataSet ==
nullptr) {
4632 std::cerr << std::endl <<
">> PRunDataHandler::WriteMusrRootFile: **ERROR** Couldn't get data set (idx=" << i <<
")";
4633 std::cerr << std::endl <<
">> something is really wrong!" << std::endl;
4636 str.Form(
"hDecay%03d", dataSet->
GetHistoNo());
4637 length = dataSet->
GetData()->size();
4638 histo =
new TH1F(str.Data(), str.Data(), length+1, -0.5,
static_cast<Double_t
>(length)+0.5);
4639 Int_t sum=0, entries=0;
4640 for (UInt_t j=0; j<length; j++) {
4641 entries = dataSet->
GetData()->at(j);
4642 histo->SetBinContent(j+1, entries);
4645 histo->SetEntries(sum);
4646 histos.push_back(histo);
4649 UInt_t dataRebin = 0;
4650 UInt_t dataCount = 0;
4651 for (UInt_t i=0; i<size; i++) {
4652 dataSet =
fData[0].GetDataSet(i,
false);
4653 if (dataSet ==
nullptr) {
4654 std::cerr << std::endl <<
">> PRunDataHandler::WriteMusrRootFile: **ERROR** Couldn't get data set (idx=" << i <<
")";
4655 std::cerr << std::endl <<
">> something is really wrong!" << std::endl;
4658 str.Form(
"hDecay%03d", dataSet->
GetHistoNo());
4659 length = dataSet->
GetData()->size();
4662 Int_t sum=0, entries=0;
4663 for (UInt_t j=0; j<length; j++) {
4666 histo->SetBinContent(dataCount, dataRebin);
4669 entries = dataSet->
GetData()->at(j);
4671 dataRebin +=
static_cast<UInt_t
>(entries);
4673 histo->SetEntries(sum);
4674 histos.push_back(histo);
4679 for (UInt_t i=0; i<histos.size(); i++)
4680 decayAnaModule->Add(histos[i]);
4683 std::unique_ptr<TFile> fout = std::make_unique<TFile>(fln,
"RECREATE", fln);
4684 if (fout ==
nullptr) {
4685 std::cerr << std::endl <<
"PRunDataHandler::WriteMusrRootFile(): **ERROR** Couldn't create ROOT file '" << fln <<
"'" << std::endl;
4690 if (header->FillFolder(runHeader))
4692 histosFolder->Write();
4696 for (UInt_t i=0; i<histos.size(); i++) {
4708 is.open(fln.Data(), std::ios::binary);
4709 if (!is.is_open()) {
4710 std::cerr << std::endl <<
"PRunDataHandler::WriteMusrRootFile(): **ERROR** Couldn't open the root-file for streaming." << std::endl;
4716 is.seekg(0, std::ios::end);
4717 length = is.tellg();
4718 is.seekg(0, std::ios::beg);
4721 std::cerr << std::endl <<
"PRunDataHandler::WriteMusrRootFile(): **ERROR** Couldn't determine the root-file size." << std::endl;
4727 buffer =
new char [length];
4731 is.read(buffer, length);
4732 std::cout.write(buffer, length);
4767 std::cout << std::endl <<
">> PRunDataHandler::WriteRootFile(): writing a root data file (" << fln.Data() <<
") ... " << std::endl;
4770 TFolder *histosFolder;
4771 TFolder *decayAnaModule;
4774 histosFolder = gROOT->GetRootFolder()->AddFolder(
"histos",
"Histograms");
4775 gROOT->GetListOfBrowsables()->Add(histosFolder,
"histos");
4776 decayAnaModule = histosFolder->AddFolder(
"DecayAnaModule",
"muSR decay histograms");
4778 runInfo = gROOT->GetRootFolder()->AddFolder(
"RunInfo",
"LEM RunInfo");
4779 gROOT->GetListOfBrowsables()->Add(runInfo,
"RunInfo");
4780 std::unique_ptr<TLemRunHeader> header = std::make_unique<TLemRunHeader>();
4781 gROOT->GetListOfBrowsables()->Add(runInfo,
"RunInfo");
4784 header->SetRunTitle(
fData[0].GetRunTitle()->Data());
4785 header->SetLemSetup(
fData[0].GetSetup()->Data());
4786 header->SetRunNumber(
fData[0].GetRunNumber());
4787 TString dt = *
fData[0].GetStartDate() +
"/" + *
fData[0].GetStartTime();
4788 header->SetStartTimeString(dt.Data());
4789 dt = *
fData[0].GetStopDate() +
"/" + *
fData[0].GetStopTime();
4790 header->SetStopTimeString(dt.Data());
4791 header->SetStartTime(
fData[0].GetStartDateTime());
4792 header->SetStopTime(
fData[0].GetStopDateTime());
4793 header->SetModeratorHV(-999.9, 0.0);
4794 header->SetSampleHV(-999.9, 0.0);
4795 header->SetImpEnergy(-999.9);
4796 header->SetSampleTemperature(
fData[0].GetTemperature(0),
fData[0].GetTempError(0));
4797 header->SetSampleBField(
fData[0].GetField(), 0.0);
4798 header->SetTimeResolution(
fData[0].GetTimeResolution());
4801 header->SetNHist(
fData[0].GetNoOfHistos());
4802 header->SetCuts(
"none");
4803 header->SetModerator(
"none");
4806 UInt_t NoT0s =
fData[0].GetNoOfHistos();
4807 if (
fData[0].GetNoOfHistos() > NHIST) {
4808 std::cerr << std::endl <<
">> PRunDataHandler::WriteRootFile: **WARNING** found more T0's (" << NoT0s <<
") than can be handled (" << NHIST <<
").";
4809 std::cerr << std::endl <<
">> Will only write the first " << NHIST <<
" T0s!!" << std::endl;
4812 Double_t *tt0 =
new Double_t[NoT0s];
4814 for (UInt_t i=0; i<NoT0s; i++) {
4815 dataSet =
fData[0].GetDataSet(i,
false);
4818 header->SetTimeZero(tt0);
4819 runInfo->Add(header.get());
4822 std::vector<TH1F*> histos;
4823 TH1F *histo =
nullptr;
4827 for (UInt_t i=0; i<
fData[0].GetNoOfHistos(); i++) {
4828 dataSet =
fData[0].GetDataSet(i,
false);
4829 if (dataSet ==
nullptr) {
4830 std::cerr << std::endl <<
">> PRunDataHandler::WriteRootFile: **ERROR** Couldn't get data set (idx=0" << i <<
")";
4831 std::cerr << std::endl <<
">> something is really wrong!" << std::endl;
4834 size = dataSet->
GetData()->size();
4835 snprintf(str,
sizeof(str),
"hDecay%02d", static_cast<Int_t>(i));
4836 histo =
new TH1F(str, str, size+1, -0.5, static_cast<Double_t>(size)+0.5);
4837 for (UInt_t j=0; j<size; j++) {
4838 histo->SetBinContent(j+1, dataSet->
GetData()->at(j));
4840 histos.push_back(histo);
4843 UInt_t dataRebin = 0;
4844 UInt_t dataCount = 0;
4845 for (UInt_t i=0; i<
fData[0].GetNoOfHistos(); i++) {
4846 dataSet =
fData[0].GetDataSet(i,
false);
4847 if (dataSet ==
nullptr) {
4848 std::cerr << std::endl <<
">> PRunDataHandler::WriteNexusFile: **ERROR** Couldn't get data set (idx=0" << i <<
")";
4849 std::cerr << std::endl <<
">> something is really wrong!" << std::endl;
4852 size = dataSet->
GetData()->size();
4853 snprintf(str,
sizeof(str),
"hDecay%02d", static_cast<Int_t>(i));
4856 for (UInt_t j=0; j<size; j++) {
4859 histo->SetBinContent(dataCount, dataRebin);
4862 dataRebin +=
static_cast<UInt_t
>(dataSet->
GetData()->at(j));
4864 histos.push_back(histo);
4869 for (UInt_t i=0; i<histos.size(); i++)
4870 decayAnaModule->Add(histos[i]);
4873 std::unique_ptr<TFile> fout = std::make_unique<TFile>(fln,
"RECREATE", fln);
4874 if (fout ==
nullptr) {
4875 std::cerr << std::endl <<
"PRunDataHandler::WriteRootFile(): **ERROR** Couldn't create ROOT file '" << fln <<
"'" << std::endl;
4881 histosFolder->Write();
4885 for (UInt_t i=0; i<histos.size(); i++) {
4898 is.open(fln.Data(), std::ios::binary);
4899 if (!is.is_open()) {
4900 std::cerr << std::endl <<
"PRunDataHandler::WriteRootFile(): **ERROR** Couldn't open the root-file for streaming." << std::endl;
4906 is.seekg(0, std::ios::end);
4907 length = is.tellg();
4908 is.seekg(0, std::ios::beg);
4911 std::cerr << std::endl <<
"PRunDataHandler::WriteRootFile(): **ERROR** Couldn't determine the root-file size." << std::endl;
4917 buffer =
new char [length];
4921 is.read(buffer, length);
4922 std::cout.write(buffer, length);
4950 #ifdef PNEXUS_ENABLED 4957 std::cout << std::endl <<
">> PRunDataHandler::WriteNexusFile(): writing a NeXus data file (" << fln.Data() <<
") ... " << std::endl;
4960 std::unique_ptr<PNeXus> nxs = std::make_unique<PNeXus>();
4961 if (nxs ==
nullptr) {
4962 std::cerr << std::endl <<
">> PRunDataHandler::WriteNexusFile(): **ERROR** couldn't invoke the NeXus object." << std::endl;
4971 nxs->SetFileName(fln.Data());
4977 tm = localtime(&now);
4978 std::string str(
"");
4980 strftime(cstr,
sizeof(cstr),
"%FT%T", tm);
4981 str = std::string(cstr);
4982 nxs->SetFileTime(str);
4984 nxs->GetEntryIdf1()->SetProgramName(
"any2many");
4985 nxs->GetEntryIdf1()->SetProgramVersion(
"$Id$");
4986 nxs->GetEntryIdf1()->SetRunNumber(
fData[0].GetRunNumber());
4987 nxs->GetEntryIdf1()->SetTitle(
fData[0].GetRunTitle()->Data());
4988 nxs->GetEntryIdf1()->SetNotes(
"n/a");
4989 nxs->GetEntryIdf1()->SetAnalysis(
"muonTD");
4990 if (*
fData[0].GetLaboratory() !=
"n/a")
4991 nxs->GetEntryIdf1()->SetLaboratory(
fData[0].GetLaboratory()->Data());
4992 if (*
fData[0].GetBeamline() !=
"n/a")
4993 nxs->GetEntryIdf1()->SetBeamline(
fData[0].GetBeamline()->Data());
4994 str = std::string(
fData[0].GetStartDate()->Data()) + std::string(
"T") + std::string(
fData[0].GetStartTime()->Data());
4995 nxs->GetEntryIdf1()->SetStartTime(str);
4996 str = std::string(
fData[0].GetStopDate()->Data()) + std::string(
"T") + std::string(
fData[0].GetStopTime()->Data());
4997 nxs->GetEntryIdf1()->SetStopTime(str);
4998 nxs->GetEntryIdf1()->SetSwitchingState(1);
4999 nxs->GetEntryIdf1()->GetUser()->SetName(
"n/a");
5000 nxs->GetEntryIdf1()->GetUser()->SetExperimentNumber(
"n/a");
5001 nxs->GetEntryIdf1()->GetSample()->SetName(
fData[0].GetSample()->Data());
5002 nxs->GetEntryIdf1()->GetSample()->SetPhysProp(
"temperature",
fData[0].GetTemperature(0),
"Kelvin");
5003 nxs->GetEntryIdf1()->GetSample()->SetPhysProp(
"magnetic_field",
fData[0].GetField(),
"Gauss");
5004 nxs->GetEntryIdf1()->GetSample()->SetEnvironment(
fData[0].GetSetup()->Data());
5005 nxs->GetEntryIdf1()->GetSample()->SetShape(
"n/a");
5006 nxs->GetEntryIdf1()->GetSample()->SetMagneticFieldVectorAvailable(0);
5007 if (*
fData[0].GetInstrument() !=
"n/a")
5008 nxs->GetEntryIdf1()->GetInstrument()->SetName(
fData[0].GetInstrument()->Data());
5009 nxs->GetEntryIdf1()->GetInstrument()->GetDetector()->SetNumber(
fData[0].GetNoOfHistos());
5010 nxs->GetEntryIdf1()->GetInstrument()->GetCollimator()->SetType(
"n/a");
5012 double total_counts = 0;
5014 for (
unsigned int i=0; i<
fData[0].GetNoOfHistos(); i++) {
5015 dataSet =
fData[0].GetDataSet(i,
false);
5016 if (dataSet ==
nullptr) {
5017 std::cerr << std::endl <<
">> PRunDataHandler::WriteNexusFile: **ERROR** Couldn't get data set (idx=0" << i <<
")";
5018 std::cerr << std::endl <<
">> something is really wrong!" << std::endl;
5021 for (
unsigned int j=0; j<dataSet->
GetData()->size(); j++)
5022 total_counts += dataSet->
GetData()->at(j);
5024 double total_counts_mev = (double) total_counts / 1.0e6;
5025 nxs->GetEntryIdf1()->GetInstrument()->GetBeam()->SetTotalCounts(total_counts_mev);
5026 nxs->GetEntryIdf1()->GetInstrument()->GetBeam()->SetUnits(
"Mev");
5030 for (
unsigned int i=0; i<
fData[0].GetNoOfHistos(); i++) {
5031 dataSet =
fData[0].GetDataSet(i,
false);
5041 for (UInt_t i=0; i<
fData[0].GetNoOfHistos(); i++) {
5042 dataSet =
fData[0].GetDataSet(i,
false);
5043 if (dataSet ==
nullptr) {
5044 std::cerr << std::endl <<
">> PRunDataHandler::WriteNexusFile: **ERROR** Couldn't get data set (idx=" << i <<
")";
5045 std::cerr << std::endl <<
">> something is really wrong!" << std::endl;
5048 size = dataSet->
GetData()->size();
5049 for (UInt_t j=0; j<size; j++) {
5050 data.push_back((UInt_t)dataSet->
GetData()->at(j));
5052 nxs->GetEntryIdf1()->GetData()->SetHisto(data, i);
5056 UInt_t dataRebin = 0;
5057 UInt_t dataCount = 0;
5058 for (UInt_t i=0; i<
fData[0].GetNoOfHistos(); i++) {
5059 dataSet =
fData[0].GetDataSet(i,
false);
5060 if (dataSet ==
nullptr) {
5061 std::cerr << std::endl <<
">> PRunDataHandler::WriteNexusFile: **ERROR** Couldn't get data set (idx=" << i <<
")";
5062 std::cerr << std::endl <<
">> something is really wrong!" << std::endl;
5065 size = dataSet->
GetData()->size();
5067 for (UInt_t j=0; j<size; j++) {
5070 data.push_back(dataRebin);
5073 dataRebin +=
static_cast<UInt_t
>(dataSet->
GetData()->at(j));
5075 nxs->GetEntryIdf1()->GetData()->SetHisto(data, i);
5081 nxs->SetFileName(fln.Data());
5087 tm = localtime(&now);
5088 std::string str(
"");
5090 strftime(cstr,
sizeof(cstr),
"%FT%T", tm);
5091 str = std::string(cstr);
5092 nxs->SetFileTime(str);
5095 nxs->SetCreator(
"PSI: any2many");
5098 nxs->GetEntryIdf2()->SetDefinition(
"muonTD");
5099 nxs->GetEntryIdf2()->SetProgramName(
"any2many");
5100 nxs->GetEntryIdf2()->SetProgramVersion(
"$Id$");
5101 nxs->GetEntryIdf2()->SetRunNumber(
fData[0].GetRunNumber());
5102 nxs->GetEntryIdf2()->SetTitle(
fData[0].GetRunTitle()->Data());
5103 str = std::string(
fData[0].GetStartDate()->Data()) + std::string(
"T") + std::string(
fData[0].GetStartTime()->Data());
5104 nxs->GetEntryIdf2()->SetStartTime(str);
5105 str = std::string(
fData[0].GetStopDate()->Data()) + std::string(
"T") + std::string(
fData[0].GetStopTime()->Data());
5106 nxs->GetEntryIdf2()->SetStopTime(str);
5108 nxs->GetEntryIdf2()->SetExperimentIdentifier(
"n/a");
5111 nxs->GetEntryIdf2()->GetUser()->SetName(
"n/a");
5114 nxs->GetEntryIdf2()->GetSample()->SetName(
fData[0].GetSample()->Data());
5115 nxs->GetEntryIdf2()->GetSample()->SetDescription(
"n/a");
5116 nxs->GetEntryIdf2()->GetSample()->SetPhysProp(
"temperature_1",
fData[0].GetTemperature(0),
"Kelvin");
5117 nxs->GetEntryIdf2()->GetSample()->SetPhysProp(
"magnetic_field_1",
fData[0].GetField(),
"Gauss");
5118 nxs->GetEntryIdf2()->GetSample()->SetEnvironmentTemp(
fData[0].GetSetup()->Data());
5119 nxs->GetEntryIdf2()->GetSample()->SetEnvironmentField(
"n/a");
5122 nxs->GetEntryIdf2()->GetInstrument()->SetName(
fData[0].GetInstrument()->Data());
5125 nxs->GetEntryIdf2()->GetInstrument()->GetSource()->SetName(
fData[0].GetLaboratory()->Data());
5126 nxs->GetEntryIdf2()->GetInstrument()->GetSource()->SetType(
fData[0].GetMuonSource()->Data());
5127 nxs->GetEntryIdf2()->GetInstrument()->GetSource()->SetProbe(
fData[0].GetMuonSpecies()->Data());
5130 nxs->GetEntryIdf2()->GetInstrument()->GetBeamline()->SetName(
fData[0].GetBeamline()->Data());
5133 nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetDescription(
fData[0].GetInstrument()->Data());
5134 nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetNoOfPeriods(0);
5135 nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetNoOfSpectra(
fData[0].GetNoOfHistos());
5137 if (dataSet ==
nullptr) {
5138 std::cerr << std::endl <<
">> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't get data set (idx=0)";
5139 std::cerr << std::endl <<
">> something is really wrong!" << std::endl;
5142 nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetNoOfBins((
unsigned int)(dataSet->
GetData()->size() /
fAny2ManyInfo->
rebin));
5143 nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetTimeResolution(
fData[0].GetTimeResolution()*
fAny2ManyInfo->
rebin,
"ns");
5144 int *histo =
nullptr;
5147 histo =
new int[
fData[0].GetNoOfHistos()*dataSet->
GetData()->size()];
5149 for (
int i=0; i<nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); i++) {
5150 dataSet =
fData[0].GetDataSet(i,
false);
5151 if (dataSet ==
nullptr) {
5152 std::cerr << std::endl <<
">> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't get data set (idx=" << i <<
")";
5153 std::cerr << std::endl <<
">> something is really wrong!" << std::endl;
5156 for (
unsigned int j=0; j<dataSet->
GetData()->size(); j++) {
5157 *(histo+idx++) = (
int) dataSet->
GetData()->at(j);
5160 nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetHistos(histo);
5170 for (
int i=0; i<nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); i++) {
5171 dataSet =
fData[0].GetDataSet(i,
false);
5172 if (dataSet ==
nullptr) {
5173 std::cerr << std::endl <<
">> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't get data set (idx=" << i <<
")";
5174 std::cerr << std::endl <<
">> something is really wrong!" << std::endl;
5177 for (
unsigned int j=0; j<dataSet->
GetData()->size(); j++) {
5179 *(histo+idx++) = counts;
5182 counts += (int) dataSet->
GetData()->at(j);
5185 nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetHistos(histo);
5194 for (
int i=0; i<nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); i++)
5195 nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetSpectrumIndex(i+1);
5198 nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetTimeResolution(
fData[0].GetTimeResolution()*
fAny2ManyInfo->
rebin,
"ns");
5201 std::vector<double> raw_time;
5203 for (
unsigned int i=0; i<size; i++) {
5206 nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetRawTime(raw_time);
5207 nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetRawTimeUnit(
"micro.second");
5208 nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetRawTimeName(
"time");
5212 nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetT0Tag(2);
5213 int *t0 =
new int[
fData[0].GetNoOfHistos()];
5214 int *fgb =
new int[
fData[0].GetNoOfHistos()];
5215 int *lgb =
new int[
fData[0].GetNoOfHistos()];
5216 if ((t0==0) || (fgb==0) || (lgb==0)) {
5217 std::cerr << std::endl <<
">> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't allocate memory for t0, fgb, lgb" << std::endl;
5220 for (
unsigned int i=0; i<
fData[0].GetNoOfHistos(); i++) {
5222 if (dataSet ==
nullptr) {
5223 std::cerr << std::endl <<
">> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't get data set (idx=0)";
5224 std::cerr << std::endl <<
">> something is really wrong!" << std::endl;
5231 nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetT0(t0);
5232 nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetFirstGoodBin(fgb);
5233 nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetLastGoodBin(lgb);
5236 if (t0)
delete [] t0;
5237 if (fgb)
delete [] fgb;
5238 if (lgb)
delete [] lgb;
5245 memset(fileType,
'\0', 32);
5247 strncpy(fileType,
"hdf4",
sizeof(fileType));
5249 strncpy(fileType,
"hdf5",
sizeof(fileType));
5251 strncpy(fileType,
"xml",
sizeof(fileType));
5253 std::cerr << std::endl <<
">> PRunDataHandler::WriteNexusFile(): **ERROR** undefined output NeXus format " <<
fAny2ManyInfo->
outFormat.Data() <<
" found.";
5254 std::cerr << std::endl <<
">> Allowed are: hdf4, hdf5, xml" << std::endl;
5261 std::cout << std::endl <<
">> PRunDataHandler::WriteNexusFile(): Sorry, not enabled at configuration level, i.e. --enable-NeXus when executing configure" << std::endl << std::endl;
5282 bool lem_wkm_style =
false;
5283 if (!
fData[0].GetBeamline()->CompareTo(
"mue4", TString::kIgnoreCase))
5284 lem_wkm_style =
true;
5295 TString fileName = fln;
5298 std::cout << std::endl <<
">> PRunDataHandler::WriteWkmFile(): writing a wkm data file (" << fln.Data() <<
") ... " << std::endl;
5302 std::streambuf* strm_buffer =
nullptr;
5306 fout.open(fln.Data(), std::ofstream::out);
5307 if (!fout.is_open()) {
5308 std::cerr << std::endl <<
">> PRunDataHandler::WriteWkmFile **ERROR** Couldn't open data file (" << fln.Data() <<
") for writing, sorry ...";
5309 std::cerr << std::endl;
5314 strm_buffer = std::cout.rdbuf();
5317 std::cout.rdbuf(fout.rdbuf());
5321 std::cout <<
"- WKM data file converted with any2many";
5322 if (lem_wkm_style) {
5323 std::cout << std::endl <<
"NEMU_Run: " <<
fData[0].GetRunNumber();
5324 std::cout << std::endl <<
"nemu_Run: " << fileName.Data();
5326 std::cout << std::endl <<
"Run: " <<
fData[0].GetRunNumber();
5328 std::cout << std::endl <<
"Date: " <<
fData[0].GetStartTime()->Data() <<
" " <<
fData[0].GetStartDate()->Data() <<
" / " <<
fData[0].GetStopTime()->Data() <<
" " <<
fData[0].GetStopDate()->Data();
5329 if (
fData[0].GetRunTitle()->Length() > 0)
5330 std::cout << std::endl <<
"Title: " <<
fData[0].GetRunTitle()->Data();
5332 std::cout << std::endl <<
"Field: " <<
fData[0].GetField();
5334 std::cout << std::endl <<
"Field: ??";
5336 std::cout << std::endl <<
"Setup: " <<
fData[0].GetSetup()->Data();
5337 if (
fData[0].GetNoOfTemperatures() == 1) {
5338 std::cout << std::endl <<
"Temp: " <<
fData[0].GetTemperature(0);
5339 }
else if (
fData[0].GetNoOfTemperatures() > 1) {
5340 std::cout << std::endl <<
"Temp(meas1): " <<
fData[0].GetTemperature(0) <<
" +- " <<
fData[0].GetTempError(0);
5341 std::cout << std::endl <<
"Temp(meas2): " <<
fData[0].GetTemperature(1) <<
" +- " <<
fData[0].GetTempError(1);
5343 std::cout << std::endl <<
"Temp: ??";
5346 std::cout << std::endl <<
"TOF(M3S1): nocut";
5347 std::cout << std::endl <<
"Groups: " <<
fData[0].GetNoOfHistos();
5352 std::cout << std::endl <<
"Channels: " <<
static_cast<UInt_t
>(
fData[0].GetDataBin(histo0)->size()/
fAny2ManyInfo->
rebin);
5353 std::cout.precision(10);
5355 std::cout.setf(std::ios::fixed,std::ios::floatfield);
5358 UInt_t no_of_bins_per_line = 16;
5360 no_of_bins_per_line = 10;
5365 for (UInt_t i=0; i<
fData[0].GetNoOfHistos(); i++) {
5366 std::cout << std::endl << std::endl;
5367 dataSet =
fData[0].GetDataSet(i,
false);
5368 for (UInt_t j=0; j<dataSet->
GetData()->size(); j++) {
5369 if ((j > 0) && (j % no_of_bins_per_line == 0))
5370 std::cout << std::endl;
5372 std::cout << std::setw(8) << static_cast<Int_t>(dataSet->
GetData()->at(j));
5374 std::cout << static_cast<Int_t>(dataSet->
GetData()->at(j)) <<
" ";
5378 Int_t dataRebin = 0;
5380 for (UInt_t i=0; i<
fData[0].GetNoOfHistos(); i++) {
5381 std::cout << std::endl << std::endl;
5384 dataSet =
fData[0].GetDataSet(i,
false);
5385 for (UInt_t j=0; j<dataSet->
GetData()->size(); j++) {
5388 std::cout << std::setw(8) << dataRebin;
5390 std::cout << dataRebin <<
" ";
5393 if ((count > 0) && (count % no_of_bins_per_line == 0) && (j != dataSet->
GetData()->size()-1))
5394 std::cout << std::endl;
5396 dataRebin +=
static_cast<Int_t
>(dataSet->
GetData()->at(j));
5404 std::cout.rdbuf(strm_buffer);
5432 std::cout << std::endl <<
">> PRunDataHandler::WritePsiBinFile(): writing a psi-bin data file (" << fln.Data() <<
") ... " << std::endl;
5434 MuSR_td_PSI_bin psibin;
5439 psibin.PutRunNumberInt(
fData[0].GetRunNumber());
5447 psibin.PutNumberHistoInt(static_cast<int>(
fData[0].GetNoOfHistos()));
5451 if (
fData[0].GetSample()->Length() > 0)
5452 strncpy(cstr,
fData[0].GetSample()->Data(), 10);
5456 psibin.PutSample(cstr);
5458 if (
fData[0].GetNoOfTemperatures() > 0)
5459 snprintf(cstr, 10,
"%.1f K",
fData[0].GetTemperature(0));
5461 strcpy(cstr,
"?? K");
5463 psibin.PutTemp(cstr);
5465 if (
fData[0].GetField() > 0)
5466 snprintf(cstr, 10,
"%.1f G",
fData[0].GetField());
5468 strcpy(cstr,
"?? G");
5470 psibin.PutField(cstr);
5472 if (
fData[0].GetOrientation()->Length() > 0)
5473 strncpy(cstr,
fData[0].GetOrientation()->Data(), 10);
5477 psibin.PutOrient(cstr);
5479 if (
fData[0].GetSetup()->Length() > 0)
5480 strncpy(cstr,
fData[0].GetSetup()->Data(), 10);
5484 psibin.PutSetup(cstr);
5489 std::vector<std::string> svec;
5492 int year, month, day;
5497 date.Append(*
fData[0].GetStartDate());
5498 sscanf((
const char*)date.Data(),
"%04d-%02d-%02d", &year, &month, &day);
5499 dt.Set(year, month, day, 0, 0, 0);
5501 date.Form(
"%02d-", dt.GetDay());
5502 date.Append(
GetMonth(dt.GetMonth()));
5504 date.Append(
GetYear(dt.GetYear()));
5505 strncpy(cstr, date.Data(), 9);
5507 svec.push_back(cstr);
5509 strncpy(cstr,
fData[0].GetStartTime()->Data(), 8);
5511 svec.push_back(cstr);
5512 psibin.PutTimeStartVector(svec);
5520 date.Append(*
fData[0].GetStopDate());
5521 sscanf((
const char*)date.Data(),
"%04d-%02d-%02d", &year, &month, &day);
5522 dt.Set(year, month, day, 0, 0, 0);
5524 date.Form(
"%02d-", dt.GetDay());
5525 date.Append(
GetMonth(dt.GetMonth()));
5527 date.Append(
GetYear(dt.GetYear()));
5528 strncpy(cstr, date.Data(), 9);
5530 svec.push_back(cstr);
5532 strncpy(cstr,
fData[0].GetStopTime()->Data(), 8);
5534 svec.push_back(cstr);
5535 psibin.PutTimeStopVector(svec);
5539 psibin.PutNumberTemperatureInt(
fData[0].GetNoOfTemperatures());
5542 std::vector<double> dvec;
5543 for (UInt_t i=0; i<
fData[0].GetNoOfTemperatures(); i++)
5544 dvec.push_back(
fData[0].GetTemperature(i));
5545 psibin.PutTemperaturesVector(dvec);
5549 for (UInt_t i=0; i<
fData[0].GetNoOfTemperatures(); i++)
5550 dvec.push_back(
fData[0].GetTempError(i));
5551 psibin.PutDevTemperaturesVector(dvec);
5554 psibin.PutComment(
fData[0].GetRunTitle()->Data());
5560 psibin.PutNumberScalerInt(0);
5565 UInt_t size =
fData[0].GetNoOfHistos();
5566 for (UInt_t i=0; i<size; i++) {
5567 dataSet =
fData[0].GetDataSet(i,
false);
5568 if (dataSet ==
nullptr) {
5569 std::cerr << std::endl <<
">> PRunDataHandler::WritePsiBinFile: **ERROR** Couldn't get data set (idx=" << i <<
")";
5570 std::cerr << std::endl <<
">> something is really wrong!" << std::endl;
5576 if (!str.CompareTo(
"n/a"))
5577 str.Form(
"Detector%3d", i+1);
5578 psibin.PutNameHisto(str.Data(), i);
5581 psibin.PutT0Int(i, ival);
5584 psibin.PutFirstGoodInt(i, ival);
5587 psibin.PutLastGoodInt(i, ival);
5591 std::vector< std::vector<int> > histos;
5592 histos.resize(
fData[0].GetNoOfHistos());
5595 for (UInt_t i=0; i<size; i++) {
5596 dataSet =
fData[0].GetDataSet(i,
false);
5597 if (dataSet ==
nullptr) {
5598 std::cerr << std::endl <<
">> PRunDataHandler::WritePsiBinFile: **ERROR** Couldn't get data set (idx=" << i <<
")";
5599 std::cerr << std::endl <<
">> something is really wrong!" << std::endl;
5602 length = dataSet->
GetData()->size();
5603 histos[i].resize(length);
5604 for (UInt_t j=0; j<length; j++) {
5605 histos[i][j] =
static_cast<Int_t
>(dataSet->
GetData()->at(j));
5609 UInt_t dataRebin = 0;
5610 UInt_t dataCount = 0;
5611 for (UInt_t i=0; i<size; i++) {
5612 dataSet =
fData[0].GetDataSet(i,
false);
5613 if (dataSet ==
nullptr) {
5614 std::cerr << std::endl <<
">> PRunDataHandler::WritePsiBinFile: **ERROR** Couldn't get data set (idx=" << i <<
")";
5615 std::cerr << std::endl <<
">> something is really wrong!" << std::endl;
5618 length = dataSet->
GetData()->size();
5620 for (UInt_t j=0; j<length; j++) {
5623 histos[i].push_back(dataRebin);
5626 dataRebin +=
static_cast<UInt_t
>(dataSet->
GetData()->at(j));
5630 status = psibin.PutHistoArrayInt(histos, 2);
5632 std::cerr << std::endl <<
">> PRunDataHandler::WritePsiBinFile(): " << psibin.ConsistencyStatus() << std::endl;
5636 if (!psibin.CheckDataConsistency(2)) {
5637 std::cerr << std::endl <<
">> PRunDataHandler::WritePsiBinFile(): " << psibin.ConsistencyStatus() << std::endl;
5642 status = psibin.Write(fln.Data());
5645 std::cerr << std::endl <<
">> PRunDataHandler::WritePsiBinFile(): " << psibin.WriteStatus() << std::endl;
5672 std::cout << std::endl <<
">> PRunDataHandler::WriteMudFile(): writing a mud data file (" << fln.Data() <<
") ... " << std::endl;
5675 int fd = MUD_openWrite((
char*)fln.Data(), MUD_FMT_TRI_TD_ID);
5677 std::cerr << std::endl <<
">> PRunDataHandler::WriteMudFile(): **ERROR** couldn't open mud data file for write ..." << std::endl;
5682 char dummy[32], info[128];
5683 strcpy(dummy,
"???");
5684 MUD_setRunDesc(fd, MUD_SEC_GEN_RUN_DESC_ID);
5685 MUD_setExptNumber(fd, 0);
5686 MUD_setRunNumber(fd,
fData[0].GetRunNumber());
5687 Int_t ival =
fData[0].GetStopDateTime()-
fData[0].GetStartDateTime();
5688 MUD_setElapsedSec(fd, ival);
5689 MUD_setTimeBegin(fd,
fData[0].GetStartDateTime());
5690 MUD_setTimeEnd(fd,
fData[0].GetStopDateTime());
5691 MUD_setTitle(fd, (
char *)
fData[0].GetRunTitle()->Data());
5692 MUD_setLab(fd, (
char *)
fData[0].GetLaboratory()->Data());
5693 MUD_setArea(fd, (
char *)
fData[0].GetBeamline()->Data());
5694 MUD_setMethod(fd, (
char *)
fData[0].GetSetup()->Data());
5695 MUD_setApparatus(fd, (
char *)
fData[0].GetInstrument()->Data());
5696 MUD_setInsert(fd, dummy);
5697 MUD_setSample(fd, (
char *)
fData[0].GetSample()->Data());
5698 MUD_setOrient(fd, (
char *)
fData[0].GetOrientation()->Data());
5699 MUD_setDas(fd, dummy);
5700 MUD_setExperimenter(fd, dummy);
5701 snprintf(info,
sizeof(info),
"%lf+-%lf (K)",
fData[0].GetTemperature(0),
fData[0].GetTempError(0));
5702 MUD_setTemperature(fd, info);
5703 snprintf(info,
sizeof(info),
"%lf",
fData[0].GetField());
5704 MUD_setField(fd, info);
5707 MUD_setHists(fd, MUD_GRP_TRI_TD_HIST_ID,
fData[0].GetNoOfHistos());
5710 data =
new UInt_t[dataSize];
5711 if (data ==
nullptr) {
5712 std::cerr << std::endl <<
">> PRunDataHandler::WriteMudFile(): **ERROR** couldn't allocate memory for the data ..." << std::endl;
5717 UInt_t noOfEvents = 0, k = 0;
5720 for (UInt_t i=0; i<
fData[0].GetNoOfHistos(); i++) {
5721 dataSet =
fData[0].GetDataSet(i,
false);
5722 if (dataSet ==
nullptr) {
5723 std::cerr << std::endl <<
">> PRunDataHandler::WriteMudFile: **ERROR** Couldn't get data set (idx=" << i <<
")";
5724 std::cerr << std::endl <<
">> something is really wrong!" << std::endl;
5729 for (UInt_t j=0; j<dataSize; j++)
5733 for (UInt_t j=0; j<dataSet->
GetData()->size(); j++) {
5740 ival +=
static_cast<UInt_t
>(dataSet->
GetData()->at(j));
5745 MUD_setHistType(fd, i+1, MUD_GRP_TRI_TD_HIST_ID);
5746 MUD_setHistNumBytes(fd, i+1,
sizeof(data));
5747 MUD_setHistNumBins(fd, i+1, dataSize);
5748 MUD_setHistBytesPerBin(fd, i+1, 0);
5754 MUD_setHistBkgd1(fd, i+1, 0);
5755 MUD_setHistBkgd2(fd, i+1, 0);
5756 MUD_setHistNumEvents(fd, i+1, (UINT32)noOfEvents);
5757 MUD_setHistTitle(fd, i+1, (
char *)dataSet->
GetName().Data());
5759 MUD_setHistSecondsPerBin(fd, i+1, timeResolution);
5761 MUD_setHistData(fd, i+1, data);
5775 is.open(fln.Data(), std::ios::binary);
5776 if (!is.is_open()) {
5777 std::cerr << std::endl <<
"PRunDataHandler::WriteMudFile(): **ERROR** Couldn't open the mud-file for streaming." << std::endl;
5783 is.seekg(0, std::ios::end);
5784 length = is.tellg();
5785 is.seekg(0, std::ios::beg);
5788 std::cerr << std::endl <<
"PRunDataHandler::WriteMudFile(): **ERROR** Couldn't determine the mud-file size." << std::endl;
5794 buffer =
new char [length];
5798 is.read(buffer, length);
5799 std::cout.write(buffer, length);
5831 TString fileName = fln;
5834 std::cout << std::endl <<
">> PRunDataHandler::WriteAsciiFile(): writing an ascii data file (" << fln.Data() <<
") ... " << std::endl;
5838 std::streambuf* strm_buffer =
nullptr;
5842 fout.open(fln.Data(), std::ofstream::out);
5843 if (!fout.is_open()) {
5844 std::cerr << std::endl <<
">> PRunDataHandler::WriteAsciiFile **ERROR** Couldn't open data file (" << fln.Data() <<
") for writing, sorry ...";
5845 std::cerr << std::endl;
5850 strm_buffer = std::cout.rdbuf();
5853 std::cout.rdbuf(fout.rdbuf());
5857 std::cout <<
"%*************************************************************************";
5858 std::cout << std::endl <<
"% file name : " << fileName.Data();
5859 if (
fData[0].GetRunTitle()->Length() > 0)
5860 std::cout << std::endl <<
"% title : " <<
fData[0].GetRunTitle()->Data();
5861 if (
fData[0].GetRunNumber() >= 0)
5862 std::cout << std::endl <<
"% run number : " <<
fData[0].GetRunNumber();
5863 if (
fData[0].GetSetup()->Length() > 0)
5864 std::cout << std::endl <<
"% setup : " <<
fData[0].GetSetup()->Data();
5865 std::cout << std::endl <<
"% field : " <<
fData[0].GetField() <<
" (G)";
5866 if (
fData[0].GetStartTime()->Length() > 0)
5867 std::cout << std::endl <<
"% date : " <<
fData[0].GetStartTime()->Data() <<
" " <<
fData[0].GetStartDate()->Data() <<
" / " <<
fData[0].GetStopTime()->Data() <<
" " <<
fData[0].GetStopDate()->Data();
5868 if (
fData[0].GetNoOfTemperatures() > 0) {
5869 std::cout << std::endl <<
"% temperature : ";
5870 for (UInt_t i=0; i<
fData[0].GetNoOfTemperatures()-1; i++) {
5871 std::cout <<
fData[0].GetTemperature(i) <<
"+-" <<
fData[0].GetTempError(i) <<
"(K) , ";
5873 std::cout <<
fData[0].GetTemperature(
fData[0].GetNoOfTemperatures()-1) <<
"+-" <<
fData[0].GetTempError(
fData[0].GetNoOfTemperatures()-1) <<
"(K)";
5876 std::cout << std::endl <<
"% energy : " <<
fData[0].GetEnergy() <<
" (keV)";
5878 std::cout << std::endl <<
"% transport : " <<
fData[0].GetTransport() <<
" (kV)";
5880 std::cout.precision(10);
5881 std::cout << std::endl <<
"% time resolution : " <<
fData[0].GetTimeResolution()*
fAny2ManyInfo->
rebin <<
" (ns)";
5882 std::cout.setf(std::ios::fixed,std::ios::floatfield);
5885 std::cout << std::endl <<
"% t0 : ";
5886 for (UInt_t i=0; i<
fData[0].GetNoOfHistos()-1; i++) {
5887 dataSet =
fData[0].GetDataSet(i,
false);
5890 dataSet =
fData[0].GetDataSet(
fData[0].GetNoOfHistos()-1,
false);
5893 std::cout << std::endl <<
"% # histos : " <<
fData[0].GetNoOfHistos();
5894 dataSet =
fData[0].GetDataSet(0,
false);
5896 std::cout << std::endl <<
"%*************************************************************************";
5899 UInt_t length =
fData[0].GetDataSet(0,
false)->GetData()->size();
5901 for (UInt_t i=0; i<length; i++) {
5902 std::cout << std::endl;
5903 for (UInt_t j=0; j<
fData[0].GetNoOfHistos(); j++) {
5904 dataSet =
fData[0].GetDataSet(j,
false);
5906 std::cout << static_cast<Int_t>(dataSet->
GetData()->at(i));
5913 for (UInt_t i=0; i<dataRebin.size(); i++) {
5914 dataSet =
fData[0].GetDataSet(i,
false);
5915 dataRebin[i] =
static_cast<UInt_t
>(dataSet->
GetData()->at(0));
5918 for (UInt_t i=0; i<length; i++) {
5920 std::cout << std::endl;
5921 for (UInt_t j=0; j<dataRebin.size(); j++) {
5923 std::cout << dataRebin[j];
5926 for (UInt_t j=0; j<dataRebin.size(); j++) {
5927 dataSet =
fData[0].GetDataSet(j,
false);
5928 dataRebin[j] =
static_cast<UInt_t
>(dataSet->
GetData()->at(i));
5931 for (UInt_t j=0; j<
fData[0].GetNoOfHistos(); j++) {
5932 dataSet =
fData[0].GetDataSet(j,
false);
5933 dataRebin[j] +=
static_cast<UInt_t
>(dataSet->
GetData()->at(i));
5939 std::cout << std::endl;
5943 std::cout.rdbuf(strm_buffer);
5967 Char_t *s =
nullptr;
5968 Char_t *subs =
nullptr;
5974 size =
static_cast<Int_t
>(str.Length());
5975 s =
new Char_t[size+1];
5980 for (Int_t i=0; i<size+1; i++)
5986 while (isblank(s[i]) || iscntrl(s[i])) {
5993 while (isblank(s[i]) || iscntrl(s[i])) {
6002 subs =
new Char_t[end-start+2];
6006 strncpy(subs, s+start, end-start+1);
6007 subs[end-start+1] =
'\0';
6009 str = TString(subs);
6041 while (isblank(str[i]) || iscntrl(str[i])) {
6047 if (i == strlen(str))
6074 size =
static_cast<Int_t
>(str.Length());
6075 s =
new Char_t[size+1];
6083 for (Int_t i=0; i<size+1; i++)
6088 status = sscanf(s,
"%lf", &value);
6124 size =
static_cast<Int_t
>(str.Length());
6125 s =
new Char_t[size+1];
6133 for (Int_t i=0; i<size+1; i++)
6138 status = sscanf(s,
"%d", &value);
6171 for (UInt_t i=0; i<dataTags->size(); i++) {
6172 if (!dataTags->at(i).CompareTo(str, TString::kIgnoreCase)) {
6200 TString fln = fileName;
6208 if (fln.Length() == 0) {
6220 if (!gSystem->AccessPathName(fln)) {
6225 newFln.Insert(newFln.Last(
'.'), TString::Format(
".%d", count++));
6226 }
while (!gSystem->AccessPathName(newFln));
6227 std::cerr << std::endl <<
">> PRunDataHandler::GenerateOutputFileName **WARNING** needed to modify output filename to " << newFln <<
",";
6228 std::cerr << std::endl <<
">> due to potential conflict with already existing files." << std::endl << std::endl;
6256 TString fileName =
"";
6262 std::cerr << std::endl <<
">> PRunDataHandler::GetFileName(): **ERROR** couldn't generate the output file name ..." << std::endl;
6267 Char_t str1[1024], str2[1024];
6269 for (Int_t i=0; i<end-start-1; i++) {
6270 str2[i] = str1[i+start+1];
6272 str2[end-start-1] = 0;
6309 TObjArray *tok=
nullptr;
6314 if ((year.Length() != 2) && (year.Length() != 4)) {
6315 std::cerr << std::endl <<
">> PRunDataHandler::FileNameFromTemplate: **ERROR** year needs to be of the format";
6316 std::cerr << std::endl <<
">> 'yy' or 'yyyy', found " << year << std::endl;
6321 TString yearShort=
"", yearLong=
"";
6322 if (year.Length() == 2) {
6327 yearShort = year[2];
6328 yearShort += year[3];
6333 tok = fileNameTemplate.Tokenize(
"[]");
6334 if (tok ==
nullptr) {
6335 std::cerr << std::endl <<
">> PRunDataHandler::FileNameFromTemplate: **ERROR** couldn't tokenize template!" << std::endl;
6338 if (tok->GetEntries()==1) {
6339 std::cerr << std::endl <<
">> PRunDataHandler::FileNameFromTemplate: **WARNING** template without tags." << std::endl;
6343 for (Int_t i=0; i<tok->GetEntries(); i++) {
6344 ostr =
dynamic_cast<TObjString*
>(tok->At(i));
6345 str = ostr->GetString();
6348 if (!str.CompareTo(
"yy", TString::kExact)) {
6349 result += yearShort;
6350 }
else if (!str.CompareTo(
"yyyy", TString::kExact)) {
6352 }
else if (str.Contains(
"rr")) {
6355 for (idx=0; idx<str.Length(); idx++) {
6356 if (str[idx] !=
'r')
6359 if (idx == str.Length()) {
6362 snprintf(fmt,
sizeof(fmt),
"%%0%dd", str.Length());
6363 runStr.Form(fmt, run);
6396 iso8601Date = std::string(
"");
6401 if (!strptime(inDate.c_str(),
"%d-%b-%y", &tm))
6405 str.Form(
"%04d-%02d-%02d", 1900+tm.tm_year, tm.tm_mon+1, tm.tm_mday);
6407 iso8601Date = str.Data();
6427 memset(&tm, 0,
sizeof(tm));
6428 strptime(timeData.Data(),
"%Y-%m-%d %H:%M:S", &tm);
6429 if (tm.tm_year == 0)
6430 strptime(timeData.Data(),
"%Y-%m-%dT%H:%M:S", &tm);
6432 if (tm.tm_year == 0) {
6437 time = TString::Format(
"%02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec);
6438 date = TString::Format(
"%04d-%02d-%02d", tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday);
6453 TString monthString =
"???";
6457 monthString =
"JAN";
6460 monthString =
"FEB";
6463 monthString =
"MAR";
6466 monthString =
"APR";
6469 monthString =
"MAY";
6472 monthString =
"JUN";
6475 monthString =
"JUL";
6478 monthString =
"AUG";
6481 monthString =
"SEP";
6484 monthString =
"OCT";
6487 monthString =
"NOV";
6490 monthString =
"DEC";
6511 TString yearString =
"??";
6517 yearString.Form(
"%02d", yy);
6520 if ((yy >= 0) && (yy <= 99))
6521 yearString.Form(
"%02d", yy);
virtual void SetInstrument(const TString &str)
virtual TString * GetBeamline(UInt_t idx=0)
virtual Bool_t StripWhitespace(TString &str)
virtual void SetTimeZeroBinEstimated(Double_t tzb)
virtual ~PRunDataHandler()
virtual Double_t ToDouble(TString &str, Bool_t &ok)
virtual void SetRunTitle(const TString str)
virtual void SetSpecificValidatorUrl(const TString &str)
virtual Bool_t ReadWkmFile()
TString year
holds the information about the year to be used
virtual void SetStopDate(const TString str)
PRawRunDataList fData
keeping all the raw data
virtual void Init(const Int_t tag=0)
virtual Bool_t ReadRootFile()
virtual void TestFileName(TString &runName, const TString &ext)
virtual void SetMagnetName(const TString str)
virtual void SetMuonSource(const TString &str)
virtual const Double_t GetTimeResolution()
virtual TString GetYear(Int_t month)
std::vector< PMsrRunBlock > PMsrRunList
virtual Bool_t WriteMudFile(TString fln="")
virtual Double_t GetValue() const
virtual TString GenerateOutputFileName(const TString fileName, const TString extension, Bool_t &ok)
virtual TString GetFileName(const TString extension, Bool_t &ok)
virtual TString * GetFileFormat(UInt_t idx=0)
virtual void SetBeamline(TString &str, Int_t idx=-1)
virtual void SetEnergy(const Double_t dval)
virtual void SetStopTime(const TString str)
virtual void SetGenericValidatorUrl(const TString &str)
virtual Bool_t WriteMusrRootFile(TString fln="")
virtual void SetRingAnode(const UInt_t idx, const Double_t dval)
TString fRunPathName
current path file name
virtual const std::vector< PDoubleVector > * GetData()
virtual Bool_t ReadFilesMsr()
TString outFileName
holds the output file name
virtual void SetTempError(const UInt_t idx, const Double_t errTemp)
virtual void SplitTimeDate(TString timeDate, TString &time, TString &date, Bool_t &ok)
virtual void SetRunName(const TString &str)
TString fRunName
current run name
virtual PRawRunData * GetRunData(const TString &runName)
virtual Bool_t WritePsiBinFile(TString fln="")
virtual const PStringVector * GetLabels()
UInt_t compressionTag
0=no compression, 1=gzip compression, 2=bzip2 compression
virtual Bool_t FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx)
virtual TString GetMonth(Int_t month)
TString inFormat
holds the information about the input data file format
virtual Bool_t WriteNexusFile(TString fln="")
virtual void SetStartTime(const TString str)
Bool_t fAllDataAvailable
flag indicating if all data sets could be read
PAny2ManyInfo * fAny2ManyInfo
pointer to the any2many data structure
virtual Bool_t ReadDatFile()
virtual void SetRunNumber(const Int_t &val)
virtual void SetFileFormat(TString &str, Int_t idx=-1)
virtual void SetBeamline(const TString &str)
std::vector< Int_t > PIntVector
virtual void AppendSubErrData(const UInt_t idx, const Double_t dval)
PStringVector fDataPath
vector containing all the search paths where to look for data files
virtual void SetMuonSpinAngle(const Double_t dval)
std::vector< UInt_t > PUIntVector
virtual void SetDataSet(PRawRunDataSet &dataSet, UInt_t idx=-1)
virtual void AppendLabel(const TString str)
std::vector< Double_t > PDoubleVector
PStringVector outPathFileName
holds the out path/file name
virtual PMsrRunList * GetMsrRunList()
virtual Bool_t SetRunData(PRawRunData *data, UInt_t idx=0)
virtual void SetStartDate(const TString str)
virtual const PStringVector * GetDataTags()
virtual void SetComment(const TString &str)
virtual void SetGenerator(const TString &str)
virtual Int_t GetLastGoodBin()
virtual TString GetName()
PIntVector groupHistoList
holds the histo group list offset (used to define for MusrRoot files, what to be exported) ...
virtual bool DateToISO8601(std::string inDate, std::string &iso8601Date)
virtual Bool_t WriteAsciiFile(TString fln="")
virtual void SetRedGreenOffset(PIntVector &ivec)
virtual TString * GetMsrFileDirectoryPath()
virtual Bool_t IsWhitespace(const Char_t *str)
virtual Int_t GetHistoNo()
virtual TString GetUnit() const
TString outTemplate
holds the output file template
virtual void SetSample(const TString str)
virtual Bool_t ReadMduAsciiFile()
virtual Bool_t WriteData(TString fileName="")
virtual const std::vector< PDoubleVector > * GetErrData()
virtual void SetVersion(const TString &str)
virtual Int_t ToInt(TString &str, Bool_t &ok)
virtual Bool_t ReadAsciiFile()
TString fFileFormat
keeps the file format if explicitly given
virtual void SetTimeZeroBin(Double_t tzb)
virtual void ClearTemperature()
virtual void SetMuonBeamMomentum(const Double_t dval)
virtual void Set(TString label, Double_t demand, Double_t value, Double_t error, TString unit, TString description=TString("n/a"))
virtual void SetName(TString str)
virtual Double_t GetError() const
UInt_t rebin
holds the number of bins to be packed
virtual void SetInstitute(TString &str, Int_t idx=-1)
virtual void AppendDataTag(const TString str)
virtual void SetHistoNo(Int_t no)
virtual Bool_t ReadNexusFile()
virtual void SetSize(const UInt_t size)
virtual void SetFirstGoodBin(Int_t fgb)
virtual void SetStartDateTime(const time_t val)
virtual void SetOrientation(const TString str)
virtual Bool_t WriteRootFile(TString fln="")
virtual void SetFileName(const TString &str)
virtual Bool_t ReadMudFile()
TString compressFileName
holds the name of the outputfile name in case of compression is used
TString outPath
holds the output path
virtual void AppendSubData(const UInt_t idx, const Double_t dval)
virtual void SetData(PDoubleVector data)
Bool_t useStandardOutput
flag showing if the converted shall be sent to the standard output
virtual void SetStopDateTime(const time_t val)
virtual PDoubleVector * GetData()
virtual void AppendErrData(const PDoubleVector &data)
virtual Bool_t ReadPsiBinFile()
virtual TString * GetInstitute(UInt_t idx=0)
virtual Bool_t ReadDBFile()
virtual void SetLabel(const UInt_t idx, const TString str)
virtual void SetCryoName(const TString str)
virtual void SetSetup(const TString str)
virtual Bool_t WriteWkmFile(TString fln="")
PUIntVector runList
holds the run number list to be converted
virtual TString FileNameFromTemplate(TString &fileNameTemplate, Int_t run, TString &year, Bool_t &ok)
virtual Int_t GetFirstGoodBin()
virtual void SetLaboratory(const TString &str)
virtual void SetField(const Double_t dval)
virtual void SetLastBkgBin(Int_t lbb)
virtual const PDoubleVector * GetDataBin(const UInt_t histoNo)
virtual Int_t GetDataTagIndex(TString &str, const PStringVector *fLabels)
virtual const UInt_t GetNoOfHistos()
std::vector< TString > PStringVector
virtual void SetLastGoodBin(Int_t lgb)
virtual void AppendData(const PDoubleVector &data)
virtual void SetFromAscii(const Bool_t bval)
virtual Double_t GetTimeZeroBin()
PNonMusrRawRunData fDataNonMusr
keeps all ascii- or db-file info in case of nonMusr fit
virtual Bool_t ReadWriteFilesList()
PMsrHandler * fMsrInfo
pointer to the msr-file handler
virtual void ConvertData()
#define PHR_INIT_ANY2MANY
virtual void SetMuonSpecies(const TString &str)
virtual void SetTimeResolution(const Double_t dval)
UInt_t idf
IDF version for NeXus files.
virtual void SetTemperature(const UInt_t idx, const Double_t temp, const Double_t errTemp)
TString outFormat
holds the information about the output data file format
virtual void SetTransport(const Double_t dval)
virtual TString * GetRunName(UInt_t idx=0)
PStringVector inFileName
holds the file name of the input data file
virtual Bool_t FileAlreadyRead(TString runName)
virtual void SetFirstBkgBin(Int_t fbb)
std::vector< Bool_t > PBoolVector
#define POST_PILEUP_HISTO_OFFSET
TString inTemplate
holds the input file template