HGCal Test Beam  03a93d6239a951948e06fb3ef8dae4cbdebfad30
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
DetectorMessenger.cc
Go to the documentation of this file.
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$
28 //
29 //
30 
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "HGCal/TBStandaloneSimulator/interface/DetectorMessenger.hh"
35 #include "HGCal/TBStandaloneSimulator/interface/DetectorConstruction.hh"
36 
37 #include "G4UIdirectory.hh"
38 #include "G4UIcmdWithAString.hh"
39 #include "G4UIcmdWithAnInteger.hh"
40 #include "G4UIcmdWithADoubleAndUnit.hh"
41 #include "G4UIcmdWithoutParameter.hh"
42 
43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44 
45 DetectorMessenger::DetectorMessenger(
46  DetectorConstruction* Det)
47  : Detector(Det)
48 {
49  N03Dir = new G4UIdirectory("/N03/");
50  N03Dir->SetGuidance("UI commands of this example");
51 
52  detDir = new G4UIdirectory("/N03/det/");
53  detDir->SetGuidance("detector control");
54 
55  MagFieldCmd = new G4UIcmdWithADoubleAndUnit("/N03/det/setField", this);
56  MagFieldCmd->SetGuidance("Define magnetic field.");
57  MagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
58  MagFieldCmd->SetParameterName("Bz", false);
59  MagFieldCmd->SetUnitCategory("Magnetic flux density");
60  MagFieldCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
61 
62  SetModelCmd = new G4UIcmdWithAnInteger("/N03/det/setModel", this);
63  SetModelCmd->SetGuidance("Define detector model");
64  SetModelCmd->SetParameterName("Model", true);
65  SetModelCmd->SetDefaultValue(0);
66  SetModelCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
67 
68 }
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71 
72 DetectorMessenger::~DetectorMessenger()
73 {
74  delete MagFieldCmd;
75  delete SetModelCmd;
76  delete detDir;
77  delete N03Dir;
78 }
79 
80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
81 
82 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
83 {
84  if( command == MagFieldCmd ) {
85  Detector->SetMagField(MagFieldCmd->GetNewDoubleValue(newValue));
86  }
87  if (command == SetModelCmd ) {
88  Detector->SetDetModel(SetModelCmd->GetNewIntValue(newValue));
89  }
90 
91 }
92 
93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......