Public Member Functions | Private Attributes | List of all members
WireCell::SigProc::Microboone::OneChannelStatus Class Reference

#include <Microboone.h>

Inheritance diagram for WireCell::SigProc::Microboone::OneChannelStatus:
WireCell::IChannelFilter WireCell::IConfigurable WireCell::IComponent< IChannelFilter > WireCell::IComponent< IConfigurable > WireCell::Interface WireCell::Interface

Public Member Functions

 OneChannelStatus (const std::string anode_tn="AnodePlane", double threshold=3.5, int window=5, int nbins=250, double cut=14)
 
virtual ~OneChannelStatus ()
 
virtual WireCell::Waveform::ChannelMaskMap apply (int channel, signal_t &sig) const
 
virtual WireCell::Waveform::ChannelMaskMap apply (channel_signals_t &chansig) const
 
virtual void configure (const WireCell::Configuration &config)
 Accept a configuration. More...
 
virtual WireCell::Configuration default_configuration () const
 Optional, override to return a hard-coded default configuration. More...
 
bool ID_lf_noisy (signal_t &sig) const
 
- Public Member Functions inherited from WireCell::IChannelFilter
virtual ~IChannelFilter ()
 
- Public Member Functions inherited from WireCell::IComponent< IChannelFilter >
virtual ~IComponent ()
 
- Public Member Functions inherited from WireCell::Interface
virtual ~Interface ()
 
- Public Member Functions inherited from WireCell::IConfigurable
virtual ~IConfigurable ()
 
- Public Member Functions inherited from WireCell::IComponent< IConfigurable >
virtual ~IComponent ()
 

Private Attributes

std::string m_anode_tn
 
IAnodePlane::pointer m_anode
 
double m_threshold
 
int m_window
 
int m_nbins
 
double m_cut
 

Additional Inherited Members

- Public Types inherited from WireCell::IChannelFilter
typedef Waveform::realseq_t signal_t
 
typedef std::map< int, signal_tchannel_signals_t
 
- Public Types inherited from WireCell::IComponent< IChannelFilter >
typedef std::shared_ptr< IChannelFilterpointer
 Access subclass facet by pointer. More...
 
typedef std::vector< pointervector
 Vector of shared pointers. More...
 
- Public Types inherited from WireCell::Interface
typedef std::shared_ptr< Interfacepointer
 
- Public Types inherited from WireCell::IComponent< IConfigurable >
typedef std::shared_ptr< IConfigurablepointer
 Access subclass facet by pointer. More...
 
typedef std::vector< pointervector
 Vector of shared pointers. More...
 

Detailed Description

Definition at line 121 of file Microboone.h.

Constructor & Destructor Documentation

Microboone::OneChannelStatus::OneChannelStatus ( const std::string  anode_tn = "AnodePlane",
double  threshold = 3.5,
int  window = 5,
int  nbins = 250,
double  cut = 14 
)
Microboone::OneChannelStatus::~OneChannelStatus ( )
virtual

Definition at line 1305 of file Microboone.cxx.

1306 {
1307 }

Member Function Documentation

WireCell::Waveform::ChannelMaskMap Microboone::OneChannelStatus::apply ( int  channel,
signal_t sig 
) const
virtual

Filter in place the signal sig from given channel.

Implements WireCell::IChannelFilter.

Definition at line 1342 of file Microboone.cxx.

1343 {
1345  auto wpid = m_anode->resolve(ch);
1346  const int iplane = wpid.index();
1347  if (iplane!=2){ // not collection
1348  //std::cout << ch << std::endl;
1349  if (ID_lf_noisy(signal)){
1350  WireCell::Waveform::BinRange temp_chirped_bins;
1351  temp_chirped_bins.first = 0;
1352  temp_chirped_bins.second = signal.size();
1353  ret["lf_noisy"][ch].push_back(temp_chirped_bins);
1354  // std::cout << "lf noisy " << ch << std::endl;
1355  }
1356  }
1357  return ret;
1358 }
std::pair< int, int > BinRange
A half-open range of bins (from first bin to one past last bin)
Definition: Waveform.h:38
std::map< std::string, ChannelMasks > ChannelMaskMap
Collect channel masks by some label.
Definition: Waveform.h:59
WireCell::Waveform::ChannelMaskMap Microboone::OneChannelStatus::apply ( channel_signals_t chansig) const
virtual

Filter in place a group of signals together.

Implements WireCell::IChannelFilter.

Definition at line 1334 of file Microboone.cxx.

1335 {
1336 
1337 
1339 }
std::map< std::string, ChannelMasks > ChannelMaskMap
Collect channel masks by some label.
Definition: Waveform.h:59
void Microboone::OneChannelStatus::configure ( const WireCell::Configuration config)
virtual

Accept a configuration.

Implements WireCell::IConfigurable.

Definition at line 1309 of file Microboone.cxx.

1310 {
1311  m_threshold = get<double>(cfg, "Threshold", m_threshold);
1312  m_window = get<int>(cfg, "Window", m_window);
1313  m_nbins = get<double>(cfg, "Nbins", m_nbins);
1314  m_cut = get<double>(cfg, "Cut", m_cut);
1315 
1316  m_anode_tn = get(cfg, "anode", m_anode_tn);
1317  m_anode = Factory::find_tn<IAnodePlane>(m_anode_tn);
1318  if (!m_anode) {
1319  THROW(KeyError() << errmsg{"failed to get IAnodePlane: " + m_anode_tn});
1320  }
1321  //std::cerr << "OneChannelStatus: \n" << cfg << "\n";
1322 }
boost::error_info< struct tag_errmsg, std::string > errmsg
Definition: Exceptions.h:54
cfg
Definition: dbjson.py:29
#define THROW(e)
Definition: Exceptions.h:25
WireCell::Configuration Microboone::OneChannelStatus::default_configuration ( ) const
virtual

Optional, override to return a hard-coded default configuration.

Reimplemented from WireCell::IConfigurable.

Definition at line 1323 of file Microboone.cxx.

1324 {
1326  cfg["Threshold"] = m_threshold;
1327  cfg["Window"] = m_window;
1328  cfg["Nbins"] = m_nbins;
1329  cfg["Cut"] = m_cut;
1330  cfg["anode"] = m_anode_tn;
1331  return cfg;
1332 }
cfg
Definition: dbjson.py:29
Json::Value Configuration
Definition: Configuration.h:50
bool Microboone::OneChannelStatus::ID_lf_noisy ( signal_t sig) const

Definition at line 1361 of file Microboone.cxx.

1361  {
1362  // do something ...
1363  //std::pair<double,double> results = Derivations::CalcRMS(sig);
1364 
1365  //Waveform::mean_rms(sig);
1366  //double mean = results.first;
1367  //double rms = results.second;
1368 
1369  double mean = Waveform::percentile_binned(sig,0.5);
1370  double val1 = Waveform::percentile_binned(sig,0.5-0.34);
1371  double val2 = Waveform::percentile_binned(sig,0.5+0.34);
1372  double rms = sqrt((pow(val1-mean,2)+pow(val2-mean,2))/2.);
1373 
1374  double valid = 0 ;
1375  for (int i=0;i<int(sig.size());i++){
1376  if (sig.at(i)!=0){
1377  valid ++;
1378  }
1379  }
1380  if (!valid) {
1381  return false;
1382  }
1383 
1384 
1385 
1386  signal_t temp_sig = sig;
1387  for (int i=0;i<int(sig.size());i++){
1388  if (fabs(sig.at(i)-mean) > m_threshold * rms){
1389  for (int k=-m_window;k!=m_window;k++){
1390  if (k+i>=0&& k+i < int(sig.size()))
1391  temp_sig.at(k+i) = mean;
1392  }
1393  }
1394  }
1395 
1396  double content = 0;
1397  // for (int i=0;i!=temp_sig.size();i++){
1398  // temp_sig.at(i)=i;
1399  // }
1400  // do FFT
1401  Waveform::compseq_t sig_freq = Waveform::dft(temp_sig);
1402  for (int i=0;i!=m_nbins;i++){
1403  content += abs(sig_freq.at(i+1));
1404  }
1405 
1406  //std::cout << mean << " " << rms << " " << content << " " << valid << std::endl;
1407  // std::cout << m_threshold << " " << m_window << " " << m_nbins << " " << m_cut << std::endl;
1408 
1409  if (content/valid>m_cut) {
1410  // std::cerr << "OneChannelStatus::ID_lf_noisy: content=" << content << " valid=" << valid << " m_cut="<<m_cut<< std::endl;
1411  return true;
1412  }
1413 
1414  return false;
1415 
1416 
1417 }
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:39
Waveform::realseq_t signal_t
constexpr T pow(T x)
Definition: pow.h:72
T abs(T value)
compseq_t dft(realseq_t seq)
Definition: Waveform.cxx:141
Sequence< complex_t > compseq_t
A complex-valued sequence, eg for discrete spectrum powers.
Definition: Waveform.h:34
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:15
real_t percentile_binned(realseq_t &wave, real_t percentage)
Definition: Waveform.cxx:93

Member Data Documentation

IAnodePlane::pointer WireCell::SigProc::Microboone::OneChannelStatus::m_anode
private

Definition at line 140 of file Microboone.h.

std::string WireCell::SigProc::Microboone::OneChannelStatus::m_anode_tn
private

Definition at line 139 of file Microboone.h.

double WireCell::SigProc::Microboone::OneChannelStatus::m_cut
private

Definition at line 144 of file Microboone.h.

int WireCell::SigProc::Microboone::OneChannelStatus::m_nbins
private

Definition at line 143 of file Microboone.h.

double WireCell::SigProc::Microboone::OneChannelStatus::m_threshold
private

Definition at line 141 of file Microboone.h.

int WireCell::SigProc::Microboone::OneChannelStatus::m_window
private

Definition at line 142 of file Microboone.h.


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