Fork me on GitHub

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

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

Add frog plus cleaning + bugs remove

File size: 2.7 KB
RevLine 
[53]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
[90]29 MAXITERATION = 10000;
[53]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?
[94]45 if(sqrt(Xvertex1*Xvertex1+Yvertex1*Yvertex1) > TRACK_radius){return;}
46 if(fabs(Zvertex1) > TRACK_length){return;}
[53]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;
[59]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;
[53]63
[94]64 double Bx = TRACK_bfield_x;
65 double By = TRACK_bfield_y;
66 double Bz = TRACK_bfield_z;
[59]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
[94]101 if( (x*x+y*y) > TRACK_radius*TRACK_radius ){ x /= (x*x+y*y)/(TRACK_radius*TRACK_radius); y /= (x*x+y*y)/(TRACK_radius*TRACK_radius); break;}
102 if( fabs(z)>TRACK_length)break;
[59]103
104 xold = x;
105 yold = y;
106 zold = z;
107 }
108
[53]109 if(x!=0 && y!=0 && z!=0)
110 {
111 double eta;
[90]112 float Theta = atan2(sqrt(x*x+y*y),z);
113 eta = -log(tan(Theta/2));
[53]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.