BLPhysics.hh

Go to the documentation of this file.
00001 //      BLPhysics.hh
00002 /*
00003 This source file is part of G4beamline, http://g4beamline.muonsinc.com
00004 Copyright (C) 2003,2004,2005,2006 by Tom Roberts, all rights reserved.
00005 
00006 This program is free software; you can redistribute it and/or
00007 modify it under the terms of the GNU General Public License
00008 as published by the Free Software Foundation; either version 2
00009 of the License, or (at your option) any later version.
00010 
00011 This program is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU General Public License for more details.
00015 
00016 http://www.gnu.org/copyleft/gpl.html
00017 */
00018 
00019 #ifndef BLPHYSICS_HH
00020 #define BLPHYSICS_HH
00021 
00022 #include "globals.hh"
00023 #include "G4VUserPhysicsList.hh"
00024 #include "G4ProcessTable.hh"
00025 
00026 enum BLSetValue { FORCE_ON, FORCE_OFF, NORMAL };
00027 
00028 /**     class BLPhysics is the interface class for selecting the physics
00029  *      processes to be used in the simulation.
00030  *
00031  *      Note: all functions are either inline or abstract, so no .cc file 
00032  *      is needed.
00033  **/
00034 class BLPhysics {
00035 protected:
00036         bool stochasticsEnabled;
00037         G4double minRangeCut;
00038 public:
00039         /// default constructor.
00040         BLPhysics() { stochasticsEnabled = true; minRangeCut = 1.0*mm; }
00041 
00042         /// destructor.
00043         virtual ~BLPhysics() { }
00044 
00045         /// setNoStochastics() sets whether or not stochastic processes
00046         /// are to be enabled. Note that Decay is a stochastic process.
00047         /// The argument can be FORCE_ON, FORCE_OFF, and NORMAL (which
00048         /// means use the doStochastics parameter of the physics command).
00049         /// warn controls how warnings are issued: 0=none, 1=printf,
00050         /// 2=G4Exception.
00051         virtual void setDoStochastics(BLSetValue value, G4int warn=1) = 0;
00052 
00053         /// getPhysicsList() returns the G4PhysicsList.
00054         virtual G4VUserPhysicsList *getPhysicsList() = 0;
00055 
00056         /// getStochasticsEnabled() returns true if stochastics are enabled,
00057         /// false if not.
00058         bool getStochasticsEnabled() { return stochasticsEnabled; }
00059 
00060         /// getRangeCut() returns the range cut.
00061         G4double getRangeCut() { return minRangeCut; }
00062 
00063         /// isStochasticProcess() returns true if the process is stochastic.
00064         bool isStochasticProcess(G4VProcess *process) 
00065                 { return isStochasticProcess(process->GetProcessName()); }
00066 
00067         /// isStochasticProcess() returns true if the process is stochastic.
00068         /// Ionization energy loss processes are considered to NOT be 
00069         /// stochastic, because they will be set to return their mean energy
00070         /// loss when stochastics are off.
00071         bool isStochasticProcess(G4String name) {
00072                 if(name.find("Trans") < name.size()) return false;
00073                 if(name.find("Ioni") < name.size()) return false;
00074                 if(name.find("Limiter") < name.size()) return false;
00075                 if(name.find("BLCMD") < name.size()) return false;
00076                 return true;
00077         }
00078 
00079         /// setProcessEnable() will disable or enable all processes that
00080         /// contain pattern in their name.
00081         void setProcessEnable(G4String pattern, bool onoff) {
00082                 G4ProcessTable *pt = G4ProcessTable::GetProcessTable();
00083                 std::vector<G4String> &pnv = *pt->GetNameList();
00084                 for(unsigned i=0; i<pnv.size(); ++i) {
00085                         G4String name = pnv[i];
00086                         if(name.find(pattern) >= name.size()) continue;
00087                         pt->SetProcessActivation(name,onoff);
00088                 }
00089         }
00090 };
00091 
00092 #endif // BLPHYSICS_HH
g4beamline