Geant4 Cross Reference |
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 // (adapted from B2aDetectorMessenger) 28 // Author: A.Knaian (ara@nklabs.com), N.MacFadden (natemacfadden@gmail.com) 29 30 #include "FADetectorConstructionMessenger.hh" 31 #include "FADetectorConstruction.hh" 32 33 #include "G4UIcmdWithAnInteger.hh" 34 #include "G4UIcmdWithADoubleAndUnit.hh" 35 #include "G4UIcmdWithADouble.hh" 36 #include "G4UIcmdWithABool.hh" 37 #include "G4UIcmdWithAString.hh" 38 39 DetectorConstructionMessenger::DetectorConstructionMessenger(DetectorConstruction* detectorIn) 40 : G4UImessenger() 41 { 42 fDetector = detectorIn; 43 44 // Directory 45 // 46 // /geometry 47 fGeometryDirectory = new G4UIdirectory("/geometry/"); 48 fGeometryDirectory->SetGuidance("Geometry setup."); 49 50 // Physics 51 // 52 // /geometry/stepLim 53 fStepLimCmd = new G4UIcmdWithADoubleAndUnit("/geometry/stepLim",this); 54 fStepLimCmd->SetGuidance("Maximum step length."); 55 fStepLimCmd->SetParameterName("stepLim",false); 56 fStepLimCmd->SetRange("stepLim>=0."); 57 fStepLimCmd->SetDefaultValue(DBL_MAX); 58 fStepLimCmd->SetDefaultUnit("mm"); 59 fStepLimCmd->AvailableForStates(G4State_PreInit); 60 61 // Cloud droplet settings 62 // /geometry/dropletR 63 fDropletRCmd = new G4UIcmdWithADoubleAndUnit("/geometry/dropletR",this); 64 fDropletRCmd->SetGuidance("Minimal bounding radius of droplet."); 65 fDropletRCmd->SetParameterName("dropletR",false); 66 fDropletRCmd->SetRange("dropletR>0."); 67 fDropletRCmd->SetDefaultValue(1.0); 68 fDropletRCmd->SetDefaultUnit("mm"); 69 fDropletRCmd->AvailableForStates(G4State_PreInit); 70 71 // /geometry/dropletNumDens 72 fDropletNumDensCmd = new G4UIcmdWithADouble("/geometry/dropletNumDens", this); 73 fDropletNumDensCmd->SetGuidance("Number of droplets per mm^3."); // would be nice to have official number density units 74 fDropletNumDensCmd->SetParameterName("dropletCOunt",false); 75 fDropletNumDensCmd->SetDefaultValue(0); 76 fDropletNumDensCmd->AvailableForStates(G4State_PreInit); 77 78 // Cloud build type 79 // 80 // /geometry/fastAerosol 81 fFastAerosolCloudCmd = new G4UIcmdWithABool("/geometry/fastAerosolCloud",this); 82 fFastAerosolCloudCmd->SetGuidance("Whether or not to build the fastAerosol cloud."); 83 fFastAerosolCloudCmd->SetParameterName("fastAerosol",false); 84 fFastAerosolCloudCmd->SetDefaultValue(false); 85 fFastAerosolCloudCmd->AvailableForStates(G4State_PreInit); 86 87 // /geometry/parameterisedCloud 88 fParameterisedCloudCmd = new G4UIcmdWithABool("/geometry/parameterisedCloud",this); 89 fParameterisedCloudCmd->SetGuidance("Whether or not to build the parameterised cloud."); 90 fParameterisedCloudCmd->SetParameterName("parameterisedCloud",false); 91 fParameterisedCloudCmd->SetDefaultValue(false); 92 fParameterisedCloudCmd->AvailableForStates(G4State_PreInit); 93 94 // /geometry/smoothCloud 95 fSmoothCloudCmd = new G4UIcmdWithABool("/geometry/smoothCloud",this); 96 fSmoothCloudCmd->SetGuidance("Whether or not to build the smooth cloud."); 97 fSmoothCloudCmd->SetParameterName("smoothCloud",false); 98 fSmoothCloudCmd->SetDefaultValue(false); 99 fSmoothCloudCmd->AvailableForStates(G4State_PreInit); 100 101 // fastAerosol cloud details 102 // 103 // /geometry/cloudShape 104 fCloudShapeCmd = new G4UIcmdWithAString("/geometry/cloudShape",this); 105 fCloudShapeCmd->SetGuidance("Cloud bulk shape"); 106 fCloudShapeCmd->SetParameterName("cloudShapeStr",false); 107 fCloudShapeCmd->AvailableForStates(G4State_PreInit); 108 109 // /geometry/dropletShape 110 fDropletShapeCmd = new G4UIcmdWithAString("/geometry/dropletShape",this); 111 fDropletShapeCmd->SetGuidance("Cloud droplet shape"); 112 fDropletShapeCmd->SetParameterName("dropletShapeStr",false); 113 fDropletShapeCmd->AvailableForStates(G4State_PreInit); 114 115 // /geometry/prePopulate 116 fPrePopulateCmd = new G4UIcmdWithABool("/geometry/prePopulate",this); 117 fPrePopulateCmd->SetGuidance("Whether or not to populate the cloud at the beginning."); 118 fPrePopulateCmd->SetParameterName("prePopulate",false); 119 fPrePopulateCmd->SetDefaultValue(false); 120 fPrePopulateCmd->AvailableForStates(G4State_PreInit); 121 122 // /geometry/minSpacing 123 fMinSpacingCmd = new G4UIcmdWithADoubleAndUnit("/geometry/minSpacing",this); 124 fMinSpacingCmd->SetGuidance("Minimum spacing between surfaces of spheres when generating random cloud of spheres."); 125 fMinSpacingCmd->SetParameterName("minSpacing",false); 126 fMinSpacingCmd->SetRange("minSpacing>0."); 127 fMinSpacingCmd->SetDefaultValue(10.); 128 fMinSpacingCmd->SetDefaultUnit("micrometer"); 129 fMinSpacingCmd->AvailableForStates(G4State_PreInit); 130 131 // /geometry/setSmartless 132 fSmartlessCmd = new G4UIcmdWithADouble("/geometry/smartless", this); 133 fSmartlessCmd->SetGuidance("Set the 'smartless' parameter for the parameterised cloud."); 134 fSmartlessCmd->SetParameterName("smartless",false); 135 fSmartlessCmd->SetRange("smartless>0."); 136 fSmartlessCmd->SetDefaultValue(2.0); 137 fSmartlessCmd->AvailableForStates(G4State_PreInit); 138 139 // /geometry/cloudSeed 140 fCloudSeedCmd = new G4UIcmdWithAnInteger("/geometry/cloudSeed", this); 141 fCloudSeedCmd->SetGuidance("Base of the random seed for the cloud sphere positions."); 142 fCloudSeedCmd->SetParameterName("cloudSeed",false); 143 fCloudSeedCmd->SetDefaultValue(0); 144 fCloudSeedCmd->AvailableForStates(G4State_PreInit); 145 } 146 147 DetectorConstructionMessenger::~DetectorConstructionMessenger() 148 { 149 delete fGeometryDirectory; 150 151 delete fStepLimCmd; 152 153 delete fDropletRCmd; 154 delete fDropletNumDensCmd; 155 156 delete fFastAerosolCloudCmd; 157 delete fParameterisedCloudCmd; 158 delete fSmoothCloudCmd; 159 160 delete fCloudShapeCmd; 161 delete fDropletShapeCmd; 162 delete fPrePopulateCmd; 163 delete fMinSpacingCmd; 164 //delete fGridPitchCmd; 165 166 delete fSmartlessCmd; 167 168 delete fCloudSeedCmd; 169 } 170 171 void DetectorConstructionMessenger::SetNewValue( G4UIcommand* command, G4String newValue) 172 { 173 // Geometry Commands 174 175 if( command == fFastAerosolCloudCmd ) { 176 fDetector->fFastAerosolCloud = (fFastAerosolCloudCmd->GetNewBoolValue(newValue)); 177 } 178 179 if( command == fStepLimCmd ) { 180 fDetector->fStepLim = (fStepLimCmd->GetNewDoubleValue(newValue)); 181 } 182 183 if( command == fDropletRCmd ) { 184 fDetector->fDropletR = (fDropletRCmd->GetNewDoubleValue(newValue)); 185 } 186 if( command == fDropletNumDensCmd ) { 187 fDetector->fDropletNumDens = (fDropletNumDensCmd->GetNewDoubleValue(newValue)); 188 } 189 190 if( command == fParameterisedCloudCmd ) { 191 fDetector->fParameterisedCloud = (fParameterisedCloudCmd->GetNewBoolValue(newValue)); 192 } 193 if( command == fSmoothCloudCmd ) { 194 fDetector->fSmoothCloud = (fSmoothCloudCmd->GetNewBoolValue(newValue)); 195 } 196 if( command == fPrePopulateCmd ) { 197 fDetector->fPrePopulate = (fPrePopulateCmd->GetNewBoolValue(newValue)); 198 } 199 200 if( command == fCloudShapeCmd ) { 201 fDetector->fCloudShapeStr = newValue; 202 } 203 if( command == fDropletShapeCmd ) { 204 fDetector->fDropletShapeStr = newValue; 205 } 206 if( command == fMinSpacingCmd ) { 207 fDetector->fMinSpacing = (fMinSpacingCmd->GetNewDoubleValue(newValue)); 208 } 209 if( command == fSmartlessCmd ) { 210 fDetector->fSmartless = (fSmartlessCmd->GetNewDoubleValue(newValue)); 211 } 212 if( command == fCloudSeedCmd ) { 213 fDetector->fCloudSeed = (fCloudSeedCmd->GetNewIntValue(newValue)); 214 } 215 } 216 217