Back to home page

EIC code displayed by LXR

 
 

    


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

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 // Code developed by
0027 // Silvia Pozzi (1), silvia.pozzi@iss.it
0028 // Barbara Caccia (1), barbara.caccia@iss.it
0029 // Carlo Mancini Terracciano (2), carlo.mancini.terracciano@roma1.infn.it
0030 // (1) Istituto Superiore di Sanita' and INFN Roma, Italy
0031 // (2) Univ. La Sapienza and INFN Roma, Italy
0032 
0033 #include "DetectorMessenger.hh"
0034 
0035 DetectorMessenger::~DetectorMessenger()
0036 {
0037     // UI commands and directory have to be deleted
0038     delete fieldSide;
0039     delete sourceToSkinDistance;
0040     delete phantomSide;
0041     delete voxelSide;
0042     delete voxelDepth;
0043 }
0044 
0045 DetectorMessenger::DetectorMessenger(DetectorConstruction* myDetector)
0046 : detPointer(myDetector)
0047 {
0048     fieldSide = new G4UIcmdWithADoubleAndUnit("/DetectorConstruction/Acc/fieldSide", this);
0049     fieldSide -> SetDefaultUnit("mm");
0050     fieldSide -> SetDefaultValue(100.);
0051     fieldSide -> SetGuidance("Set the field side");
0052     detPointer -> SetJaws(100.*mm);
0053 
0054     sourceToSkinDistance = new G4UIcmdWithADoubleAndUnit("/DetectorConstruction/Acc/sourceToSkinDistance", this);
0055     sourceToSkinDistance -> SetDefaultUnit("mm");
0056     sourceToSkinDistance -> SetDefaultValue(900.);
0057     sourceToSkinDistance -> SetGuidance("Set the distance between the source and the patient's skin");
0058     detPointer -> SetTargetPosition(900.*mm);
0059 
0060     phantomSide = new G4UIcmdWithADoubleAndUnit("/DetectorConstruction/Phantom/phantomSide", this);
0061     phantomSide -> SetDefaultUnit("mm");
0062     phantomSide -> SetDefaultValue(255.*mm);
0063     phantomSide -> SetGuidance("Set the side of the phantom");
0064     detPointer -> SetPhantomSide(255.*mm);
0065 
0066     voxelSide = new G4UIcmdWithADoubleAndUnit("/DetectorConstruction/Phantom/voxelSide", this);
0067     voxelSide -> SetDefaultUnit("mm");
0068     voxelSide -> SetDefaultValue(5.*mm);
0069     voxelSide -> SetGuidance("Set the phantom voxel lateral dimension");
0070     detPointer -> SetVoxelSide(5.*mm);
0071 
0072     voxelDepth = new G4UIcmdWithADoubleAndUnit("/DetectorConstruction/Phantom/voxelDepth", this);
0073     voxelDepth -> SetDefaultUnit("mm");
0074     voxelDepth -> SetDefaultValue(5.*mm);
0075     voxelDepth -> SetGuidance("Set the phantom voxel depth");
0076     detPointer -> SetVoxelDepth(5.*mm);
0077 }
0078 
0079 void DetectorMessenger::SetNewValue(G4UIcommand* cmd, G4String newValue)
0080 {
0081     if (cmd == fieldSide)
0082     {
0083         fieldSide -> GetNewUnitValue(newValue);
0084         detPointer -> SetJaws(fieldSide -> GetNewDoubleValue(newValue));
0085         detPointer -> UpdateGeometry("fieldSide", fieldSide -> GetNewDoubleRawValue(newValue));
0086     }
0087     else if (cmd == sourceToSkinDistance)
0088     {
0089         sourceToSkinDistance -> GetNewUnitValue(newValue);
0090         detPointer -> SetTargetPosition(sourceToSkinDistance -> GetNewDoubleValue(newValue));
0091         detPointer -> UpdateGeometry("sourceToSkinDistance", sourceToSkinDistance -> GetNewDoubleRawValue(newValue));
0092     }
0093     else if (cmd == voxelDepth)
0094     {
0095         voxelDepth -> GetNewUnitValue(newValue);
0096         detPointer -> SetVoxelDepth(voxelDepth ->GetNewDoubleValue(newValue));
0097         detPointer -> UpdateGeometry("voxelDepth", voxelDepth -> GetNewDoubleRawValue(newValue));
0098     }
0099     else if (cmd == voxelSide)
0100     {
0101         voxelSide -> GetNewUnitValue(newValue);
0102         detPointer -> SetVoxelSide(voxelSide ->GetNewDoubleValue(newValue));
0103         detPointer -> UpdateGeometry("voxelSide", voxelSide -> GetNewDoubleRawValue(newValue));
0104 
0105     }
0106     else if (cmd == phantomSide)
0107     {
0108         phantomSide -> GetNewUnitValue(newValue);
0109         detPointer -> SetPhantomSide(phantomSide ->GetNewDoubleValue(newValue));
0110         detPointer -> UpdateGeometry("phantomSide", phantomSide -> GetNewDoubleRawValue(newValue));
0111     }
0112     else
0113         G4cerr << "DetectorMessenger::SetNewValue: command not found" << G4endl;
0114 }
0115 
0116 
0117 
0118