LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
MCTrajectory.h
Go to the documentation of this file.
1 
14 
32 
35 
40 
43 
47 
48 #ifndef SIMB_MCTRAJECTORY_H
49 #define SIMB_MCTRAJECTORY_H
50 
51 #include <vector>
52 #include <iostream>
53 
54 #include <TLorentzVector.h>
55 
56 namespace simb {
57 
58  class MCTrajectory {
59  public:
63  typedef std::vector< std::pair<TLorentzVector, TLorentzVector> > list_type;
64  typedef list_type::value_type value_type;
67  typedef list_type::reverse_iterator reverse_iterator;
68  typedef list_type::const_reverse_iterator const_reverse_iterator;
69  typedef list_type::size_type size_type;
70  typedef list_type::difference_type difference_type;
71  typedef std::vector< std::pair<size_t, unsigned char> > ProcessMap;
74  MCTrajectory();
75 
76  private:
77  list_type ftrajectory;
78  ProcessMap fTrajectoryProcess;
79 
81  public:
82 
83  MCTrajectory( const TLorentzVector& vertex,
84  const TLorentzVector& momentum );
85 
87  const TLorentzVector& Position( const size_type ) const;
88  const TLorentzVector& Momentum( const size_type ) const;
89  double X( const size_type i ) const;
90  double Y( const size_type i ) const;
91  double Z( const size_type i ) const;
92  double T( const size_type i ) const;
93  double Px( const size_type i ) const;
94  double Py( const size_type i ) const;
95  double Pz( const size_type i ) const;
96  double E( const size_type i ) const;
97 
98  double TotalLength() const;
99 
100  friend std::ostream& operator<< ( std::ostream& output, const MCTrajectory& );
101 
105  iterator begin();
106  const_iterator begin() const;
107  iterator end();
108  const_iterator end() const;
109  reverse_iterator rbegin();
110  const_reverse_iterator rbegin() const;
111  reverse_iterator rend();
112  const_reverse_iterator rend() const;
113 
114  size_type size() const;
115  bool empty() const;
117  void clear();
118 
119  // Note that there's no non-const version of operator[] or at() here; once
120  // you've added a point to a trajectory, you can't modify it.
121  const value_type& operator[](const size_type i) const;
122  const value_type& at(const size_type i) const;
123 
126  void push_back(value_type const& v );
127  void push_back(TLorentzVector const& p,
128  TLorentzVector const& m );
129  void Add(TLorentzVector const& p,
130  TLorentzVector const& m );
131  void Add(TLorentzVector const& p,
132  TLorentzVector const& m,
133  std::string const& process,
134  bool keepTransportation = false);
135 
136  unsigned char ProcessToKey(std::string const& process) const;
137  std::string KeyToProcess(unsigned char const& key) const;
138  ProcessMap const& TrajectoryProcesses() const;
139 
143  void Sparsify(double margin = .1, bool keep_second_to_last = false);
144 
145  };
146 
147 } // namespace simb
148 
149 inline double simb::MCTrajectory::X ( const size_type i ) const { return Position(i).X(); }
150 inline double simb::MCTrajectory::Y ( const size_type i ) const { return Position(i).Y(); }
151 inline double simb::MCTrajectory::Z ( const size_type i ) const { return Position(i).Z(); }
152 inline double simb::MCTrajectory::T ( const size_type i ) const { return Position(i).T(); }
153 inline double simb::MCTrajectory::Px( const size_type i ) const { return Momentum(i).Px(); }
154 inline double simb::MCTrajectory::Py( const size_type i ) const { return Momentum(i).Py(); }
155 inline double simb::MCTrajectory::Pz( const size_type i ) const { return Momentum(i).Pz(); }
156 inline double simb::MCTrajectory::E ( const size_type i ) const { return Momentum(i).E(); }
157 
167 inline bool simb::MCTrajectory::empty() const { return ftrajectory.empty(); }
168 inline void simb::MCTrajectory::clear() { ftrajectory.clear(); }
170  { ftrajectory.swap( other.ftrajectory ); }
171 
173  { return ftrajectory[i]; }
174 
176  { return ftrajectory.at(i); }
177 
179  { ftrajectory.push_back(v); }
180 
181 inline void simb::MCTrajectory::push_back(const TLorentzVector& p,
182  const TLorentzVector& m )
183  { ftrajectory.push_back( simb::MCTrajectory::value_type(p,m) ); }
184 
185 inline void simb::MCTrajectory::Add(const TLorentzVector& p,
186  const TLorentzVector& m ) { push_back(p,m); }
187 
189 
190 #endif // SIMB_MCTRAJECTORY_H
intermediate_table::iterator iterator
void Add(TLorentzVector const &p, TLorentzVector const &m)
double Z(const size_type i) const
Definition: MCTrajectory.h:151
double X(const size_type i) const
Definition: MCTrajectory.h:149
void push_back(value_type const &v)
double E(const size_type i) const
Definition: MCTrajectory.h:156
reverse_iterator rbegin()
Definition: MCTrajectory.h:162
double Pz(const size_type i) const
Definition: MCTrajectory.h:155
const value_type & at(const size_type i) const
Definition: MCTrajectory.h:175
std::string KeyToProcess(unsigned char const &key) const
intermediate_table::const_iterator const_iterator
std::vector< std::pair< TLorentzVector, TLorentzVector > > list_type
Definition: MCTrajectory.h:63
unsigned char ProcessToKey(std::string const &process) const
list_type::value_type value_type
Definition: MCTrajectory.h:64
bool empty() const
Definition: MCTrajectory.h:167
list_type::size_type size_type
Definition: MCTrajectory.h:69
list_type::difference_type difference_type
Definition: MCTrajectory.h:70
double Y(const size_type i) const
Definition: MCTrajectory.h:150
list_type::const_iterator const_iterator
Definition: MCTrajectory.h:66
ProcessMap fTrajectoryProcess
Definition: MCTrajectory.h:78
list_type::iterator iterator
Definition: MCTrajectory.h:65
const TLorentzVector & Position(const size_type) const
The accessor methods described above.
ProcessMap const & TrajectoryProcesses() const
Definition: MCTrajectory.h:188
ART objects.
reverse_iterator rend()
Definition: MCTrajectory.h:164
list_type::reverse_iterator reverse_iterator
Definition: MCTrajectory.h:67
std::vector< std::pair< size_t, unsigned char > > ProcessMap
Definition: MCTrajectory.h:71
void swap(simb::MCTrajectory &other)
Definition: MCTrajectory.h:169
list_type::const_reverse_iterator const_reverse_iterator
Definition: MCTrajectory.h:68
size_type size() const
Definition: MCTrajectory.h:166
void Sparsify(double margin=.1, bool keep_second_to_last=false)
double TotalLength() const
double T(const size_type i) const
Definition: MCTrajectory.h:152
double Px(const size_type i) const
Definition: MCTrajectory.h:153
const value_type & operator[](const size_type i) const
Definition: MCTrajectory.h:172
double Py(const size_type i) const
Definition: MCTrajectory.h:154
const TLorentzVector & Momentum(const size_type) const
friend std::ostream & operator<<(std::ostream &output, const MCTrajectory &)
list_type ftrajectory
The list of trajectory points.
Definition: MCTrajectory.h:77
vertex reconstruction