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  fSizeYZCmd(0),
52  fNbLayersCmd(0),
53  fNbAbsorCmd(0),
54  fAbsorCmd(0)
55 {
56  fTestemDir = new G4UIdirectory("/testem/");
57  fTestemDir->SetGuidance("UI commands specific to this example");
58 
59  fDetDir = new G4UIdirectory("/testem/det/");
60  fDetDir->SetGuidance("detector construction commands");
61 
62  fSizeYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeYZ",this);
63  fSizeYZCmd->SetGuidance("Set tranverse size of the calorimeter");
64  fSizeYZCmd->SetParameterName("Size",false);
65  fSizeYZCmd->SetRange("Size>0.");
66  fSizeYZCmd->SetUnitCategory("Length");
69 
70  fNbLayersCmd = new G4UIcmdWithAnInteger("/testem/det/setNbOfLayers",this);
71  fNbLayersCmd->SetGuidance("Set number of layers.");
72  fNbLayersCmd->SetParameterName("NbLayers",false);
73  fNbLayersCmd->SetRange("NbLayers>0");
76 
77  fNbAbsorCmd = new G4UIcmdWithAnInteger("/testem/det/setNbOfAbsor",this);
78  fNbAbsorCmd->SetGuidance("Set number of Absorbers.");
79  fNbAbsorCmd->SetParameterName("NbAbsor",false);
80  fNbAbsorCmd->SetRange("NbAbsor>0");
83 
84  fAbsorCmd = new G4UIcommand("/testem/det/setAbsor",this);
85  fAbsorCmd->SetGuidance("Set the absor nb, the material, the thickness.");
86  fAbsorCmd->SetGuidance(" absor number : from 1 to NbOfAbsor");
87  fAbsorCmd->SetGuidance(" material name");
88  fAbsorCmd->SetGuidance(" thickness (with unit) : t>0.");
89  //
90  G4UIparameter* AbsNbPrm = new G4UIparameter("AbsorNb",'i',false);
91  AbsNbPrm->SetGuidance("absor number : from 1 to NbOfAbsor");
92  AbsNbPrm->SetParameterRange("AbsorNb>0");
93  fAbsorCmd->SetParameter(AbsNbPrm);
94  //
95  G4UIparameter* MatPrm = new G4UIparameter("material",'s',false);
96  MatPrm->SetGuidance("material name");
97  fAbsorCmd->SetParameter(MatPrm);
98  //
99  G4UIparameter* ThickPrm = new G4UIparameter("thickness",'d',false);
100  ThickPrm->SetGuidance("thickness of absorber");
101  ThickPrm->SetParameterRange("thickness>0.");
102  fAbsorCmd->SetParameter(ThickPrm);
103  //
104  G4UIparameter* unitPrm = new G4UIparameter("unit",'s',false);
105  unitPrm->SetGuidance("unit of thickness");
107  unitPrm->SetParameterCandidates(unitList);
108  fAbsorCmd->SetParameter(unitPrm);
109  //
111  fAbsorCmd->SetToBeBroadcasted(false);
112 }
113 
114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
115 
117 {
118  delete fSizeYZCmd;
119  delete fNbLayersCmd;
120  delete fNbAbsorCmd;
121  delete fAbsorCmd;
122  delete fDetDir;
123  delete fTestemDir;
124 }
125 
126 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
127 
129 {
130  if( command == fSizeYZCmd )
132 
133  if( command == fNbLayersCmd )
135 
136  if( command == fNbAbsorCmd )
138 
139  if (command == fAbsorCmd)
140  {
141  G4int num; G4double tick;
142  G4String unt, mat;
143  std::istringstream is(newValue);
144  is >> num >> mat >> tick >> unt;
146  tick *= G4UIcommand::ValueOf(unt);
147  fDetector->SetAbsorMaterial (num,material);
148  fDetector->SetAbsorThickness(num,tick);
149  }
150 }
151 
152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......