Public Member Functions | |
BLCMDparticlesource () | |
Constructor. | |
virtual G4String | commandName () |
commandName() returns "particlesource". | |
virtual int | command (BLArgumentVector &argv, BLArgumentMap &namedArgs) |
command() implements the particlesource command. | |
void | init () |
init() from BLBeam. | |
virtual void | defineNamedArgs () |
defineNamedArgs() defines the named arguments for this command. | |
virtual int | getNEvents () const |
getNEvents() returns the # events to process. | |
virtual bool | generateReferenceParticle (G4Event *event) |
generateReferenceParticle() generates the reference particle. | |
virtual bool | nextBeamEvent (G4Event *event) |
nextBeamEvent() generates the next beam event. | |
virtual void | summary () |
summary() will print a summary, if necessary. | |
Private Attributes | |
G4int | nEvents |
G4int | firstEvent |
G4int | lastEvent |
G4int | secondaryTrackID |
G4GeneralParticleSource * | particleSource |
G4int | eventsGenerated |
G4int | eventID |
G4int | prevEventID |
BLCMDparticlesource::BLCMDparticlesource | ( | ) |
Constructor.
References ALL_EVENTS, BLCMDTYPE_BEAM, eventID, eventsGenerated, firstEvent, lastEvent, nEvents, particleSource, prevEventID, BLCommand::registerCommand(), secondaryTrackID, BLCommand::setDescription(), and BLCommand::setSynopsis().
00084 { 00085 registerCommand(BLCMDTYPE_BEAM); 00086 setSynopsis("Interface to the Geant4 General Particle Source."); 00087 setDescription( 00088 "The Geant4 General Particle Source (GPS) is a very flexible " 00089 "and general way to generate events. It is controlled by " 00090 "Geant4 commands which should follow this command in " 00091 "the input.file. If you have a macro, you can include it using " 00092 "either the G4beamline 'include' command or the Geant4 command " 00093 "'/control/execute'. Note that G4beamline only recognizes " 00094 "Geant4 commands when the '/' is in column 1.\n\n" 00095 "Due to the design of the GPS, only one particlesource " 00096 "command can be used, but the GPS permits multiple sources " 00097 "to be combined.\n\n" 00098 "NOTE: the Geant4 General Particle Source inherently uses " 00099 "global coordinates, so this is most useful at the " 00100 "beginning of a beamline when global=centerline. Note also " 00101 "that it is very easy to generate a beam headed in the -z " 00102 "direction (this command will rotate to the +z direction: " 00103 "'/gps/ang/rot1 -1 0 0').\n\n" 00104 "To use this, see the User Manual for the GPS at " 00105 "http://reat.space.qinetiq.com/gps"); 00106 // initial default values: 00107 nEvents = ALL_EVENTS; 00108 firstEvent = -1; 00109 lastEvent = ALL_EVENTS; 00110 secondaryTrackID = 1001; 00111 particleSource = 0; 00112 eventsGenerated = 0; 00113 eventID = ALL_EVENTS; 00114 prevEventID = -9999; 00115 }
virtual G4String BLCMDparticlesource::commandName | ( | ) | [inline, virtual] |
int BLCMDparticlesource::command | ( | BLArgumentVector & | argv, | |
BLArgumentMap & | namedArgs | |||
) | [virtual] |
command() implements the particlesource command.
Implements BLCommand.
References ALL_EVENTS, firstEvent, BLManager::getObject(), BLCommand::handleNamedArgs(), lastEvent, nEvents, particleSource, BLCommand::print(), BLCommand::printError(), and BLManager::registerBeam().
00118 { 00119 if(particleSource != 0) { 00120 printError("particlesource: only one particlecource command is permitted."); 00121 return -1; 00122 } 00123 00124 int retval = handleNamedArgs(namedArgs); 00125 00126 if(firstEvent != -1 && lastEvent != ALL_EVENTS) 00127 nEvents = lastEvent - firstEvent + 1; 00128 00129 particleSource = new G4GeneralParticleSource(); 00130 00131 BLManager::getObject()->registerBeam(this); 00132 00133 print(""); 00134 00135 return retval; 00136 }
void BLCMDparticlesource::init | ( | ) | [inline, virtual] |
void BLCMDparticlesource::defineNamedArgs | ( | ) | [virtual] |
defineNamedArgs() defines the named arguments for this command.
Reimplemented from BLCommand.
References BLCommand::argInt(), firstEvent, lastEvent, nEvents, and secondaryTrackID.
00139 { 00140 argInt(nEvents,"nEvents","Number of events to process (default=1), " 00141 "set to lastEvent-firstEvent+1 if both are set."); 00142 argInt(firstEvent,"firstEvent","First event # to process (default " 00143 "is the next sequential eventID, 1 if none)"); 00144 argInt(lastEvent,"lastEvent","Last (highest) event # to process"); 00145 argInt(secondaryTrackID,"secondaryTrackID","The next TrackID for secondaries (1001)."); 00146 }
virtual int BLCMDparticlesource::getNEvents | ( | ) | const [inline, virtual] |
getNEvents() returns the # events to process.
Reimplemented from BLBeam.
References nEvents.
00069 { return nEvents; }
bool BLCMDparticlesource::generateReferenceParticle | ( | G4Event * | event | ) | [virtual] |
bool BLCMDparticlesource::nextBeamEvent | ( | G4Event * | event | ) | [virtual] |
nextBeamEvent() generates the next beam event.
Implements BLBeam.
References BLAssert, BLManager::clearTrackIDMap(), eventID, eventsGenerated, firstEvent, BLManager::getEventID(), BLManager::getObject(), lastEvent, nEvents, particleSource, prevEventID, secondaryTrackID, BLManager::setNextSecondaryTrackID(), BLManager::setPrimaryTrackID(), BLBeam::setRandomSeedToGenerate(), and BLBeam::setRandomSeedToTrack().
00154 { 00155 BLManager *manager = BLManager::getObject(); 00156 00157 int trackID = 1; 00158 int parentID = 0; 00159 00160 BLAssert(particleSource != 0); 00161 00162 // default eventID 00163 eventID = manager->getEventID(); 00164 if(eventsGenerated == 0 && firstEvent != -1) 00165 eventID = firstEvent; 00166 if(eventID > lastEvent) return false; 00167 if(++eventsGenerated > nEvents) return false; 00168 00169 setRandomSeedToGenerate(eventID); 00170 00171 particleSource->GeneratePrimaryVertex(event); 00172 event->SetEventID(eventID); 00173 if(eventID != prevEventID) { 00174 setRandomSeedToTrack(eventID); 00175 manager->clearTrackIDMap(); 00176 manager->setNextSecondaryTrackID(secondaryTrackID); 00177 prevEventID = eventID; 00178 } 00179 manager->setPrimaryTrackID(trackID,parentID); 00180 return true; 00181 }
virtual void BLCMDparticlesource::summary | ( | ) | [inline, virtual] |
G4int BLCMDparticlesource::nEvents [private] |
Reimplemented from BLBeam.
Referenced by BLCMDparticlesource(), command(), defineNamedArgs(), getNEvents(), and nextBeamEvent().
G4int BLCMDparticlesource::firstEvent [private] |
Referenced by BLCMDparticlesource(), command(), defineNamedArgs(), and nextBeamEvent().
G4int BLCMDparticlesource::lastEvent [private] |
Referenced by BLCMDparticlesource(), command(), defineNamedArgs(), and nextBeamEvent().
G4int BLCMDparticlesource::secondaryTrackID [private] |
Referenced by BLCMDparticlesource(), defineNamedArgs(), and nextBeamEvent().
G4GeneralParticleSource* BLCMDparticlesource::particleSource [private] |
Referenced by BLCMDparticlesource(), command(), and nextBeamEvent().
G4int BLCMDparticlesource::eventsGenerated [private] |
Referenced by BLCMDparticlesource(), and nextBeamEvent().
G4int BLCMDparticlesource::eventID [private] |
Referenced by BLCMDparticlesource(), and nextBeamEvent().
G4int BLCMDparticlesource::prevEventID [private] |
Referenced by BLCMDparticlesource(), and nextBeamEvent().