13 Commits

30 changed files with 923 additions and 1088 deletions

View File

@ -5,7 +5,7 @@ if (CMAKE_VERSION GREATER_EQUAL 3.12)
cmake_policy(SET CMP0075 NEW) cmake_policy(SET CMP0075 NEW)
endif (CMAKE_VERSION GREATER_EQUAL 3.12) endif (CMAKE_VERSION GREATER_EQUAL 3.12)
project(musrfit VERSION 1.7.2 LANGUAGES C CXX) project(musrfit VERSION 1.7.4 LANGUAGES C CXX)
#--- musrfit specific options ------------------------------------------------- #--- musrfit specific options -------------------------------------------------
option(nexus "build optional NeXus support. Needed for ISIS" OFF) option(nexus "build optional NeXus support. Needed for ISIS" OFF)

View File

@ -12,6 +12,17 @@ or
https://bitbucket.org/muonspin/musrfit/commits/all https://bitbucket.org/muonspin/musrfit/commits/all
Release of V1.7.4, 2021/06/16
=============================
allow in asymmetry fits #forward groups != #backward groups
Release of V1.7.3, 2021/06/01
=============================
making musrfit Apple Silicon M1 ready. Currently there is still an open issue
with NeXus (HDF4 only).
Release of V1.7.2, 2021/04/16 Release of V1.7.2, 2021/04/16
============================= =============================

View File

@ -2,6 +2,7 @@
#define PACKAGE_VERSION "@PROJECT_VERSION@" #define PACKAGE_VERSION "@PROJECT_VERSION@"
#define ROOT_VERSION_USED "@ROOT_VERSION@" #define ROOT_VERSION_USED "@ROOT_VERSION@"
#define BUILD_TYPE "@CMAKE_BUILD_TYPE@"
// define to 1 if minor ROOT6 version is >= 24 // define to 1 if minor ROOT6 version is >= 24
#define ROOT_GRTEQ_24 @ROOT_GRTEQ_24@ #define ROOT_GRTEQ_24 @ROOT_GRTEQ_24@

View File

@ -197,7 +197,7 @@ int main(int argc, char *argv[])
any2many_syntax(); any2many_syntax();
else if (strstr(argv[1], "--v")) { else if (strstr(argv[1], "--v")) {
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
std::cout << std::endl << "any2many version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << ", ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl; std::cout << std::endl << "any2many version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else #else
std::cout << std::endl << "any2many git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl; std::cout << std::endl << "any2many git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#endif #endif

View File

@ -6334,16 +6334,7 @@ Bool_t PMsrHandler::CheckHistoGrouping()
{ {
Bool_t result = true; Bool_t result = true;
for (UInt_t i=0; i<fRuns.size(); i++) { for (UInt_t i=0; i<fRuns.size(); i++) {
if (fRuns[i].GetFitType() == MSR_FITTYPE_ASYM || fRuns[i].GetFitType() == MSR_FITTYPE_BNMR) {
if (fRuns[i].GetForwardHistoNoSize() != fRuns[i].GetBackwardHistoNoSize()) {
std::cerr << std::endl << ">> PMsrHandler::CheckHistoGrouping: **ERROR** # of forward histos != # of backward histos.";
std::cerr << std::endl << ">> Run #" << i+1;
std::cerr << std::endl;
result = false;
break;
}
}
// check grouping entries are not identical, e.g. forward 1 1 2 // check grouping entries are not identical, e.g. forward 1 1 2
if (fRuns[i].GetForwardHistoNoSize() > 1) { if (fRuns[i].GetForwardHistoNoSize() > 1) {
for (UInt_t j=0; j<fRuns[i].GetForwardHistoNoSize(); j++) { for (UInt_t j=0; j<fRuns[i].GetForwardHistoNoSize(); j++) {

View File

@ -602,17 +602,7 @@ Bool_t PRunAsymmetry::PrepareData()
return false; return false;
} }
} }
if (forwardHistoNo.size() != backwardHistoNo.size()) {
std::cerr << std::endl << ">> PRunAsymmetry::PrepareData(): **PANIC ERROR**:";
std::cerr << std::endl << ">> # of forward histograms different from # of backward histograms.";
std::cerr << std::endl << ">> Will quit :-(";
std::cerr << std::endl;
// clean up
forwardHistoNo.clear();
backwardHistoNo.clear();
return false;
}
// keep the time resolution in (us) // keep the time resolution in (us)
fTimeResolution = runData->GetTimeResolution()/1.0e3; fTimeResolution = runData->GetTimeResolution()/1.0e3;
std::cout.precision(10); std::cout.precision(10);
@ -626,11 +616,13 @@ Bool_t PRunAsymmetry::PrepareData()
// keep the histo of each group at this point (addruns handled below) // keep the histo of each group at this point (addruns handled below)
std::vector<PDoubleVector> forward, backward; std::vector<PDoubleVector> forward, backward;
forward.resize(forwardHistoNo.size()); // resize to number of groups forward.resize(forwardHistoNo.size()); // resize to number of groups
backward.resize(backwardHistoNo.size()); // resize to numer of groups
for (UInt_t i=0; i<forwardHistoNo.size(); i++) { for (UInt_t i=0; i<forwardHistoNo.size(); i++) {
forward[i].resize(runData->GetDataBin(forwardHistoNo[i])->size()); forward[i].resize(runData->GetDataBin(forwardHistoNo[i])->size());
backward[i].resize(runData->GetDataBin(backwardHistoNo[i])->size());
forward[i] = *runData->GetDataBin(forwardHistoNo[i]); forward[i] = *runData->GetDataBin(forwardHistoNo[i]);
}
backward.resize(backwardHistoNo.size()); // resize to number of groups
for (UInt_t i=0; i<backwardHistoNo.size(); i++) {
backward[i].resize(runData->GetDataBin(backwardHistoNo[i])->size());
backward[i] = *runData->GetDataBin(backwardHistoNo[i]); backward[i] = *runData->GetDataBin(backwardHistoNo[i]);
} }
@ -676,9 +668,11 @@ Bool_t PRunAsymmetry::PrepareData()
// set forward/backward histo data of the first group // set forward/backward histo data of the first group
fForward.resize(forward[0].size()); fForward.resize(forward[0].size());
fBackward.resize(backward[0].size());
for (UInt_t i=0; i<fForward.size(); i++) { for (UInt_t i=0; i<fForward.size(); i++) {
fForward[i] = forward[0][i]; fForward[i] = forward[0][i];
}
fBackward.resize(backward[0].size());
for (UInt_t i=0; i<fBackward.size(); i++) {
fBackward[i] = backward[0][i]; fBackward[i] = backward[0][i];
} }
@ -781,7 +775,21 @@ Bool_t PRunAsymmetry::PrepareData()
*/ */
Bool_t PRunAsymmetry::SubtractFixBkg() Bool_t PRunAsymmetry::SubtractFixBkg()
{ {
if (fRunInfo->GetBkgFix(0) == PMUSR_UNDEFINED) {
std::cerr << "PRunAsymmetry::SubtractFixBkg(): **ERROR** no fixed bkg for forward set. Will do nothing here." << std::endl;
return false;
}
if (fRunInfo->GetBkgFix(1) == PMUSR_UNDEFINED) {
std::cerr << "PRunAsymmetry::SubtractFixBkg(): **ERROR** no fixed bkg for backward set. Will do nothing here." << std::endl;
std::cerr << " you need an entry like:" << std::endl;
std::cerr << " backgr.fix 2 3" << std::endl;
std::cerr << " i.e. two entries for forward and backward." << std::endl;
return false;
}
Double_t dval; Double_t dval;
for (UInt_t i=0; i<fForward.size(); i++) { for (UInt_t i=0; i<fForward.size(); i++) {
// keep the error, and make sure that the bin is NOT empty // keep the error, and make sure that the bin is NOT empty
if (fForward[i] != 0.0) if (fForward[i] != 0.0)
@ -1005,8 +1013,8 @@ Bool_t PRunAsymmetry::PrepareFitData()
Double_t asym; Double_t asym;
Double_t f, b, ef, eb; Double_t f, b, ef, eb;
// fill data time start, and step // fill data time start, and step
// data start at data_start-t0 shifted by (pack-1)/2 // data start time = (binStart - 0.5) + pack/2 - t0, with pack and binStart used as double
fData.SetDataTimeStart(fTimeResolution*(static_cast<Double_t>(fGoodBins[0])-fT0s[0]+static_cast<Double_t>(fPacking-1)/2.0)); fData.SetDataTimeStart(fTimeResolution*((static_cast<Double_t>(fGoodBins[0])-0.5) + static_cast<Double_t>(fPacking)/2.0 - static_cast<Double_t>(fT0s[0])));
fData.SetDataTimeStep(fTimeResolution*static_cast<Double_t>(fPacking)); fData.SetDataTimeStep(fTimeResolution*static_cast<Double_t>(fPacking));
for (UInt_t i=0; i<noOfBins; i++) { for (UInt_t i=0; i<noOfBins; i++) {
// to make the formulae more readable // to make the formulae more readable
@ -1207,8 +1215,8 @@ Bool_t PRunAsymmetry::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2])
Double_t asym; Double_t asym;
Double_t f, b, ef, eb, alpha = 1.0, beta = 1.0; Double_t f, b, ef, eb, alpha = 1.0, beta = 1.0;
// set data time start, and step // set data time start, and step
// data start at data_start-t0 // data start time = (binStart - 0.5) + pack/2 - t0, with pack and binStart used as double
fData.SetDataTimeStart(fTimeResolution*(static_cast<Double_t>(start[0])-t0[0]+static_cast<Double_t>(packing-1)/2.0)); fData.SetDataTimeStart(fTimeResolution*((static_cast<Double_t>(start[0])-0.5) + static_cast<Double_t>(packing)/2.0 - static_cast<Double_t>(t0[0])));
fData.SetDataTimeStep(fTimeResolution*static_cast<Double_t>(packing)); fData.SetDataTimeStep(fTimeResolution*static_cast<Double_t>(packing));
// get the proper alpha and beta // get the proper alpha and beta
@ -1586,8 +1594,8 @@ Bool_t PRunAsymmetry::PrepareRRFViewData(PRawRunData* runData, UInt_t histoNo[2]
} }
// set data time start, and step // set data time start, and step
// data start at data_start-t0 // data start time = (binStart - 0.5) + pack/2 - t0, with pack and binStart used as double
fData.SetDataTimeStart(fTimeResolution*(start[0]-t0[0]+static_cast<Double_t>(packing-1)/2.0)); fData.SetDataTimeStart(fTimeResolution*((static_cast<Double_t>(start[0])-0.5) + static_cast<Double_t>(packing)/2.0 - static_cast<Double_t>(t0[0])));
fData.SetDataTimeStep(fTimeResolution*static_cast<Double_t>(packing)); fData.SetDataTimeStep(fTimeResolution*static_cast<Double_t>(packing));
// ------------------------------------------------------------ // ------------------------------------------------------------
@ -1663,7 +1671,7 @@ Bool_t PRunAsymmetry::PrepareRRFViewData(PRawRunData* runData, UInt_t histoNo[2]
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* <p>Get the proper t0 for the single histogram run. * <p>Get the proper t0 for the single histogram run.
* -# the t0 vector size = number of detectors (grouping) for forward. * -# the t0 vector size = number of detectors (grouping) for forward + backward.
* -# initialize t0's with -1 * -# initialize t0's with -1
* -# fill t0's from RUN block * -# fill t0's from RUN block
* -# if t0's are missing (i.e. t0 == -1), try to fill from the GLOBAL block. * -# if t0's are missing (i.e. t0 == -1), try to fill from the GLOBAL block.
@ -1684,7 +1692,11 @@ Bool_t PRunAsymmetry::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalB
// feed all T0's // feed all T0's
// first init T0's, T0's are stored as (forward T0, backward T0, etc.) // first init T0's, T0's are stored as (forward T0, backward T0, etc.)
fT0s.clear(); fT0s.clear();
fT0s.resize(2*forwardHistoNo.size()); // this strange fT0 size estimate is needed in case #forw histos != #back histos
size_t size = 2*forwardHistoNo.size();
if (backwardHistoNo.size() > forwardHistoNo.size())
size = 2*backwardHistoNo.size();
fT0s.resize(size);
for (UInt_t i=0; i<fT0s.size(); i++) { for (UInt_t i=0; i<fT0s.size(); i++) {
fT0s[i] = -1.0; fT0s[i] = -1.0;
} }
@ -1751,6 +1763,8 @@ Bool_t PRunAsymmetry::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalB
std::cerr << std::endl; std::cerr << std::endl;
return false; return false;
} }
}
for (UInt_t i=0; i<backwardHistoNo.size(); i++) {
if ((fT0s[2*i+1] < 0) || (fT0s[2*i+1] > static_cast<Int_t>(runData->GetDataBin(backwardHistoNo[i])->size()))) { if ((fT0s[2*i+1] < 0) || (fT0s[2*i+1] > static_cast<Int_t>(runData->GetDataBin(backwardHistoNo[i])->size()))) {
std::cerr << std::endl << ">> PRunAsymmetry::PrepareData(): **ERROR** t0 data bin (" << fT0s[2*i+1] << ") doesn't make any sense!"; std::cerr << std::endl << ">> PRunAsymmetry::PrepareData(): **ERROR** t0 data bin (" << fT0s[2*i+1] << ") doesn't make any sense!";
std::cerr << std::endl << ">> backwardHistoNo " << backwardHistoNo[i]; std::cerr << std::endl << ">> backwardHistoNo " << backwardHistoNo[i];

View File

@ -640,6 +640,7 @@ Bool_t PRunAsymmetryBNMR::PrepareData()
return false; return false;
} }
} }
/* //as35
if (forwardHistoNo.size() != backwardHistoNo.size()) { if (forwardHistoNo.size() != backwardHistoNo.size()) {
std::cerr << std::endl << ">> PRunAsymmetryBNMR::PrepareData(): **PANIC ERROR**:"; std::cerr << std::endl << ">> PRunAsymmetryBNMR::PrepareData(): **PANIC ERROR**:";
std::cerr << std::endl << ">> # of forward histograms different from # of backward histograms."; std::cerr << std::endl << ">> # of forward histograms different from # of backward histograms.";
@ -650,7 +651,8 @@ Bool_t PRunAsymmetryBNMR::PrepareData()
backwardHistoNo.clear(); backwardHistoNo.clear();
return false; return false;
} }
*/ //as35
// keep the time resolution in (s) // keep the time resolution in (s)
fTimeResolution = runData->GetTimeResolution()/1.0e3; fTimeResolution = runData->GetTimeResolution()/1.0e3;
std::cout.precision(10); std::cout.precision(10);
@ -664,11 +666,13 @@ Bool_t PRunAsymmetryBNMR::PrepareData()
// keep the histo of each group at this point (addruns handled below) // keep the histo of each group at this point (addruns handled below)
std::vector<PDoubleVector> forward, backward; std::vector<PDoubleVector> forward, backward;
forward.resize(forwardHistoNo.size()); // resize to number of groups forward.resize(forwardHistoNo.size()); // resize to number of groups
backward.resize(backwardHistoNo.size()); // resize to numer of groups
for (UInt_t i=0; i<forwardHistoNo.size(); i++) { for (UInt_t i=0; i<forwardHistoNo.size(); i++) {
forward[i].resize(runData->GetDataBin(forwardHistoNo[i])->size()); forward[i].resize(runData->GetDataBin(forwardHistoNo[i])->size());
backward[i].resize(runData->GetDataBin(backwardHistoNo[i])->size());
forward[i] = *runData->GetDataBin(forwardHistoNo[i]); forward[i] = *runData->GetDataBin(forwardHistoNo[i]);
}
backward.resize(backwardHistoNo.size()); // resize to number of groups
for (UInt_t i=0; i<backwardHistoNo.size(); i++) {
backward[i].resize(runData->GetDataBin(backwardHistoNo[i])->size());
backward[i] = *runData->GetDataBin(backwardHistoNo[i]); backward[i] = *runData->GetDataBin(backwardHistoNo[i]);
} }
@ -712,15 +716,18 @@ Bool_t PRunAsymmetryBNMR::PrepareData()
} }
} }
// set forward/backward histo data of the first group // set forward histo data of the first group
fForwardp.resize(forward[0].size()); fForwardp.resize(forward[0].size());
fBackwardp.resize(backward[0].size());
fForwardm.resize(forward[0].size()); fForwardm.resize(forward[0].size());
fBackwardm.resize(backward[0].size());
for (UInt_t i=0; i<fForwardp.size(); i++) { for (UInt_t i=0; i<fForwardp.size(); i++) {
fForwardp[i] = forward[0][i]; fForwardp[i] = forward[0][i];
fBackwardp[i] = backward[0][i];
fForwardm[i] = forward[1][i]; fForwardm[i] = forward[1][i];
}
// set backward histo data of the first group
fBackwardp.resize(backward[0].size());
fBackwardm.resize(backward[0].size());
for (UInt_t i=0; i<fBackwardp.size(); i++) {
fBackwardp[i] = backward[0][i];
fBackwardm[i] = backward[1][i]; fBackwardm[i] = backward[1][i];
} }
@ -1529,7 +1536,11 @@ Bool_t PRunAsymmetryBNMR::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *glo
// feed all T0's // feed all T0's
// first init T0's, T0's are stored as (forward T0, backward T0, etc.) // first init T0's, T0's are stored as (forward T0, backward T0, etc.)
fT0s.clear(); fT0s.clear();
fT0s.resize(2*forwardHistoNo.size()); // this strange fT0 size estimate is needed in case #forw histos != #back histos
size_t size = 2*forwardHistoNo.size();
if (backwardHistoNo.size() > forwardHistoNo.size())
size = 2*backwardHistoNo.size();
fT0s.resize(size);
for (UInt_t i=0; i<fT0s.size(); i++) { for (UInt_t i=0; i<fT0s.size(); i++) {
fT0s[i] = -1.0; fT0s[i] = -1.0;
} }
@ -1596,6 +1607,8 @@ Bool_t PRunAsymmetryBNMR::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *glo
std::cerr << std::endl; std::cerr << std::endl;
return false; return false;
} }
}
for (UInt_t i=0; i<backwardHistoNo.size(); i++) {
if ((fT0s[2*i+1] < 0) || (fT0s[2*i+1] > static_cast<Int_t>(runData->GetDataBin(backwardHistoNo[i])->size()))) { if ((fT0s[2*i+1] < 0) || (fT0s[2*i+1] > static_cast<Int_t>(runData->GetDataBin(backwardHistoNo[i])->size()))) {
std::cerr << std::endl << ">> PRunAsymmetryBNMR::PrepareData(): **ERROR** t0 data bin (" << fT0s[2*i+1] << ") doesn't make any sense!"; std::cerr << std::endl << ">> PRunAsymmetryBNMR::PrepareData(): **ERROR** t0 data bin (" << fT0s[2*i+1] << ") doesn't make any sense!";
std::cerr << std::endl << ">> backwardHistoNo " << backwardHistoNo[i]; std::cerr << std::endl << ">> backwardHistoNo " << backwardHistoNo[i];

View File

@ -584,16 +584,6 @@ Bool_t PRunAsymmetryRRF::PrepareData()
return false; return false;
} }
} }
if (forwardHistoNo.size() != backwardHistoNo.size()) {
std::cerr << std::endl << ">> PRunAsymmetryRRF::PrepareData(): **PANIC ERROR**:";
std::cerr << std::endl << ">> # of forward histograms different from # of backward histograms.";
std::cerr << std::endl << ">> Will quit :-(";
std::cerr << std::endl;
// clean up
forwardHistoNo.clear();
backwardHistoNo.clear();
return false;
}
// keep the time resolution in (us) // keep the time resolution in (us)
fTimeResolution = runData->GetTimeResolution()/1.0e3; fTimeResolution = runData->GetTimeResolution()/1.0e3;
@ -608,11 +598,13 @@ Bool_t PRunAsymmetryRRF::PrepareData()
// keep the histo of each group at this point (addruns handled below) // keep the histo of each group at this point (addruns handled below)
std::vector<PDoubleVector> forward, backward; std::vector<PDoubleVector> forward, backward;
forward.resize(forwardHistoNo.size()); // resize to number of groups forward.resize(forwardHistoNo.size()); // resize to number of groups
backward.resize(backwardHistoNo.size()); // resize to numer of groups
for (UInt_t i=0; i<forwardHistoNo.size(); i++) { for (UInt_t i=0; i<forwardHistoNo.size(); i++) {
forward[i].resize(runData->GetDataBin(forwardHistoNo[i])->size()); forward[i].resize(runData->GetDataBin(forwardHistoNo[i])->size());
backward[i].resize(runData->GetDataBin(backwardHistoNo[i])->size());
forward[i] = *runData->GetDataBin(forwardHistoNo[i]); forward[i] = *runData->GetDataBin(forwardHistoNo[i]);
}
backward.resize(backwardHistoNo.size()); // resize to number of groups
for (UInt_t i=0; i<backwardHistoNo.size(); i++) {
backward[i].resize(runData->GetDataBin(backwardHistoNo[i])->size());
backward[i] = *runData->GetDataBin(backwardHistoNo[i]); backward[i] = *runData->GetDataBin(backwardHistoNo[i]);
} }
@ -1281,7 +1273,11 @@ Bool_t PRunAsymmetryRRF::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *glob
// feed all T0's // feed all T0's
// first init T0's, T0's are stored as (forward T0, backward T0, etc.) // first init T0's, T0's are stored as (forward T0, backward T0, etc.)
fT0s.clear(); fT0s.clear();
fT0s.resize(2*forwardHistoNo.size()); // this strange fT0 size estimate is needed in case #forw histos != #back histos
size_t size = 2*forwardHistoNo.size();
if (backwardHistoNo.size() > forwardHistoNo.size())
size = 2*backwardHistoNo.size();
fT0s.resize(size);
for (UInt_t i=0; i<fT0s.size(); i++) { for (UInt_t i=0; i<fT0s.size(); i++) {
fT0s[i] = -1.0; fT0s[i] = -1.0;
} }
@ -1348,6 +1344,8 @@ Bool_t PRunAsymmetryRRF::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *glob
std::cerr << std::endl; std::cerr << std::endl;
return false; return false;
} }
}
for (UInt_t i=0; i<backwardHistoNo.size(); i++) {
if ((fT0s[2*i+1] < 0) || (fT0s[2*i+1] > static_cast<Int_t>(runData->GetDataBin(backwardHistoNo[i])->size()))) { if ((fT0s[2*i+1] < 0) || (fT0s[2*i+1] > static_cast<Int_t>(runData->GetDataBin(backwardHistoNo[i])->size()))) {
std::cerr << std::endl << ">> PRunAsymmetryRRF::PrepareData(): **ERROR** t0 data bin (" << fT0s[2*i+1] << ") doesn't make any sense!"; std::cerr << std::endl << ">> PRunAsymmetryRRF::PrepareData(): **ERROR** t0 data bin (" << fT0s[2*i+1] << ") doesn't make any sense!";
std::cerr << std::endl << ">> backwardHistoNo " << backwardHistoNo[i]; std::cerr << std::endl << ">> backwardHistoNo " << backwardHistoNo[i];

View File

@ -604,8 +604,8 @@ Bool_t PRunMuMinus::PrepareFitData(PRawRunData* runData, const UInt_t histoNo)
Int_t t0 = static_cast<Int_t>(fT0s[0]); Int_t t0 = static_cast<Int_t>(fT0s[0]);
Double_t value = 0.0; Double_t value = 0.0;
// data start at data_start-t0 // data start at data_start-t0
// time shifted so that packing is included correctly, i.e. t0 == t0 after packing // data start time = (binStart - 0.5) + pack/2 - t0, with pack and binStart used as double
fData.SetDataTimeStart(fTimeResolution*(static_cast<Double_t>(fGoodBins[0])-static_cast<Double_t>(t0)+static_cast<Double_t>(fPacking-1)/2.0)); fData.SetDataTimeStart(fTimeResolution*((static_cast<Double_t>(fGoodBins[0])-0.5) + static_cast<Double_t>(fPacking)/2.0 - static_cast<Double_t>(t0)));
fData.SetDataTimeStep(fTimeResolution*fPacking); fData.SetDataTimeStep(fTimeResolution*fPacking);
for (Int_t i=fGoodBins[0]; i<fGoodBins[1]; i++) { for (Int_t i=fGoodBins[0]; i<fGoodBins[1]; i++) {
if (fPacking == 1) { if (fPacking == 1) {
@ -710,9 +710,8 @@ Bool_t PRunMuMinus::PrepareRawViewData(PRawRunData* runData, const UInt_t histoN
// everything looks fine, hence fill data set // everything looks fine, hence fill data set
Int_t t0 = static_cast<Int_t>(fT0s[0]); Int_t t0 = static_cast<Int_t>(fT0s[0]);
Double_t value = 0.0; Double_t value = 0.0;
// data start at data_start-t0 // data start time = (binStart - 0.5) + pack/2 - t0, with pack and binStart used as double
// time shifted so that packing is included correctly, i.e. t0 == t0 after packing fData.SetDataTimeStart(fTimeResolution*((static_cast<Double_t>(start)-0.5) + static_cast<Double_t>(packing)/2.0 - static_cast<Double_t>(t0)));
fData.SetDataTimeStart(fTimeResolution*(static_cast<Double_t>(start)-static_cast<Double_t>(t0)+static_cast<Double_t>(packing-1)/2.0));
fData.SetDataTimeStep(fTimeResolution*packing); fData.SetDataTimeStep(fTimeResolution*packing);
for (Int_t i=start; i<end; i++) { for (Int_t i=start; i<end; i++) {

View File

@ -888,7 +888,7 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN
normalizer = fPacking * (fTimeResolution * 1.0e3); // fTimeResolution us->ns normalizer = fPacking * (fTimeResolution * 1.0e3); // fTimeResolution us->ns
// data start at data_start-t0 // data start at data_start-t0
// time shifted so that packing is included correctly, i.e. t0 == t0 after packing // time shifted so that packing is included correctly, i.e. t0 == t0 after packing
fData.SetDataTimeStart(fTimeResolution*(static_cast<Double_t>(fGoodBins[0])-static_cast<Double_t>(t0)+static_cast<Double_t>(fPacking-1)/2.0)); fData.SetDataTimeStart(fTimeResolution*((static_cast<Double_t>(fGoodBins[0])-0.5) + static_cast<Double_t>(fPacking)/2.0 - static_cast<Double_t>(t0)));
fData.SetDataTimeStep(fTimeResolution*fPacking); fData.SetDataTimeStep(fTimeResolution*fPacking);
for (Int_t i=fGoodBins[0]; i<fGoodBins[1]; i++) { for (Int_t i=fGoodBins[0]; i<fGoodBins[1]; i++) {
if (fPacking == 1) { if (fPacking == 1) {
@ -991,9 +991,8 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi
// everything looks fine, hence fill data set // everything looks fine, hence fill data set
Int_t t0 = static_cast<Int_t>(fT0s[0]); Int_t t0 = static_cast<Int_t>(fT0s[0]);
Double_t value = 0.0; Double_t value = 0.0;
// data start at data_start-t0 // data start time = (binStart - 0.5) + pack/2 - t0, with pack and binStart used as double
// time shifted so that packing is included correctly, i.e. t0 == t0 after packing fData.SetDataTimeStart(fTimeResolution*((static_cast<Double_t>(start)-0.5) + static_cast<Double_t>(packing)/2.0 - static_cast<Double_t>(t0)));
fData.SetDataTimeStart(fTimeResolution*(static_cast<Double_t>(start)-static_cast<Double_t>(t0)+static_cast<Double_t>(packing-1)/2.0));
fData.SetDataTimeStep(fTimeResolution*packing); fData.SetDataTimeStep(fTimeResolution*packing);
for (Int_t i=start; i<end; i++) { for (Int_t i=start; i<end; i++) {
@ -1247,8 +1246,8 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
Double_t rrf_val = 0.0; Double_t rrf_val = 0.0;
Double_t time = 0.0; Double_t time = 0.0;
// data start at data_start-t0 shifted by (pack-1)/2 // data start time = (binStart - 0.5) + pack/2 - t0, with pack and binStart used as double
fData.SetDataTimeStart(fTimeResolution*(static_cast<Double_t>(start)-static_cast<Double_t>(t0)+static_cast<Double_t>(packing-1)/2.0)); fData.SetDataTimeStart(fTimeResolution*((static_cast<Double_t>(start)-0.5) + static_cast<Double_t>(packing)/2.0 - static_cast<Double_t>(t0)));
fData.SetDataTimeStep(fTimeResolution*packing); fData.SetDataTimeStep(fTimeResolution*packing);
// data is always normalized to (per nsec!!) // data is always normalized to (per nsec!!)
@ -1257,7 +1256,8 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
for (Int_t i=start; i<end; i++) { for (Int_t i=start; i<end; i++) {
if (((i-start) % packing == 0) && (i != start)) { // fill data if (((i-start) % packing == 0) && (i != start)) { // fill data
value *= dataNorm; value *= dataNorm;
time = ((static_cast<Double_t>(i)-static_cast<Double_t>(packing-1)/2.0)-t0)*fTimeResolution; // since the packing counter is already at the end of the bin, the time needs be shifted back by pack*time_resolution
time = (((static_cast<Double_t>(i)-0.5) + static_cast<Double_t>(packing)/2.0 - static_cast<Double_t>(t0)))*fTimeResolution - static_cast<Double_t>(packing)*fTimeResolution;
expval = TMath::Exp(+time/tau)/N0; expval = TMath::Exp(+time/tau)/N0;
fData.AppendValue(-1.0+expval*(value-bkg)); fData.AppendValue(-1.0+expval*(value-bkg));
fData.AppendErrorValue(expval*TMath::Sqrt(value*dataNorm)); fData.AppendErrorValue(expval*TMath::Sqrt(value*dataNorm));
@ -1316,7 +1316,7 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
// calculate theory // calculate theory
Double_t theoryValue; Double_t theoryValue;
UInt_t size = fForward.size()/packing; UInt_t size = fForward.size()/packing;
Int_t factor = 8; // 8 times more points for the theory (if fTheoAsData == false) const Int_t factor = 8; // 8 times more points for the theory (if fTheoAsData == false)
UInt_t rebinRRF = 0; UInt_t rebinRRF = 0;
if (wRRF == 0) { // no RRF if (wRRF == 0) { // no RRF

View File

@ -447,7 +447,8 @@ int dump_header_mud(const std::string fileName, const std::string fileFormat)
// start time // start time
time_t tval; time_t tval;
struct tm *dt; struct tm *dt;
success = MUD_getTimeBegin( fh, (UINT32*)&tval ); success = MUD_getTimeBegin( fh, &val );
tval = static_cast<time_t>(val);
if (success) { if (success) {
dt = localtime(static_cast<const time_t*>(&tval)); dt = localtime(static_cast<const time_t*>(&tval));
assert(dt); assert(dt);
@ -457,7 +458,8 @@ int dump_header_mud(const std::string fileName, const std::string fileFormat)
std::cout << std::endl << "Run Start Time : ???"; std::cout << std::endl << "Run Start Time : ???";
} }
// stop time // stop time
success = MUD_getTimeEnd( fh, (UINT32*)&tval ); success = MUD_getTimeEnd( fh, &val );
tval = static_cast<time_t>(val);
if (success) { if (success) {
dt = localtime(static_cast<const time_t*>(&tval)); dt = localtime(static_cast<const time_t*>(&tval));
assert(dt); assert(dt);
@ -776,7 +778,7 @@ int main(int argc, char *argv[])
return 0; return 0;
} else if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-v")) { } else if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-v")) {
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
std::cout << std::endl << "dump_header version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << ", ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl; std::cout << std::endl << "dump_header version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else #else
std::cout << std::endl << "dump_header git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl; std::cout << std::endl << "dump_header git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#endif #endif

View File

@ -116,6 +116,13 @@ MuSR_td_PSI_bin::MuSR_td_PSI_bin()
file_name.close(); file_name.close();
delete [] buffer_file; delete [] buffer_file;
if (format_id[0] == '1') {
if (format_id[1] != 'N') {
std::cout << "**WARNING** found '" << format_id << "'. Will change it to '1N'" << std::endl;
format_id[1] = 'N';
}
}
// file may either be PSI binary format // file may either be PSI binary format
if (strncmp(format_id,"1N",2) == 0) if (strncmp(format_id,"1N",2) == 0)
{ {
@ -306,6 +313,9 @@ int MuSR_td_PSI_bin::readbin(const char * fileName)
strncpy(format_id,buffer_file,2); strncpy(format_id,buffer_file,2);
format_id[2] = '\0'; format_id[2] = '\0';
if (format_id[1] != 'N') // the warning is already issued in read()
format_id[1] = 'N';
if (strcmp(format_id,"1N") != 0) if (strcmp(format_id,"1N") != 0)
{ {
file_name.close(); file_name.close();

View File

@ -23,10 +23,10 @@
* v1.2 08-Oct-2000 [D. Arseneau] Add MUD_setSizes * v1.2 08-Oct-2000 [D. Arseneau] Add MUD_setSizes
* v1.3 22-Apr-2003 [D. Arseneau] Add MUD_openInOut * v1.3 22-Apr-2003 [D. Arseneau] Add MUD_openInOut
* 25-Nov-2009 [D. Arseneau] Handle larger size_t * 25-Nov-2009 [D. Arseneau] Handle larger size_t
* 04-May-2016 [D. Arseneau] Edits for C++ use
*/ */
#include <stdio.h>
#include "mud.h" #include "mud.h"
#ifdef NO_STDARG #ifdef NO_STDARG
@ -35,11 +35,10 @@
#include <stdarg.h> #include <stdarg.h>
#endif /* NO_STDARG */ #endif /* NO_STDARG */
/* #define DEBUG 1 /* un-comment for debug */ /* #define DEBUG 1 */ /* un-comment for debug */
FILE* FILE*
MUD_openInput( inFile ) MUD_openInput( char* inFile )
char* inFile;
{ {
FILE* fin; FILE* fin;
@ -53,8 +52,7 @@ MUD_openInput( inFile )
/* This is the same as MUD_openInput except for access mode */ /* This is the same as MUD_openInput except for access mode */
FILE* FILE*
MUD_openInOut( inFile ) MUD_openInOut( char* inFile )
char* inFile;
{ {
FILE* fin; FILE* fin;
@ -68,8 +66,7 @@ MUD_openInOut( inFile )
FILE* FILE*
MUD_openOutput( outFile ) MUD_openOutput( char* outFile )
char* outFile;
{ {
FILE* fout; FILE* fout;
@ -83,8 +80,7 @@ MUD_openOutput( outFile )
void void
MUD_free( pMUD ) MUD_free( void* pMUD )
void* pMUD;
{ {
if( pMUD != NULL ) MUD_free( ((MUD_SEC*)pMUD)->core.pNext ); if( pMUD != NULL ) MUD_free( ((MUD_SEC*)pMUD)->core.pNext );
else return; else return;
@ -101,10 +97,7 @@ MUD_free( pMUD )
BOOL BOOL
MUD_encode( pBuf, pMUD, io_opt ) MUD_encode( BUF* pBuf, void* pMUD, MUD_IO_OPT io_opt )
BUF* pBuf;
void* pMUD;
MUD_IO_OPT io_opt;
{ {
if( pMUD == NULL ) return( TRUE ); if( pMUD == NULL ) return( TRUE );
@ -130,7 +123,7 @@ MUD_encode( pBuf, pMUD, io_opt )
printf( "MUD_encode: buf.buf = %08X\n", pBuf->buf ); printf( "MUD_encode: buf.buf = %08X\n", pBuf->buf );
#endif /* DEBUG */ #endif /* DEBUG */
MUD_CORE_proc( MUD_ENCODE, pBuf, pMUD ); MUD_CORE_proc( MUD_ENCODE, pBuf, (MUD_SEC*)pMUD );
(*((MUD_SEC*)pMUD)->core.proc)( MUD_ENCODE, pBuf, (void*)pMUD ); (*((MUD_SEC*)pMUD)->core.proc)( MUD_ENCODE, pBuf, (void*)pMUD );
if( ( MUD_secID( pMUD ) == MUD_SEC_GRP_ID ) && if( ( MUD_secID( pMUD ) == MUD_SEC_GRP_ID ) &&
@ -155,8 +148,7 @@ MUD_encode( pBuf, pMUD, io_opt )
void* void*
MUD_decode( pBuf ) MUD_decode( BUF* pBuf )
BUF* pBuf;
{ {
MUD_SEC* pMUD; MUD_SEC* pMUD;
MUD_SEC mud; MUD_SEC mud;
@ -199,23 +191,20 @@ MUD_decode( pBuf )
int int
MUD_getSize( pMUD ) MUD_getSize( void* pMUD )
void* pMUD;
{ {
return( MUD_CORE_proc( MUD_GET_SIZE, NULL, pMUD ) + return( MUD_CORE_proc( MUD_GET_SIZE, NULL, (MUD_SEC*)pMUD ) +
(*((MUD_SEC*)pMUD)->core.proc)( MUD_GET_SIZE, NULL, (void*)pMUD ) ); (*((MUD_SEC*)pMUD)->core.proc)( MUD_GET_SIZE, NULL, pMUD ) );
} }
void void
MUD_show( pMUD, io_opt ) MUD_show( void* pMUD, MUD_IO_OPT io_opt )
void* pMUD;
MUD_IO_OPT io_opt;
{ {
if( pMUD == NULL ) return; if( pMUD == NULL ) return;
MUD_CORE_proc( MUD_SHOW, NULL, pMUD ); MUD_CORE_proc( MUD_SHOW, NULL, (MUD_SEC*)pMUD );
(*((MUD_SEC*)pMUD)->core.proc)( MUD_SHOW, NULL, (void*)pMUD ); (*((MUD_SEC*)pMUD)->core.proc)( MUD_SHOW, NULL, pMUD );
printf( "\n" ); printf( "\n" );
@ -233,14 +222,12 @@ MUD_show( pMUD, io_opt )
} }
void void
MUD_heads( pMUD, io_opt ) MUD_heads( void* pMUD, MUD_IO_OPT io_opt )
void* pMUD;
MUD_IO_OPT io_opt;
{ {
if( pMUD == NULL ) return; if( pMUD == NULL ) return;
MUD_CORE_proc( MUD_HEADS, NULL, pMUD ); MUD_CORE_proc( MUD_HEADS, NULL, (MUD_SEC*)pMUD );
(*((MUD_SEC*)pMUD)->core.proc)( MUD_HEADS, NULL, (void*)pMUD ); (*((MUD_SEC*)pMUD)->core.proc)( MUD_HEADS, NULL, pMUD );
if( ( MUD_secID( pMUD ) == MUD_SEC_GRP_ID ) && if( ( MUD_secID( pMUD ) == MUD_SEC_GRP_ID ) &&
( io_opt == MUD_ALL ) ) ( io_opt == MUD_ALL ) )
@ -260,8 +247,7 @@ MUD_heads( pMUD, io_opt )
* MUD_writeEnd() - called after all writes to file * MUD_writeEnd() - called after all writes to file
*/ */
BOOL BOOL
MUD_writeEnd( fout ) MUD_writeEnd( FILE* fout )
FILE* fout;
{ {
MUD_SEC_EOF* pMUD_eof; MUD_SEC_EOF* pMUD_eof;
@ -282,9 +268,7 @@ MUD_writeEnd( fout )
* MUD_writeFile() - use for completely assembled groups/sections * MUD_writeFile() - use for completely assembled groups/sections
*/ */
BOOL BOOL
MUD_writeFile( fout, pMUD_head ) MUD_writeFile( FILE* fout, void* pMUD_head )
FILE* fout;
void* pMUD_head;
{ {
rewind( fout ); rewind( fout );
if( !MUD_write( fout, pMUD_head, MUD_ALL ) ) return( FALSE ); if( !MUD_write( fout, pMUD_head, MUD_ALL ) ) return( FALSE );
@ -296,10 +280,7 @@ MUD_writeFile( fout, pMUD_head )
* MUD_write() - use for completely assembled groups/sections * MUD_write() - use for completely assembled groups/sections
*/ */
BOOL BOOL
MUD_write( fout, pMUD, io_opt ) MUD_write( FILE* fout, void* pMUD, MUD_IO_OPT io_opt )
FILE* fout;
void* pMUD;
MUD_IO_OPT io_opt;
{ {
BUF buf; BUF buf;
@ -328,12 +309,8 @@ MUD_write( fout, pMUD, io_opt )
* MUD_writeEnd() * MUD_writeEnd()
*/ */
BOOL BOOL
MUD_writeGrpStart( fout, pMUD_parentGrp, MUD_writeGrpStart( FILE* fout, MUD_SEC_GRP* pMUD_parentGrp,
pMUD_grp, numMems ) MUD_SEC_GRP* pMUD_grp, int numMems )
FILE* fout;
MUD_SEC_GRP* pMUD_parentGrp;
MUD_SEC_GRP* pMUD_grp;
int numMems;
{ {
pMUD_grp->pParent = pMUD_parentGrp; pMUD_grp->pParent = pMUD_parentGrp;
@ -352,9 +329,7 @@ MUD_writeGrpStart( fout, pMUD_parentGrp,
void void
addIndex( pMUD_grp, pMUD ) addIndex( MUD_SEC_GRP* pMUD_grp, void* pMUD )
MUD_SEC_GRP* pMUD_grp;
void* pMUD;
{ {
MUD_INDEX** ppMUD_index; MUD_INDEX** ppMUD_index;
@ -373,10 +348,7 @@ addIndex( pMUD_grp, pMUD )
* MUD_writeGrpMem() - use for writes of unassembled groups * MUD_writeGrpMem() - use for writes of unassembled groups
*/ */
BOOL BOOL
MUD_writeGrpMem( fout, pMUD_grp, pMUD ) MUD_writeGrpMem( FILE* fout, MUD_SEC_GRP* pMUD_grp, void* pMUD )
FILE* fout;
MUD_SEC_GRP* pMUD_grp;
void* pMUD;
{ {
((MUD_SEC*)pMUD)->core.size = MUD_getSize( pMUD ); ((MUD_SEC*)pMUD)->core.size = MUD_getSize( pMUD );
@ -401,9 +373,7 @@ MUD_writeGrpMem( fout, pMUD_grp, pMUD )
* MUD_writeGrpEnd() - use for writes of unassembled groups * MUD_writeGrpEnd() - use for writes of unassembled groups
*/ */
BOOL BOOL
MUD_writeGrpEnd( fout, pMUD_grp ) MUD_writeGrpEnd( FILE* fout, MUD_SEC_GRP* pMUD_grp )
FILE* fout;
MUD_SEC_GRP* pMUD_grp;
{ {
int pos; int pos;
@ -425,8 +395,7 @@ MUD_writeGrpEnd( fout, pMUD_grp )
void* void*
MUD_readFile( fin ) MUD_readFile( FILE* fin )
FILE* fin;
{ {
rewind( fin ); rewind( fin );
@ -435,9 +404,7 @@ MUD_readFile( fin )
void* void*
MUD_read( fin, io_opt ) MUD_read( FILE* fin, MUD_IO_OPT io_opt )
FILE* fin;
MUD_IO_OPT io_opt;
{ {
BUF buf; BUF buf;
MUD_SEC* pMUD_new; MUD_SEC* pMUD_new;
@ -459,7 +426,7 @@ MUD_read( fin, io_opt )
if( fseek( fin, pos, 0 ) == EOF ) return( NULL ); if( fseek( fin, pos, 0 ) == EOF ) return( NULL );
#ifdef DEBUG #ifdef DEBUG
printf( "MUD_read: got %d\n", size ); printf( "MUD_read: got %lu\n", (unsigned long)(size) );
printf( " pos = %d\n", pos ); printf( " pos = %d\n", pos );
printf( " reading the section ...\n" ); printf( " reading the section ...\n" );
#endif /* DEBUG */ #endif /* DEBUG */
@ -572,8 +539,7 @@ MUD_read( fin, io_opt )
*/ */
UINT32 UINT32
MUD_setSizes( pMUD ) MUD_setSizes( void* pMUD )
void* pMUD;
{ {
MUD_SEC* pMember; MUD_SEC* pMember;
MUD_INDEX* pGrpIndex; MUD_INDEX* pGrpIndex;
@ -624,8 +590,7 @@ MUD_setSizes( pMUD )
MUD_SEC* MUD_SEC*
MUD_peekCore( fin ) MUD_peekCore( FILE* fin )
FILE* fin;
{ {
static MUD_SEC mud; static MUD_SEC mud;
int pos; int pos;
@ -847,12 +812,8 @@ MUD_fseek( FILE* fio, ... )
MUD_SEC* MUD_SEC*
fseekNext( fio, pMUD_parent, fseekNext( FILE* fio, MUD_SEC_GRP* pMUD_parent,
secID, instanceID ) UINT32 secID, UINT32 instanceID )
FILE* fio;
MUD_SEC_GRP* pMUD_parent;
UINT32 secID;
UINT32 instanceID;
{ {
MUD_SEC* pMUD; MUD_SEC* pMUD;
MUD_INDEX* pMUD_index; MUD_INDEX* pMUD_index;
@ -920,8 +881,7 @@ fseekNext( fio, pMUD_parent,
int int
MUD_fseekFirst( fio ) MUD_fseekFirst( FILE* fio )
FILE* fio;
{ {
int size; int size;
@ -935,9 +895,7 @@ MUD_fseekFirst( fio )
void void
MUD_add( ppMUD_head, pMUD_new ) MUD_add( void** ppMUD_head, void* pMUD_new )
void** ppMUD_head;
void* pMUD_new;
{ {
MUD_SEC** ppMUD; MUD_SEC** ppMUD;
@ -952,8 +910,7 @@ MUD_add( ppMUD_head, pMUD_new )
int int
MUD_totSize( pMUD ) MUD_totSize( void* pMUD )
void* pMUD;
{ {
return( ( MUD_secID( pMUD ) == MUD_SEC_GRP_ID ) ? return( ( MUD_secID( pMUD ) == MUD_SEC_GRP_ID ) ?
MUD_size( pMUD ) + ((MUD_SEC_GRP*)pMUD)->memSize : MUD_size( pMUD ) + ((MUD_SEC_GRP*)pMUD)->memSize :
@ -962,14 +919,13 @@ MUD_totSize( pMUD )
void void
MUD_addToGroup( pMUD_grp, pMUD ) MUD_addToGroup( MUD_SEC_GRP* pMUD_grp, void* pMUD )
MUD_SEC_GRP* pMUD_grp;
void* pMUD;
{ {
MUD_SEC** ppMUD; MUD_SEC** ppMUD;
if( pMUD == NULL ) return; if( pMUD == NULL ) return;
/* possible addition: ((MUD_SEC*)pMUD)->core.pNext = NULL; */
((MUD_SEC*)pMUD)->core.size = MUD_getSize( pMUD ); ((MUD_SEC*)pMUD)->core.size = MUD_getSize( pMUD );
for( ppMUD = &pMUD_grp->pMem; for( ppMUD = &pMUD_grp->pMem;
@ -985,9 +941,7 @@ MUD_addToGroup( pMUD_grp, pMUD )
void void
MUD_assignCore( pMUD1, pMUD2 ) MUD_assignCore( MUD_SEC* pMUD1, MUD_SEC* pMUD2 )
MUD_SEC* pMUD1;
MUD_SEC* pMUD2;
{ {
bcopy( &pMUD1->core.size, &pMUD2->core.size, bcopy( &pMUD1->core.size, &pMUD2->core.size,
MUD_CORE_proc( MUD_GET_SIZE, NULL, NULL ) ); MUD_CORE_proc( MUD_GET_SIZE, NULL, NULL ) );
@ -995,10 +949,7 @@ MUD_assignCore( pMUD1, pMUD2 )
int int
MUD_CORE_proc( op, pBuf, pMUD ) MUD_CORE_proc( MUD_OPT op, BUF* pBuf, MUD_SEC* pMUD )
MUD_OPT op;
BUF* pBuf;
MUD_SEC* pMUD;
{ {
int size; int size;
@ -1019,12 +970,13 @@ MUD_CORE_proc( op, pBuf, pMUD )
case MUD_GET_SIZE: case MUD_GET_SIZE:
size = 3*sizeof(UINT32); size = 3*sizeof(UINT32);
#ifdef DEBUG #ifdef DEBUG
printf("MUD_CORE_proc: MUD_GET_SIZE returns size=%d\n",size); printf("MUD_CORE_proc: MUD_GET_SIZE returns size=%d\n",size);
#endif /* DEBUG */ #endif /* DEBUG */
return( size ); return( size );
case MUD_SHOW: case MUD_SHOW:
printf( " CORE: size=[%ld], secID=[0x%08lX], instanceID=[0x%08lX]\n", printf( " CORE: size=[%lu], secID=[0x%08lX], instanceID=[0x%08lX]\n",
pMUD->core.size, pMUD->core.secID, pMUD->core.instanceID ); (unsigned long)(pMUD->core.size), (unsigned long)(pMUD->core.secID),
(unsigned long)(pMUD->core.instanceID) );
break; break;
case MUD_HEADS: case MUD_HEADS:
break; break;
@ -1034,10 +986,7 @@ MUD_CORE_proc( op, pBuf, pMUD )
int int
MUD_INDEX_proc( op, pBuf, pMUD ) MUD_INDEX_proc( MUD_OPT op, BUF* pBuf, MUD_INDEX* pMUD )
MUD_OPT op;
BUF* pBuf;
MUD_INDEX* pMUD;
{ {
int size; int size;
@ -1065,8 +1014,9 @@ MUD_INDEX_proc( op, pBuf, pMUD )
size = 3*sizeof(UINT32); size = 3*sizeof(UINT32);
return( size ); return( size );
case MUD_SHOW: case MUD_SHOW:
printf( " INDEX: offset=[%ld], secID=[0x%08lX], instanceID=[0x%08lX]\n", printf( " INDEX: offset=[%lu], secID=[0x%08lX], instanceID=[0x%08lX]\n",
pMUD->offset, pMUD->secID, pMUD->instanceID ); (unsigned long)(pMUD->offset), (unsigned long)(pMUD->secID),
(unsigned long)(pMUD->instanceID) );
break; break;
case MUD_HEADS: case MUD_HEADS:
break; break;

View File

@ -1,19 +1,39 @@
#ifndef _MUD_H_ #ifndef _MUD_H_
#define _MUD_H_ #define _MUD_H_
#ifdef __cplusplus
extern "C" {
#endif
/* /*
* v1.2 * mud.h Declarations for MUD
* v1.3
*
* Copyright (C) 1994-2021 TRIUMF (Vancouver, Canada)
*
* Authors: T. Whidden, D. Arseneau, S. Daviel
*
* Released under the GNU LGPL - see http://www.gnu.org/licenses
*
* This program is free software; you can distribute it and/or modify it under
* the terms of the Lesser GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or any later version.
* Accordingly, this program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public License
* for more details.
* *
* revisions: * revisions:
* 01-mar-2000 DJA add UNKNOWN section, with no ID * 01-mar-2000 DJA add UNKNOWN section, with no ID
* 11-oct-2000 DJA add MUD_FMT_RAL_ID; MUD_setSizes * 11-oct-2000 DJA add MUD_FMT_RAL_ID; MUD_setSizes
* 22-Apr-2003 DJA add MUD_openReadWrite, MUD_openInOut * 22-Apr-2003 DJA add MUD_openReadWrite, MUD_openInOut
* 25-Nov-2009 DJA 64-bit linux
* 25-Jun-2017 DJA Allow use in C++ (ROOT); shared lib.
* 14-Aug-2019 DJA Use stdint.h, casts in printf
*/ */
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __CINT__
typedef char* caddr_t;
#endif /* __CINT __ */
/* /*
* FORMAT IDs - Must be unique! * FORMAT IDs - Must be unique!
* format of ID is: 0xLLFFSSSS * format of ID is: 0xLLFFSSSS
@ -94,31 +114,49 @@ extern "C" {
#include <stddef.h> #include <stddef.h>
#include <sys/types.h> #include <sys/types.h>
#ifndef NOSTDINT
/* If there is no stdint.h, define NOSTDINT, as with "make NOSTDINT=1" */
#include <stdint.h>
#endif
/* /*
* MUD types * MUD types
*/ */
#ifdef _STDINT_H
typedef int STATUS;
typedef int8_t INT8;
typedef uint8_t UINT8;
typedef int16_t INT16;
typedef uint16_t UINT16;
typedef int32_t INT32;
typedef uint32_t UINT32;
typedef float REAL32;
typedef double REAL64;
#else /*no stding.h */
typedef int STATUS; typedef int STATUS;
typedef char INT8; typedef char INT8;
typedef unsigned char UINT8; typedef unsigned char UINT8;
typedef short INT16; typedef short INT16;
typedef unsigned short UINT16; typedef unsigned short UINT16;
#if defined(__alpha) || defined(__x86_64__) || defined(__amd64) || defined(__ia64) #if defined(__alpha) || defined(__linux) || defined(__MACH__) || defined(__arm64)
typedef int INT32; typedef int INT32;
typedef unsigned int UINT32; typedef unsigned int UINT32;
#else #else
typedef long INT32; typedef long INT32;
typedef unsigned long UINT32; typedef unsigned long UINT32;
#endif /* defined(__alpha) || defined(__x86_64__) || defined(__amd64) || defined(__ia64) */ #endif /* __alpha || __linux || __MACH__*/
typedef float REAL32; typedef float REAL32;
typedef double REAL64; typedef double REAL64;
#if (defined(__alpha)&&defined(vms)) || defined(__BORLANDC__) || defined(__TURBOC__)
typedef char* caddr_t;
#endif
#endif /* _STDINT_HNOSTDINT */
typedef UINT32 TIME; typedef UINT32 TIME;
#ifndef BOOL_DEFINED #ifndef BOOL_DEFINED
#define BOOL_DEFINED #define BOOL_DEFINED
typedef UINT32 BOOL; typedef UINT32 BOOL;
#endif #endif
#if (defined(__alpha)&&defined(vms)) || defined(__BORLANDC__) || defined(__TURBOC__)
typedef char* caddr_t;
#endif
#ifndef FALSE #ifndef FALSE
#define FALSE 0 #define FALSE 0
@ -146,10 +184,10 @@ typedef char* caddr_t;
/* /*
* c_utils.h, Defines for C utilities * c_utils.h, Defines for C utilities
*/ */
#if defined(vms) || defined(__MSDOS__) || defined(_MSC_VER) #if defined(vms) || defined(__MSDOS__)
#define bcopy( b1, b2, len ) memcpy(b2,b1,len) #define bcopy( b1, b2, len ) memcpy(b2,b1,len)
#define bzero( b, len ) memset(b,(char)0,len) #define bzero( b, len ) memset(b,(char)0,len)
#endif /* vms || __MSDOS__ || _MSC_VER */ #endif /* vms || __MSDOS__ */
#ifndef _C_UTILS_H_ /* conflict with c_utils.h */ #ifndef _C_UTILS_H_ /* conflict with c_utils.h */
#define _max( a, b ) ( ( (a) > (b) ) ? (a) : (b) ) #define _max( a, b ) ( ( (a) > (b) ) ? (a) : (b) )
#define _min( a, b ) ( ( (a) < (b) ) ? (a) : (b) ) #define _min( a, b ) ( ( (a) < (b) ) ? (a) : (b) )
@ -157,11 +195,12 @@ typedef char* caddr_t;
#define _swap32( l ) (((UINT32)l>>16)+((UINT32)l<<16)) #define _swap32( l ) (((UINT32)l>>16)+((UINT32)l<<16))
#define _swap16( s ) (((UINT16)s>>8)+((UINT16)s<<8)) #define _swap16( s ) (((UINT16)s>>8)+((UINT16)s<<8))
#endif #endif
#define _free(objp) if(objp!=NULL){free(objp);objp=NULL;}
#define _roundUp( n, r ) ( (r) * (int)( ((n)+(r)-1) / (r) ) ) #define _free(objp) if((void*)(objp)!=(void*)NULL){free((void*)(objp));objp=NULL;}
#define _roundUp( n, r ) ( (r) * (int)( ((n)+(r)-1) / (r) ) )
#define zalloc( n ) memset((void*)malloc(n),0,n) #define zalloc( n ) memset((void*)malloc(n),0,n)
#if defined(vms) || (defined(mips)&&!defined(__sgi)) || ((defined(__MSDOS__) || defined(_MSC_VER))&&defined(__STDC__)) #if defined(vms) || (defined(mips)&&!defined(__sgi)) || (defined(__MSDOS__)&&defined(__STDC__))
#define strdup( s ) strcpy((char*)malloc(strlen(s)+1),s) #define strdup( s ) strcpy((char*)malloc(strlen(s)+1),s)
#endif /* vms || mips&&!sgi */ #endif /* vms || mips&&!sgi */
/*#endif */ /*#endif */
@ -388,8 +427,7 @@ typedef struct {
#define MUD_instanceID( pM ) (((MUD_SEC*)pM)->core.instanceID) #define MUD_instanceID( pM ) (((MUD_SEC*)pM)->core.instanceID)
#if defined(__MSDOS__) || defined(__i386__) || defined(__i586__) || defined(__i686__) || defined(vax) || defined(__alpha) || defined(__x86_64__) || defined(__amd64) \ #if defined(__MSDOS__) || defined(__i386__) || defined(__i586__) || defined(__i686__) || defined(vax) || defined(__alpha) || defined(__amd64) || defined(__arm64) || (defined(__mips)&&!defined(__sgi))
|| (defined(__mips)&&!defined(__sgi))
#define MUD_LITTLE_ENDIAN 1 #define MUD_LITTLE_ENDIAN 1
#else #else
#define MUD_BIG_ENDIAN 1 #define MUD_BIG_ENDIAN 1
@ -524,9 +562,9 @@ int MUD_SEC_GEN_HIST_unpack _ANSI_ARGS_(( int num , int inBinSize , void* inHist
int MUD_SEC_TRI_TI_RUN_DESC_proc _ANSI_ARGS_(( MUD_OPT op , BUF *pBuf , MUD_SEC_TRI_TI_RUN_DESC *pMUD )); int MUD_SEC_TRI_TI_RUN_DESC_proc _ANSI_ARGS_(( MUD_OPT op , BUF *pBuf , MUD_SEC_TRI_TI_RUN_DESC *pMUD ));
/* gmf_time.c */ /* gmf_time.c */
void GMF_MKTIME _ANSI_ARGS_(( time_t* out , INT32* input )); void GMF_MKTIME _ANSI_ARGS_(( TIME* out , INT32* input ));
void GMF_TIME _ANSI_ARGS_(( time_t* out )); void GMF_TIME _ANSI_ARGS_(( TIME* out ));
void GMF_LOCALTIME _ANSI_ARGS_(( time_t* in , INT32 *out )); void GMF_LOCALTIME _ANSI_ARGS_(( TIME* in , INT32 *out ));
/* mud_friendly.c */ /* mud_friendly.c */
int MUD_openRead _ANSI_ARGS_(( char* filename, UINT32* pType )); int MUD_openRead _ANSI_ARGS_(( char* filename, UINT32* pType ));

View File

@ -27,13 +27,8 @@
int int
MUD_SEC_proc( op, pBuf, pMUD ) MUD_SEC_proc( MUD_OPT op, BUF* pBuf, MUD_SEC* pMUD )
MUD_OPT op;
BUF* pBuf;
MUD_SEC* pMUD;
{ {
int size;
switch( op ) switch( op )
{ {
case MUD_FREE: case MUD_FREE:
@ -55,13 +50,8 @@ MUD_SEC_proc( op, pBuf, pMUD )
int int
MUD_SEC_EOF_proc( op, pBuf, pMUD ) MUD_SEC_EOF_proc( MUD_OPT op, BUF* pBuf, MUD_SEC_EOF* pMUD )
MUD_OPT op;
BUF* pBuf;
MUD_SEC_EOF* pMUD;
{ {
int size;
switch( op ) switch( op )
{ {
case MUD_FREE: case MUD_FREE:
@ -83,10 +73,7 @@ MUD_SEC_EOF_proc( op, pBuf, pMUD )
int int
MUD_SEC_FIXED_proc( op, pBuf, pMUD ) MUD_SEC_FIXED_proc( MUD_OPT op, BUF* pBuf, MUD_SEC_FIXED* pMUD )
MUD_OPT op;
BUF* pBuf;
MUD_SEC_FIXED* pMUD;
{ {
int size; int size;
@ -106,8 +93,8 @@ MUD_SEC_FIXED_proc( op, pBuf, pMUD )
size = 2*sizeof( UINT32 ); size = 2*sizeof( UINT32 );
return( size ); return( size );
case MUD_SHOW: case MUD_SHOW:
printf( " MUD_SEC_FIXED: fileSize=[%ld], formatID=[0x%08lX]\n", printf( " MUD_SEC_FIXED: fileSize=[%lu], formatID=[0x%08lX]\n",
pMUD->fileSize, pMUD->formatID ); (unsigned long)(pMUD->fileSize), (unsigned long)(pMUD->formatID) );
break; break;
case MUD_HEADS: case MUD_HEADS:
break; break;
@ -117,10 +104,7 @@ MUD_SEC_FIXED_proc( op, pBuf, pMUD )
int int
MUD_SEC_GRP_proc( op, pBuf, pMUD ) MUD_SEC_GRP_proc( MUD_OPT op, BUF* pBuf, MUD_SEC_GRP* pMUD )
MUD_OPT op;
BUF* pBuf;
MUD_SEC_GRP* pMUD;
{ {
int size; int size;
int i; int i;
@ -160,7 +144,7 @@ MUD_SEC_GRP_proc( op, pBuf, pMUD )
return( size ); return( size );
case MUD_SHOW: case MUD_SHOW:
printf( " MUD_SEC_GRP: num=[%ld], memSize=%ld\n", printf( " MUD_SEC_GRP: num=[%ld], memSize=%ld\n",
pMUD->num, pMUD->memSize ); (long int)(pMUD->num), (long int)(pMUD->memSize) );
for( pMUD_index = pMUD->pMemIndex; for( pMUD_index = pMUD->pMemIndex;
pMUD_index != NULL; pMUD_index != NULL;
pMUD_index = pMUD_index->pNext ) pMUD_index = pMUD_index->pNext )
@ -178,10 +162,7 @@ MUD_SEC_GRP_proc( op, pBuf, pMUD )
int int
MUD_SEC_CMT_proc( op, pBuf, pMUD ) MUD_SEC_CMT_proc( MUD_OPT op, BUF* pBuf, MUD_SEC_CMT* pMUD )
MUD_OPT op;
BUF* pBuf;
MUD_SEC_CMT* pMUD;
{ {
int size; int size;
char tempStr1[32]; char tempStr1[32];
@ -221,8 +202,9 @@ MUD_SEC_CMT_proc( op, pBuf, pMUD )
return( size ); return( size );
case MUD_SHOW: case MUD_SHOW:
printf( " MUD_SEC_CMT: \n" ); printf( " MUD_SEC_CMT: \n" );
printf( " number:[%ld], prevReply:[%ld], nextReply:[%ld]\n", printf( " number:[%lu], prevReply:[%lu], nextReply:[%lu]\n",
pMUD->ID, pMUD->prevReplyID, pMUD->nextReplyID ); (unsigned long)(pMUD->ID), (unsigned long)(pMUD->prevReplyID),
(unsigned long)(pMUD->nextReplyID) );
bintime = pMUD->time; bintime = pMUD->time;
strncpy( tempStr1, ctime( &bintime ), sizeof(tempStr1) ); strncpy( tempStr1, ctime( &bintime ), sizeof(tempStr1) );
tempStr1[strlen(tempStr1)-1] = '\0'; tempStr1[strlen(tempStr1)-1] = '\0';
@ -232,11 +214,11 @@ MUD_SEC_CMT_proc( op, pBuf, pMUD )
if( pMUD->comment ) printf( " comment:\"%s\"\n", pMUD->comment ); if( pMUD->comment ) printf( " comment:\"%s\"\n", pMUD->comment );
break; break;
case MUD_HEADS: case MUD_HEADS:
printf( "Comment number %ld. ", pMUD->ID ); printf( "Comment number %lu. ", (unsigned long)(pMUD->ID) );
if( pMUD->prevReplyID > 0 ) if( pMUD->prevReplyID > 0 )
printf(" Re: #%ld. ", pMUD->prevReplyID ); printf(" Re: #%lu. ", (unsigned long)(pMUD->prevReplyID) );
if( pMUD->nextReplyID > 0 ) if( pMUD->nextReplyID > 0 )
printf(" Next: #%ld.", pMUD->nextReplyID ); printf(" Next: #%lu.", (unsigned long)(pMUD->nextReplyID) );
printf( "\n" ); printf( "\n" );
bintime = pMUD->time; bintime = pMUD->time;
strncpy( tempStr1, ctime( &bintime ), sizeof(tempStr1) ); strncpy( tempStr1, ctime( &bintime ), sizeof(tempStr1) );
@ -251,13 +233,8 @@ MUD_SEC_CMT_proc( op, pBuf, pMUD )
int int
MUD_SEC_UNKNOWN_proc( op, pBuf, pMUD ) MUD_SEC_UNKNOWN_proc( MUD_OPT op, BUF* pBuf, MUD_SEC_UNKNOWN* pMUD )
MUD_OPT op;
BUF* pBuf;
MUD_SEC_UNKNOWN* pMUD;
{ {
int size;
switch( op ) switch( op )
{ {
case MUD_FREE: case MUD_FREE:

View File

@ -21,15 +21,11 @@
* license (unrestricted use). * license (unrestricted use).
*/ */
#include <stdio.h>
#include "mud.h" #include "mud.h"
void void
bdecode_2( b, p ) bdecode_2( void* b, void* p )
void* b;
void* p;
{ {
#ifdef MUD_BIG_ENDIAN #ifdef MUD_BIG_ENDIAN
UINT16 i; UINT16 i;
@ -42,9 +38,7 @@ bdecode_2( b, p )
} }
void void
bencode_2( b, p ) bencode_2( void* b, void* p )
void* b;
void* p;
{ {
#ifdef MUD_BIG_ENDIAN #ifdef MUD_BIG_ENDIAN
UINT16 i; UINT16 i;
@ -63,9 +57,7 @@ bencode_2( b, p )
} }
void void
bdecode_4( b, p ) bdecode_4( void* b,void* p )
void* b;
void* p;
{ {
#ifdef MUD_BIG_ENDIAN #ifdef MUD_BIG_ENDIAN
UINT32 i; UINT32 i;
@ -78,9 +70,7 @@ bdecode_4( b, p )
} }
void void
bencode_4( b, p ) bencode_4( void* b, void* p )
void* b;
void* p;
{ {
#ifdef MUD_BIG_ENDIAN #ifdef MUD_BIG_ENDIAN
UINT32 i; UINT32 i;
@ -93,9 +83,7 @@ bencode_4( b, p )
} }
void void
bdecode_8( b, p ) bdecode_8( void* b, void* p )
void* b;
void* p;
{ {
#ifdef MUD_BIG_ENDIAN #ifdef MUD_BIG_ENDIAN
UINT32 i[2], i2[2]; UINT32 i[2], i2[2];
@ -109,9 +97,7 @@ bdecode_8( b, p )
} }
void void
bencode_8( b, p ) bencode_8( void* b, void* p )
void* b;
void* p;
{ {
#ifdef MUD_BIG_ENDIAN #ifdef MUD_BIG_ENDIAN
UINT32 i[2], i2[2]; UINT32 i[2], i2[2];
@ -126,9 +112,7 @@ bencode_8( b, p )
void void
decode_str( pB, ps ) decode_str( BUF* pB, char** ps )
BUF* pB;
char** ps;
{ {
MUD_STR_LEN_TYPE len; MUD_STR_LEN_TYPE len;
@ -153,9 +137,7 @@ decode_str( pB, ps )
void void
encode_str( pB, ps ) encode_str( BUF* pB, char** ps )
BUF* pB;
char** ps;
{ {
MUD_STR_LEN_TYPE len; MUD_STR_LEN_TYPE len;
@ -223,16 +205,13 @@ static struct sgl_limits {
#endif /* !VMS */ #endif /* !VMS */
void void
bencode_float( buf, fp ) bencode_float( char* buf, float* fp )
char* buf;
float* fp;
{ {
#ifndef VMS #ifndef VMS
struct ieee_single is; struct ieee_single is;
struct vax_single vs; struct vax_single vs;
struct sgl_limits *lim; struct sgl_limits *lim;
int i; int i;
UINT16 sa[2], sb[2];
#endif /* !VMS */ #endif /* !VMS */
#ifdef VMS #ifdef VMS
@ -262,9 +241,7 @@ shipit:
} }
void void
encode_float( pBuf, fp ) encode_float( BUF* pBuf, float* fp )
BUF* pBuf;
float* fp;
{ {
bencode_float( &(pBuf->buf[pBuf->pos]), fp ); bencode_float( &(pBuf->buf[pBuf->pos]), fp );
pBuf->pos += 4; pBuf->pos += 4;
@ -272,9 +249,7 @@ encode_float( pBuf, fp )
} }
void void
bdecode_float( buf, fp ) bdecode_float( char* buf, float* fp )
char* buf;
float* fp;
{ {
#ifndef VMS #ifndef VMS
struct ieee_single *isp; struct ieee_single *isp;
@ -315,9 +290,7 @@ shipit:
} }
void void
decode_float( pBuf, fp ) decode_float( BUF* pBuf, float* fp )
BUF* pBuf;
float* fp;
{ {
bdecode_float( &(pBuf->buf[pBuf->pos]), fp ); bdecode_float( &(pBuf->buf[pBuf->pos]), fp );
pBuf->pos += 4; pBuf->pos += 4;
@ -392,16 +365,13 @@ static struct dbl_limits {
void void
bencode_double( buf, dp ) bencode_double( char* buf, double* dp )
char* buf;
double* dp;
{ {
#ifndef VMS #ifndef VMS
struct ieee_double id; struct ieee_double id;
struct vax_double vd; struct vax_double vd;
register struct dbl_limits *lim; register struct dbl_limits *lim;
int i; int i;
UINT16 sa[4], sb[4];
#endif /* !VMS */ #endif /* !VMS */
#ifdef VMS #ifdef VMS
@ -434,9 +404,7 @@ shipit:
} }
void void
encode_double( pBuf, fp ) encode_double( BUF* pBuf, double* fp )
BUF* pBuf;
double* fp;
{ {
bencode_double( &(pBuf->buf[pBuf->pos]), fp ); bencode_double( &(pBuf->buf[pBuf->pos]), fp );
pBuf->pos += 8; pBuf->pos += 8;
@ -444,16 +412,13 @@ encode_double( pBuf, fp )
} }
void void
bdecode_double( buf, dp ) bdecode_double( char* buf, double* dp )
char* buf;
double* dp;
{ {
#ifndef VMS #ifndef VMS
struct ieee_double id, *idp; struct ieee_double *idp;
struct vax_double vd; struct vax_double vd;
register struct dbl_limits *lim; register struct dbl_limits *lim;
int i; int i;
UINT16 sa[4], sb[4];
#endif /* !VMS */ #endif /* !VMS */
#ifdef VMS #ifdef VMS
@ -486,9 +451,7 @@ shipit:
} }
void void
decode_double( pBuf, fp ) decode_double( BUF* pBuf, double* fp )
BUF* pBuf;
double* fp;
{ {
bdecode_double( &(pBuf->buf[pBuf->pos]), fp ); bdecode_double( &(pBuf->buf[pBuf->pos]), fp );
pBuf->pos += 8; pBuf->pos += 8;

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@
#include <math.h> #include <math.h>
#include "mud.h" #include "mud.h"
/* #define DEBUG 1 /* (un)comment for debug */ /* #define DEBUG 1 */ /* (un)comment for debug */
#define PACK_OP 1 #define PACK_OP 1
#define UNPACK_OP 2 #define UNPACK_OP 2
static int pack_op; static int pack_op;
@ -42,15 +42,11 @@ static void next_few_bins _ANSI_ARGS_(( int num_tot, int inBinSize, void* pHistD
int int
MUD_SEC_GEN_RUN_DESC_proc( op, pBuf, pMUD ) MUD_SEC_GEN_RUN_DESC_proc( MUD_OPT op, BUF* pBuf, MUD_SEC_GEN_RUN_DESC* pMUD )
MUD_OPT op;
BUF* pBuf;
MUD_SEC_GEN_RUN_DESC* pMUD;
{ {
int size; int size;
char tempStr1[32]; char tempStr1[32];
char tempStr2[32]; char tempStr2[32];
int imin,isec;
time_t bintime; time_t bintime;
switch( op ) switch( op )
@ -124,16 +120,16 @@ MUD_SEC_GEN_RUN_DESC_proc( op, pBuf, pMUD )
return( size ); return( size );
case MUD_SHOW: case MUD_SHOW:
printf( " MUD_SEC_GEN_RUN_DESC: expt:[%ld], run:[%ld]\n", printf( " MUD_SEC_GEN_RUN_DESC: expt:[%ld], run:[%ld]\n",
pMUD->exptNumber, pMUD->runNumber ); (long)(pMUD->exptNumber), (long)(pMUD->runNumber) );
bintime = pMUD->timeBegin; bintime = pMUD->timeBegin;
strncpy( tempStr1, ctime( &bintime ), sizeof(tempStr1) ); strncpy( tempStr1, ctime( &bintime ), sizeof(tempStr1) );
tempStr1[strlen(tempStr1)-1] = '\0'; tempStr1[strlen(tempStr1)-1] = '\0';
bintime = pMUD->timeEnd; bintime = pMUD->timeEnd;
strncpy( tempStr2, ctime( &bintime ), sizeof(tempStr2) ); strncpy( tempStr2, ctime( &bintime ), sizeof(tempStr2) );
tempStr2[strlen(tempStr2)-1] = '\0'; tempStr2[strlen(tempStr2)-1] = '\0';
printf( " timeBegin:[%s] [%ld]\n", tempStr1, pMUD->timeBegin ); printf( " timeBegin:[%s] [%lu]\n", tempStr1, (unsigned long)(pMUD->timeBegin) );
printf( " timeEnd:[%s] [%ld]\n", tempStr2, pMUD->timeEnd ); printf( " timeEnd:[%s] [%lu]\n", tempStr2, (unsigned long)(pMUD->timeEnd) );
printf( " elapsedSec:[%ld]\n", pMUD->elapsedSec ); printf( " elapsedSec:[%ld]\n", (long)(pMUD->elapsedSec) );
if( pMUD->title ) printf( " title:\"%s\"\n", pMUD->title ); if( pMUD->title ) printf( " title:\"%s\"\n", pMUD->title );
if( pMUD->lab ) printf( " lab:\"%s\"\n", pMUD->lab ); if( pMUD->lab ) printf( " lab:\"%s\"\n", pMUD->lab );
if( pMUD->area ) printf( " area:\"%s\"\n", pMUD->area ); if( pMUD->area ) printf( " area:\"%s\"\n", pMUD->area );
@ -152,8 +148,8 @@ MUD_SEC_GEN_RUN_DESC_proc( op, pBuf, pMUD )
printf( " field:\"%s\"\n", pMUD->field ); printf( " field:\"%s\"\n", pMUD->field );
break; break;
case MUD_HEADS: case MUD_HEADS:
printf( "Run number: %ld\n", pMUD->runNumber ); printf( "Run number: %ld\n", (long)(pMUD->runNumber) );
printf( " exper num: %ld\n", pMUD->exptNumber ); printf( " exper num: %ld\n", (long)(pMUD->exptNumber) );
if( pMUD->experimenter ) if( pMUD->experimenter )
printf( " operator: %s\n", pMUD->experimenter ); printf( " operator: %s\n", pMUD->experimenter );
if( pMUD->method ) printf( " method: %s\n", pMUD->method ); if( pMUD->method ) printf( " method: %s\n", pMUD->method );
@ -165,9 +161,9 @@ MUD_SEC_GEN_RUN_DESC_proc( op, pBuf, pMUD )
tempStr2[strlen(tempStr2)-1] = '\0'; tempStr2[strlen(tempStr2)-1] = '\0';
printf( " began: %s\n ended: %s\n", printf( " began: %s\n ended: %s\n",
tempStr1, tempStr2 ); tempStr1, tempStr2 );
printf( " elapsed: %ld:%.2d:%.2d (%ld seconds)\n", printf( " elapsed: %ld:%.2d:%.2d (%lu seconds)\n",
(pMUD->elapsedSec/3600), ((pMUD->elapsedSec%3600)/60), (pMUD->elapsedSec%60), (long)(pMUD->elapsedSec/3600), ((pMUD->elapsedSec%3600)/60), (pMUD->elapsedSec%60),
pMUD->elapsedSec ); (unsigned long)(pMUD->elapsedSec) );
if( pMUD->title ) if( pMUD->title )
{ {
if( strlen( pMUD->title ) > 63 && strlen( pMUD->title ) < 80 ) if( strlen( pMUD->title ) > 63 && strlen( pMUD->title ) < 80 )
@ -197,10 +193,7 @@ MUD_SEC_GEN_RUN_DESC_proc( op, pBuf, pMUD )
int int
MUD_SEC_GEN_HIST_HDR_proc( op, pBuf, pMUD ) MUD_SEC_GEN_HIST_HDR_proc( MUD_OPT op, BUF* pBuf, MUD_SEC_GEN_HIST_HDR* pMUD )
MUD_OPT op;
BUF* pBuf;
MUD_SEC_GEN_HIST_HDR* pMUD;
{ {
int size; int size;
UINT32 fsBin; UINT32 fsBin;
@ -246,28 +239,28 @@ MUD_SEC_GEN_HIST_HDR_proc( op, pBuf, pMUD )
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->title ); size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->title );
return( size ); return( size );
case MUD_SHOW: case MUD_SHOW:
printf( " MUD_SEC_GEN_HIST_HDR: histType:[0x%08lX]\n", pMUD->histType ); printf( " MUD_SEC_GEN_HIST_HDR: histType:[0x%08lX]\n", (unsigned long)(pMUD->histType) );
printf( " nBytes:[%ld], nBins:[%ld], nEvents:[%ld]\n", printf( " nBytes:[%ld], nBins:[%ld], nEvents:[%lu]\n",
pMUD->nBytes, pMUD->nBins, pMUD->nEvents ); (long)(pMUD->nBytes), (long)(pMUD->nBins), (unsigned long)(pMUD->nEvents) );
printf( " bytesPerBin:[%ld], fsPerBin:[%ld], t0_ps:[%ld], t0_bin:[%ld]\n", printf( " bytesPerBin:[%ld], fsPerBin:[%ld], t0_ps:[%ld], t0_bin:[%ld]\n",
pMUD->bytesPerBin, pMUD->fsPerBin, pMUD->t0_ps, pMUD->t0_bin ); (long)(pMUD->bytesPerBin), (long)(pMUD->fsPerBin), (long)(pMUD->t0_ps), (long)(pMUD->t0_bin) );
printf( " goodBin1:[%ld], goodBin2:[%ld], bkgd1:[%ld], bkgd2:[%ld]\n", printf( " goodBin1:[%ld], goodBin2:[%ld], bkgd1:[%ld], bkgd2:[%ld]\n",
pMUD->goodBin1, pMUD->goodBin2, pMUD->bkgd1, pMUD->bkgd2 ); (long)(pMUD->goodBin1), (long)(pMUD->goodBin2), (long)(pMUD->bkgd1), (long)(pMUD->bkgd2) );
if( pMUD->title ) printf( " title:\"%s\"\n", pMUD->title ); if( pMUD->title ) printf( " title:\"%s\"\n", pMUD->title );
break; break;
case MUD_HEADS: case MUD_HEADS:
if( pMUD->title ) printf( "Hist title: %s\n", pMUD->title ); if( pMUD->title ) printf( "Hist title: %s\n", pMUD->title );
printf( " nBins: %ld, nEvents: %ld, ", printf( " nBins: %ld, nEvents: %lu, ",
pMUD->nBins, pMUD->nEvents ); (long)(pMUD->nBins), (unsigned long)(pMUD->nEvents) );
fsBin = pMUD->fsPerBin; fsBin = pMUD->fsPerBin;
if( fsBin < 16 ) if( fsBin < 16 )
{ {
nsBin = 0.078125 * pow( (double)2.0, (double)fsBin ); nsBin = 0.078125 * pow( (double)2.0, (double)fsBin );
printf( "ns_per_Bin: %.lf\n", nsBin ); printf( "ns_per_Bin: %.6lf\n", nsBin );
} }
else if( fsBin < 29 ) else if( fsBin < 29 )
{ {
nsBin = 0.048828125 * pow( (double)2.0, (double)fsBin - 16 ); nsBin = 0.048828125 * pow( (double)2.0, (double)(fsBin - 16) );
printf( "ns_per_Bin: %.9lf\n", nsBin ); printf( "ns_per_Bin: %.9lf\n", nsBin );
} }
else else
@ -277,9 +270,9 @@ MUD_SEC_GEN_HIST_HDR_proc( op, pBuf, pMUD )
} }
printf( " t0_ps: %ld, t0_bin: %ld\n", printf( " t0_ps: %ld, t0_bin: %ld\n",
pMUD->t0_ps, pMUD->t0_bin ); (long)(pMUD->t0_ps), (long)(pMUD->t0_bin) );
printf( " goodBin1: %ld, goodBin2: %ld, bkgd1: %ld, bkgd2: %ld\n", printf( " goodBin1: %ld, goodBin2: %ld, bkgd1: %ld, bkgd2: %ld\n",
pMUD->goodBin1, pMUD->goodBin2, pMUD->bkgd1, pMUD->bkgd2 ); (long)(pMUD->goodBin1), (long)(pMUD->goodBin2), (long)(pMUD->bkgd1), (long)(pMUD->bkgd2) );
break; break;
} }
return( 1 ); return( 1 );
@ -287,10 +280,7 @@ MUD_SEC_GEN_HIST_HDR_proc( op, pBuf, pMUD )
int int
MUD_SEC_GEN_HIST_DAT_proc( op, pBuf, pMUD ) MUD_SEC_GEN_HIST_DAT_proc( MUD_OPT op, BUF* pBuf, MUD_SEC_GEN_HIST_DAT* pMUD )
MUD_OPT op;
BUF* pBuf;
MUD_SEC_GEN_HIST_DAT* pMUD;
{ {
int size; int size;
@ -313,7 +303,7 @@ MUD_SEC_GEN_HIST_DAT_proc( op, pBuf, pMUD )
size += pMUD->nBytes; size += pMUD->nBytes;
return( size ); return( size );
case MUD_SHOW: case MUD_SHOW:
printf( " MUD_SEC_GEN_HIST_DAT: nBytes:[%ld]\n", pMUD->nBytes ); printf( " MUD_SEC_GEN_HIST_DAT: nBytes:[%ld]\n", (long)(pMUD->nBytes) );
break; break;
case MUD_HEADS: case MUD_HEADS:
break; break;
@ -323,10 +313,7 @@ MUD_SEC_GEN_HIST_DAT_proc( op, pBuf, pMUD )
int int
MUD_SEC_GEN_SCALER_proc( op, pBuf, pMUD ) MUD_SEC_GEN_SCALER_proc( MUD_OPT op, BUF* pBuf, MUD_SEC_GEN_SCALER* pMUD )
MUD_OPT op;
BUF* pBuf;
MUD_SEC_GEN_SCALER* pMUD;
{ {
int size; int size;
@ -350,15 +337,16 @@ MUD_SEC_GEN_SCALER_proc( op, pBuf, pMUD )
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->label ); size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->label );
return( size ); return( size );
case MUD_SHOW: case MUD_SHOW:
printf( " MUD_SEC_GEN_SCALER: counts[1]:[%ld], counts[0]:[%ld]\n", printf( " MUD_SEC_GEN_SCALER: counts[1]:[%lu], counts[0]:[%lu]\n",
pMUD->counts[1], pMUD->counts[0] ); (unsigned long)(pMUD->counts[1]), (unsigned long)(pMUD->counts[0]) );
if( pMUD->label ) printf( " label:\"%s\"\n", pMUD->label ); if( pMUD->label ) printf( " label:\"%s\"\n", pMUD->label );
break; break;
case MUD_HEADS: case MUD_HEADS:
printf( " Scaler " ); printf( " Scaler " );
if( pMUD->label ) printf( "%8s", pMUD->label ); if( pMUD->label ) printf( "%8s", pMUD->label );
else printf( "??? " ); else printf( "??? " );
printf( " total: %11ld, recent: %ld\n", pMUD->counts[0], pMUD->counts[1] ); printf( " total: %11lu, recent: %lu\n",
(unsigned long)(pMUD->counts[0]), (unsigned long)(pMUD->counts[1]) );
break; break;
} }
return( 1 ); return( 1 );
@ -366,10 +354,7 @@ MUD_SEC_GEN_SCALER_proc( op, pBuf, pMUD )
int int
MUD_SEC_GEN_IND_VAR_proc( op, pBuf, pMUD ) MUD_SEC_GEN_IND_VAR_proc( MUD_OPT op, BUF* pBuf, MUD_SEC_GEN_IND_VAR* pMUD )
MUD_OPT op;
BUF* pBuf;
MUD_SEC_GEN_IND_VAR* pMUD;
{ {
int size; int size;
@ -431,10 +416,7 @@ MUD_SEC_GEN_IND_VAR_proc( op, pBuf, pMUD )
int int
MUD_SEC_GEN_ARRAY_proc( op, pBuf, pMUD ) MUD_SEC_GEN_ARRAY_proc( MUD_OPT op, BUF* pBuf, MUD_SEC_GEN_ARRAY* pMUD )
MUD_OPT op;
BUF* pBuf;
MUD_SEC_GEN_ARRAY* pMUD;
{ {
int size; int size;
int i; int i;
@ -538,8 +520,8 @@ MUD_SEC_GEN_ARRAY_proc( op, pBuf, pMUD )
case MUD_SHOW: case MUD_SHOW:
printf( " MUD_SEC_GEN_ARRAY: \n" ); printf( " MUD_SEC_GEN_ARRAY: \n" );
printf( " num:[%ld], elemSize:[%ld], type:[%ld], hasTime:[%ld], nBytes:[%ld]\n", printf( " num:[%ld], elemSize:[%ld], type:[%ld], hasTime:[%ld], nBytes:[%ld]\n",
pMUD->num, pMUD->elemSize, pMUD->type, pMUD->hasTime, (long)(pMUD->num), (long)(pMUD->elemSize), (long)(pMUD->type), (long)(pMUD->hasTime),
pMUD->nBytes ); (long)(pMUD->nBytes) );
break; break;
case MUD_HEADS: case MUD_HEADS:
break; break;
@ -549,42 +531,27 @@ MUD_SEC_GEN_ARRAY_proc( op, pBuf, pMUD )
int int
MUD_SEC_GEN_HIST_pack( num, inBinSize, inHist, outBinSize, outHist ) MUD_SEC_GEN_HIST_pack( int num, int inBinSize, void* inHist, int outBinSize, void* outHist )
int num;
int inBinSize;
void* inHist;
int outBinSize;
void* outHist;
{ {
pack_op = PACK_OP; pack_op = PACK_OP;
return( MUD_SEC_GEN_HIST_dopack( num, inBinSize, inHist, outBinSize, outHist ) ); return( MUD_SEC_GEN_HIST_dopack( num, inBinSize, inHist, outBinSize, outHist ) );
} }
int int
MUD_SEC_GEN_HIST_unpack( num, inBinSize, inHist, outBinSize, outHist ) MUD_SEC_GEN_HIST_unpack( int num, int inBinSize, void* inHist, int outBinSize, void* outHist )
int num;
int inBinSize;
void* inHist;
int outBinSize;
void* outHist;
{ {
pack_op = UNPACK_OP; pack_op = UNPACK_OP;
return( MUD_SEC_GEN_HIST_dopack( num, inBinSize, inHist, outBinSize, outHist ) ); return( MUD_SEC_GEN_HIST_dopack( num, inBinSize, inHist, outBinSize, outHist ) );
} }
static int static int
MUD_SEC_GEN_HIST_dopack( num, inBinSize, inHist, outBinSize, outHist ) MUD_SEC_GEN_HIST_dopack( int num, int inBinSize, void* inHist, int outBinSize, void* outHist )
int num;
int inBinSize;
void* inHist;
int outBinSize;
void* outHist;
{ {
int i; int i;
int outLen = 0; int outLen = 0;
MUD_VAR_BIN_LEN_TYPE num_temp; MUD_VAR_BIN_LEN_TYPE num_temp;
int bin, inLoc, outLoc; int bin, inLoc, outLoc;
int inLen_temp, outLen_temp; int outLen_temp;
MUD_VAR_BIN_SIZ_TYPE outBinSize_now, outBinSize_next; MUD_VAR_BIN_SIZ_TYPE outBinSize_now, outBinSize_next;
MUD_VAR_BIN_SIZ_TYPE inBinSize_temp; MUD_VAR_BIN_SIZ_TYPE inBinSize_temp;
UINT8 c, *pc; UINT8 c, *pc;
@ -935,8 +902,7 @@ MUD_SEC_GEN_HIST_dopack( num, inBinSize, inHist, outBinSize, outHist )
static int static int
n_bytes_needed( val ) n_bytes_needed( UINT32 val )
UINT32 val;
{ {
if( val & 0xFFFF0000 ) return( 4 ); if( val & 0xFFFF0000 ) return( 4 );
else if( val & 0x0000FF00 ) return( 2 ); else if( val & 0x0000FF00 ) return( 2 );
@ -946,10 +912,7 @@ n_bytes_needed( val )
static UINT32 static UINT32
varBinArray( pHistData, binSize, index ) varBinArray( void* pHistData, int binSize, int index )
void* pHistData;
int binSize;
int index;
{ {
UINT8 c; UINT8 c;
UINT16 s; UINT16 s;
@ -991,17 +954,8 @@ varBinArray( pHistData, binSize, index )
static void static void
next_few_bins( num_tot, inBinSize, next_few_bins( int num_tot, int inBinSize, void* pHistData, int outBinSize_now,
pHistData, MUD_VAR_BIN_LEN_TYPE* pNum_next, MUD_VAR_BIN_SIZ_TYPE* pOutBinSize_next )
outBinSize_now,
pNum_next,
pOutBinSize_next )
int num_tot;
int inBinSize;
void* pHistData;
int outBinSize_now;
MUD_VAR_BIN_LEN_TYPE* pNum_next;
MUD_VAR_BIN_SIZ_TYPE* pOutBinSize_next;
{ {
int val; int val;
MUD_VAR_BIN_LEN_TYPE num_next; MUD_VAR_BIN_LEN_TYPE num_next;

View File

@ -27,13 +27,11 @@
* v1.2a 01-Mar-2000 DA Add handling of unidentified sections (don't quit) * v1.2a 01-Mar-2000 DA Add handling of unidentified sections (don't quit)
*/ */
#include "mud.h" #include "mud.h"
MUD_SEC* MUD_SEC*
MUD_new( secID, instanceID ) MUD_new( UINT32 secID, UINT32 instanceID )
UINT32 secID;
UINT32 instanceID;
{ {
MUD_SEC* pMUD_new; MUD_SEC* pMUD_new;
MUD_PROC proc; MUD_PROC proc;
@ -43,78 +41,78 @@ MUD_new( secID, instanceID )
{ {
case MUD_SEC_ID: case MUD_SEC_ID:
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC ) ); pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC ) );
proc = MUD_SEC_proc; proc = (MUD_PROC)MUD_SEC_proc;
sizeOf = sizeof( MUD_SEC ); sizeOf = sizeof( MUD_SEC );
break; break;
case MUD_SEC_FIXED_ID: case MUD_SEC_FIXED_ID:
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_FIXED ) ); pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_FIXED ) );
proc = MUD_SEC_FIXED_proc; proc = (MUD_PROC)MUD_SEC_FIXED_proc;
sizeOf = sizeof( MUD_SEC_FIXED ); sizeOf = sizeof( MUD_SEC_FIXED );
break; break;
case MUD_SEC_GRP_ID: case MUD_SEC_GRP_ID:
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GRP ) ); pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GRP ) );
proc = MUD_SEC_GRP_proc; proc = (MUD_PROC)MUD_SEC_GRP_proc;
sizeOf = sizeof( MUD_SEC_GRP ); sizeOf = sizeof( MUD_SEC_GRP );
break; break;
case MUD_SEC_EOF_ID: case MUD_SEC_EOF_ID:
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_EOF ) ); pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_EOF ) );
proc = MUD_SEC_EOF_proc; proc = (MUD_PROC)MUD_SEC_EOF_proc;
sizeOf = sizeof( MUD_SEC_EOF ); sizeOf = sizeof( MUD_SEC_EOF );
break; break;
case MUD_SEC_CMT_ID: case MUD_SEC_CMT_ID:
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_CMT ) ); pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_CMT ) );
proc = MUD_SEC_CMT_proc; proc = (MUD_PROC)MUD_SEC_CMT_proc;
sizeOf = sizeof( MUD_SEC_CMT ); sizeOf = sizeof( MUD_SEC_CMT );
break; break;
case MUD_SEC_GEN_RUN_DESC_ID: case MUD_SEC_GEN_RUN_DESC_ID:
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GEN_RUN_DESC ) ); pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GEN_RUN_DESC ) );
proc = MUD_SEC_GEN_RUN_DESC_proc; proc = (MUD_PROC)MUD_SEC_GEN_RUN_DESC_proc;
sizeOf = sizeof( MUD_SEC_GEN_RUN_DESC ); sizeOf = sizeof( MUD_SEC_GEN_RUN_DESC );
break; break;
case MUD_SEC_GEN_HIST_HDR_ID: case MUD_SEC_GEN_HIST_HDR_ID:
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GEN_HIST_HDR ) ); pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GEN_HIST_HDR ) );
proc = MUD_SEC_GEN_HIST_HDR_proc; proc = (MUD_PROC)MUD_SEC_GEN_HIST_HDR_proc;
sizeOf = sizeof( MUD_SEC_GEN_HIST_HDR ); sizeOf = sizeof( MUD_SEC_GEN_HIST_HDR );
break; break;
case MUD_SEC_GEN_HIST_DAT_ID: case MUD_SEC_GEN_HIST_DAT_ID:
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GEN_HIST_DAT ) ); pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GEN_HIST_DAT ) );
proc = MUD_SEC_GEN_HIST_DAT_proc; proc = (MUD_PROC)MUD_SEC_GEN_HIST_DAT_proc;
sizeOf = sizeof( MUD_SEC_GEN_HIST_DAT ); sizeOf = sizeof( MUD_SEC_GEN_HIST_DAT );
break; break;
case MUD_SEC_GEN_SCALER_ID: case MUD_SEC_GEN_SCALER_ID:
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GEN_SCALER ) ); pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GEN_SCALER ) );
proc = MUD_SEC_GEN_SCALER_proc; proc = (MUD_PROC)MUD_SEC_GEN_SCALER_proc;
sizeOf = sizeof( MUD_SEC_GEN_SCALER ); sizeOf = sizeof( MUD_SEC_GEN_SCALER );
break; break;
case MUD_SEC_GEN_IND_VAR_ID: case MUD_SEC_GEN_IND_VAR_ID:
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GEN_IND_VAR ) ); pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GEN_IND_VAR ) );
proc = MUD_SEC_GEN_IND_VAR_proc; proc = (MUD_PROC)MUD_SEC_GEN_IND_VAR_proc;
sizeOf = sizeof( MUD_SEC_GEN_IND_VAR ); sizeOf = sizeof( MUD_SEC_GEN_IND_VAR );
break; break;
case MUD_SEC_GEN_ARRAY_ID: case MUD_SEC_GEN_ARRAY_ID:
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GEN_ARRAY ) ); pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_GEN_ARRAY ) );
proc = MUD_SEC_GEN_ARRAY_proc; proc = (MUD_PROC)MUD_SEC_GEN_ARRAY_proc;
sizeOf = sizeof( MUD_SEC_GEN_ARRAY ); sizeOf = sizeof( MUD_SEC_GEN_ARRAY );
break; break;
case MUD_SEC_TRI_TI_RUN_DESC_ID: case MUD_SEC_TRI_TI_RUN_DESC_ID:
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_TRI_TI_RUN_DESC ) ); pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_TRI_TI_RUN_DESC ) );
proc = MUD_SEC_TRI_TI_RUN_DESC_proc; proc = (MUD_PROC)MUD_SEC_TRI_TI_RUN_DESC_proc;
sizeOf = sizeof( MUD_SEC_TRI_TI_RUN_DESC ); sizeOf = sizeof( MUD_SEC_TRI_TI_RUN_DESC );
break; break;
/* /*
case MUD_SEC_CAMP_NUM_ID: case MUD_SEC_CAMP_NUM_ID:
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_CAMP_NUM ) ); pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_CAMP_NUM ) );
proc = MUD_SEC_CAMP_NUM_proc; proc = (MUD_PROC)MUD_SEC_CAMP_NUM_proc;
sizeOf = sizeof( MUD_SEC_CAMP_NUM ); sizeOf = sizeof( MUD_SEC_CAMP_NUM );
break; break;
case MUD_SEC_CAMP_STR_ID: case MUD_SEC_CAMP_STR_ID:
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_CAMP_STR ) ); pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_CAMP_STR ) );
proc = MUD_SEC_CAMP_STR_proc; proc = (MUD_PROC)MUD_SEC_CAMP_STR_proc;
sizeOf = sizeof( MUD_SEC_CAMP_STR ); sizeOf = sizeof( MUD_SEC_CAMP_STR );
break; break;
case MUD_SEC_CAMP_SEL_ID: case MUD_SEC_CAMP_SEL_ID:
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_CAMP_SEL ) ); pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_CAMP_SEL ) );
proc = MUD_SEC_CAMP_SEL_proc; proc = (MUD_PROC)MUD_SEC_CAMP_SEL_proc;
sizeOf = sizeof( MUD_SEC_CAMP_SEL ); sizeOf = sizeof( MUD_SEC_CAMP_SEL );
break; break;
*/ */
@ -122,7 +120,7 @@ MUD_new( secID, instanceID )
/* add action for unknown */ /* add action for unknown */
default: default:
pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_UNKNOWN ) ); pMUD_new = (MUD_SEC*)zalloc( sizeof( MUD_SEC_UNKNOWN ) );
proc = MUD_SEC_UNKNOWN_proc; proc = (MUD_PROC)MUD_SEC_UNKNOWN_proc;
sizeOf = sizeof( MUD_SEC_UNKNOWN ); sizeOf = sizeof( MUD_SEC_UNKNOWN );
break; break;
@ -138,4 +136,3 @@ MUD_new( secID, instanceID )
return( pMUD_new ); return( pMUD_new );
} }

View File

@ -27,10 +27,7 @@
int int
MUD_SEC_TRI_TI_RUN_DESC_proc( op, pBuf, pMUD ) MUD_SEC_TRI_TI_RUN_DESC_proc( MUD_OPT op, BUF* pBuf, MUD_SEC_TRI_TI_RUN_DESC* pMUD )
MUD_OPT op;
BUF* pBuf;
MUD_SEC_TRI_TI_RUN_DESC* pMUD;
{ {
int size; int size;
char tempStr1[32]; char tempStr1[32];
@ -115,8 +112,8 @@ MUD_SEC_TRI_TI_RUN_DESC_proc( op, pBuf, pMUD )
size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->comment3 ); size += sizeof( MUD_STR_LEN_TYPE ) + _strlen( pMUD->comment3 );
return( size ); return( size );
case MUD_SHOW: case MUD_SHOW:
printf( " MUD_SEC_TRI_TI_RUN_DESC: expt:[%ld], run:[%ld]\n", printf( " MUD_SEC_TRI_TI_RUN_DESC: expt:[%lu], run:[%lu]\n",
pMUD->exptNumber, pMUD->runNumber ); (unsigned long)(pMUD->exptNumber), (unsigned long)(pMUD->runNumber) );
bintime = pMUD->timeBegin; bintime = pMUD->timeBegin;
strncpy( tempStr1, ctime( &bintime ), sizeof(tempStr1) ); strncpy( tempStr1, ctime( &bintime ), sizeof(tempStr1) );
tempStr1[strlen(tempStr1)-1] = '\0'; tempStr1[strlen(tempStr1)-1] = '\0';
@ -125,7 +122,7 @@ MUD_SEC_TRI_TI_RUN_DESC_proc( op, pBuf, pMUD )
tempStr2[strlen(tempStr2)-1] = '\0'; tempStr2[strlen(tempStr2)-1] = '\0';
printf( " timeBegin:[%s]\n", tempStr1 ); printf( " timeBegin:[%s]\n", tempStr1 );
printf( " timeEnd:[%s]\n", tempStr2 ); printf( " timeEnd:[%s]\n", tempStr2 );
printf( " elapsedSec:[%ld]\n", pMUD->elapsedSec ); printf( " elapsedSec:[%lu]\n", (unsigned long)(pMUD->elapsedSec) );
if( pMUD->title ) printf( " title:\"%s\"\n", pMUD->title ); if( pMUD->title ) printf( " title:\"%s\"\n", pMUD->title );
if( pMUD->lab ) printf( " lab:\"%s\"\n", pMUD->lab ); if( pMUD->lab ) printf( " lab:\"%s\"\n", pMUD->lab );
if( pMUD->area ) printf( " area:\"%s\"\n", pMUD->area ); if( pMUD->area ) printf( " area:\"%s\"\n", pMUD->area );
@ -148,8 +145,8 @@ MUD_SEC_TRI_TI_RUN_DESC_proc( op, pBuf, pMUD )
printf( " comment3:\"%s\"\n", pMUD->comment3 ); printf( " comment3:\"%s\"\n", pMUD->comment3 );
break; break;
case MUD_HEADS: case MUD_HEADS:
printf( "Run number: %ld\n", pMUD->runNumber ); printf( "Run number: %lu\n", (unsigned long)(pMUD->runNumber) );
printf( " exper num: %ld\n", pMUD->exptNumber ); printf( " exper num: %lu\n", (unsigned long)(pMUD->exptNumber) );
if( pMUD->experimenter ) if( pMUD->experimenter )
printf( " operator: %s\n", pMUD->experimenter ); printf( " operator: %s\n", pMUD->experimenter );
if( pMUD->method ) if( pMUD->method )
@ -162,9 +159,9 @@ MUD_SEC_TRI_TI_RUN_DESC_proc( op, pBuf, pMUD )
tempStr2[strlen(tempStr2)-1] = '\0'; tempStr2[strlen(tempStr2)-1] = '\0';
printf( " began: %s\n ended: %s\n", printf( " began: %s\n ended: %s\n",
tempStr1, tempStr2 ); tempStr1, tempStr2 );
printf( " elapsed: %ld:%.2d:%.2d (%ld seconds)\n", printf( " elapsed: %ld:%.2d:%.2d (%lu seconds)\n",
(pMUD->elapsedSec/3600), ((pMUD->elapsedSec%3600)/60), (pMUD->elapsedSec%60), (long)(pMUD->elapsedSec/3600), ((pMUD->elapsedSec%3600)/60), (pMUD->elapsedSec%60),
pMUD->elapsedSec ); (unsigned long)(pMUD->elapsedSec) );
if( pMUD->title ) printf( " title: %s\n", pMUD->title ); if( pMUD->title ) printf( " title: %s\n", pMUD->title );
if( pMUD->sample ) printf( " sample: %s\n", pMUD->sample ); if( pMUD->sample ) printf( " sample: %s\n", pMUD->sample );
if( pMUD->orient ) printf( " orient: %s\n", pMUD->orient ); if( pMUD->orient ) printf( " orient: %s\n", pMUD->orient );

View File

@ -818,10 +818,10 @@ PNeXusDetector2::PNeXusDetector2()
fNoOfBins = -1; fNoOfBins = -1;
fT0Tag = -1; fT0Tag = -1;
fT0 = 0; fT0 = nullptr;
fFirstGoodBin = 0; fFirstGoodBin = nullptr;
fLastGoodBin = 0; fLastGoodBin = nullptr;
fHisto = 0; fHisto = nullptr;
} }
//------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------
@ -837,19 +837,19 @@ PNeXusDetector2::~PNeXusDetector2()
if (fT0) { if (fT0) {
delete [] fT0; delete [] fT0;
fT0 = 0; fT0 = nullptr;
} }
if (fFirstGoodBin) { if (fFirstGoodBin) {
delete [] fFirstGoodBin; delete [] fFirstGoodBin;
fFirstGoodBin = 0; fFirstGoodBin = nullptr;
} }
if (fLastGoodBin) { if (fLastGoodBin) {
delete [] fLastGoodBin; delete [] fLastGoodBin;
fLastGoodBin = 0; fLastGoodBin = nullptr;
} }
if (fHisto) { if (fHisto) {
delete [] fHisto; delete [] fHisto;
fHisto = 0; fHisto = nullptr;
} }
} }
@ -919,10 +919,16 @@ bool PNeXusDetector2::IsValid(bool strict)
*/ */
int PNeXusDetector2::GetT0(int idxp, int idxs) int PNeXusDetector2::GetT0(int idxp, int idxs)
{ {
int result = -1; int result = -1;
if (fT0Tag == 1) { // there is only ONE t0 present
if (fT0 != nullptr)
result = *fT0;
return result;
}
if ((idxp < 0) && (idxs < 0)) { // assumption: there is only ONE t0 for all spectra if ((idxp < 0) && (idxs < 0)) { // assumption: there is only ONE t0 for all spectra
if (fT0 != 0) { if (fT0 != nullptr) {
result = *fT0; result = *fT0;
} }
} else if ((idxp < 0) && (idxs >= 0)) { // assumption: t0's are represented as t0[ns] } else if ((idxp < 0) && (idxs >= 0)) { // assumption: t0's are represented as t0[ns]
@ -1031,17 +1037,24 @@ int PNeXusDetector2::GetFirstGoodBin(int idxp, int idxs)
{ {
int result = -1; int result = -1;
if (fT0Tag == 1) { // there is only ONE t0 present
if (fT0 != nullptr)
result = *fFirstGoodBin;
return result;
}
if ((idxp < 0) && (idxs < 0)) { // assumption: there is only ONE t0 for all spectra if ((idxp < 0) && (idxs < 0)) { // assumption: there is only ONE t0 for all spectra
if (fFirstGoodBin != 0) { if (fFirstGoodBin != nullptr) {
result = *fFirstGoodBin; result = *fFirstGoodBin;
} }
} else if ((idxp < 0) && (idxs >= 0)) { // assumptions: fgb's are represented as fgb[ns] } else if ((idxp < 0) && (idxs >= 0)) { // assumptions: fgb's are represented as fgb[ns]
if (idxs < fNoOfSpectra) { if ((idxs < fNoOfSpectra) && (fFirstGoodBin != nullptr)) {
result = *(fFirstGoodBin+idxs); result = *(fFirstGoodBin+idxs);
} }
} else if ((idxp >= 0) && (idxs >= 0)) { // assumption: fgb's are represented as fgb[np][ns] } else if ((idxp >= 0) && (idxs >= 0)) { // assumption: fgb's are represented as fgb[np][ns]
if ((idxp < fNoOfPeriods) || (idxs < fNoOfSpectra)) { if ((idxp < fNoOfPeriods) || (idxs < fNoOfSpectra)) {
result = *(fFirstGoodBin+idxp*fNoOfSpectra+idxs); if (fFirstGoodBin != nullptr)
result = *(fFirstGoodBin+idxp*fNoOfSpectra+idxs);
} }
} else { } else {
result = -1; result = -1;
@ -1141,17 +1154,24 @@ int PNeXusDetector2::GetLastGoodBin(int idxp, int idxs)
{ {
int result = -1; int result = -1;
if (fT0Tag == 1) { // there is only ONE t0 present
if (fT0 != nullptr)
result = *fLastGoodBin;
return result;
}
if ((idxp < 0) && (idxs < 0)) { // assumption: there is only ONE t0 for all spectra if ((idxp < 0) && (idxs < 0)) { // assumption: there is only ONE t0 for all spectra
if (fLastGoodBin != 0) { if (fLastGoodBin != nullptr) {
result = *fLastGoodBin; result = *fLastGoodBin;
} }
} else if ((idxp < 0) && (idxs >= 0)) { // assumption: lgb's are represented as lgb[ns] } else if ((idxp < 0) && (idxs >= 0)) { // assumption: lgb's are represented as lgb[ns]
if (idxs < fNoOfSpectra) { if ((idxs < fNoOfSpectra) && (fLastGoodBin != nullptr)) {
result = *(fLastGoodBin+idxs); result = *(fLastGoodBin+idxs);
} }
} else if ((idxp >= 0) && (idxs >= 0)) { // assumption: lgb's are represented as lgb[np][ns] } else if ((idxp >= 0) && (idxs >= 0)) { // assumption: lgb's are represented as lgb[np][ns]
if ((idxp < fNoOfPeriods) || (idxs < fNoOfSpectra)) { if ((idxp < fNoOfPeriods) || (idxs < fNoOfSpectra)) {
result = *(fLastGoodBin+idxp*fNoOfSpectra+idxs); if (fLastGoodBin != nullptr)
result = *(fLastGoodBin+idxp*fNoOfSpectra+idxs);
} }
} else { } else {
result = -1; result = -1;
@ -3398,6 +3418,14 @@ int PNeXus::ReadFileIdf2()
return NX_ERROR; return NX_ERROR;
} }
// beamline
if (SearchInGroup("beamline", "name", nxname, nxclass, dataType)) {
if (!ErrorHandler(NXopendata(fFileHandle, "beamline"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'beamline' data in NXentry!")) return NX_ERROR;
if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'beamline' data in NXentry!")) return NX_ERROR;
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'beamline' data in NXentry!")) return NX_ERROR;
fNxEntry2->GetInstrument()->GetBeamline()->SetName(str);
}
// definition // definition
if (!ErrorHandler(NXopendata(fFileHandle, "definition"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'definition' data in NXentry!")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "definition"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'definition' data in NXentry!")) return NX_ERROR;
if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'definition' data in NXentry!")) return NX_ERROR; if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'definition' data in NXentry!")) return NX_ERROR;
@ -3576,26 +3604,37 @@ int PNeXus::ReadFileIdf2()
// close group NXsource // close group NXsource
NXclosegroup(fFileHandle); NXclosegroup(fFileHandle);
// open group NXbeamline // open group NXbeamline
if (!ErrorHandler(NXopengroup(fFileHandle, "beamline", "NXbeamline"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open NeXus subgroup beamline in NXinstrument!")) return NX_ERROR; if (SearchInGroup("beamline", "name", nxname, nxclass, dataType)) {
if (!ErrorHandler(NXopengroup(fFileHandle, "beamline", "NXbeamline"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open NeXus subgroup beamline in NXinstrument!")) return NX_ERROR;
// beamline name // beamline name
if (!ErrorHandler(NXopendata(fFileHandle, "beamline"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'beamline' data in NXbeamline!")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "beamline"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'beamline' data in NXbeamline!")) return NX_ERROR;
if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'beamline' data in NXbeamline!")) return NX_ERROR; if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'beamline' data in NXbeamline!")) return NX_ERROR;
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'beamline' data in NXbeamline!")) return NX_ERROR; if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'beamline' data in NXbeamline!")) return NX_ERROR;
fNxEntry2->GetInstrument()->GetBeamline()->SetName(str); fNxEntry2->GetInstrument()->GetBeamline()->SetName(str);
// close group NXbeamline // close group NXbeamline
NXclosegroup(fFileHandle); NXclosegroup(fFileHandle);
} else {
std::cerr << "**WARNING** in class NXinstrument the object NXbeamline with name 'beamline' is missing!" << std::endl;
std::cerr << " Complain at the facility where you got this data file from!" << std::endl;
}
// open group NXdetector // open group NXdetector in instrument (NXinstrument)
if (!ErrorHandler(NXopengroup(fFileHandle, "detector_1", "NXdetector"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open NeXus subgroup detector_1 in NXinstrument!")) return NX_ERROR; if (!ErrorHandler(NXopengroup(fFileHandle, "detector_1", "NXdetector"), PNEXUS_GROUP_OPEN_ERROR, "couldn't open NeXus subgroup detector_1 in NXinstrument!")) return NX_ERROR;
// description // description
if (!ErrorHandler(NXopendata(fFileHandle, "description"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'description' data in NXdetector!")) return NX_ERROR; if (SearchInGroup("description", "name", nxname, nxclass, dataType)) {
if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'description' data in NXdetector!")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "description"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'description' data in NXdetector!")) return NX_ERROR;
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'description' data in NXdetector!")) return NX_ERROR; if (!ErrorHandler(GetStringData(str), PNEXUS_GET_DATA_ERROR, "couldn't read 'description' data in NXdetector!")) return NX_ERROR;
fNxEntry2->GetInstrument()->GetDetector()->SetDescription(str); if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'description' data in NXdetector!")) return NX_ERROR;
fNxEntry2->GetInstrument()->GetDetector()->SetDescription(str);
} else {
std::cerr << "**WARNING** in class NXdetector to object NX_CHAR with name 'description' is missing!" << std::endl;
std::cerr << " Complain at the facility where you got this data file from!" << std::endl;
}
// get the time resolution. This is a little bit complicated since it is either present as 'histogram_resolution' or needs to be extracted from the 'raw_time' vector // get the time resolution. This is a little bit complicated since it is either present as 'histogram_resolution' or needs to be extracted from the 'raw_time' vector
// 1st check if 'histogram_resolution' is found // 1st check if 'histogram_resolution' is found
@ -3607,10 +3646,10 @@ int PNeXus::ReadFileIdf2()
fNxEntry2->GetInstrument()->GetDetector()->SetTimeResolution((double)fval, str); fNxEntry2->GetInstrument()->GetDetector()->SetTimeResolution((double)fval, str);
} else if (SearchInGroup("resolution", "name", nxname, nxclass, dataType)) { // 2nd check if 'resolution' is found } else if (SearchInGroup("resolution", "name", nxname, nxclass, dataType)) { // 2nd check if 'resolution' is found
if (!ErrorHandler(NXopendata(fFileHandle, "resolution"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'resolution' data in NXdetector!")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "resolution"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'resolution' data in NXdetector!")) return NX_ERROR;
if (!ErrorHandler(NXgetdata(fFileHandle, &fval), PNEXUS_GET_DATA_ERROR, "couldn't read 'resolution' data in NXdetector!")) return NX_ERROR; if (!ErrorHandler(NXgetdata(fFileHandle, &ival), PNEXUS_GET_DATA_ERROR, "couldn't read 'resolution' data in NXdetector!")) return NX_ERROR;
if (!ErrorHandler(GetStringAttr("units", str), PNEXUS_GET_ATTR_ERROR, "couldn't read time resolution units in NXdetector!")) return NX_ERROR; if (!ErrorHandler(GetStringAttr("units", str), PNEXUS_GET_ATTR_ERROR, "couldn't read time resolution units in NXdetector!")) return NX_ERROR;
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'resolution' data in NXdetector!")) return NX_ERROR; if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'resolution' data in NXdetector!")) return NX_ERROR;
fNxEntry2->GetInstrument()->GetDetector()->SetTimeResolution((double)fval, str); fNxEntry2->GetInstrument()->GetDetector()->SetTimeResolution((double)ival, str);
} else { // 3nd 'histogram_resolution' is not present, hence extract the time resolution from the 'raw_time' vector } else { // 3nd 'histogram_resolution' is not present, hence extract the time resolution from the 'raw_time' vector
if (!ErrorHandler(NXopendata(fFileHandle, "raw_time"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'raw_time' data in NXdetector!")) return NX_ERROR; if (!ErrorHandler(NXopendata(fFileHandle, "raw_time"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'raw_time' data in NXdetector!")) return NX_ERROR;
std::vector<double> rawTime; std::vector<double> rawTime;
@ -3626,6 +3665,51 @@ int PNeXus::ReadFileIdf2()
// check the dimensions of 'counts' // check the dimensions of 'counts'
if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get 'counts' info in NXdetector!")) return NX_ERROR; if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get 'counts' info in NXdetector!")) return NX_ERROR;
// check if last_good_bin, first_good_bin, and t0_bins are defined as attributes
int attLen = 1, attType = NX_INT32;
if (SearchAttrInData("first_good_bin", attLen, attType)) {
char cstr[1204];
memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, "first_good_bin", sizeof(cstr));
status = NXgetattr(fFileHandle, cstr, (void*)&ival, &attLen, &attType);
fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(1); // a single set for t0, fgb, lgb is likely given
int *i_data_ptr = new int;
*i_data_ptr = ival;
if (!fNxEntry2->GetInstrument()->GetDetector()->SetFirstGoodBin(i_data_ptr)) {
std::cerr << std::endl << ">> **ERROR** " << fNxEntry2->GetInstrument()->GetDetector()->GetErrorMsg() << std::endl;
return NX_ERROR;
}
}
if (SearchAttrInData("last_good_bin", attLen, attType)) {
char cstr[1204];
memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, "last_good_bin", sizeof(cstr));
status = NXgetattr(fFileHandle, cstr, (void*)&ival, &attLen, &attType);
fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(1); // a single set for t0, fgb, lgb is likely given
int *i_data_ptr = new int;
*i_data_ptr = ival;
if (!fNxEntry2->GetInstrument()->GetDetector()->SetLastGoodBin(i_data_ptr)) {
std::cerr << std::endl << ">> **ERROR** " << fNxEntry2->GetInstrument()->GetDetector()->GetErrorMsg() << std::endl;
return NX_ERROR;
}
}
if (SearchAttrInData("t0_bin", attLen, attType)) {
char cstr[1204];
memset(cstr, '\0', sizeof(cstr));
strncpy(cstr, "t0_bin", sizeof(cstr));
status = NXgetattr(fFileHandle, cstr, (void*)&ival, &attLen, &attType);
fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(1); // a single set for t0, fgb, lgb is likely given
int *i_data_ptr = new int;
*i_data_ptr = ival;
if (!fNxEntry2->GetInstrument()->GetDetector()->SetT0(i_data_ptr)) {
std::cerr << std::endl << ">> **ERROR** " << fNxEntry2->GetInstrument()->GetDetector()->GetErrorMsg() << std::endl;
return NX_ERROR;
}
}
// calculate the needed size // calculate the needed size
size = dims[0]; size = dims[0];
for (int i=1; i<rank; i++) for (int i=1; i<rank; i++)
@ -3713,320 +3797,323 @@ int PNeXus::ReadFileIdf2()
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'spectrum_index' data in NXdetector!")) return NX_ERROR; if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'spectrum_index' data in NXdetector!")) return NX_ERROR;
// handle t0's // only handle t0, fgb, lgb, if they are not already set as an attribute of /raw_data_1/instrument/detector_1/counts
if (SearchInGroup("time_zero_bin", "name", nxname, nxclass, dataType)) { // check for 'time_zero_bin' if (fNxEntry2->GetInstrument()->GetDetector()->GetT0Tag() == -1) {
if (!ErrorHandler(NXopendata(fFileHandle, "time_zero_bin"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'time_zero_bin' data in NXdetector!")) return NX_ERROR; // handle t0's
if (SearchInGroup("time_zero_bin", "name", nxname, nxclass, dataType)) { // check for 'time_zero_bin'
if (!ErrorHandler(NXopendata(fFileHandle, "time_zero_bin"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'time_zero_bin' data in NXdetector!")) return NX_ERROR;
// check the dimensions of the 'time_zero_bin' vector // check the dimensions of the 'time_zero_bin' vector
if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get 'time_zero_bin' info in NXdetector!")) return NX_ERROR; if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get 'time_zero_bin' info in NXdetector!")) return NX_ERROR;
if ((rank == 1) && (dims[0] == 1)) { // single t0 entry if ((rank == 1) && (dims[0] == 1)) { // single t0 entry
fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(1); fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(1);
} else if ((rank == 1) && (dims[0] > 1)) { // t0 of the form t0[ns] } else if ((rank == 1) && (dims[0] > 1)) { // t0 of the form t0[ns]
fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(2); fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(2);
} else if (rank == 2) { // t0 of the form t0[np][ns] } else if (rank == 2) { // t0 of the form t0[np][ns]
fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(3); fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(3);
} else {
std::cerr << std::endl << ">> **ERROR** found 'time_zero_bin' info in NXdetector with rank=" << rank << ". Do not know how to handle." << std::endl;
return NX_ERROR;
}
// calculate the needed size
size = dims[0];
for (int i=1; i<rank; i++)
size *= dims[i];
noOfElements = size;
size *= GetDataSize(type);
// allocate locale memory to get the data
char *data_ptr = new char[size];
if (data_ptr == nullptr) {
return NX_ERROR;
}
// get the data
int *i_data_ptr = (int*) data_ptr;
int status = NXgetdata(fFileHandle, i_data_ptr);
if (status != NX_OK) {
return NX_ERROR;
}
if (!fNxEntry2->GetInstrument()->GetDetector()->SetT0(i_data_ptr)) {
std::cerr << std::endl << ">> **ERROR** " << fNxEntry2->GetInstrument()->GetDetector()->GetErrorMsg() << std::endl;
return NX_ERROR;
}
// clean up
if (data_ptr) {
delete [] data_ptr;
data_ptr = nullptr;
}
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'time_zero_bin' data in NXdetector!")) return NX_ERROR;
} else if (SearchInGroup("time_zero", "name", nxname, nxclass, dataType)) { // check for 'time_zero'
if (!ErrorHandler(NXopendata(fFileHandle, "time_zero"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'time_zero' data in NXdetector!")) return NX_ERROR;
// check the dimensions of the 'time_zero' vector
if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get 'time_zero' info in NXdetector!")) return NX_ERROR;
if ((rank == 1) && (dims[0] == 1)) { // single t0 entry
fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(1);
} else if ((rank == 1) && (dims[0] > 1)) { // t0 of the form t0[ns]
fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(2);
} else if (rank == 2) { // t0 of the form t0[np][ns]
fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(3);
} else {
std::cerr << std::endl << ">> **ERROR** found 'time_zero' info in NXdetector with rank=" << rank << ". Do not know how to handle." << std::endl;
return NX_ERROR;
}
// calculate the needed size
size = dims[0];
for (int i=1; i<rank; i++)
size *= dims[i];
noOfElements = size;
size *= GetDataSize(type);
// allocate locale memory to get the data
char *data_ptr = new char[size];
if (data_ptr == nullptr) {
return NX_ERROR;
}
// get the data
float *f_data_ptr = (float*) data_ptr;
int status = NXgetdata(fFileHandle, f_data_ptr);
if (status != NX_OK) {
return NX_ERROR;
}
if (!ErrorHandler(GetStringAttr("units", str), PNEXUS_GET_ATTR_ERROR, "couldn't read 'time_zero' units in NXdetector!")) return NX_ERROR;
// Set T0's
// check that the necessary time resolution is present
if (fNxEntry2->GetInstrument()->GetDetector()->GetTimeResolution(str) == 0.0) {
std::cerr << std::endl << ">> **ERROR** trying to set T0's based on 'time_zero'. Need a valid time resolution to do so, but this is not given." << std::endl;
return NX_ERROR;
}
// set the t0's based on the t0 time stamp and the time resolution
int *pt0 = nullptr;
if (rank == 1) {
pt0 = new int;
*pt0 = (int)(*f_data_ptr / (float)fNxEntry2->GetInstrument()->GetDetector()->GetTimeResolution(str));
} else { // rank == 2
pt0 = new int[noOfElements];
for (int i=0; i<noOfElements; i++) {
*(pt0+i) = (int)(*(f_data_ptr+i) / (float)fNxEntry2->GetInstrument()->GetDetector()->GetTimeResolution(str));
}
}
if (!fNxEntry2->GetInstrument()->GetDetector()->SetT0(pt0)) {
std::cerr << std::endl << ">> **ERROR** " << fNxEntry2->GetInstrument()->GetDetector()->GetErrorMsg() << std::endl;
return NX_ERROR;
}
// clean up
if (data_ptr) {
delete [] data_ptr;
data_ptr = nullptr;
}
std::cerr << std::endl << ">> **WARNING** found only 'time_zero' will convert it to 'time_zero_bin' values" << std::endl;
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'time_zero' data in NXdetector!")) return NX_ERROR;
} else { } else {
std::cerr << std::endl << ">> **ERROR** found 'time_zero_bin' info in NXdetector with rank=" << rank << ". Do not know how to handle." << std::endl; std::cerr << std::endl << ">> **WARNING** found neither 'time_zero_bin' nor 'time_zero' values ..." << std::endl;
return NX_ERROR;
} }
// calculate the needed size // handle first good bin
size = dims[0]; if (SearchInGroup("first_good_bin", "name", nxname, nxclass, dataType)) {
for (int i=1; i<rank; i++) if (!ErrorHandler(NXopendata(fFileHandle, "first_good_bin"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'first_good_bin' data in NXdetector!")) return NX_ERROR;
size *= dims[i];
noOfElements = size;
size *= GetDataSize(type);
// allocate locale memory to get the data // check the dimensions of the 'first_good_bin' vector
char *data_ptr = new char[size]; if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get 'first_good_bin' info in NXdetector!")) return NX_ERROR;
if (data_ptr == nullptr) {
return NX_ERROR;
}
// get the data // calculate the needed size
int *i_data_ptr = (int*) data_ptr; size = dims[0];
int status = NXgetdata(fFileHandle, i_data_ptr); for (int i=1; i<rank; i++)
if (status != NX_OK) { size *= dims[i];
return NX_ERROR; noOfElements = size;
} size *= GetDataSize(type);
if (!fNxEntry2->GetInstrument()->GetDetector()->SetT0(i_data_ptr)) { // allocate locale memory to get the data
std::cerr << std::endl << ">> **ERROR** " << fNxEntry2->GetInstrument()->GetDetector()->GetErrorMsg() << std::endl; char *data_ptr = new char[size];
return NX_ERROR; if (data_ptr == nullptr) {
} return NX_ERROR;
}
// clean up // get the data
if (data_ptr) { int *i_data_ptr = (int*) data_ptr;
delete [] data_ptr; int status = NXgetdata(fFileHandle, i_data_ptr);
data_ptr = nullptr; if (status != NX_OK) {
} return NX_ERROR;
}
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'time_zero_bin' data in NXdetector!")) return NX_ERROR; if (!fNxEntry2->GetInstrument()->GetDetector()->SetFirstGoodBin(i_data_ptr)) {
} else if (SearchInGroup("time_zero", "name", nxname, nxclass, dataType)) { // check for 'time_zero' std::cerr << std::endl << ">> **ERROR** " << fNxEntry2->GetInstrument()->GetDetector()->GetErrorMsg() << std::endl;
if (!ErrorHandler(NXopendata(fFileHandle, "time_zero"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'time_zero' data in NXdetector!")) return NX_ERROR; return NX_ERROR;
// check the dimensions of the 'time_zero' vector }
if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get 'time_zero' info in NXdetector!")) return NX_ERROR;
if ((rank == 1) && (dims[0] == 1)) { // single t0 entry if (data_ptr) {
fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(1); delete [] data_ptr;
} else if ((rank == 1) && (dims[0] > 1)) { // t0 of the form t0[ns] data_ptr = nullptr;
fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(2); }
} else if (rank == 2) { // t0 of the form t0[np][ns]
fNxEntry2->GetInstrument()->GetDetector()->SetT0Tag(3); if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'first_good_bin' data in NXdetector!")) return NX_ERROR;
} else if (SearchInGroup("first_good_time", "name", nxname, nxclass, dataType)) {
if (!ErrorHandler(NXopendata(fFileHandle, "first_good_time"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'first_good_time' data in NXdetector!")) return NX_ERROR;
// check the dimensions of the 'first_good_time' vector
if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get 'first_good_time' info in NXdetector!")) return NX_ERROR;
// calculate the needed size
size = dims[0];
for (int i=1; i<rank; i++)
size *= dims[i];
noOfElements = size;
size *= GetDataSize(type);
// allocate locale memory to get the data
char *data_ptr = new char[size];
if (data_ptr == nullptr) {
return NX_ERROR;
}
// get the data
float *f_data_ptr = (float*) data_ptr;
int status = NXgetdata(fFileHandle, f_data_ptr);
if (status != NX_OK) {
return NX_ERROR;
}
// set the fgb's based on the fgb time stamp and the time resolution
int *p_fgb = nullptr;
if (rank == 1) {
p_fgb = new int;
*p_fgb = (int)(*f_data_ptr / (float)fNxEntry2->GetInstrument()->GetDetector()->GetTimeResolution(str));
} else { // rank == 2
p_fgb = new int[noOfElements];
for (int i=0; i<noOfElements; i++) {
*(p_fgb+i) = (int)(*(f_data_ptr+i) / (float)fNxEntry2->GetInstrument()->GetDetector()->GetTimeResolution(str));
}
}
if (!fNxEntry2->GetInstrument()->GetDetector()->SetFirstGoodBin(p_fgb)) {
std::cerr << std::endl << ">> **ERROR** " << fNxEntry2->GetInstrument()->GetDetector()->GetErrorMsg() << std::endl;
return NX_ERROR;
}
// clean up
if (p_fgb) {
delete [] p_fgb;
p_fgb = 0;
}
if (data_ptr) {
delete [] data_ptr;
data_ptr = nullptr;
}
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'first_good_time' data in NXdetector!")) return NX_ERROR;
} else { } else {
std::cerr << std::endl << ">> **ERROR** found 'time_zero' info in NXdetector with rank=" << rank << ". Do not know how to handle." << std::endl; std::cerr << std::endl << ">> **WARNING** found neither 'first_good_bin' nor 'first_good_time' values ..." << std::endl;
return NX_ERROR;
} }
// calculate the needed size // handle last good bin
size = dims[0]; if (SearchInGroup("last_good_bin", "name", nxname, nxclass, dataType)) {
for (int i=1; i<rank; i++) if (!ErrorHandler(NXopendata(fFileHandle, "last_good_bin"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'last_good_bin' data in NXdetector!")) return NX_ERROR;
size *= dims[i];
noOfElements = size;
size *= GetDataSize(type);
// allocate locale memory to get the data // check the dimensions of the 'last_good_bin' vector
char *data_ptr = new char[size]; if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get 'last_good_bin' info in NXdetector!")) return NX_ERROR;
if (data_ptr == nullptr) {
return NX_ERROR;
}
// get the data // calculate the needed size
float *f_data_ptr = (float*) data_ptr; size = dims[0];
int status = NXgetdata(fFileHandle, f_data_ptr); for (int i=1; i<rank; i++)
if (status != NX_OK) { size *= dims[i];
return NX_ERROR; noOfElements = size;
} size *= GetDataSize(type);
if (!ErrorHandler(GetStringAttr("units", str), PNEXUS_GET_ATTR_ERROR, "couldn't read 'time_zero' units in NXdetector!")) return NX_ERROR; // allocate locale memory to get the data
char *data_ptr = new char[size];
// Set T0's if (data_ptr == nullptr) {
// check that the necessary time resolution is present return NX_ERROR;
if (fNxEntry2->GetInstrument()->GetDetector()->GetTimeResolution(str) == 0.0) {
std::cerr << std::endl << ">> **ERROR** trying to set T0's based on 'time_zero'. Need a valid time resolution to do so, but this is not given." << std::endl;
return NX_ERROR;
}
// set the t0's based on the t0 time stamp and the time resolution
int *pt0 = nullptr;
if (rank == 1) {
pt0 = new int;
*pt0 = (int)(*f_data_ptr / (float)fNxEntry2->GetInstrument()->GetDetector()->GetTimeResolution(str));
} else { // rank == 2
pt0 = new int[noOfElements];
for (int i=0; i<noOfElements; i++) {
*(pt0+i) = (int)(*(f_data_ptr+i) / (float)fNxEntry2->GetInstrument()->GetDetector()->GetTimeResolution(str));
} }
}
if (!fNxEntry2->GetInstrument()->GetDetector()->SetT0(pt0)) { // get the data
std::cerr << std::endl << ">> **ERROR** " << fNxEntry2->GetInstrument()->GetDetector()->GetErrorMsg() << std::endl; int *i_data_ptr = (int*) data_ptr;
return NX_ERROR; int status = NXgetdata(fFileHandle, i_data_ptr);
} if (status != NX_OK) {
return NX_ERROR;
// clean up
if (data_ptr) {
delete [] data_ptr;
data_ptr = nullptr;
}
std::cerr << std::endl << ">> **WARNING** found only 'time_zero' will convert it to 'time_zero_bin' values" << std::endl;
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'time_zero' data in NXdetector!")) return NX_ERROR;
} else {
std::cerr << std::endl << ">> **WARNING** found neither 'time_zero_bin' nor 'time_zero' values ..." << std::endl;
}
// handle first good bin
if (SearchInGroup("first_good_bin", "name", nxname, nxclass, dataType)) {
if (!ErrorHandler(NXopendata(fFileHandle, "first_good_bin"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'first_good_bin' data in NXdetector!")) return NX_ERROR;
// check the dimensions of the 'first_good_bin' vector
if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get 'first_good_bin' info in NXdetector!")) return NX_ERROR;
// calculate the needed size
size = dims[0];
for (int i=1; i<rank; i++)
size *= dims[i];
noOfElements = size;
size *= GetDataSize(type);
// allocate locale memory to get the data
char *data_ptr = new char[size];
if (data_ptr == nullptr) {
return NX_ERROR;
}
// get the data
int *i_data_ptr = (int*) data_ptr;
int status = NXgetdata(fFileHandle, i_data_ptr);
if (status != NX_OK) {
return NX_ERROR;
}
if (!fNxEntry2->GetInstrument()->GetDetector()->SetFirstGoodBin(i_data_ptr)) {
std::cerr << std::endl << ">> **ERROR** " << fNxEntry2->GetInstrument()->GetDetector()->GetErrorMsg() << std::endl;
return NX_ERROR;
}
if (data_ptr) {
delete [] data_ptr;
data_ptr = nullptr;
}
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'first_good_bin' data in NXdetector!")) return NX_ERROR;
} else if (SearchInGroup("first_good_time", "name", nxname, nxclass, dataType)) {
if (!ErrorHandler(NXopendata(fFileHandle, "first_good_time"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'first_good_time' data in NXdetector!")) return NX_ERROR;
// check the dimensions of the 'first_good_time' vector
if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get 'first_good_time' info in NXdetector!")) return NX_ERROR;
// calculate the needed size
size = dims[0];
for (int i=1; i<rank; i++)
size *= dims[i];
noOfElements = size;
size *= GetDataSize(type);
// allocate locale memory to get the data
char *data_ptr = new char[size];
if (data_ptr == nullptr) {
return NX_ERROR;
}
// get the data
float *f_data_ptr = (float*) data_ptr;
int status = NXgetdata(fFileHandle, f_data_ptr);
if (status != NX_OK) {
return NX_ERROR;
}
// set the fgb's based on the fgb time stamp and the time resolution
int *p_fgb = nullptr;
if (rank == 1) {
p_fgb = new int;
*p_fgb = (int)(*f_data_ptr / (float)fNxEntry2->GetInstrument()->GetDetector()->GetTimeResolution(str));
} else { // rank == 2
p_fgb = new int[noOfElements];
for (int i=0; i<noOfElements; i++) {
*(p_fgb+i) = (int)(*(f_data_ptr+i) / (float)fNxEntry2->GetInstrument()->GetDetector()->GetTimeResolution(str));
} }
}
if (!fNxEntry2->GetInstrument()->GetDetector()->SetFirstGoodBin(p_fgb)) { if (!fNxEntry2->GetInstrument()->GetDetector()->SetLastGoodBin(i_data_ptr)) {
std::cerr << std::endl << ">> **ERROR** " << fNxEntry2->GetInstrument()->GetDetector()->GetErrorMsg() << std::endl; std::cerr << std::endl << ">> **ERROR** " << fNxEntry2->GetInstrument()->GetDetector()->GetErrorMsg() << std::endl;
return NX_ERROR; return NX_ERROR;
}
// clean up
if (p_fgb) {
delete [] p_fgb;
p_fgb = 0;
}
if (data_ptr) {
delete [] data_ptr;
data_ptr = nullptr;
}
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'first_good_time' data in NXdetector!")) return NX_ERROR;
} else {
std::cerr << std::endl << ">> **WARNING** found neither 'first_good_bin' nor 'first_good_time' values ..." << std::endl;
}
// handle last good bin
if (SearchInGroup("last_good_bin", "name", nxname, nxclass, dataType)) {
if (!ErrorHandler(NXopendata(fFileHandle, "last_good_bin"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'last_good_bin' data in NXdetector!")) return NX_ERROR;
// check the dimensions of the 'last_good_bin' vector
if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get 'last_good_bin' info in NXdetector!")) return NX_ERROR;
// calculate the needed size
size = dims[0];
for (int i=1; i<rank; i++)
size *= dims[i];
noOfElements = size;
size *= GetDataSize(type);
// allocate locale memory to get the data
char *data_ptr = new char[size];
if (data_ptr == nullptr) {
return NX_ERROR;
}
// get the data
int *i_data_ptr = (int*) data_ptr;
int status = NXgetdata(fFileHandle, i_data_ptr);
if (status != NX_OK) {
return NX_ERROR;
}
if (!fNxEntry2->GetInstrument()->GetDetector()->SetLastGoodBin(i_data_ptr)) {
std::cerr << std::endl << ">> **ERROR** " << fNxEntry2->GetInstrument()->GetDetector()->GetErrorMsg() << std::endl;
return NX_ERROR;
}
// clean up
if (data_ptr) {
delete [] data_ptr;
data_ptr = nullptr;
}
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'last_good_bin' data in NXdetector!")) return NX_ERROR;
} else if (SearchInGroup("last_good_time", "name", nxname, nxclass, dataType)) {
if (!ErrorHandler(NXopendata(fFileHandle, "last_good_time"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'last_good_time' data in NXdetector!")) return NX_ERROR;
// check the dimensions of the 'last_good_time' vector
if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get 'last_good_time' info in NXdetector!")) return NX_ERROR;
// calculate the needed size
size = dims[0];
for (int i=1; i<rank; i++)
size *= dims[i];
noOfElements = size;
size *= GetDataSize(type);
// allocate locale memory to get the data
char *data_ptr = new char[size];
if (data_ptr == nullptr) {
return NX_ERROR;
}
// get the data
float *f_data_ptr = (float*) data_ptr;
int status = NXgetdata(fFileHandle, f_data_ptr);
if (status != NX_OK) {
return NX_ERROR;
}
// set the lgb's based on the lgb time stamp and the time resolution
int *p_lgb = nullptr;
if (rank == 1) {
p_lgb = new int;
*p_lgb = (int)(*f_data_ptr / (float)fNxEntry2->GetInstrument()->GetDetector()->GetTimeResolution(str));
} else { // rank == 2
p_lgb = new int[noOfElements];
for (int i=0; i<noOfElements; i++) {
*(p_lgb+i) = (int)(*(f_data_ptr+i) / (float)fNxEntry2->GetInstrument()->GetDetector()->GetTimeResolution(str));
} }
}
if (fNxEntry2->GetInstrument()->GetDetector()->SetFirstGoodBin(p_lgb)) { // clean up
std::cerr << std::endl << ">> **ERROR** " << fNxEntry2->GetInstrument()->GetDetector()->GetErrorMsg() << std::endl; if (data_ptr) {
return NX_ERROR; delete [] data_ptr;
} data_ptr = nullptr;
}
// clean up if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'last_good_bin' data in NXdetector!")) return NX_ERROR;
if (p_lgb) { } else if (SearchInGroup("last_good_time", "name", nxname, nxclass, dataType)) {
delete [] p_lgb; if (!ErrorHandler(NXopendata(fFileHandle, "last_good_time"), PNEXUS_OPEN_DATA_ERROR, "couldn't open 'last_good_time' data in NXdetector!")) return NX_ERROR;
p_lgb = 0;
}
if (data_ptr) {
delete [] data_ptr;
data_ptr = nullptr;
}
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'last_good_time' data in NXdetector!")) return NX_ERROR; // check the dimensions of the 'last_good_time' vector
} else { if (!ErrorHandler(NXgetinfo(fFileHandle, &rank, dims, &type), PNEXUS_GET_META_INFO_ERROR, "couldn't get 'last_good_time' info in NXdetector!")) return NX_ERROR;
std::cerr << std::endl << ">> **WARNING** found neither 'last_good_bin' nor 'last_good_time' values ..." << std::endl;
// calculate the needed size
size = dims[0];
for (int i=1; i<rank; i++)
size *= dims[i];
noOfElements = size;
size *= GetDataSize(type);
// allocate locale memory to get the data
char *data_ptr = new char[size];
if (data_ptr == nullptr) {
return NX_ERROR;
}
// get the data
float *f_data_ptr = (float*) data_ptr;
int status = NXgetdata(fFileHandle, f_data_ptr);
if (status != NX_OK) {
return NX_ERROR;
}
// set the lgb's based on the lgb time stamp and the time resolution
int *p_lgb = nullptr;
if (rank == 1) {
p_lgb = new int;
*p_lgb = (int)(*f_data_ptr / (float)fNxEntry2->GetInstrument()->GetDetector()->GetTimeResolution(str));
} else { // rank == 2
p_lgb = new int[noOfElements];
for (int i=0; i<noOfElements; i++) {
*(p_lgb+i) = (int)(*(f_data_ptr+i) / (float)fNxEntry2->GetInstrument()->GetDetector()->GetTimeResolution(str));
}
}
if (fNxEntry2->GetInstrument()->GetDetector()->SetFirstGoodBin(p_lgb)) {
std::cerr << std::endl << ">> **ERROR** " << fNxEntry2->GetInstrument()->GetDetector()->GetErrorMsg() << std::endl;
return NX_ERROR;
}
// clean up
if (p_lgb) {
delete [] p_lgb;
p_lgb = 0;
}
if (data_ptr) {
delete [] data_ptr;
data_ptr = nullptr;
}
if (!ErrorHandler(NXclosedata(fFileHandle), PNEXUS_CLOSE_DATA_ERROR, "couldn't close 'last_good_time' data in NXdetector!")) return NX_ERROR;
} else {
std::cerr << std::endl << ">> **WARNING** found neither 'last_good_bin' nor 'last_good_time' values ..." << std::endl;
}
} }
// close group NXdetector // close group NXdetector

View File

@ -512,7 +512,7 @@ int main(int argc, char *argv[])
return 0; return 0;
} else if (!strcmp(argv[1], "--version")) { } else if (!strcmp(argv[1], "--version")) {
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
std::cout << std::endl << "msr2data version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << ", ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl; std::cout << std::endl << "msr2data version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else #else
std::cout << std::endl << "msr2data git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl; std::cout << std::endl << "msr2data git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#endif #endif

View File

@ -297,7 +297,7 @@ Int_t musrFT_parse_options(Int_t argc, Char_t *argv[], musrFT_startup_param &sta
tstr = argv[i]; tstr = argv[i];
if (tstr.BeginsWith("--version")) { if (tstr.BeginsWith("--version")) {
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
std::cout << std::endl << "musrFT version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << ", ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl; std::cout << std::endl << "musrFT version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else #else
std::cout << std::endl << "musrFT git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl; std::cout << std::endl << "musrFT git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#endif #endif

View File

@ -574,7 +574,7 @@ int main(int argc, char *argv[])
} else if (argc==2) { } else if (argc==2) {
if (!strcmp(argv[1], "--version")) { if (!strcmp(argv[1], "--version")) {
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
std::cout << std::endl << "musrRootValidation version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl; std::cout << std::endl << "musrRootValidation version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else #else
std::cout << std::endl << "musrRootValidation git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl; std::cout << std::endl << "musrRootValidation git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#endif #endif

View File

@ -41,7 +41,7 @@ PMusrEditAbout::PMusrEditAbout(QWidget *parent) : QDialog(parent)
fGitBranch_label->setText(QString("git-branch: %1").arg(GIT_BRANCH)); fGitBranch_label->setText(QString("git-branch: %1").arg(GIT_BRANCH));
fGitRev_label->setText(QString("git-rev: %1").arg(GIT_CURRENT_SHA1)); fGitRev_label->setText(QString("git-rev: %1").arg(GIT_CURRENT_SHA1));
fMusrfitVersion_label->setText(QString("musrfit-version: %1").arg(PACKAGE_VERSION)); fMusrfitVersion_label->setText(QString("musrfit-version: %1 (%2)").arg(PACKAGE_VERSION).arg(BUILD_TYPE));
fRootVersion_label->setText(QString("ROOT-version: %1").arg(ROOT_VERSION_USED)); fRootVersion_label->setText(QString("ROOT-version: %1").arg(ROOT_VERSION_USED));
setModal(true); setModal(true);

View File

@ -41,7 +41,7 @@ PMusrEditAbout::PMusrEditAbout(QWidget *parent) : QDialog(parent)
fGitBranch_label->setText(QString("git-branch: %1").arg(GIT_BRANCH)); fGitBranch_label->setText(QString("git-branch: %1").arg(GIT_BRANCH));
fGitRev_label->setText(QString("git-rev: %1").arg(GIT_CURRENT_SHA1)); fGitRev_label->setText(QString("git-rev: %1").arg(GIT_CURRENT_SHA1));
fMusrfitVersion_label->setText(QString("musrfit-version: %1").arg(PACKAGE_VERSION)); fMusrfitVersion_label->setText(QString("musrfit-version: %1 (%2)").arg(PACKAGE_VERSION).arg(BUILD_TYPE));
fRootVersion_label->setText(QString("ROOT-version: %1").arg(ROOT_VERSION_USED)); fRootVersion_label->setText(QString("ROOT-version: %1").arg(ROOT_VERSION_USED));
setModal(true); setModal(true);

View File

@ -464,7 +464,7 @@ int main(int argc, char *argv[])
if (argc == 2) { if (argc == 2) {
if (!strcmp(argv[1], "--version")) { if (!strcmp(argv[1], "--version")) {
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
std::cout << std::endl << "musrfit version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << ", ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl; std::cout << std::endl << "musrfit version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else #else
std::cout << std::endl << "musrfit git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl; std::cout << std::endl << "musrfit git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#endif #endif

View File

@ -237,7 +237,7 @@ Int_t main(Int_t argc, Char_t *argv[])
for (int i=1; i<argc; i++) { for (int i=1; i<argc; i++) {
if (!strcmp(argv[i], "--version")) { if (!strcmp(argv[i], "--version")) {
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
std::cout << std::endl << "musrt0 version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << ", ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl; std::cout << std::endl << "musrt0 version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else #else
std::cout << std::endl << "musrt0 git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl; std::cout << std::endl << "musrt0 git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#endif #endif

View File

@ -135,7 +135,7 @@ int main(int argc, char *argv[])
} }
} else if (!strcmp(argv[i], "--version")) { } else if (!strcmp(argv[i], "--version")) {
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
std::cout << std::endl << "musrview version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << ", ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl; std::cout << std::endl << "musrview version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else #else
std::cout << std::endl << "musrview git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl; std::cout << std::endl << "musrview git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#endif #endif

View File

@ -61,9 +61,9 @@ int main(int argc, char *argv[])
if (!strcmp(argv[1], "--version")) { if (!strcmp(argv[1], "--version")) {
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
std::cout << std::endl << "write_musrRoot_runHeader version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl; std::cout << std::endl << "write_musrRoot_runHeader version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else #else
std::cout << std::endl << "write_musrRoot_runHeader git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl; std::cout << std::endl << "write_musrRoot_runHeader git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#endif #endif
return 0; return 0;
} }