All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MCParticleLite.h
Go to the documentation of this file.
1 /**
2  * \file MCParticleLite.h
3  *
4  * \ingroup MCBase
5  *
6  * \brief Class def header for MCParticleLite data container
7  *
8  * @author Temigo
9  */
10 
11 /** \addtogroup MCBase
12 
13  @{*/
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
20 #include "nusimdata/SimulationBase/MCParticle.h"
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 {
35 
37 
38  public:
39 
41  virtual ~MCParticleLite(){};
42 
43  void AddDaughter(unsigned int d) {
44  if (!this->HasDaughter(d))
45  _daughters.push_back(d);
46  }
47  bool HasDaughter(unsigned int d) const {
48  return std::find(_daughters.begin(), _daughters.end(), d) != _daughters.end();
49  }
50 
51  // Getters
52  const simb::Origin_t& Origin () const { return _origin; }
53  int PdgCode() const { return _pdgcode; }
54  unsigned int TrackID() const { return _track_id; }
55  const std::string& Process() const { return _process; }
56  unsigned int Mother() const { return _mother; }
57  unsigned int Ancestor() const { return _ancestor; }
58  const TLorentzVector& StartVtx() const { return _start_vtx; }
59  const TLorentzVector& StartMom() const { return _start_mom; }
60  const TLorentzVector& EndVtx() const { return _end_vtx; }
61  const TLorentzVector& EndMom() const { return _end_mom; }
62  const std::vector<std::pair<TLorentzVector,TLorentzVector> >& DetPath() const { return _det_path; }
63  const std::vector<unsigned int>& Daughters() const { return _daughters; }
64 
65  // Setters
66  void Origin (simb::Origin_t o) { _origin = o; }
67  void PdgCode(int id) { _pdgcode = id; }
68  void TrackID(unsigned int id) { _track_id = id; }
69  void Process(const std::string &name) { _process = name; }
70  void Mother(unsigned int id) { _mother = id; }
71  void Ancestor(unsigned int id) { _ancestor = id; }
72  void StartVtx(const TLorentzVector& vtx) { _start_vtx = vtx; }
73  void StartMom(const TLorentzVector& mom) { _start_mom = mom; }
74  void EndVtx(const TLorentzVector& vtx) { _end_vtx = vtx; }
75  void EndMom(const TLorentzVector& mom) { _end_mom = mom; }
76  void DetPath(const std::vector<std::pair<TLorentzVector,TLorentzVector> >& p) { _det_path = p; }
77  void DetPath(std::vector<std::pair<TLorentzVector,TLorentzVector> >&& p) { _det_path = std::move(p); }
78  void Daughters(const std::vector<unsigned int>& d) { _daughters = d; }
79  void Daughters(std::vector<unsigned int>&& d) { _daughters = std::move(d); }
80 
81  virtual operator simb::MCParticle() const {
82  simb::MCParticle mcpart(_track_id,
83  _pdgcode,
84  _process,
85  _mother);
86  mcpart.AddTrajectoryPoint(_start_vtx, _start_mom);
87  mcpart.AddTrajectoryPoint(_end_vtx, _end_mom);
88  for (auto const & d : _daughters) mcpart.AddDaughter(d);
89  return mcpart;
90  }
91 
92  MCParticleLite(const simb::MCParticle& p) {
93  _daughters.clear();
94  _det_path.clear();
95  _track_id = (unsigned int) p.TrackId();
96  _pdgcode = p.PdgCode();
97  _mother = (unsigned int) p.Mother();
98  _process = p.Process();
99  _start_vtx = p.Position();
100  _start_mom = p.Momentum();
101  _end_vtx = p.EndPosition();
102  _end_mom = p.EndMomentum();
103  }
104 
105  protected:
106  unsigned int _track_id{kINVALID_UINT};
107  std::string _process{};
108  unsigned int _mother{kINVALID_UINT};
109  unsigned int _ancestor{kINVALID_UINT};
112  TLorentzVector _start_mom{TLorentzVector(kINVALID_DOUBLE, kINVALID_DOUBLE, kINVALID_DOUBLE, kINVALID_DOUBLE)}; ///< Start momentum in GeV
114  TLorentzVector _end_mom{TLorentzVector(kINVALID_DOUBLE, kINVALID_DOUBLE, kINVALID_DOUBLE, kINVALID_DOUBLE)}; ///< End momentum in GeV
115  std::vector<std::pair<TLorentzVector,TLorentzVector> > _det_path;
116  std::vector<unsigned int> _daughters;
117  ::simb::Origin_t _origin{::simb::kUnknown};
118  };
119 } // namespace sim
120 
121 #endif
const double kINVALID_DOUBLE
Definition: MCLimits.h:10
unsigned int Ancestor() const
unsigned int _mother
const std::vector< std::pair< TLorentzVector, TLorentzVector > > & DetPath() const
const TLorentzVector & EndVtx() const
void PdgCode(int id)
const int kINVALID_INT
Definition: MCLimits.h:16
const TLorentzVector & EndMom() const
const TLorentzVector & StartVtx() const
TLorentzVector _end_mom
End momentum in GeV.
unsigned int _ancestor
void Daughters(std::vector< unsigned int > &&d)
void Process(const std::string &name)
pdgs p
Definition: selectors.fcl:22
unsigned int _track_id
std::vector< unsigned int > _daughters
bool HasDaughter(unsigned int d) const
void DetPath(const std::vector< std::pair< TLorentzVector, TLorentzVector > > &p)
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:265
void Ancestor(unsigned int id)
int PdgCode() const
const std::vector< unsigned int > & Daughters() const
TLorentzVector _end_vtx
TLorentzVector _start_vtx
void Mother(unsigned int id)
TLorentzVector _start_mom
Start momentum in GeV.
void DetPath(std::vector< std::pair< TLorentzVector, TLorentzVector > > &&p)
void StartMom(const TLorentzVector &mom)
void Origin(simb::Origin_t o)
void AddDaughter(unsigned int d)
void EndVtx(const TLorentzVector &vtx)
unsigned int TrackID() const
const simb::Origin_t & Origin() const
const unsigned int kINVALID_UINT
Definition: MCLimits.h:14
then echo fcl name
virtual ~MCParticleLite()
::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)
std::vector< std::pair< TLorentzVector, TLorentzVector > > _det_path