LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
btutil::MCBTAlg Class Reference

#include "MCBTAlg.h"

Public Member Functions

 MCBTAlg ()
 
 MCBTAlg (const std::vector< unsigned int > &g4_trackid_v, const std::vector< sim::SimChannel > &simch_v)
 
void Reset (const std::vector< unsigned int > &g4_trackid_v, const std::vector< sim::SimChannel > &simch_v)
 
void Reset (const std::vector< std::vector< unsigned int >> &g4_trackid_v, const std::vector< sim::SimChannel > &simch_v)
 
const std::vector< double > & MCQSum (const size_t plane_id) const
 
std::vector< double > MCQ (detinfo::DetectorClocksData const &clockData, const WireRange_t &hit) const
 
std::vector< double > MCQFrac (detinfo::DetectorClocksData const &clockData, const WireRange_t &hit) const
 
std::vector< double > MCQ (detinfo::DetectorClocksData const &clockData, const std::vector< btutil::WireRange_t > &hit_v) const
 
std::vector< double > MCQFrac (detinfo::DetectorClocksData const &clockData, const std::vector< btutil::WireRange_t > &hit_v) const
 
size_t Index (const unsigned int g4_track_id) const
 
size_t NumParts () const
 

Protected Member Functions

void Register (const unsigned int &g4_track_id)
 
void Register (const std::vector< unsigned int > &g4_track_id)
 
void ProcessSimChannel (const std::vector< sim::SimChannel > &simch_v)
 

Protected Attributes

std::vector<::btutil::ch_info_t_event_info
 
std::vector< size_t > _trkid_to_index
 
std::vector< std::vector< double > > _sum_mcq
 
size_t _num_parts
 

Detailed Description

Definition at line 54 of file MCBTAlg.h.

Constructor & Destructor Documentation

btutil::MCBTAlg::MCBTAlg ( )
inline

Definition at line 57 of file MCBTAlg.h.

References Reset(), and lar::dump::vector().

57 {}
MCBTAlg::MCBTAlg ( const std::vector< unsigned int > &  g4_trackid_v,
const std::vector< sim::SimChannel > &  simch_v 
)

Definition at line 17 of file MCBTAlg.cxx.

References Reset().

19  {
20  Reset(g4_trackid_v, simch_v);
21  }
void Reset(const std::vector< unsigned int > &g4_trackid_v, const std::vector< sim::SimChannel > &simch_v)
Definition: MCBTAlg.cxx:23

Member Function Documentation

size_t MCBTAlg::Index ( const unsigned int  g4_track_id) const

Definition at line 168 of file MCBTAlg.cxx.

References _trkid_to_index, and btutil::kINVALID_INDEX.

169  {
170  if (g4_track_id >= _trkid_to_index.size()) return kINVALID_INDEX;
171  return _trkid_to_index[g4_track_id];
172  }
static const size_t kINVALID_INDEX
Signifies invalid MCX index number.
std::vector< size_t > _trkid_to_index
Definition: MCBTAlg.h:125
std::vector< double > MCBTAlg::MCQ ( detinfo::DetectorClocksData const &  clockData,
const WireRange_t hit 
) const

Relate Hit => MCShower/MCTrack (called MCX). Returns a vector of double w/ length = # of relevant MCX + 1. Each entry is # drifted electrons from each relevant MCX. The last element contains a sum of drifted electrons that do not belong to any of relevant MCX.

Definition at line 101 of file MCBTAlg.cxx.

References _event_info, _num_parts, btutil::WireRange_t::ch, btutil::WireRange_t::end, btutil::WireRange_t::start, and detinfo::DetectorClocksData::TPCTick2TDC().

Referenced by MCBTDemo::analyze(), ShowerQuality::analyze(), btutil::MCMatchAlg::BuildMap(), MCQ(), and MCQFrac().

103  {
104  std::vector<double> res(_num_parts, 0);
105 
106  if (_event_info.size() <= hit.ch) return res;
107 
108  auto const& ch_info = _event_info[hit.ch];
109 
110  auto itlow = ch_info.lower_bound((unsigned int)(clockData.TPCTick2TDC(hit.start)));
111  auto itup = ch_info.upper_bound((unsigned int)(clockData.TPCTick2TDC(hit.end)) + 1);
112 
113  while (itlow != ch_info.end() && itlow != itup) {
114 
115  auto const& edep_info = (*itlow).second;
116 
117  for (size_t part_index = 0; part_index < _num_parts; ++part_index)
118 
119  res[part_index] += edep_info[part_index];
120 
121  ++itlow;
122  }
123  return res;
124  }
std::vector<::btutil::ch_info_t > _event_info
Definition: MCBTAlg.h:124
Detector simulation of raw signals on wires.
size_t _num_parts
Definition: MCBTAlg.h:127
std::vector< double > MCBTAlg::MCQ ( detinfo::DetectorClocksData const &  clockData,
const std::vector< btutil::WireRange_t > &  hit_v 
) const

Relate Cluster => MCX. Returns a vector of double w/ length = # of relevant MCXs + 1. Each entry is # drifted electrons from each relevant MCX. The last element contains a sum of drifted electrons that do not belong to any of relevant MCX.

Definition at line 141 of file MCBTAlg.cxx.

References _num_parts, and MCQ().

143  {
144  std::vector<double> res(_num_parts, 0);
145  for (auto const& h : hit_v) {
146  auto tmp_res = MCQ(clockData, h);
147  for (size_t i = 0; i < res.size(); ++i)
148  res[i] += tmp_res[i];
149  }
150  return res;
151  }
std::vector< double > MCQ(detinfo::DetectorClocksData const &clockData, const WireRange_t &hit) const
Definition: MCBTAlg.cxx:101
size_t _num_parts
Definition: MCBTAlg.h:127
std::vector< double > MCBTAlg::MCQFrac ( detinfo::DetectorClocksData const &  clockData,
const WireRange_t hit 
) const

Relate Hit => MCX. Returns a vector of double w/ length = # of relevant MCXs + 1. Each entry is a fraction of # drifted electrons within the specified time range from each relevant MCX. The last element contains a sum of drifted electrons that do not belong to any of relevant MCX.

Definition at line 126 of file MCBTAlg.cxx.

References MCQ(), and sum.

Referenced by MCBTDemo::analyze().

128  {
129  auto res = MCQ(clockData, hit);
130  if (!res.size()) return res;
131 
132  double sum = 0;
133  for (auto const& v : res)
134  sum += v;
135  for (size_t i = 0; i < (res.size() - 1); ++i)
136  res[i] /= (sum - (*res.rbegin()));
137  (*res.rbegin()) /= sum;
138  return res;
139  }
std::vector< double > MCQ(detinfo::DetectorClocksData const &clockData, const WireRange_t &hit) const
Definition: MCBTAlg.cxx:101
Detector simulation of raw signals on wires.
Double_t sum
Definition: plot.C:31
std::vector< double > MCBTAlg::MCQFrac ( detinfo::DetectorClocksData const &  clockData,
const std::vector< btutil::WireRange_t > &  hit_v 
) const

Relate Cluster => MCX. Returns a vector of double w/ length = # of relevant MCXs + 1. Each entry is a fraction of # drifted electrons within the specified time range from each relevant MCX. The last element contains a sum of drifted electrons that do not belong to any of relevant MCX.

Definition at line 153 of file MCBTAlg.cxx.

References MCQ(), and sum.

155  {
156  auto res = MCQ(clockData, hit_v);
157  if (!res.size()) return res;
158 
159  double sum = 0;
160  for (auto const& v : res)
161  sum += v;
162  for (size_t i = 0; i < (res.size() - 1); ++i)
163  res[i] /= (sum - (*res.rbegin()));
164  (*res.rbegin()) /= sum;
165  return res;
166  }
std::vector< double > MCQ(detinfo::DetectorClocksData const &clockData, const WireRange_t &hit) const
Definition: MCBTAlg.cxx:101
Double_t sum
Definition: plot.C:31
const std::vector< double > & MCBTAlg::MCQSum ( const size_t  plane_id) const

Returns MC charge sum per MCX for a specified plane

Definition at line 94 of file MCBTAlg.cxx.

References _sum_mcq.

Referenced by MCBTDemo::analyze().

95  {
96  if (plane_id > _sum_mcq.size())
97  throw MCBTException(Form("Invalid plane requested: %zu", plane_id));
98  return _sum_mcq[plane_id];
99  }
std::vector< std::vector< double > > _sum_mcq
Definition: MCBTAlg.h:126
size_t btutil::MCBTAlg::NumParts ( ) const
inline

Definition at line 115 of file MCBTAlg.h.

Referenced by btutil::MCMatchAlg::BuildMap().

115 { return _num_parts - 1; }
size_t _num_parts
Definition: MCBTAlg.h:127
void MCBTAlg::ProcessSimChannel ( const std::vector< sim::SimChannel > &  simch_v)
protected

Definition at line 51 of file MCBTAlg.cxx.

References _event_info, _num_parts, _sum_mcq, _trkid_to_index, geo::GeometryCore::ChannelToWire(), btutil::kINVALID_INDEX, and geo::GeometryCore::Nplanes().

Referenced by Reset().

52  {
53 
55  //auto geo = ::larutil::Geometry::GetME();
56  _sum_mcq.resize(geo->Nplanes(), std::vector<double>(_num_parts, 0));
57 
58  for (auto const& sch : simch_v) {
59 
60  auto const ch = sch.Channel();
61  if (_event_info.size() <= ch) _event_info.resize(ch + 1);
62 
63  auto& ch_info = _event_info[ch];
64 
65  size_t plane = geo->ChannelToWire(ch)[0].Plane;
66  //size_t plane = geo->ChannelToPlane(ch);
67 
68  for (auto const& time_ide : sch.TDCIDEMap()) {
69 
70  auto const& time = time_ide.first;
71  auto const& ide_v = time_ide.second;
72 
73  auto& edep_info = ch_info[time];
74 
75  if (!edep_info.size()) edep_info.resize(_num_parts, 0);
76 
77  for (auto const& ide : ide_v) {
78 
79  size_t index = kINVALID_INDEX;
80  if (ide.trackID < (int)(_trkid_to_index.size())) { index = _trkid_to_index[ide.trackID]; }
81  if (_num_parts <= index) {
82  (*edep_info.rbegin()) += ide.numElectrons;
83  (*(_sum_mcq[plane]).rbegin()) += ide.numElectrons;
84  }
85  else {
86  edep_info[index] += ide.numElectrons;
87  _sum_mcq[plane][index] += ide.numElectrons;
88  }
89  }
90  }
91  }
92  }
std::vector< WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
std::vector< std::vector< double > > _sum_mcq
Definition: MCBTAlg.h:126
std::vector<::btutil::ch_info_t > _event_info
Definition: MCBTAlg.h:124
static const size_t kINVALID_INDEX
Signifies invalid MCX index number.
std::vector< size_t > _trkid_to_index
Definition: MCBTAlg.h:125
unsigned int Nplanes(TPCID const &tpcid=tpc_zero) const
Returns the total number of planes in the specified TPC.
Definition: GeometryCore.h:977
size_t _num_parts
Definition: MCBTAlg.h:127
Namespace collecting geometry-related classes utilities.
void MCBTAlg::Register ( const unsigned int &  g4_track_id)
protected

Definition at line 174 of file MCBTAlg.cxx.

References _num_parts, _trkid_to_index, and btutil::kINVALID_INDEX.

Referenced by Reset().

175  {
176  if (_trkid_to_index.size() <= g4_track_id)
177  _trkid_to_index.resize(g4_track_id + 1, kINVALID_INDEX);
178 
179  if (_trkid_to_index[g4_track_id] == kINVALID_INDEX) {
180  _trkid_to_index[g4_track_id] = _num_parts;
181  ++_num_parts;
182  }
183  }
static const size_t kINVALID_INDEX
Signifies invalid MCX index number.
std::vector< size_t > _trkid_to_index
Definition: MCBTAlg.h:125
size_t _num_parts
Definition: MCBTAlg.h:127
void MCBTAlg::Register ( const std::vector< unsigned int > &  g4_track_id)
protected

Definition at line 185 of file MCBTAlg.cxx.

References _num_parts, _trkid_to_index, and btutil::kINVALID_INDEX.

186  {
187  unsigned int max_id = 0;
188  for (auto const& id : track_id_v)
189  if (max_id < id) max_id = id;
190  if (_trkid_to_index.size() <= max_id) _trkid_to_index.resize(max_id + 1, kINVALID_INDEX);
191 
192  for (auto const& id : track_id_v) {
193 
194  if (_trkid_to_index[id] == kINVALID_INDEX)
195 
197 
198  else
199 
200  throw MCBTException(Form("Doubly used TrackID: %d", id));
201  }
202  ++_num_parts;
203  }
static const size_t kINVALID_INDEX
Signifies invalid MCX index number.
std::vector< size_t > _trkid_to_index
Definition: MCBTAlg.h:125
size_t _num_parts
Definition: MCBTAlg.h:127
void MCBTAlg::Reset ( const std::vector< unsigned int > &  g4_trackid_v,
const std::vector< sim::SimChannel > &  simch_v 
)

Definition at line 23 of file MCBTAlg.cxx.

References _event_info, _num_parts, _sum_mcq, _trkid_to_index, ProcessSimChannel(), and Register().

Referenced by btutil::MCMatchAlg::BuildMap(), and MCBTAlg().

25  {
26  _num_parts = 0;
27  _sum_mcq.clear();
28  _trkid_to_index.clear();
29  _event_info.clear();
30  //
31  for (auto const& id : g4_trackid_v)
32  Register(id);
33  _num_parts++;
34  ProcessSimChannel(simch_v);
35  }
std::vector< std::vector< double > > _sum_mcq
Definition: MCBTAlg.h:126
std::vector<::btutil::ch_info_t > _event_info
Definition: MCBTAlg.h:124
void ProcessSimChannel(const std::vector< sim::SimChannel > &simch_v)
Definition: MCBTAlg.cxx:51
std::vector< size_t > _trkid_to_index
Definition: MCBTAlg.h:125
size_t _num_parts
Definition: MCBTAlg.h:127
void Register(const unsigned int &g4_track_id)
Definition: MCBTAlg.cxx:174
void MCBTAlg::Reset ( const std::vector< std::vector< unsigned int >> &  g4_trackid_v,
const std::vector< sim::SimChannel > &  simch_v 
)

Definition at line 37 of file MCBTAlg.cxx.

References _event_info, _num_parts, _sum_mcq, _trkid_to_index, ProcessSimChannel(), and Register().

39  {
40  _num_parts = 0;
41  _sum_mcq.clear();
42  _trkid_to_index.clear();
43  _event_info.clear();
44  //
45  for (auto const& id : g4_trackid_v)
46  Register(id);
47  _num_parts++;
48  ProcessSimChannel(simch_v);
49  }
std::vector< std::vector< double > > _sum_mcq
Definition: MCBTAlg.h:126
std::vector<::btutil::ch_info_t > _event_info
Definition: MCBTAlg.h:124
void ProcessSimChannel(const std::vector< sim::SimChannel > &simch_v)
Definition: MCBTAlg.cxx:51
std::vector< size_t > _trkid_to_index
Definition: MCBTAlg.h:125
size_t _num_parts
Definition: MCBTAlg.h:127
void Register(const unsigned int &g4_track_id)
Definition: MCBTAlg.cxx:174

Member Data Documentation

std::vector<::btutil::ch_info_t> btutil::MCBTAlg::_event_info
protected

Definition at line 124 of file MCBTAlg.h.

Referenced by MCQ(), ProcessSimChannel(), and Reset().

size_t btutil::MCBTAlg::_num_parts
protected

Definition at line 127 of file MCBTAlg.h.

Referenced by MCQ(), ProcessSimChannel(), Register(), and Reset().

std::vector<std::vector<double> > btutil::MCBTAlg::_sum_mcq
protected

Definition at line 126 of file MCBTAlg.h.

Referenced by MCQSum(), ProcessSimChannel(), and Reset().

std::vector<size_t> btutil::MCBTAlg::_trkid_to_index
protected

Definition at line 125 of file MCBTAlg.h.

Referenced by Index(), ProcessSimChannel(), Register(), and Reset().


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