start with the implementation of NeXus IDF V2.

This commit is contained in:
2026-02-04 19:48:38 +01:00
parent ceb9673330
commit 43cb8b2460
2 changed files with 153 additions and 192 deletions

View File

@@ -2284,198 +2284,6 @@ Bool_t PRunDataHandler::ReadNexusFile()
// not yet implemented
}
}
/* //as35
} else if (nxs_file->GetIdfVersion() == 2) {
if (!nxs_file->IsValid()) {
std::cout << std::endl << "**ERROR** invalid NeXus IDF 2 version file found." << std::endl;
return false;
}
// get header information
// get/set laboratory
str = TString(nxs_file->GetEntryIdf2()->GetInstrument()->GetSource()->GetName());
runData.SetLaboratory(str);
// get/set beamline
str = TString(nxs_file->GetEntryIdf2()->GetInstrument()->GetName());
runData.SetBeamline(str);
// get/set instrument
str = TString(nxs_file->GetEntryIdf2()->GetInstrument()->GetName());
runData.SetInstrument(str);
// get/set muon source
str = TString(nxs_file->GetEntryIdf2()->GetInstrument()->GetSource()->GetType());
runData.SetMuonSource(str);
// get/set muon species
str = TString(nxs_file->GetEntryIdf2()->GetInstrument()->GetSource()->GetProbe());
runData.SetMuonSpecies(str);
// get/set run title
str = TString(nxs_file->GetEntryIdf2()->GetTitle());
runData.SetRunTitle(str);
// get/set run number
runData.SetRunNumber(nxs_file->GetEntryIdf2()->GetRunNumber());
// get/set temperature
dval = nxs_file->GetEntryIdf2()->GetSample()->GetPhysPropValue("temperature", ok);
if (ok)
runData.SetTemperature(0, dval, 0.0);
// get/set field
dval = nxs_file->GetEntryIdf2()->GetSample()->GetPhysPropValue("magnetic_field", ok);
nxs_file->GetEntryIdf2()->GetSample()->GetPhysPropUnit("magnetic_field", sstr, ok);
str = sstr;
// since field has to be given in Gauss, check the units
Double_t factor=1.0;
if (!str.CompareTo("gauss", TString::kIgnoreCase))
factor=1.0;
else if (!str.CompareTo("tesla", TString::kIgnoreCase))
factor=1.0e4;
else
factor=1.0;
runData.SetField(factor*dval);
// get/set implantation energy
runData.SetEnergy(PMUSR_UNDEFINED);
// get/set moderator HV
runData.SetTransport(PMUSR_UNDEFINED);
// get/set RA HV's (LEM specific)
for (UInt_t i=0; i<4; i++)
runData.SetRingAnode(i, PMUSR_UNDEFINED);
// get/set setup take NXsample/temperature_1_env and NXsample/magnetic_field_1_env
sstr = nxs_file->GetEntryIdf2()->GetSample()->GetEnvironmentTemp() + std::string("/");
sstr += nxs_file->GetEntryIdf2()->GetSample()->GetEnvironmentField();
str = sstr;
runData.SetSetup(str);
// get/set sample
runData.SetSample(nxs_file->GetEntryIdf2()->GetSample()->GetName());
// get/set orientation
runData.SetOrientation("??");
// get/set time resolution (ns)
runData.SetTimeResolution(nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetTimeResolution("ns"));
// get/set start/stop time
sstr = nxs_file->GetEntryIdf2()->GetStartTime();
str = sstr;
TString date, time;
SplitTimeDate(str, time, date, ok);
if (ok) {
runData.SetStartTime(time);
runData.SetStartDate(date);
}
sstr = nxs_file->GetEntryIdf2()->GetStopTime();
str = sstr;
SplitTimeDate(str, time, date, ok);
if (ok) {
runData.SetStopTime(time);
runData.SetStopDate(date);
}
// get/set data, t0, fgb, lgb
PDoubleVector data;
PRawRunDataSet dataSet;
UInt_t histoNo = 0;
Int_t ival;
int *histos = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetHistos();
if (nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfPeriods() > 0) { // counts[][][]
for (int i=0; i<nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfPeriods(); i++) {
for (int j=0; j<nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); j++) {
for (int k=0; k<nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfBins(); k++) {
data.push_back(*(histos+i*nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra()+j*nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfBins()+k));
}
dataSet.Clear();
dataSet.SetHistoNo(++histoNo); // i.e. histo numbers start with 1
// get t0
ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0(i,j);
if (ival == -1) // i.e. single value only
ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0();
dataSet.SetTimeZeroBin(ival);
// get first good bin
ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetFirstGoodBin(i,j);
if (ival == -1) // i.e. single value only
ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetFirstGoodBin();
dataSet.SetFirstGoodBin(ival);
// get last good bin
ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetLastGoodBin(i,j);
if (ival == -1) // i.e. single value only
ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetLastGoodBin();
dataSet.SetLastGoodBin(ival);
dataSet.SetData(data);
runData.SetDataSet(dataSet);
data.clear();
}
}
} else {
if (nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra() > 0) { // counts[][]
for (int i=0; i<nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); i++) {
for (int j=0; j<nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfBins(); j++) {
data.push_back(*(histos+i*nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfBins()+j));
}
dataSet.Clear();
dataSet.SetHistoNo(++histoNo); // i.e. histo numbers start with 1
// get t0
ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0(-1,i);
if (ival == -1) // i.e. single value only
ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0();
dataSet.SetTimeZeroBin(ival);
// get first good bin
ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetFirstGoodBin(-1,i);
if (ival == -1) // i.e. single value only
ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetFirstGoodBin();
dataSet.SetFirstGoodBin(ival);
// get last good bin
ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetLastGoodBin(-1,i);
if (ival == -1) // i.e. single value only
ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetLastGoodBin();
dataSet.SetLastGoodBin(ival);
dataSet.SetData(data);
runData.SetDataSet(dataSet);
data.clear();
}
} else { // counts[]
for (int i=0; i<nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfBins(); i++) {
data.push_back(*(histos+i));
}
dataSet.Clear();
dataSet.SetHistoNo(++histoNo); // i.e. histo numbers start with 1
// get t0
ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0();
dataSet.SetTimeZeroBin(ival);
// get first good bin
ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetFirstGoodBin();
dataSet.SetFirstGoodBin(ival);
// get last good bin
ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetLastGoodBin();
dataSet.SetLastGoodBin(ival);
dataSet.SetData(data);
runData.SetDataSet(dataSet);
data.clear();
}
}
// keep run name from the msr-file
runData.SetRunName(fRunName);
// keep the information
fData.push_back(runData);
} else {
std::cout << std::endl << ">> PRunDataHandler::ReadNexusFile(): IDF version " << nxs_file->GetIdfVersion() << ", not implemented." << std::endl;
}
*/ //as35
#else
std::cout << std::endl << ">> PRunDataHandler::ReadNexusFile(): Sorry, not enabled at configuration level, i.e. --enable-NeXus when executing configure" << std::endl << std::endl;
#endif