15 #include "art/Framework/Core/EDAnalyzer.h"
16 #include "art/Framework/Core/ModuleMacros.h"
17 #include "art/Framework/Principal/Event.h"
18 #include "art/Framework/Principal/Handle.h"
19 #include "art/Framework/Services/Registry/ServiceHandle.h"
20 #include "art_root_io/TFileService.h"
21 #include "fhiclcpp/ParameterSet.h"
22 #include "messagefacility/MessageLogger/MessageLogger.h"
68 : EDAnalyzer(pset), fDetSimModuleLabel(pset.
get<
std::string>(
"DetSimModuleLabel"))
76 art::ServiceHandle<art::TFileService const>
tfs;
78 art::ServiceHandle<util::LArFFT const> fFFT;
79 int fNTicks = fFFT->FFTSize();
81 auto const clock_data =
82 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
84 double sampfreq = 1. / samprate * 1e6;
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();
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++) {
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),
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),
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),
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),
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),
131 hh = tfs->make<TH1F>(Form(
"waveform"), Form(
"waveform"), fNTicks, 0, fNTicks);
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();
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++) {
152 for (
int ii = 1; ii <
fCsignal_av[icstat][itpc][pp]->GetNbinsX(); ii++) {
154 double diff = ((
fCsignal_av[icstat][itpc][pp]->GetBinContent(ii) *
156 fCnoise_av[icstat][itpc][pp]->GetBinContent(ii) *
157 fCnoise_av[icstat][itpc][pp]->GetBinContent(ii)) >= 0) ?
160 fCnoise_av[icstat][itpc][pp]->GetBinContent(ii) *
161 fCnoise_av[icstat][itpc][pp]->GetBinContent(ii) :
164 if (
fCsignal_av[icstat][itpc][pp]->GetBinContent(ii) > 0)
167 (
double)((diff) / (
fCsignal_av[icstat][itpc][pp]->GetBinContent(ii) *
168 fCsignal_av[icstat][itpc][pp]->GetBinContent(ii))));
170 fFilter_av[icstat][itpc][pp]->SetBinContent(ii, 0);
185 art::Handle<std::vector<raw::RawDigit>> rdHandle;
187 mf::LogInfo(
"WienerFilterMicroBooNE") <<
" readout Wiener " << rdHandle->size() << std::endl;
189 if (!rdHandle->size())
return;
190 mf::LogInfo(
"WienerFilterMicroBooNE")
191 <<
"WienerFilterMicroBooNE:: rdHandle size is " << rdHandle->size();
196 art::PtrVector<raw::RawDigit> rdvec;
197 for (
unsigned int i = 0; i < rdHandle->size(); ++i) {
198 art::Ptr<raw::RawDigit>
r(rdHandle, i);
203 art::ServiceHandle<geo::Geometry const> geom;
204 art::ServiceHandle<util::LArFFT const> fft;
206 for (
unsigned int rd = 0; rd < rdvec.size(); ++rd) {
208 std::vector<double> adc(fft->FFTSize());
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));
215 geo::WireID wireid = geom->ChannelToWire(rdvec[rd]->Channel())[0];
218 unsigned int plane = wireid.
Plane;
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));
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));
247 DEFINE_ART_MODULE(WienerFilterAna)
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
CryostatID_t Cryostat
Index of cryostat.
Definition of basic raw digits.
WireID_t Wire
Index of the wire within its plane.
std::string fDetSimModuleLabel
TH1F * fCnoise[10][10][5]
Base class for creation of raw signals on wires.
PlaneID_t Plane
Index of the plane within its TPC.
TH1F * fCnoise_av[10][10][5]
TH1F * fFilter_av[10][10][5]
art::ServiceHandle< art::TFileService > tfs
void analyze(const art::Event &evt)
read/write access to event
WienerFilterAna(fhicl::ParameterSet const &pset)
TPCID_t TPC
Index of the TPC within its cryostat.
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
art framework interface to geometry description
TH1F * fCsignal_av[10][10][5]
TH1F * fCsignal[10][10][5]