~maus-release/maus/release

« back to all changes in this revision

Viewing changes to src/common_py/analysis/analysis_track.py

  • Committer: Paolo Franchini
  • Date: 2018-06-24 14:27:26 UTC
  • mfrom: (659.2.80 release-candidate)
  • Revision ID: p.franchini@warwick.ac.uk-20180624142726-nbxxyjyer146dr1t
Tags: MAUS-v3.2.0
MAUS-v3.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# This file is part of MAUS: http://micewww.pp.rl.ac.uk/projects/maus
 
3
#
 
4
# MAUS is free software: you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation, either version 3 of the License, or
 
7
# (at your option) any later version.
 
8
#
 
9
# MAUS is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with MAUS.  If not, see <http://www.gnu.org/licenses/>.
 
16
#
 
17
 
 
18
"""
 
19
  Defines the AnalysisTrack class.
 
20
 
 
21
  A generic track class that can be used to simplify the analysis of track data.
 
22
"""
 
23
 
 
24
# pylint: disable = W0311, R0902, R0904, R0913, C0103, W0102
 
25
 
 
26
class AnalysisTrack() :
 
27
  """
 
28
    A simple, unified class that holds the essential information, when copied
 
29
    from MAUS data types, during various analyses.
 
30
 
 
31
    Some syntax was borrowed from XBoa for simplicity and because I like the
 
32
    interface!
 
33
  """
 
34
  def __init__( self, trackpoints={}, chisq=0.0, ndf=0, p_value=1.0, status=0 ) :
 
35
    """
 
36
      Initialise object. 
 
37
    """
 
38
    self.__trackpoints = trackpoints
 
39
    self.__chisq = chisq
 
40
    self.__ndf = ndf
 
41
    self.__p_value = p_value
 
42
    self.__status = status
 
43
 
 
44
 
 
45
  def __getitem__(self, index) :
 
46
    """
 
47
      Return a trackpoint from the track at index ``index''
 
48
    """
 
49
    return self.__trackpoints[index]
 
50
    
 
51
 
 
52
  def __setitem__(self, index, item) :
 
53
    """
 
54
      Set the value of the trackpoint in the track at index ``index''
 
55
    """
 
56
    self.__trackpoints[index] = item
 
57
 
 
58
 
 
59
  def __len__(self) :
 
60
    """
 
61
      Return the number of trackpoints in the track>
 
62
    """
 
63
    return len(self.__trackpoints)
 
64
    
 
65
 
 
66
  def get_trackpoint( self, index ) : 
 
67
    """
 
68
      Return a trackpoint from the track at index ``index''
 
69
    """
 
70
    return self.__trackpoints[index]
 
71
 
 
72
 
 
73
  def set_trackpoint( self, index, item ) : 
 
74
    """
 
75
      Set the value of the trackpoint in the track at index ``index''
 
76
    """
 
77
    self.__trackpoints[index] = item
 
78
 
 
79
 
 
80
  def get_p_value( self ) :
 
81
    """
 
82
      Return the track p-value
 
83
    """
 
84
    return self.__p_value
 
85
 
 
86
 
 
87
  def set_p_value( self, pvalue ) :
 
88
    """
 
89
      Set the track p-value
 
90
    """
 
91
    self.__p_value = pvalue
 
92
 
 
93
 
 
94
  def get_chisq( self ) :
 
95
    """
 
96
      Return the track chisq squared
 
97
    """
 
98
    return self.__chisq
 
99
 
 
100
 
 
101
  def set_chisq( self, chisq ) :
 
102
    """
 
103
      Set the track chisq squared
 
104
    """
 
105
    self.__chisq = chisq
 
106
 
 
107
 
 
108
  def get_ndf( self ) :
 
109
    """
 
110
      Get the track No. Degrees of Freedom
 
111
    """
 
112
    return self.__ndf
 
113
 
 
114
 
 
115
  def set_ndf( self, ndf ) :
 
116
    """
 
117
      Set the track No. Degrees of Freedom
 
118
    """
 
119
    self.__ndf = ndf
 
120
 
 
121
 
 
122
  def get_chisq_ndf(self) :
 
123
    """
 
124
      Get the track Chisquared / No. Degrees of Freedom
 
125
    """
 
126
    return self.__chisq / self.__ndf
 
127
 
 
128
 
 
129
  def set_status(self, status) :
 
130
    """
 
131
      Set a undefined status flag
 
132
    """
 
133
    self.__status = status
 
134
 
 
135
 
 
136
  def get_status(self) :
 
137
    """
 
138
      Get the status flag
 
139
    """
 
140
    return self.__status
 
141