1
2
3
4
5
6
7
8
9 package org.lcsim.event.base;
10
11 import hep.physics.particle.BasicParticle;
12 import hep.physics.particle.properties.ParticleType;
13 import hep.physics.vec.BasicHep3Vector;
14 import hep.physics.vec.Hep3Vector;
15 import hep.physics.vec.HepLorentzVector;
16 import org.lcsim.event.MCParticle;
17
18
19
20
21
22
23 public class BaseMCParticle extends BasicParticle implements MCParticle
24 {
25
26 protected Hep3Vector _endPoint = new BasicHep3Vector(0., 0., 0.);
27 protected SimulatorStatus _status;
28 protected double charge;
29 protected float[] spin = new float[3];
30 protected int[] colorFlow = new int[2];
31 protected double time;
32
33
34
35
36
37
38
39
40
41 public BaseMCParticle(Hep3Vector origin,HepLorentzVector p,ParticleType ptype,int status, double time)
42 {
43 super(origin, p, ptype, status, time);
44 this.time = time;
45 }
46
47
48
49
50
51 public void setCharge(double charge) {
52 this.charge = charge;
53 }
54
55 @Override
56 public double getCharge() {
57 return Double.isNaN(charge) ? super.getCharge() : charge;
58 }
59
60
61
62
63
64 public void setEndPoint(Hep3Vector p)
65 {
66 _endPoint = p;
67 }
68
69
70
71
72 public void setSimulatorStatus(SimulatorStatus status) {
73 _status = status;
74 }
75
76 public void setSimulatorStatus(int value) {
77 _status = new Status(value);
78 }
79
80 public void setProductionTime(double time)
81 {
82 this.time = time;
83 }
84
85 @Override
86 public double getProductionTime() {
87 return time;
88 }
89
90 public String toString()
91 {
92
93 String className = getClass().getName();
94 int lastDot = className.lastIndexOf('.');
95 if(lastDot!=-1)className = className.substring(lastDot+1);
96 StringBuffer sb = new StringBuffer(className+": "+getType().getName()+"\n");
97 sb.append("pdgId: "+getPDGID()+"\n");
98 sb.append("(x,y,z): ("+getOriginX()+", "+getOriginY()+", "+getOriginZ()+")\n");
99 sb.append("(px,py,pz): ("+getPX()+", "+getPY()+", "+getPZ()+")\n");
100 return sb.toString();
101 }
102
103
104
105
106
107
108
109
110 public SimulatorStatus getSimulatorStatus()
111 {
112 return _status;
113 }
114
115
116
117
118
119 public Hep3Vector getEndPoint()
120 {
121 return _endPoint;
122 }
123
124 public float[] getSpin()
125 {
126 return spin;
127 }
128
129 public int[] getColorFlow()
130 {
131 return colorFlow;
132 }
133
134 protected class Status implements SimulatorStatus {
135 int simulatorStatus;
136 public Status(int v) {
137 simulatorStatus = v;
138 }
139 public boolean vertexIsNotEndpointOfParent()
140 {
141 return (simulatorStatus & (1<<BITVertexIsNotEndpointOfParent)) != 0;
142 }
143
144 public boolean isStopped()
145 {
146 return (simulatorStatus & (1<<BITStopped)) != 0;
147 }
148
149 public boolean isDecayedInTracker()
150 {
151 return (simulatorStatus & (1<<BITDecayedInTracker)) != 0;
152 }
153
154 public boolean isDecayedInCalorimeter()
155 {
156 return (simulatorStatus & (1<<BITDecayedInCalorimeter)) != 0;
157 }
158
159 public boolean isCreatedInSimulation()
160 {
161 return (simulatorStatus & (1<<BITCreatedInSimulation)) != 0;
162 }
163
164 public boolean isBackscatter()
165 {
166 return (simulatorStatus & (1<<BITBackscatter)) != 0;
167 }
168
169 public boolean hasLeftDetector()
170 {
171 return (simulatorStatus & (1<<BITLeftDetector)) != 0;
172 }
173
174 public int getValue()
175 {
176 return simulatorStatus;
177 }
178
179 private final static int BITEndpoint = 31;
180 private final static int BITCreatedInSimulation = 30;
181 private final static int BITBackscatter = 29;
182 private final static int BITVertexIsNotEndpointOfParent = 28;
183 private final static int BITDecayedInTracker = 27;
184 private final static int BITDecayedInCalorimeter = 26;
185 private final static int BITLeftDetector = 25;
186 private final static int BITStopped = 24;
187 }
188 }