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4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 /// \file DetectorMessenger.cc
 27 /// \brief Implementation of the DetectorMessenger class
 28 //
 29 //
 30 
 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 33 
 34 #include "DetectorMessenger.hh"
 35 
 36 #include "DetectorConstruction.hh"
 37 
 38 #include "G4UIcmdWithABool.hh"
 39 #include "G4UIcmdWithADouble.hh"
 40 #include "G4UIcmdWithADoubleAndUnit.hh"
 41 #include "G4UIcmdWithAString.hh"
 42 #include "G4UIcmdWithAnInteger.hh"
 43 #include "G4UIcmdWithoutParameter.hh"
 44 #include "G4UIdirectory.hh"
 45 #include "globals.hh"
 46 
 47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 48 
 49 DetectorMessenger::DetectorMessenger(DetectorConstruction* myDet) : fDetector(myDet)
 50 {
 51   fDetectorDir = new G4UIdirectory("/mydet/");
 52   fDetectorDir->SetGuidance("Detector control.");
 53 
 54   fFieldCommand = new G4UIcmdWithADoubleAndUnit("/mydet/setField", this);
 55   fFieldCommand->SetGuidance("Define uniform magnetic field along Y.");
 56   fFieldCommand->SetGuidance(" -> in unit of  [Tesla]");
 57   fFieldCommand->SetParameterName("By", false);
 58   fFieldCommand->SetDefaultValue(0.0);
 59   fFieldCommand->SetUnitCategory("Magnetic flux density");
 60   fFieldCommand->AvailableForStates(G4State_PreInit, G4State_Idle);
 61 
 62   fAbsorberMaterial = new G4UIcmdWithAString("/mydet/absorberMaterial", this);
 63   fAbsorberMaterial->SetGuidance("Choice of the absorber material:");
 64   fAbsorberMaterial->SetGuidance("   iron / copper / tungsten / lead / PbWO4 / uranium ");
 65   fAbsorberMaterial->SetParameterName("choiceAbsorberMaterial", true);
 66   fAbsorberMaterial->SetDefaultValue("iron");
 67   fAbsorberMaterial->AvailableForStates(G4State_PreInit, G4State_Idle);
 68 
 69   fActiveMaterial = new G4UIcmdWithAString("/mydet/activeMaterial", this);
 70   fActiveMaterial->SetGuidance("Choice of the active material:");
 71   fActiveMaterial->SetGuidance("   scintillator / liquidArgon / PbWO4 / silicon / quartz ");
 72   fActiveMaterial->SetParameterName("choiceActiveMaterial", true);
 73   fActiveMaterial->SetDefaultValue("scintillator");
 74   fActiveMaterial->AvailableForStates(G4State_PreInit, G4State_Idle);
 75 
 76   fIsCalHomogeneous = new G4UIcmdWithABool("/mydet/isCalHomogeneous", this);
 77   fIsCalHomogeneous->SetParameterName("choiceIsCalHomogeneous", true);
 78   fIsCalHomogeneous->SetGuidance("Is the calorimeter homogeneous?");
 79   fIsCalHomogeneous->SetGuidance(" -> yes|y|true|t|1 : Homogeneous calorimeter");
 80   fIsCalHomogeneous->SetGuidance(" -> no|n|false|f|0 : Sampling calorimeter");
 81   fIsCalHomogeneous->SetDefaultValue(false);  // default: sampling calorimeter
 82   fIsCalHomogeneous->AvailableForStates(G4State_PreInit, G4State_Idle);
 83 
 84   fIsUnitInLambda = new G4UIcmdWithABool("/mydet/isUnitInLambda", this);
 85   fIsUnitInLambda->SetParameterName("choiceIsUnitInLambda", true);
 86   fIsUnitInLambda->SetGuidance("Is unit for absorber length in lambda?");
 87   fIsUnitInLambda->SetGuidance(" -> yes|y|true|t|1 : unit in lambda");
 88   fIsUnitInLambda->SetGuidance(" -> no|n|false|f|0 : unit in [mm]");
 89   fIsUnitInLambda->SetDefaultValue(false);  // default: unit in [mm].
 90   fIsUnitInLambda->AvailableForStates(G4State_PreInit, G4State_Idle);
 91 
 92   fAbsorberTotalLength = new G4UIcmdWithADouble("/mydet/absorberTotalLength", this);
 93   fAbsorberTotalLength->SetParameterName("choiceAbsorberTotalLength", true);
 94   fAbsorberTotalLength->SetGuidance("Absorber total length");
 95   fAbsorberTotalLength->SetGuidance(" -> in unit of lambda or [mm]");
 96   fAbsorberTotalLength->SetGuidance(" -> depending on value of choiceIsUnitInLambda");
 97   fAbsorberTotalLength->SetDefaultValue(2000.0);  // default: 2 meters.
 98   fAbsorberTotalLength->AvailableForStates(G4State_PreInit, G4State_Idle);
 99 
100   fCalorimeterRadius = new G4UIcmdWithADouble("/mydet/calorimeterRadius", this);
101   fCalorimeterRadius->SetParameterName("choiceCalorimeterRadius", true);
102   fCalorimeterRadius->SetGuidance("Calorimeter Radius");
103   fCalorimeterRadius->SetGuidance(" -> in unit of lambda or [mm]");
104   fCalorimeterRadius->SetGuidance(" -> depending on value of choiceIsUnitInLambda");
105   fCalorimeterRadius->SetDefaultValue(1000.0);  // default: 1 meter.
106   fCalorimeterRadius->AvailableForStates(G4State_PreInit, G4State_Idle);
107 
108   fActiveLayerNumber = new G4UIcmdWithAnInteger("/mydet/activeLayerNumber", this);
109   fActiveLayerNumber->SetParameterName("choiceActiveLayerNumber", true);
110   fActiveLayerNumber->SetGuidance("Number of active layers");
111   fActiveLayerNumber->SetDefaultValue(50);
112   fActiveLayerNumber->AvailableForStates(G4State_PreInit, G4State_Idle);
113 
114   fActiveLayerSize = new G4UIcmdWithADouble("/mydet/activeLayerSize", this);
115   fActiveLayerSize->SetParameterName("choiceActiveLayerSize", true);
116   fActiveLayerSize->SetGuidance("Size (thickness) of the active layer, in [mm]");
117   fActiveLayerSize->SetDefaultValue(4.0);  // default: 4 millimeters.
118   fActiveLayerSize->AvailableForStates(G4State_PreInit, G4State_Idle);
119 
120   fIsRadiusUnitInLambda = new G4UIcmdWithABool("/mydet/isRadiusUnitInLambda", this);
121   fIsRadiusUnitInLambda->SetParameterName("choiceIsRadiusUnitInLambda", true);
122   fIsRadiusUnitInLambda->SetGuidance("Is unit of radius in lambda?");
123   fIsRadiusUnitInLambda->SetGuidance(" -> yes|y|true|t|1 : unit in lambda");
124   fIsRadiusUnitInLambda->SetGuidance(" -> no|n|false|f|0 : unit in [mm]");
125   fIsRadiusUnitInLambda->SetDefaultValue(false);  // default: unit in [mm].
126   fIsRadiusUnitInLambda->AvailableForStates(G4State_PreInit, G4State_Idle);
127 
128   fUpdateCommand = new G4UIcmdWithoutParameter("/mydet/update", this);
129   fUpdateCommand->SetGuidance("Update calorimeter geometry.");
130   fUpdateCommand->SetGuidance("This command MUST be applied before \"beamOn\" ");
131   fUpdateCommand->SetGuidance("if you changed geometrical value(s).");
132   fUpdateCommand->AvailableForStates(G4State_Idle);
133 }
134 
135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
136 
137 DetectorMessenger::~DetectorMessenger()
138 {
139   delete fFieldCommand;
140   delete fDetectorDir;
141   delete fAbsorberMaterial;
142   delete fActiveMaterial;
143   delete fIsCalHomogeneous;
144   delete fIsUnitInLambda;
145   delete fAbsorberTotalLength;
146   delete fCalorimeterRadius;
147   delete fActiveLayerNumber;
148   delete fActiveLayerSize;
149   delete fIsRadiusUnitInLambda;
150   delete fUpdateCommand;
151 }
152 
153 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
154 
155 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
156 {
157   if (command == fFieldCommand) {
158     fDetector->SetMagField(fFieldCommand->GetNewDoubleValue(newValue));
159   }
160   if (command == fAbsorberMaterial) {
161     fDetector->SetAbsorberMaterial(newValue);
162   }
163   if (command == fActiveMaterial) {
164     fDetector->SetActiveMaterial(newValue);
165   }
166   if (command == fIsCalHomogeneous) {
167     fDetector->SetIsCalHomogeneous(fIsCalHomogeneous->GetNewBoolValue(newValue));
168   }
169   if (command == fIsUnitInLambda) {
170     fDetector->SetIsUnitInLambda(fIsUnitInLambda->GetNewBoolValue(newValue));
171   }
172   if (command == fAbsorberTotalLength) {
173     fDetector->SetAbsorberTotalLength(fAbsorberTotalLength->GetNewDoubleValue(newValue));
174   }
175   if (command == fCalorimeterRadius) {
176     fDetector->SetCalorimeterRadius(fCalorimeterRadius->GetNewDoubleValue(newValue));
177   }
178   if (command == fActiveLayerNumber) {
179     fDetector->SetActiveLayerNumber(fActiveLayerNumber->GetNewIntValue(newValue));
180   }
181   if (command == fActiveLayerSize) {
182     fDetector->SetActiveLayerSize(fActiveLayerSize->GetNewDoubleValue(newValue));
183   }
184   if (command == fIsRadiusUnitInLambda) {
185     fDetector->SetIsRadiusUnitInLambda(fIsRadiusUnitInLambda->GetNewBoolValue(newValue));
186   }
187   if (command == fUpdateCommand) {
188     fDetector->UpdateGeometry();
189   }
190 }
191 
192 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
193