LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
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...
 
elements
 STL member. More...
 

Protected Attributes

double _x_max
 
double _x_min
 
double _y_max
 
double _y_min
 
double _z_max
 
double _z_min
 

Detailed Description

Definition at line 76 of file MCRecoPart.h.

Constructor & Destructor Documentation

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

Default constructor with fhicl parameters.

Definition at line 15 of file MCRecoPart.cxx.

References _pdg_list, _track_index, _x_max, _x_min, _y_max, _y_min, _z_max, _z_min, clear(), geo::GeometryCore::DetHalfHeight(), geo::GeometryCore::DetHalfWidth(), geo::GeometryCore::DetLength(), and fhicl::ParameterSet::get().

17  {
18  this->clear();
19  _track_index.clear();
20  _pdg_list.clear();
21  for(auto const& id : pset.get<std::vector<int> >("SavePathPDGList"))
22 
23  _pdg_list.insert(id);
24 
26  _y_max = geo->DetHalfHeight();
27  _y_min = (-1.) * _y_max;
28  _z_min = 0;
29  _z_max = geo->DetLength();
30  _x_min = 0;
31  _x_max = 2.*(geo->DetHalfWidth());
32 
33  }
geo::Length_t DetHalfWidth(geo::TPCID const &tpcid) const
Returns the half width of the active volume of the specified TPC.
std::map< unsigned int, unsigned int > _track_index
Track ID => Index Map.
Definition: MCRecoPart.h:111
geo::Length_t DetHalfHeight(geo::TPCID const &tpcid) const
Returns the half height of the active volume of the specified TPC.
geo::Length_t DetLength(geo::TPCID const &tpcid) const
Returns the length of the active volume of the specified TPC.
std::set< int > _pdg_list
PDG code list for which particle&#39;s trajectory within the detector is saved.
Definition: MCRecoPart.h:115
Namespace collecting geometry-related classes utilities.
vec_iX clear()
virtual sim::MCRecoPart::~MCRecoPart ( )
inlinevirtual

Default destructor.

Definition at line 84 of file MCRecoPart.h.

84 {};

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 122 of file MCRecoPart.cxx.

References _pdg_list, _track_index, clear(), and InDetector().

Referenced by MCReco::produce().

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

Definition at line 62 of file MCRecoPart.cxx.

References sim::kINVALID_UINT, MotherTrackID(), and TrackToParticleIndex().

Referenced by sim::MCTrackRecoAlg::Reconstruct(), and sim::MCShowerRecoAlg::Reconstruct().

64  {
65  if(part_index >= this->size()) return kINVALID_UINT;
66 
67  if((*this)[part_index]._ancestor != kINVALID_UINT) return (*this)[part_index]._ancestor;
68 
69  unsigned int result = MotherTrackID(part_index);
70 
71  if(result == this->at(part_index)._track_id) return result;
72 
73  if(!result) return this->at(part_index)._track_id;
74 
75  auto mother_index = TrackToParticleIndex(result);
76 
77  while(1) {
78 
79  if(mother_index != kINVALID_UINT) {
80 
81  auto const new_result = MotherTrackID(mother_index);
82 
83  if(new_result == this->at(mother_index)._track_id) break;
84 
85  result = new_result;
86 
87  }else{
88 
89  // Look for a particle that has a daughter = this mother
90  auto const old_result = result;
91  for(auto const& p : *this) {
92 
93  if(p._daughters.find(result) != p._daughters.end()) {
94  result = p._track_id;
95  break;
96  }
97  }
98  if(result == old_result)
99  break;
100  }
101 
102  mother_index = TrackToParticleIndex(result);
103 
104  }
105 
106  (*this)[part_index]._ancestor = result;
107  return result;
108  }
unsigned int MotherTrackID(const unsigned int part_index) const
Definition: MCRecoPart.cxx:36
const unsigned int kINVALID_UINT
Definition: MCLimits.h:14
unsigned int TrackToParticleIndex(const unsigned int track_id) const
Definition: MCRecoPart.h:97
bool sim::MCRecoPart::InDetector ( const double &  x,
const double &  y,
const double &  z 
) const

Definition at line 111 of file MCRecoPart.cxx.

References _x_max, _x_min, _y_max, _y_min, _z_max, _z_min, x, y, and z.

Referenced by AddParticles().

115  {
116  return !( x > _x_max || x < _x_min ||
117  z > _z_max || z < _z_min ||
118  y > _y_max || y < _y_min );
119  }
Float_t x
Definition: compare.C:6
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:279
unsigned int sim::MCRecoPart::MotherTrackID ( const unsigned int  part_index) const

Definition at line 36 of file MCRecoPart.cxx.

References sim::kINVALID_UINT, part, and TrackToParticleIndex().

Referenced by AncestorTrackID(), sim::MCTrackRecoAlg::Reconstruct(), and sim::MCShowerRecoAlg::Reconstruct().

38  {
39  if(this->size() <= part_index) return ::sim::kINVALID_UINT;
40 
41  unsigned int result = this->at(part_index)._mother;
42 
43  if(!result) return this->at(part_index)._track_id;
44 
45  if(TrackToParticleIndex(result) != ::sim::kINVALID_UINT) return result;
46 
47  //std::cout<< "\033[95mWarning:\033[00m Mother particle not in the particle list!"<<std::endl;
48  // Do brute search
49  unsigned int daughter_id = this->at(part_index)._track_id;
50 
51  for(auto const& part : *this) {
52 
53  if(part._daughters.find(daughter_id) != part._daughters.end())
54 
55  return part._track_id;
56 
57  }
58  return result;
59  }
TString part[npart]
Definition: Style.C:32
const unsigned int kINVALID_UINT
Definition: MCLimits.h:14
unsigned int TrackToParticleIndex(const unsigned int track_id) const
Definition: MCRecoPart.h:97
unsigned int sim::MCRecoPart::TrackToParticleIndex ( const unsigned int  track_id) const
inline

Definition at line 97 of file MCRecoPart.h.

References sim::kINVALID_UINT.

Referenced by AncestorTrackID(), MotherTrackID(), sim::MCTrackRecoAlg::Reconstruct(), and sim::MCShowerRecoAlg::Reconstruct().

98  {
99  auto const iter (_track_index.find(track_id));
100  if(iter==_track_index.end()) return kINVALID_UINT;
101  return (*iter).second;
102  }
std::map< unsigned int, unsigned int > _track_index
Track ID => Index Map.
Definition: MCRecoPart.h:111
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 115 of file MCRecoPart.h.

Referenced by AddParticles(), MCRecoPart(), and sim::MCTrackRecoAlg::Reconstruct().

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

Track ID => Index Map.

Definition at line 111 of file MCRecoPart.h.

Referenced by AddParticles(), sim::MCShowerRecoPart::ConstructShower(), and MCRecoPart().

double sim::MCRecoPart::_x_max
protected

Definition at line 119 of file MCRecoPart.h.

Referenced by InDetector(), and MCRecoPart().

double sim::MCRecoPart::_x_min
protected

Definition at line 119 of file MCRecoPart.h.

Referenced by InDetector(), and MCRecoPart().

double sim::MCRecoPart::_y_max
protected

Definition at line 120 of file MCRecoPart.h.

Referenced by InDetector(), and MCRecoPart().

double sim::MCRecoPart::_y_min
protected

Definition at line 120 of file MCRecoPart.h.

Referenced by InDetector(), and MCRecoPart().

double sim::MCRecoPart::_z_max
protected

Definition at line 121 of file MCRecoPart.h.

Referenced by InDetector(), and MCRecoPart().

double sim::MCRecoPart::_z_min
protected

Definition at line 121 of file MCRecoPart.h.

Referenced by InDetector(), and MCRecoPart().

T std::vector< T >::elements
inherited

STL member.


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