All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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:

Public Member Functions

 WienerFilterAna (fhicl::ParameterSet const &pset)
 
void analyze (const art::Event &evt)
 read/write access to event More...
 
void beginJob ()
 
void endJob ()
 

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
 

Detailed Description

Base class for creation of raw signals on wires.

Definition at line 36 of file WienerFilterAna_module.cc.

Constructor & Destructor Documentation

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

Definition at line 67 of file WienerFilterAna_module.cc.

68  : EDAnalyzer(pset), fDetSimModuleLabel(pset.get<std::string>("DetSimModuleLabel"))
69  {}

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 180 of file WienerFilterAna_module.cc.

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

Definition at line 73 of file WienerFilterAna_module.cc.

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

Definition at line 138 of file WienerFilterAna_module.cc.

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

Member Data Documentation

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

Definition at line 49 of file WienerFilterAna_module.cc.

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

Definition at line 52 of file WienerFilterAna_module.cc.

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

Definition at line 50 of file WienerFilterAna_module.cc.

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

Definition at line 53 of file WienerFilterAna_module.cc.

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

Definition at line 47 of file WienerFilterAna_module.cc.

TH1* detsim::WienerFilterAna::ff
private

Definition at line 57 of file WienerFilterAna_module.cc.

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

Definition at line 55 of file WienerFilterAna_module.cc.

int detsim::WienerFilterAna::fNBins
private

Definition at line 59 of file WienerFilterAna_module.cc.

TH1F* detsim::WienerFilterAna::hh
private

Definition at line 58 of file WienerFilterAna_module.cc.


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