From 385c42d27f6594b500a9a9f7aa35925259c59f05 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Wed, 15 Mar 2023 15:08:10 +0100 Subject: [PATCH] TRestDetectorSignalToRawSignalProcess. InitFromConfigFile removed --- inc/TRestDetectorSignalToRawSignalProcess.h | 2 - src/TRestDetectorSignalToRawSignalProcess.cxx | 80 +++++++------------ 2 files changed, 29 insertions(+), 53 deletions(-) diff --git a/inc/TRestDetectorSignalToRawSignalProcess.h b/inc/TRestDetectorSignalToRawSignalProcess.h index 2b28a79..ba51997 100644 --- a/inc/TRestDetectorSignalToRawSignalProcess.h +++ b/inc/TRestDetectorSignalToRawSignalProcess.h @@ -36,8 +36,6 @@ class TRestDetectorSignalToRawSignalProcess : public TRestEventProcess { /// A pointer to the specific TRestRawSignalEvent input TRestRawSignalEvent* fOutputRawSignalEvent; //! - void InitFromConfigFile() override; - void Initialize() override; protected: diff --git a/src/TRestDetectorSignalToRawSignalProcess.cxx b/src/TRestDetectorSignalToRawSignalProcess.cxx index 0ebb125..6ea0f8f 100644 --- a/src/TRestDetectorSignalToRawSignalProcess.cxx +++ b/src/TRestDetectorSignalToRawSignalProcess.cxx @@ -177,6 +177,35 @@ void TRestDetectorSignalToRawSignalProcess::Initialize() { fOutputRawSignalEvent = new TRestRawSignalEvent(); } +/////////////////////////////////////////////// +/// \brief Some actions taken before start the event data processing +/// +void TRestDetectorSignalToRawSignalProcess::InitProcess() { + if (fTriggerMode == "fixed") { + fTimeStart = fTriggerFixedStartTime - fTriggerDelay * fSampling; + fTimeEnd = fTimeStart + fNPoints * fSampling; + } + + const set validTriggerModes = {"firstDeposit", "integralThreshold", "fixed"}; + if (validTriggerModes.count(fTriggerMode.Data()) == 0) { + RESTError << "Trigger mode set to: '" << fTriggerMode + << "' which is not a valid trigger mode. Please use one of the following trigger modes: "; + for (const auto& triggerMode : validTriggerModes) { + RESTError << triggerMode << " "; + } + RESTError << RESTendl; + exit(1); + } + + if (IsLinearCalibration()) { + const auto range = numeric_limits::max() - numeric_limits::min(); + fCalibrationGain = range * (fCalibrationRange.Y() - fCalibrationRange.X()) / + (fCalibrationEnergy.Y() - fCalibrationEnergy.X()); + fCalibrationOffset = range * (fCalibrationRange.X() - fCalibrationGain * fCalibrationEnergy.X()) + + numeric_limits::min(); + } +} + /////////////////////////////////////////////// /// \brief The main processing event function /// @@ -310,54 +339,3 @@ TRestEvent* TRestDetectorSignalToRawSignalProcess::ProcessEvent(TRestEvent* inpu return fOutputRawSignalEvent; } - -/////////////////////////////////////////////// -/// \brief Function reading input parameters from the RML -/// TRestDetectorSignalToRawSignalProcess metadata section -/// -void TRestDetectorSignalToRawSignalProcess::InitFromConfigFile() { - auto nPoints = GetParameter("nPoints"); - if (nPoints == PARAMETER_NOT_FOUND_STR) { - nPoints = GetParameter("Npoints", fNPoints); - } - fNPoints = StringToInteger(nPoints); - - fTriggerMode = GetParameter("triggerMode", fTriggerMode); - const set validTriggerModes = {"firstDeposit", "integralThreshold", "fixed"}; - if (validTriggerModes.count(fTriggerMode.Data()) == 0) { - RESTError << "Trigger mode set to: '" << fTriggerMode - << "' which is not a valid trigger mode. Please use one of the following trigger modes: "; - for (const auto& triggerMode : validTriggerModes) { - RESTError << triggerMode << " "; - } - RESTError << RESTendl; - exit(1); - } - - fSampling = GetDblParameterWithUnits("sampling", fSampling); - fTriggerDelay = StringToInteger(GetParameter("triggerDelay", fTriggerDelay)); - fIntegralThreshold = StringToDouble(GetParameter("integralThreshold", fIntegralThreshold)); - fTriggerFixedStartTime = GetDblParameterWithUnits("triggerFixedStartTime", fTriggerFixedStartTime); - - fCalibrationGain = StringToDouble(GetParameter("gain", fCalibrationGain)); - fCalibrationOffset = StringToDouble(GetParameter("offset", fCalibrationOffset)); - fCalibrationEnergy = Get2DVectorParameterWithUnits("calibrationEnergy", fCalibrationEnergy); - fCalibrationRange = Get2DVectorParameterWithUnits("calibrationRange", fCalibrationRange); - - if (IsLinearCalibration()) { - const auto range = numeric_limits::max() - numeric_limits::min(); - fCalibrationGain = range * (fCalibrationRange.Y() - fCalibrationRange.X()) / - (fCalibrationEnergy.Y() - fCalibrationEnergy.X()); - fCalibrationOffset = range * (fCalibrationRange.X() - fCalibrationGain * fCalibrationEnergy.X()) + - numeric_limits::min(); - } - - fShapingTime = GetDblParameterWithUnits("shapingTime", fShapingTime); -} - -void TRestDetectorSignalToRawSignalProcess::InitProcess() { - if (fTriggerMode == "fixed") { - fTimeStart = fTriggerFixedStartTime - fTriggerDelay * fSampling; - fTimeEnd = fTimeStart + fNPoints * fSampling; - } -}