Back to home page

EIC code displayed by LXR

 
 

    


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

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 "globals.hh"
0030 #include "G4SystemOfUnits.hh"
0031 #include "G4Box.hh"
0032 #include "G4Tubs.hh"
0033 #include "G4VisAttributes.hh"
0034 #include "G4Colour.hh"
0035 #include "G4RunManager.hh"
0036 #include "G4LogicalVolume.hh"
0037 #include "G4PVPlacement.hh"
0038 #include "G4RotationMatrix.hh"
0039 #include "G4NistManager.hh"
0040 #include "G4NistElementBuilder.hh"
0041 #include "HadrontherapyDetectorConstruction.hh"
0042 #include "HadrontherapyModulator.hh"
0043 #include "BESTPassiveProtonBeamLine.hh"
0044 #include "BESTPassiveProtonBeamLineMessenger.hh"
0045 
0046 
0047 //G4bool PassiveProtonBeamLine::doCalculation = false;
0048 /////////////////////////////////////////////////////////////////////////////
0049 BESTPassiveProtonBeamLine::BESTPassiveProtonBeamLine():
0050 modulator(0), physicalTreatmentRoom(0),hadrontherapyDetectorConstruction(0),
0051 physiBeamLineSupport(0), physiBeamLineCover(0), physiBeamLineCover2(0),
0052 BESTfirstScatteringFoil(0), physiBESTFirstScatteringFoil(0), physiBESTKaptonWindow(0),
0053 solidBESTStopper(0), physiBESTStopper(0), BESTsecondScatteringFoil(0), physiBESTSecondScatteringFoil(0),
0054 physiBESTFirstCollimator(0), solidBESTRangeShifterBox(0), logicBESTRangeShifterBox(0),
0055 physiBESTRangeShifterBox(0), physiBESTSecondCollimator(0), physiBESTFirstCollimatorModulatorBox(0),
0056 physiBESTHoleFirstCollimatorModulatorBox(0), physiBESTSecondCollimatorModulatorBox(0),
0057 physiBESTHoleSecondCollimatorModulatorBox(0),
0058 chamberPhys(0),innerchamberPhys(0),enterWindowPhys(0),enterElectrodePhys(0),kaptonLayerPhys1(0),copperLayerPhys1(0),nickelLayerPhys1(0),fFirstCavityPhys(0),centralElectrode1Phys(0), centralWindowPhys(0), centralElectrode2Phys(0),fSecondCavityPhys(0),exitElectrodePhys(0),kaptonLayerPhys2(0),copperLayerPhys2(0),nickelLayerPhys2(0),exitWindowPhys(0),physiNozzleSupport(0), physiBrassTube(0), solidFinalCollimator(0), physiFinalCollimator(0)
0059 {
0060     // Messenger to change parameters of the passiveProtonBeamLine geometry
0061     passiveMessenger = new BESTPassiveProtonBeamLineMessenger(this);
0062     
0063     //***************************** PW ***************************************
0064     static G4String ROGeometryName = "DetectorROGeometry";
0065     RO = new HadrontherapyDetectorROGeometry(ROGeometryName);
0066     
0067     G4cout << "Going to register Parallel world...";
0068     RegisterParallelWorld(RO);
0069     G4cout << "... done" << G4endl;
0070 
0071 }
0072 /////////////////////////////////////////////////////////////////////////////
0073 BESTPassiveProtonBeamLine::~BESTPassiveProtonBeamLine()
0074 {
0075    // delete passiveMessenger;
0076     delete hadrontherapyDetectorConstruction;
0077 
0078 }
0079 
0080 /////////////////////////////////////////////////////////////////////////////
0081 G4VPhysicalVolume* BESTPassiveProtonBeamLine::Construct()
0082 {
0083     // Sets default geometry and materials
0084     SetDefaultDimensions();
0085     
0086     // Construct the whole BEST Passive Beam Line
0087     ConstructBESTPassiveProtonBeamLine();
0088     
0089     //***************************** PW ***************************************
0090     if (!hadrontherapyDetectorConstruction)
0091         
0092         //***************************** PW ***************************************
0093         
0094         // HadrontherapyDetectorConstruction builds ONLY the phantom and the detector with its associated ROGeometry
0095         hadrontherapyDetectorConstruction = new HadrontherapyDetectorConstruction(physicalTreatmentRoom);
0096     
0097     
0098     //***************************** PW ***************************************
0099     
0100     hadrontherapyDetectorConstruction->InitializeDetectorROGeometry(RO,hadrontherapyDetectorConstruction->GetDetectorToWorldPosition());
0101     
0102     //***************************** PW ***************************************
0103 
0104     return physicalTreatmentRoom;
0105 }
0106 
0107 // In the following method the DEFAULTS used in the geometry of
0108 // passive beam line are provided
0109 // HERE THE USER CAN CHANGE THE GEOMETRY CHARACTERISTICS OF BEAM
0110 // LINE ELEMENTS, ALTERNATIVELY HE/SHE CAN USE THE MACRO FILE (IF A
0111 // MESSENGER IS PROVIDED)
0112 //
0113 // DEFAULT MATERIAL ARE ALSO PROVIDED
0114 // and COLOURS ARE ALSO DEFINED
0115 // ----------------------------------------------------------
0116 /////////////////////////////////////////////////////////////////////////////
0117 void BESTPassiveProtonBeamLine::SetDefaultDimensions()
0118 {
0119     // Set of coulors that can be used
0120     white = new G4VisAttributes( G4Colour());
0121     white -> SetVisibility(true);
0122     white -> SetForceSolid(true);
0123     
0124     blue = new G4VisAttributes(G4Colour(0. ,0. ,1.));
0125     blue -> SetVisibility(true);
0126     blue -> SetForceSolid(true);
0127     
0128     gray = new G4VisAttributes( G4Colour(0.5, 0.5, 0.5 ));
0129     gray-> SetVisibility(true);
0130     gray-> SetForceSolid(true);
0131     
0132     red = new G4VisAttributes(G4Colour(1. ,0. ,0.));
0133     red-> SetVisibility(true);
0134     red-> SetForceSolid(true);
0135     
0136     yellow = new G4VisAttributes(G4Colour(1., 1., 0. ));
0137     yellow-> SetVisibility(true);
0138     yellow-> SetForceSolid(true);
0139     
0140     green = new G4VisAttributes( G4Colour(25/255. , 255/255. ,  25/255. ));
0141     green -> SetVisibility(true);
0142     green -> SetForceSolid(true);
0143     
0144     darkGreen = new G4VisAttributes( G4Colour(0/255. , 100/255. ,  0/255. ));
0145     darkGreen -> SetVisibility(true);
0146     darkGreen -> SetForceSolid(true);
0147     
0148     darkOrange3 = new G4VisAttributes( G4Colour(205/255. , 102/255. ,  000/255. ));
0149     darkOrange3 -> SetVisibility(true);
0150     darkOrange3 -> SetForceSolid(true);
0151     
0152     skyBlue = new G4VisAttributes( G4Colour(135/255. , 206/255. ,  235/255. ));
0153     skyBlue -> SetVisibility(true);
0154     skyBlue -> SetForceSolid(true);
0155     
0156     
0157     // VACUUM PIPE: first track of the beam line is inside vacuum;
0158     // The PIPE contains the FIRST SCATTERING FOIL and the KAPTON WINDOW
0159     G4double defaultBESTVacuumZoneXSize = 100.0 *mm;
0160     BESTvacuumZoneXSize = defaultBESTVacuumZoneXSize;
0161     
0162     G4double defaultBESTVacuumZoneYSize = 52.5 *mm;
0163     BESTvacuumZoneYSize = defaultBESTVacuumZoneYSize;
0164     
0165     G4double defaultBESTVacuumZoneZSize = 52.5 *mm;
0166     BESTvacuumZoneZSize = defaultBESTVacuumZoneZSize;
0167     
0168     G4double defaultBESTVacuumZoneXPosition = -3010.0 *mm;
0169     BESTvacuumZoneXPosition = defaultBESTVacuumZoneXPosition;
0170     
0171     // FIRST SCATTERING FOIL: a thin foil performing a first scattering
0172     // of the original beam
0173     G4double defaultBESTFirstScatteringFoilXSize = 0.0075 *mm;
0174     BESTfirstScatteringFoilXSize = defaultBESTFirstScatteringFoilXSize;
0175     
0176     G4double defaultBESTFirstScatteringFoilYSize = 52.5   *mm;
0177    BESTfirstScatteringFoilYSize = defaultBESTFirstScatteringFoilYSize;
0178     
0179     G4double defaultBESTFirstScatteringFoilZSize = 52.5   *mm;
0180     BESTfirstScatteringFoilZSize = defaultBESTFirstScatteringFoilZSize;
0181     
0182     G4double defaultBESTFirstScatteringFoilXPosition = 0.0 *mm;
0183     BESTfirstScatteringFoilXPosition = defaultBESTFirstScatteringFoilXPosition;
0184     
0185     // KAPTON WINDOW: it prmits the passage of the beam from vacuum to air
0186     G4double defaultBESTKaptonWindowXSize = 0.010*mm;
0187     BESTkaptonWindowXSize = defaultBESTKaptonWindowXSize;
0188     
0189     G4double defaultBESTKaptonWindowYSize = 5.25*cm;
0190     BESTkaptonWindowYSize = defaultBESTKaptonWindowYSize;
0191     
0192     G4double defaultBESTKaptonWindowZSize = 5.25*cm;
0193     BESTkaptonWindowZSize = defaultBESTKaptonWindowZSize;
0194     
0195     G4double defaultBESTKaptonWindowXPosition = 100.0*mm - defaultBESTKaptonWindowXSize;
0196     BESTkaptonWindowXPosition = defaultBESTKaptonWindowXPosition;
0197     
0198     // STOPPER: is a small cylinder able to stop the central component
0199     // of the beam (having a gaussian shape). It is connected to the SECON SCATTERING FOIL
0200     // and represent the second element of the scattering system
0201     G4double defaultBESTInnerRadiusStopper = 0.*cm;
0202     BESTinnerRadiusStopper = defaultBESTInnerRadiusStopper;
0203     
0204     G4double defaultBESTHeightStopper = 4.5*mm;
0205     BESTheightStopper = defaultBESTHeightStopper;
0206     
0207     G4double defaultBESTStartAngleStopper = 0.*deg;
0208     BESTstartAngleStopper = defaultBESTStartAngleStopper;
0209     
0210     G4double defaultBESTSpanningAngleStopper = 360.*deg;
0211     BESTspanningAngleStopper = defaultBESTSpanningAngleStopper;
0212     
0213     G4double defaultBESTStopperXPosition = -2705.0 *mm;
0214     BESTstopperXPosition = defaultBESTStopperXPosition;
0215     
0216     G4double defaultBESTStopperYPosition = 0.*m;
0217     BESTstopperYPosition = defaultBESTStopperYPosition;
0218     
0219     G4double defaultBESTStopperZPosition = 0.*m;
0220     BESTstopperZPosition = defaultBESTStopperZPosition;
0221     
0222     G4double defaultBESTOuterRadiusStopper = 3 *mm;
0223     BESTouterRadiusStopper = defaultBESTOuterRadiusStopper;
0224     
0225     // SECOND SCATTERING FOIL: it is another thin foil and provides the
0226     // final diffusion of the beam. It represents the third element of the scattering
0227     // system;
0228     G4double defaultBESTSecondScatteringFoilXSize = 0.0125 *mm;
0229    BESTsecondScatteringFoilXSize = defaultBESTSecondScatteringFoilXSize;
0230     
0231     G4double defaultBESTSecondScatteringFoilYSize = 52.5   *mm;
0232     BESTsecondScatteringFoilYSize = defaultBESTSecondScatteringFoilYSize;
0233     
0234     G4double defaultBESTSecondScatteringFoilZSize = 52.5   *mm;
0235     BESTsecondScatteringFoilZSize = defaultBESTSecondScatteringFoilZSize;
0236     
0237     G4double defaultBESTSecondScatteringFoilXPosition = defaultBESTStopperXPosition + defaultBESTHeightStopper + defaultBESTSecondScatteringFoilXSize;
0238     BESTsecondScatteringFoilXPosition = defaultBESTSecondScatteringFoilXPosition;
0239     
0240     G4double defaultBESTSecondScatteringFoilYPosition =  0 *mm;
0241     BESTsecondScatteringFoilYPosition = defaultBESTSecondScatteringFoilYPosition;
0242     
0243     G4double defaultBESTSecondScatteringFoilZPosition =  0 *mm;
0244     BESTsecondScatteringFoilZPosition = defaultBESTSecondScatteringFoilZPosition;
0245     
0246     // RANGE SHIFTER: is a slab of PMMA acting as energy degreader of
0247     // primary beam
0248     
0249     //Default material of the range shifter
0250     
0251     G4double defaultBESTRangeShifterXSize = 5. *mm;
0252     BESTrangeShifterXSize = defaultBESTRangeShifterXSize;
0253     
0254     G4double defaultBESTRangeShifterYSize = 176. *mm;
0255     BESTrangeShifterYSize = defaultBESTRangeShifterYSize;
0256     
0257     G4double defaultBESTRangeShifterZSize = 176. *mm;
0258     BESTrangeShifterZSize = defaultBESTRangeShifterZSize;
0259     
0260     G4double defaultBESTRangeShifterXPosition = -2393.0 *mm;
0261     BESTrangeShifterXPosition = defaultBESTRangeShifterXPosition;
0262     
0263     G4double defaultBESTRangeShifterYPosition = 0. *mm;
0264     BESTrangeShifterYPosition = defaultBESTRangeShifterYPosition;
0265     
0266     G4double defaultBESTRangeShifterZPosition = 0. *mm;
0267     BESTrangeShifterZPosition = defaultBESTRangeShifterZPosition;
0268     
0269    
0270     
0271     // FINAL COLLIMATOR: is the collimator giving the final transversal shape
0272     // of the beam
0273     G4double defaultBESTinnerRadiusFinalCollimator = 7.5 *mm;
0274     BESTinnerRadiusFinalCollimator = defaultBESTinnerRadiusFinalCollimator;
0275     
0276     // DEFAULT DEFINITION OF THE MATERIALS
0277     // All elements and compound definition follows the NIST database
0278     
0279     // ELEMENTS
0280     G4bool isotopes = false;
0281     G4Material* aluminumNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Al", isotopes);
0282     G4Material* tantalumNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Ta", isotopes);
0283     G4Material* copperNistAsMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu", isotopes);
0284     G4Element* zincNist = G4NistManager::Instance()->FindOrBuildElement("Zn");
0285     G4Element* copperNist = G4NistManager::Instance()->FindOrBuildElement("Cu");
0286     
0287     // COMPOUND
0288     G4Material* airNist =  G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes);
0289     G4Material* kaptonNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON", isotopes);
0290     G4Material* galacticNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic", isotopes);
0291     G4Material* PMMANist = G4NistManager::Instance()->FindOrBuildMaterial("G4_PLEXIGLASS", isotopes);
0292     G4Material* mylarNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_MYLAR", isotopes);
0293     
0294 G4Material* nichelNistAsMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Ni", isotopes);
0295 
0296     
0297 
0298 
0299     G4double d; // Density
0300     G4int nComponents;// Number of components
0301     G4double fractionmass; // Fraction in mass of an element in a material
0302     
0303     d = 8.40*g/cm3;
0304     nComponents = 2;
0305     G4Material* brass = new G4Material("Brass", d, nComponents);
0306     brass -> AddElement(zincNist, fractionmass = 30 *perCent);
0307     brass -> AddElement(copperNist, fractionmass = 70 *perCent);
0308     
0309     
0310     //***************************** PW ***************************************
0311     
0312     // DetectorROGeometry Material
0313     new G4Material("dummyMat", 1., 1.*g/mole, 1.*g/cm3);
0314     
0315     //***************************** PW ***************************************
0316     
0317     
0318     
0319     // MATERIAL ASSIGNMENT
0320     // Range shifter
0321     rangeShifterMaterial = airNist;
0322     
0323     // Support of the beam line
0324     beamLineSupportMaterial = aluminumNist;
0325     
0326     // Vacuum pipe
0327     vacuumZoneMaterial = galacticNist;
0328     
0329     // Material of the fisrt scattering foil
0330     firstScatteringFoilMaterial = tantalumNist;
0331     
0332     // Material of kapton window
0333     kaptonWindowMaterial = kaptonNist;
0334     
0335     // Material of the stopper
0336     stopperMaterial = brass;
0337     
0338     // Material of the second scattering foil
0339     secondScatteringFoilMaterial = tantalumNist;
0340     
0341     // Materials of the collimators
0342     firstCollimatorMaterial = PMMANist;
0343     holeFirstCollimatorMaterial = airNist;
0344     
0345     // Box containing the modulator wheel
0346     modulatorBoxMaterial = aluminumNist;
0347     holeModulatorBoxMaterial = airNist;
0348     
0349     // Materials of the monitor chamber
0350   CopperLayerMaterial=copperNistAsMaterial;
0351     NichelLayerMaterial=nichelNistAsMaterial;
0352     KaptonLayerMaterial=kaptonNist;
0353     WindowMaterial=mylarNist;
0354     CentralWindowMaterial=mylarNist;
0355     wallMaterial=aluminumNist;
0356     ElectrodeMaterial=aluminumNist;
0357     CavityMaterial=airNist;
0358       
0359     
0360     // material of the final nozzle
0361     nozzleSupportMaterial = PMMANist;
0362     brassTubeMaterial = brassTube2Material = brassTube3Material = brass;
0363     holeNozzleSupportMaterial = airNist;
0364     
0365     // Material of the final collimator
0366     finalCollimatorMaterial = brass;
0367 }
0368 
0369 /////////////////////////////////////////////////////////////////////////////
0370 void BESTPassiveProtonBeamLine::ConstructBESTPassiveProtonBeamLine()
0371 {
0372     // -----------------------------
0373     // Treatment room - World volume
0374     //------------------------------
0375     // Treatment room sizes
0376     const G4double worldX = 400.0 *cm;
0377     const G4double worldY = 400.0 *cm;
0378     const G4double worldZ = 400.0 *cm;
0379     G4bool isotopes = false;
0380     
0381     G4Material* airNist =  G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes);
0382     G4Box* treatmentRoom = new G4Box("TreatmentRoom",worldX,worldY,worldZ);
0383     G4LogicalVolume* logicTreatmentRoom = new G4LogicalVolume(treatmentRoom,
0384                                                               airNist,
0385                                                               "logicTreatmentRoom",
0386                                                               0,0,0);
0387     physicalTreatmentRoom = new G4PVPlacement(0,
0388                                               G4ThreeVector(),
0389                                               "physicalTreatmentRoom",
0390                                               logicTreatmentRoom,
0391                                               0,false,0);
0392     
0393     
0394     // The treatment room is invisible in the Visualisation
0395     //logicTreatmentRoom -> SetVisAttributes(G4VisAttributes::GetInvisible());
0396     
0397     // Components of the BEST Passive Proton Beam Line
0398    BESTBeamLineSupport();
0399     BESTBeamScatteringFoils();
0400     BESTRangeShifter();
0401     BESTBeamCollimators();
0402     BESTBeamMonitoring();
0403     BESTBeamNozzle();
0404     BESTBeamFinalCollimator();
0405     
0406     // The following lines construc a typical modulator wheel inside the Passive Beam line.
0407     // Please remember to set the nodulator material (default is air, i.e. no modulator!)
0408     // in the HadrontherapyModulator.cc file
0409     modulator = new HadrontherapyModulator();
0410     modulator -> BuildModulator(physicalTreatmentRoom);
0411 }
0412 
0413 /////////////////////////////////////////////////////////////////////////////
0414 void BESTPassiveProtonBeamLine::BESTBeamLineSupport()
0415 {
0416     // ------------------//
0417     // BEAM LINE SUPPORT //
0418     //-------------------//
0419     const G4double beamLineSupportXSize = 1.5*m;
0420     const G4double beamLineSupportYSize = 20.*mm;
0421     const G4double beamLineSupportZSize = 600.*mm;
0422     
0423     const G4double beamLineSupportXPosition = -1745.09 *mm;
0424     const G4double beamLineSupportYPosition = -230. *mm;
0425     const G4double beamLineSupportZPosition = 0.*mm;
0426     
0427   G4Box* beamLineSupport = new G4Box("BeamLineSupport",
0428                                        beamLineSupportXSize,
0429                                        beamLineSupportYSize,
0430                                        beamLineSupportZSize);
0431     
0432     G4LogicalVolume* logicBeamLineSupport = new G4LogicalVolume(beamLineSupport,
0433                                                                 beamLineSupportMaterial,
0434                                                                 "BeamLineSupport");
0435     physiBeamLineSupport = new G4PVPlacement(0, G4ThreeVector(beamLineSupportXPosition,
0436                                                               beamLineSupportYPosition,
0437                                                               beamLineSupportZPosition),
0438                                              "BeamLineSupport",
0439                                              logicBeamLineSupport,
0440                                              physicalTreatmentRoom, false, 0);
0441     
0442     // Visualisation attributes of the beam line support
0443     
0444     logicBeamLineSupport -> SetVisAttributes(gray);
0445 
0446     //---------------------------------//
0447     //  Beam line cover 1 (left panel) //
0448     //---------------------------------//
0449     const G4double beamLineCoverXSize = 1.5*m;
0450     const G4double beamLineCoverYSize = 750.*mm;
0451     const G4double beamLineCoverZSize = 10.*mm;
0452     
0453     const G4double beamLineCoverXPosition = -1745.09 *mm;
0454     const G4double beamLineCoverYPosition = -1000.*mm;
0455     const G4double beamLineCoverZPosition = 600.*mm;
0456     
0457    G4Box* beamLineCover = new G4Box("BeamLineCover",
0458                                      beamLineCoverXSize,
0459                                      beamLineCoverYSize,
0460                                      beamLineCoverZSize);
0461     
0462     G4LogicalVolume* logicBeamLineCover = new G4LogicalVolume(beamLineCover,
0463                                                               beamLineSupportMaterial,
0464                                                               "BeamLineCover");
0465     
0466     physiBeamLineCover = new G4PVPlacement(0, G4ThreeVector(beamLineCoverXPosition,
0467                                                             beamLineCoverYPosition,
0468                                                             beamLineCoverZPosition),
0469                                            "BeamLineCover",
0470                                            logicBeamLineCover,
0471                                            physicalTreatmentRoom,
0472                                            false,
0473                                            0);
0474     
0475     // ---------------------------------//
0476     //  Beam line cover 2 (rigth panel) //
0477     // ---------------------------------//
0478     // It has the same characteristic of beam line cover 1 but set in a different position
0479     physiBeamLineCover2 = new G4PVPlacement(0, G4ThreeVector(beamLineCoverXPosition,
0480                                                              beamLineCoverYPosition,
0481                                                              - beamLineCoverZPosition),
0482                                             "BeamLineCover2",
0483                                             logicBeamLineCover,
0484                                             physicalTreatmentRoom,
0485                                             false,
0486                                             0);
0487     
0488     logicBeamLineCover -> SetVisAttributes(blue);
0489 
0490     }
0491 
0492 /////////////////////////////////////////////////////////////////////////////
0493 void BESTPassiveProtonBeamLine::BESTBeamScatteringFoils()
0494 {
0495    // ------------//
0496     // VACUUM PIPE //
0497     //-------------//
0498     //
0499     // First track of the beam line is inside vacuum;
0500     // The PIPE contains the FIRST SCATTERING FOIL and the KAPTON WINDOW
0501     G4Box* BESTvacuumZone = new G4Box("VacuumZone", BESTvacuumZoneXSize, BESTvacuumZoneYSize, BESTvacuumZoneZSize);
0502     G4LogicalVolume* logicBESTVacuumZone = new G4LogicalVolume(BESTvacuumZone, vacuumZoneMaterial, "VacuumZone");
0503     G4VPhysicalVolume* physiBESTVacuumZone = new G4PVPlacement(0, G4ThreeVector(BESTvacuumZoneXPosition, 0., 0.),
0504                                                            "VacuumZone",logicBESTVacuumZone, physicalTreatmentRoom, false, 0);
0505     // --------------------------//
0506     // THE FIRST SCATTERING FOIL //
0507     // --------------------------//
0508     // A thin foil performing a first scattering
0509     // of the original beam
0510     BESTfirstScatteringFoil = new G4Box("FirstScatteringFoil",
0511                                     BESTfirstScatteringFoilXSize,
0512                                     BESTfirstScatteringFoilYSize,
0513                                     BESTfirstScatteringFoilZSize);
0514     
0515     G4LogicalVolume* logicBESTFirstScatteringFoil = new G4LogicalVolume(BESTfirstScatteringFoil,
0516                                                                     firstScatteringFoilMaterial,
0517                                                                     "FirstScatteringFoil");
0518     
0519     physiBESTFirstScatteringFoil = new G4PVPlacement(0, G4ThreeVector(BESTfirstScatteringFoilXPosition, 0.,0.),
0520                                                  "FirstScatteringFoil", logicBESTFirstScatteringFoil, physiBESTVacuumZone,
0521                                                  false, 0);
0522     
0523     logicBESTFirstScatteringFoil -> SetVisAttributes(skyBlue);
0524     // -------------------//
0525     // THE KAPTON WINDOWS //
0526     //--------------------//
0527     //It prmits the passage of the beam from vacuum to air
0528  
0529     G4Box* solidBESTKaptonWindow = new G4Box("BESTKaptonWindow",
0530                                          BESTkaptonWindowXSize,
0531                                          BESTkaptonWindowYSize,
0532                                          BESTkaptonWindowZSize);
0533     
0534     G4LogicalVolume* logicBESTKaptonWindow = new G4LogicalVolume(solidBESTKaptonWindow,
0535                                                              kaptonWindowMaterial,
0536                                                              "BESTKaptonWindow");
0537     
0538     physiBESTKaptonWindow = new G4PVPlacement(0, G4ThreeVector(BESTkaptonWindowXPosition, 0., 0.),
0539                                           "BESTKaptonWindow", logicBESTKaptonWindow,
0540                                           physiBESTVacuumZone, false,   0);
0541     
0542     logicBESTKaptonWindow -> SetVisAttributes(darkOrange3);
0543     
0544     // ------------//
0545     // THE STOPPER //
0546     //-------------//
0547     // Is a small cylinder able to stop the central component
0548     // of the beam (having a gaussian shape). It is connected to the SECON SCATTERING FOIL
0549     // and represent the second element of the scattering system
0550     G4double phi = 90. *deg;
0551     // Matrix definition for a 90 deg rotation with respect to Y axis
0552     G4RotationMatrix rm;
0553     rm.rotateY(phi);
0554     
0555     solidBESTStopper = new G4Tubs("Stopper",
0556                               BESTinnerRadiusStopper,
0557                               BESTouterRadiusStopper,
0558                               BESTheightStopper,
0559                               BESTstartAngleStopper,
0560                               BESTspanningAngleStopper);
0561     
0562     logicBESTStopper = new G4LogicalVolume(solidBESTStopper,
0563                                        stopperMaterial,
0564                                        "Stopper",
0565                                        0, 0, 0);
0566     
0567     physiBESTStopper = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(BESTstopperXPosition,
0568                                                                      BESTstopperYPosition,
0569                                                                      BESTstopperZPosition)),
0570                                      "BESTStopper",
0571                                      logicBESTStopper,
0572                                      physicalTreatmentRoom,
0573                                      false,
0574                                      0);
0575     
0576     logicBESTStopper -> SetVisAttributes(red);
0577     
0578     // ---------------------------//
0579     // THE SECOND SCATTERING FOIL //
0580     // ---------------------------//
0581     // It is another thin foil and provides the
0582     // final diffusion of the beam. It represents the third element of the scattering
0583     // system;
0584     
0585     BESTsecondScatteringFoil = new G4Box("SecondScatteringFoil",
0586                                      BESTsecondScatteringFoilXSize,
0587                                      BESTsecondScatteringFoilYSize,
0588                                      BESTsecondScatteringFoilZSize);
0589     
0590     G4LogicalVolume* logicBESTSecondScatteringFoil = new G4LogicalVolume(BESTsecondScatteringFoil,
0591                                                                      secondScatteringFoilMaterial,
0592                                                                      "SecondScatteringFoil");
0593     
0594     physiBESTSecondScatteringFoil = new G4PVPlacement(0, G4ThreeVector(BESTsecondScatteringFoilXPosition,
0595                                                                    BESTsecondScatteringFoilYPosition,
0596                                                                    BESTsecondScatteringFoilZPosition),
0597                                                   "SeconScatteringFoil",
0598                                                   logicBESTSecondScatteringFoil,
0599                                                   physicalTreatmentRoom,
0600                                                   false,
0601                                                   0);
0602     
0603     logicBESTSecondScatteringFoil -> SetVisAttributes(skyBlue);
0604  
0605  
0606 }
0607 /////////////////////////////////////////////////////////////////////////////
0608 void BESTPassiveProtonBeamLine::BESTRangeShifter()
0609 {
0610     // ---------------------------- //
0611     //         THE RANGE SHIFTER    //
0612     // -----------------------------//
0613     // It is a slab of PMMA acting as energy degreader of
0614     // primary beam
0615  
0616     
0617     solidBESTRangeShifterBox = new G4Box("RangeShifterBox",
0618                                      BESTrangeShifterXSize,
0619                                      BESTrangeShifterYSize,
0620                                      BESTrangeShifterZSize);
0621     
0622     logicBESTRangeShifterBox = new G4LogicalVolume(solidBESTRangeShifterBox,
0623                                                rangeShifterMaterial,
0624                                                "RangeShifterBox");
0625     physiBESTRangeShifterBox = new G4PVPlacement(0,
0626                                              G4ThreeVector(BESTrangeShifterXPosition, 0., 0.),
0627                                              "RangeShifterBox",
0628                                              logicBESTRangeShifterBox,
0629                                              physicalTreatmentRoom,
0630                                              false,
0631                                              0);
0632     
0633     
0634     logicBESTRangeShifterBox -> SetVisAttributes(yellow);
0635      
0636     
0637 }
0638 /////////////////////////////////////////////////////////////////////////////
0639 void BESTPassiveProtonBeamLine::BESTBeamCollimators()
0640 {
0641     
0642     
0643     // -----------------//
0644     // FIRST COLLIMATOR //
0645     // -----------------//
0646     // It is a slab of PMMA with an hole in its center
0647     const G4double firstCollimatorXSize = 20.*mm;
0648     const G4double firstCollimatorYSize = 100.*mm;
0649     const G4double firstCollimatorZSize = 100.*mm;
0650     
0651     const G4double firstCollimatorXPosition = -2673.00*mm;
0652     const G4double firstCollimatorYPosition = 0.*mm;
0653     const G4double firstCollimatorZPosition = 0.*mm;
0654     
0655     
0656     G4Box* solidBESTFirstCollimator = new G4Box("FirstCollimator",
0657                                             firstCollimatorXSize,
0658                                             firstCollimatorYSize,
0659                                             firstCollimatorZSize);
0660     
0661     G4LogicalVolume* logicBESTFirstCollimator = new G4LogicalVolume(solidBESTFirstCollimator,
0662                                                                 firstCollimatorMaterial,
0663                                                                 "FirstCollimator");
0664     
0665     physiBESTFirstCollimator = new G4PVPlacement(0, G4ThreeVector(firstCollimatorXPosition,
0666                                                               firstCollimatorYPosition,
0667                                                               firstCollimatorZPosition),
0668                                              "FirstCollimator",
0669                                              logicBESTFirstCollimator,
0670                                              physicalTreatmentRoom,
0671                                              false,
0672                                              0);
0673     // ----------------------------//
0674     // Hole of the first collimator//
0675     //-----------------------------//
0676     G4double innerRadiusHoleFirstCollimator   = 0.*mm;
0677     G4double outerRadiusHoleFirstCollimator   = 15.*mm;
0678     G4double hightHoleFirstCollimator         = 20.*mm;
0679     G4double startAngleHoleFirstCollimator    = 0.*deg;
0680     G4double spanningAngleHoleFirstCollimator = 360.*deg;
0681     
0682     G4Tubs* solidBESTHoleFirstCollimator = new G4Tubs("HoleFirstCollimator",
0683                                                   innerRadiusHoleFirstCollimator,
0684                                                   outerRadiusHoleFirstCollimator,
0685                                                   hightHoleFirstCollimator,
0686                                                   startAngleHoleFirstCollimator,
0687                                                   spanningAngleHoleFirstCollimator);
0688     
0689     G4LogicalVolume* logicBESTHoleFirstCollimator = new G4LogicalVolume(solidBESTHoleFirstCollimator,
0690                                                                     holeFirstCollimatorMaterial,
0691                                                                     "HoleFirstCollimator",
0692                                                                     0, 0, 0);
0693     G4double phi = 90. *deg;
0694     // Matrix definition for a 90 deg rotation. Also used for other volumes
0695     G4RotationMatrix rm;
0696     rm.rotateY(phi);
0697     
0698     physiBESTHoleFirstCollimator = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector()),
0699                                                  "HoleFirstCollimator",
0700                                                  logicBESTHoleFirstCollimator,
0701                                                  physiBESTFirstCollimator,
0702                                                  false,
0703                                                  0);
0704     // ------------------//
0705     // SECOND COLLIMATOR //
0706     //-------------------//
0707     // It is a slab of PMMA with an hole in its center
0708     const G4double secondCollimatorXPosition = -1900.00*mm;
0709     const G4double secondCollimatorYPosition =  0*mm;
0710     const G4double secondCollimatorZPosition =  0*mm;
0711     
0712     physiBESTSecondCollimator = new G4PVPlacement(0, G4ThreeVector(secondCollimatorXPosition,
0713                                                                secondCollimatorYPosition,
0714                                                                secondCollimatorZPosition),
0715                                               "SecondCollimator",
0716                                               logicBESTFirstCollimator,
0717                                               physicalTreatmentRoom,
0718                                               false,
0719                                               0);
0720     
0721     // ------------------------------//
0722     // Hole of the second collimator //
0723     // ------------------------------//
0724     physiBESTHoleSecondCollimator = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector()),
0725                                                   "HoleSecondCollimator",
0726                                                   logicBESTHoleFirstCollimator,
0727                                                   physiBESTSecondCollimator,
0728                                                   false,
0729                                                   0);
0730     
0731     // --------------------------------------//
0732     // FIRST SIDE OF THE MODULATOR BOX      //
0733     // --------------------------------------//
0734     // The modulator box is an aluminum box in which
0735     // the range shifter and the energy modulator are located
0736     // In this example only the entrance and exit
0737     // faces of the box are simulated.
0738     // Each face is an aluminum slab with an hole in its center
0739     
0740     const G4double firstCollimatorModulatorXSize = 10.*mm;
0741     const G4double firstCollimatorModulatorYSize = 200.*mm;
0742     const G4double firstCollimatorModulatorZSize = 200.*mm;
0743     
0744     const G4double firstCollimatorModulatorXPosition = -2523.00*mm;
0745     const G4double firstCollimatorModulatorYPosition = 0.*mm;
0746     const G4double firstCollimatorModulatorZPosition = 0.*mm;
0747     
0748    G4Box* solidBESTFirstCollimatorModulatorBox = new G4Box("FirstCollimatorModulatorBox",
0749                                                         firstCollimatorModulatorXSize,
0750                                                         firstCollimatorModulatorYSize,
0751                                                         firstCollimatorModulatorZSize);
0752     
0753     G4LogicalVolume* logicBESTFirstCollimatorModulatorBox = new G4LogicalVolume(solidBESTFirstCollimatorModulatorBox,
0754                                                                             modulatorBoxMaterial,
0755                                                                             "FirstCollimatorModulatorBox");
0756     
0757     physiBESTFirstCollimatorModulatorBox = new G4PVPlacement(0, G4ThreeVector(firstCollimatorModulatorXPosition,
0758                                                                           firstCollimatorModulatorYPosition,
0759                                                                           firstCollimatorModulatorZPosition),
0760                                                          "FirstCollimatorModulatorBox",
0761                                                          logicBESTFirstCollimatorModulatorBox,
0762                                                          physicalTreatmentRoom, false, 0);
0763     
0764     // ----------------------------------------------------//
0765     //   Hole of the first collimator of the modulator box //
0766     // ----------------------------------------------------//
0767     const G4double innerRadiusHoleFirstCollimatorModulatorBox = 0.*mm;
0768     const G4double outerRadiusHoleFirstCollimatorModulatorBox = 31.*mm;
0769     const G4double hightHoleFirstCollimatorModulatorBox = 10.*mm;
0770     const G4double startAngleHoleFirstCollimatorModulatorBox = 0.*deg;
0771     const G4double spanningAngleHoleFirstCollimatorModulatorBox = 360.*deg;
0772     
0773     G4Tubs* solidBESTHoleFirstCollimatorModulatorBox  = new G4Tubs("HoleFirstCollimatorModulatorBox",
0774                                                                innerRadiusHoleFirstCollimatorModulatorBox,
0775                                                                outerRadiusHoleFirstCollimatorModulatorBox,
0776                                                                hightHoleFirstCollimatorModulatorBox ,
0777                                                                startAngleHoleFirstCollimatorModulatorBox,
0778                                                                spanningAngleHoleFirstCollimatorModulatorBox);
0779     
0780     G4LogicalVolume* logicBESTHoleFirstCollimatorModulatorBox = new G4LogicalVolume(solidBESTHoleFirstCollimatorModulatorBox,
0781                                                                                 holeModulatorBoxMaterial,
0782                                                                                 "HoleFirstCollimatorModulatorBox",
0783                                                                                 0, 0, 0);
0784     
0785     physiBESTHoleFirstCollimatorModulatorBox = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector()),
0786                                                              "HoleFirstCollimatorModulatorBox",
0787                                                              logicBESTHoleFirstCollimatorModulatorBox,
0788                                                              physiBESTFirstCollimatorModulatorBox, false, 0);
0789     
0790     // --------------------------------------------------//
0791     //       SECOND SIDE OF THE MODULATOR BOX            //
0792     // --------------------------------------------------//
0793     const G4double secondCollimatorModulatorXSize = 10.*mm;
0794     const G4double secondCollimatorModulatorYSize = 200.*mm;
0795     const G4double secondCollimatorModulatorZSize = 200.*mm;
0796     
0797     const G4double secondCollimatorModulatorXPosition = -1953.00 *mm;
0798     
0799     const G4double secondCollimatorModulatorYPosition = 0.*mm;
0800     const G4double secondCollimatorModulatorZPosition = 0.*mm;
0801     
0802     G4Box* solidBESTSecondCollimatorModulatorBox = new G4Box("SecondCollimatorModulatorBox",
0803                                                          secondCollimatorModulatorXSize,
0804                                                          secondCollimatorModulatorYSize,
0805                                                          secondCollimatorModulatorZSize);
0806     
0807     G4LogicalVolume* logicBESTSecondCollimatorModulatorBox = new G4LogicalVolume(solidBESTSecondCollimatorModulatorBox,
0808                                                                              modulatorBoxMaterial,
0809                                                                              "SecondCollimatorModulatorBox");
0810     
0811     physiBESTSecondCollimatorModulatorBox = new G4PVPlacement(0, G4ThreeVector(secondCollimatorModulatorXPosition,
0812                                                                            secondCollimatorModulatorYPosition,
0813                                                                            secondCollimatorModulatorZPosition),
0814                                                           "SecondCollimatorModulatorBox",
0815                                                           logicBESTSecondCollimatorModulatorBox,
0816                                                           physicalTreatmentRoom, false, 0);
0817     
0818     // ----------------------------------------------//
0819     //   Hole of the second collimator modulator box //
0820     // ----------------------------------------------//
0821     const G4double innerRadiusHoleSecondCollimatorModulatorBox = 0.*mm;
0822     const G4double outerRadiusHoleSecondCollimatorModulatorBox = 31.*mm;
0823     const G4double hightHoleSecondCollimatorModulatorBox = 10.*mm;
0824     const G4double startAngleHoleSecondCollimatorModulatorBox = 0.*deg;
0825     const G4double spanningAngleHoleSecondCollimatorModulatorBox = 360.*deg;
0826     
0827     G4Tubs* solidBESTHoleSecondCollimatorModulatorBox  = new G4Tubs("HoleSecondCollimatorModulatorBox",
0828                                                                 innerRadiusHoleSecondCollimatorModulatorBox,
0829                                                                 outerRadiusHoleSecondCollimatorModulatorBox,
0830                                                                 hightHoleSecondCollimatorModulatorBox ,
0831                                                                 startAngleHoleSecondCollimatorModulatorBox,
0832                                                                 spanningAngleHoleSecondCollimatorModulatorBox);
0833     
0834     G4LogicalVolume* logicHBESToleSecondCollimatorModulatorBox = new G4LogicalVolume(solidBESTHoleSecondCollimatorModulatorBox,
0835                                                                                  holeModulatorBoxMaterial,
0836                                                                                  "HoleSecondCollimatorModulatorBox",
0837                                                                                  0, 0, 0);
0838     
0839     physiBESTHoleSecondCollimatorModulatorBox = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector()),
0840                                                               "HoleSecondCollimatorModulatorBox",
0841                                                              logicHBESToleSecondCollimatorModulatorBox,
0842                                                               physiBESTSecondCollimatorModulatorBox, false, 0);
0843     
0844     logicBESTFirstCollimator -> SetVisAttributes(yellow);
0845     logicBESTFirstCollimatorModulatorBox -> SetVisAttributes(blue);
0846     logicBESTSecondCollimatorModulatorBox -> SetVisAttributes(blue);
0847 
0848 
0849   
0850   }
0851 
0852 /////////////////////////////////////////////////////////////////////////////
0853 void BESTPassiveProtonBeamLine::BESTBeamMonitoring()
0854 {
0855 
0856 //////// Double-GAP Monitor Chamber ////////////
0857   
0858     G4double fBoxOuterThickness { 100 * mm };
0859     G4double fBoxOuterHeight { 42 * cm };
0860     G4double fBoxOuterWidth { 42 * cm };
0861     G4double fEnterWindowThickness { 25 * um };
0862     G4double fCentralWindowThickness { 20 * um };
0863     G4double fExitWindowThickness { 25 * um };
0864     G4double fBoxInnerThickness { fBoxOuterThickness - fEnterWindowThickness - fExitWindowThickness };
0865     G4double fBoxInnerHeight { 41.95 * cm };
0866     G4double fBoxInnerWidth { 41.95 * cm };
0867     G4double fInnerHeight { 16 * cm };
0868     G4double fInnerWidth { 16 * cm };
0869     G4double fCentralElectrodeThickness { 2 * um };
0870     G4double fCopperLayerThickness { 5 * um };
0871     G4double fKaptonLayerThickness { 25 * um };
0872     G4double fNickelLayerThickness { 2 * um };
0873     G4double fFirstCavityThickness { 5 * mm };
0874     G4double fSecondCavityThickness { 10 * mm };
0875 
0876     G4double monitor1XPosition = -1059.0 *mm;
0877     G4String name;
0878 
0879 G4double phi = 90. *deg;
0880     // Matrix definition for a 90 deg rotation. Also used for other volumes
0881     G4RotationMatrix rm;
0882     rm.rotateY(phi);
0883     
0884   
0885     name = "monitorChamber-externalBox";
0886     G4Box* chamberSolid = new G4Box(name, fBoxOuterWidth / 2, fBoxOuterHeight / 2, fBoxOuterThickness / 2);
0887     G4LogicalVolume* chamberLog = new G4LogicalVolume(chamberSolid, wallMaterial, name);
0888     chamberPhys=new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(monitor1XPosition-10*cm,0.*cm,0.*cm)),name,chamberLog,physicalTreatmentRoom,
0889                                                 false,
0890                                                 0);
0891    // chamberLog->SetVisAttributes(green);
0892 
0893     name = "monitorChamber-innerBox";
0894    
0895     G4Box* innerchamberSolid = new G4Box(name, fBoxInnerWidth / 2, fBoxInnerHeight / 2, fBoxInnerThickness / 2);
0896     G4LogicalVolume* innerchamberLog = new G4LogicalVolume(innerchamberSolid, CavityMaterial, name);
0897     innerchamberPhys=new G4PVPlacement(0, G4ThreeVector(0,0,0), name,innerchamberLog, chamberPhys, false, 0);
0898    // innerchamberLog->SetVisAttributes(green);
0899 
0900     name = "monitorChamber-enterWindow";
0901  
0902 
0903     G4Box* enterWindowSolid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fEnterWindowThickness / 2);
0904     G4LogicalVolume* enterWindowLog = new G4LogicalVolume(enterWindowSolid, WindowMaterial, name);
0905     enterWindowPhys= new G4PVPlacement(0,  G4ThreeVector((-fBoxOuterThickness + fEnterWindowThickness) / 2,0, 0), name,enterWindowLog, chamberPhys, false, 0);
0906     enterWindowLog->SetVisAttributes(green);
0907 
0908     name = "monitorChamber-enterElectrode";
0909     G4double enterElectrodeThickness = fCopperLayerThickness + fKaptonLayerThickness + fNickelLayerThickness;
0910     G4double exitElectrodeThickness = enterElectrodeThickness;
0911    
0912     G4Box* enterElectrodeSolid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, enterElectrodeThickness / 2);
0913     G4LogicalVolume* enterElectrodeLog = new G4LogicalVolume(enterElectrodeSolid, CavityMaterial, name);
0914 
0915     enterElectrodePhys=new G4PVPlacement(0, G4ThreeVector(-(fCentralWindowThickness + enterElectrodeThickness) / 2 - (fCentralElectrodeThickness + fFirstCavityThickness),0,0),  name,enterElectrodeLog, innerchamberPhys, false, 0);
0916     enterElectrodeLog->SetVisAttributes(green);
0917 
0918     name = "monitorChamber-kaptonLayer1";
0919     G4double position_kaptonLayer1 =-enterElectrodeThickness+fKaptonLayerThickness / 2;
0920     G4Box* kaptonLayerSolid1 = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fKaptonLayerThickness / 2);
0921     G4LogicalVolume* kaptonLayerLog1 = new G4LogicalVolume(kaptonLayerSolid1,  KaptonLayerMaterial, name);
0922     kaptonLayerPhys1= new G4PVPlacement(0, G4ThreeVector(position_kaptonLayer1,0,0),  name,kaptonLayerLog1, enterElectrodePhys, false, 0);
0923     kaptonLayerLog1->SetVisAttributes(green);
0924 
0925     name = "monitorChamber-copperLayer1";
0926  
0927 G4double position_copperLayer1=position_kaptonLayer1+(fKaptonLayerThickness+fCopperLayerThickness)/2;
0928     G4Box* copperLayerSolid1 = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fCopperLayerThickness / 2);
0929     G4LogicalVolume* copperLayerLog1 = new G4LogicalVolume(copperLayerSolid1, CopperLayerMaterial, name);
0930     copperLayerPhys1=new G4PVPlacement(0, G4ThreeVector(position_copperLayer1,0,0), name,copperLayerLog1, enterElectrodePhys, false, 0);
0931 
0932     name = "monitorChamber-nickelLayer1";
0933  
0934 G4double position_nichelLayer1=position_copperLayer1+(fCopperLayerThickness + fNickelLayerThickness)/2;
0935 
0936     G4Box* nickelLayerSolid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fNickelLayerThickness / 2);
0937     G4LogicalVolume* nickelLayerLog1 = new G4LogicalVolume(nickelLayerSolid,  NichelLayerMaterial, name);
0938     nickelLayerPhys1=new G4PVPlacement(0,  G4ThreeVector(position_nichelLayer1,0,0), name,nickelLayerLog1, enterElectrodePhys, false, 0);
0939 
0940     name = "monitorChamber-firstCavity";
0941   
0942   
0943 G4double position_firstCavity=-fCentralWindowThickness/2-fCentralElectrodeThickness-(fFirstCavityThickness) / 2;
0944     G4Box* firstCavitySolid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fFirstCavityThickness / 2);
0945     G4LogicalVolume*fFirstCavityLog = new G4LogicalVolume(firstCavitySolid, CavityMaterial, name);
0946     fFirstCavityPhys=new G4PVPlacement(0,  G4ThreeVector( position_firstCavity,0,0), name, fFirstCavityLog, innerchamberPhys, false, 0);
0947 
0948     name = "monitorChamber-centralElectrode1";
0949  
0950 G4double position_centralElectrode1=(-fCentralWindowThickness-fCentralElectrodeThickness) / 2;
0951     G4Box* centralElectrode1Solid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fCentralElectrodeThickness / 2);
0952     G4LogicalVolume* centralElectrode1Log = new G4LogicalVolume(centralElectrode1Solid, ElectrodeMaterial, name);
0953     centralElectrode1Phys=new G4PVPlacement(0, G4ThreeVector(position_centralElectrode1,0,0), name,centralElectrode1Log, innerchamberPhys, false, 0);
0954 
0955     name = "monitorChamber-centralWindow";
0956   //  position={0,0,0};
0957     G4Box* centralWindowSolid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fCentralWindowThickness / 2);
0958     G4LogicalVolume* centralWindowLog = new G4LogicalVolume(centralWindowSolid, CentralWindowMaterial, name);
0959     centralWindowPhys =new G4PVPlacement(0, G4ThreeVector(0,0,0),  name,centralWindowLog, innerchamberPhys, false, 0);
0960     centralWindowLog->SetVisAttributes(green);
0961 
0962     name = "monitorChamber-centralElectrode2";
0963  
0964 G4double position_centralElectrode2=(fCentralWindowThickness+fCentralElectrodeThickness) / 2;
0965     G4Box* centralElectrode2Solid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fCentralElectrodeThickness / 2);
0966     G4LogicalVolume* centralElectrode2Log = new G4LogicalVolume(centralElectrode2Solid, ElectrodeMaterial, name);
0967    centralElectrode2Phys= new G4PVPlacement(0, G4ThreeVector(position_centralElectrode2,0,0),name, centralElectrode2Log,innerchamberPhys, false, 0);
0968 
0969     name = "monitorChamber-secondCavity";
0970  
0971 G4double position_secondCavity=(fCentralWindowThickness)/2+fCentralElectrodeThickness+(fSecondCavityThickness) / 2;
0972     G4Box* secondCavitySolid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fSecondCavityThickness / 2);
0973     G4LogicalVolume*fSecondCavityLog = new G4LogicalVolume(secondCavitySolid, CavityMaterial, name);
0974     fSecondCavityPhys=new G4PVPlacement(0, G4ThreeVector(position_secondCavity,0,0), name, fSecondCavityLog, innerchamberPhys, false, 0);
0975 
0976     name="monitorChamber-exitElectrode";
0977   
0978 G4double position_exitElectrode=(fCentralWindowThickness)/2+fCentralElectrodeThickness+fSecondCavityThickness+(exitElectrodeThickness) / 2;
0979     G4Box* exitElectrodeSolid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, exitElectrodeThickness / 2);
0980     G4LogicalVolume* exitElectrodeLog = new G4LogicalVolume(exitElectrodeSolid, ElectrodeMaterial, name);
0981     exitElectrodePhys=new G4PVPlacement(0, G4ThreeVector(position_exitElectrode,0,0), name,exitElectrodeLog,innerchamberPhys, false, 0);
0982     exitElectrodeLog->SetVisAttributes(green);
0983 
0984     name = "monitorChamber-kaptonLayer2";
0985    
0986 G4double position_kaptonLayer2=(exitElectrodeThickness-fKaptonLayerThickness) / 2;
0987     G4Box* kaptonLayerSolid2 = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fKaptonLayerThickness / 2);
0988     G4LogicalVolume* kaptonLayerLog2 = new G4LogicalVolume(kaptonLayerSolid2,  KaptonLayerMaterial, name);
0989     kaptonLayerPhys2=new G4PVPlacement(0, G4ThreeVector(position_kaptonLayer2,0,0), name,kaptonLayerLog2, exitElectrodePhys, false, 0);
0990 
0991     name = "monitorChamber-copperLayer2";
0992   
0993 G4double position_copperLayer2=(exitElectrodeThickness)/2-fKaptonLayerThickness-(fCopperLayerThickness)/2;
0994     G4Box* copperLayerSolid2 = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fCopperLayerThickness / 2);
0995     G4LogicalVolume* copperLayerLog2 = new G4LogicalVolume(copperLayerSolid2,  CopperLayerMaterial, name);
0996     copperLayerPhys2=new G4PVPlacement(0, G4ThreeVector(position_copperLayer2,0,0), name, copperLayerLog2, exitElectrodePhys, false, 0);
0997 
0998     name = "monitorChamber-nickelLayer2";
0999   
1000 G4double position_nichelLayer2=(exitElectrodeThickness)/2-fKaptonLayerThickness-fCopperLayerThickness-fNickelLayerThickness/2;
1001 
1002     G4Box* nickelLayerSolid2 = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fNickelLayerThickness / 2);
1003     G4LogicalVolume* nickelLayerLog2 = new G4LogicalVolume(nickelLayerSolid2,  NichelLayerMaterial, name);
1004      nickelLayerPhys2=new G4PVPlacement(0, G4ThreeVector(position_nichelLayer2,0,0), name,nickelLayerLog2, exitElectrodePhys, false, 0);
1005 
1006     name = "monitorChamber-exitWindow";
1007  
1008 G4double position_exitWindow=(fBoxOuterThickness - fEnterWindowThickness) / 2;
1009     G4Box* exitWindowSolid = new G4Box(name, fInnerWidth / 2, fInnerHeight / 2, fExitWindowThickness / 2);
1010     G4LogicalVolume* exitWindowLog = new G4LogicalVolume(exitWindowSolid, WindowMaterial, name);
1011    exitWindowPhys= new G4PVPlacement(0, G4ThreeVector(position_exitWindow,0,0), name,exitWindowLog, chamberPhys, false, 0);
1012     exitWindowLog->SetVisAttributes(green);
1013 
1014     
1015      }
1016 /////////////////////////////////////////////////////////////////////////////
1017 void BESTPassiveProtonBeamLine::BESTBeamNozzle()
1018 {
1019     // ------------------------------//
1020     // THE FINAL TUBE AND COLLIMATOR //
1021     //-------------------------------//
1022     // The last part of the transport beam line consists of
1023     // a 59 mm thick PMMA slab (to stop all the diffused radiation), a 370 mm brass tube
1024     // (to well collimate the proton beam) and a final collimator with 25 mm diameter
1025     // aperture (that provide the final trasversal shape of the beam)
1026     
1027     // -------------------//
1028     //     PMMA SUPPORT   //
1029     // -------------------//
1030     const G4double nozzleSupportXSize = 29.5 *mm;
1031     const G4double nozzleSupportYSize = 180. *mm;
1032     const G4double nozzleSupportZSize = 180. *mm;
1033     
1034     const G4double nozzleSupportXPosition = -397.50 *mm;
1035     
1036     G4double phi = 90. *deg;
1037     // Matrix definition for a 90 deg rotation. Also used for other volumes
1038     G4RotationMatrix rm;
1039     rm.rotateY(phi);
1040     
1041     G4Box* solidNozzleSupport = new G4Box("NozzleSupport",
1042                                           nozzleSupportXSize,
1043                                           nozzleSupportYSize,
1044                                           nozzleSupportZSize);
1045     
1046     G4LogicalVolume* logicNozzleSupport = new G4LogicalVolume(solidNozzleSupport,
1047                                                               nozzleSupportMaterial,
1048                                                               "NozzleSupport");
1049     
1050     physiNozzleSupport = new G4PVPlacement(0, G4ThreeVector(nozzleSupportXPosition,0., 0.),
1051                                            "NozzleSupport",
1052                                            logicNozzleSupport,
1053                                            physicalTreatmentRoom,
1054                                            false,
1055                                            0);
1056     
1057     logicNozzleSupport -> SetVisAttributes(yellow);
1058     
1059     
1060     
1061     //------------------------------------//
1062     // HOLE IN THE SUPPORT                //
1063     //------------------------------------//
1064     const G4double innerRadiusHoleNozzleSupport = 0.*mm;
1065     const G4double outerRadiusHoleNozzleSupport = 21.5*mm;
1066     const G4double hightHoleNozzleSupport = 29.5 *mm;
1067     const G4double startAngleHoleNozzleSupport = 0.*deg;
1068     const G4double spanningAngleHoleNozzleSupport = 360.*deg;
1069     
1070     G4Tubs* solidHoleNozzleSupport = new G4Tubs("HoleNozzleSupport",
1071                                                 innerRadiusHoleNozzleSupport,
1072                                                 outerRadiusHoleNozzleSupport,
1073                                                 hightHoleNozzleSupport,
1074                                                 startAngleHoleNozzleSupport,
1075                                                 spanningAngleHoleNozzleSupport);
1076     
1077     G4LogicalVolume* logicHoleNozzleSupport = new G4LogicalVolume(solidHoleNozzleSupport,
1078                                                                   holeNozzleSupportMaterial,
1079                                                                   "HoleNozzleSupport",
1080                                                                   0,
1081                                                                   0,
1082                                                                   0);
1083     
1084     
1085     physiHoleNozzleSupport = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector()),
1086                                                "HoleNozzleSupport",
1087                                                logicHoleNozzleSupport,
1088                                                physiNozzleSupport,
1089                                                false, 0);
1090     
1091     logicHoleNozzleSupport -> SetVisAttributes(darkOrange3);
1092     
1093     // ---------------------------------//
1094     //     BRASS TUBE 1 (phantom side)    //
1095     // ---------------------------------//
1096     const G4double innerRadiusBrassTube= 18.*mm;
1097     const G4double outerRadiusBrassTube = 21.5 *mm;
1098     const G4double hightBrassTube = 140.5*mm;
1099     const G4double startAngleBrassTube = 0.*deg;
1100     const G4double spanningAngleBrassTube = 360.*deg;
1101     
1102     const G4double brassTubeXPosition = -227.5 *mm;
1103     
1104     G4Tubs* solidBrassTube = new G4Tubs("BrassTube",
1105                                         innerRadiusBrassTube,
1106                                         outerRadiusBrassTube,
1107                                         hightBrassTube,
1108                                         startAngleBrassTube,
1109                                         spanningAngleBrassTube);
1110     
1111     G4LogicalVolume* logicBrassTube = new G4LogicalVolume(solidBrassTube,
1112                                                           brassTubeMaterial,
1113                                                           "BrassTube",
1114                                                           0, 0, 0);
1115     
1116     physiBrassTube = new G4PVPlacement(G4Transform3D(rm,
1117                                                      G4ThreeVector(brassTubeXPosition,
1118                                                                    0.,
1119                                                                    0.)),
1120                                        "BrassTube",
1121                                        logicBrassTube,
1122                                        physicalTreatmentRoom,
1123                                        false,
1124                                        0);
1125     
1126     logicBrassTube -> SetVisAttributes(darkOrange3);
1127     
1128     // ----------------------------------------------//
1129     //     BRASS TUBE 2 (inside the PMMA support)    //
1130     // ----------------------------------------------//
1131     const G4double innerRadiusBrassTube2= 18.*mm;
1132     const G4double outerRadiusBrassTube2 = 21.5 *mm;
1133     const G4double hightBrassTube2 = 29.5*mm;
1134     const G4double startAngleBrassTube2 = 0.*deg;
1135     const G4double spanningAngleBrassTube2 = 360.*deg;
1136     
1137     
1138     G4Tubs* solidBrassTube2 = new G4Tubs("BrassTube2",
1139                                          innerRadiusBrassTube2,
1140                                          outerRadiusBrassTube2,
1141                                          hightBrassTube2,
1142                                          startAngleBrassTube2,
1143                                          spanningAngleBrassTube2);
1144     
1145     G4LogicalVolume* logicBrassTube2 = new G4LogicalVolume(solidBrassTube2,
1146                                                            brassTube2Material,
1147                                                            "BrassTube2",
1148                                                            0, 0, 0);
1149     
1150     physiBrassTube2 = new G4PVPlacement(0,
1151                                         G4ThreeVector(0,0.,0.),
1152                                         logicBrassTube2,
1153                                         "BrassTube2",
1154                                         logicHoleNozzleSupport,
1155                                         false,
1156                                         0);
1157     
1158     logicBrassTube2 -> SetVisAttributes(darkOrange3);
1159     
1160     
1161     // --------------------------------------//
1162     //     BRASS TUBE 3 (beam line side)    //
1163     // -------------------------------------//
1164     const G4double innerRadiusBrassTube3= 18.*mm;
1165     const G4double outerRadiusBrassTube3 = 21.5 *mm;
1166     const G4double hightBrassTube3 = 10.0 *mm;
1167     const G4double startAngleBrassTube3 = 0.*deg;
1168     const G4double spanningAngleBrassTube3 = 360.*deg;
1169     
1170     const G4double brassTube3XPosition = -437 *mm;
1171     
1172     G4Tubs* solidBrassTube3 = new G4Tubs("BrassTube3",
1173                                          innerRadiusBrassTube3,
1174                                          outerRadiusBrassTube3,
1175                                          hightBrassTube3,
1176                                          startAngleBrassTube3,
1177                                          spanningAngleBrassTube3);
1178     
1179     G4LogicalVolume* logicBrassTube3 = new G4LogicalVolume(solidBrassTube3,
1180                                                            brassTube3Material,
1181                                                            "BrassTube3",
1182                                                            0, 0, 0);
1183     
1184     physiBrassTube3 = new G4PVPlacement(G4Transform3D(rm,
1185                                                       G4ThreeVector(brassTube3XPosition,
1186                                                                     0.,
1187                                                                     0.)),
1188                                         "BrassTube3",
1189                                         logicBrassTube3,
1190                                         physicalTreatmentRoom,
1191                                         false,
1192                                         0);
1193     
1194     logicBrassTube3 -> SetVisAttributes(darkOrange3);
1195 }
1196 
1197 /////////////////////////////////////////////////////////////////////////////
1198 void BESTPassiveProtonBeamLine::BESTBeamFinalCollimator()
1199 {
1200     // -----------------------//
1201     //     FINAL COLLIMATOR   //
1202     //------------------------//
1203     const G4double outerRadiusFinalCollimator = 21.5*mm;
1204     const G4double hightFinalCollimator = 4.5*mm;
1205     const G4double startAngleFinalCollimator = 0.*deg;
1206     const G4double spanningAngleFinalCollimator = 360.*deg;
1207     const G4double finalCollimatorXPosition = -82.5 *mm;
1208     
1209     G4double phi = 90. *deg;
1210     
1211     // Matrix definition for a 90 deg rotation. Also used for other volumes
1212     G4RotationMatrix rm;
1213     rm.rotateY(phi);
1214     
1215     solidFinalCollimator = new G4Tubs("FinalCollimator",
1216                                       BESTinnerRadiusFinalCollimator,
1217                                       outerRadiusFinalCollimator,
1218                                       hightFinalCollimator,
1219                                       startAngleFinalCollimator,
1220                                       spanningAngleFinalCollimator);
1221     
1222     G4LogicalVolume* logicFinalCollimator = new G4LogicalVolume(solidFinalCollimator,
1223                                                                 finalCollimatorMaterial,
1224                                                                 "FinalCollimator",
1225                                                                 0,
1226                                                                 0,
1227                                                                 0);
1228     
1229     physiFinalCollimator = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(finalCollimatorXPosition,0.,0.)),
1230                                              "FinalCollimator", logicFinalCollimator, physicalTreatmentRoom, false, 0);
1231     
1232     logicFinalCollimator -> SetVisAttributes(yellow);
1233 }
1234 /////////////////////////// MESSENGER ///////////////////////////////////////
1235 /////////////////////////////////////////////////////////////////////////////
1236 
1237 
1238 /////////////////////////////////////////////////////////////////////////////
1239 void BESTPassiveProtonBeamLine::SetRangeShifterXSize(G4double value)
1240 {
1241     solidBESTRangeShifterBox -> SetXHalfLength(value) ;
1242     G4cout << "RangeShifter size X (mm): "<< ((solidBESTRangeShifterBox -> GetXHalfLength())*2.)/mm
1243     << G4endl;
1244     G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1245 }
1246 
1247 /////////////////////////////////////////////////////////////////////////////
1248 void BESTPassiveProtonBeamLine::SetFirstScatteringFoilXSize(G4double value)
1249 {
1250     BESTfirstScatteringFoil -> SetXHalfLength(value);
1251     G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1252     G4cout <<"The X size of the first scattering foil is (mm):"<<
1253     ((BESTfirstScatteringFoil -> GetXHalfLength())*2.)/mm
1254     << G4endl;
1255 }
1256 
1257 /////////////////////////////////////////////////////////////////////////////
1258 void BESTPassiveProtonBeamLine::SetSecondScatteringFoilXSize(G4double value)
1259 {
1260     BESTsecondScatteringFoil -> SetXHalfLength(value);
1261     G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1262     G4cout <<"The X size of the second scattering foil is (mm):"<<
1263     ((BESTsecondScatteringFoil -> GetXHalfLength())*2.)/mm
1264     << G4endl;
1265 }
1266 
1267 /////////////////////////////////////////////////////////////////////////////
1268 void BESTPassiveProtonBeamLine::SetOuterRadiusStopper(G4double value)
1269 {
1270     solidBESTStopper -> SetOuterRadius(value);
1271     G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1272     G4cout << "OuterRadius od the Stopper is (mm):"
1273     << solidBESTStopper -> GetOuterRadius()/mm
1274     << G4endl;
1275 }
1276 
1277 /////////////////////////////////////////////////////////////////////////////
1278 void BESTPassiveProtonBeamLine::SetInnerRadiusFinalCollimator(G4double value)
1279 {
1280     solidFinalCollimator -> SetInnerRadius(value);
1281     G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1282     G4cout<<"Inner Radius of the final collimator is (mm):"
1283     << solidFinalCollimator -> GetInnerRadius()/mm
1284     << G4endl;
1285 }
1286 
1287 /////////////////////////////////////////////////////////////////////////////
1288 void BESTPassiveProtonBeamLine::SetRSMaterial(G4String materialChoice)
1289 {
1290     if (G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice, false) )
1291     {
1292         if (pttoMaterial)
1293         {
1294             rangeShifterMaterial  = pttoMaterial;
1295             logicBESTRangeShifterBox -> SetMaterial(pttoMaterial);
1296             G4cout << "The material of the Range Shifter has been changed to " << materialChoice << G4endl;
1297         }
1298     }
1299     else
1300     {
1301         G4cout << "WARNING: material \"" << materialChoice << "\" doesn't exist in NIST elements/materials"
1302         " table [located in $G4INSTALL/source/materials/src/G4NistMaterialBuilder.cc]" << G4endl;
1303         G4cout << "Use command \"/parameter/nist\" to see full materials list!" << G4endl;
1304     }
1305 }
1306 
1307 /////////////////////////////////////////////////////////////////////////////
1308 void BESTPassiveProtonBeamLine::SetModulatorAngle(G4double value)
1309 {
1310     modulator -> SetModulatorAngle(value);
1311     //G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1312 }
1313 /////////////////////////////////////////////////////////////////////////////