Public Member Functions | Public Attributes | Protected Attributes | List of all members
sim::MCRecoPart Class Reference

#include <MCRecoPart.h>

Inheritance diagram for sim::MCRecoPart:

Public Member Functions

 MCRecoPart (fhicl::ParameterSet const &pset)
 Default constructor with fhicl parameters. More...
 
virtual ~MCRecoPart ()
 Default destructor. More...
 
void AddParticles (const std::vector< simb::MCParticle > &mcp_v, const std::vector< simb::Origin_t > &orig_v)
 
unsigned int AncestorTrackID (const unsigned int part_index)
 
unsigned int MotherTrackID (const unsigned int part_index) const
 
unsigned int TrackToParticleIndex (const unsigned int track_id) const
 
bool InDetector (const double &x, const double &y, const double &z) const
 

Public Attributes

std::map< unsigned int, unsigned int > _track_index
 Track ID => Index Map. More...
 
std::set< int > _pdg_list
 PDG code list for which particle's trajectory within the detector is saved. More...
 

Protected Attributes

double _x_max
 x-max of volume box used to determine whether to save track information More...
 
double _x_min
 x-min of volume box used to determine whether to save track information More...
 
double _y_max
 y-max of volume box used to determine whether to save track information More...
 
double _y_min
 y-min of volume box used to determine whether to save track information More...
 
double _z_max
 z-max of volume box used to determine whether to save track information More...
 
double _z_min
 z-min of volume box used to determine whether to save track information More...
 

Detailed Description

Definition at line 61 of file MCRecoPart.h.

Constructor & Destructor Documentation

sim::MCRecoPart::MCRecoPart ( fhicl::ParameterSet const &  pset)

Default constructor with fhicl parameters.

Definition at line 19 of file MCRecoPart.cxx.

21  {
22  this->clear();
23  _track_index.clear();
24  _pdg_list.clear();
25  for(auto const& id : pset.get<std::vector<int> >("SavePathPDGList"))
26 
27  _pdg_list.insert(id);
28 
30  // Build "Fiducial" Volume Definition:
31  //
32  // Iterate over all TPC's to get bounding box that covers volumes of each individual TPC in the detector
33  _x_min = std::min_element(geo->begin_TPC(), geo->end_TPC(), [](auto const &lhs, auto const &rhs){ return lhs.BoundingBox().MinX() < rhs.BoundingBox().MinX();})->MinX();
34  _y_min = std::min_element(geo->begin_TPC(), geo->end_TPC(), [](auto const &lhs, auto const &rhs){ return lhs.BoundingBox().MinY() < rhs.BoundingBox().MinY();})->MinY();
35  _z_min = std::min_element(geo->begin_TPC(), geo->end_TPC(), [](auto const &lhs, auto const &rhs){ return lhs.BoundingBox().MinZ() < rhs.BoundingBox().MinZ();})->MinZ();
36  _x_max = std::max_element(geo->begin_TPC(), geo->end_TPC(), [](auto const &lhs, auto const &rhs){ return lhs.BoundingBox().MaxX() < rhs.BoundingBox().MaxX();})->MaxX();
37  _y_max = std::max_element(geo->begin_TPC(), geo->end_TPC(), [](auto const &lhs, auto const &rhs){ return lhs.BoundingBox().MaxY() < rhs.BoundingBox().MaxY();})->MaxY();
38  _z_max = std::max_element(geo->begin_TPC(), geo->end_TPC(), [](auto const &lhs, auto const &rhs){ return lhs.BoundingBox().MaxZ() < rhs.BoundingBox().MaxZ();})->MaxZ();
39  }
double _z_max
z-max of volume box used to determine whether to save track information
Definition: MCRecoPart.h:108
double _y_max
y-max of volume box used to determine whether to save track information
Definition: MCRecoPart.h:106
double _y_min
y-min of volume box used to determine whether to save track information
Definition: MCRecoPart.h:107
std::map< unsigned int, unsigned int > _track_index
Track ID => Index Map.
Definition: MCRecoPart.h:96
TPC_iterator begin_TPC() const
Returns an iterator pointing to the first TPC in the detector.
double _z_min
z-min of volume box used to determine whether to save track information
Definition: MCRecoPart.h:109
double _x_max
x-max of volume box used to determine whether to save track information
Definition: MCRecoPart.h:104
double _x_min
x-min of volume box used to determine whether to save track information
Definition: MCRecoPart.h:105
std::set< int > _pdg_list
PDG code list for which particle&#39;s trajectory within the detector is saved.
Definition: MCRecoPart.h:100
vector< vector< double > > clear
LArSoft geometry interface.
Definition: ChannelGeo.h:16
TPC_iterator end_TPC() const
Returns an iterator pointing after the last TPC in the detector.
virtual sim::MCRecoPart::~MCRecoPart ( )
inlinevirtual

Default destructor.

Definition at line 69 of file MCRecoPart.h.

69 {};

Member Function Documentation

void sim::MCRecoPart::AddParticles ( const std::vector< simb::MCParticle > &  mcp_v,
const std::vector< simb::Origin_t > &  orig_v 
)

Definition at line 128 of file MCRecoPart.cxx.

131  {
132  if(orig_v.size() != mcp_v.size()) throw cet::exception(__FUNCTION__) << "MCParticle and Origin_t vector size not same!";
133 
134  this->clear();
135  _track_index.clear();
136 
137  for(size_t i=0; i < mcp_v.size(); ++i) {
138 
139  auto const& mcp = mcp_v[i];
140 
141  //std::cout<<" Track ID : "<<mcp.TrackId()<<" ... Index : " <<this->size()<<std::endl;
142 
143  _track_index.insert(std::make_pair((size_t)(mcp.TrackId()),(size_t)(this->size())));
144 
145  this->push_back(MCMiniPart());
146 
147  auto& mini_mcp = (*this->rbegin());
148 
149  for(size_t i=0; i<(size_t)(mcp.NumberDaughters()); ++i)
150  mini_mcp._daughters.insert(mcp.Daughter(i));
151 
152  mini_mcp._track_id = mcp.TrackId();
153  mini_mcp._pdgcode = mcp.PdgCode();
154  mini_mcp._mother = mcp.Mother();
155  mini_mcp._process = mcp.Process();
156  mini_mcp._start_vtx = mcp.Position();
157  mini_mcp._start_mom = mcp.Momentum();
158  mini_mcp._end_vtx = mcp.EndPosition();
159  mini_mcp._end_mom = mcp.EndMomentum();
160  mini_mcp._origin = orig_v[i];
161 
162  // Change units to LArSoft (MeV, cm, us)
163  for(size_t i=0; i<4; ++i) {
164  mini_mcp._start_mom[i] *= 1.e3;
165  mini_mcp._end_mom[i] *= 1.e3;
166  }
167  /*
168  for(size_t i=0; i<3; ++i) {
169  mini_mcp._start_vtx[i] /= 10.;
170  mini_mcp._end_vtx[i] /= 10.;
171  }
172  mini_mcp.start_vtx[3] /= 1.e-3;
173  mini_mcp.end_vtx[3] /= 1.e-3;
174  */
175 
176  if(_pdg_list.find(mcp.PdgCode()) != _pdg_list.end()) {
177 
178  std::set<size_t> det_path_index;
179 
180  for(size_t i=0; i<mcp.NumberTrajectoryPoints(); ++i) {
181 
182  if(InDetector(mcp.Vx(i),mcp.Vy(i),mcp.Vz(i)))
183 
184  det_path_index.insert(i);
185 
186  }
187 
188  if(det_path_index.size()) {
189  if( (*det_path_index.begin()) )
190  det_path_index.insert( (*det_path_index.begin())-1 );
191  if( det_path_index.size()>1 ) {
192  if( ((*det_path_index.rbegin())+1) < mcp.NumberTrajectoryPoints() )
193  det_path_index.insert( (*det_path_index.rbegin())+1 );
194  }
195  mini_mcp._det_path.reserve(det_path_index.size());
196  for(auto const& index : det_path_index) {
197 
198  TLorentzVector vec(mcp.Momentum(index));
199  for(size_t i=0; i<4; ++i) vec[i] *= 1.e3;
200 
201  mini_mcp._det_path.push_back(std::make_pair(mcp.Position(index),vec));
202 
203  }
204  }
205  }
206  }
207  }
std::map< unsigned int, unsigned int > _track_index
Track ID => Index Map.
Definition: MCRecoPart.h:96
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
fInnerVessel push_back(Point(-578.400000, 0.000000, 0.000000))
std::set< int > _pdg_list
PDG code list for which particle&#39;s trajectory within the detector is saved.
Definition: MCRecoPart.h:100
vector< vector< double > > clear
bool InDetector(const double &x, const double &y, const double &z) const
Definition: MCRecoPart.cxx:117
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
unsigned int sim::MCRecoPart::AncestorTrackID ( const unsigned int  part_index)

Definition at line 68 of file MCRecoPart.cxx.

70  {
71  if(part_index >= this->size()) return kINVALID_UINT;
72 
73  if((*this)[part_index]._ancestor != kINVALID_UINT) return (*this)[part_index]._ancestor;
74 
75  unsigned int result = MotherTrackID(part_index);
76 
77  if(result == this->at(part_index)._track_id) return result;
78 
79  if(!result) return this->at(part_index)._track_id;
80 
81  auto mother_index = TrackToParticleIndex(result);
82 
83  while(1) {
84 
85  if(mother_index != kINVALID_UINT) {
86 
87  auto const new_result = MotherTrackID(mother_index);
88 
89  if(new_result == this->at(mother_index)._track_id) break;
90 
91  result = new_result;
92 
93  }else{
94 
95  // Look for a particle that has a daughter = this mother
96  auto const old_result = result;
97  for(auto const& p : *this) {
98 
99  if(p._daughters.find(result) != p._daughters.end()) {
100  result = p._track_id;
101  break;
102  }
103  }
104  if(result == old_result)
105  break;
106  }
107 
108  mother_index = TrackToParticleIndex(result);
109 
110  }
111 
112  (*this)[part_index]._ancestor = result;
113  return result;
114  }
static QCString result
unsigned int MotherTrackID(const unsigned int part_index) const
Definition: MCRecoPart.cxx:42
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
p
Definition: test.py:223
const unsigned int kINVALID_UINT
Definition: MCLimits.h:14
unsigned int TrackToParticleIndex(const unsigned int track_id) const
Definition: MCRecoPart.h:82
bool sim::MCRecoPart::InDetector ( const double &  x,
const double &  y,
const double &  z 
) const

Definition at line 117 of file MCRecoPart.cxx.

121  {
122  return !( x > _x_max || x < _x_min ||
123  z > _z_max || z < _z_min ||
124  y > _y_max || y < _y_min );
125  }
double _z_max
z-max of volume box used to determine whether to save track information
Definition: MCRecoPart.h:108
double _y_max
y-max of volume box used to determine whether to save track information
Definition: MCRecoPart.h:106
double _y_min
y-min of volume box used to determine whether to save track information
Definition: MCRecoPart.h:107
double _z_min
z-min of volume box used to determine whether to save track information
Definition: MCRecoPart.h:109
double _x_max
x-max of volume box used to determine whether to save track information
Definition: MCRecoPart.h:104
double _x_min
x-min of volume box used to determine whether to save track information
Definition: MCRecoPart.h:105
list x
Definition: train.py:276
unsigned int sim::MCRecoPart::MotherTrackID ( const unsigned int  part_index) const

Definition at line 42 of file MCRecoPart.cxx.

44  {
45  if(this->size() <= part_index) return ::sim::kINVALID_UINT;
46 
47  unsigned int result = this->at(part_index)._mother;
48 
49  if(!result) return this->at(part_index)._track_id;
50 
51  if(TrackToParticleIndex(result) != ::sim::kINVALID_UINT) return result;
52 
53  //std::cout<< "\033[95mWarning:\033[00m Mother particle not in the particle list!"<<std::endl;
54  // Do brute search
55  unsigned int daughter_id = this->at(part_index)._track_id;
56 
57  for(auto const& part : *this) {
58 
59  if(part._daughters.find(daughter_id) != part._daughters.end())
60 
61  return part._track_id;
62 
63  }
64  return result;
65  }
static QCString result
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
const unsigned int kINVALID_UINT
Definition: MCLimits.h:14
unsigned int TrackToParticleIndex(const unsigned int track_id) const
Definition: MCRecoPart.h:82
unsigned int sim::MCRecoPart::TrackToParticleIndex ( const unsigned int  track_id) const
inline

Definition at line 82 of file MCRecoPart.h.

83  {
84  auto const iter (_track_index.find(track_id));
85  if(iter==_track_index.end()) return kINVALID_UINT;
86  return (*iter).second;
87  }
std::map< unsigned int, unsigned int > _track_index
Track ID => Index Map.
Definition: MCRecoPart.h:96
const unsigned int kINVALID_UINT
Definition: MCLimits.h:14

Member Data Documentation

std::set<int> sim::MCRecoPart::_pdg_list

PDG code list for which particle's trajectory within the detector is saved.

Definition at line 100 of file MCRecoPart.h.

std::map<unsigned int, unsigned int> sim::MCRecoPart::_track_index

Track ID => Index Map.

Definition at line 96 of file MCRecoPart.h.

double sim::MCRecoPart::_x_max
protected

x-max of volume box used to determine whether to save track information

Definition at line 104 of file MCRecoPart.h.

double sim::MCRecoPart::_x_min
protected

x-min of volume box used to determine whether to save track information

Definition at line 105 of file MCRecoPart.h.

double sim::MCRecoPart::_y_max
protected

y-max of volume box used to determine whether to save track information

Definition at line 106 of file MCRecoPart.h.

double sim::MCRecoPart::_y_min
protected

y-min of volume box used to determine whether to save track information

Definition at line 107 of file MCRecoPart.h.

double sim::MCRecoPart::_z_max
protected

z-max of volume box used to determine whether to save track information

Definition at line 108 of file MCRecoPart.h.

double sim::MCRecoPart::_z_min
protected

z-min of volume box used to determine whether to save track information

Definition at line 109 of file MCRecoPart.h.


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