38 #include <TPaveText.h> 40 #include <TObjArray.h> 41 #include <TObjString.h> 78 TObject(), fLabel(label), fDemand(demand), fValue(value), fError(error), fUnit(unit)
80 if (description.IsWhitespace())
99 TObject(), fLabel(label), fDemand(demand), fValue(value), fUnit(unit)
102 if (description.IsWhitespace())
120 TObject(), fLabel(label), fValue(value), fUnit(unit)
124 if (description.IsWhitespace())
150 if (description.IsWhitespace())
175 if (description.IsWhitespace())
199 if (description.IsWhitespace())
234 Init(TString(fileName));
250 fVersion = TString(
"git-sha: dae9ef0ffba4");
252 Set(
"RunInfo/Generic Validator URL",
"http://lmu.web.psi.ch/facilities/software/MusrRoot/validation/MusrRoot.xsd");
253 Set(
"RunInfo/Specific Validator URL",
"n/a");
254 Set(
"RunInfo/Generator",
"n/a");
255 Set(
"RunInfo/Proposal Number", -1);
256 Set(
"RunInfo/Main Proposer",
"n/a");
257 Set(
"RunInfo/File Name",
"n/a");
258 Set(
"RunInfo/Run Title",
"n/a");
259 Set(
"RunInfo/Run Number", -1);
260 Set(
"RunInfo/Run Start Time",
"1970-01-01 00:00:00");
261 Set(
"RunInfo/Run Stop Time",
"1970-01-01 00:00:00");
262 prop.
Set(
"Run Duration", 0.0,
"sec");
263 Set(
"RunInfo/Run Duration", prop);
264 Set(
"RunInfo/Laboratory",
"n/a");
265 Set(
"RunInfo/Instrument",
"n/a");
266 prop.
Set(
"Muon Beam Momentum", 0.0,
"MeV/c");
267 Set(
"RunInfo/Muon Beam Momentum", prop);
268 Set(
"RunInfo/Muon Species",
"n/a");
269 Set(
"RunInfo/Muon Source",
"n/a");
270 Set(
"RunInfo/Setup",
"n/a");
271 Set(
"RunInfo/Comment",
"n/a");
272 Set(
"RunInfo/Sample Name",
"n/a");
273 prop.
Set(
"Sample Temperature", 0.0,
"K");
274 Set(
"RunInfo/Sample Temperature", prop);
275 prop.
Set(
"Sample Magnetic Field", 1000.0,
"T");
276 Set(
"RunInfo/Sample Magnetic Field", prop);
277 Set(
"RunInfo/No of Histos", 0);
278 prop.
Set(
"Time Resolution", 0.0,
"ns");
279 Set(
"RunInfo/Time Resolution", prop);
280 std::vector<int> ivec;
282 Set(
"RunInfo/RedGreen Offsets", ivec);
284 Set(
"DetectorInfo/Detector001/Name",
"n/a");
285 Set(
"DetectorInfo/Detector001/Histo Number", 0);
286 Set(
"DetectorInfo/Detector001/Histo Length", 0);
287 Set(
"DetectorInfo/Detector001/Time Zero Bin", static_cast<Double_t>(0.0));
288 Set(
"DetectorInfo/Detector001/First Good Bin", 0);
289 Set(
"DetectorInfo/Detector001/Last Good Bin", 0);
291 Set(
"SampleEnvironmentInfo/Cryo",
"n/a");
293 Set(
"MagneticFieldEnvironmentInfo/Magnet Name",
"n/a");
295 Set(
"BeamlineInfo/Name",
"n/a");
341 TObjString ostr, *p_ostr;
342 TString path, name, str;
346 if (folder ==
nullptr) {
347 std::cerr << std::endl <<
">> TMusrRunHeader::FillFolder(): **ERROR** folder == 0!!" << std::endl;
364 pos = path.Last(
'/');
366 std::cerr << std::endl <<
">> TMusrRunHeader::FillFolder(): **ERROR** somethig is wrong with the path=" << path <<
" !!" << std::endl;
371 oarray =
dynamic_cast<TObjArray*
>(
FindObject(folder, path));
373 std::cerr << std::endl <<
">> TMusrRunHeader::FillFolder(): **ERROR** couldn't create header structure!!" << std::endl;
379 name = ostr.GetString();
382 for (Int_t j=0; j<oarray->GetEntriesFast(); j++) {
383 p_ostr =
dynamic_cast<TObjString*
>(oarray->At(j));
384 if (p_ostr->GetString().BeginsWith(str)) {
385 oarray->AddAt(ostr.Clone(), j);
391 oarray->AddLast(ostr.Clone());
410 TString type(
"undef");
414 if (
fStringObj[i].GetPathName() == pathName) {
419 for (Int_t i=0; i<
fIntObj.size(); i++) {
420 if (
fIntObj[i].GetPathName() == pathName) {
426 if (
fDoubleObj[i].GetPathName() == pathName) {
475 if (
fStringObj[i].GetPathName() == pathName) {
496 for (UInt_t i=0; i<
fIntObj.size(); i++) {
497 if (
fIntObj[i].GetPathName() == pathName) {
519 if (
fDoubleObj[i].GetPathName() == pathName) {
628 if (!
fStringObj[i].GetPathName().CompareTo(pathName, TString::kIgnoreCase)) {
630 std::cerr << std::endl <<
">> **WARNING** " << pathName.Data() <<
" already exists, will replace it." << std::endl;
661 for (i=0; i<
fIntObj.size(); i++) {
662 if (!
fIntObj[i].GetPathName().CompareTo(pathName, TString::kIgnoreCase)) {
664 std::cerr << std::endl <<
">> **WARNING** " << pathName.Data() <<
" already exists, will replace it." << std::endl;
696 if (!
fDoubleObj[i].GetPathName().CompareTo(pathName, TString::kIgnoreCase)) {
698 std::cerr << std::endl <<
">> **WARNING** " << pathName.Data() <<
" already exists, will replace it." << std::endl;
732 std::cerr << std::endl <<
">> **WARNING** " << pathName.Data() <<
" already exists, will replace it." << std::endl;
764 if (!
fStringVectorObj[i].GetPathName().CompareTo(pathName, TString::kIgnoreCase)) {
766 std::cerr << std::endl <<
">> **WARNING** " << pathName.Data() <<
" already exists, will replace it." << std::endl;
798 if (!
fIntVectorObj[i].GetPathName().CompareTo(pathName, TString::kIgnoreCase)) {
800 std::cerr << std::endl <<
">> **WARNING** " << pathName.Data() <<
" already exists, will replace it." << std::endl;
832 if (!
fDoubleVectorObj[i].GetPathName().CompareTo(pathName, TString::kIgnoreCase)) {
834 std::cerr << std::endl <<
">> **WARNING** " << pathName.Data() <<
" already exists, will replace it." << std::endl;
864 TIter next(folder->GetListOfFolders());
870 while ((entry = dynamic_cast<TObjArray*>(next()))) {
887 TString label(
""), path(
""), pathName(
""), str(
""), strValue(
""), type(
"");
888 TObjString *ostr =
nullptr;
889 TObjArray *tokens =
nullptr;
895 for (Int_t i=0; i<headerInfo->GetEntries(); i++) {
897 str = TString(headerInfo->At(i)->ClassName());
898 if (str ==
"TObjArray") {
899 path = requestedPath +
"/" + TString(headerInfo->At(i)->GetName());
903 ostr =
dynamic_cast<TObjString*
>(headerInfo->At(i));
904 str = ostr->GetString();
915 pathName = requestedPath + TString(
"/") + label;
922 if (type ==
"TString") {
923 Set(pathName, strValue);
924 }
else if (type ==
"Int_t") {
925 intValue = strValue.Atoi();
926 Set(pathName, intValue);
927 }
else if (type ==
"Double_t") {
928 dval = strValue.Atof();
930 }
else if (type ==
"TMusrRunPhysicalQuantity") {
935 tokens = strValue.Tokenize(
";");
936 if (tokens ==
nullptr) {
937 std::cerr << std::endl <<
">> **ERROR** Couldn't tokenize entry in Bool_t TMusrRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString requestedPath)" << std::endl;
941 switch (tokens->GetEntries()) {
943 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
944 str = ostr->GetString();
945 if (!str.Contains(
"SP:")) {
950 ostr =
dynamic_cast<TObjString*
>(tokens->At(2));
951 str = ostr->GetString();
963 idx1 = strValue.Last(
';');
966 for (Int_t i=idx1+2; i<strValue.Length(); i++)
969 if (!last.Contains(
"SP:")) {
971 for (Int_t i=0; i<idx1; i++)
977 tokens = strValue.Tokenize(
" +;");
978 if (tokens ==
nullptr) {
979 std::cerr << std::endl <<
">> **ERROR** Couldn't tokenize entry in Bool_t TMusrRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString requestedPath)" << std::endl;
983 switch (tokens->GetEntries()) {
985 ostr =
dynamic_cast<TObjString*
>(tokens->At(0));
986 str = ostr->GetString();
988 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
989 str = ostr->GetString();
993 ostr =
dynamic_cast<TObjString*
>(tokens->At(0));
994 str = ostr->GetString();
996 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
997 str = ostr->GetString();
999 ostr =
dynamic_cast<TObjString*
>(tokens->At(2));
1000 str = ostr->GetString();
1002 ostr =
dynamic_cast<TObjString*
>(tokens->At(3));
1003 str = ostr->GetString();
1007 ostr =
dynamic_cast<TObjString*
>(tokens->At(3));
1008 str = ostr->GetString();
1013 ostr =
dynamic_cast<TObjString*
>(tokens->At(0));
1014 str = ostr->GetString();
1016 ostr =
dynamic_cast<TObjString*
>(tokens->At(2));
1017 str = ostr->GetString();
1019 ostr =
dynamic_cast<TObjString*
>(tokens->At(3));
1020 str = ostr->GetString();
1022 ostr =
dynamic_cast<TObjString*
>(tokens->At(5));
1023 str = ostr->GetString();
1035 Set(pathName, prop);
1036 }
else if (type ==
"TStringVector") {
1038 tokens = strValue.Tokenize(
";");
1039 if (tokens ==
nullptr) {
1040 std::cerr << std::endl <<
">> **ERROR** Couldn't tokenize entry in Bool_t TMusrRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString requestedPath)" << std::endl;
1043 for (Int_t i=0; i<tokens->GetEntries(); i++) {
1044 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
1045 str = ostr->GetString();
1046 str.Remove(TString::kBoth,
' ');
1047 svec.push_back(str);
1053 Set(pathName, svec);
1054 }
else if (type ==
"TIntVector") {
1056 tokens = strValue.Tokenize(
";");
1057 if (tokens ==
nullptr) {
1058 std::cerr << std::endl <<
">> **ERROR** Couldn't tokenize entry in Bool_t TMusrRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString requestedPath)" << std::endl;
1061 for (Int_t i=0; i<tokens->GetEntries(); i++) {
1062 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
1063 ivec.push_back(ostr->GetString().Atoi());
1069 Set(pathName, ivec);
1070 }
else if (type ==
"TDoubleVector") {
1072 tokens = strValue.Tokenize(
";");
1073 if (tokens ==
nullptr) {
1074 std::cerr << std::endl <<
">> **ERROR** Couldn't tokenize entry in Bool_t TMusrRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString requestedPath)" << std::endl;
1077 for (Int_t i=0; i<tokens->GetEntries(); i++) {
1078 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
1079 dvec.push_back(ostr->GetString().Atoi());
1085 Set(pathName, dvec);
1101 std::cout << std::endl <<
"***************************************";
1102 std::cout << std::endl <<
"header info of file : " <<
fFileName;
1103 std::cout << std::endl <<
"***************************************";
1105 TString str(
""), tstr(
""), fmt(
""), path(
""), name(
""), currentPath(
"");
1111 if (path != currentPath) {
1113 std::cout << std::endl << currentPath;
1122 std::cout << std::endl << str;
1126 for (UInt_t j=0; j<
fIntObj.size(); j++) {
1129 str.Form(
" %03d - %s: %d -@%d", i, name.Data(),
fIntObj[j].GetValue(),
MRH_INT);
1130 std::cout << std::endl << str;
1139 std::cout << std::endl << str;
1146 Int_t digit, digit_d;
1152 fmt.Form(
"%%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf; %%s", digit, digit, digit_d);
1156 fmt.Form(
"%%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf", digit, digit, digit_d);
1163 fmt.Form(
"%%s: %%.%dlf +- %%.%dlf %%s; %%s", digit, digit);
1166 fmt.Form(
"%%s: %%.%dlf +- %%.%dlf %%s", digit, digit);
1173 fmt.Form(
"%%s: %%.%dlf %%s; %%s", digit);
1176 fmt.Form(
"%%s: %%.%dlf %%s", digit);
1184 fmt.Form(
"%%s: %%.%dlf %%s; SP: %%.%dlf; %%s", digit, digit_d);
1187 fmt.Form(
"%%s: %%.%dlf %%s; SP: %%.%dlf", digit, digit_d);
1192 std::cout << std::endl << str;
1199 str.Form(
" %03d - %s: ", i, name.Data());
1201 for (UInt_t k=0; k<vstr.size()-1; k++)
1202 str += vstr[k] +
"; ";
1203 str += vstr[vstr.size()-1];
1206 std::cout << std::endl << str;
1213 str.Form(
" %03d - %s: ", i, name.Data());
1215 for (UInt_t k=0; k<vint.size()-1; k++) {
1219 str += vint[vint.size()-1];
1222 std::cout << std::endl << str;
1229 str.Form(
" %03d - %s: ", i, name.Data());
1233 for (UInt_t k=0; k<dvec.size()-1; k++) {
1234 subStr.Form(fmt, dvec[k]);
1238 subStr.Form(fmt, dvec.size()-1);
1242 std::cout << std::endl << str;
1247 std::cout << std::endl;
1258 std::unique_ptr<TPaveText> pt;
1259 std::unique_ptr<TCanvas> ca;
1261 ca = std::make_unique<TCanvas>(
"MusrRoot RunHeader",
"MusrRoot RunHeader", 147,37,699,527);
1262 ca->Range(0., 0., 100., 100.);
1264 pt = std::make_unique<TPaveText>(10.,10.,90.,90.,
"br");
1265 pt->SetFillColor(19);
1266 pt->SetTextAlign(12);
1270 ca->Modified(kTRUE);
1293 }
while ((digit == 0) && (count < 20));
1310 snprintf(cstr,
sizeof(cstr),
"%.10lf", val);
1313 for (i=strlen(cstr)-1; i>=0; i--) {
1318 for (j=strlen(cstr)-1; j>=0; j--) {
1342 Ssiz_t idx = pathName.Last(
'/');
1344 for (Int_t i=0; i<idx; i++)
1345 path += pathName[i];
1347 for (Int_t i=idx+1; i<pathName.Length(); i++)
1348 name += pathName[i];
1365 TString label = TString(
"n/a");
1366 Ssiz_t idx1 = str.First(
'-');
1367 Ssiz_t idx2 = str.First(
':');
1368 if ((idx1 == -1) || (idx2 == -1)) {
1370 std::cerr << std::endl <<
">> TMusrRunHeader::GetLabel(): **WARNING** str='" << str <<
"', seems not correctly encoded.";
1371 std::cerr << std::endl <<
">> Will omit it." << std::endl;
1376 label = TString(
"");
1377 for (Int_t j=idx1+2; j<idx2; j++)
1397 TString strValue = TString(
"n/a");
1398 Ssiz_t idx1 = str.First(
':');
1399 Ssiz_t idx2 = str.Last(
'-');
1400 if ((idx1 == -1) || (idx2 == -1)) {
1402 std::cerr << std::endl <<
">> TMusrRunHeader::GetStrValue(): **WARNING** str='" << str <<
"', seems not correctly encoded.";
1403 std::cerr << std::endl <<
">> Will omit it." << std::endl;
1408 strValue = TString(
"");
1409 for (Int_t j=idx1+2; j<idx2-1; j++)
1425 TString result =
"n/a";
1429 Ssiz_t pos = str.Last(
'@');
1433 std::cerr << std::endl <<
">> TMusrRunHeader::GetType(): **WARNING** str=" << str <<
" seems to be an invalid MusrROOT run header string.";
1434 std::cerr << std::endl <<
">> Will omit it." << std::endl;
1440 TString typeStr(str);
1441 typeStr.Remove(0, pos+1);
1443 if (!typeStr.IsDigit()) {
1444 std::cerr << std::endl <<
">> TMusrRunHeader::GetType(): **ERROR** typeStr=" << typeStr <<
" is not supported." << std::endl;
1448 typeVal = typeStr.Atoi();
1458 result =
"Double_t";
1461 result =
"TMusrRunPhysicalQuantity";
1464 result =
"TStringVector";
1467 result =
"TIntVector";
1470 result =
"TDoubleVector";
1473 std::cerr << std::endl <<
">> TMusrRunHeader::GetType(): **ERROR** found unsupport type encoded with: " << typeVal <<
"." << std::endl;
1495 if (path.First(
'/') == -1)
1500 TObject *obj = treeObj->FindObject(str);
1504 std::cerr << std::endl <<
">> TMusrRunHeader::UpdateFolder(): **ERROR** couldn't tokenize path!!" << std::endl;
1509 TObjArray *oarray =
new TObjArray();
1510 if (oarray ==
nullptr) {
1511 std::cerr << std::endl <<
">> TMusrRunHeader::UpdateFolder(): **ERROR** couldn't create header structure!!" << std::endl;
1515 oarray->SetName(str);
1517 if (!strcmp(treeObj->ClassName(),
"TFolder"))
1518 (
dynamic_cast<TFolder*
>(treeObj))->Add(oarray);
1520 (
dynamic_cast<TObjArray*
>(treeObj))->AddLast(oarray);
1544 TObject *obj=
nullptr;
1547 if (strcmp(treeObj->ClassName(),
"TFolder") && strcmp(treeObj->ClassName(),
"TObjArray"))
1550 pos = path.First(
'/');
1552 obj = treeObj->FindObject(path);
1555 TString objName =
GetFirst(path,
'/');
1556 obj = treeObj->FindObject(objName);
1576 TObjString tostr(
"n/a");
1578 TString str(
""), path(
""), name(
""), fmt(
""), tstr(
"");
1587 tostr.SetString(str);
1591 for (UInt_t j=0; j<
fIntObj.size(); j++) {
1594 str.Form(
"%03d - %s: %d -@%d", idx, name.Data(),
fIntObj[j].GetValue(),
MRH_INT);
1595 tostr.SetString(str);
1604 tostr.SetString(str);
1611 Int_t digit, digit_d;
1617 fmt.Form(
"%%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf; %%s", digit, digit, digit_d);
1621 fmt.Form(
"%%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf", digit, digit, digit_d);
1628 fmt.Form(
"%%s: %%.%dlf +- %%.%dlf %%s; %%s", digit, digit);
1631 fmt.Form(
"%%s: %%.%dlf +- %%.%dlf %%s", digit, digit);
1638 fmt.Form(
"%%s: %%.%dlf %%s; %%s", digit);
1641 fmt.Form(
"%%s: %%.%dlf %%s", digit);
1649 fmt.Form(
"%%s: %%.%dlf %%s; SP: %%.%dlf; %%s", digit, digit_d);
1652 fmt.Form(
"%%s: %%.%dlf %%s; SP: %%.%dlf", digit, digit_d);
1657 tostr.SetString(str);
1664 str.Form(
"%03d - %s: ", idx, name.Data());
1666 for (UInt_t k=0; k<vstr.size()-1; k++)
1667 str += vstr[k] +
"; ";
1668 str += vstr[vstr.size()-1];
1671 tostr.SetString(str);
1678 str.Form(
"%03d - %s: ", idx, name.Data());
1680 for (UInt_t k=0; k<vint.size()-1; k++) {
1684 str += vint[vint.size()-1];
1687 tostr.SetString(str);
1694 str.Form(
"%03d - %s: ", idx, name.Data());
1698 for (UInt_t k=0; k<dvec.size()-1; k++) {
1699 subStr.Form(fmt, dvec[k]);
1703 subStr.Form(fmt, dvec[dvec.size()-1]);
1707 tostr.SetString(str);
1727 Ssiz_t idx = str.First(splitter);
1731 str.Remove(0, idx+1);
1754 TString result = str;
1756 Ssiz_t idx = str.First(splitter);
1758 result.Remove(idx, str.Length());
virtual void SetDemand(Double_t val)
Double_t fError
estimated error (standard deviation) of the measured value
TString fDescription
a more detailed description of the physical quantity
virtual Double_t GetValue() const
virtual void SetError(Double_t err)
TMusrRunPhysicalQuantity()
virtual TString GetDescription() const
TString fUnit
unit of the physical quantity
virtual void SetValue(Double_t val)
virtual void SetUnit(TString &unit)
virtual TString GetUnit() const
Double_t fValue
measured value of the physical quantity
virtual Double_t GetDemand() const
virtual TString GetLabel() const
virtual void Set(TString label, Double_t demand, Double_t value, Double_t error, TString unit, TString description=TString("n/a"))
virtual Double_t GetError() const
virtual void SetDescription(TString &str)
TString fLabel
property label, like ’Sample Temperature’ etc.
Double_t fDemand
demand value of the physical quantity, e.g. temperature setpoint
virtual void SetLabel(TString &label)