Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:20:51

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 electromagnetic/TestEm11/src/DetectorMessenger.cc
0027 /// \brief Implementation of the DetectorMessenger class
0028 //
0029 //
0030 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 
0033 #include "DetectorMessenger.hh"
0034 
0035 #include "DetectorConstruction.hh"
0036 
0037 #include "G4UIcmdWithADoubleAndUnit.hh"
0038 #include "G4UIcmdWithAnInteger.hh"
0039 #include "G4UIcmdWithoutParameter.hh"
0040 #include "G4UIcommand.hh"
0041 #include "G4UIdirectory.hh"
0042 #include "G4UIparameter.hh"
0043 
0044 #include <sstream>
0045 
0046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0047 
0048 DetectorMessenger::DetectorMessenger(DetectorConstruction* Det) : fDetector(Det)
0049 {
0050   fTestemDir = new G4UIdirectory("/testem/");
0051   fTestemDir->SetGuidance(" detector control.");
0052 
0053   fDetDir = new G4UIdirectory("/testem/det/");
0054   fDetDir->SetGuidance("detector construction commands");
0055 
0056   fNbAbsorCmd = new G4UIcmdWithAnInteger("/testem/det/setNbOfAbsor", this);
0057   fNbAbsorCmd->SetGuidance("Set number of Absorbers.");
0058   fNbAbsorCmd->SetParameterName("NbAbsor", false);
0059   fNbAbsorCmd->SetRange("NbAbsor>0");
0060   fNbAbsorCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0061   fNbAbsorCmd->SetToBeBroadcasted(false);
0062 
0063   fAbsorCmd = new G4UIcommand("/testem/det/setAbsor", this);
0064   fAbsorCmd->SetGuidance("Set the absor nb, the material, the thickness.");
0065   fAbsorCmd->SetGuidance("  absor number : from 1 to NbOfAbsor");
0066   fAbsorCmd->SetGuidance("  material name");
0067   fAbsorCmd->SetGuidance("  thickness (with unit) : t>0.");
0068   //
0069   G4UIparameter* AbsNbPrm = new G4UIparameter("AbsorNb", 'i', false);
0070   AbsNbPrm->SetGuidance("absor number : from 1 to NbOfAbsor");
0071   AbsNbPrm->SetParameterRange("AbsorNb>0");
0072   fAbsorCmd->SetParameter(AbsNbPrm);
0073   //
0074   G4UIparameter* MatPrm = new G4UIparameter("material", 's', false);
0075   MatPrm->SetGuidance("material name");
0076   fAbsorCmd->SetParameter(MatPrm);
0077   //
0078   G4UIparameter* ThickPrm = new G4UIparameter("thickness", 'd', false);
0079   ThickPrm->SetGuidance("thickness of absorber");
0080   ThickPrm->SetParameterRange("thickness>0.");
0081   fAbsorCmd->SetParameter(ThickPrm);
0082   //
0083   G4UIparameter* unitPrm = new G4UIparameter("unit", 's', false);
0084   unitPrm->SetGuidance("unit of thickness");
0085   G4String unitList = G4UIcommand::UnitsList(G4UIcommand::CategoryOf("mm"));
0086   unitPrm->SetParameterCandidates(unitList);
0087   fAbsorCmd->SetParameter(unitPrm);
0088   //
0089   fAbsorCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0090   fAbsorCmd->SetToBeBroadcasted(false);
0091 
0092   fNdivCmd = new G4UIcommand("/testem/det/nDivAbsor", this);
0093   fNdivCmd->SetGuidance("Divide the absor nb : number of divisions");
0094   fNdivCmd->SetGuidance("  absor number : from 1 to NbOfAbsor");
0095   fNdivCmd->SetGuidance("  number of divisions >= 0");
0096   //
0097   G4UIparameter* AbsNbPar = new G4UIparameter("AbsorNb", 'i', false);
0098   AbsNbPar->SetGuidance("absor number : from 1 to NbOfAbsor");
0099   AbsNbPar->SetParameterRange("AbsorNb>0");
0100   fNdivCmd->SetParameter(AbsNbPar);
0101   //
0102   G4UIparameter* NdivPrm = new G4UIparameter("NdivNb", 'i', false);
0103   NdivPrm->SetGuidance("nb of divisions > 0");
0104   NdivPrm->SetParameterRange("NdivNb>0");
0105   fNdivCmd->SetParameter(NdivPrm);
0106   //
0107   fNdivCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0108   fNdivCmd->SetToBeBroadcasted(false);
0109 
0110   fSizeYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeYZ", this);
0111   fSizeYZCmd->SetGuidance("Set sizeYZ of the absorber");
0112   fSizeYZCmd->SetParameterName("SizeYZ", false);
0113   fSizeYZCmd->SetRange("SizeYZ>0.");
0114   fSizeYZCmd->SetUnitCategory("Length");
0115   fSizeYZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0116   fSizeYZCmd->SetToBeBroadcasted(false);
0117 }
0118 
0119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0120 
0121 DetectorMessenger::~DetectorMessenger()
0122 {
0123   delete fNbAbsorCmd;
0124   delete fAbsorCmd;
0125   delete fNdivCmd;
0126   delete fSizeYZCmd;
0127   delete fDetDir;
0128   delete fTestemDir;
0129 }
0130 
0131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0132 
0133 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0134 {
0135   if (command == fNbAbsorCmd) {
0136     fDetector->SetNbOfAbsor(fNbAbsorCmd->GetNewIntValue(newValue));
0137   }
0138 
0139   if (command == fAbsorCmd) {
0140     G4int num;
0141     G4double tick;
0142     G4String unt, mat;
0143     std::istringstream is(newValue);
0144     is >> num >> mat >> tick >> unt;
0145     G4String material = mat;
0146     tick *= G4UIcommand::ValueOf(unt);
0147     fDetector->SetAbsorMaterial(num, material);
0148     fDetector->SetAbsorThickness(num, tick);
0149   }
0150 
0151   if (command == fNdivCmd) {
0152     G4int num, ndiv;
0153     std::istringstream is(newValue);
0154     is >> num >> ndiv;
0155     fDetector->SetNbOfDivisions(num, ndiv);
0156   }
0157 
0158   if (command == fSizeYZCmd) {
0159     fDetector->SetAbsorSizeYZ(fSizeYZCmd->GetNewDoubleValue(newValue));
0160   }
0161 }
0162 
0163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......