1 #ifndef SIGMOIDFILTER_H 2 #define SIGMOIDFILTER_H 19 #include "art_root_io/TFileService.h" 20 #include "art_root_io/TFileDirectory.h" 35 #include "lbne-raw-data/Services/ChannelMap/ChannelMapService.h" 51 #include "TVirtualFFT.h" 101 produces<std::vector<raw::RawDigit> >();
117 std::vector<double> colFiltParams = pset.
get<std::vector<double> >(
"ColFilterParams");
119 for(
unsigned int i=0; i<colFiltParams.size(); ++i)
123 std::vector<double> indUFiltParams = pset.
get<std::vector<double> >(
"IndUFilterParams");
125 for(
unsigned int i=0; i<indUFiltParams.size(); ++i)
129 std::vector<double> indVFiltParams = pset.
get<std::vector<double> >(
"IndVFilterParams");
131 for(
unsigned int i=0; i<indVFiltParams.size(); ++i)
143 RawFFT = tfs->make<TH2F>(
"RawFFT",
"Raw FFT for all channels less than 1000 KHz; Channel Number; Frequency (KHz)" , 2048, 0, 2048, 1000, 0, 1000);
144 FixFFT = tfs->make<TH2F>(
"FixFFT",
"FFT for all channels less than 1000 KHz after filtering; Channel Number; Frequency (KHz)", 2048, 0, 2048, 1000, 0, 1000);
160 std::vector<raw::RawDigit>
const& rawDigitVector(*rawDigitHandle);
162 std::vector<raw::RawDigit> filterRawDigitVector;
165 std::vector< std::pair<int,int> > ZeroFreq;
172 for (
size_t DigLoop=0; DigLoop < rawDigitVector.size(); ++DigLoop) {
173 int Channel = rawDigitVector[DigLoop].Channel();
174 size_t NADC = rawDigitVector[DigLoop].NADC();
175 double Pedestal = rawDigitVector[DigLoop].GetPedestal();
184 TH1F hRawDigit(
"hRawDigit",
"",NADC,0,NADC/2);
185 TH1F hRawFFT(
"hRawFFT" ,
"",NADC,0,NADC);
186 for (
size_t ADCs=0; ADCs < NADC; ++ADCs) {
187 hRawDigit.SetBinContent( ADCs+1, rawDigitVector[DigLoop].ADC(ADCs)-Pedestal );
189 for (
size_t ww=NADC; ww<NADC; ++ww)
190 hRawFFT.SetBinContent( ww, 0 );
192 hRawDigit.FFT( (&hRawFFT) ,
"MAG");
193 for (
size_t bin = 0;
bin < NADC; ++
bin) {
194 double BinVal = hRawFFT.GetBinContent(
bin+1);
195 double freq = 2000. *
bin / (double)NADC;
196 if (freq < 1000 && BinVal < 1e5 &&
fMakeTree) {
197 RawFFT->Fill( (Channel-0.5) , freq, BinVal );
203 std::unique_ptr<double[]> Re(
new double[NADC]);
204 std::unique_ptr<double[]> Im(
new double[NADC]);
205 TVirtualFFT *fft = TVirtualFFT::GetCurrentTransform();
206 fft->GetPointsComplex(Re.get(),Im.get());
210 for (
size_t aa=0; aa<ZeroFreq.size(); ++aa) {
211 for (
int bb=ZeroFreq[aa].first; bb<ZeroFreq[aa].second; ++bb) {
215 for (
int cc=0; cc<Range; ++cc) {
216 ReMeanVal += Re[ZeroFreq[aa].first-cc] + Re[ZeroFreq[aa].second+cc];
217 ImMeanVal += Im[ZeroFreq[aa].first-cc] + Im[ZeroFreq[aa].second+cc];
219 ReMeanVal = ReMeanVal / Range;
220 Re[bb] = Re[1500-bb] = ReMeanVal;
221 ImMeanVal = ImMeanVal / Range;
222 Im[bb] = Im[1500-bb] = ImMeanVal;
227 for (
size_t bin = 0;
bin < NADC; ++
bin) {
228 double freq = 2000. *
bin / NADC;
241 if (TMath::IsNaN(MagVal)) MagVal = 0;
244 if (freq < 1000 && MagVal < 1e5 &&
fMakeTree) {
245 FixFFT -> Fill( (Channel-0.5) , freq, MagVal );
251 TVirtualFFT *fft_back = TVirtualFFT::FFT(1, &NBins,
"C2R");
252 fft_back->SetPointsComplex(Re.get(),Im.get());
253 fft_back->Transform();
255 hb = TH1::TransformHisto(fft_back, hb,
"Re");
257 std::vector<short> NewADC;
258 for (
int BinNum=0; BinNum<NBins; ++BinNum) {
259 short Val = rawDigitVector[DigLoop].GetPedestal() + hb->GetBinContent(BinNum+1) / NBins;
260 NewADC.push_back( Val);
264 theRawDigit.
SetPedestal( rawDigitVector[DigLoop].GetPedestal(), rawDigitVector[DigLoop].GetSigma());
265 filterRawDigitVector.push_back( theRawDigit );
269 evt.
put(std::make_unique<decltype(filterRawDigitVector)>(
std::move(filterRawDigitVector)));
275 #endif //SIGMOIDFILTER_H TF1 * fIndVFilterFunc
Parameterized induction filter function.
TF1 * fColFilterFunc
Parameterized collection filter function.
Collection of charge vs time digitized from a single readout channel.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
EDProducer(fhicl::ParameterSet const &pset)
std::string fDigitModuleLabel
art::ServiceHandle< lbne::ChannelMapService > fChannelMap
Definition of basic raw digits.
Planes which measure Z direction.
void beginRun(art::Run &run) override
void reconfigure(fhicl::ParameterSet const &pset)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
#define DEFINE_ART_MODULE(klass)
T get(std::string const &key) const
art::ServiceHandle< geo::Geometry > fGeom
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
std::string fDigitModuleInstance
void SetPedestal(float ped, float sigma=1.)
Set pedestal and its RMS (the latter is 0 by default)
ChannelMappingService::Channel Channel
QTextStream & bin(QTextStream &s)
Interface for experiment-specific channel quality info provider.
virtual void produce(art::Event &evt) override
void endRun(art::Run &run) override
Sigmoidfilter(fhicl::ParameterSet const &pset)
Interface for experiment-specific service for channel quality info.
TF1 * fIndUFilterFunc
Parameterized induction filter function.
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Namespace collecting geometry-related classes utilities.