ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DetectorMessenger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DetectorMessenger.cc
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 //
28 //
29 //
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 
33 #include "DetectorMessenger.hh"
34 
35 #include <sstream>
36 
37 #include "DetectorConstruction.hh"
38 #include "G4UIdirectory.hh"
39 #include "G4UIcommand.hh"
40 #include "G4UIparameter.hh"
41 #include "G4UIcmdWithAnInteger.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 
48 :G4UImessenger(),fDetector(Det),
49  fTestemDir(0),
50  fDetDir(0),
51  fNbAbsorCmd(0),
52  fAbsorCmd(0),
53  fSizeYZCmd(0),
54  fIsotopeCmd(0)
55 {
56  fTestemDir = new G4UIdirectory("/testhadr/");
57  fTestemDir->SetGuidance(" detector control.");
58 
59  fDetDir = new G4UIdirectory("/testhadr/det/");
60  fDetDir->SetGuidance("detector construction commands");
61 
62  fNbAbsorCmd = new G4UIcmdWithAnInteger("/testhadr/det/setNbOfAbsor",this);
63  fNbAbsorCmd->SetGuidance("Set number of Absorbers.");
64  fNbAbsorCmd->SetParameterName("NbAbsor",false);
65  fNbAbsorCmd->SetRange("NbAbsor>0");
68 
69  fAbsorCmd = new G4UIcommand("/testhadr/det/setAbsor",this);
70  fAbsorCmd->SetGuidance("Set the absor nb, the material, the thickness.");
71  fAbsorCmd->SetGuidance(" absor number : from 1 to NbOfAbsor");
72  fAbsorCmd->SetGuidance(" material name");
73  fAbsorCmd->SetGuidance(" thickness (with unit) : t>0.");
74  //
75  G4UIparameter* AbsNbPrm = new G4UIparameter("AbsorNb",'i',false);
76  AbsNbPrm->SetGuidance("absor number : from 1 to NbOfAbsor");
77  AbsNbPrm->SetParameterRange("AbsorNb>0");
78  fAbsorCmd->SetParameter(AbsNbPrm);
79  //
80  G4UIparameter* MatPrm = new G4UIparameter("material",'s',false);
81  MatPrm->SetGuidance("material name");
82  fAbsorCmd->SetParameter(MatPrm);
83  //
84  G4UIparameter* ThickPrm = new G4UIparameter("thickness",'d',false);
85  ThickPrm->SetGuidance("thickness of absorber");
86  ThickPrm->SetParameterRange("thickness>0.");
87  fAbsorCmd->SetParameter(ThickPrm);
88  //
89  G4UIparameter* unitPrm = new G4UIparameter("unit",'s',false);
90  unitPrm->SetGuidance("unit of thickness");
92  unitPrm->SetParameterCandidates(unitList);
93  fAbsorCmd->SetParameter(unitPrm);
94  //
97 
98  fSizeYZCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/det/setSizeYZ",this);
99  fSizeYZCmd->SetGuidance("Set sizeYZ of the absorber");
100  fSizeYZCmd->SetParameterName("SizeYZ",false);
101  fSizeYZCmd->SetRange("SizeYZ>0.");
102  fSizeYZCmd->SetUnitCategory("Length");
105 
106  fIsotopeCmd = new G4UIcommand("/testhadr/det/setIsotopeMat",this);
107  fIsotopeCmd->SetGuidance("Build and select a material with single isotope");
108  fIsotopeCmd->SetGuidance(" symbol of isotope, Z, A, density of material");
109  //
110  G4UIparameter* symbPrm = new G4UIparameter("isotope",'s',false);
111  symbPrm->SetGuidance("isotope symbol");
112  fIsotopeCmd->SetParameter(symbPrm);
113  //
114  G4UIparameter* ZPrm = new G4UIparameter("Z",'i',false);
115  ZPrm->SetGuidance("Z");
116  ZPrm->SetParameterRange("Z>0");
117  fIsotopeCmd->SetParameter(ZPrm);
118  //
119  G4UIparameter* APrm = new G4UIparameter("A",'i',false);
120  APrm->SetGuidance("A");
121  APrm->SetParameterRange("A>0");
122  fIsotopeCmd->SetParameter(APrm);
123  //
124  G4UIparameter* densityPrm = new G4UIparameter("density",'d',false);
125  densityPrm->SetGuidance("density of material");
126  densityPrm->SetParameterRange("density>0.");
127  fIsotopeCmd->SetParameter(densityPrm);
128  //
129  G4UIparameter* unitPrm1 = new G4UIparameter("unit",'s',false);
130  unitPrm1->SetGuidance("unit of density");
132  unitPrm1->SetParameterCandidates(unitList1);
133  fIsotopeCmd->SetParameter(unitPrm1);
134  //
136 }
137 
138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
139 
141 {
142  delete fNbAbsorCmd;
143  delete fAbsorCmd;
144  delete fSizeYZCmd;
145  delete fIsotopeCmd;
146  delete fDetDir;
147  delete fTestemDir;
148 }
149 
150 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
151 
153 {
154  if( command == fNbAbsorCmd )
156 
157  if (command == fAbsorCmd)
158  {
159  G4int num; G4double tick;
160  G4String unt, mat;
161  std::istringstream is(newValue);
162  is >> num >> mat >> tick >> unt;
164  tick *= G4UIcommand::ValueOf(unt);
165  fDetector->SetAbsorMaterial (num,material);
166  fDetector->SetAbsorThickness(num,tick);
167  }
168 
169  if( command == fSizeYZCmd )
171 
172  if (command == fIsotopeCmd)
173  {
174  G4int Z; G4int A; G4double dens;
175  G4String name, unt;
176  std::istringstream is(newValue);
177  is >> name >> Z >> A >> dens >> unt;
178  dens *= G4UIcommand::ValueOf(unt);
179  fDetector->MaterialWithSingleIsotope (name,name,dens,Z,A);
180  }
181 }
182 
183 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......