Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

MagField.cxx

Go to the documentation of this file.
00001 
00002 //                                                                      //
00003 // PS Magfield. Calculate bending due to Magnetic Field                 //
00004 //                                                                      // 
00005 //                                                                      //
00007 
00008 #include "AtlfastAlgs/MagField.h" 
00009 #include <cmath> 
00010 #include "AtlfastEvent/Phi.h" 
00011 namespace Atlfast{
00012   using std::abs;
00013   using std::cout;
00014   using std::endl;
00015 
00016   MagField::MagField(bool fieldOn): 
00017     m_fieldOn(fieldOn), m_chargeService(ChargeService()) {}
00018 
00019   void MagField::operator()( const MCparticleCollection& p, 
00020                              TransportedParticleCollection& atCal) const {
00021     
00022     // calculation of phi deflection due to B-field - from L. Poggioli
00023     MCparticleCollectionCIter ip= p.begin();
00024     for(; ip<p.end(); ++ip){
00025       double phi;
00026       phi=(*ip)->momentum().phi();
00027       double charge=m_chargeService(*ip);
00028       if(m_fieldOn && !(charge==0.) ) {
00029         
00030         double def=0.;
00031         double theta = (*ip)->momentum().theta();
00032         double eta = (*ip)->momentum().pseudoRapidity();
00033         double pt = (*ip)->momentum().perp();
00034         
00035         if (abs(eta) < 1.4) {def = -150. * 0.006/pt/2.0;}
00036         else { def = -350. * abs(tan(theta))* 0.006/pt/2.0;}
00037         
00038         if(double turns =(def/(2*M_PI))>5.0) {
00039           cout<<"MagField: particle has spun  "<<turns<<" pt= "<<pt<<endl;
00040         } 
00041         
00042         phi = Phi(phi + def*charge);
00043       }
00044       //      std::pair<double, HepMC::GenParticle*>* temp = 
00045       //new std::pair<double, HepMC::GenParticle*>(phi,*ip);
00046       //atCal.push_back( *temp );
00047       //delete temp;
00048       atCal.push_back( new TransportedParticle(phi, *ip));
00049     }
00050     
00051   }
00052 }
00053 //__________________________________________________________________
00054 
00055 
00056 
00057 
00058 
00059 
00060 

Generated on Tue Mar 18 11:18:24 2003 for AtlfastAlgs by doxygen1.3-rc1