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

00001 /* BDSIM
00002    Author: L. Nevay,
00003    Last modified 15/04/2014
00004    Copyright (c) 2014.  ALL RIGHTS RESERVED.
00005 */
00006 
00007 /*
00008 
00009 This class is to give dynamic user limits to a certain volume.
00010 In the case of a ring, we want to cut ALL particles at the end 
00011 of the ring after a certain number of turns.
00012 */
00013 
00014 #include "G4ios.hh"
00015 #include "BDSTerminatorUserLimits.hh"
00016 #include "G4UserLimits.hh"
00017 #include "BDSGlobalConstants.hh"
00018 #include "BDSExecOptions.hh"
00019 #include "G4Track.hh"
00020 #include "BDSDebug.hh"
00021 
00022 // basic inheritance - just use everything normally from G4UserLimits but 
00023 // replace one function in inherited class
00024 // default values are defined in G4UserLimits so all particles continue
00025 BDSTerminatorUserLimits::BDSTerminatorUserLimits(G4double ustepMax,
00026                                                  G4double utrakMax,
00027                                                  G4double utimeMax,
00028                                                  G4double uekinMin,
00029                                                  G4double urangMin):
00030   G4UserLimits(ustepMax,
00031                  utrakMax,
00032                  utimeMax,
00033                  uekinMin,
00034                  urangMin), keeprunningEK(0.0), stoprunningEK(DBL_MAX)
00035 {
00036   verbose = BDSExecOptions::Instance()->GetVerbose();
00037 }
00038 
00039 BDSTerminatorUserLimits::BDSTerminatorUserLimits(const G4String& type,
00040                                                  G4double ustepMax,
00041                                                  G4double utrakMax,
00042                                                  G4double utimeMax,
00043                                                  G4double uekinMin,
00044                                                  G4double urangMin):
00045   G4UserLimits(type,
00046                ustepMax,
00047                utrakMax,
00048                utimeMax,
00049                uekinMin,
00050                urangMin), keeprunningEK(0.0), stoprunningEK(DBL_MAX)
00051 {
00052   verbose = BDSExecOptions::Instance()->GetVerbose();
00053 }
00054 
00055 inline G4double BDSTerminatorUserLimits::GetUserMinEkine(const G4Track& trk)
00056 {
00057   // does the number of turns passed == number of turns to take
00058 #ifdef BDSDEBUG
00059   G4cout << __METHOD_NAME__ << " turns taken : " << BDSGlobalConstants::Instance()->GetTurnsTaken() << G4endl;
00060 #endif
00061   if ((BDSGlobalConstants::Instance()->GetTurnsTaken() == BDSGlobalConstants::Instance()->GetTurnsToTake())
00062       && trk.GetTrackLength()/CLHEP::m > 1.0*CLHEP::m)
00063     {
00064       //only stop if it's travelled at least one metre - protects against starting distribution
00065       //starting inside terminator
00066       if (verbose){
00067         G4cout << "Requested number of turns completed - stopping all particles" << G4endl;
00068         G4cout << "Track length: " << trk.GetTrackLength()/CLHEP::m << " m" << G4endl;
00069       }
00070       return stoprunningEK;
00071     } // yes - stop: return DBL_MAX eV so no particles will be tracked
00072   else
00073     {
00074       return keeprunningEK;
00075     } // no  - keep going: return 0 eV so all are tracked
00076 }
00077 
00078 

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7