HGCal Test Beam  03a93d6239a951948e06fb3ef8dae4cbdebfad30
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
PrimaryGeneratorMessenger.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id$
28 //
29 //
30 
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "HGCal/TBStandaloneSimulator/interface/PrimaryGeneratorMessenger.hh"
35 #include "HGCal/TBStandaloneSimulator/interface/PrimaryGeneratorAction.hh"
36 
37 #include "G4UIdirectory.hh"
38 #include "G4UIcmdWithAString.hh"
39 
40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
41 
42 PrimaryGeneratorMessenger::PrimaryGeneratorMessenger(
43  PrimaryGeneratorAction* Gun)
44  : Action(Gun)
45 {
46  dir = new G4UIdirectory("/generator/");
47  dir-> SetGuidance("Control commands for primary generator");
48 
49  select = new G4UIcmdWithAString("/generator/select", this);
50  select-> SetGuidance("select generator type");
51  select-> SetParameterName("generator_type", false, false);
52  select-> SetCandidates("particleGun pythia hepmcAscii");
53  select-> SetDefaultValue("particleGun");
54 
55  RndmCmd = new G4UIcmdWithAString("/generator/particleGun/rndm", this);
56  RndmCmd->SetGuidance("Shoot randomly the incident particle.");
57  RndmCmd->SetGuidance(" Choice : on(default), off");
58  RndmCmd->SetParameterName("choice", true);
59  RndmCmd->SetDefaultValue("on");
60  RndmCmd->SetCandidates("on off");
61  RndmCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
62 }
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 
66 PrimaryGeneratorMessenger::~PrimaryGeneratorMessenger()
67 {
68  delete select;
69  delete RndmCmd;
70  delete dir;
71  //delete gunDir;
72 }
73 
74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
75 
76 void PrimaryGeneratorMessenger::SetNewValue(
77  G4UIcommand* command, G4String newValue)
78 {
79  if ( command == select) {
80  Action->SetGenerator(newValue);
81  G4cout << "current generator type: "
82  << Action-> GetGeneratorName() << G4endl;
83  } else if( command == RndmCmd ) {
84  Action->SetRndmFlag(newValue);
85  } else {}
86 }
87 
88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
89 
90 
91 //////////////////////////////////////////////////////////////////////////////
92 G4String PrimaryGeneratorMessenger::GetCurrentValue(G4UIcommand* command)
93 //////////////////////////////////////////////////////////////////////////////
94 {
95  G4String cv, st;
96  if (command == select) {
97  cv = Action-> GetGeneratorName();
98  }
99 
100  return cv;
101 }