00001 #include "AtlfastEvent/TransportedSMParticle.h"
00002 #include "AtlfastEvent/ChargeService.h"
00003 #include "AtlfastEvent/MagField.h"
00004
00005 #include <iostream>
00006 #include <cmath>
00007
00008 namespace Atlfast {
00009
00010
00011 using std::abs;
00012 using std::cout;
00013 using std::flush;
00014 using std::endl;
00015
00016 void TransportedSMParticle::deflect(){
00017
00018
00019 double phi=m_phi.val();
00020
00021
00022 double charge;
00023 ChargeService cs;
00024 try{
00025 charge=cs(m_particle);
00026 }catch(std::string errMsg){
00027 throw errMsg;
00028 }
00029
00030
00031 MagField *bfield = MagField::Instance();
00032
00033 if( bfield->is_on() && !(charge==0.) ) {
00034
00035
00036
00037 assert(std::abs(charge)>0.5);
00038
00039 double def=0.;
00040 double theta = m_particle->momentum().theta();
00041 double eta = m_particle->momentum().eta();
00042 double pt = m_particle->momentum().perp();
00043
00044
00045 if (abs(eta) < 1.4) {
00046
00047
00048
00049
00050
00051
00052
00053 def = -150. * bfield->strength() * 3.0 / ( pt * 2.0 );
00054 } else {
00055 def = -350.*abs(tan(theta)) * bfield->strength() * 3.0 / ( pt * 2.0 );
00056 }
00057
00058 if(double turns =(def/(2*M_PI))>5.0) {
00059 cout<<"MagField: particle has spun "<<turns<<" pt= "<<pt<<endl;
00060 }
00061
00062
00063 m_phi = phi + def*charge;
00064
00065
00066
00067 }
00068
00069 return;
00070
00071 }
00072
00073 }