00001 // BLKillTrack.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 BLKILLTRACK_HH 00020 #define BLKILLTRACK_HH 00021 00022 #include "BLParam.hh" 00023 00024 /** class BLKillTrack - class to kill tracks. 00025 * 00026 * Any BLElement that wants to kill tracks that enter a given physical 00027 * volume (e.g. a box command with kill=1) should register an 00028 * instance of this class with the BLManager, associated with the 00029 * physical volume. 00030 **/ 00031 class BLKillTrack : public BLManager::SteppingAction { 00032 bool verbose; 00033 G4String name; 00034 public: 00035 BLKillTrack(G4String &_name) : BLManager::SteppingAction(), name(_name) 00036 { 00037 verbose = Param.getInt("steppingVerbose") != 0; 00038 } 00039 void UserSteppingAction(const G4Step *step) { 00040 G4Track *track = step->GetTrack(); 00041 track->SetTrackStatus(fStopAndKill); 00042 if(verbose) printf("Track killed by '%s' with kill=1\n", 00043 name.c_str()); 00044 } 00045 }; 00046 00047 #endif // BLKILLTRACK_HH