1 package org.lcsim.recon.tracking.trfbase;
2 import Jama.Matrix;
3
4
5
6
7
8
9
10 public class HitDerivative
11 {
12 private Matrix _mat;
13 private int _size;
14
15
16
17
18
19 private HitDerivative( Matrix mtx )
20 {
21 _size = mtx.getRowDimension();
22 _mat = (Matrix) mtx.clone();
23 }
24
25
26
27
28 public HitDerivative()
29 {
30 _size = 0;
31 _mat = new Matrix(_size, 5);
32 }
33
34
35
36
37
38 public HitDerivative( int size)
39 {
40 _size = size;
41 _mat = new Matrix(_size, 5);
42 }
43
44
45
46
47
48
49
50 public HitDerivative( int size, double[] arr )
51 {
52
53 _size = size;
54 _mat = new Matrix(_size, 5);
55 int i=0;
56 int j=0;
57 int k=0;
58 while(k<_size*5)
59 {
60 for (j = 0; j<5; ++j)
61 {
62 _mat.set(i,j,arr[k++]);
63 }
64 i++;
65 j=0;
66 }
67 }
68
69
70
71
72
73
74 public HitDerivative( HitDerivative hder )
75 {
76 _size = hder.size();
77 _mat = hder.matrix();
78 }
79
80
81
82
83
84
85
86
87
88
89
90
91
92 public Matrix matrix()
93 {
94 return _mat.copy();
95 }
96
97
98
99
100
101 public int size()
102 {
103 return _size;
104 }
105
106
107
108
109
110
111
112 public double get( int i, int j )
113 {
114 return _mat.get(i,j);
115 }
116
117
118
119
120
121
122
123 public void set(int i, int j, double val)
124 {
125 _mat.set(i, j, val);
126 }
127
128
129
130
131
132
133 public double min( )
134 { return _mat.min(); };
135
136
137
138
139
140 public double max( )
141 { return _mat.max(); };
142
143
144
145
146
147 public double amin( )
148 { return _mat.amin(); };
149
150
151
152
153
154 public double amax( )
155 { return _mat.amax(); };
156
157
158
159
160
161
162
163 public HitDerivative plusEquals( HitDerivative hder)
164 {
165 if(_size != hder.size()) throw new IllegalArgumentException("HitVectors have different dimensions!");
166
167 return new HitDerivative( _mat.plusEquals(hder.matrix()) );
168 }
169
170
171
172
173
174
175 public HitDerivative minusEquals( HitDerivative hder)
176 {
177 if(_size != hder.size()) throw new IllegalArgumentException("HitVectors have different dimensions!");
178
179 return new HitDerivative( _mat.minusEquals(hder.matrix()) );
180 }
181
182
183
184
185
186
187 public HitDerivative plus( HitDerivative hd)
188 {
189 return new HitDerivative( _mat.plus(hd.matrix()) );
190 }
191
192
193
194
195
196
197 public HitDerivative minus(HitDerivative hd)
198 {
199 return new HitDerivative( _mat.minus(hd.matrix()) );
200 }
201
202
203
204
205
206
207
208 public boolean equals( HitDerivative hd )
209 {
210 if ( _size != hd.size() ) return false;
211 Matrix tmp = hd.matrix();
212 for(int i =0; i<_size; ++i)
213 {
214 for (int j=0; j<5; ++j)
215 {
216 if(_mat.get(i,j)!=tmp.get(i,j)) return false;
217 }
218 }
219 return true;
220 }
221
222
223
224
225
226 public boolean notEquals( HitDerivative hd)
227 {
228 return ! equals(hd);
229 }
230
231
232
233
234
235
236
237
238
239
240
241
242 public String toString()
243 {
244 String className = getClass().getName();
245 int lastDot = className.lastIndexOf('.');
246 if(lastDot!=-1)className = className.substring(lastDot+1);
247
248 return className+"\n"+_mat.toString();
249 }
250
251 }