/home/cern/BDSIM_new/src/BDSDriftStepper.cc

00001 /* BDSIM code.    Version 1.0
00002    Author: Grahame A. Blair, Royal Holloway, Univ. of London.
00003    Last modified 24.7.2002
00004    Copyright (c) 2002 by G.A.Blair.  ALL RIGHTS RESERVED. 
00005 */
00006 #include "BDSGlobalConstants.hh" // must be first in include list
00007 
00008 #include "BDSDriftStepper.hh"
00009 #include "G4ThreeVector.hh"
00010 #include "G4LineSection.hh"
00011 #include "G4TransportationManager.hh"
00012 
00013 extern G4int event_number;
00014 
00015 extern G4bool verbose;      // run options
00016 extern G4bool verboseStep;
00017 extern G4bool verboseEvent;
00018 extern G4int verboseEventNumber;
00019 extern G4bool isBatch;
00020 
00021 BDSDriftStepper::BDSDriftStepper(G4Mag_EqRhs *EqRhs)
00022    : G4MagIntegratorStepper(EqRhs,6)  // integrate over 6 variables only !!
00023                                        // position & velocity
00024 {}
00025 
00026 
00027 void BDSDriftStepper::AdvanceHelix( const G4double  yIn[],
00028                                    G4ThreeVector Bfld,
00029                                    G4double  h,
00030                                    G4double  yDrift[])
00031 {
00032   G4ThreeVector positionMove, endTangent;
00033 
00034   const G4double *pIn = yIn+3;
00035   G4ThreeVector v0= G4ThreeVector( pIn[0], pIn[1], pIn[2]);  
00036 
00037 
00038   G4double InitMag=v0.mag();
00039 
00040       positionMove  = (h/InitMag) * v0;
00041 
00042 
00043       yDrift[0]   = yIn[0] + positionMove.x(); 
00044       yDrift[1]   = yIn[1] + positionMove.y(); 
00045       yDrift[2]   = yIn[2] + positionMove.z(); 
00046                                 
00047       yDrift[3] = v0.x();
00048       yDrift[4] = v0.y();
00049       yDrift[5] = v0.z();
00050 
00051 
00052       // dump step information for particular event
00053       if(verboseStep)
00054         if(verboseEventNumber == event_number)
00055           {
00056             G4cout.precision(10);
00057             G4cout<<" h="<<h/m<<G4endl;
00058             G4cout<<"xIn="<<yIn[0]/m<<" yIn="<<yIn[1]/m<<
00059                   " zIn="<<yIn[2]/m<<" v0="<<v0<<G4endl;
00060             G4cout<<"xOut="<<yDrift[0]/m<<" yOut="<<yDrift[1]/m<<
00061               "zOut="<<yDrift[2]/m<<G4endl;
00062 
00063           } 
00064 }
00065 
00066 void BDSDriftStepper::Stepper( const G4double yInput[],
00067                      const G4double dydx[],
00068                      const G4double hstep,
00069                      G4double yOut[],
00070                      G4double yErr[]      )
00071 {  
00072    const G4int nvar = 6 ;
00073 
00074    G4int i;
00075    for(i=0;i<nvar;i++) yErr[i]=0;
00076 
00077    //   G4cout<<G4endl;
00078    //     G4cout<<"yInput="<<yInput[0]<<" "<< yInput[1]<<" "<<yInput[2]<<G4endl;
00079    AdvanceHelix(yInput,0,hstep,yOut);
00080 
00081    //     G4cout<<"yOut="<<yOut[0]<<" "<< yOut[1]<<" "<<yOut[2]<<G4endl;
00082 
00083    //   G4cout<<"hstep="<<hstep<<G4endl;
00084    return ;
00085 }
00086 
00087 G4double BDSDriftStepper::DistChord()   const 
00088 {
00089 return 0;
00090 }
00091 
00092 BDSDriftStepper::~BDSDriftStepper()
00093 {}

Generated on Wed Mar 5 17:25:22 2008 for BDSIM by  doxygen 1.5.3