LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
noisefilteralg::WireCellNoiseFilter Class Reference
Inheritance diagram for noisefilteralg::WireCellNoiseFilter:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 WireCellNoiseFilter (fhicl::ParameterSet const &pset)
 
virtual ~WireCellNoiseFilter ()
 
void produce (art::Event &evt)
 
void reconfigure (fhicl::ParameterSet const &pset)
 
void beginJob ()
 
void endJob ()
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > mayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Member Functions

void DoNoiseFilter (unsigned int runNum, const std::vector< raw::RawDigit > &, std::vector< raw::RawDigit > &) const
 

Private Attributes

std::string fDigitModuleLabel
 
bool fDoNoiseFiltering
 
size_t fNumTicksToDropFront
 
size_t fWindowSize
 

Detailed Description

Definition at line 44 of file WireCellNoiseFilter_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

noisefilteralg::WireCellNoiseFilter::WireCellNoiseFilter ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 72 of file WireCellNoiseFilter_module.cc.

References reconfigure().

73  : EDProducer()
74 {
75  this->reconfigure(pset);
76  produces<std::vector<raw::RawDigit> >();
77 }
void reconfigure(fhicl::ParameterSet const &pset)
noisefilteralg::WireCellNoiseFilter::~WireCellNoiseFilter ( )
virtual

Definition at line 80 of file WireCellNoiseFilter_module.cc.

80 {}

Member Function Documentation

void noisefilteralg::WireCellNoiseFilter::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 91 of file WireCellNoiseFilter_module.cc.

91  {
93  //art::ServiceHandle<util::LArWireCellNoiseFilterService> larWireCellNF;
94  //larWireCellNF->print(17);
95 }
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 147 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

148 {
149  if (!moduleContext_)
150  return ProductToken<T>::invalid();
151 
152  consumables_[BT].emplace_back(ConsumableType::Product,
153  TypeID{typeid(T)},
154  it.label(),
155  it.instance(),
156  it.process());
157  return ProductToken<T>{it};
158 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 172 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited

Definition at line 32 of file EngineCreator.cc.

References art::EngineCreator::rng().

34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited

Definition at line 40 of file EngineCreator.cc.

References art::EngineCreator::rng().

43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
CurrentProcessingContext const * art::EDProducer::currentContext ( ) const
protectedinherited

Definition at line 120 of file EDProducer.cc.

References art::EDProducer::current_context_.

121  {
122  return current_context_.get();
123  }
CPC_exempt_ptr current_context_
Definition: EDProducer.h:116
void noisefilteralg::WireCellNoiseFilter::DoNoiseFilter ( unsigned int  runNum,
const std::vector< raw::RawDigit > &  inputWaveforms,
std::vector< raw::RawDigit > &  outputWaveforms 
) const
private

Definition at line 154 of file WireCellNoiseFilter_module.cc.

References DEFINE_ART_MODULE, fNumTicksToDropFront, fWindowSize, raw::kNone, min, noise(), geo::GeometryCore::Nwires(), and lar::dump::vector().

Referenced by produce().

155 {
156 
157  // Recover services we will need
158  const lariov::ChannelStatusProvider& channelStatus = art::ServiceHandle<lariov::ChannelStatusService>()->GetProvider();
159  const lariov::DetPedestalProvider& pedestalValues = art::ServiceHandle<lariov::DetPedestalService>()->GetPedestalProvider();
160  const lariov::ElectronicsCalibProvider& elec_provider = art::ServiceHandle<lariov::ElectronicsCalibService>()->GetProvider();
161  const geo::GeometryCore& geometry = *lar::providerFrom<geo::Geometry>();
162  const detinfo::DetectorProperties& detectorProperties = *lar::providerFrom<detinfo::DetectorPropertiesService>();
163 
164  const unsigned int n_channels = inputWaveforms.size();
165 
166  // S&C microboone sampling parameter database
167  const double tick = detectorProperties.SamplingRate(); // 0.5 * units::microsecond;
168  const size_t nsamples = inputWaveforms.at(0).NADC();
169  const size_t windowSize = std::min(fWindowSize,nsamples);
170 
171  // Q&D microboone channel map
172  std::vector<int> uchans(geometry.Nwires(0)), vchans(geometry.Nwires(1)), wchans(geometry.Nwires(2));
173  const int nchans = uchans.size() + vchans.size() + wchans.size();
174  std::iota(uchans.begin(), uchans.end(), 0);
175  std::iota(vchans.begin(), vchans.end(), vchans.size());
176  std::iota(wchans.begin(), wchans.end(), vchans.size() + uchans.size());
177 
178  // Q&D nominal baseline
179  const double unombl=2048.0, vnombl=2048.0, wnombl=400.0;
180 
181  // Q&D miss-configured channel database
182  std::vector<int> miscfgchan;
183  for(int channelIdx=0; channelIdx<nchans; channelIdx++) {
184  if (elec_provider.ExtraInfo(channelIdx).GetBoolData("is_misconfigured")) {
185  miscfgchan.push_back(channelIdx);
186  }
187  }
188 
189  const double from_gain_mVfC=4.7, to_gain_mVfC=14.0,from_shaping=1.0*units::microsecond, to_shaping=2.0*units::microsecond;
190 
191  // Recover bad channels from the database
192  std::vector<int> bad_channels;
193  for(int channelIdx=0; channelIdx<nchans; channelIdx++) if (channelStatus.IsBad(channelIdx)) bad_channels.push_back(channelIdx);
194 
195  // Q&D RC+RC time constant - all have same.
196  const double rcrc = 1.0*units::millisecond;
197  std::vector<int> rcrcchans(nchans);
198  std::iota(rcrcchans.begin(), rcrcchans.end(), 0);
199 
200  //harmonic noises
201  std::vector<int> harmonicchans(uchans.size() + vchans.size());
202  std::iota(harmonicchans.begin(), harmonicchans.end(), 0);
203 
204  std::vector<int> special_chans;
205  special_chans.push_back(2240);
206 
207  WireCell::SigProc::SimpleChannelNoiseDB::mask_t h36kHz(0,169,173);
208  WireCell::SigProc::SimpleChannelNoiseDB::mask_t h108kHz(0,513,516);
209  WireCell::SigProc::SimpleChannelNoiseDB::mask_t hspkHz(0,17,19);
210  WireCell::SigProc::SimpleChannelNoiseDB::multimask_t hharmonic;
211  hharmonic.push_back(h36kHz);
212  hharmonic.push_back(h108kHz);
213  WireCell::SigProc::SimpleChannelNoiseDB::multimask_t hspecial;
214  hspecial.push_back(h36kHz);
215  hspecial.push_back(h108kHz);
216  hspecial.push_back(hspkHz);
217 
218  float u_resp_array[120]={0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.364382, 0.387949, 0.411053, 0.433979, 0.456863, 0.479746, 0.502641, 0.52554, 0.548441, 0.57134, 0.591765, 0.609448, 0.626848, 0.644094, 0.661364, 0.678859, 0.695231, 0.710462, 0.726147, 0.742373, 0.761332, 0.783313, 0.806325, 0.830412, 0.857676, 0.888412, 0.920705, 0.954624, 0.990242, 1.02766, 1.06121, 1.09027, 1.12037, 1.15157, 1.18392, 1.21748, 1.25229, 1.28824, 1.32509, 1.36256, 1.40051, 1.43907, 1.47857, 1.51933, 1.56134, 1.60404, 1.72665, 1.94005, 2.16994, 2.42041, 2.69475, 3.07222, 3.67375, 4.60766, 5.91864, 7.30178, 8.3715, 8.94736, 8.93705, 8.40339, 7.2212, 5.76382, 3.8931, 1.07893, -3.52481, -11.4593, -20.4011, -29.1259, -34.9544, -36.9358, -35.3303, -31.2068, -25.8614, -20.3613, -15.3794, -11.2266, -7.96091, -5.50138, -3.71143, -2.44637, -1.57662, -0.99733, -0.62554, -0.393562, -0.249715, -0.15914, -0.100771, -0.062443, -0.037283, -0.0211508, -0.0112448, -0.00552085, -0.00245133, -0.000957821, -0.000316912, -8.51679e-05, -2.21299e-05, -1.37496e-05, -1.49806e-05, -1.36935e-05, -9.66758e-06, -5.20773e-06, -7.4787e-07, 3.71199e-06, 8.17184e-06, 1.26317e-05, 1.70916e-05, 2.15514e-05, 2.60113e-05, 3.04711e-05};
219  float v_resp_array[120]={0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0865303, 0.0925559, 0.0983619, 0.104068, 0.109739, 0.115403, 0.121068, 0.126735, 0.132403, 0.138072, 0.143739, 0.149408, 0.155085, 0.160791, 0.166565, 0.172454, 0.178514, 0.184795, 0.191341, 0.198192, 0.205382, 0.212944, 0.220905, 0.229292, 0.238129, 0.247441, 0.257256, 0.267601, 0.278502, 0.28999, 0.298745, 0.304378, 0.310105, 0.315921, 0.321818, 0.327796, 0.333852, 0.339967, 0.346098, 0.352169, 0.358103, 0.363859, 0.36945, 0.374915, 0.380261, 0.385401, 0.39016, 0.394378, 0.39804, 0.401394, 0.405145, 0.410714, 0.4205, 0.437951, 0.467841, 0.516042, 0.587738, 0.694157, 0.840763, 1.01966, 1.22894, 1.5612, 2.12348, 3.31455, 5.59355, 9.10709, 14.1756, 18.4603, 19.9517, 17.4166, 10.6683, 1.40656, -10.0638, -19.034, -23.654, -24.0558, -21.4418, -17.3229, -12.9485, -9.08912, -6.05941, -3.86946, -2.38669, -1.43678, -0.853335, -0.503951, -0.296551, -0.173029, -0.0990099, -0.0547172, -0.0287882, -0.0142758, -0.00661815, -0.00284757, -0.00115702, -0.000456456, -0.000183439, -8.04214e-05, -4.20533e-05, -2.62903e-05, -1.64098e-05, -6.68039e-06, 3.04903e-06, 1.27784e-05, 2.25079e-05, 3.22373e-05, 4.19667e-05, 5.16961e-05, 6.14255e-05, 7.11549e-05};
220  WireCell::Waveform::realseq_t u_resp(nsamples);
221  WireCell::Waveform::realseq_t v_resp(nsamples);
222  for (int i=0;i!=120;i++){
223  u_resp.at(i) = u_resp_array[i];
224  v_resp.at(i) = v_resp_array[i];
225  }
226  WireCell::Waveform::compseq_t u_resp_freq = WireCell::Waveform::dft(u_resp);
227  WireCell::Waveform::compseq_t v_resp_freq = WireCell::Waveform::dft(v_resp);
228 
229  int uplane_time_shift = 79;
230  int vplane_time_shift = 82;
231 
232  // do the coherent subtraction
233  std::vector< std::vector<int> > channel_groups;
234  for (unsigned int i=0;i!=172;i++){
235  //for (int i=150;i!=151;i++){
236  std::vector<int> channel_group;
237  for (int j=0;j!=48;j++){
238  channel_group.push_back(i*48+j);
239  }
240  channel_groups.push_back(channel_group);
241  }
242 
243  auto noise = new WireCell::SigProc::SimpleChannelNoiseDB;
244  // initialize
245  noise->set_sampling(tick, nsamples);
246  // set nominal baseline
247  noise->set_nominal_baseline(uchans, unombl);
248  noise->set_nominal_baseline(vchans, vnombl);
249  noise->set_nominal_baseline(wchans, wnombl);
250 
251  noise->set_response(uchans,u_resp_freq);
252  noise->set_response(vchans,v_resp_freq);
253 
254  noise->set_response_offset(uchans,uplane_time_shift);
255  noise->set_response_offset(vchans,vplane_time_shift);
256 
257  noise->set_pad_window_front(uchans,20);
258  noise->set_pad_window_back(uchans,10);
259  noise->set_pad_window_front(vchans,10);
260  noise->set_pad_window_back(vchans,10);
261  noise->set_pad_window_front(wchans,10);
262  noise->set_pad_window_back(wchans,10);
263 
264  // set misconfigured channels
265  noise->set_gains_shapings(miscfgchan, from_gain_mVfC, to_gain_mVfC, from_shaping, to_shaping);
266  // do the RCRC
267  noise->set_rcrc_constant(rcrcchans, rcrc);
268  // set initial bad channels
269  noise->set_bad_channels(bad_channels);
270  // set the harmonic filter
271  noise->set_filter(harmonicchans,hharmonic);
272  noise->set_filter(special_chans,hspecial);
273  noise->set_channel_groups(channel_groups);
274 
275  for (unsigned int i=0;i!=uchans.size();i++){
276  if (uchans.at(i)<100){
277  noise->set_min_rms_cut_one(uchans.at(i),1);
278  noise->set_max_rms_cut_one(uchans.at(i),5);
279  }else if (uchans.at(i)<2000){
280  noise->set_min_rms_cut_one(uchans.at(i),1.9);
281  noise->set_max_rms_cut_one(uchans.at(i),11);
282  }else{
283  noise->set_min_rms_cut_one(uchans.at(i),0.9);
284  noise->set_max_rms_cut_one(uchans.at(i),5);
285  }
286  }
287  for (unsigned int i=0;i!=vchans.size();i++){
288  if (vchans.at(i)<290+ (int) uchans.size()){
289  noise->set_min_rms_cut_one(vchans.at(i),1);
290  noise->set_max_rms_cut_one(vchans.at(i),5);
291  }else if (vchans.at(i)<2200+(int) uchans.size()){
292  noise->set_min_rms_cut_one(vchans.at(i),1.9);
293  noise->set_max_rms_cut_one(vchans.at(i),11);
294  }else{
295  noise->set_min_rms_cut_one(vchans.at(i),1);
296  noise->set_max_rms_cut_one(vchans.at(i),5);
297  }
298  }
299 
300  // these are the one after the Hardware Fix
301  if( runNum > 8000 ){
302  for (unsigned int i=0;i!=uchans.size();i++){
303  if (uchans.at(i)<600){
304  noise->set_min_rms_cut_one(uchans.at(i),1+(1.7-1)/600.*i);
305  noise->set_max_rms_cut_one(uchans.at(i),5);
306  }else if (uchans.at(i)<1800){
307  noise->set_min_rms_cut_one(uchans.at(i),1.7);
308  noise->set_max_rms_cut_one(uchans.at(i),11);
309  }else{
310  noise->set_min_rms_cut_one(uchans.at(i),1+ (1.7-1)/600.*(2399-i));
311  noise->set_max_rms_cut_one(uchans.at(i),5);
312  }
313  }
314  for (unsigned int i=0;i!=vchans.size();i++){
315  if (vchans.at(i)<600+(int)uchans.size()){
316  noise->set_min_rms_cut_one(vchans.at(i),0.8+(1.7-0.8)/600.*i);
317  noise->set_max_rms_cut_one(vchans.at(i),5);
318  }else if (vchans.at(i)<1800+(int)uchans.size()){
319  noise->set_min_rms_cut_one(vchans.at(i),1.7);
320  noise->set_max_rms_cut_one(vchans.at(i),11);
321  }else{
322  noise->set_min_rms_cut_one(vchans.at(i),0.8+ (1.7-0.8)/600.*(2399-i));
323  noise->set_max_rms_cut_one(vchans.at(i),5);
324  }
325  }
326  }
327 
328  noise->set_min_rms_cut(wchans,1.3);
329  noise->set_max_rms_cut(wchans,8.0);
330 
331  //Define database object
332  std::shared_ptr<WireCell::IChannelNoiseDatabase> noise_sp(noise);
333 
334  auto one = new WireCell::SigProc::Microboone::OneChannelNoise;
335  one->set_channel_noisedb(noise_sp);
336  std::shared_ptr<WireCell::IChannelFilter> one_sp(one);
337  auto many = new WireCell::SigProc::Microboone::CoherentNoiseSub;
338  many->set_channel_noisedb(noise_sp);
339  std::shared_ptr<WireCell::IChannelFilter> many_sp(many);
340 
341  //define noisefilter object
342  WireCell::SigProc::OmnibusNoiseFilter bus;
343  bus.set_channel_filters({one_sp});
344  bus.set_grouped_filters({many_sp});
345  bus.set_channel_noisedb(noise_sp);
346 
347  // Enable truncation
348  size_t startBin(fNumTicksToDropFront);
349  size_t stopBin(startBin + windowSize);
350 
351  //load waveforms into traces
353  for(unsigned int ich=0; ich<n_channels; ich++)
354  {
355  if( inputWaveforms.at(ich).NADC() < windowSize ) continue;
356 
357  const raw::RawDigit::ADCvector_t& rawAdcVec = inputWaveforms.at(ich).ADCs();
358 
359  WireCell::ITrace::ChargeSequence charges;
360 
361  charges.resize(nsamples);
362 
363  std::transform(rawAdcVec.begin(), rawAdcVec.end(), charges.begin(), [](auto& adcVal){return float(adcVal);});
364 
365  unsigned int chan = inputWaveforms.at(ich).Channel();
366  WireCell::SimpleTrace* st = new WireCell::SimpleTrace(chan, 0.0, charges);
367  traces.push_back(WireCell::ITrace::pointer(st));
368  }
369 
370  //Load traces into frame
371  WireCell::SimpleFrame* sf = new WireCell::SimpleFrame(0, 0, traces);
372  WireCell::IFrame::pointer frame = WireCell::IFrame::pointer(sf);
373  WireCell::IFrame::pointer quiet = NULL;
374 
375  //Do filtering
376  bus(frame, quiet);
377 
378  //std::cout << "HERE" << std::endl;
379  //return;
380  if( quiet == NULL )
381  return;
382 
383  //Output results
384  std::vector< short > waveform(windowSize);
385 
386  auto quiet_traces = quiet->traces();
387  for (auto quiet_trace : *quiet_traces.get()) {
388  //int tbin = quiet_trace->tbin();
389  unsigned int channel = quiet_trace->channel();
390 
391  auto& quiet_charges = quiet_trace->charge();
392 
393  // Recover the database version of the pedestal, we'll offset the waveforms so it matches
394  float pedestal = pedestalValues.PedMean(channel);
395 
396  std::transform(quiet_charges.begin() + startBin, quiet_charges.begin() + stopBin, waveform.begin(), [pedestal](auto charge){return std::round(charge+pedestal);});
397 
398  outputWaveforms.emplace_back( raw::RawDigit( channel , waveform.size(), waveform, raw::kNone) );
399  outputWaveforms.back().SetPedestal(pedestal,1.75);
400  }
401 
402  return;
403 }
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:68
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition: RawDigit.h:72
no compression
Definition: RawTypes.h:9
unsigned int Nwires(unsigned int p, unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wires in the specified plane.
unsigned int noise()
Definition: chem4.cc:265
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
Description of geometry of one entire detector.
Int_t min
Definition: plot.C:26
void noisefilteralg::WireCellNoiseFilter::endJob ( )
virtual
EngineCreator::seed_t EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited

Definition at line 49 of file EngineCreator.cc.

References fhicl::ParameterSet::get().

Referenced by art::MixFilter< T >::initEngine_().

52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References B, and art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
Int_t B
Definition: plot.C:25
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 190 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 215 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID().

41  {
42  return true;
43  }
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
void noisefilteralg::WireCellNoiseFilter::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 103 of file WireCellNoiseFilter_module.cc.

References DoNoiseFilter(), fDigitModuleLabel, fDoNoiseFiltering, fNumTicksToDropFront, fWindowSize, art::DataViewImpl::getByLabel(), art::Handle< T >::isValid(), raw::kNone, min, art::Event::put(), and art::Event::run().

104 {
105  // Recover services we will need
106  const lariov::DetPedestalProvider& pedestalValues = art::ServiceHandle<lariov::DetPedestalService>()->GetPedestalProvider();
107 
109  evt.getByLabel(fDigitModuleLabel,rawDigitHandle);
110 
111  // Define the output vector (in case we don't do anything)
112  std::unique_ptr<std::vector<raw::RawDigit> > filteredRawDigit(new std::vector<raw::RawDigit>);
113 
114  if (rawDigitHandle.isValid() && rawDigitHandle->size() > 0)
115  {
116  const std::vector<raw::RawDigit>& rawDigitVector(*rawDigitHandle);
117 
118  // Make sure we have the correct window size (e.g. window size = 9600 but data is 9595)
119  size_t windowSize(std::min(fWindowSize,rawDigitVector.at(0).NADC()));
120 
121  if (fNumTicksToDropFront + windowSize > rawDigitVector.at(0).NADC())
122  throw cet::exception("WireCellNoiseFilter") << "Ticks to drop + windowsize larger than input buffer\n";
123 
124  if (fDoNoiseFiltering) DoNoiseFilter(evt.run(), rawDigitVector, *filteredRawDigit);
125  else
126  {
127  // Enable truncation
128  size_t startBin(fNumTicksToDropFront);
129  size_t stopBin(startBin + windowSize);
130 
131  raw::RawDigit::ADCvector_t outputVector(windowSize);
132 
133  for(const auto& rawDigit : rawDigitVector)
134  {
135  if (rawDigit.NADC() < windowSize) continue;
136 
137  const raw::RawDigit::ADCvector_t& rawAdcVec = rawDigit.ADCs();
138 
139  unsigned int channel = rawDigit.Channel();
140  float pedestal = pedestalValues.PedMean(channel);
141 
142  std::copy(rawAdcVec.begin() + startBin, rawAdcVec.begin() + stopBin, outputVector.begin());
143 
144  filteredRawDigit->emplace_back( raw::RawDigit( channel , outputVector.size(), outputVector, raw::kNone) );
145  filteredRawDigit->back().SetPedestal(pedestal,2.0);
146  }
147  }
148  }
149 
150  //filtered raw digits
151  evt.put(std::move(filteredRawDigit));
152 }
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:68
void DoNoiseFilter(unsigned int runNum, const std::vector< raw::RawDigit > &, std::vector< raw::RawDigit > &) const
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition: RawDigit.h:72
no compression
Definition: RawTypes.h:9
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
bool isValid() const
Definition: Handle.h:190
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Int_t min
Definition: plot.C:26
RunNumber_t run() const
Definition: Event.h:77
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void noisefilteralg::WireCellNoiseFilter::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 83 of file WireCellNoiseFilter_module.cc.

References fDigitModuleLabel, fDoNoiseFiltering, fNumTicksToDropFront, fWindowSize, and fhicl::ParameterSet::get().

Referenced by WireCellNoiseFilter().

83  {
84  fDigitModuleLabel = pset.get<std::string>("DigitModuleLabel", "daq");
85  fDoNoiseFiltering = pset.get<bool> ("DoNoiseFiltering", true );
86  fNumTicksToDropFront = pset.get<size_t> ("NumTicksToDropFront", 2400 );
87  fWindowSize = pset.get<size_t> ("WindowSize", 6400 );
88 }
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139

Member Data Documentation

std::string noisefilteralg::WireCellNoiseFilter::fDigitModuleLabel
private

Definition at line 62 of file WireCellNoiseFilter_module.cc.

Referenced by produce(), and reconfigure().

bool noisefilteralg::WireCellNoiseFilter::fDoNoiseFiltering
private

Definition at line 63 of file WireCellNoiseFilter_module.cc.

Referenced by produce(), and reconfigure().

size_t noisefilteralg::WireCellNoiseFilter::fNumTicksToDropFront
private

Definition at line 64 of file WireCellNoiseFilter_module.cc.

Referenced by DoNoiseFilter(), produce(), and reconfigure().

size_t noisefilteralg::WireCellNoiseFilter::fWindowSize
private

Definition at line 65 of file WireCellNoiseFilter_module.cc.

Referenced by DoNoiseFilter(), produce(), and reconfigure().


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