move DeadTimeCorrection to PRunBase. Make ADDRUN part in PrepareData more readable.
This commit is contained in:
@@ -159,6 +159,55 @@ PRunBase::~PRunBase()
|
||||
fFuncValues.clear();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// DeadTimeCorrection (protected)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* \brief carry out dead time correction
|
||||
*
|
||||
* \param histos histograms to be corrected
|
||||
* \param histoNo histogram numbers
|
||||
*/
|
||||
void PRunBase::DeadTimeCorrection(std::vector<PDoubleVector> &histos, PUIntVector &histoNo)
|
||||
{
|
||||
PRawRunData* runData = fRawData->GetRunData(*fRunInfo->GetRunName());
|
||||
|
||||
if (!runData->DeadTimeCorrectionReady())
|
||||
return;
|
||||
|
||||
|
||||
// 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<histos[i].size(); j++) {
|
||||
n_true = histos[i][j] / (1.0 - histos[i][j] * t_dt[histoNo[i]] / (gf * fTimeResolution));
|
||||
histos[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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// SetFitRange (public)
|
||||
|
||||
Reference in New Issue
Block a user