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 "BDSExecOptions.hh"
00007 #include "BDSGlobalConstants.hh" 
00008 
00009 #include "BDSDriftStepper.hh"
00010 #include "G4ThreeVector.hh"
00011 #include "G4LineSection.hh"
00012 #include "G4TransportationManager.hh"
00013 
00014 extern G4int event_number;
00015 
00016 
00017 BDSDriftStepper::BDSDriftStepper(G4Mag_EqRhs *EqRhs)
00018    : G4MagIntegratorStepper(EqRhs,6)  // integrate over 6 variables only !!
00019                                        // position & velocity
00020 {}
00021 
00022 
00023 void BDSDriftStepper::AdvanceHelix( const G4double  yIn[],
00024                                     G4ThreeVector /*Bfld*/,
00025                                     G4double  h,
00026                                     G4double  yDrift[])
00027 {
00028   G4ThreeVector positionMove, endTangent;
00029 
00030   const G4double *pIn = yIn+3;
00031   G4ThreeVector v0= G4ThreeVector( pIn[0], pIn[1], pIn[2]);  
00032 
00033 
00034   G4double InitMag=v0.mag();
00035 
00036       positionMove  = (h/InitMag) * v0;
00037 
00038 
00039       yDrift[0]   = yIn[0] + positionMove.x(); 
00040       yDrift[1]   = yIn[1] + positionMove.y(); 
00041       yDrift[2]   = yIn[2] + positionMove.z(); 
00042                                 
00043       yDrift[3] = v0.x();
00044       yDrift[4] = v0.y();
00045       yDrift[5] = v0.z();
00046 
00047 
00048       // dump step information for particular event
00049       G4bool verboseStep       = BDSExecOptions::Instance()->GetVerboseStep();
00050       G4int verboseEventNumber = BDSExecOptions::Instance()->GetVerboseEventNumber();
00051       if(verboseStep && verboseEventNumber == event_number)
00052         {
00053           int G4precision = G4cout.precision();
00054           G4cout.precision(10);
00055           G4cout<<" h="<<h/m<<G4endl;
00056           G4cout<<"xIn="<<yIn[0]/m<<" yIn="<<yIn[1]/m<<
00057             " zIn="<<yIn[2]/m<<" v0="<<v0<<G4endl;
00058           G4cout<<"xOut="<<yDrift[0]/m<<" yOut="<<yDrift[1]/m<<
00059             "zOut="<<yDrift[2]/m<<G4endl;
00060           // set precision back
00061           G4cout.precision(G4precision);
00062         }
00063 }
00064 
00065 void BDSDriftStepper::Stepper( const G4double yInput[],
00066                      const G4double[],
00067                      const G4double hstep,
00068                      G4double yOut[],
00069                      G4double yErr[]      )
00070 {  
00071    const G4int nvar = 6 ;
00072 
00073    G4int i;
00074    for(i=0;i<nvar;i++) yErr[i]=0;
00075 
00076    //   G4cout<<G4endl;
00077    //     G4cout<<"yInput="<<yInput[0]<<" "<< yInput[1]<<" "<<yInput[2]<<G4endl;
00078    AdvanceHelix(yInput,(G4ThreeVector)0,hstep,yOut);
00079 
00080    //     G4cout<<"yOut="<<yOut[0]<<" "<< yOut[1]<<" "<<yOut[2]<<G4endl;
00081 
00082    //   G4cout<<"hstep="<<hstep<<G4endl;
00083 }
00084 
00085 G4double BDSDriftStepper::DistChord()   const 
00086 {
00087 return 0;
00088 }
00089 
00090 BDSDriftStepper::~BDSDriftStepper()
00091 {}

Generated on 27 Aug 2013 for BDSIM by  doxygen 1.4.7