Public Types | Public Member Functions | Private Attributes | List of all members
FclStickyCodeFlagger Class Reference

#include <FclStickyCodeFlagger.h>

Inheritance diagram for FclStickyCodeFlagger:
TpcDataTool

Public Types

using Index = unsigned int
 
using IndexVector = std::vector< Index >
 
using IndexVectorMap = std::map< Index, IndexVector >
 
using IndexPair = std::pair< Index, Index >
 
using IndexPairMap = std::multimap< Index, IndexPair >
 
using Name = std::string
 

Public Member Functions

 FclStickyCodeFlagger (fhicl::ParameterSet const &ps)
 
 ~FclStickyCodeFlagger () override=default
 
DataMap update (AdcChannelData &acds) const override
 

Private Attributes

int m_LogLevel
 
AdcFlag m_StickyCode
 
IndexVectorMap m_stickyCodes
 
IndexPairMap m_stickyRanges
 

Additional Inherited Members

- Private Types inherited from AdcChannelTool
using Index = unsigned int
 
- Private Member Functions inherited from TpcDataTool
virtual DataMap updateTpcData (TpcData &) const
 
virtual DataMap viewTpcData (const TpcData &) const
 
virtual int forwardTpcData () const
 
- Private Member Functions inherited from AdcChannelTool
virtual ~AdcChannelTool ()=default
 
virtual DataMap view (const AdcChannelData &acd) const
 
virtual DataMap updateMap (AdcChannelDataMap &acds) const
 
virtual DataMap viewMap (const AdcChannelDataMap &acds) const
 
virtual bool updateWithView () const
 
virtual bool viewWithUpdate () const
 
virtual DataMap beginEvent (const DuneEventInfo &) const
 
virtual DataMap endEvent (const DuneEventInfo &) const
 
virtual DataMap close (const DataMap *dmin=nullptr)
 
- Static Private Member Functions inherited from AdcChannelTool
static int interfaceNotImplemented ()
 

Detailed Description

Definition at line 38 of file FclStickyCodeFlagger.h.

Member Typedef Documentation

using FclStickyCodeFlagger::Index = unsigned int

Definition at line 42 of file FclStickyCodeFlagger.h.

Definition at line 45 of file FclStickyCodeFlagger.h.

Definition at line 46 of file FclStickyCodeFlagger.h.

Definition at line 43 of file FclStickyCodeFlagger.h.

Definition at line 44 of file FclStickyCodeFlagger.h.

Definition at line 47 of file FclStickyCodeFlagger.h.

Constructor & Destructor Documentation

FclStickyCodeFlagger::FclStickyCodeFlagger ( fhicl::ParameterSet const &  ps)

Definition at line 71 of file FclStickyCodeFlagger_tool.cc.

72 : m_LogLevel(ps.get<int>("LogLevel")),
73  m_StickyCode(ps.get<AdcFlag>("StickyCode")) {
74  const string myname = "FclStickyCodeFlagger::ctor: ";
75  // Display configuration.
76  if ( m_LogLevel ) {
77  cout << myname << "Configuration: " << endl;
78  cout << myname << " LogLevel: " << m_LogLevel << endl;
79  cout << myname << " StickyCode: " << m_StickyCode << endl;
80  }
81  // Check the sticky code.
82  if ( m_StickyCode < AdcStuck || m_StickyCode >= AdcMitigated ) {
83  cout << myname << "WARNING: Flag for sticky code has an unexpected value: "
84  << m_StickyCode << endl;
85  }
86  // Build the sticky code map.
87  fhicl::ParameterSet pstabsc = ps.get<fhicl::ParameterSet>("StickyCodes");
88  IndexVectorMultiMap mvmap;
89  int nerr = readFclIndexMap("chan", "Sticky codes", m_LogLevel, pstabsc, mvmap);
90  for ( const IndexVectorMultiMap::value_type& imma : mvmap ) {
91  Index icha = imma.first;
92  const IndexVector& newcodes = imma.second;
93  IndexVector& codes = m_stickyCodes[icha];
94  codes.insert(codes.end(), newcodes.begin(), newcodes.end());
95  }
96  Index ncha = m_stickyCodes.size();
97  Index ncod = 0;
98  for ( IndexVectorMap::value_type& ient : m_stickyCodes ) ncod += ient.second.size();
99  cout << myname << "Found " << ncod << " sticky code" << (ncod == 1 ? "" : "s") << " for "
100  << ncha << " channel" << (ncha == 1 ? "" : "s") << "." << endl;
101  if ( nerr ) {
102  cout << myname << "WARNING: Found " << nerr << " error" << (nerr == 1 ? "" : "s")
103  << " while parsing the sticky code map." << endl;
104  }
105  // Build the sticky code range map.
106  fhicl::ParameterSet pstabsr = ps.get<fhicl::ParameterSet>("StickyRanges");
107  nerr = readFclIndexMap("chan", "Sticky ranges", m_LogLevel, pstabsr, m_stickyRanges);
108  IndexSet chset;
109  Index nran = m_stickyRanges.size();
110  for ( IndexPairMap::value_type& ient : m_stickyRanges ) chset.insert(ient.first);
111  ncha = chset.size();
112  cout << myname << "Found " << nran << " sticky range" << (nran == 1 ? "" : "s") << " for "
113  << ncha << " channel" << (ncha == 1 ? "" : "s") << "." << endl;
114  if ( nerr ) {
115  cout << myname << "WARNING: Found " << nerr << " error" << (nerr == 1 ? "" : "s")
116  << " while parsing the sticky range map." << endl;
117  }
118 }
std::multimap< Index, IndexVector > IndexVectorMultiMap
std::vector< Index > IndexVector
short AdcFlag
Definition: AdcTypes.h:29
std::set< Index > IndexSet
int readFclIndexMap(string pre, string sdesc, int logLevel, const fhicl::ParameterSet &pstab, std::multimap< Index, T > &dat)
unsigned int Index
IndexVectorMap m_stickyCodes
static constexpr double ps
Definition: Units.h:99
const AdcFlag AdcMitigated
Definition: AdcTypes.h:40
QTextStream & endl(QTextStream &s)
FclStickyCodeFlagger::~FclStickyCodeFlagger ( )
overridedefault

Member Function Documentation

DataMap FclStickyCodeFlagger::update ( AdcChannelData acds) const
overridevirtual

Reimplemented from AdcChannelTool.

Definition at line 122 of file FclStickyCodeFlagger_tool.cc.

122  {
123  const string myname = "FclStickyCodeFlagger::view: ";
124  DataMap ret;
125  // Make sure flags is as long as raw.
126  if ( acd.flags.size() < acd.raw.size() ) {
127  cout << myname << "WARNING: Increasing size of the flags vector for channel " << acd.channel() << endl;
128  acd.flags.resize(acd.raw.size(), AdcGood);
129  }
130  IndexSet samplesToFlag;
131  // Find samples with sticky codes.
132  IndexVectorMap::const_iterator icod = m_stickyCodes.find(acd.channel());
133  if ( icod != m_stickyCodes.end() ) {
134  const IndexVector& codes = icod->second;
135  for ( Index isam=0; isam<acd.raw.size(); ++isam ) {
136  if ( std::find(codes.begin(), codes.end(), acd.raw[isam]) != codes.end() ) samplesToFlag.insert(isam);
137  }
138  }
139  // Find samples with in sticky code ranges.
140  using IndexPairRange = std::pair<IndexPairMap::const_iterator, IndexPairMap::const_iterator>;
141  IndexPairRange irans = m_stickyRanges.equal_range(acd.channel());
142  for ( IndexPairMap::const_iterator iran=irans.first; iran!=irans.second; ++iran ) {
143  IndexPair ran = iran->second;
144  for ( Index isam=0; isam<acd.raw.size(); ++isam ) {
145  AdcIndex adc = acd.raw[isam];
146  if ( adc >= ran.first && adc <= ran.second ) samplesToFlag.insert(isam);
147  }
148  }
149  // Set flags.
150  for ( AdcIndex isam : samplesToFlag ) acd.flags[isam] = m_StickyCode;
151  // Fill output data map and return.
152  ret.setInt("stickyChannel", acd.channel());
153  ret.setInt("stickyCodeCount", samplesToFlag.size());
154  return ret;
155 }
std::vector< Index > IndexVector
std::set< Index > IndexSet
int16_t adc
Definition: CRTFragment.hh:202
intermediate_table::const_iterator const_iterator
unsigned int Index
const AdcFlag AdcGood
Definition: AdcTypes.h:32
IndexVectorMap m_stickyCodes
void setInt(Name name, int val)
Definition: DataMap.h:131
unsigned int AdcIndex
Definition: AdcTypes.h:15
FclStickyCodeFlagger::IndexPair IndexPair
int flags() const
Definition: qtextstream.h:232
QTextStream & endl(QTextStream &s)

Member Data Documentation

int FclStickyCodeFlagger::m_LogLevel
private

Definition at line 58 of file FclStickyCodeFlagger.h.

AdcFlag FclStickyCodeFlagger::m_StickyCode
private

Definition at line 59 of file FclStickyCodeFlagger.h.

IndexVectorMap FclStickyCodeFlagger::m_stickyCodes
private

Definition at line 62 of file FclStickyCodeFlagger.h.

IndexPairMap FclStickyCodeFlagger::m_stickyRanges
private

Definition at line 63 of file FclStickyCodeFlagger.h.


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