/scratch0/jsnuveri/BDSIM/BDSIMgit/bdsim/src/BDSTeleporterStepper.cc

00001 #include "BDSExecOptions.hh"
00002 #include "BDSGlobalConstants.hh" 
00003 
00004 #include "BDSTeleporterStepper.hh"
00005 #include "BDSDebug.hh"
00006 #include "G4Event.hh"
00007 #include "G4EventManager.hh"
00008 
00009 BDSTeleporterStepper::BDSTeleporterStepper(G4Mag_EqRhs *EqRhs)
00010    : G4MagIntegratorStepper(EqRhs,6)  // integrate over 6 variables only !!
00011                                       // position & velocity
00012 {
00013 #ifdef BDSDEBUG
00014   G4cout << "BDSTeleporterStepper Constructor " << G4endl;
00015 #endif
00016   verboseStep        = BDSExecOptions::Instance()->GetVerboseStep();
00017   verboseEventNumber = BDSExecOptions::Instance()->GetVerboseEventNumber();
00018   nvar               = 6;
00019   //  turnnumberrecord.push_back((G4int)-1);
00020   //  turnstaken         = 0;
00021   teleporterdelta    = BDSGlobalConstants::Instance()->GetTeleporterDelta();
00022 }
00023 
00024 
00025 void BDSTeleporterStepper::AdvanceHelix( const G4double  yIn[],
00026                                          G4ThreeVector /*Bfld*/,
00027                                          G4double  h,
00028                                          G4double  yOut[])
00029 {
00030   // FOR NOW - do it to everything every time
00031   //           will likely only take one step...
00032   // keep a record of the turn number for this particle
00033   // only adjust its position if the particle on this turn
00034   // hasn't been shifted already - ie its turn number
00035   // won't have been registered in the vector member
00036   // turnnumberrecord
00037   
00038 #ifdef BDSDEBUG
00039   G4int turnstaken = BDSGlobalConstants::Instance()->GetTurnsTaken();
00040   G4cout << " Teleporter Stepper" << G4endl;
00041   G4cout << "turnstaken " << turnstaken << G4endl;
00042 #endif
00043   //if (turnstaken != turnnumberrecord.back())
00044   if (1 == 1)
00045     {
00046       //do the adjustment
00047       //register this turn
00048       //turnnumberrecord.push_back(turnstaken);
00049       //G4cout << "registering this turn in teleporter" << G4endl;
00050       // accelerator is built along z axis
00051       // bends bend normally in x axis
00052       // for a flat machine, the delta.y() should be <10^-9 ie rounding error 
00053       yOut[0] = yIn[0] - teleporterdelta.x();
00054       yOut[1] = yIn[1] - teleporterdelta.y();
00055       yOut[2] = yIn[2] + h; // move it along the step length
00056       yOut[3] = yIn[3];
00057       yOut[4] = yIn[4];
00058       yOut[5] = yIn[5];
00059     }
00060   else
00061     {
00062       //move the particle along the step without affecting anything (ensure periodicity)
00063       yOut[0] = yIn[0];
00064       yOut[1] = yIn[1];
00065       yOut[2] = yIn[2] + h;
00066       yOut[3] = yIn[3];
00067       yOut[4] = yIn[4];
00068       yOut[5] = yIn[5];
00069     }
00070   
00071   // dump step information for particular event
00072   if(verboseStep || verboseEventNumber == G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID())
00073     {
00074       G4ThreeVector inA  = G4ThreeVector(yIn[0],yIn[1],yIn[2]);
00075       G4ThreeVector inB  = G4ThreeVector(yIn[3],yIn[4],yIn[5]);
00076       G4ThreeVector outA = G4ThreeVector(yOut[0],yOut[1],yOut[2]);
00077       G4ThreeVector outB = G4ThreeVector(yOut[3],yOut[4],yOut[5]);
00078       int G4precision    = G4cout.precision();
00079       G4cout.precision(10);
00080       G4cout << __METHOD_NAME__ << G4endl;
00081       G4cout << "h (step length) " << h   /CLHEP::m << G4endl;
00082       G4cout << "Input x,y,z     " << inA /CLHEP::m << G4endl;
00083       G4cout << "Input px,py,pz  " << inB /CLHEP::m << G4endl;
00084       G4cout << "Output x,y,z    " << outA/CLHEP::m << G4endl;
00085       G4cout << "Output px,py,pz " << outB/CLHEP::m << G4endl;
00086       G4cout.precision(G4precision);
00087     }
00088 }
00089 
00090 void BDSTeleporterStepper::Stepper( const G4double yInput[],
00091                                     const G4double[],
00092                                     const G4double hstep,
00093                                     G4double yOut[],
00094                                     G4double yErr[])
00095 {  
00096   //const G4int nvar = 6 ;
00097   G4int i;
00098   for(i=0;i<nvar;i++) yErr[i]=0;
00099   
00100   AdvanceHelix(yInput,(G4ThreeVector)0,hstep,yOut);
00101 }
00102 
00103 BDSTeleporterStepper::~BDSTeleporterStepper()
00104 {}

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7