Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 07:51:43

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/MicroElec-SEYv1/src/DetectorMessenger.cc
0027 /// \brief Implementation of the DetectorMessenger class
0028 //
0029 // $Id: DetectorMessenger.cc 84208 2014-10-10 14:44:50Z gcosmo $
0030 //
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0033 
0034 #include "DetectorMessenger.hh"
0035 #include "G4UIcmdWithoutParameter.hh"
0036 #include "DetectorConstruction.hh"
0037 #include "G4UIdirectory.hh"
0038 #include "G4UIcmdWithAString.hh"
0039 #include "G4UIcmdWithADoubleAndUnit.hh"
0040 #include "G4UIcmdWithADouble.hh"
0041 #include "G4UIcmdWithAnInteger.hh"
0042 #include "G4UIcmdWith3Vector.hh"
0043 #include "G4UIcmdWithABool.hh"
0044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0045 
0046 DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
0047 :G4UImessenger(),fDetector(Det),
0048  fTestemDir(0),
0049  fDetDir(0),    
0050  fMaterCmd(0),
0051  fSizeCmd(0)
0052 { 
0053   fTestemDir = new G4UIdirectory("/testem/");
0054   fTestemDir->SetGuidance("commands specific to this example");
0055   
0056   fDetDir = new G4UIdirectory("/testem/det/");
0057   fDetDir->SetGuidance("detector construction");
0058   
0059   fMaterCmd = new G4UIcmdWithAString("/testem/det/setMat",this);
0060   fMaterCmd->SetGuidance("Select material of the box.");
0061   fMaterCmd->SetParameterName("choice",false);
0062   fMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0063   fMaterCmd->SetToBeBroadcasted(false);
0064   
0065   fMaterSurfCmd = new G4UIcmdWithAString("/testem/det/setMatSurf", this);
0066   fMaterSurfCmd->SetGuidance("Select material of the box.");
0067   fMaterSurfCmd->SetParameterName("choice", false);
0068   fMaterSurfCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0069   fMaterSurfCmd->SetToBeBroadcasted(false);
0070 
0071   fMaterLayer1Cmd = new G4UIcmdWithAString("/testem/det/setMatLayer1", this);
0072   fMaterLayer1Cmd->SetGuidance("Select material of the box.");
0073   fMaterLayer1Cmd->SetParameterName("choice", false);
0074   fMaterLayer1Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0075   fMaterLayer1Cmd->SetToBeBroadcasted(false);
0076 
0077   fMaterLayer2Cmd = new G4UIcmdWithAString("/testem/det/setMatLayer2", this);
0078   fMaterLayer2Cmd->SetGuidance("Select material of the box.");
0079   fMaterLayer2Cmd->SetParameterName("choice", false);
0080   fMaterLayer2Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0081   fMaterLayer2Cmd->SetToBeBroadcasted(false);
0082 
0083   fMaterLayer3Cmd = new G4UIcmdWithAString("/testem/det/setMatLayer3", this);
0084   fMaterLayer3Cmd->SetGuidance("Select material of the box.");
0085   fMaterLayer3Cmd->SetParameterName("choice", false);
0086   fMaterLayer3Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0087   fMaterLayer3Cmd->SetToBeBroadcasted(false);
0088 
0089   fMaterLayer4Cmd = new G4UIcmdWithAString("/testem/det/setMatLayer4", this);
0090   fMaterLayer4Cmd->SetGuidance("Select material of the box.");
0091   fMaterLayer4Cmd->SetParameterName("choice", false);
0092   fMaterLayer4Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0093   fMaterLayer4Cmd->SetToBeBroadcasted(false);
0094 
0095   fSizeCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSize",this);
0096   fSizeCmd->SetGuidance("Set size of the box");
0097   fSizeCmd->SetParameterName("Size",false);
0098   fSizeCmd->SetRange("Size>0.");
0099   fSizeCmd->SetUnitCategory("Length");
0100   fSizeCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0101   fSizeCmd->SetToBeBroadcasted(false);
0102 
0103   fWidthCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setWidth", this);
0104   fWidthCmd->SetGuidance("Set Width of the box");
0105   fWidthCmd->SetParameterName("Width", false);
0106   fWidthCmd->SetRange("Width>0.");
0107   fWidthCmd->SetUnitCategory("Length");
0108   fWidthCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0109   fWidthCmd->SetToBeBroadcasted(false);
0110 
0111 
0112   fSizeSurfCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeSurf", this);
0113   fSizeSurfCmd->SetGuidance("Set size of the box");
0114   fSizeSurfCmd->SetParameterName("Size", false);
0115   fSizeSurfCmd->SetRange("Size>0.");
0116   fSizeSurfCmd->SetUnitCategory("Length");
0117   fSizeSurfCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0118   fSizeSurfCmd->SetToBeBroadcasted(false);
0119 
0120   fSizeLayer1Cmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeLayer1", this);
0121   fSizeLayer1Cmd->SetGuidance("Set size of the box");
0122   fSizeLayer1Cmd->SetParameterName("Size", false);
0123   fSizeLayer1Cmd->SetRange("Size>0.");
0124   fSizeLayer1Cmd->SetUnitCategory("Length");
0125   fSizeLayer1Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0126   fSizeLayer1Cmd->SetToBeBroadcasted(false);
0127 
0128   fSizeLayer2Cmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeLayer2", this);
0129   fSizeLayer2Cmd->SetGuidance("Set size of the box");
0130   fSizeLayer2Cmd->SetParameterName("Size", false);
0131   fSizeLayer2Cmd->SetRange("Size>0.");
0132   fSizeLayer2Cmd->SetUnitCategory("Length");
0133   fSizeLayer2Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0134   fSizeLayer2Cmd->SetToBeBroadcasted(false);
0135 
0136   fSizeLayer3Cmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeLayer3", this);
0137   fSizeLayer3Cmd->SetGuidance("Set size of the box");
0138   fSizeLayer3Cmd->SetParameterName("Size", false);
0139   fSizeLayer3Cmd->SetRange("Size>0.");
0140   fSizeLayer3Cmd->SetUnitCategory("Length");
0141   fSizeLayer3Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0142   fSizeLayer3Cmd->SetToBeBroadcasted(false);
0143 
0144   fSizeLayer4Cmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeLayer4", this);
0145   fSizeLayer4Cmd->SetGuidance("Set size of the box");
0146   fSizeLayer4Cmd->SetParameterName("Size", false);
0147   fSizeLayer4Cmd->SetRange("Size>0.");
0148   fSizeLayer4Cmd->SetUnitCategory("Length");
0149   fSizeLayer4Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0150   fSizeLayer4Cmd->SetToBeBroadcasted(false);
0151 
0152 
0153   UpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update", this);
0154   UpdateCmd->SetGuidance("Update calorimeter geometry.");
0155   UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
0156   UpdateCmd->SetGuidance("if you changed geometrical value(s).");
0157   UpdateCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0158 
0159 
0160 }
0161 
0162 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0163 
0164 DetectorMessenger::~DetectorMessenger()
0165 {
0166   delete fMaterCmd;
0167   delete fSizeCmd;
0168   delete fWidthCmd;
0169   delete fDetDir;  
0170   delete fTestemDir;
0171   delete  UpdateCmd;
0172  
0173 
0174 }
0175 
0176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0177 
0178 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0179 { 
0180   if( command == fMaterCmd )
0181    { fDetector->SetMaterial(newValue);}
0182 
0183   if (command == fMaterSurfCmd)
0184   {
0185       fDetector->SetMaterialSurface(newValue);
0186   }
0187   if (command == fMaterLayer1Cmd)
0188   {
0189       fDetector->SetMaterialLayer1(newValue);
0190   }
0191   if (command == fMaterLayer2Cmd)
0192   {
0193       fDetector->SetMaterialLayer2(newValue);
0194   }
0195   if (command == fMaterLayer3Cmd)
0196   {
0197       fDetector->SetMaterialLayer3(newValue);
0198   }
0199   if (command == fMaterLayer4Cmd)
0200   {
0201       fDetector->SetMaterialLayer4(newValue);
0202   }
0203 
0204 
0205   if( command == fSizeCmd )
0206    { 
0207       fDetector->SetSize(fSizeCmd->GetNewDoubleValue(newValue));
0208   }
0209   if (command == fWidthCmd)
0210   {
0211       fDetector->SetWidth(fWidthCmd->GetNewDoubleValue(newValue));
0212   }
0213   if (command == fSizeSurfCmd)
0214   {
0215       fDetector->SetSizeSurface(fSizeSurfCmd->GetNewDoubleValue(newValue));
0216   }
0217   if (command == fSizeLayer1Cmd)
0218   {
0219       fDetector->SetSizeLayer1(fSizeLayer1Cmd->GetNewDoubleValue(newValue));
0220   }
0221   if (command == fSizeLayer2Cmd)
0222   {
0223       fDetector->SetSizeLayer2(fSizeLayer2Cmd->GetNewDoubleValue(newValue));
0224   }
0225   if (command == fSizeLayer3Cmd)
0226   {
0227       fDetector->SetSizeLayer3(fSizeLayer3Cmd->GetNewDoubleValue(newValue));
0228   }
0229   if (command == fSizeLayer4Cmd)
0230   {
0231       fDetector->SetSizeLayer4(fSizeLayer4Cmd->GetNewDoubleValue(newValue));
0232   }
0233 
0234   if (command == UpdateCmd) {
0235       fDetector->UpdateGeometry();
0236   }
0237  
0238 }
0239 
0240 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......