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 "DetectorConstruction.hh"
36 #include "G4UIdirectory.hh"
37 #include "G4UIcommand.hh"
38 #include "G4UIparameter.hh"
39 #include "G4UIcmdWithAString.hh"
42 
43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44 
46 :G4UImessenger(),
47  fDetector(Det), fTestemDir(nullptr), fDetDir(nullptr), fMaterCmd(nullptr),
48  fThickCmd(nullptr), fSizeYZCmd(nullptr), fIsotopeCmd(nullptr)
49 {
50  fTestemDir = new G4UIdirectory("/testhadr/");
51  fTestemDir->SetGuidance("commands specific to this example");
52 
53  G4bool broadcast = false;
54  fDetDir = new G4UIdirectory("/testhadr/det/",broadcast);
55  fDetDir->SetGuidance("detector construction commands");
56 
57  fMaterCmd = new G4UIcmdWithAString("/testhadr/det/setMat",this);
58  fMaterCmd->SetGuidance("Select material of the box.");
59  fMaterCmd->SetParameterName("choice",false);
61 
62  fThickCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/det/setThickness",this);
63  fThickCmd->SetGuidance("Set thickness of the absor");
64  fThickCmd->SetParameterName("Thickness",false);
65  fThickCmd->SetRange("Thickness>0.");
66  fThickCmd->SetUnitCategory("Length");
68 
69  fSizeYZCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/det/setSizeYZ",this);
70  fSizeYZCmd->SetGuidance("Set transverse size of the absor");
71  fSizeYZCmd->SetParameterName("Size",false);
72  fSizeYZCmd->SetRange("Size>0.");
73  fSizeYZCmd->SetUnitCategory("Length");
75 
76  fIsotopeCmd = new G4UIcommand("/testhadr/det/setIsotopeMat",this);
77  fIsotopeCmd->SetGuidance("Build and select a material with single isotope");
78  fIsotopeCmd->SetGuidance(" symbol of isotope, Z, A, density of material");
79  //
80  G4UIparameter* symbPrm = new G4UIparameter("isotope",'s',false);
81  symbPrm->SetGuidance("isotope symbol");
82  fIsotopeCmd->SetParameter(symbPrm);
83  //
84  G4UIparameter* ZPrm = new G4UIparameter("Z",'i',false);
85  ZPrm->SetGuidance("Z");
86  ZPrm->SetParameterRange("Z>0");
88  //
89  G4UIparameter* APrm = new G4UIparameter("A",'i',false);
90  APrm->SetGuidance("A");
91  APrm->SetParameterRange("A>0");
92  fIsotopeCmd->SetParameter(APrm);
93  //
94  G4UIparameter* densityPrm = new G4UIparameter("density",'d',false);
95  densityPrm->SetGuidance("density of material");
96  densityPrm->SetParameterRange("density>0.");
97  fIsotopeCmd->SetParameter(densityPrm);
98  //
99  G4UIparameter* unitPrm = new G4UIparameter("unit",'s',false);
100  unitPrm->SetGuidance("unit of density");
102  unitPrm->SetParameterCandidates(unitList);
103  fIsotopeCmd->SetParameter(unitPrm);
104  //
106 }
107 
108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
109 
111 {
112  delete fMaterCmd;
113  delete fThickCmd;
114  delete fSizeYZCmd;
115  delete fIsotopeCmd;
116  delete fDetDir;
117  delete fTestemDir;
118 }
119 
120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
121 
123 {
124  if( command == fMaterCmd )
125  { fDetector->SetAbsorMaterial(newValue);}
126 
127  if( command == fThickCmd )
129 
130  if( command == fSizeYZCmd )
132 
133  if (command == fIsotopeCmd)
134  {
135  G4int Z; G4int A; G4double dens;
136  G4String name, unt;
137  std::istringstream is(newValue);
138  is >> name >> Z >> A >> dens >> unt;
139  dens *= G4UIcommand::ValueOf(unt);
140  fDetector->MaterialWithSingleIsotope (name,name,dens,Z,A);
141  fDetector->SetAbsorMaterial(name);
142  }
143 }
144 
145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......