LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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 #ifndef __GCCXML__
82  public:
83 
84  MCTrajectory( const TLorentzVector& vertex,
85  const TLorentzVector& momentum );
86 
88  const TLorentzVector& Position( const size_type ) const;
89  const TLorentzVector& Momentum( const size_type ) const;
90  double X( const size_type i ) const;
91  double Y( const size_type i ) const;
92  double Z( const size_type i ) const;
93  double T( const size_type i ) const;
94  double Px( const size_type i ) const;
95  double Py( const size_type i ) const;
96  double Pz( const size_type i ) const;
97  double E( const size_type i ) const;
98 
99  double TotalLength() const;
100 
101  friend std::ostream& operator<< ( std::ostream& output, const MCTrajectory& );
102 
106  iterator begin();
107  const_iterator begin() const;
108  iterator end();
109  const_iterator end() const;
110  reverse_iterator rbegin();
111  const_reverse_iterator rbegin() const;
112  reverse_iterator rend();
113  const_reverse_iterator rend() const;
114 
115  size_type size() const;
116  bool empty() const;
118  void clear();
119 
120  // Note that there's no non-const version of operator[] or at() here; once
121  // you've added a point to a trajectory, you can't modify it.
122  const value_type& operator[](const size_type i) const;
123  const value_type& at(const size_type i) const;
124 
127  void push_back(value_type const& v );
128  void push_back(TLorentzVector const& p,
129  TLorentzVector const& m );
130  void Add(TLorentzVector const& p,
131  TLorentzVector const& m );
132  void Add(TLorentzVector const& p,
133  TLorentzVector const& m,
134  std::string const& process );
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);
144 
145 #endif
146  };
147 
148 } // namespace simb
149 
150 #ifndef __GCCXML__
151 
152 inline double simb::MCTrajectory::X ( const size_type i ) const { return Position(i).X(); }
153 inline double simb::MCTrajectory::Y ( const size_type i ) const { return Position(i).Y(); }
154 inline double simb::MCTrajectory::Z ( const size_type i ) const { return Position(i).Z(); }
155 inline double simb::MCTrajectory::T ( const size_type i ) const { return Position(i).T(); }
156 inline double simb::MCTrajectory::Px( const size_type i ) const { return Momentum(i).Px(); }
157 inline double simb::MCTrajectory::Py( const size_type i ) const { return Momentum(i).Py(); }
158 inline double simb::MCTrajectory::Pz( const size_type i ) const { return Momentum(i).Pz(); }
159 inline double simb::MCTrajectory::E ( const size_type i ) const { return Momentum(i).E(); }
160 
170 inline bool simb::MCTrajectory::empty() const { return ftrajectory.empty(); }
171 inline void simb::MCTrajectory::clear() { ftrajectory.clear(); }
173  { ftrajectory.swap( other.ftrajectory ); }
174 
176  { return ftrajectory[i]; }
177 
179  { return ftrajectory.at(i); }
180 
182  { ftrajectory.push_back(v); }
183 
184 inline void simb::MCTrajectory::push_back(const TLorentzVector& p,
185  const TLorentzVector& m )
186  { ftrajectory.push_back( simb::MCTrajectory::value_type(p,m) ); }
187 
188 inline void simb::MCTrajectory::Add(const TLorentzVector& p,
189  const TLorentzVector& m ) { push_back(p,m); }
190 
192 
193 #endif
194 
195 #endif // SIMB_MCTRAJECTORY_H
void Add(TLorentzVector const &p, TLorentzVector const &m)
double Z(const size_type i) const
Definition: MCTrajectory.h:154
double X(const size_type i) const
Definition: MCTrajectory.h:152
void push_back(value_type const &v)
double E(const size_type i) const
Definition: MCTrajectory.h:159
intermediate_table::iterator iterator
reverse_iterator rbegin()
Definition: MCTrajectory.h:165
double Pz(const size_type i) const
Definition: MCTrajectory.h:158
const value_type & at(const size_type i) const
Definition: MCTrajectory.h:178
std::string KeyToProcess(unsigned char const &key) const
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:170
void Sparsify(double margin=.1)
list_type::size_type size_type
Definition: MCTrajectory.h:69
list_type::difference_type difference_type
Definition: MCTrajectory.h:70
intermediate_table::const_iterator const_iterator
double Y(const size_type i) const
Definition: MCTrajectory.h:153
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:191
Framework includes.
reverse_iterator rend()
Definition: MCTrajectory.h:167
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:172
list_type::const_reverse_iterator const_reverse_iterator
Definition: MCTrajectory.h:68
size_type size() const
Definition: MCTrajectory.h:169
double TotalLength() const
double T(const size_type i) const
Definition: MCTrajectory.h:155
double Px(const size_type i) const
Definition: MCTrajectory.h:156
const value_type & operator[](const size_type i) const
Definition: MCTrajectory.h:175
double Py(const size_type i) const
Definition: MCTrajectory.h:157
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