Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:11

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 #include "DetectorConstructionMessenger.hh"
0028 
0029 #include "DetectorConstruction.hh"
0030 
0031 #include "G4RunManager.hh"
0032 #include "G4UIcmdWith3Vector.hh"
0033 #include "G4UIcmdWith3VectorAndUnit.hh"
0034 #include "G4UIcmdWithABool.hh"
0035 #include "G4UIcmdWithADouble.hh"
0036 #include "G4UIcmdWithADoubleAndUnit.hh"
0037 #include "G4UIcmdWithAString.hh"
0038 #include "G4UIdirectory.hh"
0039 #include "G4ios.hh"
0040 
0041 DetectorConstructionMessenger::DetectorConstructionMessenger(DetectorConstruction* mpga)
0042   : fTarget(mpga)
0043 {
0044   fMyXtalDirectory = new G4UIdirectory("/xtal/");
0045   fMyXtalDirectory->SetGuidance("Crystal setup control commands.");
0046 
0047   fXtalMaterialCmd = new G4UIcmdWithAString("/xtal/setMaterial", this);
0048   fXtalMaterialCmd->SetGuidance("Set crystal material.");
0049   fXtalMaterialCmd->SetParameterName("xMat", true);
0050   fXtalMaterialCmd->SetDefaultValue("G4_Si");
0051 
0052   fXtalSizeCmd = new G4UIcmdWith3VectorAndUnit("/xtal/setSize", this);
0053   fXtalSizeCmd->SetGuidance("Set crystal size.");
0054   fXtalSizeCmd->SetParameterName("xtalSizeX", "xtalSizeY", "xtalSizeZ", true);
0055   fXtalSizeCmd->SetDefaultValue(G4ThreeVector(6., 2., 6.));
0056   fXtalSizeCmd->SetDefaultUnit("mm");
0057 
0058   fXtalBRCmd = new G4UIcmdWith3VectorAndUnit("/xtal/setBR", this);
0059   fXtalBRCmd->SetGuidance("Set crystal bending radius.");
0060   fXtalBRCmd->SetParameterName("xtalBRX", "xtalBRY", "xtalBRZ", true);
0061   fXtalBRCmd->SetDefaultValue(G4ThreeVector(0., 0., 0.));
0062   fXtalBRCmd->SetDefaultUnit("m");
0063 
0064   fXtalAngleCmd = new G4UIcmdWith3VectorAndUnit("/xtal/setAngle", this);
0065   fXtalAngleCmd->SetGuidance("Set crystal angles.");
0066   fXtalAngleCmd->SetParameterName("xtalAngleX", "xtalAngleY", "xtalAngleZ", true);
0067   fXtalAngleCmd->SetDefaultValue(G4ThreeVector(0., 0., 0.));
0068   fXtalAngleCmd->SetDefaultUnit("rad");
0069 
0070   fXtalECCmd = new G4UIcmdWithAString("/xtal/setEC", this);
0071   fXtalECCmd->SetGuidance("Set crystal EC.");
0072   fXtalECCmd->SetParameterName("xEC", true);
0073   fXtalECCmd->SetDefaultValue("data/Si220pl");
0074 }
0075 
0076 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0077 
0078 DetectorConstructionMessenger::~DetectorConstructionMessenger()
0079 {
0080   delete fXtalMaterialCmd;
0081   delete fXtalSizeCmd;
0082   delete fXtalAngleCmd;
0083   delete fXtalECCmd;
0084   delete fXtalBRCmd;
0085 }
0086 
0087 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0088 
0089 void DetectorConstructionMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0090 {
0091   if (command == fXtalMaterialCmd) {
0092     fTarget->SetMaterial(newValue);
0093   }
0094   if (command == fXtalSizeCmd) {
0095     fTarget->SetSizes(fXtalSizeCmd->GetNew3VectorValue(newValue));
0096   }
0097   if (command == fXtalBRCmd) {
0098     fTarget->SetBR(fXtalBRCmd->GetNew3VectorValue(newValue));
0099   }
0100   if (command == fXtalAngleCmd) {
0101     fTarget->SetAngles(fXtalAngleCmd->GetNew3VectorValue(newValue));
0102   }
0103   if (command == fXtalECCmd) {
0104     fTarget->SetEC(newValue);
0105   }
0106 }
0107 
0108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0109 
0110 G4String DetectorConstructionMessenger::GetCurrentValue(G4UIcommand* command)
0111 {
0112   G4String cv;
0113 
0114   if (command == fXtalMaterialCmd) {
0115     cv = fTarget->GetMaterial();
0116   }
0117   if (command == fXtalSizeCmd) {
0118     cv = fXtalSizeCmd->ConvertToString(fTarget->GetSizes(), "mm");
0119   }
0120   if (command == fXtalBRCmd) {
0121     cv = fXtalBRCmd->ConvertToString(fTarget->GetBR(), "m");
0122   }
0123   if (command == fXtalAngleCmd) {
0124     cv = fXtalAngleCmd->ConvertToString(fTarget->GetAngles(), "rad");
0125   }
0126   if (command == fXtalECCmd) {
0127     cv = fTarget->GetEC();
0128   }
0129   return cv;
0130 }
0131 
0132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....