start working on the deadtime correction.

This commit is contained in:
2026-02-08 15:34:22 +01:00
parent d70fd34345
commit 6a41458310
6 changed files with 79 additions and 28 deletions

View File

@@ -3,21 +3,20 @@ Ag_T=100_F=20
FITPARAMETER FITPARAMETER
# No Name Value Step Pos_Error Boundaries # No Name Value Step Pos_Error Boundaries
1 zero 0 0 none 1 zero 0 0 none
2 phase 0.00000000029 -0.00000000029 0.00985861603 0 100 2 phase 0.000000011 -0.000000011 0.005772888 0 100
3 field 20.3708 -0.0088 0.0088 0 none 3 field 20.3391 -0.0085 0.0085 0 none
4 asym 0.23135 -0.00065 0.00066 0 0.3 4 asym 0.23461 -0.00051 0.00051 0 0.3
5 rate 0.0074 0.0049 none 0 100 5 rate 0.0239 -0.0040 0.0035 0 100
6 beta 1.867 0.043 none 6 Norm_L 1151.24 -0.53 0.53
7 Norm_L 1135.66 -0.58 0.58 7 BG_L 0 0 none 0 none
8 BG_L 0 0 none 0 none 8 Norm_R 1178.60 -0.58 0.58 0 none
9 Norm_R 1168.88 -0.61 0.61 0 none 9 BG_R 0 0 none 0 none
10 BG_R 0 0 none 0 none 10 relPhase 178.49 -0.20 0.20 0 none
11 relPhase 177.40 -0.20 0.21 0 none
############################################################### ###############################################################
THEORY THEORY
asymmetry 4 asymmetry 4
generExpo 5 6 (rate exponent) simpleGss 5 (rate)
TFieldCos fun1 fun2 (phase frequency) TFieldCos fun1 fun2 (phase frequency)
############################################################### ###############################################################
@@ -28,21 +27,24 @@ fun2 = gamma_mu * par3
############################################################### ###############################################################
GLOBAL GLOBAL
fittype 0 (single histogram fit) fittype 0 (single histogram fit)
data 10 2048 data 5 2048
fit 0.2 14 t0 10.0
deadtime-cor file
fit 0.144 30
packing 1 packing 1
############################################################### ###############################################################
RUN data/emu00139040 XXXX ISIS NEXUS (name beamline institute data-file-format) RUN data/emu00139040 EMU ISIS NEXUS (name beamline institute data-file-format)
norm 7 norm 6
backgr.fit 8 backgr.fit 7
map 1 0 0 0 0 0 0 0 0 0 map 1 0 0 0 0 0 0 0 0 0
forward 1-48 forward 1-48
#deadtime-cor file
RUN data/emu00139040 XXXX ISIS NEXUS (name beamline institute data-file-format) RUN data/emu00139040 XXXX ISIS NEXUS (name beamline institute data-file-format)
norm 9 norm 8
backgr.fit 10 backgr.fit 9
map 11 0 0 0 0 0 0 0 0 0 map 10 0 0 0 0 0 0 0 0 0
forward 49-96 forward 49-96
############################################################### ###############################################################
@@ -59,15 +61,15 @@ fourier_power 11
apodization STRONG # NONE, WEAK, MEDIUM, STRONG apodization STRONG # NONE, WEAK, MEDIUM, STRONG
plot REAL # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE, PHASE_OPT_REAL plot REAL # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE, PHASE_OPT_REAL
range 0 200 range 0 200
phase parR2, par11 phase parR2, par10
############################################################### ###############################################################
PLOT 0 (single histo plot) PLOT 0 (single histo plot)
lifetimecorrection lifetimecorrection
runs 1 2 runs 1 2
range 0 14 -0.35 0.35 range 0 20 -0.35 0.35
view_packing 10 #view_packing 10
############################################################### ###############################################################
STATISTIC --- 2026-02-05 10:47:55 STATISTIC --- 2026-02-08 15:32:12
maxLH = 2154.1, NDF = 1684, maxLH/NDF = 1.279168 maxLH = 4233.1, NDF = 3725, maxLH/NDF = 1.136412

View File

@@ -721,6 +721,22 @@ PRawRunDataSet* PRawRunData::GetDataSet(const UInt_t idx, Bool_t wantHistoNo)
return fData.GetSet(idx); return fData.GetSet(idx);
} }
//--------------------------------------------------------------------------
// DeadTimeCorrectionReady (public)
//--------------------------------------------------------------------------
/**
* <p>Checks if deadtime correction information is sufficient to apply it.
* This means that fNumberOfGoodFrames must be present and the deadtime
* parameter vector.
*
* @return true if ready to apply deadtime correctio, false otherwise
*/
const Bool_t PRawRunData::DeadTimeCorrectionReady()
{
if ((fNumberOfGoodFrames > 0) && (fDeadTimeParam.size() > 0))
return true;
return false;
}
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// SetRingAnode (public) // SetRingAnode (public)

View File

@@ -1069,6 +1069,38 @@ Bool_t PRunSingleHisto::PrepareData()
forward[i] = *runData->GetDataBin(histoNo[i]); forward[i] = *runData->GetDataBin(histoNo[i]);
} }
// check if a dead time correction has to be done
// first check the global block
TString dtcg = fMsrInfo->GetMsrGlobal()->GetDeadTimeCorrection();
Int_t dtcg_tag = 0; // 0=no, 1=file, 2=estimate
if (dtcg.Contains("file", TString::kIgnoreCase)) {
dtcg_tag = 1;
} else if (dtcg.Contains("estimate", TString::kIgnoreCase)) {
dtcg_tag = 2;
}
// now check each run
TString dtcr{"no"};
Bool_t needToCheck{true};
for (UInt_t i=0; i<histoNo.size(); i++) {
dtcr = fRunInfo->GetDeadTimeCorrection();
if (dtcr.Contains("file", TString::kIgnoreCase) || (dtcg_tag != 0)) {
if (runData->DeadTimeCorrectionReady()) {
needToCheck = false;
// Dead time correction: n_true = n_obs / (1 - n_obs * t_dt / (good_frames * dt))
Double_t n_true;
Int_t gf = runData->GetNumberOfGoodFrames();
std::vector<float> t_dt = runData->GetDeadTimeParam();
for (UInt_t j=0; j<forward[i].size(); j++) {
n_true = forward[i][j] / (1.0 - forward[i][j] * t_dt[histoNo[i]] / (gf * fTimeResolution));
forward[i][j] = n_true;
}
}
}
if ((dtcr.Contains("estimate", TString::kIgnoreCase) || (dtcg_tag != 0)) && needToCheck) {
std::cerr << "as35> run: deadtime correction: " << dtcr.Data() << ", global: " << dtcg_tag << std::endl;
}
}
// check if there are runs to be added to the current one // check if there are runs to be added to the current one
if (fRunInfo->GetRunNameSize() > 1) { // runs to be added present if (fRunInfo->GetRunNameSize() > 1) { // runs to be added present
PRawRunData *addRunData; PRawRunData *addRunData;

View File

@@ -3744,7 +3744,7 @@ void nxH5::PNeXus::HandleIdfV2(H5::H5File &file)
ReadIntDataset(file, "/raw_data_1/instrument/detector_1/counts"); ReadIntDataset(file, "/raw_data_1/instrument/detector_1/counts");
ReadFloatDataset(file, "/raw_data_1/instrument/detector_1/raw_time"); ReadFloatDataset(file, "/raw_data_1/instrument/detector_1/raw_time");
ReadIntDataset(file, "/raw_data_1/instrument/detector_1/spectrum_index"); ReadIntDataset(file, "/raw_data_1/instrument/detector_1/spectrum_index");
ReadFloatDataset(file, "/raw_data_1/detector_1/dead_time"); ReadFloatDataset(file, "/raw_data_1/instrument/detector_1/dead_time");
ReadStringDataset(file, "/raw_data_1/sample/name"); ReadStringDataset(file, "/raw_data_1/sample/name");
ReadFloatDataset(file, "/raw_data_1/sample/temperature"); ReadFloatDataset(file, "/raw_data_1/sample/temperature");
ReadFloatDataset(file, "/raw_data_1/sample/magnetic_field"); ReadFloatDataset(file, "/raw_data_1/sample/magnetic_field");
@@ -4739,7 +4739,7 @@ void nxH5::PNeXus::Dump()
std::cout << std::endl << " dead_time:"; std::cout << std::endl << " dead_time:";
std::cout << std::endl; std::cout << std::endl;
try { try {
auto dead_time = std::any_cast<PNXdata<float>>(fDataMap["/raw_data_1/detector_1/dead_time"]); auto dead_time = std::any_cast<PNXdata<float>>(fDataMap["/raw_data_1/instrument/detector_1/dead_time"]);
const auto& data = dead_time.GetData(); const auto& data = dead_time.GetData();
// dump the first couple of raw_times // dump the first couple of raw_times

View File

@@ -872,6 +872,7 @@ class PRawRunData {
virtual const PIntPair GetBkgBin(const UInt_t histoNo) { return fData.GetBkgBin(histoNo); } virtual const PIntPair GetBkgBin(const UInt_t histoNo) { return fData.GetBkgBin(histoNo); }
virtual const PIntPair GetGoodDataBin(const UInt_t histoNo) { return fData.GetGoodDataBin(histoNo); } virtual const PIntPair GetGoodDataBin(const UInt_t histoNo) { return fData.GetGoodDataBin(histoNo); }
virtual const PIntVector GetRedGreenOffset() { return fRedGreenOffset; } virtual const PIntVector GetRedGreenOffset() { return fRedGreenOffset; }
virtual const Bool_t DeadTimeCorrectionReady();
virtual const Int_t GetNumberOfGoodFrames() { return fNumberOfGoodFrames; } virtual const Int_t GetNumberOfGoodFrames() { return fNumberOfGoodFrames; }
virtual const std::vector<float> GetDeadTimeParam() { return fDeadTimeParam; } virtual const std::vector<float> GetDeadTimeParam() { return fDeadTimeParam; }
virtual const UInt_t GetNoOfHistos() { return fData.Size(); } virtual const UInt_t GetNoOfHistos() { return fData.Size(); }

View File

@@ -824,9 +824,9 @@ Bool_t PRunDataHandler::ReadNexusFileIdf2(T& nxs_file)
} }
// get/set deadtime relevant parameters // get/set deadtime relevant parameters
if (nxs_file->HasDataset("/raw_data_1/instrument/detector1/dead_time")) { if (nxs_file->HasDataset("/raw_data_1/instrument/detector_1/dead_time")) {
std::vector<float> dt; std::vector<float> dt;
dt = nxs_file->template GetDataset<float>("/raw_data_1/instrument/detector1/dead_time").GetData(); dt = nxs_file->template GetDataset<float>("/raw_data_1/instrument/detector_1/dead_time").GetData();
runData.SetDeadTimeParam(dt); runData.SetDeadTimeParam(dt);
} }
if (nxs_file->HasDataset("/raw_data_1/good_frames")) { if (nxs_file->HasDataset("/raw_data_1/good_frames")) {