Skip to content

Commit

Permalink
Merge pull request #31 from rest-for-physics/jgalan_signalToRaw_update
Browse files Browse the repository at this point in the history
TRestDetectorSignalToRawSignalProcess. InitFromConfigFile removed
  • Loading branch information
jgalan authored Mar 17, 2023
2 parents 9ce3fa7 + 385c42d commit 94f0551
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 53 deletions.
2 changes: 0 additions & 2 deletions inc/TRestDetectorSignalToRawSignalProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class TRestDetectorSignalToRawSignalProcess : public TRestEventProcess {
/// A pointer to the specific TRestRawSignalEvent input
TRestRawSignalEvent* fOutputRawSignalEvent; //!

void InitFromConfigFile() override;

void Initialize() override;

protected:
Expand Down
80 changes: 29 additions & 51 deletions src/TRestDetectorSignalToRawSignalProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> 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<Short_t>::max() - numeric_limits<Short_t>::min();
fCalibrationGain = range * (fCalibrationRange.Y() - fCalibrationRange.X()) /
(fCalibrationEnergy.Y() - fCalibrationEnergy.X());
fCalibrationOffset = range * (fCalibrationRange.X() - fCalibrationGain * fCalibrationEnergy.X()) +
numeric_limits<Short_t>::min();
}
}

///////////////////////////////////////////////
/// \brief The main processing event function
///
Expand Down Expand Up @@ -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<string> 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<Short_t>::max() - numeric_limits<Short_t>::min();
fCalibrationGain = range * (fCalibrationRange.Y() - fCalibrationRange.X()) /
(fCalibrationEnergy.Y() - fCalibrationEnergy.X());
fCalibrationOffset = range * (fCalibrationRange.X() - fCalibrationGain * fCalibrationEnergy.X()) +
numeric_limits<Short_t>::min();
}

fShapingTime = GetDblParameterWithUnits("shapingTime", fShapingTime);
}

void TRestDetectorSignalToRawSignalProcess::InitProcess() {
if (fTriggerMode == "fixed") {
fTimeStart = fTriggerFixedStartTime - fTriggerDelay * fSampling;
fTimeEnd = fTimeStart + fNPoints * fSampling;
}
}

0 comments on commit 94f0551

Please sign in to comment.