Fork me on GitHub

source: svn/trunk/src/BFieldProp.cc@ 90

Last change on this file since 90 was 90, checked in by severine ovyn, 16 years ago

remove 1 bug in BField prop

File size: 2.7 KB
Line 
1/*
2 * ---- Delphes ----
3 * A Fast Simulator for general purpose LHC detector
4 * S. Ovyn ~~~~ severine.ovyn@uclouvain.be
5 *
6 * Center for Particle Physics and Phenomenology (CP3)
7 * Universite Catholique de Louvain (UCL)
8 * Louvain-la-Neuve, Belgium
9 * */
10
11#include "interface/BFieldProp.h"
12#include "TRandom.h"
13
14#include <iostream>
15#include <sstream>
16#include <fstream>
17#include <iomanip>
18
19#include<cmath>
20
21
22using namespace std;
23
24
25//------------------------------------------------------------------------------
26
27TrackPropagation::TrackPropagation() {
28
29 MAXITERATION = 10000;
30 MINSEGLENGTH = 70;
31
32}
33
34void TrackPropagation::Propagation(const TRootGenParticle *Part,TLorentzVector &genMomentum)
35{
36
37 double q = Charge(Part->PID);
38 if(q==0)return;
39
40 float Xvertex1 = Part->X;
41 float Yvertex1 = Part->Y;
42 float Zvertex1 = Part->Z;
43
44 //out of trackibg coverage?
45 if(sqrt(Xvertex1*Xvertex1+Yvertex1*Yvertex1) > TRACKING_RADIUS){return;}
46 if(fabs(Zvertex1) > TRACKING_LENGTH){return;}
47
48 float Px = Part->Px;
49 float Py = Part->Py;
50 float Pz = Part->Pz;
51
52 double px = Px / 0.003;
53 double py = Py / 0.003;
54 double pz = Pz / 0.003;
55 double pt = sqrt(px*px+py*py);
56 double p = sqrt(px*px+py*py+pz*pz);
57
58 if(q!=0){
59 double M = Part->M;
60 double vx = px/M;
61 double vy = py/M;
62 double vz = pz/M;
63
64 double Bx = BFIELD_X;
65 double By = BFIELD_Y;
66 double Bz = BFIELD_Z;
67
68 double ax = (q/M)*(Bz*vy - By*vz);
69 double ay = (q/M)*(Bx*vz - Bz*vx);
70 double az = (q/M)*(By*vx - Bx*vy);
71 double dt = 1/p;
72 if(pt<266 && vz < 0.0012) dt = fabs(0.001/vz);
73
74 double xold=Xvertex1; double x=xold;
75 double yold=Yvertex1; double y=yold;
76 double zold=Zvertex1; double z=zold;
77
78 double VTold = sqrt(vx*vx+vy*vy);
79
80 int k = 0;
81
82 while(k < MAXITERATION){
83 k++;
84
85 vx += ax*dt;
86 vy += ay*dt;
87 vz += az*dt;
88
89 double VTratio = VTold/sqrt(vx*vx+vy*vy);
90 vx *= VTratio;
91 vy *= VTratio;
92
93 ax = (q/M)*(Bz*vy - By*vz);
94 ay = (q/M)*(Bx*vz - Bz*vx);
95 az = (q/M)*(By*vx - Bx*vy);
96
97 x += vx*dt;
98 y += vy*dt;
99 z += vz*dt;
100
101 if( (x*x+y*y) > TRACKING_RADIUS*TRACKING_RADIUS ){ x /= (x*x+y*y)/(TRACKING_RADIUS*TRACKING_RADIUS); y /= (x*x+y*y)/(TRACKING_RADIUS*TRACKING_RADIUS); break;}
102 if( fabs(z)>TRACKING_LENGTH)break;
103
104 xold = x;
105 yold = y;
106 zold = z;
107 }
108
109 if(x!=0 && y!=0 && z!=0)
110 {
111 double eta;
112 float Theta = atan2(sqrt(x*x+y*y),z);
113 eta = -log(tan(Theta/2));
114 double phi = atan2(y,x);
115 genMomentum.SetPtEtaPhiE(Part->PT,eta,phi,Part->E);
116 }
117 }
118}
Note: See TracBrowser for help on using the repository browser.