Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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.

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.

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:24

Member Function Documentation

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

Definition at line 175 of file MCBTAlg.cxx.

176  {
177  if (g4_track_id >= _trkid_to_index.size()) return kINVALID_INDEX;
178  return _trkid_to_index[g4_track_id];
179  }
static const size_t kINVALID_INDEX
Signifies invalid MCX index number.
std::vector< size_t > _trkid_to_index
Definition: MCBTAlg.h:129
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 106 of file MCBTAlg.cxx.

107  {
108  std::vector<double> res(_num_parts, 0);
109 
110  if (_event_info.size() <= hit.ch) return res;
111 
112  auto const& ch_info = _event_info[hit.ch];
113 
114  auto itlow = ch_info.lower_bound((unsigned int)(clockData.TPCTick2TDC(hit.start)));
115  auto itup = ch_info.upper_bound((unsigned int)(clockData.TPCTick2TDC(hit.end)) + 1);
116 
117  while (itlow != ch_info.end() && itlow != itup) {
118 
119  auto const& edep_info = (*itlow).second;
120 
121  for (size_t part_index = 0; part_index < _num_parts; ++part_index)
122 
123  res[part_index] += edep_info[part_index];
124 
125  ++itlow;
126  }
127  return res;
128  }
std::vector<::btutil::ch_info_t > _event_info
Definition: MCBTAlg.h:128
Detector simulation of raw signals on wires.
size_t _num_parts
Definition: MCBTAlg.h:131
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 146 of file MCBTAlg.cxx.

148  {
149  std::vector<double> res(_num_parts, 0);
150  for (auto const& h : hit_v) {
151  auto tmp_res = MCQ(clockData, h);
152  for (size_t i = 0; i < res.size(); ++i)
153  res[i] += tmp_res[i];
154  }
155  return res;
156  }
std::vector< double > MCQ(detinfo::DetectorClocksData const &clockData, const WireRange_t &hit) const
Definition: MCBTAlg.cxx:106
size_t _num_parts
Definition: MCBTAlg.h:131
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 131 of file MCBTAlg.cxx.

132  {
133  auto res = MCQ(clockData, hit);
134  if (!res.size()) return res;
135 
136  double sum = 0;
137  for (auto const& v : res)
138  sum += v;
139  for (size_t i = 0; i < (res.size() - 1); ++i)
140  res[i] /= (sum - (*res.rbegin()));
141  (*res.rbegin()) /= sum;
142  return res;
143  }
std::vector< double > MCQ(detinfo::DetectorClocksData const &clockData, const WireRange_t &hit) const
Definition: MCBTAlg.cxx:106
Detector simulation of raw signals on wires.
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 159 of file MCBTAlg.cxx.

161  {
162  auto res = MCQ(clockData, hit_v);
163  if (!res.size()) return res;
164 
165  double sum = 0;
166  for (auto const& v : res)
167  sum += v;
168  for (size_t i = 0; i < (res.size() - 1); ++i)
169  res[i] /= (sum - (*res.rbegin()));
170  (*res.rbegin()) /= sum;
171  return res;
172  }
std::vector< double > MCQ(detinfo::DetectorClocksData const &clockData, const WireRange_t &hit) const
Definition: MCBTAlg.cxx:106
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 98 of file MCBTAlg.cxx.

99  {
100  if (plane_id > _sum_mcq.size())
101  throw MCBTException(Form("Invalid plane requested: %zu", plane_id));
102  return _sum_mcq[plane_id];
103  }
std::vector< std::vector< double > > _sum_mcq
Definition: MCBTAlg.h:130
size_t btutil::MCBTAlg::NumParts ( ) const
inline

Definition at line 116 of file MCBTAlg.h.

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

Definition at line 54 of file MCBTAlg.cxx.

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

Definition at line 182 of file MCBTAlg.cxx.

183  {
184  if (_trkid_to_index.size() <= g4_track_id)
185  _trkid_to_index.resize(g4_track_id + 1, kINVALID_INDEX);
186 
187  if (_trkid_to_index[g4_track_id] == kINVALID_INDEX) {
188  _trkid_to_index[g4_track_id] = _num_parts;
189  ++_num_parts;
190  }
191  }
static const size_t kINVALID_INDEX
Signifies invalid MCX index number.
std::vector< size_t > _trkid_to_index
Definition: MCBTAlg.h:129
size_t _num_parts
Definition: MCBTAlg.h:131
void MCBTAlg::Register ( const std::vector< unsigned int > &  g4_track_id)
protected

Definition at line 194 of file MCBTAlg.cxx.

195  {
196  unsigned int max_id = 0;
197  for (auto const& id : track_id_v)
198  if (max_id < id) max_id = id;
199  if (_trkid_to_index.size() <= max_id) _trkid_to_index.resize(max_id + 1, kINVALID_INDEX);
200 
201  for (auto const& id : track_id_v) {
202 
203  if (_trkid_to_index[id] == kINVALID_INDEX)
204 
206 
207  else
208 
209  throw MCBTException(Form("Doubly used TrackID: %d", id));
210  }
211  ++_num_parts;
212  }
static const size_t kINVALID_INDEX
Signifies invalid MCX index number.
std::vector< size_t > _trkid_to_index
Definition: MCBTAlg.h:129
size_t _num_parts
Definition: MCBTAlg.h:131
void MCBTAlg::Reset ( const std::vector< unsigned int > &  g4_trackid_v,
const std::vector< sim::SimChannel > &  simch_v 
)

Definition at line 24 of file MCBTAlg.cxx.

26  {
27  _num_parts = 0;
28  _sum_mcq.clear();
29  _trkid_to_index.clear();
30  _event_info.clear();
31  //
32  for (auto const& id : g4_trackid_v)
33  Register(id);
34  _num_parts++;
35  ProcessSimChannel(simch_v);
36  }
std::vector< std::vector< double > > _sum_mcq
Definition: MCBTAlg.h:130
std::vector<::btutil::ch_info_t > _event_info
Definition: MCBTAlg.h:128
void ProcessSimChannel(const std::vector< sim::SimChannel > &simch_v)
Definition: MCBTAlg.cxx:54
std::vector< size_t > _trkid_to_index
Definition: MCBTAlg.h:129
size_t _num_parts
Definition: MCBTAlg.h:131
void Register(const unsigned int &g4_track_id)
Definition: MCBTAlg.cxx:182
void MCBTAlg::Reset ( const std::vector< std::vector< unsigned int >> &  g4_trackid_v,
const std::vector< sim::SimChannel > &  simch_v 
)

Definition at line 39 of file MCBTAlg.cxx.

41  {
42  _num_parts = 0;
43  _sum_mcq.clear();
44  _trkid_to_index.clear();
45  _event_info.clear();
46  //
47  for (auto const& id : g4_trackid_v)
48  Register(id);
49  _num_parts++;
50  ProcessSimChannel(simch_v);
51  }
std::vector< std::vector< double > > _sum_mcq
Definition: MCBTAlg.h:130
std::vector<::btutil::ch_info_t > _event_info
Definition: MCBTAlg.h:128
void ProcessSimChannel(const std::vector< sim::SimChannel > &simch_v)
Definition: MCBTAlg.cxx:54
std::vector< size_t > _trkid_to_index
Definition: MCBTAlg.h:129
size_t _num_parts
Definition: MCBTAlg.h:131
void Register(const unsigned int &g4_track_id)
Definition: MCBTAlg.cxx:182

Member Data Documentation

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

Definition at line 128 of file MCBTAlg.h.

size_t btutil::MCBTAlg::_num_parts
protected

Definition at line 131 of file MCBTAlg.h.

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

Definition at line 130 of file MCBTAlg.h.

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

Definition at line 129 of file MCBTAlg.h.


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