86 #include "TRestRawCommonNoiseReductionProcess.h"
116 if (LoadConfigFromFile(configFilename)) LoadDefaultConfig();
137 SetSectionName(this->ClassName());
138 SetLibraryVersion(LIBRARY_VERSION);
140 fInputEvent =
nullptr;
157 if (LoadConfigFromFile(configFilename, name)) LoadDefaultConfig();
171 if (fInputEvent->GetNumberOfSignals() < fMinSignalsRequired) {
172 for (
int sgnl = 0; sgnl < fInputEvent->GetNumberOfSignals(); sgnl++) {
173 fOutputEvent->AddSignal(*fInputEvent->GetSignal(sgnl));
179 Double_t baseLineMean = 0;
180 for (
int sgnl = 0; sgnl < fInputEvent->GetNumberOfSignals(); sgnl++) {
181 fInputEvent->GetSignal(sgnl)->CalculateBaseLine(20, 150);
182 Double_t baseline = fInputEvent->GetSignal(sgnl)->GetBaseLine();
183 baseLineMean += baseline;
185 Double_t Baseline = baseLineMean / fInputEvent->GetNumberOfSignals();
188 Int_t N = fInputEvent->GetNumberOfSignals();
191 for (
int sgnl = 0; sgnl < N; sgnl++) {
192 fOutputEvent->AddSignal(*fInputEvent->GetSignal(sgnl));
195 Int_t nBins = fInputEvent->GetSignal(0)->GetNumberOfPoints();
196 vector<Double_t> sgnlValues(N, 0.0);
198 for (Int_t bin = 0; bin < nBins; bin++) {
199 for (Int_t sgnl = 0; sgnl < N; sgnl++) {
200 sgnlValues[sgnl] = fOutputEvent->GetSignal(sgnl)->GetRawData(bin);
203 std::sort(sgnlValues.begin(), sgnlValues.end());
206 Int_t begin = 0, middle = 0, end = 0;
207 middle = (Int_t)N / 2;
212 begin = (Int_t)((double_t)N / 2.0);
215 }
else if (fMode == 1) {
217 begin = middle - (Int_t)(N * fCenterWidth * 0.01);
218 end = middle + (Int_t)(N * fCenterWidth * 0.01);
219 norm = (Double_t)end - begin;
223 Double_t binCorrection = 0.0;
224 for (Int_t i = begin; i <= end; i++) binCorrection += sgnlValues[i];
226 binCorrection = binCorrection / norm;
229 for (Int_t sgnl = 0; sgnl < N; sgnl++)
230 fOutputEvent->GetSignal(sgnl)->IncreaseBinBy(bin, Baseline - binCorrection);
234 }
else if (fBlocks == 1) {
244 for (
int block = 0; block < nBlocks; block++) {
245 firstInBlock = firstID + block * (N + gap);
249 for (Int_t sgnl = 0; sgnl < N; sgnl++) {
250 sigID = firstInBlock + sgnl;
251 fInputEvent->GetSignalById(sigID)->CalculateBaseLine(20, 500);
252 if (fInputEvent->GetSignalById(sigID)->GetBaseLineSigma() >= 3.3) {
256 fOutputEvent->AddSignal(*fInputEvent->GetSignalById(sigID));
261 Int_t nBins = fInputEvent->GetSignal(0)->GetNumberOfPoints();
262 vector<Double_t> sgnlValues(nSign, 0.0);
266 for (Int_t bin = 0; bin < nBins; bin++) {
268 for (Int_t sgnl = 0; sgnl < N; sgnl++) {
269 sigID = firstInBlock + sgnl;
270 if (fInputEvent->GetSignalById(sigID)->GetBaseLineSigma() >= 3.3) {
276 sgnlValues[i] = fOutputEvent->GetSignalById(sigID)->GetRawData(bin);
281 std::sort(sgnlValues.begin(), sgnlValues.end());
284 Int_t begin = 0, middle = 0, end = 0;
285 middle = (Int_t)nSign / 2;
290 begin = (Int_t)((double_t)nSign / 2.0);
293 }
else if (fMode == 1) {
295 begin = middle - (Int_t)(nSign * fCenterWidth * 0.01);
296 end = middle + (Int_t)(nSign * fCenterWidth * 0.01);
297 norm = (Double_t)end - begin;
301 Double_t binCorrection = 0.0;
302 for (Int_t i = begin; i <= end; i++) binCorrection += sgnlValues[i];
304 binCorrection = binCorrection / norm;
307 for (Int_t sgnl = 0; sgnl < N; sgnl++) {
308 if (fInputEvent->GetSignalById(firstInBlock + sgnl)->GetBaseLineSigma() >= 3.3) {
309 fOutputEvent->GetSignalById(firstInBlock + sgnl)
310 ->IncreaseBinBy(bin, Baseline - binCorrection);
314 for (
int sgnl = 0; sgnl < N; sgnl++) {
315 if (fInputEvent->GetSignalById(firstInBlock + sgnl)->GetBaseLineSigma() < 3.3) {
316 fOutputEvent->AddSignal(*fInputEvent->GetSignalById(firstInBlock + sgnl));
A base class for any REST event.
A process to subtract the common channels noise from RawSignal type.
void Initialize() override
Function to initialize input/output event members and define the section name.
~TRestRawCommonNoiseReductionProcess()
Default destructor.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
void EndProcess() override
Function to include required actions after all events have been processed. This method will write the...
TRestRawCommonNoiseReductionProcess()
Default constructor.
void LoadDefaultConfig()
Function to load the default config in absence of RML input.
void InitProcess() override
Process initialization.
void LoadConfig(const std::string &configFilename, const std::string &name="")
Function to load the configuration from an external configuration file.
An event container for time rawdata signals with fixed length.