// SPDX-License-Identifier: LGPL-3.0-or-other // Copyright (C) 2021 Contributors to the SLS Detector Package #ifndef COMMONMODESUBTRACTION_H #define COMMONMODESUBTRACTION_H #include "MovingStat.h" class commonModeSubtraction { /** @short class to calculate the common mode of the pedestals based on an approximated moving average*/ public: /** constructor \param nn number of samples for the moving average to calculate the average common mode \param iroi number of regions on which one can calculate the common mode separately. Defaults to 1 i.e. whole detector */ commonModeSubtraction(int nn=1000, int iroi=1) : cmStat(NULL), cmPed(NULL), nCm(NULL), nROI(iroi) {cmStat=new MovingStat[nROI]; for (int i=0; i0) cmStat[i].Calc(cmPed[i]/nCm[i]); nCm[i]=0; cmPed[i]=0; }}; /** adds the pixel to the sum of pedestals -- virtual func must be overloaded to define the regions of interest \param val value to add \param ix pixel x coordinate \param iy pixel y coordinate */ virtual void addToCommonMode(double val, int ix=0, int iy=0) { (void) ix; (void) iy; //if (isc>=0 && isc0) return cmPed[0]/nCm[0]-cmStat[0].Mean(); return 0;}; protected: MovingStat *cmStat; /**