CMS 3D CMS Logo

SingleParticleEvent.cc
Go to the documentation of this file.
2 
4  int id, double px, double py, double pz, double e, double m, double vx, double vy, double vz, double t0) {
5  ID = ID_in = id;
6  Px = Px_in = px;
7  Py = Py_in = py;
8  Pz = Pz_in = pz;
9  E = E_in = e;
10  M = M_in = m;
11  Vx = Vx_in = vx;
12  Vy = Vy_in = vy;
13  Vz = Vz_in = vz;
14  T0 = T0_in = t0;
15  HitTarget = false;
16 }
17 
18 void SingleParticleEvent::propagate(double ElossScaleFac,
19  double RadiusTarget,
20  double Z_DistTarget,
21  double Z_CentrTarget,
22  bool TrackerOnly,
23  bool MTCCHalf) {
24  MTCC = MTCCHalf; //need to know this boolean in absVzTmp()
25  // calculated propagation direction
26  dX = Px / absmom();
27  dY = Py / absmom();
28  dZ = Pz / absmom();
29  // propagate with decreasing step size
30  tmpVx = Vx;
31  tmpVy = Vy;
32  tmpVz = Vz;
33  double RadiusTargetEff = RadiusTarget;
34  double Z_DistTargetEff = Z_DistTarget;
35  double Z_CentrTargetEff = Z_CentrTarget;
36  if (TrackerOnly == true) {
37  RadiusTargetEff = RadiusTracker;
38  Z_DistTargetEff = Z_DistTracker;
39  }
40  HitTarget = true;
41  if (HitTarget == true) {
42  HitTarget = false;
43  double stepSize = MinStepSize * 100000.;
44  double acceptR = RadiusTargetEff + stepSize;
45  double acceptZ = Z_DistTargetEff + stepSize;
46  bool continuePropagation = true;
47  while (continuePropagation) {
48  //if (tmpVy < -acceptR) continuePropagation = false;
49  if (dY < 0. && tmpVy < -acceptR)
50  continuePropagation = false;
51  if (dY >= 0. && tmpVy > acceptR)
52  continuePropagation = false;
53  //if (absVzTmp() < acceptZ && rVxyTmp() < acceptR){
54  if (std::fabs(tmpVz - Z_CentrTargetEff) < acceptZ && rVxyTmp() < acceptR) {
55  HitTarget = true;
56  continuePropagation = false;
57  }
58  if (continuePropagation)
59  updateTmp(stepSize);
60  }
61  }
62  if (HitTarget == true) {
63  HitTarget = false;
64  double stepSize = MinStepSize * 10000.;
65  double acceptR = RadiusTargetEff + stepSize;
66  double acceptZ = Z_DistTargetEff + stepSize;
67  bool continuePropagation = true;
68  while (continuePropagation) {
69  //if (tmpVy < -acceptR) continuePropagation = false;
70  if (dY < 0. && tmpVy < -acceptR)
71  continuePropagation = false;
72  if (dY >= 0. && tmpVy > acceptR)
73  continuePropagation = false;
74  //if (absVzTmp() < acceptZ && rVxyTmp() < acceptR){
75  if (std::fabs(tmpVz - Z_CentrTargetEff) < acceptZ && rVxyTmp() < acceptR) {
76  HitTarget = true;
77  continuePropagation = false;
78  }
79  if (continuePropagation)
80  updateTmp(stepSize);
81  }
82  }
83  if (HitTarget == true) {
84  HitTarget = false;
85  double stepSize = MinStepSize * 1000.;
86  double acceptR = RadiusTargetEff + stepSize;
87  double acceptZ = Z_DistTargetEff + stepSize;
88  bool continuePropagation = true;
89  while (continuePropagation) {
90  //if (tmpVy < -acceptR) continuePropagation = false;
91  if (dY < 0. && tmpVy < -acceptR)
92  continuePropagation = false;
93  if (dY >= 0. && tmpVy > acceptR)
94  continuePropagation = false;
95  //if (absVzTmp() < acceptZ && rVxyTmp() < acceptR){
96  if (std::fabs(tmpVz - Z_CentrTargetEff) < acceptZ && rVxyTmp() < acceptR) {
97  HitTarget = true;
98  continuePropagation = false;
99  }
100  if (continuePropagation)
101  updateTmp(stepSize);
102  }
103  }
104  if (HitTarget == true) {
105  HitTarget = false;
106  double stepSize = MinStepSize * 100.;
107  double acceptR = RadiusTargetEff + stepSize;
108  double acceptZ = Z_DistTargetEff + stepSize;
109  bool continuePropagation = true;
110  while (continuePropagation) {
111  //if (tmpVy < -acceptR) continuePropagation = false;
112  if (dY < 0. && tmpVy < -acceptR)
113  continuePropagation = false;
114  if (dY >= 0. && tmpVy > acceptR)
115  continuePropagation = false;
116  //if (absVzTmp() < acceptZ && rVxyTmp() < acceptR){
117  if (std::fabs(tmpVz - Z_CentrTargetEff) < acceptZ && rVxyTmp() < acceptR) {
118  HitTarget = true;
119  continuePropagation = false;
120  }
121  if (continuePropagation)
122  updateTmp(stepSize);
123  }
124  }
125  if (HitTarget == true) {
126  HitTarget = false;
127  double stepSize = MinStepSize * 10.;
128  double acceptR = RadiusTargetEff + stepSize;
129  double acceptZ = Z_DistTargetEff + stepSize;
130  bool continuePropagation = true;
131  while (continuePropagation) {
132  //if (tmpVy < -acceptR) continuePropagation = false;
133  if (dY < 0. && tmpVy < -acceptR)
134  continuePropagation = false;
135  if (dY >= 0. && tmpVy > acceptR)
136  continuePropagation = false;
137  //if (absVzTmp() < acceptZ && rVxyTmp() < acceptR){
138  if (std::fabs(tmpVz - Z_CentrTargetEff) < acceptZ && rVxyTmp() < acceptR) {
139  HitTarget = true;
140  continuePropagation = false;
141  }
142  if (continuePropagation)
143  updateTmp(stepSize);
144  }
145  }
146  if (HitTarget == true) {
147  HitTarget = false;
148  double stepSize = MinStepSize * 1.;
149  double acceptR = RadiusTargetEff + stepSize;
150  double acceptZ = Z_DistTargetEff + stepSize;
151  bool continuePropagation = true;
152  while (continuePropagation) {
153  //if (tmpVy < -acceptR) continuePropagation = false;
154  if (dY < 0. && tmpVy < -acceptR)
155  continuePropagation = false;
156  if (dY >= 0. && tmpVy > acceptR)
157  continuePropagation = false;
158  //if (0 < absVzTmp()){ //only check for MTCC setup in last step of propagation, need fine stepSize
159  if (absVzTmp() < acceptZ && rVxyTmp() < acceptR) {
160  if (std::fabs(tmpVz - Z_CentrTargetEff) < acceptZ && rVxyTmp() < acceptR) {
161  HitTarget = true;
162  continuePropagation = false;
163  }
164  }
165  if (continuePropagation)
166  updateTmp(stepSize);
167  }
168  }
169  // actual propagation + energy loss
170  if (HitTarget == true) {
171  HitTarget = false;
172  //int nAir = 0; int nWall = 0; int nRock = 0; int nClay = 0; int nPlug = 0;
173  int nMat[6] = {0, 0, 0, 0, 0, 0};
174  double stepSize = MinStepSize * 1.; // actual step size
175  double acceptR = RadiusCMS + stepSize;
176  double acceptZ = Z_DistCMS + stepSize;
177  if (TrackerOnly == true) {
178  acceptR = RadiusTracker + stepSize;
179  acceptZ = Z_DistTracker + stepSize;
180  }
181  bool continuePropagation = true;
182  while (continuePropagation) {
183  //if (Vy < -acceptR) continuePropagation = false;
184  if (dY < 0. && tmpVy < -acceptR)
185  continuePropagation = false;
186  if (dY >= 0. && tmpVy > acceptR)
187  continuePropagation = false;
188  //if (absVz() < acceptZ && rVxy() < acceptR){
189  if (std::fabs(Vz - Z_CentrTargetEff) < acceptZ && rVxy() < acceptR) {
190  HitTarget = true;
191  continuePropagation = false;
192  }
193  if (continuePropagation)
194  update(stepSize);
195 
196  int Mat = inMat(Vx, Vy, Vz, PlugVx, PlugVz, ClayWidth);
197 
198  nMat[Mat]++;
199  }
200 
201  if (HitTarget) {
202  double lPlug = double(nMat[Plug]) * stepSize;
203  double lWall = double(nMat[Wall]) * stepSize;
204  double lAir = double(nMat[Air]) * stepSize;
205  double lClay = double(nMat[Clay]) * stepSize;
206  double lRock = double(nMat[Rock]) * stepSize;
207  //double lUnknown = double(nMat[Unknown])*stepSize;
208 
209  double waterEquivalents =
210  (lAir * RhoAir + lWall * RhoWall + lRock * RhoRock + lClay * RhoClay + lPlug * RhoPlug) * ElossScaleFac /
211  10.; // [g cm^-2]
213  if (E < MuonMass)
214  HitTarget = false; // muon stopped in the material around the target
215  }
216  }
217  // end of propagation part
218 }
219 
220 void SingleParticleEvent::update(double stepSize) {
221  Vx += stepSize * dX;
222  Vy += stepSize * dY;
223  Vz += stepSize * dZ;
224 }
225 
226 void SingleParticleEvent::updateTmp(double stepSize) {
227  tmpVx += stepSize * dX;
228  tmpVy += stepSize * dY;
229  tmpVz += stepSize * dZ;
230 }
231 
232 void SingleParticleEvent::subtractEloss(double waterEquivalents) {
233  double L10E = log10(E);
234  // parameters for standard rock (PDG 2004, page 230)
235  double A = (1.91514 + 0.254957 * L10E) / 1000.; // a [GeV g^-1 cm^2]
236  double B = (0.379763 + 1.69516 * L10E - 0.175026 * L10E * L10E) / 1000000.; // b [g^-1 cm^2]
237  double EPS = A / B; // epsilon [GeV]
238  E = (E + EPS) * exp(-B * waterEquivalents) - EPS; // updated energy
239  double oldAbsMom = absmom();
240  double newAbsMom = sqrt(E * E - MuonMass * MuonMass);
241  Px = Px * newAbsMom / oldAbsMom; // updated px
242  Py = Py * newAbsMom / oldAbsMom; // updated py
243  Pz = Pz * newAbsMom / oldAbsMom; // updated pz
244 }
245 
246 double SingleParticleEvent::Eloss(double waterEquivalents, double Energy) {
247  double L10E = log10(Energy);
248  // parameters for standard rock (PDG 2004, page 230)
249  double A = (1.91514 + 0.254957 * L10E) / 1000.; // a [GeV g^-1 cm^2]
250  double B = (0.379763 + 1.69516 * L10E - 0.175026 * L10E * L10E) / 1000000.; // b [g^-1 cm^2]
251  double EPS = A / B; // epsilon [GeV]
252  double newEnergy = (Energy + EPS) * exp(-B * waterEquivalents) - EPS; // updated energy
253  double EnergyLoss = Energy - newEnergy;
254  return EnergyLoss;
255 }
256 
257 void SingleParticleEvent::setEug(double Eug) { E_ug = Eug; }
258 
259 double SingleParticleEvent::Eug() { return E_ug; }
260 
261 double SingleParticleEvent::deltaEmin(double E_sf) {
262  double dE = Eloss(waterEquivalents, E_sf);
263  return E_ug - (E_sf - dE);
264 }
265 
267  double Vy_in,
268  double Vz_in,
269  double Px_in,
270  double Py_in,
271  double Pz_in,
272  double& Vx_up,
273  double& Vy_up,
274  double& Vz_up) {
275  //determine vertex of muon at Surface (+PlugWidth)
276  double dy = Vy_in - (SurfaceOfEarth + PlugWidth);
277  Vy_up = Vy_in - dy;
278  Vx_up = Vx_in - dy * Px_in / Py_in;
279  Vz_up = Vz_in - dy * Pz_in / Py_in;
280  if (Debug)
281  std::cout << "Vx_up=" << Vx_up << " Vy_up=" << Vy_up << " Vz_up=" << Vz_up << std::endl;
282 }
283 
285  if (MTCC == true) {
286  return tmpVz; //need sign to be sure muon hits half of CMS with MTCC setup
287  } else {
288  return std::fabs(tmpVz);
289  }
290 }
291 
293 
295 
297 
298 double SingleParticleEvent::px_in() { return Px_in; }
299 
300 double SingleParticleEvent::py_in() { return Py_in; }
301 
302 double SingleParticleEvent::pz_in() { return Pz_in; }
303 
304 double SingleParticleEvent::e_in() { return E_in; }
305 
306 double SingleParticleEvent::m_in() { return M_in; }
307 
308 double SingleParticleEvent::vx_in() { return Vx_in; }
309 
310 double SingleParticleEvent::vy_in() { return Vy_in; }
311 
312 double SingleParticleEvent::vz_in() { return Vz_in; }
313 
314 double SingleParticleEvent::t0_in() { return T0_in; }
315 
316 int SingleParticleEvent::id() { return ID; }
317 
318 double SingleParticleEvent::px() { return Px; }
319 
320 double SingleParticleEvent::py() { return Py; }
321 
322 double SingleParticleEvent::pz() { return Pz; }
323 
324 double SingleParticleEvent::e() { return E; }
325 
326 double SingleParticleEvent::m() { return M; }
327 
328 double SingleParticleEvent::vx() { return Vx; }
329 
330 double SingleParticleEvent::vy() { return Vy; }
331 
332 double SingleParticleEvent::vz() { return Vz; }
333 
334 double SingleParticleEvent::t0() { return T0; }
335 
337 
339  double phiXZ = atan2(Px, Pz);
340  if (phiXZ < 0.)
341  phiXZ = phiXZ + TwoPi;
342  return phiXZ;
343 }
344 
345 double SingleParticleEvent::theta() { return atan2(sqrt(Px * Px + Pz * Pz), -Py); }
346 
347 double SingleParticleEvent::absmom() { return sqrt(Px * Px + Py * Py + Pz * Pz); }
348 
349 double SingleParticleEvent::absVz() { return std::fabs(Vz); }
350 
351 double SingleParticleEvent::rVxy() { return sqrt(Vx * Vx + Vy * Vy); }
const double TwoPi
void propagate(double ElossScaleFac, double RadiusTarget, double Z_DistTarget, double Z_CentrTarget, bool TrackerOnly, bool MTCCHalf)
Definition: APVGainStruct.h:7
#define EPS
const double Z_DistTracker
double Eloss(double waterEquivalents, double Energy)
void updateTmp(double stepSize)
void subtractEloss(double waterEquivalents)
const double PlugWidth
const double RadiusCMS
void update(double stepSize)
const double SurfaceOfEarth
T sqrt(T t)
Definition: SSEVec.h:23
const double Z_DistCMS
double deltaEmin(double Energy)
void SurfProj(double Vx_in, double Vy_in, double Vz_in, double Px_in, double Py_in, double Pz_in, double &Vx_up, double &Vy_up, double &Vz_up)
int inMat(double vx, double vy, double vz, double PlugVx=PlugOnShaftVx, double PlugVz=PlugOnShaftVz, double ClayWidth=DefaultClayWidth)
const double MinStepSize
void create(int id, double px, double py, double pz, double e, double m, double vx, double vy, double vz, double t0)
const double MuonMass
const double RadiusTracker
Definition: APVGainStruct.h:7
const bool Debug
MPlex< T, D1, D2, N > atan2(const MPlex< T, D1, D2, N > &y, const MPlex< T, D1, D2, N > &x)
Definition: Matriplex.h:648