83 #include "TRestRawSignalShapingProcess.h"
111 LoadConfigFromFile(configFilename);
124 SetSectionName(this->ClassName());
125 SetLibraryVersion(LIBRARY_VERSION);
127 fInputSignalEvent =
nullptr;
144 LoadConfigFromFile(configFilename, name);
195 if (fInputSignalEvent->GetNumberOfSignals() <= 0) {
199 std::vector<double> response;
204 if (fShapingType ==
"gaus") {
205 Int_t cBin = (Int_t)(fShapingTime * 3.5);
207 Double_t sigma = fShapingTime;
211 for (
int i = 0; i < Nr; i++) {
212 response[i] = TMath::Exp(-0.5 * (i - cBin) * (i - cBin) / sigma / sigma);
213 response[i] = response[i] / TMath::Sqrt(2 * M_PI) / sigma;
215 }
else if (fShapingType ==
"exponential") {
216 Nr = (Int_t)(5 * fShapingTime);
220 for (
int i = 0; i < Nr; i++) {
221 Double_t coeff = ((Double_t)i) / fShapingTime;
222 response[i] = TMath::Exp(-coeff);
224 }
else if (fShapingType ==
"shaper") {
225 Nr = (Int_t)(5 * fShapingTime);
229 for (
int i = 0; i < Nr; i++) {
230 Double_t coeff = ((Double_t)i) / fShapingTime;
231 response[i] = TMath::Exp(-3. * coeff) * coeff * coeff * coeff;
233 }
else if (fShapingType ==
"shaperSin") {
234 Nr = (Int_t)(5 * fShapingTime);
238 for (
int i = 0; i < Nr; i++) {
239 Double_t coeff = ((Double_t)i) / fShapingTime;
240 response[i] = TMath::Exp(-3. * coeff) * coeff * coeff * coeff * sin(coeff);
243 if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Warning)
244 cout <<
"REST WARNING. Shaping type : " << fShapingType <<
" is not defined!!" << endl;
250 for (
int n = 0; n < Nr; n++) sum += response[n];
251 for (
int n = 0; n < Nr; n++) response[n] = response[n] * fShapingGain / sum;
253 for (
int n = 0; n < fInputSignalEvent->GetNumberOfSignals(); n++) {
258 vector<double> out(nBins);
259 for (
int m = 0; m < nBins; m++) out[m] = 0;
261 for (
int m = 0; m < nBins; m++) {
262 if (inSignal.
GetData(m) >= 0) {
263 if (fShapingType ==
"gaus") {
264 for (
int n = -Nr / 2; m + n < nBins && n < Nr / 2; n++)
265 if (m + n >= 0) out[m + n] += response[n + Nr / 2] * inSignal.
GetData(m);
267 for (
int n = 0; m + n < nBins && n < Nr; n++)
268 out[m + n] += response[n] * inSignal.
GetData(m);
272 for (
int i = 0; i < nBins; i++) {
273 shapingSignal.
AddPoint((Short_t)round(out[i]));
277 fOutputSignalEvent->AddSignal(shapingSignal);
280 return fOutputSignalEvent;
A base class for any REST event.
An event container for time rawdata signals with fixed length.
void Initialize() override
Function to initialize input/output event members and define the section name.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
void EndProcess() override
Function to include required actions after all events have been processed.
~TRestRawSignalShapingProcess()
Default destructor.
void LoadConfig(const std::string &configFilename, const std::string &name="")
Function to load the configuration from an external configuration file.
TRestRawSignalShapingProcess()
Default constructor.
void InitProcess() override
Process initialization. Observable names are interpreted and auxiliar observable members,...
It defines a Short_t array with a physical parameter that evolves in time using a fixed time bin.
void SetSignalID(Int_t sID)
It sets the id number of the signal.
Double_t GetData(Int_t n) const
It returns the data value of point n including baseline correction.
void AddPoint(Short_t)
Adds a new point to the end of the signal data array.
Int_t GetSignalID() const
Returns the value of signal ID.
Int_t GetNumberOfPoints() const
Returns the actual number of points, or size of the signal.