Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:20

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 // Hadrontherapy advanced example for Geant4
0027 // See more at: https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesHadrontherapy
0028 
0029 #include "LaserDrivenBeamLineMessenger.hh"
0030 #include "LaserDrivenBeamLine.hh"
0031 #include "G4UIdirectory.hh"
0032 #include "G4UIcmdWithADoubleAndUnit.hh"
0033 #include "G4UIcmdWithoutParameter.hh"
0034 #include "G4UIcmdWithAString.hh"
0035 #include "G4SystemOfUnits.hh"
0036 
0037 /////////////////////////////////////////////////////////////////////////////
0038 LaserDrivenBeamLineMessenger::LaserDrivenBeamLineMessenger(LaserDrivenBeamLine* laserDriven)
0039   :laserDrivenMessengerPointer(laserDriven)
0040 {
0041 // Messenger directories for the Energy Selector module
0042   laserDrivenDir = new G4UIdirectory("/LaserDriven/");
0043   laserDrivenDir -> SetGuidance("The Laser Driven Beam Line module of Hadrontherapy");
0044 
0045   // Messenger directories for the Energy Selector module
0046   energySelectorDir = new G4UIdirectory("/LaserDriven/EnergySelector/");
0047   energySelectorDir -> SetGuidance("The Energy selector (ESS) module of Hadrontherapy");
0048 
0049   FcollimatorDir =  new G4UIdirectory("/LaserDriven/EnergySelector/FirstCollimator/");
0050   FcollimatorDir -> SetGuidance("Define geometrical characteristics of the ESS first collimator");
0051 
0052   ScollimatorDir =  new G4UIdirectory("/LaserDriven/EnergySelector/SecondCollimator/");
0053   ScollimatorDir -> SetGuidance("Define geometrical characteristics of the ESS second collimator");
0054 
0055   slitDir =  new G4UIdirectory("/LaserDriven/EnergySelector/Slit/");
0056   slitDir -> SetGuidance("Define geometrical characteristics of the ESS slit");
0057 
0058  // Messenger directories for the Quadrupole module
0059   quadrupoleDir = new G4UIdirectory("/LaserDriven/Quadrupoles/");
0060   quadrupoleDir -> SetGuidance("The Quadrupoles module of Hadrontherapy");
0061 
0062   relativePosDir = new G4UIdirectory("/LaserDriven/Quadrupoles/xRelPosition/");
0063   relativePosDir -> SetGuidance("Define the x relative positions of the quadrupoles");
0064 
0065   // ESS DISABLE
0066   DisableESSCmd = new G4UIcmdWithoutParameter("/LaserDriven/EnergySelector/Disable", this); 
0067   DisableESSCmd -> SetGuidance("Disable the Energy Selector.");
0068   DisableESSCmd -> SetGuidance("This command MUST be applied before \"beamOn\" ");
0069   DisableESSCmd -> AvailableForStates(G4State_Idle);
0070 
0071   // THE FIRST ESS COLLIMATOR
0072   //
0073   // Diameter of the first collimator
0074   FcollimatorRadiusCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/FirstCollimator/Radius", this);
0075   FcollimatorRadiusCmd -> SetGuidance("Set the Radius of the first collimator");
0076   FcollimatorRadiusCmd -> SetParameterName("Size",false);
0077   FcollimatorRadiusCmd -> SetDefaultUnit("mm"); 
0078   FcollimatorRadiusCmd -> SetUnitCandidates("mm cm m");  
0079   FcollimatorRadiusCmd -> AvailableForStates(G4State_Idle);
0080     
0081   // Thickness of the first collimator
0082   FcollimatorThicknessCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/FirstCollimator/Thickness", this);
0083   FcollimatorThicknessCmd -> SetGuidance("Set the thickness of the first collimator");
0084   FcollimatorThicknessCmd -> SetParameterName("Size",false);
0085   FcollimatorThicknessCmd -> SetDefaultUnit("mm"); 
0086   FcollimatorThicknessCmd -> SetUnitCandidates("mm cm m");  
0087   FcollimatorThicknessCmd -> AvailableForStates(G4State_Idle);
0088 
0089   // Z Position of the first collimator hole 
0090   FcollimatorZpositionCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/FirstCollimator/zPosizion", this);
0091   FcollimatorZpositionCmd -> SetGuidance("Set the Z position of the first collimator hole as respect the internal vacuum chamber center axis");
0092   FcollimatorZpositionCmd -> SetParameterName("Size",false);
0093   FcollimatorZpositionCmd -> SetDefaultUnit("mm"); 
0094   FcollimatorZpositionCmd -> SetUnitCandidates("mm cm m");  
0095   FcollimatorZpositionCmd -> AvailableForStates(G4State_Idle);
0096         
0097   // THE SECOND ESS COLLIMATOR
0098   //
0099  // Diameter of the second collimator
0100   ScollimatorRadiusCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/SecondCollimator/Radius", this);
0101   ScollimatorRadiusCmd -> SetGuidance("Set the Radius of the second collimator");
0102   ScollimatorRadiusCmd -> SetParameterName("Size",false);
0103   ScollimatorRadiusCmd -> SetDefaultUnit("mm"); 
0104   ScollimatorRadiusCmd -> SetUnitCandidates("mm cm m");  
0105   ScollimatorRadiusCmd -> AvailableForStates(G4State_Idle);
0106     
0107   // Thickness of the second collimator
0108   ScollimatorThicknessCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/SecondCollimator/Thickness", this);
0109   ScollimatorThicknessCmd -> SetGuidance("Set the thickness of the second collimator");
0110   ScollimatorThicknessCmd -> SetParameterName("Size",false);
0111   ScollimatorThicknessCmd -> SetDefaultUnit("mm"); 
0112   ScollimatorThicknessCmd -> SetUnitCandidates("mm cm m");  
0113   ScollimatorThicknessCmd -> AvailableForStates(G4State_Idle);
0114 
0115   // Z Position of the second collimator hole 
0116   ScollimatorZpositionCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/SecondCollimator/zPosizion", this);
0117   ScollimatorZpositionCmd -> SetGuidance("Set the Z position of the second collimator hole as respect the internal vacuum chamber center axis");
0118   ScollimatorZpositionCmd -> SetParameterName("Size",false);
0119   ScollimatorZpositionCmd -> SetDefaultUnit("mm"); 
0120   ScollimatorZpositionCmd -> SetUnitCandidates("mm cm m");  
0121   ScollimatorZpositionCmd -> AvailableForStates(G4State_Idle);
0122         
0123   // THE SLIT
0124   //    
0125   // Thickness Slit
0126   SlitThicknessCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/Slit/thickness",this);
0127   SlitThicknessCmd -> SetGuidance("Set the X dimension of the Slit, the maximum value is 10 mm");
0128   SlitThicknessCmd -> SetParameterName("Size",false);
0129   SlitThicknessCmd -> SetDefaultUnit("mm"); 
0130   SlitThicknessCmd -> SetUnitCandidates("mm cm m");  
0131   SlitThicknessCmd -> AvailableForStates(G4State_Idle);
0132     
0133   //Hole dimension of the Slit (in Y direction)
0134   holeSlitDimensionYCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/Slit/HoleDimensionY",this);
0135   holeSlitDimensionYCmd -> SetGuidance("Set the Y dimension of the Slit Hole");
0136   holeSlitDimensionYCmd -> SetParameterName("Size",false);
0137   holeSlitDimensionYCmd -> SetDefaultUnit("mm"); 
0138   holeSlitDimensionYCmd -> SetUnitCandidates("mm cm m");  
0139   holeSlitDimensionYCmd -> AvailableForStates(G4State_Idle);
0140     
0141   // Hole dimension of the Slit (in Z direction)
0142   holeSlitDimensionZCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/Slit/HoleDimensionZ",this);
0143   holeSlitDimensionZCmd -> SetGuidance("Set the Z dimension of the external part of magnet 4");
0144   holeSlitDimensionZCmd -> SetParameterName("Size",false);
0145   holeSlitDimensionZCmd -> SetDefaultUnit("mm"); 
0146   holeSlitDimensionZCmd -> SetUnitCandidates("mm cm m");  
0147   holeSlitDimensionZCmd -> AvailableForStates(G4State_Idle);
0148     
0149   // Hole position of the Slit (in Z direction as respect the Slit body)
0150   slitHolePositionZCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/Slit/HolePositionZ", this);
0151   slitHolePositionZCmd -> SetGuidance("Set the Slit hole position in the Z direction as respect the Slit body center");
0152   slitHolePositionZCmd -> SetParameterName("Size",false);
0153   slitHolePositionZCmd -> SetDefaultUnit("mm"); 
0154   slitHolePositionZCmd -> SetUnitCandidates("mm cm m");  
0155   slitHolePositionZCmd -> AvailableForStates(G4State_Idle);
0156 
0157 //  Quadrupole system DISABLE
0158    DisableQuadsCmd = new G4UIcmdWithoutParameter("/LaserDriven/Quadrupoles/DisableQuads", this);    
0159    DisableQuadsCmd -> SetGuidance("Disable the Quadrupole system.");
0160    DisableQuadsCmd -> SetGuidance("This command MUST be applied before \"beamOn\" ");
0161    DisableQuadsCmd -> AvailableForStates(G4State_Idle);         
0162 }
0163 
0164 /////////////////////////////////////////////////////////////////////////////
0165 LaserDrivenBeamLineMessenger::~LaserDrivenBeamLineMessenger()
0166 { 
0167 
0168   delete laserDrivenDir;
0169   delete energySelectorDir;
0170   delete FcollimatorDir;
0171   delete ScollimatorDir;
0172   delete slitDir;
0173   delete quadrupoleDir;
0174   delete relativePosDir;
0175   delete DisableESSCmd;
0176   delete FcollimatorRadiusCmd;
0177   delete FcollimatorThicknessCmd;   
0178   delete FcollimatorZpositionCmd;
0179   delete ScollimatorRadiusCmd;
0180   delete ScollimatorThicknessCmd;   
0181   delete ScollimatorZpositionCmd;
0182 
0183   delete SlitThicknessCmd;
0184   delete holeSlitDimensionYCmd;
0185   delete holeSlitDimensionZCmd;
0186   delete slitHolePositionZCmd;
0187 
0188   delete DisableQuadsCmd;
0189         
0190 }
0191 /////////////////////////////////////////////////////////////////////////////
0192 void LaserDrivenBeamLineMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
0193 { 
0194   if (command == DisableESSCmd)
0195     {
0196       laserDrivenMessengerPointer -> RemoveESS();
0197     }
0198   if( command == FcollimatorRadiusCmd )
0199     { 
0200       laserDrivenMessengerPointer -> SetFirstCollimatorRadius
0201     (FcollimatorRadiusCmd -> GetNewDoubleValue(newValue));
0202     }
0203   else if( command == FcollimatorThicknessCmd )
0204     { 
0205       laserDrivenMessengerPointer -> SetFirstCollimatorThickness
0206     (FcollimatorThicknessCmd -> GetNewDoubleValue(newValue));
0207     }
0208   else if( command == FcollimatorZpositionCmd )
0209     { 
0210       laserDrivenMessengerPointer -> SetFirstCollimatorPositionZ
0211     (FcollimatorZpositionCmd -> GetNewDoubleValue(newValue));
0212     }
0213   else if( command == ScollimatorRadiusCmd )
0214     { 
0215       laserDrivenMessengerPointer -> SetSecondCollimatorRadius
0216     (ScollimatorRadiusCmd -> GetNewDoubleValue(newValue));
0217     }
0218   else if( command == ScollimatorThicknessCmd )
0219     { 
0220       laserDrivenMessengerPointer -> SetSecondCollimatorThickness
0221     (ScollimatorThicknessCmd -> GetNewDoubleValue(newValue));
0222     }
0223   else if( command == ScollimatorZpositionCmd )
0224     { 
0225       laserDrivenMessengerPointer -> SetSecondCollimatorPositionZ
0226     (ScollimatorZpositionCmd -> GetNewDoubleValue(newValue));
0227     }
0228   else if( command == SlitThicknessCmd )
0229     { 
0230       laserDrivenMessengerPointer -> SetThicknessSlit
0231     (SlitThicknessCmd -> GetNewDoubleValue(newValue));
0232     }       
0233   else if( command == holeSlitDimensionYCmd ) 
0234     { 
0235       laserDrivenMessengerPointer -> SetSlitHoleDimensionY
0236     (holeSlitDimensionYCmd -> GetNewDoubleValue(newValue));
0237     }
0238   else if( command == holeSlitDimensionZCmd ) 
0239     { 
0240       laserDrivenMessengerPointer -> SetSlitHoleDimensionZ
0241     (holeSlitDimensionZCmd -> GetNewDoubleValue(newValue));
0242     }
0243   else if( command == slitHolePositionZCmd ) 
0244     { 
0245       laserDrivenMessengerPointer -> SetSlitHolePositionZ
0246     (slitHolePositionZCmd -> GetNewDoubleValue(newValue));
0247     }   
0248   else if (command==DisableQuadsCmd)
0249    {
0250       laserDrivenMessengerPointer -> RemoveQuads();
0251     }
0252     
0253 }
0254