Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:16:36

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 
0027 // (adapted from B2aDetectorMessenger)
0028 // Author: A.Knaian (ara@nklabs.com), N.MacFadden (natemacfadden@gmail.com)
0029 
0030 #include "FADetectorConstructionMessenger.hh"
0031 #include "FADetectorConstruction.hh"
0032 
0033 #include "G4UIcmdWithAnInteger.hh"
0034 #include "G4UIcmdWithADoubleAndUnit.hh"
0035 #include "G4UIcmdWithADouble.hh"
0036 #include "G4UIcmdWithABool.hh"
0037 #include "G4UIcmdWithAString.hh"
0038 
0039 DetectorConstructionMessenger::DetectorConstructionMessenger(DetectorConstruction* detectorIn)
0040  : G4UImessenger()
0041 {
0042     fDetector = detectorIn;
0043 
0044     // Directory
0045     //
0046     // /geometry
0047     fGeometryDirectory = new G4UIdirectory("/geometry/");
0048     fGeometryDirectory->SetGuidance("Geometry setup.");
0049 
0050     // Physics
0051     //
0052     // /geometry/stepLim
0053     fStepLimCmd = new G4UIcmdWithADoubleAndUnit("/geometry/stepLim",this);
0054     fStepLimCmd->SetGuidance("Maximum step length.");
0055     fStepLimCmd->SetParameterName("stepLim",false);
0056     fStepLimCmd->SetRange("stepLim>=0.");
0057     fStepLimCmd->SetDefaultValue(DBL_MAX);
0058     fStepLimCmd->SetDefaultUnit("mm");
0059     fStepLimCmd->AvailableForStates(G4State_PreInit);
0060 
0061     // Cloud droplet settings
0062     // /geometry/dropletR
0063     fDropletRCmd = new G4UIcmdWithADoubleAndUnit("/geometry/dropletR",this);
0064     fDropletRCmd->SetGuidance("Minimal bounding radius of droplet.");
0065     fDropletRCmd->SetParameterName("dropletR",false);
0066     fDropletRCmd->SetRange("dropletR>0.");
0067     fDropletRCmd->SetDefaultValue(1.0);
0068     fDropletRCmd->SetDefaultUnit("mm");
0069     fDropletRCmd->AvailableForStates(G4State_PreInit);
0070 
0071     // /geometry/dropletNumDens         
0072     fDropletNumDensCmd = new G4UIcmdWithADouble("/geometry/dropletNumDens", this);
0073     fDropletNumDensCmd->SetGuidance("Number of droplets per mm^3.");                // would be nice to have official number density units
0074     fDropletNumDensCmd->SetParameterName("dropletCOunt",false);
0075     fDropletNumDensCmd->SetDefaultValue(0);
0076     fDropletNumDensCmd->AvailableForStates(G4State_PreInit);
0077 
0078     // Cloud build type
0079     //
0080     // /geometry/fastAerosol
0081     fFastAerosolCloudCmd = new G4UIcmdWithABool("/geometry/fastAerosolCloud",this);
0082     fFastAerosolCloudCmd->SetGuidance("Whether or not to build the fastAerosol cloud.");
0083     fFastAerosolCloudCmd->SetParameterName("fastAerosol",false);
0084     fFastAerosolCloudCmd->SetDefaultValue(false);
0085     fFastAerosolCloudCmd->AvailableForStates(G4State_PreInit);
0086 
0087     // /geometry/parameterisedCloud
0088     fParameterisedCloudCmd = new G4UIcmdWithABool("/geometry/parameterisedCloud",this);
0089     fParameterisedCloudCmd->SetGuidance("Whether or not to build the parameterised cloud.");
0090     fParameterisedCloudCmd->SetParameterName("parameterisedCloud",false);
0091     fParameterisedCloudCmd->SetDefaultValue(false);
0092     fParameterisedCloudCmd->AvailableForStates(G4State_PreInit);
0093 
0094     // /geometry/smoothCloud
0095     fSmoothCloudCmd = new G4UIcmdWithABool("/geometry/smoothCloud",this);
0096     fSmoothCloudCmd->SetGuidance("Whether or not to build the smooth cloud.");
0097     fSmoothCloudCmd->SetParameterName("smoothCloud",false);
0098     fSmoothCloudCmd->SetDefaultValue(false);
0099     fSmoothCloudCmd->AvailableForStates(G4State_PreInit);
0100 
0101     // fastAerosol cloud details
0102     //
0103     // /geometry/cloudShape
0104     fCloudShapeCmd = new G4UIcmdWithAString("/geometry/cloudShape",this);
0105     fCloudShapeCmd->SetGuidance("Cloud bulk shape");
0106     fCloudShapeCmd->SetParameterName("cloudShapeStr",false);
0107     fCloudShapeCmd->AvailableForStates(G4State_PreInit);
0108 
0109     // /geometry/dropletShape
0110     fDropletShapeCmd = new G4UIcmdWithAString("/geometry/dropletShape",this);
0111     fDropletShapeCmd->SetGuidance("Cloud droplet shape");
0112     fDropletShapeCmd->SetParameterName("dropletShapeStr",false);
0113     fDropletShapeCmd->AvailableForStates(G4State_PreInit);
0114 
0115     // /geometry/prePopulate
0116     fPrePopulateCmd = new G4UIcmdWithABool("/geometry/prePopulate",this);
0117     fPrePopulateCmd->SetGuidance("Whether or not to populate the cloud at the beginning.");
0118     fPrePopulateCmd->SetParameterName("prePopulate",false);
0119     fPrePopulateCmd->SetDefaultValue(false);
0120     fPrePopulateCmd->AvailableForStates(G4State_PreInit);
0121 
0122     // /geometry/minSpacing
0123     fMinSpacingCmd = new G4UIcmdWithADoubleAndUnit("/geometry/minSpacing",this);
0124     fMinSpacingCmd->SetGuidance("Minimum spacing between surfaces of spheres when generating random cloud of spheres.");
0125     fMinSpacingCmd->SetParameterName("minSpacing",false);
0126     fMinSpacingCmd->SetRange("minSpacing>0.");
0127     fMinSpacingCmd->SetDefaultValue(10.);
0128     fMinSpacingCmd->SetDefaultUnit("micrometer");
0129     fMinSpacingCmd->AvailableForStates(G4State_PreInit);
0130 
0131     // /geometry/setSmartless
0132     fSmartlessCmd = new G4UIcmdWithADouble("/geometry/smartless", this);
0133     fSmartlessCmd->SetGuidance("Set the 'smartless' parameter for the parameterised cloud.");
0134     fSmartlessCmd->SetParameterName("smartless",false);
0135     fSmartlessCmd->SetRange("smartless>0.");
0136     fSmartlessCmd->SetDefaultValue(2.0);
0137     fSmartlessCmd->AvailableForStates(G4State_PreInit);
0138 
0139     // /geometry/cloudSeed
0140     fCloudSeedCmd = new G4UIcmdWithAnInteger("/geometry/cloudSeed", this);
0141     fCloudSeedCmd->SetGuidance("Base of the random seed for the cloud sphere positions.");
0142     fCloudSeedCmd->SetParameterName("cloudSeed",false);
0143     fCloudSeedCmd->SetDefaultValue(0);
0144     fCloudSeedCmd->AvailableForStates(G4State_PreInit);
0145 }
0146 
0147 DetectorConstructionMessenger::~DetectorConstructionMessenger()
0148 {
0149     delete fGeometryDirectory;
0150 
0151     delete fStepLimCmd;
0152 
0153     delete fDropletRCmd;
0154     delete fDropletNumDensCmd;
0155 
0156     delete fFastAerosolCloudCmd;
0157     delete fParameterisedCloudCmd;
0158     delete fSmoothCloudCmd;
0159 
0160     delete fCloudShapeCmd;
0161     delete fDropletShapeCmd;
0162     delete fPrePopulateCmd;
0163     delete fMinSpacingCmd;
0164     //delete fGridPitchCmd;
0165 
0166     delete fSmartlessCmd;
0167 
0168     delete fCloudSeedCmd;
0169 }
0170 
0171 void DetectorConstructionMessenger::SetNewValue( G4UIcommand* command, G4String newValue)
0172 {
0173     // Geometry Commands
0174 
0175     if( command == fFastAerosolCloudCmd ) {
0176         fDetector->fFastAerosolCloud = (fFastAerosolCloudCmd->GetNewBoolValue(newValue));
0177     }
0178 
0179     if( command == fStepLimCmd ) {
0180         fDetector->fStepLim = (fStepLimCmd->GetNewDoubleValue(newValue));
0181     }
0182 
0183     if( command == fDropletRCmd ) {
0184         fDetector->fDropletR = (fDropletRCmd->GetNewDoubleValue(newValue));
0185     }
0186     if( command == fDropletNumDensCmd ) {
0187         fDetector->fDropletNumDens = (fDropletNumDensCmd->GetNewDoubleValue(newValue));
0188     }
0189 
0190     if( command == fParameterisedCloudCmd ) {
0191         fDetector->fParameterisedCloud = (fParameterisedCloudCmd->GetNewBoolValue(newValue));
0192     }
0193     if( command == fSmoothCloudCmd ) {
0194         fDetector->fSmoothCloud = (fSmoothCloudCmd->GetNewBoolValue(newValue));
0195     }
0196     if( command == fPrePopulateCmd ) {
0197         fDetector->fPrePopulate = (fPrePopulateCmd->GetNewBoolValue(newValue));
0198     }
0199 
0200     if( command == fCloudShapeCmd ) {
0201         fDetector->fCloudShapeStr = newValue;
0202     }
0203     if( command == fDropletShapeCmd ) {
0204         fDetector->fDropletShapeStr = newValue;
0205     }
0206     if( command == fMinSpacingCmd ) {
0207         fDetector->fMinSpacing = (fMinSpacingCmd->GetNewDoubleValue(newValue));
0208     }
0209     if( command == fSmartlessCmd ) {
0210         fDetector->fSmartless = (fSmartlessCmd->GetNewDoubleValue(newValue));
0211     }
0212     if( command == fCloudSeedCmd ) {
0213         fDetector->fCloudSeed = (fCloudSeedCmd->GetNewIntValue(newValue));
0214     }
0215 }
0216