xboa
_tracking_base.py
Go to the documentation of this file.
1 #This file is a part of xboa
2 #
3 #xboa is free software: you can redistribute it and/or modify
4 #it under the terms of the GNU General Public License as published by
5 #the Free Software Foundation, either version 3 of the License, or
6 #(at your option) any later version.
7 #
8 #xboa is distributed in the hope that it will be useful,
9 #but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 #GNU General Public License for more details.
12 #
13 #You should have received a copy of the GNU General Public License
14 #along with xboa in the doc folder. If not, see
15 #<http://www.gnu.org/licenses/>.
16 
17 """
18 \namespace xboa::tracking::_tracking_base
19 
20 Should be imported directly from the xboa::tracking namespace
21 """
22 
23 class TrackingBase(object):
24  """
25  Base class provides an interface to particle tracking routines for use by
26  xboa.algorithms
27  """
28  def __init__(self):
29  pass
30 
31  def track_one(self, hit):
32  """
33  Track a hit and return a list of output hits
34  - hit initial particle coordinates to be tracked
35 
36  Track a hit and return a list of output hits. The output hits should
37  corresponds to e.g. particle crossings over cell ends, depending on the
38  usage of the Tracking object. The first item in the list should be the
39  input hit.
40  """
41  raise NotImplementedError("track_one was not implemented")
42 
43  def track_many(self, list_of_hits):
44  """
45  Track many hits and return a list of list of output hits
46  - list_of_hits list of initial particle corodinates to be tracked
47 
48  Track many hits and return a list containing a list of output hits,
49  one for each track. This provides a hook for tracking codes that have
50  significant set up and tear down times, or which simulate collective
51  effects that need to be taken into account by the algorithm
52 
53  By default this calls track_one for each hit; but can be overloaded by
54  a base class
55  """
56  hits_out = [self.track_one(hit) for hit in list_of_hits]
57  return hits_out
58 
def track_one
Track a hit and return a list of output hits.
def track_many
Track many hits and return a list of list of output hits.
Base class provides an interface to particle tracking routines for use by xboa.algorithms.