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  fNdivCmd(0),
54  fSizeYZCmd(0)
55 {
56  fTestemDir = new G4UIdirectory("/testem/");
57  fTestemDir->SetGuidance(" detector control.");
58 
59  fDetDir = new G4UIdirectory("/testem/det/");
60  fDetDir->SetGuidance("detector construction commands");
61 
62  fNbAbsorCmd = new G4UIcmdWithAnInteger("/testem/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("/testem/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  fNdivCmd = new G4UIcommand("/testem/det/nDivAbsor",this);
99  fNdivCmd->SetGuidance("Divide the absor nb : number of divisions");
100  fNdivCmd->SetGuidance(" absor number : from 1 to NbOfAbsor");
101  fNdivCmd->SetGuidance(" number of divisions >= 0");
102  //
103  G4UIparameter* AbsNbPar = new G4UIparameter("AbsorNb",'i',false);
104  AbsNbPar->SetGuidance("absor number : from 1 to NbOfAbsor");
105  AbsNbPar->SetParameterRange("AbsorNb>0");
106  fNdivCmd->SetParameter(AbsNbPar);
107  //
108  G4UIparameter* NdivPrm = new G4UIparameter("NdivNb",'i',false);
109  NdivPrm->SetGuidance("nb of divisions > 0");
110  NdivPrm->SetParameterRange("NdivNb>0");
111  fNdivCmd->SetParameter(NdivPrm);
112  //
115 
116  fSizeYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeYZ",this);
117  fSizeYZCmd->SetGuidance("Set sizeYZ of the absorber");
118  fSizeYZCmd->SetParameterName("SizeYZ",false);
119  fSizeYZCmd->SetRange("SizeYZ>0.");
120  fSizeYZCmd->SetUnitCategory("Length");
123 
124 }
125 
126 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
127 
129 {
130  delete fNbAbsorCmd;
131  delete fAbsorCmd;
132  delete fNdivCmd;
133  delete fSizeYZCmd;
134  delete fDetDir;
135  delete fTestemDir;
136 }
137 
138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
139 
141 {
142  if( command == fNbAbsorCmd )
144 
145  if (command == fAbsorCmd)
146  {
147  G4int num; G4double tick;
148  G4String unt, mat;
149  std::istringstream is(newValue);
150  is >> num >> mat >> tick >> unt;
152  tick *= G4UIcommand::ValueOf(unt);
153  fDetector->SetAbsorMaterial (num,material);
154  fDetector->SetAbsorThickness(num,tick);
155  }
156 
157  if (command == fNdivCmd)
158  {
159  G4int num, ndiv;
160  std::istringstream is(newValue);
161  is >> num >> ndiv;
162  fDetector->SetNbOfDivisions (num,ndiv);
163  }
164 
165  if( command == fSizeYZCmd )
167 
168 }
169 
170 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......