proper TDirectory handling for the histos.
All checks were successful
Build and Deploy Documentation / build-and-deploy (push) Successful in 19s
All checks were successful
Build and Deploy Documentation / build-and-deploy (push) Successful in 19s
This commit is contained in:
@@ -1946,7 +1946,12 @@ Bool_t PRunDataHandler::ReadRootFile()
|
|||||||
runData.SetBeamline(str);
|
runData.SetBeamline(str);
|
||||||
|
|
||||||
// read run summary to obtain ring anode HV values
|
// read run summary to obtain ring anode HV values
|
||||||
TObjArray *runSummary = dynamic_cast<TObjArray*>(folder->FindObjectAny("RunSummary"));
|
TObjArray *runSummary = nullptr;
|
||||||
|
if (fileType == PRH_MUSR_ROOT) // TFolder
|
||||||
|
runSummary = dynamic_cast<TObjArray*>(folder->FindObjectAny("RunSummary"));
|
||||||
|
else { // TDirectory
|
||||||
|
f.GetObject("RunHeader/RunSummary", runSummary);
|
||||||
|
}
|
||||||
|
|
||||||
// check if run summary is valid
|
// check if run summary is valid
|
||||||
if (!runSummary) {
|
if (!runSummary) {
|
||||||
@@ -2056,6 +2061,7 @@ Bool_t PRunDataHandler::ReadRootFile()
|
|||||||
|
|
||||||
// read data ---------------------------------------------------------
|
// read data ---------------------------------------------------------
|
||||||
|
|
||||||
|
if (fileType == PRH_MUSR_ROOT) { // TFolder
|
||||||
// check if histos folder is found
|
// check if histos folder is found
|
||||||
f.GetObject("histos", folder);
|
f.GetObject("histos", folder);
|
||||||
if (!folder) {
|
if (!folder) {
|
||||||
@@ -2111,6 +2117,56 @@ Bool_t PRunDataHandler::ReadRootFile()
|
|||||||
histoData.clear();
|
histoData.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else { // TDirectory
|
||||||
|
// get all the data
|
||||||
|
TH1F *histo;
|
||||||
|
for (UInt_t i=0; i<redGreenOffsets.size(); i++) {
|
||||||
|
for (Int_t j=0; j<noOfHistos; j++) {
|
||||||
|
str.Form("histos/DecayAnaModule/hDecay%03d", redGreenOffsets[i]+j+1);
|
||||||
|
f.GetObject(str, histo);
|
||||||
|
if (!histo) {
|
||||||
|
std::cerr << std::endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't get histo " << str;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
f.Close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
dataSet.Clear();
|
||||||
|
dataSet.SetTitle(histo->GetTitle());
|
||||||
|
dataSet.SetHistoNo(redGreenOffsets[i]+j+1);
|
||||||
|
|
||||||
|
// get detector info
|
||||||
|
path.Form("DetectorInfo/Detector%03d/", redGreenOffsets[i]+j+1);
|
||||||
|
pathName = path + "Name";
|
||||||
|
header->Get(pathName, str, ok);
|
||||||
|
if (ok)
|
||||||
|
dataSet.SetName(str);
|
||||||
|
pathName = path + "Time Zero Bin";
|
||||||
|
header->Get(pathName, dval, ok);
|
||||||
|
if (ok)
|
||||||
|
dataSet.SetTimeZeroBin(dval);
|
||||||
|
pathName = path + "First Good Bin";
|
||||||
|
header->Get(pathName, ival, ok);
|
||||||
|
if (ok)
|
||||||
|
dataSet.SetFirstGoodBin(ival);
|
||||||
|
pathName = path + "Last Good Bin";
|
||||||
|
header->Get(pathName, ival, ok);
|
||||||
|
if (ok)
|
||||||
|
dataSet.SetLastGoodBin(ival);
|
||||||
|
dataSet.SetTimeZeroBinEstimated(histo->GetMaximumBin());
|
||||||
|
|
||||||
|
// fill data
|
||||||
|
for (Int_t j=1; j<=histo->GetNbinsX(); j++) {
|
||||||
|
histoData.push_back(histo->GetBinContent(j));
|
||||||
|
}
|
||||||
|
dataSet.SetData(histoData);
|
||||||
|
runData.SetDataSet(dataSet);
|
||||||
|
|
||||||
|
// clear histoData for the next histo
|
||||||
|
histoData.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
f.Close();
|
f.Close();
|
||||||
|
|||||||
Reference in New Issue
Block a user