117#include "TRestDetectorSignalToRawSignalProcess.h"
189 const set<string> validTriggerModes = {
"firstDeposit",
"integralThreshold",
"fixed"};
190 if (validTriggerModes.count(
fTriggerMode.Data()) == 0) {
192 <<
"' which is not a valid trigger mode. Please use one of the following trigger modes: ";
193 for (
const auto& triggerMode : validTriggerModes) {
194 RESTError << triggerMode <<
" ";
200 if (IsLinearCalibration()) {
201 const auto range = numeric_limits<Short_t>::max() - numeric_limits<Short_t>::min();
205 numeric_limits<Short_t>::min();
232 bool thresholdReached =
false;
240 thresholdReached =
true;
243 if (!thresholdReached) {
244 RESTWarning <<
"Integral threshold for trigger not reached" <<
RESTendl;
250 RESTDebug <<
"fTimeStart : " << fTimeStart <<
" us " <<
RESTendl;
251 RESTDebug <<
"fTimeEnd : " << fTimeEnd <<
" us " <<
RESTendl;
254 vector<Double_t> data(
fNPoints, fCalibrationOffset);
256 Int_t signalID = signal->GetSignalID();
258 for (
int m = 0; m < signal->GetNumberOfPoints(); m++) {
259 Double_t t = signal->GetTime(m);
260 Double_t d = signal->GetData(m);
263 cout <<
"Signal : " << n <<
" Sample : " << m <<
" T : " << t <<
" Data : " << d << endl;
266 if (t > fTimeStart && t < fTimeEnd) {
268 Int_t timeBin = (Int_t)round((t - fTimeStart) /
fSampling);
270 if (
GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Warning) {
271 if (timeBin < 0 || timeBin >
fNPoints) {
272 cout <<
"Time bin out of range!!! bin value : " << timeBin << endl;
277 RESTDebug <<
"Adding data : " << signal->GetData(m) <<
" to Time Bin : " << timeBin
283 if (IsShapingEnabled()) {
284 const auto shapingFunction = [](Double_t t) -> Double_t {
290 return TMath::Exp(-3.0 * t) * TMath::Power(t, 3.0) * TMath::Sin(t) * 22.68112123672292;
293 vector<Double_t> dataAfterShaping(
fNPoints, fCalibrationOffset);
294 for (
int i = 0; i <
fNPoints; i++) {
295 const Double_t value = data[i] - fCalibrationOffset;
300 for (
int j = 0; j <
fNPoints; j++) {
304 data = dataAfterShaping;
309 for (
int x = 0; x <
fNPoints; x++) {
310 double value = round(data[x]);
311 if (
GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Warning) {
312 if (value < numeric_limits<Short_t>::min() || value > numeric_limits<Short_t>::max()) {
313 RESTWarning <<
"value (" << value <<
") is outside short range ("
314 << numeric_limits<Short_t>::min() <<
", " << numeric_limits<Short_t>::max()
319 if (value < numeric_limits<Short_t>::min()) {
320 value = numeric_limits<Short_t>::min();
322 }
else if (value > numeric_limits<Short_t>::max()) {
323 value = numeric_limits<Short_t>::max();
332 RESTDebug <<
"Adding signal to raw signal event" <<
RESTendl;
337 RESTDebug <<
"TRestDetectorSignalToRawSignalProcess. Returning event with N signals "
A process to convert a TRestDetectorSignalEvent into a TRestRawSignalEvent.
TVector2 fCalibrationEnergy
two distinct energy values used for calibration
TRestDetectorSignalEvent * fInputSignalEvent
A pointer to the specific TRestDetectorSignalEvent input.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
Double_t fSampling
The sampling time from the binned raw output signal.
void Initialize() override
Function to initialize input/output event members and define the section name.
void InitProcess() override
Some actions taken before start the event data processing.
TRestRawSignalEvent * fOutputRawSignalEvent
A pointer to the specific TRestRawSignalEvent input.
TVector2 fCalibrationRange
position in the range corresponding to the energy in 'fCalibrationEnergy'. Values between 0 and 1
Double_t fIntegralThreshold
This parameter is used by integralWindow trigger mode to define the acquisition window.
TString fTriggerMode
It is used to define the way the time start will be fixed.
Int_t fNPoints
The number of points of the resulting output signal.
TRestDetectorSignalToRawSignalProcess()
Default constructor.
~TRestDetectorSignalToRawSignalProcess()
Default destructor.
Int_t fTriggerFixedStartTime
The starting time for the "fixed" trigger mode (can be offset by the trigger delay)
Double_t fCalibrationGain
Int_t fTriggerDelay
The number of time bins the time start is delayed in the resulting output signal.
void LoadConfig(const std::string &configFilename, const std::string &name="")
Function to load the configuration from an external configuration file.
A base class for any REST event.
An event container for time rawdata signals with fixed length.
It defines a Short_t array with a physical parameter that evolves in time using a fixed time bin.
void Print() const
It prints the signal data on screen.
void SetSignalID(Int_t sID)
It sets the id number of the signal.
void AddPoint(Short_t)
Adds a new point to the end of the signal data array.
@ REST_Debug
+show the defined debug messages