source: trunk/examples/advanced/raredecay_calorimetry/src/PhotInDetectorMessenger.cc@ 1178

Last change on this file since 1178 was 807, checked in by garnier, 17 years ago

update

File size: 7.9 KB
Line 
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: PhotInDetectorMessenger.cc,v 1.5 2006/06/29 16:25:11 gunter Exp $
28// GEANT4 tag $Name: $
29//
30
31//#define debug
32
33#include "PhotInDetectorMessenger.hh"
34
35PhotInDetectorMessenger::PhotInDetectorMessenger(PhotInDetectorConstruction* PhotInDet,
36 PhotInPrimaryGeneratorAction* PhotInGen):
37 PhotInDetector(PhotInDet),PhotInGenerator(PhotInGen)
38{
39#ifdef debug
40 G4cout<<"PhotInDetectorMessenger::Constructor is called"<<G4endl;
41#endif
42 PhotInDir = new G4UIdirectory("/PhotIn/");
43 PhotInDir->SetGuidance("UI commands of this example");
44
45 AddMaterCmd = new G4UIcmdWithAString("/PhotIn/addMat",this);
46 AddMaterCmd->SetGuidance("Add Material");
47 AddMaterCmd->SetParameterName("choice",false);
48 AddMaterCmd->AvailableForStates(G4State_PreInit);
49
50 // Make a list of existing materials separated by a space
51 G4String matList;
52 const G4MaterialTable* matTbl = G4Material::GetMaterialTable();
53 for(size_t i=0; i<G4Material::GetNumberOfMaterials(); i++)
54 {
55 matList += (*matTbl)[i]->GetName();
56 matList += " ";
57 }
58
59 // Make a list of existing particles separated by a space
60 G4String partList;
61 //const G4ParticleTable* partTbl = G4ParticleTable::GetParticleTable();
62 for(G4int j=0; j<G4ParticleTable::GetParticleTable()->size(); j++)
63 {
64 G4String newName=G4ParticleTable::GetParticleTable()->GetParticleName(j);
65 partList += newName;
66 partList += " ";
67 }
68
69 setPartCmd = new G4UIcmdWithAString("/PhotIn/projParticle",this);
70 setPartCmd->SetGuidance("Select Incident Beam Particle.");
71 setPartCmd->SetParameterName("particle",false);
72 setPartCmd->AvailableForStates(G4State_Idle);
73 setPartCmd->SetCandidates(partList);
74
75 setEnergyCmd = new G4UIcmdWithADouble("/PhotIn/projEnergy",this);
76 setEnergyCmd->SetGuidance("Set energy of the beam particle.");
77 setEnergyCmd->SetParameterName("Energy",false);
78 setEnergyCmd->AvailableForStates(G4State_Idle);
79 setEnergyCmd->SetRange("Energy>0");
80
81 AbsMaterCmd = new G4UIcmdWithAString("/PhotIn/setAbsMat",this);
82 AbsMaterCmd->SetGuidance("Select Material of the Absorber.");
83 AbsMaterCmd->SetParameterName("choice",false);
84 AbsMaterCmd->AvailableForStates(G4State_Idle);
85 AbsMaterCmd->SetCandidates(matList);
86
87 GapMaterCmd = new G4UIcmdWithAString("/PhotIn/setGapMat",this);
88 GapMaterCmd->SetGuidance("Select Material of the Gap.");
89 GapMaterCmd->SetParameterName("choice",false);
90 GapMaterCmd->AvailableForStates(G4State_Idle);
91 GapMaterCmd->SetCandidates(matList);
92
93 numLayerCmd = new G4UIcmdWithAnInteger("/PhotIn/numberOfLayers",this);
94 numLayerCmd->SetGuidance("Set number of layers.");
95 numLayerCmd->SetParameterName("nl",false);
96 numLayerCmd->AvailableForStates(G4State_Idle);
97 numLayerCmd->SetRange("nl>0");
98
99 numSlabsCmd = new G4UIcmdWithAnInteger("/PhotIn/numberOfSlabs",this);
100 numSlabsCmd->SetGuidance("Set number of slabs in a layer.");
101 numSlabsCmd->SetParameterName("ns",false);
102 numSlabsCmd->AvailableForStates(G4State_Idle);
103 numSlabsCmd->SetRange("ns>0");
104
105 SerialCmd = new G4UIcmdWithABool("/PhotIn/serialGeometry",this);
106 SerialCmd->SetGuidance("Select calorimeters to be placed in serial or parallel.");
107 SerialCmd->SetParameterName("serialize",false);
108 SerialCmd->AvailableForStates(G4State_Idle);
109
110 verboseCmd = new G4UIcmdWithAnInteger("/PhotIn/verbose", this);
111 verboseCmd->SetGuidance("Set verbosity of each event.");
112 verboseCmd->SetParameterName("vl",true,true);
113 verboseCmd->SetRange("vl>=0 && vl<10");
114}
115
116PhotInDetectorMessenger::~PhotInDetectorMessenger()
117{
118 delete AddMaterCmd;
119 delete setPartCmd;
120 delete setEnergyCmd;
121 delete AbsMaterCmd;
122 delete GapMaterCmd;
123 delete numLayerCmd;
124 delete numSlabsCmd;
125 delete SerialCmd;
126 delete verboseCmd;
127 delete PhotInDir;
128}
129
130void PhotInDetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
131{
132#ifdef debug
133 G4cout<<"PhotInDetectorMessenger::SetNewValue: "<<newValue<<G4endl;
134#endif
135 if( command == AddMaterCmd )
136 {
137 PhotInDetector->CreateMaterial(newValue);
138 // update candidate list
139 G4String matList;
140 const G4MaterialTable* matTbl = G4Material::GetMaterialTable();
141 for(size_t i=0;i<G4Material::GetNumberOfMaterials();i++)
142 {
143 matList += (*matTbl)[i]->GetName();
144 matList += " ";
145 }
146 GapMaterCmd->SetCandidates(matList);
147 AbsMaterCmd->SetCandidates(matList);
148 }
149 else if( command == setPartCmd )
150 {
151 PhotInGenerator->SetProjectileName(newValue);
152#ifdef debug
153 G4cout<<"PhotInDetectorMessenger::SetNewValue: After SetProjName="<<newValue<<G4endl;
154#endif
155 }
156 else if( command == setEnergyCmd)
157 PhotInGenerator->SetProjectileEnergy(setEnergyCmd->GetNewDoubleValue(newValue));
158 else if( command == AbsMaterCmd ) PhotInDetector->SetAbsorberMaterial(newValue);
159 else if( command == GapMaterCmd ) PhotInDetector->SetGapMaterial(newValue);
160 else if( command == numLayerCmd )
161 PhotInDetector->SetNumberOfLayers(numLayerCmd->GetNewIntValue(newValue));
162 else if( command == numSlabsCmd )
163 PhotInDetector->SetNumberOfSlabs(numSlabsCmd->GetNewIntValue(newValue));
164 else if( command == SerialCmd )
165 PhotInDetector->SetSerialGeometry(SerialCmd->GetNewBoolValue(newValue));
166 else if( command == verboseCmd )
167 PhotInEventAction::SetVerboseLevel(verboseCmd->GetNewIntValue(newValue));
168 else G4cerr<<"***PhotInDetectorMessenger::SetNewValue: Command not found"<<G4endl;
169}
170
171G4String PhotInDetectorMessenger::GetCurrentValue(G4UIcommand * command)
172{
173 G4String ans;
174 if( command == AbsMaterCmd ) ans=PhotInDetector->GetAbsorberMaterial();
175 else if( command == setPartCmd ) ans=PhotInGenerator->GetProjectileName();
176 else if( command == setEnergyCmd )
177 ans=setEnergyCmd->ConvertToString(PhotInGenerator->GetProjectileEnergy());
178 else if( command == GapMaterCmd ) ans=PhotInDetector->GetGapMaterial();
179 else if( command == numLayerCmd )
180 ans=numLayerCmd->ConvertToString(PhotInDetector->GetNumberOfLayers());
181 else if( command == numSlabsCmd )
182 ans=numSlabsCmd->ConvertToString(PhotInDetector->GetNumberOfSlabs());
183 else if( command == SerialCmd )
184 ans=SerialCmd->ConvertToString(PhotInDetector->IsSerial());
185 else if( command == verboseCmd )
186 ans=verboseCmd->ConvertToString(PhotInEventAction::GetVerboseLevel());
187 else G4cerr<<"***PhotInDetectorMessenger::GetCurrentValue: Command not found"<<G4endl;
188#ifdef debug
189 G4cout<<"PhotInDetectorMessenger::GetCurrentValue: "<<ans<<G4endl;
190#endif
191 return ans;
192}
193
194
195
Note: See TracBrowser for help on using the repository browser.