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

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7