Public Member Functions | Private Attributes | List of all members
DAQToOffline::FilterAnalyzer Class Reference
Inheritance diagram for DAQToOffline::FilterAnalyzer:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 FilterAnalyzer (fhicl::ParameterSet const &pset)
 
 FilterAnalyzer (FilterAnalyzer const &)=delete
 
 FilterAnalyzer (FilterAnalyzer &&)=delete
 
FilterAnalyzeroperator= (FilterAnalyzer const &)=delete
 
FilterAnalyzeroperator= (FilterAnalyzer &&)=delete
 
void analyze (art::Event const &evt) override
 
void reconfigure (const fhicl::ParameterSet &pset)
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
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::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
- 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 fMakeADCPlots
 
TF1 * fColFilterFunc
 Parameterized collection filter function. More...
 
TF1 * fIndUFilterFunc
 Parameterized induction filter function. More...
 
TF1 * fIndVFilterFunc
 Parameterized induction filter function. More...
 
const lariov::DetPedestalProviderfPedestalRetrievalAlg = *(lar::providerFrom<lariov::DetPedestalService>())
 
TH1F * RawDigitHistos [2048]
 
TH1F * RawDigitFFT [2048]
 
TH1F * RawDigitFFTCorrect [2048]
 
TH1F * RawDigitFFTChannel [2048]
 
TH1F * RawDigitFFTChannelFilter [2048]
 
TH1F * RawDigitInvFFT [2048]
 
TH2F * RawFFT_100KHz
 
TH2F * FixFFT_100KHz
 
TH2F * RawFFT_1000KHz
 
TH2F * FixFFT_1000KHz
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &paths, fhicl::ParameterSet const &config)
 
detail::ProcessAndEventSelectorsprocessAndEventSelectors ()
 
- 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 63 of file FilterAnalyzer_module.cc.

Constructor & Destructor Documentation

DAQToOffline::FilterAnalyzer::FilterAnalyzer ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 104 of file FilterAnalyzer_module.cc.

104  : art::EDAnalyzer(pset) {
105 
106  this->reconfigure(pset);
107  gStyle->SetOptStat(0);
108 
110  RawFFT_100KHz = tfs->make<TH2F>("RawFFT_100KHz" , "Raw FFT for all channels less than 100 KHz; Channel Number; Frequency (KHz)" , 2048, 0, 2048, 100, 0, 100 );
111  FixFFT_100KHz = tfs->make<TH2F>("FixFFT_100KHz" , "FFT for all channels less than 100 KHz after filtering; Channel Number; Frequency (KHz)" , 2048, 0, 2048, 100, 0, 100 );
112  RawFFT_1000KHz = tfs->make<TH2F>("RawFFT_1000KHz", "Raw FFT for all channels less than 1000 KHz; Channel Number; Frequency (KHz)" , 2048, 0, 2048, 1000, 0, 1000);
113  FixFFT_1000KHz = tfs->make<TH2F>("FixFFT_1000KHz", "FFT for all channels less than 1000 KHz after filtering; Channel Number; Frequency (KHz)", 2048, 0, 2048, 1000, 0, 1000);
114 
115  int NumBins = 15000;
116  for (int HistoChan=0; HistoChan<2048; HistoChan++) {
117 
118  // Make the RawDigit Histograms....
119  std::stringstream oss1, oss2;
120  oss1 << "RawDigit_"<<HistoChan;
121  oss2 << "Raw Digit for Channel "<<HistoChan<<"; Time (us); ADC";
122  std::string Name1 = oss1.str();
123  std::string Title1= oss2.str();
124  if (fMakeADCPlots) RawDigitHistos[HistoChan] = tfs->make<TH1F>(Name1.c_str(), Title1.c_str(), NumBins, 0, NumBins/2);
125  else RawDigitHistos[HistoChan] = new TH1F(Name1.c_str(), Title1.c_str(), NumBins, 0, NumBins/2);
126 
127  // Make the FFT Histograms....
128  std::stringstream oss3, oss3a, oss4;
129  oss3 << "FFT_"<<HistoChan;
130  oss3a << "FFT_"<<HistoChan<<"_correct";
131  oss4 << "FFT of Raw Digit for Channel "<<HistoChan<< " in frequency domain";
132  std::string Name2 = oss3.str();
133  std::string Name2a= oss3a.str();
134  std::string Title2= oss4.str();
135  RawDigitFFT[HistoChan] = new TH1F(Name2.c_str(), Title2.c_str(), NumBins, 0, NumBins);
136  RawDigitFFTCorrect[HistoChan] = new TH1F(Name2a.c_str(),Title2.c_str(), NumBins, 0, NumBins);
137 
138  // Make the FFT Channel Histograms....
139  std::stringstream oss5, oss5a, oss6;
140  oss5 << "ChanFFT_"<<HistoChan;
141  oss6 << "FFT of Raw Digit for Channel "<<HistoChan<<"; Frequency (KHz); Number";
142  std::string Name3 = oss5.str();
143  std::string Title3= oss6.str();
144  RawDigitFFTChannel[HistoChan] = new TH1F(Name3.c_str(), Title3.c_str(), NumBins, 0, 2000);
145 
146  // Make the FFT Channel after filter Histograms....
147  std::stringstream oss9, oss10;
148  oss9 << "ChanFFT_"<<HistoChan<<"_Filter";
149  oss10 << "FFT of Raw Digit for Channel "<<HistoChan<<" after filter is applied; Frequency (KHz); Number";
150  std::string Name5 = oss9.str();
151  std::string Title5= oss10.str();
152  RawDigitFFTChannelFilter[HistoChan] = new TH1F(Name5.c_str(), Title5.c_str(), NumBins, 0, 2000);
153 
154  // Make the Inverse FFT Histograms....
155  std::stringstream oss7, oss8;
156  oss5 << "InvFFT_"<<HistoChan;
157  oss6 << "Inverse FFT of the FFT Channel "<<HistoChan<<" histogram; Time (us); ADC";
158  std::string Name4 = oss5.str();
159  std::string Title4= oss6.str();
160  RawDigitInvFFT[HistoChan] = new TH1F(Name4.c_str(), Title4.c_str(), NumBins, 0, NumBins/2);
161  }
162 }
std::string string
Definition: nybbler.cc:12
void reconfigure(const fhicl::ParameterSet &pset)
DAQToOffline::FilterAnalyzer::FilterAnalyzer ( FilterAnalyzer const &  )
delete
DAQToOffline::FilterAnalyzer::FilterAnalyzer ( FilterAnalyzer &&  )
delete

Member Function Documentation

void DAQToOffline::FilterAnalyzer::analyze ( art::Event const &  evt)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 188 of file FilterAnalyzer_module.cc.

188  {
189 
191 
193  evt.getByLabel(fDigitModuleLabel, fDigitModuleInstance, rawDigitHandle);
194  std::vector<raw::RawDigit> const& rawDigitVector(*rawDigitHandle);
195 
196  std::vector< std::pair<int,int> > ZeroFreq;
197  //ZeroFreq.push_back( std::make_pair(276 , 285 ) );
198  //ZeroFreq.push_back( std::make_pair(558 , 568 ) );
199  //ZeroFreq.push_back( std::make_pair(837 , 849 ) );
200  //ZeroFreq.push_back( std::make_pair(1116, 1127) );
201  //ZeroFreq.push_back( std::make_pair(4340, 5205) );
202 
203  for (size_t DigLoop=0; DigLoop < rawDigitVector.size(); ++DigLoop) {
204 
205  int Channel = rawDigitVector[DigLoop].Channel();
206  size_t NADC = rawDigitVector[DigLoop].NADC();
207  double Pedestal = rawDigitVector[DigLoop].GetPedestal();
208  const geo::View_t view = geo->View(Channel);
209  //std::cout << "Looking at rawDigitVector["<<DigLoop<<"] it was on channel " << rawDigitVector[DigLoop].Channel() << "("<<Channel<<") it is in View " << view
210  // << ", NADC is " << rawDigitVector[DigLoop].NADC() << " ("<<NADC<<")"
211  // << ", pedestal is " << rawDigitVector[DigLoop].GetPedestal() << " ("<<Pedestal<<")"
212  // << std::endl;
213 
214  // Fill the RawDigit histogram for this histogram.
215  for (size_t ADCs=0; ADCs < NADC; ++ADCs) {
216  RawDigitHistos[Channel] -> SetBinContent( ADCs+1, rawDigitVector[DigLoop].ADC(ADCs)-Pedestal );
217  }
218  for (int ww=NADC; ww<16384; ++ww)
219  RawDigitHistos[Channel] -> SetBinContent( ww, 0 );
220  // Make the FFT for this channel.
221  RawDigitHistos[Channel] -> FFT( RawDigitFFT[Channel] ,"MAG");
222  for (int bin = 0; bin < RawDigitFFTCorrect[Channel]->GetNbinsX(); ++bin) {
223  double BinVal = RawDigitFFT[Channel]->GetBinContent(bin+1);
224  RawDigitFFTCorrect[Channel] -> SetBinContent(bin+1, BinVal );
225  double freq = 2000. * bin / (double)RawDigitFFTCorrect[Channel]->GetNbinsX();
226  if (freq < 1000 && BinVal < 1e5) {
227  RawFFT_1000KHz -> Fill( Channel,freq, BinVal);
228  if (freq < 100) {
229  RawFFT_100KHz-> Fill( Channel,freq, BinVal);
230  }
231  }
232  }
233 
234  // I want to do an inverse FFT, so need to convert the tranformed FFT into an array....
235  int NBins = RawDigitFFT[Channel]->GetNbinsX();
236  //double Re[NADC], Im[NADC];
237  std::unique_ptr<double[]> Re( new double[NADC]);
238  std::unique_ptr<double[]> Im( new double[NADC]);
239  TVirtualFFT *fft = TVirtualFFT::GetCurrentTransform();
240  fft->GetPointsComplex(Re.get(),Im.get());
241 
242  // Set the noisy frequency range bins to zero.
243  for (size_t aa=0; aa<ZeroFreq.size(); ++aa) {
244  for (int bb=ZeroFreq[aa].first; bb<ZeroFreq[aa].second; ++bb) {
245  double ReMeanVal=0;
246  double ImMeanVal=0;
247  int Range = 50;
248  for (int cc=0; cc<Range; ++cc) {
249  ReMeanVal += Re[ZeroFreq[aa].first-cc] + Re[ZeroFreq[aa].second+cc];
250  ImMeanVal += Im[ZeroFreq[aa].first-cc] + Im[ZeroFreq[aa].second+cc];
251  }
252  ReMeanVal = ReMeanVal / Range;
253  Re[bb] = Re[1500-bb] = ReMeanVal;
254  ImMeanVal = ImMeanVal / Range;
255  Im[bb] = Im[1500-bb] = ImMeanVal;
256  double MagVal = pow ( Re[bb]*Re[bb] + Im[bb]*Im[bb], 0.5);
257  RawDigitFFTCorrect[Channel] -> SetBinContent(bb+1 , MagVal );
258  RawDigitFFTCorrect[Channel] -> SetBinContent(15000-bb+1, MagVal );
259  }
260  }
261 
262  // Renormalise the X axis, so it is in frequency.
263  for (int bin = 0; bin < RawDigitFFTCorrect[Channel]->GetNbinsX(); ++bin){
264  RawDigitFFTChannel[Channel] -> SetBinContent( bin+1, RawDigitFFTCorrect[Channel]->GetBinContent(bin+1) );
265  }
266  // Apply the filter...
267  for (int bin = 0; bin < NBins; ++bin) {
268  double freq = 2000. * bin / NBins;
269  if (view == geo::kU) { // U plane
270  Re[bin] = Re[bin]*fIndUFilterFunc->Eval(freq);
271  Im[bin] = Im[bin]*fIndUFilterFunc->Eval(freq);
272  } else if ( view == geo::kV) { // V plane
273  Re[bin] = Re[bin]*fIndVFilterFunc->Eval(freq);
274  Im[bin] = Im[bin]*fIndVFilterFunc->Eval(freq);
275  } else if ( view == geo::kZ) { // Collection plane
276  Re[bin] = Re[bin]*fColFilterFunc->Eval(freq);
277  Im[bin] = Im[bin]*fColFilterFunc->Eval(freq);
278  }
279  double MagVal = pow ( Re[bin]*Re[bin] + Im[bin]*Im[bin], 0.5);
280  if (TMath::IsNaN(MagVal)) MagVal = 0;
281  RawDigitFFTChannelFilter[Channel] -> SetBinContent( bin+1, MagVal );
282 
283  // Now do the big histograms...
284  if (freq < 1000 && RawDigitFFTChannelFilter[Channel]->GetBinContent(bin+1) < 1e5) {
285  FixFFT_1000KHz -> Fill( Channel,freq, MagVal );
286  if (freq < 100) {
287  FixFFT_100KHz-> Fill( Channel,freq, MagVal );
288  }
289  }
290  }
291 
292  // I have applied the filter so now transform back....
293  TVirtualFFT *fft_back = TVirtualFFT::FFT(1, &NBins, "C2R");
294  fft_back->SetPointsComplex(Re.get(),Im.get());
295  fft_back->Transform();
296  TH1 *hb=0;
297  hb = TH1::TransformHisto(fft_back, hb, "Re");
298  for (int BinNum=0; BinNum<NBins; ++BinNum) {
299  //if (TMath::IsNaN(hb->GetBinContent(BinNum+1))) {
300  ////std::cout << "A bin entry is NaN." << std::endl;
301  //RawDigitInvFFT[Channel] -> Fill( BinNum, 0 );
302  //} else {
303  RawDigitInvFFT[Channel] -> Fill( BinNum, hb->GetBinContent(BinNum+1) / NBins );
304  //}
305  }
306  RawDigitInvFFT[Channel] -> SetXTitle("Time (us)");
307  RawDigitInvFFT[Channel] -> SetYTitle("ADC");
308  }
309  return;
310 }
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
TF1 * fColFilterFunc
Parameterized collection filter function.
TF1 * fIndVFilterFunc
Parameterized induction filter function.
Planes which measure U.
Definition: geo_types.h:125
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
TF1 * fIndUFilterFunc
Parameterized induction filter function.
ChannelMappingService::Channel Channel
QTextStream & bin(QTextStream &s)
TCEvent evt
Definition: DataStructs.cxx:7
Namespace collecting geometry-related classes utilities.
FilterAnalyzer& DAQToOffline::FilterAnalyzer::operator= ( FilterAnalyzer const &  )
delete
FilterAnalyzer& DAQToOffline::FilterAnalyzer::operator= ( FilterAnalyzer &&  )
delete
void DAQToOffline::FilterAnalyzer::reconfigure ( const fhicl::ParameterSet pset)

Definition at line 164 of file FilterAnalyzer_module.cc.

164  {
165  fDigitModuleLabel = pset.get<std::string>("DigitModuleLabel");
166  fDigitModuleInstance = pset.get<std::string>("DigitModuleInstance");
167  fMakeADCPlots = pset.get<bool> ("MakeADCPlots");
168  // Make the filter functions.
169  std::string colFilt = pset.get<std::string>("ColFilter");
170  std::vector<double> colFiltParams = pset.get<std::vector<double> >("ColFilterParams");
171  fColFilterFunc = new TF1("colFilter", colFilt.c_str());
172  for(unsigned int i=0; i<colFiltParams.size(); ++i)
173  fColFilterFunc->SetParameter(i, colFiltParams[i]);
174 
175  std::string indUFilt = pset.get<std::string>("IndUFilter");
176  std::vector<double> indUFiltParams = pset.get<std::vector<double> >("IndUFilterParams");
177  fIndUFilterFunc = new TF1("indUFilter", indUFilt.c_str());
178  for(unsigned int i=0; i<indUFiltParams.size(); ++i)
179  fIndUFilterFunc->SetParameter(i, indUFiltParams[i]);
180 
181  std::string indVFilt = pset.get<std::string>("IndVFilter");
182  std::vector<double> indVFiltParams = pset.get<std::vector<double> >("IndVFilterParams");
183  fIndVFilterFunc = new TF1("indVFilter", indVFilt.c_str());
184  for(unsigned int i=0; i<indVFiltParams.size(); ++i)
185  fIndVFilterFunc->SetParameter(i, indVFiltParams[i]);
186 }
std::string string
Definition: nybbler.cc:12
TF1 * fColFilterFunc
Parameterized collection filter function.
TF1 * fIndVFilterFunc
Parameterized induction filter function.
T get(std::string const &key) const
Definition: ParameterSet.h:231
TF1 * fIndUFilterFunc
Parameterized induction filter function.

Member Data Documentation

TF1* DAQToOffline::FilterAnalyzer::fColFilterFunc
private

Parameterized collection filter function.

Definition at line 85 of file FilterAnalyzer_module.cc.

std::string DAQToOffline::FilterAnalyzer::fDigitModuleInstance
private

Definition at line 82 of file FilterAnalyzer_module.cc.

std::string DAQToOffline::FilterAnalyzer::fDigitModuleLabel
private

Definition at line 81 of file FilterAnalyzer_module.cc.

TF1* DAQToOffline::FilterAnalyzer::fIndUFilterFunc
private

Parameterized induction filter function.

Definition at line 86 of file FilterAnalyzer_module.cc.

TF1* DAQToOffline::FilterAnalyzer::fIndVFilterFunc
private

Parameterized induction filter function.

Definition at line 87 of file FilterAnalyzer_module.cc.

TH2F* DAQToOffline::FilterAnalyzer::FixFFT_1000KHz
private

Definition at line 101 of file FilterAnalyzer_module.cc.

TH2F* DAQToOffline::FilterAnalyzer::FixFFT_100KHz
private

Definition at line 99 of file FilterAnalyzer_module.cc.

bool DAQToOffline::FilterAnalyzer::fMakeADCPlots
private

Definition at line 83 of file FilterAnalyzer_module.cc.

const lariov::DetPedestalProvider& DAQToOffline::FilterAnalyzer::fPedestalRetrievalAlg = *(lar::providerFrom<lariov::DetPedestalService>())
private

Definition at line 89 of file FilterAnalyzer_module.cc.

TH1F* DAQToOffline::FilterAnalyzer::RawDigitFFT[2048]
private

Definition at line 92 of file FilterAnalyzer_module.cc.

TH1F* DAQToOffline::FilterAnalyzer::RawDigitFFTChannel[2048]
private

Definition at line 94 of file FilterAnalyzer_module.cc.

TH1F* DAQToOffline::FilterAnalyzer::RawDigitFFTChannelFilter[2048]
private

Definition at line 95 of file FilterAnalyzer_module.cc.

TH1F* DAQToOffline::FilterAnalyzer::RawDigitFFTCorrect[2048]
private

Definition at line 93 of file FilterAnalyzer_module.cc.

TH1F* DAQToOffline::FilterAnalyzer::RawDigitHistos[2048]
private

Definition at line 91 of file FilterAnalyzer_module.cc.

TH1F* DAQToOffline::FilterAnalyzer::RawDigitInvFFT[2048]
private

Definition at line 96 of file FilterAnalyzer_module.cc.

TH2F* DAQToOffline::FilterAnalyzer::RawFFT_1000KHz
private

Definition at line 100 of file FilterAnalyzer_module.cc.

TH2F* DAQToOffline::FilterAnalyzer::RawFFT_100KHz
private

Definition at line 98 of file FilterAnalyzer_module.cc.


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