Precalibrated Ion Beam Identification Detector Simulation 1.0
A pilot study detector simulation, written in C++ with Geant4.
PrimaryGeneratorMessenger.cc
Go to the documentation of this file.
00001 #include "PrimaryGeneratorMessenger.hh"
00002 
00003 PrimaryGeneratorMessenger::PrimaryGeneratorMessenger(
00004                                           PrimaryGeneratorAction* Gun)
00005 :Action(Gun)
00006 {
00007   gunDir = new G4UIdirectory("/PIBIDS/gun/");
00008   gunDir->SetGuidance("PrimaryGenerator control");
00009    
00010   RndmCmd = new G4UIcmdWithAString("/PIBIDS/gun/rndm",this);
00011   RndmCmd->SetGuidance("Shoot randomly the incident particle.");
00012   RndmCmd->SetGuidance("  Choice : on(default), off");
00013   RndmCmd->SetParameterName("choice",true);
00014   RndmCmd->SetDefaultValue("on");
00015   RndmCmd->SetCandidates("on off");
00016   RndmCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00017 
00018   gunZ = new G4UIcmdWithAnInteger("/PIBIDS/gun/Z",this);
00019   gunZ->SetGuidance("Set the atomic number of the incident particle");
00020   gunZ->SetParameterName("Z",true);
00021   gunZ->SetDefaultValue(6);
00022   currentGunZ = 6;
00023   gunZ->SetRange("Z>=0");
00024 
00025   gunA = new G4UIcmdWithAnInteger("/PIBIDS/gun/A",this);
00026   gunA->SetGuidance("Set the atomic number of the incident particle");
00027   gunA->SetParameterName("A",true);
00028   gunA->SetDefaultValue(17);
00029   currentGunA = 17;
00030   gunA->SetRange("A>=0");
00031 
00032   gunE = new G4UIcmdWithADouble("/PIBIDS/gun/E",this);
00033   gunE->SetGuidance("Set the excitation energy of the incident particle");
00034   gunE->SetParameterName("E",true);
00035   gunE->SetDefaultValue(0.);
00036   currentGunE = 0.;
00037 
00038   gunQ = new G4UIcmdWithADouble("/PIBIDS/gun/Q",this);
00039   gunQ->SetGuidance("Set the charge of the incident particle");
00040   gunQ->SetParameterName("E",true);
00041   gunQ->SetDefaultValue(0.);
00042   currentGunQ = 0.;
00043 
00044   targetArea = new G4UIcmdWithoutParameter("/PIBIDS/gun/area",this);
00045   targetArea->SetGuidance("Show target area");
00046 }
00047 
00048 PrimaryGeneratorMessenger::~PrimaryGeneratorMessenger()
00049 {
00050   delete gunE;
00051   delete gunQ;
00052   delete gunA;
00053   delete gunZ;
00054   delete targetArea;
00055   delete RndmCmd;
00056   delete gunDir;
00057 }
00058 
00059 void PrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
00060 { 
00061   if( command == RndmCmd )
00062     { Action->SetRndmFlag(newValue);}
00063   bool set = false;
00064   if (command == gunZ)
00065     {
00066       currentGunZ=gunZ->GetNewIntValue(newValue);
00067       set=true;
00068     }
00069   if(command == gunA) 
00070     {
00071       currentGunA=gunA->GetNewIntValue(newValue);
00072       set=true;
00073     }
00074   if(command == gunE)
00075     {
00076       currentGunE=gunE->GetNewDoubleValue(newValue);
00077       set=true;
00078     }
00079   if(command == gunQ)
00080     {
00081       currentGunQ=gunQ->GetNewDoubleValue(newValue);
00082       set=true;
00083     }
00084   if(command == targetArea)
00085     {
00086       Action->PrintTargetSize();
00087     }
00088   
00089 
00090 
00091   if(set)
00092     Action->SetParticle(currentGunZ,currentGunA,currentGunE,currentGunQ);
00093 }
00094 
00095 
 All Classes Files Functions Variables Defines

Back to the main page of the Precalibrated Ion Beam Identification Detector project

Created by Rikard Lundmark