TransportedSMParticle.cxx

Go to the documentation of this file.
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   // std::abs accepts doubles and floats
00011   using std::abs;
00012   using std::cout;
00013   using std::flush;
00014   using std::endl;
00015 
00016   void TransportedSMParticle::deflect(){
00017 
00018     // A Phi object is held as a member
00019     double phi=m_phi.val();
00020   
00021     // Use ChargeService to get particle's charge
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       //cout << "deflect phi: " << phi << flush;
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         // Conversion factor of 3.0: 
00048         //     3e8 (from c in MeV/c, for pT) /
00049         //     100 (calorimeter radius measured in cm) /
00050         //     1e6 (from MeV in MeV/c, for pT)
00051         // Don't understand the factor of 2.0 at end of expression
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       // Replace member Phi with deflected version
00063       m_phi = phi + def*charge;
00064       
00065       //cout << " ==> " << m_phi.val() << endl;
00066       
00067     }
00068     
00069     return;
00070     
00071   }
00072   
00073 }

Generated on Fri Sep 21 13:00:10 2007 for AtlfastEvent by  doxygen 1.5.1