LArSoft  v10_04_05
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 16 of file MCBTAlg.cxx.

References Reset().

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

Member Function Documentation

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

Definition at line 164 of file MCBTAlg.cxx.

References _trkid_to_index, and btutil::kINVALID_INDEX.

165  {
166  if (g4_track_id >= _trkid_to_index.size()) return kINVALID_INDEX;
167  return _trkid_to_index[g4_track_id];
168  }
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 97 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().

99  {
100  std::vector<double> res(_num_parts, 0);
101 
102  if (_event_info.size() <= hit.ch) return res;
103 
104  auto const& ch_info = _event_info[hit.ch];
105 
106  auto itlow = ch_info.lower_bound((unsigned int)(clockData.TPCTick2TDC(hit.start)));
107  auto itup = ch_info.upper_bound((unsigned int)(clockData.TPCTick2TDC(hit.end)) + 1);
108 
109  while (itlow != ch_info.end() && itlow != itup) {
110 
111  auto const& edep_info = (*itlow).second;
112 
113  for (size_t part_index = 0; part_index < _num_parts; ++part_index)
114 
115  res[part_index] += edep_info[part_index];
116 
117  ++itlow;
118  }
119  return res;
120  }
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 137 of file MCBTAlg.cxx.

References _num_parts, and MCQ().

139  {
140  std::vector<double> res(_num_parts, 0);
141  for (auto const& h : hit_v) {
142  auto tmp_res = MCQ(clockData, h);
143  for (size_t i = 0; i < res.size(); ++i)
144  res[i] += tmp_res[i];
145  }
146  return res;
147  }
std::vector< double > MCQ(detinfo::DetectorClocksData const &clockData, const WireRange_t &hit) const
Definition: MCBTAlg.cxx:97
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 122 of file MCBTAlg.cxx.

References MCQ(), and sum.

Referenced by MCBTDemo::analyze().

124  {
125  auto res = MCQ(clockData, hit);
126  if (!res.size()) return res;
127 
128  double sum = 0;
129  for (auto const& v : res)
130  sum += v;
131  for (size_t i = 0; i < (res.size() - 1); ++i)
132  res[i] /= (sum - (*res.rbegin()));
133  (*res.rbegin()) /= sum;
134  return res;
135  }
std::vector< double > MCQ(detinfo::DetectorClocksData const &clockData, const WireRange_t &hit) const
Definition: MCBTAlg.cxx:97
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 149 of file MCBTAlg.cxx.

References MCQ(), and sum.

151  {
152  auto res = MCQ(clockData, hit_v);
153  if (!res.size()) return res;
154 
155  double sum = 0;
156  for (auto const& v : res)
157  sum += v;
158  for (size_t i = 0; i < (res.size() - 1); ++i)
159  res[i] /= (sum - (*res.rbegin()));
160  (*res.rbegin()) /= sum;
161  return res;
162  }
std::vector< double > MCQ(detinfo::DetectorClocksData const &clockData, const WireRange_t &hit) const
Definition: MCBTAlg.cxx:97
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 90 of file MCBTAlg.cxx.

References _sum_mcq.

Referenced by MCBTDemo::analyze().

91  {
92  if (plane_id > _sum_mcq.size())
93  throw MCBTException(Form("Invalid plane requested: %zu", plane_id));
94  return _sum_mcq[plane_id];
95  }
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 50 of file MCBTAlg.cxx.

References _event_info, _num_parts, _sum_mcq, _trkid_to_index, Get, and btutil::kINVALID_INDEX.

Referenced by Reset().

51  {
52  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout const>()->Get();
53  _sum_mcq.resize(wireReadoutGeom.Nplanes(), std::vector<double>(_num_parts, 0));
54 
55  for (auto const& sch : simch_v) {
56 
57  auto const ch = sch.Channel();
58  if (_event_info.size() <= ch) _event_info.resize(ch + 1);
59 
60  auto& ch_info = _event_info[ch];
61 
62  size_t plane = wireReadoutGeom.ChannelToWire(ch)[0].Plane;
63 
64  for (auto const& time_ide : sch.TDCIDEMap()) {
65 
66  auto const& time = time_ide.first;
67  auto const& ide_v = time_ide.second;
68 
69  auto& edep_info = ch_info[time];
70 
71  if (!edep_info.size()) edep_info.resize(_num_parts, 0);
72 
73  for (auto const& ide : ide_v) {
74 
75  size_t index = kINVALID_INDEX;
76  if (ide.trackID < (int)(_trkid_to_index.size())) { index = _trkid_to_index[ide.trackID]; }
77  if (_num_parts <= index) {
78  (*edep_info.rbegin()) += ide.numElectrons;
79  (*(_sum_mcq[plane]).rbegin()) += ide.numElectrons;
80  }
81  else {
82  edep_info[index] += ide.numElectrons;
83  _sum_mcq[plane][index] += ide.numElectrons;
84  }
85  }
86  }
87  }
88  }
std::vector< std::vector< double > > _sum_mcq
Definition: MCBTAlg.h:126
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
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
size_t _num_parts
Definition: MCBTAlg.h:127
void MCBTAlg::Register ( const unsigned int &  g4_track_id)
protected

Definition at line 170 of file MCBTAlg.cxx.

References _num_parts, _trkid_to_index, and btutil::kINVALID_INDEX.

Referenced by Reset().

171  {
172  if (_trkid_to_index.size() <= g4_track_id)
173  _trkid_to_index.resize(g4_track_id + 1, kINVALID_INDEX);
174 
175  if (_trkid_to_index[g4_track_id] == kINVALID_INDEX) {
176  _trkid_to_index[g4_track_id] = _num_parts;
177  ++_num_parts;
178  }
179  }
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 181 of file MCBTAlg.cxx.

References _num_parts, _trkid_to_index, and btutil::kINVALID_INDEX.

182  {
183  unsigned int max_id = 0;
184  for (auto const& id : track_id_v)
185  if (max_id < id) max_id = id;
186  if (_trkid_to_index.size() <= max_id) _trkid_to_index.resize(max_id + 1, kINVALID_INDEX);
187 
188  for (auto const& id : track_id_v) {
189 
190  if (_trkid_to_index[id] == kINVALID_INDEX)
191 
193 
194  else
195 
196  throw MCBTException(Form("Doubly used TrackID: %d", id));
197  }
198  ++_num_parts;
199  }
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 22 of file MCBTAlg.cxx.

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

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

24  {
25  _num_parts = 0;
26  _sum_mcq.clear();
27  _trkid_to_index.clear();
28  _event_info.clear();
29  //
30  for (auto const& id : g4_trackid_v)
31  Register(id);
32  _num_parts++;
33  ProcessSimChannel(simch_v);
34  }
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:50
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:170
void MCBTAlg::Reset ( const std::vector< std::vector< unsigned int >> &  g4_trackid_v,
const std::vector< sim::SimChannel > &  simch_v 
)

Definition at line 36 of file MCBTAlg.cxx.

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

38  {
39  _num_parts = 0;
40  _sum_mcq.clear();
41  _trkid_to_index.clear();
42  _event_info.clear();
43  //
44  for (auto const& id : g4_trackid_v)
45  Register(id);
46  _num_parts++;
47  ProcessSimChannel(simch_v);
48  }
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:50
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:170

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: