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

#include <TpcData.h>

Public Types

using Index = unsigned int
 
using Name = std::string
 
using Tpc2dRoiVector = std::vector< Tpc2dRoi >
 
using TpcDataMap = std::map< Name, TpcData >
 
using TpcDataVector = std::vector< TpcData * >
 
using AdcData = AdcChannelDataMap
 
using AdcDataPtr = std::shared_ptr< AdcChannelDataMap >
 
using AdcDataVector = std::vector< AdcDataPtr >
 

Public Member Functions

 TpcData ()
 
 TpcData (Index npla)
 
 TpcData (const AdcDataVector &adcs)
 
 TpcData (const TpcData &rhs)=delete
 
TpcDatagetParent ()
 
const TpcDatagetParent () const
 
TpcDataMapgetData ()
 
const TpcDataMapgetData () const
 
AdcDataVectorgetAdcData ()
 
const AdcDataVectorgetAdcData () const
 
Tpc2dRoiVectorget2dRois ()
 
const Tpc2dRoiVectorget2dRois () const
 
TpcDataaddTpcData (Name nam, bool copyAdcData=true)
 
TpcDatagetTpcData (Name nam)
 
const TpcDatagetTpcData (Name nam) const
 
Index getTpcData (Name nam, TpcDataVector &out)
 
AdcDataPtr createAdcData (bool updateParent=true)
 
AdcDataPtr addAdcData (AdcDataPtr padc, bool updateParent=true)
 
void clearAdcData ()
 
std::ostream & print (Name prefix, Index depth=10) const
 

Private Attributes

TpcDatam_parent
 
TpcDataMap m_dat
 
AdcDataVector m_adcs
 
Tpc2dRoiVector m_2drois
 

Detailed Description

Definition at line 25 of file TpcData.h.

Member Typedef Documentation

Definition at line 34 of file TpcData.h.

using TpcData::AdcDataPtr = std::shared_ptr<AdcChannelDataMap>

Definition at line 35 of file TpcData.h.

Definition at line 36 of file TpcData.h.

using TpcData::Index = unsigned int

Definition at line 29 of file TpcData.h.

Definition at line 30 of file TpcData.h.

Definition at line 31 of file TpcData.h.

using TpcData::TpcDataMap = std::map<Name, TpcData>

Definition at line 32 of file TpcData.h.

Definition at line 33 of file TpcData.h.

Constructor & Destructor Documentation

TpcData::TpcData ( )

Definition at line 10 of file TpcData.cxx.

10 : m_parent(nullptr) { }
TpcData * m_parent
Definition: TpcData.h:99
TpcData::TpcData ( Index  npla)

Definition at line 14 of file TpcData.cxx.

14  : m_parent(nullptr), m_adcs(npla) {
15  for ( Index ipla=0; ipla<npla; ++ipla ) m_adcs[ipla].reset(new AdcChannelDataMap);
16 }
AdcDataVector m_adcs
Definition: TpcData.h:101
TpcData * m_parent
Definition: TpcData.h:99
unsigned int Index
QTextStream & reset(QTextStream &s)
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
TpcData::TpcData ( const AdcDataVector adcs)

Definition at line 20 of file TpcData.cxx.

20 : m_parent(nullptr), m_adcs(adcs) { }
AdcDataVector m_adcs
Definition: TpcData.h:101
TpcData * m_parent
Definition: TpcData.h:99
TpcData::TpcData ( const TpcData rhs)
delete

Member Function Documentation

TpcData::AdcDataPtr TpcData::addAdcData ( AdcDataPtr  padc,
bool  updateParent = true 
)

Definition at line 105 of file TpcData.cxx.

105  {
106  m_adcs.push_back(padc);
107  if ( updateParent && m_parent != nullptr ) m_parent->addAdcData(padc, true);
108  return padc;
109 }
AdcDataVector m_adcs
Definition: TpcData.h:101
TpcData * m_parent
Definition: TpcData.h:99
AdcDataPtr addAdcData(AdcDataPtr padc, bool updateParent=true)
Definition: TpcData.cxx:105
TpcData * TpcData::addTpcData ( Name  nam,
bool  copyAdcData = true 
)

Definition at line 24 of file TpcData.cxx.

24  {
25  if ( nam == "" || nam == "." ) return nullptr;
26  Name::size_type ipos = nam.rfind("/");
27  if ( ipos != Name::npos ) {
28  TpcData* pdat = getTpcData(nam.substr(0, ipos));
29  if ( pdat == nullptr ) return nullptr;
30  return pdat->addTpcData(nam.substr(ipos+1), copyAdcData);
31  }
32 
33  if ( m_dat.count(nam) ) return nullptr;
34  TpcData& tpc = m_dat[nam];
35  if ( copyAdcData ) tpc.m_adcs = m_adcs;
36  tpc.m_parent = this;
37  return &tpc;
38 }
AdcDataVector m_adcs
Definition: TpcData.h:101
TpcData * m_parent
Definition: TpcData.h:99
TpcData * addTpcData(Name nam, bool copyAdcData=true)
Definition: TpcData.cxx:24
TpcDataMap m_dat
Definition: TpcData.h:100
TpcData * getTpcData(Name nam)
Definition: TpcData.cxx:42
void TpcData::clearAdcData ( )

Definition at line 113 of file TpcData.cxx.

113  {
114  m_adcs.clear();
115 }
AdcDataVector m_adcs
Definition: TpcData.h:101
TpcData::AdcDataPtr TpcData::createAdcData ( bool  updateParent = true)

Definition at line 99 of file TpcData.cxx.

99  {
100  return addAdcData(AdcDataPtr(new AdcChannelDataMap), updateParent);
101 }
AdcDataPtr addAdcData(AdcDataPtr padc, bool updateParent=true)
Definition: TpcData.cxx:105
std::shared_ptr< AdcChannelDataMap > AdcDataPtr
Definition: TpcData.h:35
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
Tpc2dRoiVector& TpcData::get2dRois ( )
inline

Definition at line 57 of file TpcData.h.

57 { return m_2drois; }
Tpc2dRoiVector m_2drois
Definition: TpcData.h:102
const Tpc2dRoiVector& TpcData::get2dRois ( ) const
inline

Definition at line 58 of file TpcData.h.

58 { return m_2drois; }
Tpc2dRoiVector m_2drois
Definition: TpcData.h:102
AdcDataVector& TpcData::getAdcData ( )
inline

Definition at line 55 of file TpcData.h.

55 { return m_adcs; }
AdcDataVector m_adcs
Definition: TpcData.h:101
const AdcDataVector& TpcData::getAdcData ( ) const
inline

Definition at line 56 of file TpcData.h.

56 { return m_adcs; }
AdcDataVector m_adcs
Definition: TpcData.h:101
TpcDataMap& TpcData::getData ( )
inline

Definition at line 53 of file TpcData.h.

53 { return m_dat; }
TpcDataMap m_dat
Definition: TpcData.h:100
const TpcDataMap& TpcData::getData ( ) const
inline

Definition at line 54 of file TpcData.h.

54 { return m_dat; }
TpcDataMap m_dat
Definition: TpcData.h:100
TpcData* TpcData::getParent ( )
inline

Definition at line 51 of file TpcData.h.

51 { return m_parent; }
TpcData * m_parent
Definition: TpcData.h:99
const TpcData* TpcData::getParent ( ) const
inline

Definition at line 52 of file TpcData.h.

52 { return m_parent; }
TpcData * m_parent
Definition: TpcData.h:99
TpcData * TpcData::getTpcData ( Name  nam)

Definition at line 42 of file TpcData.cxx.

42  {
43  if ( nam == "" || nam == "." ) return this;
44  Name::size_type ipos = nam.find("/");
45  if ( ipos == Name::npos ) return m_dat.count(nam) ? &m_dat[nam] : nullptr;
46  TpcData* pdat = getTpcData(nam.substr(0,ipos));
47  if ( pdat == nullptr ) return nullptr;
48  return pdat->getTpcData(nam.substr(ipos+1));
49 }
TpcDataMap m_dat
Definition: TpcData.h:100
TpcData * getTpcData(Name nam)
Definition: TpcData.cxx:42
const TpcData * TpcData::getTpcData ( Name  nam) const

Definition at line 84 of file TpcData.cxx.

84  {
85  if ( nam == "" || nam == "." ) return this;
86  Name::size_type ipos = nam.find("/");
87  if ( ipos == Name::npos ) {
88  TpcDataMap::const_iterator idat = m_dat.find(nam);
89  if ( idat == m_dat.end() ) return nullptr;
90  return &idat->second;
91  }
92  const TpcData* pdat = getTpcData(nam.substr(0,ipos));
93  if ( pdat == nullptr ) return nullptr;
94  return pdat->getTpcData(nam.substr(ipos+1));
95 }
intermediate_table::const_iterator const_iterator
TpcDataMap m_dat
Definition: TpcData.h:100
TpcData * getTpcData(Name nam)
Definition: TpcData.cxx:42
TpcData::Index TpcData::getTpcData ( Name  nam,
TpcDataVector out 
)

Definition at line 54 of file TpcData.cxx.

54  {
55  Index nerr = 0;
56  if ( nam == "" || nam == "." ) {
57  out.push_back(this);
58  return 0;
59  }
60  if ( nam == "*" ) {
61  for ( TpcDataMap::value_type& idat : m_dat ) {
62  out.push_back(&idat.second);
63  }
64  return 0;
65  }
66  // Split nam --> dnam/rnam
67  Name::size_type ipos = nam.find("/");
68  if ( ipos == Name::npos ) {
69  TpcData* pdat = getTpcData(nam);
70  if ( pdat == nullptr ) ++nerr;
71  else out.push_back(pdat);
72  } else {
73  Name dnam = nam.substr(0,ipos);
74  Name rnam = ipos == Name::npos ? "" : nam.substr(ipos+1);
75  TpcDataVector dirs;
76  nerr += getTpcData(dnam, dirs);
77  for ( TpcData* pdat : dirs ) nerr += pdat->getTpcData(rnam, out);
78  }
79  return nerr;
80 }
ChannelGroupService::Name Name
unsigned int Index
std::vector< TpcData * > TpcDataVector
Definition: TpcData.h:33
TpcDataMap m_dat
Definition: TpcData.h:100
TpcData * getTpcData(Name nam)
Definition: TpcData.cxx:42
std::ostream & TpcData::print ( Name  prefix,
Index  depth = 10 
) const

Definition at line 119 of file TpcData.cxx.

119  {
120  Index nmap = getAdcData().size();
121  cout << prefix << "ADC Channel map count is " << nmap;
122  if ( nmap ) cout << ":";
123  cout << endl;
124  for ( const AdcDataPtr& pacm : getAdcData() ) {
125  if ( ! pacm ) cout << "NULL" << endl;
126  else {
127  cout << prefix << " " << "Channel count " << pacm->size();
128  if ( pacm->size() ) {
129  cout << " in range [" << pacm->begin()->first << ", " << pacm->rbegin()->first << "]";
130  }
131  cout << endl;
132  }
133  }
134  cout << prefix << "2D ROI count is " << get2dRois().size() << endl;
135  cout << prefix << "TPC data count is " << getData().size();
136  if ( getData().size() ) cout << ":";
137  cout << endl;
138  if ( depth > 0 ) {
139  for ( const TpcDataMap::value_type& itpd : getData() ) {
140  cout << prefix << itpd.first << ":" << endl;
141  itpd.second.print(prefix + " ", depth - 1);
142  }
143  }
144  return cout;
145 }
std::shared_ptr< AdcChannelDataMap > AdcDataPtr
Definition: TpcData.h:35
unsigned int Index
TpcDataMap & getData()
Definition: TpcData.h:53
AdcDataVector & getAdcData()
Definition: TpcData.h:55
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
Tpc2dRoiVector & get2dRois()
Definition: TpcData.h:57
QTextStream & endl(QTextStream &s)

Member Data Documentation

Tpc2dRoiVector TpcData::m_2drois
private

Definition at line 102 of file TpcData.h.

AdcDataVector TpcData::m_adcs
private

Definition at line 101 of file TpcData.h.

TpcDataMap TpcData::m_dat
private

Definition at line 100 of file TpcData.h.

TpcData* TpcData::m_parent
private

Definition at line 99 of file TpcData.h.


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