Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-10 08:06:16

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 /// \file DetectorMessenger.cc
0027 /// \brief Implementation of the DetectorMessenger class
0028 //
0029 //
0030 
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0033 
0034 #include "DetectorMessenger.hh"
0035 
0036 #include "DetectorConstruction.hh"
0037 
0038 #include "G4UIcmdWithABool.hh"
0039 #include "G4UIcmdWithADouble.hh"
0040 #include "G4UIcmdWithADoubleAndUnit.hh"
0041 #include "G4UIcmdWithAString.hh"
0042 #include "G4UIcmdWithAnInteger.hh"
0043 #include "G4UIcmdWithoutParameter.hh"
0044 #include "G4UIdirectory.hh"
0045 #include "globals.hh"
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 DetectorMessenger::DetectorMessenger(DetectorConstruction* myDet) : fDetector(myDet)
0050 {
0051   fDetectorDir = new G4UIdirectory("/mydet/");
0052   fDetectorDir->SetGuidance("Detector control.");
0053 
0054   fFieldCommand = new G4UIcmdWithADoubleAndUnit("/mydet/setField", this);
0055   fFieldCommand->SetGuidance("Define uniform magnetic field along Y.");
0056   fFieldCommand->SetGuidance(" -> in unit of  [Tesla]");
0057   fFieldCommand->SetParameterName("By", false);
0058   fFieldCommand->SetDefaultValue(0.0);
0059   fFieldCommand->SetUnitCategory("Magnetic flux density");
0060   fFieldCommand->AvailableForStates(G4State_PreInit, G4State_Idle);
0061 
0062   fAbsorberMaterial = new G4UIcmdWithAString("/mydet/absorberMaterial", this);
0063   fAbsorberMaterial->SetGuidance("Choice of the absorber material:");
0064   fAbsorberMaterial->SetGuidance("   iron / copper / tungsten / lead / PbWO4 / uranium ");
0065   fAbsorberMaterial->SetParameterName("choiceAbsorberMaterial", true);
0066   fAbsorberMaterial->SetDefaultValue("iron");
0067   fAbsorberMaterial->AvailableForStates(G4State_PreInit, G4State_Idle);
0068 
0069   fActiveMaterial = new G4UIcmdWithAString("/mydet/activeMaterial", this);
0070   fActiveMaterial->SetGuidance("Choice of the active material:");
0071   fActiveMaterial->SetGuidance("   scintillator / liquidArgon / PbWO4 / silicon / quartz ");
0072   fActiveMaterial->SetParameterName("choiceActiveMaterial", true);
0073   fActiveMaterial->SetDefaultValue("scintillator");
0074   fActiveMaterial->AvailableForStates(G4State_PreInit, G4State_Idle);
0075 
0076   fIsCalHomogeneous = new G4UIcmdWithABool("/mydet/isCalHomogeneous", this);
0077   fIsCalHomogeneous->SetParameterName("choiceIsCalHomogeneous", true);
0078   fIsCalHomogeneous->SetGuidance("Is the calorimeter homogeneous?");
0079   fIsCalHomogeneous->SetGuidance(" -> yes|y|true|t|1 : Homogeneous calorimeter");
0080   fIsCalHomogeneous->SetGuidance(" -> no|n|false|f|0 : Sampling calorimeter");
0081   fIsCalHomogeneous->SetDefaultValue(false);  // default: sampling calorimeter
0082   fIsCalHomogeneous->AvailableForStates(G4State_PreInit, G4State_Idle);
0083 
0084   fIsUnitInLambda = new G4UIcmdWithABool("/mydet/isUnitInLambda", this);
0085   fIsUnitInLambda->SetParameterName("choiceIsUnitInLambda", true);
0086   fIsUnitInLambda->SetGuidance("Is unit for absorber length in lambda?");
0087   fIsUnitInLambda->SetGuidance(" -> yes|y|true|t|1 : unit in lambda");
0088   fIsUnitInLambda->SetGuidance(" -> no|n|false|f|0 : unit in [mm]");
0089   fIsUnitInLambda->SetDefaultValue(false);  // default: unit in [mm].
0090   fIsUnitInLambda->AvailableForStates(G4State_PreInit, G4State_Idle);
0091 
0092   fAbsorberTotalLength = new G4UIcmdWithADouble("/mydet/absorberTotalLength", this);
0093   fAbsorberTotalLength->SetParameterName("choiceAbsorberTotalLength", true);
0094   fAbsorberTotalLength->SetGuidance("Absorber total length");
0095   fAbsorberTotalLength->SetGuidance(" -> in unit of lambda or [mm]");
0096   fAbsorberTotalLength->SetGuidance(" -> depending on value of choiceIsUnitInLambda");
0097   fAbsorberTotalLength->SetDefaultValue(2000.0);  // default: 2 meters.
0098   fAbsorberTotalLength->AvailableForStates(G4State_PreInit, G4State_Idle);
0099 
0100   fCalorimeterRadius = new G4UIcmdWithADouble("/mydet/calorimeterRadius", this);
0101   fCalorimeterRadius->SetParameterName("choiceCalorimeterRadius", true);
0102   fCalorimeterRadius->SetGuidance("Calorimeter Radius");
0103   fCalorimeterRadius->SetGuidance(" -> in unit of lambda or [mm]");
0104   fCalorimeterRadius->SetGuidance(" -> depending on value of choiceIsUnitInLambda");
0105   fCalorimeterRadius->SetDefaultValue(1000.0);  // default: 1 meter.
0106   fCalorimeterRadius->AvailableForStates(G4State_PreInit, G4State_Idle);
0107 
0108   fActiveLayerNumber = new G4UIcmdWithAnInteger("/mydet/activeLayerNumber", this);
0109   fActiveLayerNumber->SetParameterName("choiceActiveLayerNumber", true);
0110   fActiveLayerNumber->SetGuidance("Number of active layers");
0111   fActiveLayerNumber->SetDefaultValue(50);
0112   fActiveLayerNumber->AvailableForStates(G4State_PreInit, G4State_Idle);
0113 
0114   fActiveLayerSize = new G4UIcmdWithADouble("/mydet/activeLayerSize", this);
0115   fActiveLayerSize->SetParameterName("choiceActiveLayerSize", true);
0116   fActiveLayerSize->SetGuidance("Size (thickness) of the active layer, in [mm]");
0117   fActiveLayerSize->SetDefaultValue(4.0);  // default: 4 millimeters.
0118   fActiveLayerSize->AvailableForStates(G4State_PreInit, G4State_Idle);
0119 
0120   fIsRadiusUnitInLambda = new G4UIcmdWithABool("/mydet/isRadiusUnitInLambda", this);
0121   fIsRadiusUnitInLambda->SetParameterName("choiceIsRadiusUnitInLambda", true);
0122   fIsRadiusUnitInLambda->SetGuidance("Is unit of radius in lambda?");
0123   fIsRadiusUnitInLambda->SetGuidance(" -> yes|y|true|t|1 : unit in lambda");
0124   fIsRadiusUnitInLambda->SetGuidance(" -> no|n|false|f|0 : unit in [mm]");
0125   fIsRadiusUnitInLambda->SetDefaultValue(false);  // default: unit in [mm].
0126   fIsRadiusUnitInLambda->AvailableForStates(G4State_PreInit, G4State_Idle);
0127 
0128   fUpdateCommand = new G4UIcmdWithoutParameter("/mydet/update", this);
0129   fUpdateCommand->SetGuidance("Update calorimeter geometry.");
0130   fUpdateCommand->SetGuidance("This command MUST be applied before \"beamOn\" ");
0131   fUpdateCommand->SetGuidance("if you changed geometrical value(s).");
0132   fUpdateCommand->AvailableForStates(G4State_Idle);
0133 }
0134 
0135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0136 
0137 DetectorMessenger::~DetectorMessenger()
0138 {
0139   delete fFieldCommand;
0140   delete fDetectorDir;
0141   delete fAbsorberMaterial;
0142   delete fActiveMaterial;
0143   delete fIsCalHomogeneous;
0144   delete fIsUnitInLambda;
0145   delete fAbsorberTotalLength;
0146   delete fCalorimeterRadius;
0147   delete fActiveLayerNumber;
0148   delete fActiveLayerSize;
0149   delete fIsRadiusUnitInLambda;
0150   delete fUpdateCommand;
0151 }
0152 
0153 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0154 
0155 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0156 {
0157   if (command == fFieldCommand) {
0158     fDetector->SetMagField(fFieldCommand->GetNewDoubleValue(newValue));
0159   }
0160   if (command == fAbsorberMaterial) {
0161     fDetector->SetAbsorberMaterial(newValue);
0162   }
0163   if (command == fActiveMaterial) {
0164     fDetector->SetActiveMaterial(newValue);
0165   }
0166   if (command == fIsCalHomogeneous) {
0167     fDetector->SetIsCalHomogeneous(fIsCalHomogeneous->GetNewBoolValue(newValue));
0168   }
0169   if (command == fIsUnitInLambda) {
0170     fDetector->SetIsUnitInLambda(fIsUnitInLambda->GetNewBoolValue(newValue));
0171   }
0172   if (command == fAbsorberTotalLength) {
0173     fDetector->SetAbsorberTotalLength(fAbsorberTotalLength->GetNewDoubleValue(newValue));
0174   }
0175   if (command == fCalorimeterRadius) {
0176     fDetector->SetCalorimeterRadius(fCalorimeterRadius->GetNewDoubleValue(newValue));
0177   }
0178   if (command == fActiveLayerNumber) {
0179     fDetector->SetActiveLayerNumber(fActiveLayerNumber->GetNewIntValue(newValue));
0180   }
0181   if (command == fActiveLayerSize) {
0182     fDetector->SetActiveLayerSize(fActiveLayerSize->GetNewDoubleValue(newValue));
0183   }
0184   if (command == fIsRadiusUnitInLambda) {
0185     fDetector->SetIsRadiusUnitInLambda(fIsRadiusUnitInLambda->GetNewBoolValue(newValue));
0186   }
0187   if (command == fUpdateCommand) {
0188     fDetector->UpdateGeometry();
0189   }
0190 }
0191 
0192 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......