Public Member Functions | Private Attributes | List of all members
detsim::WienerFilterAna Class Reference

Base class for creation of raw signals on wires. More...

Inheritance diagram for detsim::WienerFilterAna:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 WienerFilterAna (fhicl::ParameterSet const &pset)
 
void analyze (const art::Event &evt)
 read/write access to event More...
 
void beginJob ()
 
void endJob ()
 
- 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 (SharedResources const &resources)
 
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 &)
 
fhicl::ParameterSetID selectorConfig () 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 fDetSimModuleLabel
 
TH1F * fCnoise [10][10][5]
 
TH1F * fCsignal [10][10][5]
 
TH1F * fCnoise_av [10][10][5]
 
TH1F * fCsignal_av [10][10][5]
 
TH1F * fFilter_av [10][10][5]
 
TH1 * ff
 
TH1F * hh
 
int fNBins
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- 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

Base class for creation of raw signals on wires.

Definition at line 35 of file WienerFilterAna_module.cc.

Constructor & Destructor Documentation

detsim::WienerFilterAna::WienerFilterAna ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 66 of file WienerFilterAna_module.cc.

67  : EDAnalyzer(pset), fDetSimModuleLabel(pset.get<std::string>("DetSimModuleLabel"))
68  {}
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25

Member Function Documentation

void detsim::WienerFilterAna::analyze ( const art::Event evt)

read/write access to event

Todo:
Need to change hardcoded values to an automatic determination of noise vs. signal

Definition at line 179 of file WienerFilterAna_module.cc.

180  {
181 
182  // loop over the raw digits and get the adc vector for each, then compress it and uncompress it
183 
185  evt.getByLabel(fDetSimModuleLabel, rdHandle);
186  mf::LogInfo("WienerFilterMicroBooNE") << " readout Wiener " << rdHandle->size() << std::endl;
187  // return;
188  if (!rdHandle->size()) return;
189  mf::LogInfo("WienerFilterMicroBooNE")
190  << "WienerFilterMicroBooNE:: rdHandle size is " << rdHandle->size();
191 
192  // Read in the digit List object(s).
193 
194  // Use the handle to get a particular (0th) element of collection.
196  for (unsigned int i = 0; i < rdHandle->size(); ++i) {
197  art::Ptr<raw::RawDigit> r(rdHandle, i);
198  rdvec.push_back(r);
199  // std::cout << " i, rdvec: "<<i <<" " << r->ADC(0) << " "<< rdvec[i]->ADC(0)<< std::endl;
200  }
201 
204 
205  for (unsigned int rd = 0; rd < rdvec.size(); ++rd) {
206 
207  std::vector<double> adc(fft->FFTSize());
208 
209  for (unsigned int t = 1; t < rdvec[rd]->Samples(); t++) {
210  adc[t - 1] = rdvec[rd]->ADC(t - 1);
211  hh->SetBinContent(t, rdvec[rd]->ADC(t));
212  }
213 
214  geo::WireID wireid = geom->ChannelToWire(rdvec[rd]->Channel())[0];
215 
216  // this is hardcoded for the time being. Should be automatized.
217  unsigned int plane = wireid.Plane; /// \todo Need to change hardcoded values to an automatic
218  /// determination of noise vs. signal
219  unsigned int wire = wireid.Wire;
220  unsigned int cstat = wireid.Cryostat;
221  unsigned int tpc = wireid.TPC;
222  ff = hh->FFT(NULL, "MAG M");
223  if (wire >= 50 && wire < 250) {
224  for (int ii = 0; ii < fNBins; ii++) {
225  fCnoise_av[cstat][tpc][plane]->AddBinContent(ii, ff->GetBinContent(ii));
226  if (wire == 150) fCnoise[cstat][tpc][plane]->SetBinContent(ii, ff->GetBinContent(ii));
227  }
228  }
229  else if (wire >= 700 && wire < 900) {
230  for (int ii = 0; ii < fNBins; ii++) {
231  fCsignal_av[cstat][tpc][plane]->AddBinContent(ii, ff->GetBinContent(ii));
232  if (wire == 800) fCsignal[cstat][tpc][plane]->SetBinContent(ii, ff->GetBinContent(ii));
233  }
234  }
235 
236  //
237  } //end loop over rawDigits
238 
239  return;
240  } //end analyze method
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
int16_t adc
Definition: CRTFragment.hh:202
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
int FFTSize() const
Definition: LArFFT.h:69
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
size_type size() const
Definition: PtrVector.h:302
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
QTextStream & endl(QTextStream &s)
void detsim::WienerFilterAna::beginJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 72 of file WienerFilterAna_module.cc.

73  {
74  // get access to the TFile service
76 
78  int fNTicks = fFFT->FFTSize();
79  fNBins = fNTicks / 2 + 1;
80  auto const clock_data =
82  double samprate = sampling_rate(clock_data);
83  double sampfreq = 1. / samprate * 1e6; // in kHz
85  unsigned int fNPlanes = geo->Nplanes();
86  unsigned int fNCryostats = geo->Ncryostats();
87  unsigned int fNTPC = geo->NTPC();
88 
89  for (unsigned int icstat = 0; icstat < fNCryostats; icstat++) {
90  for (unsigned int itpc = 0; itpc < fNTPC; itpc++) {
91  for (unsigned int iplane = 0; iplane < fNPlanes; iplane++) {
92  fCnoise[icstat][itpc][iplane] =
93  tfs->make<TH1F>(Form("fft_noise_%d_%d_%d", icstat, itpc, iplane),
94  Form("fft_of_unfiltered_noise_%d_%d_%d", icstat, itpc, iplane),
95  fNBins,
96  0,
97  sampfreq / 2);
98 
99  fCsignal[icstat][itpc][iplane] = tfs->make<TH1F>(
100  Form("fft_signal_%d_%d_%d", icstat, itpc, iplane),
101  Form("fft_of_unfiltered_noise_and_signal_%d_%d_%d", icstat, itpc, iplane),
102  fNBins,
103  0,
104  sampfreq / 2);
105 
106  fCnoise_av[icstat][itpc][iplane] =
107  tfs->make<TH1F>(Form("fft_noise_%d_%d_%d_av", icstat, itpc, iplane),
108  Form("fft_of_unfiltered_noise_%d_%d_%d_av", icstat, itpc, iplane),
109  fNBins,
110  0,
111  sampfreq / 2);
112  fCsignal_av[icstat][itpc][iplane] = tfs->make<TH1F>(
113  Form("fft_signal_%d_%d_%d_av", icstat, itpc, iplane),
114  Form("fft_of_unfiltered_noise_and_signal_%d_%d_%d_av", icstat, itpc, iplane),
115  fNBins,
116  0,
117  sampfreq / 2);
118 
119  fFilter_av[icstat][itpc][iplane] =
120  tfs->make<TH1F>(Form("fft_filter_%d_%d_%d_av", icstat, itpc, iplane),
121  Form("fft_filter_%d_%d_%d_av", icstat, itpc, iplane),
122  fNBins,
123  0,
124  sampfreq / 2);
125  }
126  }
127  }
128 
129  //ff=tfs->make<TH1>(Form("fftwaveform"),Form("fftwaveform"),4096,0,4096);
130  hh = tfs->make<TH1F>(Form("waveform"), Form("waveform"), fNTicks, 0, fNTicks);
131 
132  return;
133  }
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
int FFTSize() const
Definition: LArFFT.h:69
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
LArSoft geometry interface.
Definition: ChannelGeo.h:16
void detsim::WienerFilterAna::endJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 137 of file WienerFilterAna_module.cc.

138  {
139 
141  unsigned int nplanes = geom->Nplanes();
142  unsigned int fNCryostats = geom->Ncryostats();
143  unsigned int fNTPC = geom->NTPC();
144 
145  // calculate filters
146 
147  for (unsigned int icstat = 0; icstat < fNCryostats; icstat++) {
148  for (unsigned int itpc = 0; itpc < fNTPC; itpc++) {
149  for (unsigned int pp = 0; pp < nplanes; pp++) {
150 
151  for (int ii = 1; ii < fCsignal_av[icstat][itpc][pp]->GetNbinsX(); ii++) {
152 
153  double diff = ((fCsignal_av[icstat][itpc][pp]->GetBinContent(ii) *
154  fCsignal_av[icstat][itpc][pp]->GetBinContent(ii) -
155  fCnoise_av[icstat][itpc][pp]->GetBinContent(ii) *
156  fCnoise_av[icstat][itpc][pp]->GetBinContent(ii)) >= 0) ?
157  fCsignal_av[icstat][itpc][pp]->GetBinContent(ii) *
158  fCsignal_av[icstat][itpc][pp]->GetBinContent(ii) -
159  fCnoise_av[icstat][itpc][pp]->GetBinContent(ii) *
160  fCnoise_av[icstat][itpc][pp]->GetBinContent(ii) :
161  0;
162 
163  if (fCsignal_av[icstat][itpc][pp]->GetBinContent(ii) > 0)
164  fFilter_av[icstat][itpc][pp]->SetBinContent(
165  ii,
166  (double)((diff) / (fCsignal_av[icstat][itpc][pp]->GetBinContent(ii) *
167  fCsignal_av[icstat][itpc][pp]->GetBinContent(ii))));
168  else
169  fFilter_av[icstat][itpc][pp]->SetBinContent(ii, 0);
170 
171  } // end loop on Csignal
172  } // end loop on planes
173  } // end loop on TPCs
174  } // end loop on cryostats
175  }
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.

Member Data Documentation

TH1F* detsim::WienerFilterAna::fCnoise[10][10][5]
private

Definition at line 48 of file WienerFilterAna_module.cc.

TH1F* detsim::WienerFilterAna::fCnoise_av[10][10][5]
private

Definition at line 51 of file WienerFilterAna_module.cc.

TH1F* detsim::WienerFilterAna::fCsignal[10][10][5]
private

Definition at line 49 of file WienerFilterAna_module.cc.

TH1F* detsim::WienerFilterAna::fCsignal_av[10][10][5]
private

Definition at line 52 of file WienerFilterAna_module.cc.

std::string detsim::WienerFilterAna::fDetSimModuleLabel
private

Definition at line 46 of file WienerFilterAna_module.cc.

TH1* detsim::WienerFilterAna::ff
private

Definition at line 56 of file WienerFilterAna_module.cc.

TH1F* detsim::WienerFilterAna::fFilter_av[10][10][5]
private

Definition at line 54 of file WienerFilterAna_module.cc.

int detsim::WienerFilterAna::fNBins
private

Definition at line 58 of file WienerFilterAna_module.cc.

TH1F* detsim::WienerFilterAna::hh
private

Definition at line 57 of file WienerFilterAna_module.cc.


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