LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
MCParticleLite.h
Go to the documentation of this file.
1 
14 #ifndef MCPARTICLELITE_H
15 #define MCPARTICLELITE_H
16 
17 // LArSoft
18 //#include "lardataobj/MCBase/MCStep.h"
19 #include "lardataobj/MCBase/MCLimits.h" // kINVALID_X
21 #include "nusimdata/SimulationBase/MCTruth.h" // simb::Origin_t
22 
23 // ROOT libraries
24 #include <TVector3.h>
25 
26 // STL
27 //#include <set>
28 #include <utility> // std::pair<>
29 #include <vector>
30 
31 #include "TLorentzVector.h"
32 
33 namespace sim {
34 
36 
37  public:
39  virtual ~MCParticleLite(){};
40 
41  void AddDaughter(unsigned int d)
42  {
43  if (!this->HasDaughter(d)) _daughters.push_back(d);
44  }
45  bool HasDaughter(unsigned int d) const
46  {
47  return std::find(_daughters.begin(), _daughters.end(), d) != _daughters.end();
48  }
49 
50  // Getters
51  const simb::Origin_t& Origin() const { return _origin; }
52  int PdgCode() const { return _pdgcode; }
53  unsigned int TrackID() const { return _track_id; }
54  const std::string& Process() const { return _process; }
55  unsigned int Mother() const { return _mother; }
56  unsigned int Ancestor() const { return _ancestor; }
57  const TLorentzVector& StartVtx() const { return _start_vtx; }
58  const TLorentzVector& StartMom() const { return _start_mom; }
59  const TLorentzVector& EndVtx() const { return _end_vtx; }
60  const TLorentzVector& EndMom() const { return _end_mom; }
61  const std::vector<std::pair<TLorentzVector, TLorentzVector>>& DetPath() const
62  {
63  return _det_path;
64  }
65  const std::vector<unsigned int>& Daughters() const { return _daughters; }
66 
67  // Setters
68  void Origin(simb::Origin_t o) { _origin = o; }
69  void PdgCode(int id) { _pdgcode = id; }
70  void TrackID(unsigned int id) { _track_id = id; }
71  void Process(const std::string& name) { _process = name; }
72  void Mother(unsigned int id) { _mother = id; }
73  void Ancestor(unsigned int id) { _ancestor = id; }
74  void StartVtx(const TLorentzVector& vtx) { _start_vtx = vtx; }
75  void StartMom(const TLorentzVector& mom) { _start_mom = mom; }
76  void EndVtx(const TLorentzVector& vtx) { _end_vtx = vtx; }
77  void EndMom(const TLorentzVector& mom) { _end_mom = mom; }
78  void DetPath(const std::vector<std::pair<TLorentzVector, TLorentzVector>>& p) { _det_path = p; }
79  void DetPath(std::vector<std::pair<TLorentzVector, TLorentzVector>>&& p)
80  {
81  _det_path = std::move(p);
82  }
83  void Daughters(const std::vector<unsigned int>& d) { _daughters = d; }
84  void Daughters(std::vector<unsigned int>&& d) { _daughters = std::move(d); }
85 
86  virtual operator simb::MCParticle() const
87  {
91  for (auto const& d : _daughters)
92  mcpart.AddDaughter(d);
93  return mcpart;
94  }
95 
97  {
98  _daughters.clear();
99  _det_path.clear();
100  _track_id = (unsigned int)p.TrackId();
101  _pdgcode = p.PdgCode();
102  _mother = (unsigned int)p.Mother();
103  _process = p.Process();
104  _start_vtx = p.Position();
105  _start_mom = p.Momentum();
106  _end_vtx = p.EndPosition();
107  _end_mom = p.EndMomentum();
108  }
109 
110  protected:
111  unsigned int _track_id{kINVALID_UINT};
112  std::string _process{};
113  unsigned int _mother{kINVALID_UINT};
114  unsigned int _ancestor{kINVALID_UINT};
116  TLorentzVector _start_vtx{
118  TLorentzVector _start_mom{TLorentzVector(kINVALID_DOUBLE,
121  kINVALID_DOUBLE)};
122  TLorentzVector _end_vtx{
124  TLorentzVector _end_mom{TLorentzVector(kINVALID_DOUBLE,
127  kINVALID_DOUBLE)};
128  std::vector<std::pair<TLorentzVector, TLorentzVector>> _det_path;
129  std::vector<unsigned int> _daughters;
131  };
132 } // namespace sim
133 
134 #endif
const double kINVALID_DOUBLE
Definition: MCLimits.h:10
unsigned int Ancestor() const
unsigned int _mother
const TLorentzVector & EndVtx() const
const TLorentzVector & Position(const int i=0) const
Definition: MCParticle.h:220
void PdgCode(int id)
void AddDaughter(const int trackID)
Definition: MCParticle.h:269
int PdgCode() const
Definition: MCParticle.h:213
const int kINVALID_INT
Definition: MCLimits.h:16
const TLorentzVector & EndMom() const
const TLorentzVector & StartVtx() const
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
Definition: MCParticle.h:258
const TLorentzVector & EndPosition() const
Definition: MCParticle.h:226
TLorentzVector _end_mom
End momentum in GeV.
unsigned int _ancestor
void Daughters(std::vector< unsigned int > &&d)
void Process(const std::string &name)
Unknown view.
Definition: geo_types.h:142
int Mother() const
Definition: MCParticle.h:214
enum simb::_ev_origin Origin_t
event origin types
unsigned int _track_id
const std::vector< std::pair< TLorentzVector, TLorentzVector > > & DetPath() const
std::vector< unsigned int > _daughters
std::string Process() const
Definition: MCParticle.h:216
bool HasDaughter(unsigned int d) const
Particle class.
std::vector< std::pair< TLorentzVector, TLorentzVector > > _det_path
int TrackId() const
Definition: MCParticle.h:211
const std::string & Process() const
unsigned int Mother() const
void EndMom(const TLorentzVector &mom)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
void Ancestor(unsigned int id)
int PdgCode() const
const std::vector< unsigned int > & Daughters() const
void DetPath(std::vector< std::pair< TLorentzVector, TLorentzVector >> &&p)
TLorentzVector _end_vtx
Float_t d
Definition: plot.C:235
TLorentzVector _start_vtx
void Mother(unsigned int id)
TLorentzVector _start_mom
Start momentum in GeV.
Monte Carlo Simulation.
void StartMom(const TLorentzVector &mom)
void Origin(simb::Origin_t o)
void AddDaughter(unsigned int d)
void DetPath(const std::vector< std::pair< TLorentzVector, TLorentzVector >> &p)
void EndVtx(const TLorentzVector &vtx)
unsigned int TrackID() const
const simb::Origin_t & Origin() const
const TLorentzVector & Momentum(const int i=0) const
Definition: MCParticle.h:221
const unsigned int kINVALID_UINT
Definition: MCLimits.h:14
virtual ~MCParticleLite()
const TLorentzVector & EndMomentum() const
Definition: MCParticle.h:241
::simb::Origin_t _origin
void StartVtx(const TLorentzVector &vtx)
void Daughters(const std::vector< unsigned int > &d)
MCParticleLite(const simb::MCParticle &p)
const TLorentzVector & StartMom() const
void TrackID(unsigned int id)