LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 (const WireRange_t &hit) const
 
std::vector< double > MCQFrac (const WireRange_t &hit) const
 
std::vector< double > MCQ (const std::vector< btutil::WireRange_t > &hit_v) const
 
std::vector< double > MCQFrac (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 51 of file MCBTAlg.h.

Constructor & Destructor Documentation

btutil::MCBTAlg::MCBTAlg ( )
inline

Definition at line 55 of file MCBTAlg.h.

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

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

Definition at line 8 of file MCBTAlg.cxx.

References Reset().

10  {
11  Reset(g4_trackid_v,simch_v);
12  }
void Reset(const std::vector< unsigned int > &g4_trackid_v, const std::vector< sim::SimChannel > &simch_v)
Definition: MCBTAlg.cxx:14

Member Function Documentation

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

Definition at line 159 of file MCBTAlg.cxx.

References _trkid_to_index, and btutil::kINVALID_INDEX.

160  {
161  if(g4_track_id >= _trkid_to_index.size()) return kINVALID_INDEX;
162  return _trkid_to_index[g4_track_id];
163  }
static const size_t kINVALID_INDEX
Signifies invalid MCX index number.
std::vector< size_t > _trkid_to_index
Definition: MCBTAlg.h:120
std::vector< double > MCBTAlg::MCQ ( 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 95 of file MCBTAlg.cxx.

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

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

96  {
97  std::vector<double> res(_num_parts,0);
98 
99  if(_event_info.size() <= hit.ch) return res;
100 
101  auto const& ch_info = _event_info[hit.ch];
102 
103  const detinfo::DetectorClocks* ts = lar::providerFrom<detinfo::DetectorClocksService>();
104  //auto ts = ::larutil::TimeService::GetME();
105 
106  auto itlow = ch_info.lower_bound((unsigned int)(ts->TPCTick2TDC(hit.start)));
107  auto itup = ch_info.upper_bound((unsigned int)(ts->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  }
Detector simulation of raw signals on wires.
Conversion of times between different formats and references.
virtual double TPCTick2TDC(double tick) const =0
Converts a TPC time tick into a electronics time tick.
size_t _num_parts
Definition: MCBTAlg.h:122
std::vector< ::btutil::ch_info_t > _event_info
Definition: MCBTAlg.h:119
std::vector< double > MCBTAlg::MCQ ( 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 136 of file MCBTAlg.cxx.

References _num_parts, and MCQ().

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

References MCQ().

Referenced by MCBTDemo::analyze().

124  {
125  auto res = MCQ(hit);
126  if(!res.size()) return res;
127 
128  double sum = 0;
129  for(auto const& v : res) sum += v;
130  for(size_t i=0; i<(res.size()-1); ++i)
131  res[i] /= (sum - (*res.rbegin()));
132  (*res.rbegin()) /= sum;
133  return res;
134  }
Detector simulation of raw signals on wires.
std::vector< double > MCQ(const WireRange_t &hit) const
Definition: MCBTAlg.cxx:95
std::vector< double > MCBTAlg::MCQFrac ( 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 146 of file MCBTAlg.cxx.

References MCQ().

147  {
148  auto res = MCQ(hit_v);
149  if(!res.size()) return res;
150 
151  double sum = 0;
152  for(auto const& v : res) sum += v;
153  for(size_t i=0; i<(res.size()-1); ++i)
154  res[i] /= (sum - (*res.rbegin()));
155  (*res.rbegin()) /= sum;
156  return res;
157  }
std::vector< double > MCQ(const WireRange_t &hit) const
Definition: MCBTAlg.cxx:95
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 88 of file MCBTAlg.cxx.

References _sum_mcq.

Referenced by MCBTDemo::analyze().

89  {
90  if(plane_id > _sum_mcq.size())
91  throw MCBTException(Form("Invalid plane requested: %zu",plane_id));
92  return _sum_mcq[plane_id];
93  }
std::vector< std::vector< double > > _sum_mcq
Definition: MCBTAlg.h:121
size_t btutil::MCBTAlg::NumParts ( ) const
inline

Definition at line 109 of file MCBTAlg.h.

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

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

Definition at line 43 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().

44  {
45 
47  //auto geo = ::larutil::Geometry::GetME();
48  _sum_mcq.resize(geo->Nplanes(),std::vector<double>(_num_parts,0));
49 
50  for(auto const& sch : simch_v) {
51 
52  auto const ch = sch.Channel();
53  if(_event_info.size() <= ch) _event_info.resize(ch+1);
54 
55  auto& ch_info = _event_info[ch];
56 
57  size_t plane = geo->ChannelToWire(ch)[0].Plane;
58  //size_t plane = geo->ChannelToPlane(ch);
59 
60  for(auto const& time_ide : sch.TDCIDEMap()) {
61 
62  auto const& time = time_ide.first;
63  auto const& ide_v = time_ide.second;
64 
65  auto& edep_info = ch_info[time];
66 
67  if(!edep_info.size()) edep_info.resize(_num_parts,0);
68 
69  for(auto const& ide : ide_v) {
70 
71  size_t index = kINVALID_INDEX;
72  if(ide.trackID < (int)(_trkid_to_index.size())){
73  index = _trkid_to_index[ide.trackID];
74  }
75  if(_num_parts <= index) {
76  (*edep_info.rbegin()) += ide.numElectrons;
77  (*(_sum_mcq[plane]).rbegin()) += ide.numElectrons;
78  }
79  else {
80  edep_info[index] += ide.numElectrons;
81  _sum_mcq[plane][index] += ide.numElectrons;
82  }
83  }
84  }
85  }
86  }
std::vector< std::vector< double > > _sum_mcq
Definition: MCBTAlg.h:121
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
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:120
size_t _num_parts
Definition: MCBTAlg.h:122
Namespace collecting geometry-related classes utilities.
std::vector< ::btutil::ch_info_t > _event_info
Definition: MCBTAlg.h:119
void MCBTAlg::Register ( const unsigned int &  g4_track_id)
protected

Definition at line 165 of file MCBTAlg.cxx.

References _num_parts, _trkid_to_index, and btutil::kINVALID_INDEX.

Referenced by Reset().

166  {
167  if(_trkid_to_index.size() <= g4_track_id)
168  _trkid_to_index.resize(g4_track_id+1,kINVALID_INDEX);
169 
170  if(_trkid_to_index[g4_track_id] == kINVALID_INDEX){
171  _trkid_to_index[g4_track_id] = _num_parts;
172  ++_num_parts;
173  }
174  }
static const size_t kINVALID_INDEX
Signifies invalid MCX index number.
std::vector< size_t > _trkid_to_index
Definition: MCBTAlg.h:120
size_t _num_parts
Definition: MCBTAlg.h:122
void MCBTAlg::Register ( const std::vector< unsigned int > &  g4_track_id)
protected

Definition at line 176 of file MCBTAlg.cxx.

References _num_parts, _trkid_to_index, and btutil::kINVALID_INDEX.

177  {
178  unsigned int max_id = 0;
179  for(auto const& id : track_id_v) if(max_id < id) max_id = id;
180  if(_trkid_to_index.size() <= max_id)
181  _trkid_to_index.resize(max_id+1,kINVALID_INDEX);
182 
183  for(auto const& id : track_id_v) {
184 
186 
188 
189  else
190 
191  throw MCBTException(Form("Doubly used TrackID: %d",id));
192 
193  }
194  ++_num_parts;
195  }
static const size_t kINVALID_INDEX
Signifies invalid MCX index number.
std::vector< size_t > _trkid_to_index
Definition: MCBTAlg.h:120
size_t _num_parts
Definition: MCBTAlg.h:122
void MCBTAlg::Reset ( const std::vector< unsigned int > &  g4_trackid_v,
const std::vector< sim::SimChannel > &  simch_v 
)

Definition at line 14 of file MCBTAlg.cxx.

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

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

16  {
17  _num_parts = 0;
18  _sum_mcq.clear();
19  _trkid_to_index.clear();
20  _event_info.clear();
21  //
22  for(auto const& id : g4_trackid_v)
23  Register(id);
24  _num_parts++;
25  ProcessSimChannel(simch_v);
26 
27  }
std::vector< std::vector< double > > _sum_mcq
Definition: MCBTAlg.h:121
void ProcessSimChannel(const std::vector< sim::SimChannel > &simch_v)
Definition: MCBTAlg.cxx:43
std::vector< size_t > _trkid_to_index
Definition: MCBTAlg.h:120
size_t _num_parts
Definition: MCBTAlg.h:122
void Register(const unsigned int &g4_track_id)
Definition: MCBTAlg.cxx:165
std::vector< ::btutil::ch_info_t > _event_info
Definition: MCBTAlg.h:119
void MCBTAlg::Reset ( const std::vector< std::vector< unsigned int > > &  g4_trackid_v,
const std::vector< sim::SimChannel > &  simch_v 
)

Definition at line 29 of file MCBTAlg.cxx.

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

31  {
32  _num_parts = 0;
33  _sum_mcq.clear();
34  _trkid_to_index.clear();
35  _event_info.clear();
36  //
37  for(auto const& id : g4_trackid_v)
38  Register(id);
39  _num_parts++;
40  ProcessSimChannel(simch_v);
41  }
std::vector< std::vector< double > > _sum_mcq
Definition: MCBTAlg.h:121
void ProcessSimChannel(const std::vector< sim::SimChannel > &simch_v)
Definition: MCBTAlg.cxx:43
std::vector< size_t > _trkid_to_index
Definition: MCBTAlg.h:120
size_t _num_parts
Definition: MCBTAlg.h:122
void Register(const unsigned int &g4_track_id)
Definition: MCBTAlg.cxx:165
std::vector< ::btutil::ch_info_t > _event_info
Definition: MCBTAlg.h:119

Member Data Documentation

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

Definition at line 119 of file MCBTAlg.h.

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

size_t btutil::MCBTAlg::_num_parts
protected

Definition at line 122 of file MCBTAlg.h.

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

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

Definition at line 121 of file MCBTAlg.h.

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

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

Definition at line 120 of file MCBTAlg.h.

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


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