1
2
3
4
5
6
7
8
9
10 package org.lcsim.recon.tracking.digitization.sisim;
11
12 import org.lcsim.detector.tracker.silicon.SiSensor;
13
14
15
16
17
18 public class TrackerHitType
19 {
20
21 private CoordinateSystem _coordinate_system;
22 private MeasurementType _measurement_type;
23
24 public enum CoordinateSystem
25 {
26 GLOBAL,
27 SENSOR,
28 UNKNOWN;
29 }
30
31 public enum MeasurementType
32 {
33 STRIP_1D,
34 STRIP_2D,
35 PIXEL;
36 }
37
38
39 public TrackerHitType(CoordinateSystem coordinate_system, MeasurementType measurement_type)
40 {
41 _coordinate_system = coordinate_system;
42 _measurement_type = measurement_type;
43 }
44
45 public CoordinateSystem getCoordinateSystem()
46 {
47 return _coordinate_system;
48 }
49
50 public MeasurementType getMeasurementType()
51 {
52 return _measurement_type;
53 }
54
55 private void setCoordinateSystem(CoordinateSystem coordinate_system)
56 {
57 _coordinate_system = coordinate_system;
58 }
59
60 private void setMeasurementType(MeasurementType measurement_type)
61 {
62 _measurement_type = measurement_type;
63 }
64
65 public static TrackerHitType decoded(int encoded_type)
66 {
67 return Decoder.decoded(encoded_type);
68 }
69
70 public static int encoded(TrackerHitType decoded_type)
71 {
72 return Decoder.encoded(decoded_type);
73 }
74
75 private static class Decoder
76 {
77
78 private static TrackerHitType decoded(int raw_type)
79 {
80 int measurement_type_index = raw_type & 0x3 ;
81 int coordinate_system_index = (raw_type & 0x4) >> 2;
82
83 MeasurementType measurement_type = MeasurementType.values()[measurement_type_index];
84 CoordinateSystem coordinate_system = CoordinateSystem.values()[coordinate_system_index];
85
86 return new TrackerHitType(coordinate_system,measurement_type);
87 }
88
89 private static int encoded(TrackerHitType type)
90 {
91 return (type.getCoordinateSystem().ordinal()<<2) | type.getMeasurementType().ordinal();
92 }
93
94 }
95
96
97
98
99 }