CMS 3D CMS Logo

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