Back to home page

EIC code displayed by LXR

 
 

    


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

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/TestEm3/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("UI commands specific to this example");
0052 
0053   fDetDir = new G4UIdirectory("/testem/det/");
0054   fDetDir->SetGuidance("detector construction commands");
0055 
0056   fSizeYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeYZ", this);
0057   fSizeYZCmd->SetGuidance("Set tranverse size of the calorimeter");
0058   fSizeYZCmd->SetParameterName("Size", false);
0059   fSizeYZCmd->SetRange("Size>0.");
0060   fSizeYZCmd->SetUnitCategory("Length");
0061   fSizeYZCmd->AvailableForStates(G4State_PreInit);
0062   fSizeYZCmd->SetToBeBroadcasted(false);
0063 
0064   fNbLayersCmd = new G4UIcmdWithAnInteger("/testem/det/setNbOfLayers", this);
0065   fNbLayersCmd->SetGuidance("Set number of layers.");
0066   fNbLayersCmd->SetParameterName("NbLayers", false);
0067   fNbLayersCmd->SetRange("NbLayers>0");
0068   fNbLayersCmd->AvailableForStates(G4State_PreInit);
0069   fNbLayersCmd->SetToBeBroadcasted(false);
0070 
0071   fNbAbsorCmd = new G4UIcmdWithAnInteger("/testem/det/setNbOfAbsor", this);
0072   fNbAbsorCmd->SetGuidance("Set number of Absorbers.");
0073   fNbAbsorCmd->SetParameterName("NbAbsor", false);
0074   fNbAbsorCmd->SetRange("NbAbsor>0");
0075   fNbAbsorCmd->AvailableForStates(G4State_PreInit);
0076   fNbAbsorCmd->SetToBeBroadcasted(false);
0077 
0078   fAbsorCmd = new G4UIcommand("/testem/det/setAbsor", this);
0079   fAbsorCmd->SetGuidance("Set the absor nb, the material, the thickness.");
0080   fAbsorCmd->SetGuidance("  absor number : from 1 to NbOfAbsor");
0081   fAbsorCmd->SetGuidance("  material name");
0082   fAbsorCmd->SetGuidance("  thickness (with unit) : t>0.");
0083   //
0084   G4UIparameter* AbsNbPrm = new G4UIparameter("AbsorNb", 'i', false);
0085   AbsNbPrm->SetGuidance("absor number : from 1 to NbOfAbsor");
0086   AbsNbPrm->SetParameterRange("AbsorNb>0");
0087   fAbsorCmd->SetParameter(AbsNbPrm);
0088   //
0089   G4UIparameter* MatPrm = new G4UIparameter("material", 's', false);
0090   MatPrm->SetGuidance("material name");
0091   fAbsorCmd->SetParameter(MatPrm);
0092   //
0093   G4UIparameter* ThickPrm = new G4UIparameter("thickness", 'd', false);
0094   ThickPrm->SetGuidance("thickness of absorber");
0095   ThickPrm->SetParameterRange("thickness>0.");
0096   fAbsorCmd->SetParameter(ThickPrm);
0097   //
0098   G4UIparameter* unitPrm = new G4UIparameter("unit", 's', false);
0099   unitPrm->SetGuidance("unit of thickness");
0100   G4String unitList = G4UIcommand::UnitsList(G4UIcommand::CategoryOf("mm"));
0101   unitPrm->SetParameterCandidates(unitList);
0102   fAbsorCmd->SetParameter(unitPrm);
0103   //
0104   fAbsorCmd->AvailableForStates(G4State_PreInit);
0105   fAbsorCmd->SetToBeBroadcasted(false);
0106 }
0107 
0108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0109 
0110 DetectorMessenger::~DetectorMessenger()
0111 {
0112   delete fSizeYZCmd;
0113   delete fNbLayersCmd;
0114   delete fNbAbsorCmd;
0115   delete fAbsorCmd;
0116   delete fDetDir;
0117   delete fTestemDir;
0118 }
0119 
0120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0121 
0122 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0123 {
0124   if (command == fSizeYZCmd) {
0125     fDetector->SetCalorSizeYZ(fSizeYZCmd->GetNewDoubleValue(newValue));
0126   }
0127 
0128   if (command == fNbLayersCmd) {
0129     fDetector->SetNbOfLayers(fNbLayersCmd->GetNewIntValue(newValue));
0130   }
0131 
0132   if (command == fNbAbsorCmd) {
0133     fDetector->SetNbOfAbsor(fNbAbsorCmd->GetNewIntValue(newValue));
0134   }
0135 
0136   if (command == fAbsorCmd) {
0137     G4int num;
0138     G4double tick;
0139     G4String unt, mat;
0140     std::istringstream is(newValue);
0141     is >> num >> mat >> tick >> unt;
0142     G4String material = mat;
0143     tick *= G4UIcommand::ValueOf(unt);
0144     fDetector->SetAbsorMaterial(num, material);
0145     fDetector->SetAbsorThickness(num, tick);
0146   }
0147 }
0148 
0149 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......