REST version: v2.3.12
Commit: 0cf8f3c8 (2022-04-25 16:40:49 +0200)
Hi,
I have noticed that TRestRawSignalShapingProcess
is affecting the energy of the processed event(which should not in my opinion)
I use gaus convolution in my case.
To test that, I generated simple RawSignal
events with only one signal and only one time-bin (Dirac-like signal):
The amplitude of the signal corresponds to the total integral over DetectorSignal
event. And initial events themselves I generated in restG4
Thus, when I look at the residual between primaryEnergy
from G4analysis and FullIntegral
from RawSignalAnalysis:
AnalysisTree->Draw("g4Ana_energyPrimary-sAna_FullIntegral >> h1")
it peaks at zero:
However, when I apply TRestRawSignalShapingProcess
on my RawSignal events the residual b/w primaryEnergy
and FullIntegral
is shifted:
I don’t know why this is happening as the gaussian convolution in the code is being normalized to one and should not affect the total energy of the event:
/// It is the response function. Does not change from event ot event
if (fShapingType == "gaus") {
Int_t cBin = (Int_t)(fShapingTime * 3.5);
Nr = 2 * cBin;
Double_t sigma = fShapingTime;
rsp = new double[Nr];
for (int i = 0; i < Nr; i++) {
rsp[i] = TMath::Exp(-0.5 * (i - cBin) * (i - cBin) / sigma / sigma);
rsp[i] = rsp[i] / TMath::Sqrt(2 * M_PI) / sigma;
}
***
/ Making sure that rsp integral is 1, and applying the gain
Double_t sum = 0;
for (int n = 0; n < Nr; n++) sum += rsp[n];
for (int n = 0; n < Nr; n++) rsp[n] = rsp[n] * fShapingGain / sum;
for (int n = 0; n < fInputSignalEvent->GetNumberOfSignals(); n++) {
TRestRawSignal shapingSignal = TRestRawSignal();
TRestRawSignal inSignal = *fInputSignalEvent->GetSignal(n);
Int_t nBins = inSignal.GetNumberOfPoints();
vector<double> out(nBins);
for (int m = 0; m < nBins; m++) out[m] = 0;
for (int m = 0; m < nBins; m++) {
if (inSignal.GetData(m) >= 0) {
if (fShapingType == "gaus") {
for (int n = -Nr / 2; m + n < nBins && n < Nr / 2; n++)
if (m + n >= 0) out[m + n] += rsp[n + Nr / 2] * inSignal.GetData(m);
} else
for (int n = 0; m + n < nBins && n < Nr; n++) out[m + n] += rsp[n] * inSignal.GetData(m);
}
}
***
Thank you in advance for any help
Andrii