Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 07:51:38

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 
0027 
0028 #include "G4UIdirectory.hh"
0029 #include "G4UIcmdWithADoubleAndUnit.hh"
0030 #include "G4UIcmdWithAnInteger.hh"
0031 
0032 #include "PrimaryGeneratorMessenger.hh"
0033 #include "PrimaryGeneratorAction.hh"
0034 
0035 
0036 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0037 
0038 PrimaryGeneratorMessenger::
0039 PrimaryGeneratorMessenger(PrimaryGeneratorAction* gen)
0040   : fGen(gen)
0041 {
0042   fBeamDir = new G4UIdirectory("/my_beam/");
0043   fBeamDir->SetGuidance("Example-specific commands to set beam properties");
0044 
0045   fKinECmd = new G4UIcmdWithADoubleAndUnit("/my_beam/kinE",this);
0046   fKinECmd->SetGuidance("Set the beam kinetic energy");
0047   fKinECmd->SetParameterName("kinE",false);
0048   fKinECmd->SetUnitCategory("Energy");
0049   fKinECmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0050 
0051   fDECmd = new G4UIcmdWithADoubleAndUnit("/my_beam/DE",this);
0052   fDECmd->SetGuidance("Set the beam energy half-width, flat distribution");
0053   fDECmd->SetParameterName("DE",false);
0054   fDECmd->SetUnitCategory("Energy");
0055   fDECmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0056 
0057   fX0Cmd = new G4UIcmdWithADoubleAndUnit("/my_beam/X0",this);
0058   fX0Cmd->SetGuidance("Set X position of the center of the beam.");
0059   fX0Cmd->SetParameterName("X0",false);
0060   fX0Cmd->SetUnitCategory("Length");
0061   fX0Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0062 
0063   fY0Cmd = new G4UIcmdWithADoubleAndUnit("/my_beam/Y0",this);
0064   fY0Cmd->SetGuidance("Set Y position of the center of the beam.");
0065   fY0Cmd->SetParameterName("Y0",false);
0066   fY0Cmd->SetUnitCategory("Length");
0067   fY0Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0068 
0069   fZ0Cmd = new G4UIcmdWithADoubleAndUnit("/my_beam/Z0",this);
0070   fZ0Cmd->SetGuidance("Set Z position of the center of the beam.");
0071   fZ0Cmd->SetParameterName("Z0",false);
0072   fZ0Cmd->SetUnitCategory("Length");
0073   fZ0Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0074 
0075   fDXCmd = new G4UIcmdWithADoubleAndUnit("/my_beam/DX",this);
0076   fDXCmd->SetGuidance("Set the beam half-width for X, flat distribution");
0077   fDXCmd->SetParameterName("DX",false);
0078   fDXCmd->SetUnitCategory("Length");
0079   fDXCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0080 
0081   fDYCmd = new G4UIcmdWithADoubleAndUnit("/my_beam/DY",this);
0082   fDYCmd->SetGuidance("Set the beam half-width for Y, flat distribution");
0083   fDYCmd->SetParameterName("DY",false);
0084   fDYCmd->SetUnitCategory("Length");
0085   fDYCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0086 
0087   fDZCmd = new G4UIcmdWithADoubleAndUnit("/my_beam/DZ",this);
0088   fDZCmd->SetGuidance("Set the beam half-width for Z, flat distribution");
0089   fDZCmd->SetParameterName("DZ",false);
0090   fDZCmd->SetUnitCategory("Length");
0091   fDZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0092 
0093   fVerboseCmd = new G4UIcmdWithAnInteger("/my_beam/verbose", this);
0094   fVerboseCmd->SetGuidance("Set primary generator verbose");
0095   fVerboseCmd->SetParameterName("verb",false);
0096   fVerboseCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0097 
0098 }
0099 
0100 
0101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0102 
0103 PrimaryGeneratorMessenger::~PrimaryGeneratorMessenger()
0104 {
0105   delete fBeamDir;
0106   delete fKinECmd;
0107   delete fDECmd;
0108   delete fX0Cmd;
0109   delete fY0Cmd;
0110   delete fZ0Cmd;
0111   delete fDXCmd;
0112   delete fDYCmd;
0113   delete fDZCmd;
0114   delete fVerboseCmd;
0115 }
0116 
0117 
0118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0119 
0120 void PrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command,
0121                                             G4String newValue)
0122 {
0123   if (command == fKinECmd)
0124     fGen->SetKinE(fKinECmd->GetNewDoubleValue(newValue));
0125   else if (command == fDECmd)
0126     fGen->SetDE(fDECmd->GetNewDoubleValue(newValue));
0127   else if (command == fX0Cmd)
0128     fGen->SetX0(fX0Cmd->GetNewDoubleValue(newValue));
0129   else if (command == fY0Cmd)
0130     fGen->SetY0(fY0Cmd->GetNewDoubleValue(newValue));
0131   else if (command == fZ0Cmd)
0132     fGen->SetZ0(fZ0Cmd->GetNewDoubleValue(newValue));
0133   else if (command == fDXCmd)
0134     fGen->SetDX(fDXCmd->GetNewDoubleValue(newValue));
0135   else if (command == fDYCmd)
0136     fGen->SetDY(fDYCmd->GetNewDoubleValue(newValue));
0137   else if (command == fDZCmd)
0138     fGen->SetDZ(fDZCmd->GetNewDoubleValue(newValue));
0139   else if (command == fVerboseCmd)
0140     fGen->SetVerbose(fVerboseCmd->GetNewIntValue(newValue));
0141 }
0142