Public Member Functions | Private Attributes | List of all members
lbne::Sigmoidfilter Class Reference
Inheritance diagram for lbne::Sigmoidfilter:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 Sigmoidfilter (fhicl::ParameterSet const &pset)
 
virtual ~Sigmoidfilter ()
 
virtual void produce (art::Event &evt) override
 
void reconfigure (fhicl::ParameterSet const &pset)
 
void beginRun (art::Run &run) override
 
void beginJob () override
 
void endRun (art::Run &run) override
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob ()
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Attributes

std::string fDigitModuleLabel
 
std::string fDigitModuleInstance
 
bool fMakeTree
 
TF1 * fColFilterFunc
 Parameterized collection filter function. More...
 
TF1 * fIndUFilterFunc
 Parameterized induction filter function. More...
 
TF1 * fIndVFilterFunc
 Parameterized induction filter function. More...
 
art::ServiceHandle< geo::GeometryfGeom
 
art::ServiceHandle< lbne::ChannelMapService > fChannelMap
 
TH2F * RawFFT
 
TH2F * FixFFT
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 58 of file Sigmoidfilter_module.cc.

Constructor & Destructor Documentation

lbne::Sigmoidfilter::Sigmoidfilter ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 89 of file Sigmoidfilter_module.cc.

89  : EDProducer{pset} {
90  std::string colFilt = pset.get<std::string>("ColFilter");
91  fColFilterFunc = new TF1("colFilter", colFilt.c_str());
92 
93  std::string indUFilt = pset.get<std::string>("IndUFilter");
94  fIndUFilterFunc = new TF1("indUFilter", indUFilt.c_str());
95 
96  std::string indVFilt = pset.get<std::string>("IndVFilter");
97  fIndVFilterFunc = new TF1("indVFilter", indVFilt.c_str());
98 
99 
100  this->reconfigure(pset);
101  produces<std::vector<raw::RawDigit> >();
102 
103 }
TF1 * fIndVFilterFunc
Parameterized induction filter function.
TF1 * fColFilterFunc
Parameterized collection filter function.
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
void reconfigure(fhicl::ParameterSet const &pset)
TF1 * fIndUFilterFunc
Parameterized induction filter function.
lbne::Sigmoidfilter::~Sigmoidfilter ( )
virtual

Definition at line 106 of file Sigmoidfilter_module.cc.

106  {
107 }

Member Function Documentation

void lbne::Sigmoidfilter::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 140 of file Sigmoidfilter_module.cc.

140  {
142  if (fMakeTree) {
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);
145  }
146 }
void lbne::Sigmoidfilter::beginRun ( art::Run run)
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 136 of file Sigmoidfilter_module.cc.

136  {
137  return;
138 }
void lbne::Sigmoidfilter::endRun ( art::Run run)
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 149 of file Sigmoidfilter_module.cc.

149  {
150  return;
151 }
void lbne::Sigmoidfilter::produce ( art::Event evt)
overridevirtual

Implements art::EDProducer.

Definition at line 154 of file Sigmoidfilter_module.cc.

154  {
155 
157 
159  evt.getByLabel(fDigitModuleLabel, fDigitModuleInstance, rawDigitHandle);
160  std::vector<raw::RawDigit> const& rawDigitVector(*rawDigitHandle);
161 
162  std::vector<raw::RawDigit> filterRawDigitVector; // The new Vector of RawDigits
163 
164  // If I want to ignore any frequency ranges....
165  std::vector< std::pair<int,int> > ZeroFreq;
166  //ZeroFreq.push_back( std::make_pair(276 , 285 ) );
167  //ZeroFreq.push_back( std::make_pair(558 , 568 ) );
168  //ZeroFreq.push_back( std::make_pair(837 , 849 ) );
169  //ZeroFreq.push_back( std::make_pair(1116, 1127) );
170  //ZeroFreq.push_back( std::make_pair(4340, 5205) );
171 
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();
176  const geo::View_t view = geo->View(Channel);
177 
178  //std::cout << "Looking at rawDigitVector["<<DigLoop<<"] it was on channel " << rawDigitVector[DigLoop].Channel() << "("<<Channel<<") it is in View " << view
179  // << ", NADC is " << rawDigitVector[DigLoop].NADC() << " ("<<NADC<<")"
180  // << ", pedestal is " << rawDigitVector[DigLoop].GetPedestal() << " ("<<Pedestal<<")"
181  // << std::endl;
182 
183  // Fill the RawDigit histogram for this histogram.
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 );
188  }
189  for (size_t ww=NADC; ww<NADC; ++ww)
190  hRawFFT.SetBinContent( ww, 0 );
191  // Make the FFT for this channel.
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 );
198  }
199  }
200 
201  // I want to do an inverse FFT, so need to convert the tranformed FFT into an array....
202  //double Re[NADC], Im[NADC];
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());
207  delete fft;
208 
209  // Set the noisy frequency range bins to an average value.
210  for (size_t aa=0; aa<ZeroFreq.size(); ++aa) {
211  for (int bb=ZeroFreq[aa].first; bb<ZeroFreq[aa].second; ++bb) {
212  double ReMeanVal=0;
213  double ImMeanVal=0;
214  int Range = 50;
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];
218  }
219  ReMeanVal = ReMeanVal / Range;
220  Re[bb] = Re[1500-bb] = ReMeanVal;
221  ImMeanVal = ImMeanVal / Range;
222  Im[bb] = Im[1500-bb] = ImMeanVal;
223  }
224  }
225 
226  // Apply the filter...
227  for (size_t bin = 0; bin < NADC; ++bin) {
228  double freq = 2000. * bin / NADC;
229  if (view == geo::kU) { // U plane
230  Re[bin] = Re[bin]*fIndUFilterFunc->Eval(freq);
231  Im[bin] = Im[bin]*fIndUFilterFunc->Eval(freq);
232  } else if ( view == geo::kV) { // V plane
233  Re[bin] = Re[bin]*fIndVFilterFunc->Eval(freq);
234  Im[bin] = Im[bin]*fIndVFilterFunc->Eval(freq);
235  } else if ( view == geo::kZ) { // Collection plane
236  Re[bin] = Re[bin]*fColFilterFunc->Eval(freq);
237  Im[bin] = Im[bin]*fColFilterFunc->Eval(freq);
238  }
239 
240  double MagVal = pow ( Re[bin]*Re[bin] + Im[bin]*Im[bin], 0.5);
241  if (TMath::IsNaN(MagVal)) MagVal = 0;
242 
243  // Now do the big histograms...
244  if (freq < 1000 && MagVal < 1e5 && fMakeTree) {
245  FixFFT -> Fill( (Channel-0.5) , freq, MagVal );
246  }
247  }
248 
249  // I have applied the filter so now transform back....
250  int NBins = NADC;
251  TVirtualFFT *fft_back = TVirtualFFT::FFT(1, &NBins, "C2R");
252  fft_back->SetPointsComplex(Re.get(),Im.get());
253  fft_back->Transform();
254  TH1 *hb=0;
255  hb = TH1::TransformHisto(fft_back, hb, "Re");
256  delete fft_back;
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);
261  }
262  delete hb;
263  raw::RawDigit theRawDigit( rawDigitVector[DigLoop].Channel(), NewADC.size(), NewADC );
264  theRawDigit.SetPedestal( rawDigitVector[DigLoop].GetPedestal(), rawDigitVector[DigLoop].GetSigma());
265  filterRawDigitVector.push_back( theRawDigit );
266  } // RawDigit Loop
267 
268  // save filtered waveforms to event
269  evt.put(std::make_unique<decltype(filterRawDigitVector)>(std::move(filterRawDigitVector)));
270  return;
271 }
TF1 * fIndVFilterFunc
Parameterized induction filter function.
TF1 * fColFilterFunc
Parameterized collection filter function.
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Planes which measure V.
Definition: geo_types.h:126
constexpr T pow(T x)
Definition: pow.h:72
Planes which measure Z direction.
Definition: geo_types.h:128
Planes which measure U.
Definition: geo_types.h:125
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:446
def move(depos, offset)
Definition: depos.py:107
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
void SetPedestal(float ped, float sigma=1.)
Set pedestal and its RMS (the latter is 0 by default)
Definition: RawDigit.cxx:68
ChannelMappingService::Channel Channel
QTextStream & bin(QTextStream &s)
TF1 * fIndUFilterFunc
Parameterized induction filter function.
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:730
Namespace collecting geometry-related classes utilities.
void lbne::Sigmoidfilter::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 110 of file Sigmoidfilter_module.cc.

110  {
111  fDigitModuleLabel = pset.get<std::string>("DigitModuleLabel");
112  fDigitModuleInstance = pset.get<std::string>("DigitModuleInstance");
113  fMakeTree = pset.get<bool>("MakeTree");
114 
115  // Make the filter functions.
116  //std::string colFilt = pset.get<std::string>("ColFilter");
117  std::vector<double> colFiltParams = pset.get<std::vector<double> >("ColFilterParams");
118  //fColFilterFunc = new TF1("colFilter", colFilt.c_str());
119  for(unsigned int i=0; i<colFiltParams.size(); ++i)
120  fColFilterFunc->SetParameter(i, colFiltParams[i]);
121 
122  //std::string indUFilt = pset.get<std::string>("IndUFilter");
123  std::vector<double> indUFiltParams = pset.get<std::vector<double> >("IndUFilterParams");
124  //fIndUFilterFunc = new TF1("indUFilter", indUFilt.c_str());
125  for(unsigned int i=0; i<indUFiltParams.size(); ++i)
126  fIndUFilterFunc->SetParameter(i, indUFiltParams[i]);
127 
128  //std::string indVFilt = pset.get<std::string>("IndVFilter");
129  std::vector<double> indVFiltParams = pset.get<std::vector<double> >("IndVFilterParams");
130  //fIndVFilterFunc = new TF1("indVFilter", indVFilt.c_str());
131  for(unsigned int i=0; i<indVFiltParams.size(); ++i)
132  fIndVFilterFunc->SetParameter(i, indVFiltParams[i]);
133 }
TF1 * fIndVFilterFunc
Parameterized induction filter function.
TF1 * fColFilterFunc
Parameterized collection filter function.
std::string string
Definition: nybbler.cc:12
TF1 * fIndUFilterFunc
Parameterized induction filter function.

Member Data Documentation

art::ServiceHandle<lbne::ChannelMapService> lbne::Sigmoidfilter::fChannelMap
private

Definition at line 82 of file Sigmoidfilter_module.cc.

TF1* lbne::Sigmoidfilter::fColFilterFunc
private

Parameterized collection filter function.

Definition at line 77 of file Sigmoidfilter_module.cc.

std::string lbne::Sigmoidfilter::fDigitModuleInstance
private

Definition at line 74 of file Sigmoidfilter_module.cc.

std::string lbne::Sigmoidfilter::fDigitModuleLabel
private

Definition at line 73 of file Sigmoidfilter_module.cc.

art::ServiceHandle<geo::Geometry> lbne::Sigmoidfilter::fGeom
private

Definition at line 81 of file Sigmoidfilter_module.cc.

TF1* lbne::Sigmoidfilter::fIndUFilterFunc
private

Parameterized induction filter function.

Definition at line 78 of file Sigmoidfilter_module.cc.

TF1* lbne::Sigmoidfilter::fIndVFilterFunc
private

Parameterized induction filter function.

Definition at line 79 of file Sigmoidfilter_module.cc.

TH2F* lbne::Sigmoidfilter::FixFFT
private

Definition at line 85 of file Sigmoidfilter_module.cc.

bool lbne::Sigmoidfilter::fMakeTree
private

Definition at line 75 of file Sigmoidfilter_module.cc.

TH2F* lbne::Sigmoidfilter::RawFFT
private

Definition at line 84 of file Sigmoidfilter_module.cc.


The documentation for this class was generated from the following file: