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 // Simulation of the "Zero degree" experimental beamline of INFN-LNS (Catania, Italy).
0029 
0030 #include "G4Box.hh"
0031 #include "G4Tubs.hh"
0032 #include "G4VisAttributes.hh"
0033 #include "G4Colour.hh"
0034 #include "globals.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 "PassiveCarbonBeamLine.hh"
0044 #include "G4SystemOfUnits.hh"
0045 #include "G4Trd.hh"
0046 #include "PassiveCarbonBeamLineMessenger.hh"
0047 #include "G4UnionSolid.hh"
0048 
0049 using namespace std;
0050 
0051 //G4bool PassiveCarbonBeamLine::doCalculation = false;
0052 /////////////////////////////////////////////////////////////////////////////
0053 PassiveCarbonBeamLine::PassiveCarbonBeamLine():
0054 physicalTreatmentRoom(0),hadrontherapyDetectorConstruction(0),
0055 physiBeamLineSupport(0), physiBeamLineCover(0), physiBeamLineCover2(0),
0056 physiKaptonWindow(0),PhysiRippleFilter(0),PhysiRippleFilterBase(0),PhysiRippleFilterTrd(0),
0057 physiFirstMonitorLayer1(0), physiFirstMonitorLayer2(0),
0058 physiFirstMonitorLayer3(0), physiFirstMonitorLayer4(0),
0059 physiNozzleSupport(0), physiHoleNozzleSupport(0)
0060 {
0061     
0062     // Messenger to change parameters of the passiveCarbonBeamLine geometry
0063     PassiveCarbonMessenger = new PassiveCarbonBeamLineMessenger(this);
0064     
0065     //***************************** PW ***************************************
0066     
0067     static G4String ROGeometryName = "DetectorROGeometry";
0068     RO = new HadrontherapyDetectorROGeometry(ROGeometryName);
0069     
0070     
0071     G4cout << "Going to register Parallel world...";
0072     RegisterParallelWorld(RO);
0073     G4cout << "... done" << G4endl;
0074     //***************************** PW ***************************************
0075 }
0076 
0077 /////////////////////////////////////////////////////////////////////////////
0078 PassiveCarbonBeamLine::~PassiveCarbonBeamLine()
0079 {
0080     delete hadrontherapyDetectorConstruction;
0081     delete PassiveCarbonMessenger;
0082 }
0083 
0084 /////////////////////////////////////////////////////////////////////////////
0085 G4VPhysicalVolume* PassiveCarbonBeamLine::Construct()
0086 {
0087     // Sets default geometry and materials
0088     SetDefaultDimensions();
0089     
0090     // Construct the whole CarbonPassive Beam Line
0091     ConstructPassiveCarbonBeamLine();
0092     
0093     
0094     //***************************** PW ***************************************
0095     if (!hadrontherapyDetectorConstruction)
0096         
0097         //***************************** PW ***************************************
0098         // HadrontherapyDetectorConstruction builds ONLY the phantom and the detector with its associated ROGeometry
0099         hadrontherapyDetectorConstruction = new HadrontherapyDetectorConstruction(physicalTreatmentRoom);
0100     
0101     //***************************** PW ***************************************
0102     
0103     hadrontherapyDetectorConstruction->InitializeDetectorROGeometry(RO,hadrontherapyDetectorConstruction->GetDetectorToWorldPosition());
0104     
0105     //***************************** PW ***************************************
0106     return physicalTreatmentRoom;
0107 }
0108 
0109 // In the following method the DEFAULTS used in the geometry of
0110 // passive beam line are provided
0111 // HERE THE USER CAN CHANGE THE GEOMETRY CHARACTERISTICS OF BEAM
0112 // LINE ELEMENTS, ALTERNATIVELY HE/SHE CAN USE THE MACRO FILE (IF A
0113 // MESSENGER IS PROVIDED)
0114 //
0115 // DEFAULT MATERIAL ARE ALSO PROVIDED
0116 // and COLOURS ARE ALSO DEFINED
0117 // ----------------------------------------------------------
0118 /////////////////////////////////////////////////////////////////////////////
0119 void PassiveCarbonBeamLine::SetDefaultDimensions()
0120 {
0121     // Set of coulors that can be used
0122     white = new G4VisAttributes( G4Colour());
0123     white -> SetVisibility(true);
0124     white -> SetForceSolid(true);
0125     
0126     black = new G4VisAttributes( G4Colour(1., 1., 1.));
0127     black -> SetVisibility(true);
0128     black -> SetForceSolid(true);
0129     
0130     
0131     blue = new G4VisAttributes(G4Colour(0. ,0. ,1.));
0132     blue -> SetVisibility(true);
0133     blue -> SetForceSolid(true);
0134     
0135     gray = new G4VisAttributes( G4Colour(0.5, 0.5, 0.5 ));
0136     gray-> SetVisibility(true);
0137     gray-> SetForceSolid(true);
0138     
0139     red = new G4VisAttributes(G4Colour(1. ,0. ,0.));
0140     red-> SetVisibility(true);
0141     red-> SetForceSolid(true);
0142     
0143     yellow = new G4VisAttributes(G4Colour(1., 1., 0. ));
0144     yellow-> SetVisibility(true);
0145     yellow-> SetForceSolid(true);
0146     
0147     green = new G4VisAttributes( G4Colour(25/255. , 255/255. ,  25/255. ));
0148     green -> SetVisibility(true);
0149     green -> SetForceSolid(true);
0150     
0151     darkGreen = new G4VisAttributes( G4Colour(0/255. , 100/255. ,  0/255. ));
0152     darkGreen -> SetVisibility(true);
0153     darkGreen -> SetForceSolid(true);
0154     
0155     darkOrange3 = new G4VisAttributes( G4Colour(205/255. , 102/255. ,  000/255. ));
0156     darkOrange3 -> SetVisibility(true);
0157     darkOrange3 -> SetForceSolid(true);
0158     
0159     skyBlue = new G4VisAttributes( G4Colour(135/255. , 206/255. ,  235/255. ));
0160     skyBlue -> SetVisibility(true);
0161     skyBlue -> SetForceSolid(true);
0162     
0163     
0164     // FINAL COLLIMATOR: is the collimator giving the final transversal shape
0165     // of the beam
0166     
0167     G4double defaultinnerRadiusFinalCollimator = 12.5 *mm;
0168     innerRadiusFinalCollimator = defaultinnerRadiusFinalCollimator;
0169     
0170     // DEFAULT DEFINITION OF THE MATERIALS
0171     // All elements and compound definition follows the NIST database
0172     
0173     // ELEMENTS
0174     G4bool isotopes = false;
0175     aluminumNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Al", isotopes);
0176     G4Element* zincNist = G4NistManager::Instance()->FindOrBuildElement("Zn");
0177     G4Element* copperNist = G4NistManager::Instance()->FindOrBuildElement("Cu");
0178     
0179     // MATERIAL (Including compounds)
0180     copperNistMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Cu", isotopes);
0181     airNist =  G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes);
0182     kaptonNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON", isotopes);
0183     galacticNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic", isotopes);
0184     PMMANist = G4NistManager::Instance()->FindOrBuildMaterial("G4_PLEXIGLASS", isotopes);
0185     tantalumNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_Ta", isotopes);
0186     
0187     G4double d; // Density
0188     G4int nComponents;// Number of components
0189     G4double fractionmass; // Fraction in mass of an element in a material
0190     
0191     d = 8.40*g/cm3;
0192     nComponents = 2;
0193     brass = new G4Material("Brass", d, nComponents);
0194     brass -> AddElement(zincNist, fractionmass = 30 *perCent);
0195     brass -> AddElement(copperNist, fractionmass = 70 *perCent);
0196     
0197     //***************************** PW ***************************************
0198     
0199     // DetectorROGeometry Material
0200     new G4Material("dummyMat", 1., 1.*g/mole, 1.*g/cm3);
0201     
0202     //***************************** PW ***************************************
0203     
0204     // MATERIAL ASSIGNMENT
0205     // Support of the beam line
0206     beamLineSupportMaterial = aluminumNist;
0207     
0208     // Vacuum pipe
0209     vacuumZoneMaterial = galacticNist;
0210     firstScatteringFoilMaterial = tantalumNist;
0211     
0212     // Material of kapton window
0213     kaptonWindowMaterial = kaptonNist;
0214     
0215     // Material of ripple filter
0216     rippleFilterMaterial = PMMANist;
0217     rippleFilterBoxMaterial = airNist;
0218     
0219     // Materials of the monitor chamber
0220     layer1MonitorChamberMaterial = kaptonNist;
0221     layer2MonitorChamberMaterial = copperNistMaterial;
0222     layer3MonitorChamberMaterial = airNist;
0223     layer4MonitorChamberMaterial = copperNistMaterial;
0224     
0225     // Material of the final nozzle
0226     nozzleSupportMaterial = PMMANist;
0227     holeNozzleSupportMaterial = airNist;
0228     seconHoleNozzleSupportMaterial = airNist;
0229     
0230     // Material of the final collimator
0231     brassTubeMaterial = brassTube2Material = brassTube3Material = brass;
0232     
0233     // Material of the final collimator
0234     finalCollimatorMaterial = brass;
0235     
0236     // Material of the PMMA collimator
0237     PMMACollimatorMaterial = airNist;
0238     
0239     
0240     G4Element* hydrogenNist = G4NistManager::Instance()->FindOrBuildElement("H");
0241     G4Element* oxygenNist = G4NistManager::Instance()->FindOrBuildElement("O");
0242     G4Element* carbonNist = G4NistManager::Instance()->FindOrBuildElement("C");
0243     
0244     G4Material* plastic = new G4Material("Plastic", 1.18*g/cm3, nComponents=3);
0245     plastic -> AddElement(carbonNist, 21);
0246     plastic -> AddElement(oxygenNist, 4);
0247     plastic -> AddElement(hydrogenNist, 24);
0248     PMMANist = plastic;
0249     
0250     
0251     
0252 }
0253 
0254 /////////////////////////////////////////////////////////////////////////////
0255 void PassiveCarbonBeamLine::ConstructPassiveCarbonBeamLine()
0256 {
0257     // -----------------------------
0258     // Treatment room - World volume
0259     //------------------------------
0260     // Treatment room sizes
0261     
0262     const G4double worldX = 400.0 *cm;
0263     const G4double worldY = 400.0 *cm;
0264     const G4double worldZ = 400.0 *cm;
0265     G4bool isotopes = false;
0266     
0267     airNist =  G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes);
0268     treatmentRoom = new G4Box("TreatmentRoom",worldX,worldY,worldZ);
0269     logicTreatmentRoom = new G4LogicalVolume(treatmentRoom,
0270                                              airNist,
0271                                              "logicTreatmentRoom",
0272                                              0,0,0);
0273     physicalTreatmentRoom = new G4PVPlacement(0,
0274                                               G4ThreeVector(),
0275                                               "physicalTreatmentRoom",
0276                                               logicTreatmentRoom,
0277                                               0,false,0);
0278     
0279     
0280     // The treatment room is invisible in the Visualisation
0281     logicTreatmentRoom -> SetVisAttributes (G4VisAttributes::GetInvisible());
0282     
0283     // Components of the Passive Carbon Beam Line
0284     HadrontherapyBeamLineSupport();
0285     VacuumToAirInterface();
0286     HadrontherapyBeamMonitoring();
0287     HadrontherapyBeamNozzle();
0288     HadrontherapyBeamFinalCollimator();
0289     HadrontherapyPMMACollimator();
0290    // HadrontherapyRippleFilter();
0291     
0292     
0293    // StopperCostruction();
0294     
0295     
0296    HadrontherapyRidgeFilter();
0297 }
0298 
0299 /////////////////////////////////////////////////////////////////////////////
0300 void PassiveCarbonBeamLine::HadrontherapyBeamLineSupport()
0301 {
0302     // ------------------//
0303     // BEAM LINE SUPPORT //
0304     //-------------------//
0305     
0306     beamLineSupportXSize = 1.5*m;
0307     beamLineSupportYSize = 20.*mm;
0308     beamLineSupportZSize = 600.*mm;
0309     
0310     beamLineSupportXPosition = -1745.09 *mm;
0311     beamLineSupportYPosition = -230. *mm;
0312     beamLineSupportZPosition = 0.*mm;
0313     
0314     beamLineSupport = new G4Box("BeamLineSupport",
0315                                 beamLineSupportXSize,
0316                                 beamLineSupportYSize,
0317                                 beamLineSupportZSize);
0318     
0319     logicBeamLineSupport = new G4LogicalVolume(beamLineSupport,
0320                                                beamLineSupportMaterial,
0321                                                "BeamLineSupport");
0322     physiBeamLineSupport = new G4PVPlacement(0, G4ThreeVector(beamLineSupportXPosition,
0323                                                               beamLineSupportYPosition,
0324                                                               beamLineSupportZPosition),
0325                                              "BeamLineSupport",
0326                                              logicBeamLineSupport,
0327                                              physicalTreatmentRoom, false, 0);
0328     
0329     // Visualisation attributes of the beam line support
0330     logicBeamLineSupport -> SetVisAttributes(gray);
0331     
0332     //---------------------------------//
0333     //  Beam line cover 1 (left panel) //
0334     //---------------------------------//
0335     beamLineCoverXSize = 1.5*m;
0336     beamLineCoverYSize = 750.*mm;
0337     beamLineCoverZSize = 10.*mm;
0338     
0339     beamLineCoverXPosition = -1745.09 *mm;
0340     beamLineCoverYPosition = -1000.*mm;
0341     beamLineCoverZPosition = 610.*mm;
0342     
0343     beamLineCover = new G4Box("BeamLineCover",
0344                               beamLineCoverXSize,
0345                               beamLineCoverYSize,
0346                               beamLineCoverZSize);
0347     
0348     logicBeamLineCover = new G4LogicalVolume(beamLineCover,
0349                                              beamLineSupportMaterial,
0350                                              "BeamLineCover");
0351     
0352     physiBeamLineCover = new G4PVPlacement(0, G4ThreeVector(beamLineCoverXPosition,
0353                                                             beamLineCoverYPosition,
0354                                                             beamLineCoverZPosition),
0355                                            "BeamLineCover",
0356                                            logicBeamLineCover,
0357                                            physicalTreatmentRoom,
0358                                            false,
0359                                            0);
0360     
0361     // ---------------------------------//
0362     //  Beam line cover 2 (rigth panel) //
0363     // ---------------------------------//
0364     // It has the same characteristic of beam line cover 1 but set in a different position
0365     physiBeamLineCover2 = new G4PVPlacement(0, G4ThreeVector(beamLineCoverXPosition,
0366                                                              beamLineCoverYPosition,
0367                                                              - beamLineCoverZPosition),
0368                                             "BeamLineCover2",
0369                                             logicBeamLineCover,
0370                                             physicalTreatmentRoom,
0371                                             false,
0372                                             0);
0373     
0374     
0375     logicBeamLineCover -> SetVisAttributes(blue);
0376 }
0377 
0378 /////////////////////////////////////////////////////////////////////////////
0379 void PassiveCarbonBeamLine::VacuumToAirInterface()
0380 {
0381     // ------------//
0382     // VACUUM PIPE //
0383     //-------------//
0384     //
0385     // First track of the beam line is inside vacuum;
0386     
0387     vacuumZoneXSize = 100 *mm;
0388     vacuumZoneYSize = 52.5 *mm;
0389     vacuumZoneZSize = 52.5 *mm;
0390     vacuumPipeXPosition = -1708.0 *mm;
0391     
0392     
0393     vacuumZone = new G4Box("VacuumZone",
0394                            vacuumZoneXSize/2,
0395                            vacuumZoneYSize/2,
0396                            vacuumZoneZSize/2);
0397     
0398     logicVacuumZone = new G4LogicalVolume(vacuumZone, vacuumZoneMaterial,"VacuumZone");
0399     
0400     physiVacuumZone = new G4PVPlacement(0, G4ThreeVector(vacuumPipeXPosition, 0., 0.),
0401                                         "VacuumZone",
0402                                         logicVacuumZone,
0403                                         physicalTreatmentRoom,
0404                                         false,
0405                                         0);
0406     
0407     // --------------------------//
0408     // THE FIRST SCATTERING FOIL //
0409     // --------------------------//
0410     // A thin foil performing a first scattering
0411     // of the original beam
0412     
0413     firstScatteringFoilXSize = 0.015 *mm;
0414     firstScatteringFoilYSize = 52.5 *mm;
0415     firstScatteringFoilZSize = 52.5 *mm;
0416     firstScatteringFoilXPosition = 0.0 *mm;
0417     
0418     firstScatteringFoil = new G4Box("FirstScatteringFoil",
0419                                     firstScatteringFoilXSize/2,
0420                                     firstScatteringFoilYSize/2,
0421                                     firstScatteringFoilZSize/2);
0422     
0423     logicFirstScatteringFoil = new G4LogicalVolume(firstScatteringFoil,
0424                                                    firstScatteringFoilMaterial,
0425                                                    "FirstScatteringFoil");
0426     
0427     physiFirstScatteringFoil = new G4PVPlacement(0, G4ThreeVector(firstScatteringFoilXPosition, 0.,0.),
0428                                                  "FirstScatteringFoil", logicFirstScatteringFoil, physiVacuumZone,
0429                                                  false, 0);
0430     
0431     logicFirstScatteringFoil -> SetVisAttributes(skyBlue);
0432     
0433     // -------------------//
0434     // THE KAPTON WINDOWS //
0435     //--------------------//
0436     //It permits the passage of the beam from vacuum to air
0437     
0438     // KAPTON WINDOW: it permits the passage of the beam from vacuum to air
0439     kaptonWindowXSize = 0.050 *mm;
0440     kaptonWindowYSize = 52.5 *mm;
0441     kaptonWindowZSize = 52.5 *mm;
0442     kaptonWindowXPosition = vacuumZoneXSize/2 - kaptonWindowXSize/2;
0443     
0444     solidKaptonWindow = new G4Box("KaptonWindow",
0445                                   kaptonWindowXSize/2,
0446                                   kaptonWindowYSize/2,
0447                                   kaptonWindowZSize/2);
0448     
0449     logicKaptonWindow = new G4LogicalVolume(solidKaptonWindow,
0450                                             kaptonWindowMaterial,
0451                                             "KaptonWindow");
0452     
0453     physiKaptonWindow = new G4PVPlacement(0, G4ThreeVector(kaptonWindowXPosition, 0., 0.),
0454                                           "KaptonWindow", logicKaptonWindow,
0455                                           physiVacuumZone, false,    0);
0456     
0457     logicKaptonWindow -> SetVisAttributes(darkOrange3);
0458 }
0459 /////////////////////////////////////////////////////////////////////////////
0460 void PassiveCarbonBeamLine::HadrontherapyRippleFilter()
0461 {
0462     
0463     G4double defaultRippleFilterXPosition = -1638.0*mm;
0464     G4double ripple_position=(defaultRippleFilterXPosition);
0465     G4double RF_x = 200.0 * mm;
0466     G4double RF_y = 200.0 * mm;
0467     G4double RF_z = 1.4 * mm;
0468     G4double RFbase_z = 0.2 * mm;
0469     G4double RFtrd_z = RF_z - RFbase_z;
0470     G4double RFtrd_top = 1e-4 * mm;
0471     G4double RFtrd_bottom = 1.5 * mm;
0472     G4double distanceBetweenTrd = 0.1*mm;
0473     
0474     
0475     
0476     
0477     G4double theta = -90. *deg;
0478     // Matrix definition for a "theta" deg rotation with respect to Y axis
0479     G4RotationMatrix rot;
0480     rot.rotateY(theta);
0481     
0482     
0483     SolidRippleFilter= new G4Box("RippleFilter",
0484                                  RF_x/2 + 1*mm,
0485                                  RF_y/2 + 1*mm,
0486                                  RF_z/2 + 1*mm);
0487     
0488     LogicRippleFilter = new G4LogicalVolume(SolidRippleFilter,
0489                                             rippleFilterBoxMaterial,
0490                                             "LogicRippleFilter",
0491                                             0,0,0);
0492     
0493     PhysiRippleFilter = new G4PVPlacement(G4Transform3D(rot,G4ThreeVector(ripple_position,0,0)),
0494                                           "PhysiRippleFilter",
0495                                           LogicRippleFilter,
0496                                           physicalTreatmentRoom,
0497                                           false,
0498                                           1,
0499                                           true);
0500     
0501     PhysiRippleFilter = new G4PVPlacement(G4Transform3D(rot,G4ThreeVector(ripple_position + 10*cm,0,0)),
0502                                           "PhysiRippleFilter",
0503                                           LogicRippleFilter,
0504                                           physicalTreatmentRoom,
0505                                           false,
0506                                           2,
0507                                           true);
0508     
0509     LogicRippleFilter -> SetVisAttributes(G4VisAttributes::GetInvisible());
0510     
0511     SolidRippleFilterBase = new G4Box("RippleFilterBase",
0512                                       RF_x/2,
0513                                       RF_y/2,
0514                                       RFbase_z/2);
0515     
0516     LogicRippleFilterBase = new G4LogicalVolume(SolidRippleFilterBase,
0517                                                 rippleFilterMaterial,
0518                                                 "LogicRippleFilterBase",
0519                                                 0,0,0);
0520     
0521     LogicRippleFilterBase -> SetVisAttributes(green);
0522     
0523     PhysiRippleFilterBase = new G4PVPlacement(0,
0524                                               G4ThreeVector(0, 0, -RF_z/2 + RFbase_z/2),
0525                                               "PhysiRippleFilter",
0526                                               LogicRippleFilterBase,
0527                                               PhysiRippleFilter,
0528                                               false,
0529                                               0,
0530                                               false);
0531     
0532     SolidRippleFilterTrd = new G4Trd("SolidRippleFilterTrd",
0533                                      RF_x/2,
0534                                      RF_x/2,
0535                                      RFtrd_bottom/2,
0536                                      RFtrd_top/2,
0537                                      RFtrd_z/2);
0538     
0539     LogicRippleFilterTrd = new G4LogicalVolume(SolidRippleFilterTrd,
0540                                                rippleFilterMaterial,
0541                                                "LogicRippleFilterTrd",
0542                                                0,0,0);
0543     
0544     LogicRippleFilterTrd -> SetVisAttributes(green);
0545     
0546     G4int numberOfTrd = static_cast<int>(std::floor( RF_y / (RFtrd_bottom+distanceBetweenTrd) ));
0547     
0548     G4int N = static_cast<int>( std::floor(numberOfTrd-1)/2 );
0549     
0550     G4int copyNumber = 0;
0551     
0552     for( int i = -N; i <= N; i++ )
0553     {
0554         PhysiRippleFilterTrd = new G4PVPlacement(0,
0555                                                  G4ThreeVector(0,
0556                                                                i*(RFtrd_bottom+distanceBetweenTrd),
0557                                                                -RF_z/2+RFbase_z+RFtrd_z/2),
0558                                                  "PhysiRippleFilterTrd",
0559                                                  LogicRippleFilterTrd,
0560                                                  PhysiRippleFilter,
0561                                                  false,
0562                                                  copyNumber,
0563                                                  false);
0564         
0565         copyNumber++;
0566     }
0567     
0568 }
0569 /////////////////////////////////////////////////////////////////////////////
0570 
0571 void PassiveCarbonBeamLine::StopperCostruction(){
0572     
0573     supportFoil= new G4Box("supportFoil",25/2*um,10*cm,10*cm);
0574     LogicSupportFoil = new G4LogicalVolume(supportFoil,tantalumNist,"logicSupportFoil");
0575     PhysiSupportFoil = new G4PVPlacement(0,G4ThreeVector(-1398.*mm+25/2*um,0.*mm,0.*mm),"logicSupportFoil",LogicSupportFoil,physicalTreatmentRoom,false,0 );
0576     LogicSupportFoil -> SetVisAttributes(skyBlue);
0577     
0578     
0579     
0580     stopper = new G4Tubs("Stopper",0*mm,3*mm,3.5*mm,0.*deg,360.*deg);
0581     LogicStopper= new G4LogicalVolume(stopper,brass,"logicalStopper");
0582     
0583     G4double ti = -270. *deg;
0584     G4RotationMatrix rt;
0585     rt.rotateY(ti);
0586     
0587     PhysicStopper= new G4PVPlacement(G4Transform3D(rt,G4ThreeVector(-1398.*mm-3.5*mm,0*mm,0*mm)),"logicalStopper",LogicStopper,physicalTreatmentRoom,false,0);
0588     
0589     LogicStopper -> SetVisAttributes(red);
0590     
0591     
0592 }
0593 
0594 void PassiveCarbonBeamLine::HadrontherapyRidgeFilter(){
0595     
0596    
0597     G4double defaultRidgeXPosition= -1270.0*mm; 
0598     const G4double XBase = 0.5 *mm;
0599     const G4double YBase =6.03*cm;
0600     const G4double ZBase =6.03*cm;
0601     
0602     
0603     
0604     SolidRidgeBase = new G4Box("BaseRidgeFilter",
0605                                XBase,
0606                                YBase/2,
0607                                ZBase/2);
0608     
0609     LogicRidgeBase = new G4LogicalVolume(SolidRidgeBase,
0610                                          PMMANist,
0611                                          "BaseRidgeFilter");
0612     
0613     PhysiRidgeFilterBase = new G4PVPlacement(0,
0614                                              G4ThreeVector(
0615                                                            -1270*mm, 
0616                                                            0.,
0617                                                            0.),
0618                                              "BaseRidgeFilter",
0619                                              LogicRidgeBase,
0620                                              physicalTreatmentRoom,
0621                                              false,
0622                                              0);
0623     
0624     LogicRidgeBase->SetVisAttributes(red);
0625     
0626     
0627     SolidRidgeMother = new G4Box("MotherRidgeSOL",1.7*mm/2,1.7*mm/2,4.72*mm/2);
0628     LogicRidgeMother = new G4LogicalVolume(SolidRidgeMother,airNist,"MotherRidge");
0629     
0630     G4Trd* trapp1=new G4Trd("Trapp1SOL",1.7*mm/2,1.68*mm/2,1.7*mm/2,1.68*mm/2,0.22*mm/2);
0631     G4LogicalVolume* LogicTrapp1=new G4LogicalVolume(trapp1,PMMANist,"Trapp1");
0632  PhysiTrapp1=new G4PVPlacement(0,G4ThreeVector(0.,0.,(-4.72/2+0.22/2)*mm),LogicTrapp1,"Trapp1",LogicRidgeMother,false,0);
0633     
0634     G4Trd* trapp2=new G4Trd("Trapp2SOL",1.68*mm/2,1.64*mm/2,1.68*mm/2,1.64*mm/2,0.08*mm/2);
0635     G4LogicalVolume* LogicTrapp2=new G4LogicalVolume(trapp2,PMMANist,"Trapp2");
0636   PhysiTrapp2=new G4PVPlacement(0,G4ThreeVector(0.,0.,(-4.72/2+0.22+0.08/2)*mm),LogicTrapp2,"Trapp2",LogicRidgeMother,false,0);
0637     
0638     G4Trd* trapp3=new G4Trd("Trapp3SOL",1.64*mm/2,1.58*mm/2,1.64*mm/2,1.58*mm/2,0.14*mm/2);
0639     G4LogicalVolume* LogicTrapp3=new G4LogicalVolume(trapp3,PMMANist,"Trapp3");
0640  PhysiTrapp3=new G4PVPlacement(0,G4ThreeVector(0.,0.,(-4.72/2+0.22+0.08+0.14/2)*mm),LogicTrapp3,"Trapp3",LogicRidgeMother,false,0);
0641     
0642     G4Trd* trapp4=new G4Trd("Trapp4SOL",1.58*mm/2,1.50*mm/2,1.58*mm/2,1.50*mm/2,0.22*mm/2);
0643     G4LogicalVolume* LogicTrapp4=new G4LogicalVolume(trapp4,PMMANist,"Trapp4");
0644     PhysiTrapp4=new G4PVPlacement(0,G4ThreeVector(0.,0.,(-4.72/2+0.22+0.08+0.14+0.22/2)*mm),LogicTrapp4,"Trapp4",LogicRidgeMother,false,0);
0645     
0646     G4Trd* trapp5=new G4Trd("Trapp5SOL",1.50*mm/2,1.40*mm/2,1.50*mm/2,1.40*mm/2,0.31*mm/2);
0647     G4LogicalVolume* LogicTrapp5=new G4LogicalVolume(trapp5,PMMANist,"Trapp5");
0648    PhysiTrapp5=new G4PVPlacement(0,G4ThreeVector(0.,0.,(-4.72/2+0.22+0.08+0.14+0.22+0.31/2)*mm),LogicTrapp5,"Trapp5",LogicRidgeMother,false,0);
0649     
0650     G4Trd* trapp6=new G4Trd("Trapp6SOL",1.40*mm/2,1.26*mm/2,1.40*mm/2,1.26*mm/2,0.48*mm/2);
0651     G4LogicalVolume* LogicTrapp6=new G4LogicalVolume(trapp6,PMMANist,"Trapp6");
0652    PhysiTrapp6=new G4PVPlacement(0,G4ThreeVector(0.,0.,(-4.72/2+0.22+0.08+0.14+0.22+0.31+0.48/2)*mm),LogicTrapp6,"Trapp6",LogicRidgeMother,false,0);
0653     
0654     G4Trd* trapp7=new G4Trd("Trapp7SOL",1.26*mm/2,0.94*mm/2,1.26*mm/2,0.94*mm/2,1.20*mm/2);
0655     G4LogicalVolume* LogicTrapp7=new G4LogicalVolume(trapp7,PMMANist,"Trapp7");
0656 PhysiTrapp7=new G4PVPlacement(0,G4ThreeVector(0.,0.,(-4.72/2+0.22+0.08+0.14+0.22+0.31+0.48+1.20/2)*mm),LogicTrapp7,"Trapp7",LogicRidgeMother,false,0);
0657     
0658     G4Trd* trapp8=new G4Trd("Trapp8SOL",0.94*mm/2,0.78*mm/2,0.94*mm/2,0.78*mm/2,0.57*mm/2);
0659     G4LogicalVolume* LogicTrapp8=new G4LogicalVolume(trapp8,PMMANist,"Trapp8");
0660     PhysiTrapp8=new G4PVPlacement(0,G4ThreeVector(0.,0.,(-4.72/2+0.22+0.08+0.14+0.22+0.31+0.48+1.20+0.57/2)*mm),LogicTrapp8,"Trapp8",LogicRidgeMother,false,0);
0661     
0662     G4Trd* trapp9=new G4Trd("Trapp9SOL",0.78*mm/2,0.66*mm/2,0.78*mm/2,0.66*mm/2,0.39*mm/2);
0663     G4LogicalVolume* LogicTrapp9=new G4LogicalVolume(trapp9,PMMANist,"Trapp9");
0664   PhysiTrapp9=new G4PVPlacement(0,G4ThreeVector(0.,0.,(-4.72/2+0.22+0.08+0.14+0.22+0.31+0.48+1.20+0.57+0.39/2)*mm),LogicTrapp9,"Trapp9",LogicRidgeMother,false,0);
0665     
0666     G4Trd* trapp10=new G4Trd("Trapp10SOL",0.66*mm/2,0.56*mm/2,0.66*mm/2,0.56*mm/2,0.29*mm/2);
0667     G4LogicalVolume* LogicTrapp10=new G4LogicalVolume(trapp10,PMMANist,"Trapp10");
0668  PhysiTrapp10=new G4PVPlacement(0,G4ThreeVector(0.,0.,(-4.72/2+0.22+0.08+0.14+0.22+0.31+0.48+1.20+0.57+0.39+0.29/2)*mm),LogicTrapp10,"Trapp10",LogicRidgeMother,false,0);
0669     
0670     G4Trd* trapp11=new G4Trd("Trapp11SOL",0.56*mm/2,0.46*mm/2,0.56*mm/2,0.46*mm/2,0.25*mm/2);
0671     G4LogicalVolume* LogicTrapp11=new G4LogicalVolume(trapp11,PMMANist,"Trapp11");
0672 PhysiTrapp11=new G4PVPlacement(0,G4ThreeVector(0.,0.,(-4.72/2+0.22+0.08+0.14+0.22+0.31+0.48+1.20+0.57+0.39+0.29+0.25/2)*mm),LogicTrapp11,"Trapp11",LogicRidgeMother,false,0);
0673     
0674     G4Trd* trapp12=new G4Trd("Trapp12SOL",0.46*mm/2,0.38*mm/2,0.46*mm/2,0.38*mm/2,0.17*mm/2);
0675     G4LogicalVolume* LogicTrapp12=new G4LogicalVolume(trapp12,PMMANist,"Trapp12");
0676    PhysiTrapp12=new G4PVPlacement(0,G4ThreeVector(0.,0.,(-4.72/2+0.22+0.08+0.14+0.22+0.31+0.48+1.20+0.57+0.39+0.29+0.25+0.17/2)*mm),LogicTrapp12,"Trapp12",LogicRidgeMother,false,0);
0677     
0678     G4Trd* trapp13=new G4Trd("Trapp13SOL",0.38*mm/2,0.30*mm/2,0.38*mm/2,0.30*mm/2,0.14*mm/2);
0679     G4LogicalVolume* LogicTrapp13=new G4LogicalVolume(trapp13,PMMANist,"Trapp13");
0680    PhysiTrapp13=new G4PVPlacement(0,G4ThreeVector(0.,0.,(-4.72/2+0.22+0.08+0.14+0.22+0.31+0.48+1.20+0.57+0.39+0.29+0.25+0.17+0.14/2)*mm),LogicTrapp13,"Trapp13",LogicRidgeMother,false,0);
0681     
0682     G4Trd* trapp14=new G4Trd("Trapp14SOL",0.30*mm/2,0.24*mm/2,0.30*mm/2,0.24*mm/2,0.09*mm/2);
0683     G4LogicalVolume* LogicTrapp14=new G4LogicalVolume(trapp14,PMMANist,"Trapp13");
0684 PhysiTrapp14=new G4PVPlacement(0,G4ThreeVector(0.,0.,(-4.72/2+0.22+0.08+0.14+0.22+0.31+0.48+1.20+0.57+0.39+0.29+0.25+0.17+0.14+0.09/2)*mm),LogicTrapp14,"Trapp14",LogicRidgeMother,false,0);
0685     
0686     G4Trd* trapp15=new G4Trd("Trapp14SOL",0.24*mm/2,0.18*mm/2,0.24*mm/2,0.18*mm/2,0.07*mm/2);
0687     G4LogicalVolume* LogicTrapp15=new G4LogicalVolume(trapp15,PMMANist,"Trapp15");
0688     PhysiTrapp15=new G4PVPlacement(0,G4ThreeVector(0.,0.,(-4.72/2+0.22+0.08+0.14+0.22+0.31+0.48+1.20+0.57+0.39+0.29+0.25+0.17+0.14+0.09+0.07/2)*mm),LogicTrapp15,"Trapp15",LogicRidgeMother,false,0);
0689     
0690     G4Trd* trapp16=new G4Trd("Trapp16SOL",0.18*mm/2,0.12*mm/2,0.18*mm/2,0.12*mm/2,0.10*mm/2);
0691     G4LogicalVolume* LogicTrapp16=new G4LogicalVolume(trapp16,PMMANist,"Trapp16");
0692   PhysiTrapp16=new G4PVPlacement(0,G4ThreeVector(0.,0.,(-4.72/2+0.22+0.08+0.14+0.22+0.31+0.48+1.20+0.57+0.39+0.29+0.25+0.17+0.14+0.09+0.07+0.10/2)*mm),LogicTrapp16,"Trapp16",LogicRidgeMother,false,0);
0693     
0694     LogicTrapp1->SetVisAttributes(green);
0695     LogicTrapp2->SetVisAttributes(green);
0696     LogicTrapp3->SetVisAttributes(green);
0697     LogicTrapp4->SetVisAttributes(green);
0698     LogicTrapp5->SetVisAttributes(green);
0699     LogicTrapp6->SetVisAttributes(green);
0700     LogicTrapp7->SetVisAttributes(green);
0701     LogicTrapp8->SetVisAttributes(green);
0702     LogicTrapp9->SetVisAttributes(green);
0703     LogicTrapp10->SetVisAttributes(green);
0704     LogicTrapp11->SetVisAttributes(green);
0705     LogicTrapp12->SetVisAttributes(green);
0706     LogicTrapp13->SetVisAttributes(green);
0707     LogicTrapp14->SetVisAttributes(green);
0708     LogicTrapp15->SetVisAttributes(green);
0709     LogicTrapp16->SetVisAttributes(green);
0710     G4VisAttributes* visAttr = new G4VisAttributes();
0711     visAttr->SetVisibility(false);
0712     LogicRidgeMother->SetVisAttributes(visAttr);
0713     
0714     
0715     
0716     
0717     
0718     
0719     G4int numberOfLayers = 30;
0720     G4double minZ = 30.15*mm-0.3*mm-1.70/2*mm;
0721     G4double minY = 30.15*mm-0.3*mm-1.70/2*mm;
0722     G4double sum_space = 0.3*mm+1.70*mm;
0723     
0724     
0725     std::vector<G4ThreeVector> singleTrapPositions;
0726     
0727     for (int i = 0; i < numberOfLayers; i++)
0728     {
0729         for (int j = 0; j < numberOfLayers; j++)
0730         {
0731             singleTrapPositions.push_back({defaultRidgeXPosition-4.72/2*mm-0.5*mm,
0732                 minY - i*sum_space,
0733                 minZ - j*sum_space,
0734                 
0735             });
0736         }
0737     }
0738     
0739     G4double ti = -  90. *deg;
0740     G4RotationMatrix rt;
0741     rt.rotateY(ti);
0742     
0743     
0744     G4int peaks = numberOfLayers*numberOfLayers;
0745     for (int i = 0; i < peaks; i++)
0746     {
0747         
0748         std::ostringstream tName;tName << "singleTrap" << i;
0749         new G4PVPlacement(G4Transform3D(rt,
0750                                         singleTrapPositions[i]),
0751                           LogicRidgeMother,
0752                           "tName.str()",
0753                           logicTreatmentRoom,
0754                           0,
0755                           i);
0756         
0757     }
0758     
0759 }
0760 
0761 
0762 
0763 
0764 
0765 
0766 /////////////////////////////////////////////////////////////////////////////
0767 void PassiveCarbonBeamLine::HadrontherapyPMMACollimator()
0768 {
0769     
0770     // ----------------------//
0771     //   PMMA COLLIMATOR     //
0772     // ----------------------//
0773     PMMACollimatorSupportXSize = 25.0 *mm;
0774     PMMACollimatorSupportYSize = 200. *mm;
0775     PMMACollimatorSupportZSize = 200. *mm;
0776     
0777     
0778     PMMACollimatorXPosition = -1257.0 *mm; 
0779     
0780     G4double phi = 90. *deg;
0781     G4RotationMatrix rm;
0782     rm.rotateY(phi);
0783     
0784     solidPMMACollimatorSupport = new G4Box("PMMACollimatorSupport",
0785                                            PMMACollimatorSupportXSize/2,
0786                                            PMMACollimatorSupportYSize/2,
0787                                            PMMACollimatorSupportZSize/2);
0788     
0789     logicPMMACollimatorSupport = new G4LogicalVolume(solidPMMACollimatorSupport,
0790                                                      PMMACollimatorMaterial,
0791                                                      "PMMACollimatorSupport");
0792     
0793     physiPMMACollimatorSupport = new G4PVPlacement(0, G4ThreeVector(PMMACollimatorXPosition,0., 0.),
0794                                                    "PMMACollimatorSupport",
0795                                                    logicPMMACollimatorSupport,
0796                                                    physicalTreatmentRoom,
0797                                                    false,
0798                                                    0);
0799     
0800     
0801     yellow = new G4VisAttributes(G4Colour(1., 1., 0. ));
0802     yellow-> SetVisibility(true);
0803     yellow-> SetForceWireframe(true);
0804     
0805     logicPMMACollimatorSupport -> SetVisAttributes(yellow);
0806     
0807     // ----------------------//
0808     //     PMMA COLLIMATOR   //
0809     //-----------------------//
0810     innerRadiusPMMACollimator= 4.5 *cm;
0811     outerRadiusPMMACollimator = 4.6 *cm;
0812     hightPMMACollimator = PMMACollimatorSupportXSize;
0813     startAnglePMMACollimator = 0.*deg;
0814     spanningAnglePMMACollimator = 360.*deg;
0815     
0816     
0817     solidPMMACollimator = new G4Tubs("PMMACollimator",
0818                                      innerRadiusPMMACollimator,
0819                                      outerRadiusPMMACollimator,
0820                                      hightPMMACollimator/2,
0821                                      startAnglePMMACollimator,
0822                                      spanningAnglePMMACollimator);
0823     
0824     logicPMMACollimator = new G4LogicalVolume(solidPMMACollimator,
0825                                               PMMACollimatorMaterial,
0826                                               "PMMACollimator",
0827                                               0,
0828                                               0,
0829                                               0);
0830     
0831     physiPMMACollimator = new G4PVPlacement(G4Transform3D(rm,
0832                                                           G4ThreeVector(0,0.,0.)),
0833                                             "PMMACollimator",
0834                                             logicPMMACollimator,
0835                                             physiPMMACollimatorSupport,
0836                                             false,
0837                                             0);
0838     
0839     logicPMMACollimator -> SetVisAttributes(yellow);
0840     
0841     
0842     
0843     
0844 }
0845 /////////////////////////////////////////////////////////////////////////////
0846 void PassiveCarbonBeamLine::HadrontherapyBeamMonitoring()
0847 {
0848     // ----------------------------
0849     //       MONITOR CHAMBER
0850     // ----------------------------
0851     // A monitor chamber is a free-air  ionisation chamber
0852     // able to measure do carbon fluence during the treatment.
0853     // Here its responce is not simulated in terms of produced
0854     // charge but only the energy losses are taked into account.
0855     // Each chamber consist of 9 mm of air in a box
0856     // that has two layers one of kapton and one
0857     // of copper
0858     
0859     monitor1XSize = 4.525022*mm;
0860     monitor2XSize = 0.000011*mm;
0861     monitor3XSize = 4.5*mm;
0862     monitorYSize = 10.*cm;
0863     monitorZSize = 10.*cm;
0864     monitor1XPosition = -1239.974978 *mm;
0865     monitor2XPosition = -4.500011*mm;
0866     monitor4XPosition = 4.500011*mm;
0867     
0868     solidFirstMonitorLayer1 = new G4Box("FirstMonitorLayer1",
0869                                         monitor1XSize,
0870                                         monitorYSize,
0871                                         monitorZSize);
0872     
0873     logicFirstMonitorLayer1 = new G4LogicalVolume(solidFirstMonitorLayer1,
0874                                                   layer1MonitorChamberMaterial,
0875                                                   "FirstMonitorLayer1");
0876     
0877     physiFirstMonitorLayer1 = new G4PVPlacement(0,
0878                                                 G4ThreeVector(monitor1XPosition,0.*cm,0.*cm),
0879                                                 "FirstMonitorLayer1",
0880                                                 logicFirstMonitorLayer1,
0881                                                 physicalTreatmentRoom,
0882                                                 false,
0883                                                 0);
0884     
0885     solidFirstMonitorLayer2 = new G4Box("FirstMonitorLayer2",
0886                                         monitor2XSize,
0887                                         monitorYSize,
0888                                         monitorZSize);
0889     
0890     logicFirstMonitorLayer2 = new G4LogicalVolume(solidFirstMonitorLayer2,
0891                                                   layer2MonitorChamberMaterial,
0892                                                   "FirstMonitorLayer2");
0893     
0894     physiFirstMonitorLayer2 = new G4PVPlacement(0, G4ThreeVector(monitor2XPosition,0.*cm,0.*cm),
0895                                                 "FirstMonitorLayer2",
0896                                                 logicFirstMonitorLayer2,
0897                                                 physiFirstMonitorLayer1,
0898                                                 false,
0899                                                 0);
0900     
0901     solidFirstMonitorLayer3 = new G4Box("FirstMonitorLayer3",
0902                                         monitor3XSize,
0903                                         monitorYSize,
0904                                         monitorZSize);
0905     
0906     logicFirstMonitorLayer3 = new G4LogicalVolume(solidFirstMonitorLayer3,
0907                                                   layer3MonitorChamberMaterial,
0908                                                   "FirstMonitorLayer3");
0909     
0910     physiFirstMonitorLayer3 = new G4PVPlacement(0,
0911                                                 G4ThreeVector(0.*mm,0.*cm,0.*cm),
0912                                                 "MonitorLayer3",
0913                                                 logicFirstMonitorLayer3,
0914                                                 physiFirstMonitorLayer1,
0915                                                 false,
0916                                                 0);
0917     
0918     solidFirstMonitorLayer4 = new G4Box("FirstMonitorLayer4",
0919                                         monitor2XSize,
0920                                         monitorYSize,
0921                                         monitorZSize);
0922     
0923     logicFirstMonitorLayer4 = new G4LogicalVolume(solidFirstMonitorLayer4,
0924                                                   layer4MonitorChamberMaterial,
0925                                                   "FirstMonitorLayer4");
0926     
0927     physiFirstMonitorLayer4 = new G4PVPlacement(0, G4ThreeVector(monitor4XPosition,0.*cm,0.*cm),
0928                                                 "FirstMonitorLayer4",
0929                                                 logicFirstMonitorLayer4,
0930                                                 physiFirstMonitorLayer1, false, 0);
0931     
0932     logicFirstMonitorLayer3 -> SetVisAttributes(white);
0933     
0934 }
0935 
0936 /////////////////////////////////////////////////////////////////////////////
0937 /////////////////////////////////////////////////////////////////////////////
0938 void PassiveCarbonBeamLine::HadrontherapyBeamNozzle()
0939 {
0940     // ------------------------------//
0941     // THE FINAL TUBE AND COLLIMATOR //
0942     //-------------------------------//
0943     // The last part of the transport beam line consists of
0944     // a 59 mm thick PMMA slab (to stop all the diffused radiation), a 370 mm brass tube
0945     // (to well collimate the proton beam) and a final collimator with 25 mm diameter
0946     // aperture (that provide the final trasversal shape of the beam)
0947     
0948     // -------------------//
0949     //     PMMA SUPPORT   //
0950     // -------------------//
0951     
0952     nozzleSupportXSize = 50 *mm;
0953     nozzleSupportYSize = 360. *mm;
0954     nozzleSupportZSize = 360. *mm;
0955     nozzleSupportXPosition = -423.0 *mm;
0956     
0957     G4double phi = 90. *deg;
0958     // Matrix definition for a 90 deg rotation. Also used for other volumes
0959     G4RotationMatrix rm;
0960     rm.rotateY(phi);
0961     
0962     solidNozzleSupport = new G4Box("NozzleSupport",
0963                                    nozzleSupportXSize/2,
0964                                    nozzleSupportYSize/2,
0965                                    nozzleSupportZSize/2);
0966     
0967     logicNozzleSupport = new G4LogicalVolume(solidNozzleSupport,
0968                                              nozzleSupportMaterial,
0969                                              "NozzleSupport");
0970     
0971     physiNozzleSupport = new G4PVPlacement(0, G4ThreeVector(nozzleSupportXPosition,0., 0.),
0972                                            "NozzleSupport",
0973                                            logicNozzleSupport,
0974                                            physicalTreatmentRoom,
0975                                            false,
0976                                            0);
0977     
0978     yellow = new G4VisAttributes(G4Colour(1., 1., 0. ));
0979     yellow-> SetVisibility(true);
0980     yellow-> SetForceWireframe(true);
0981     
0982     //------------------------------------//
0983     // HOLE IN THE SUPPORT                //
0984     //------------------------------------//
0985     innerRadiusHoleNozzleSupport = 0.*mm;
0986     outerRadiusHoleNozzleSupport = 22.0*mm;
0987     hightHoleNozzleSupport = nozzleSupportXSize;
0988     startAngleHoleNozzleSupport = 0.*deg;
0989     spanningAngleHoleNozzleSupport = 360.*deg;
0990     
0991     solidHoleNozzleSupport = new G4Tubs("HoleNozzleSupport",
0992                                         innerRadiusHoleNozzleSupport,
0993                                         outerRadiusHoleNozzleSupport,
0994                                         hightHoleNozzleSupport/2,
0995                                         startAngleHoleNozzleSupport,
0996                                         spanningAngleHoleNozzleSupport);
0997     
0998     logicHoleNozzleSupport = new G4LogicalVolume(solidHoleNozzleSupport,
0999                                                  holeNozzleSupportMaterial,
1000                                                  "HoleNozzleSupport",
1001                                                  0,
1002                                                  0,
1003                                                  0);
1004     
1005     physiHoleNozzleSupport = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector()),
1006                                                "HoleNozzleSupport",
1007                                                logicHoleNozzleSupport,
1008                                                physiNozzleSupport,
1009                                                false, 0);
1010     
1011     
1012     // --------------------------------------//
1013     //     BRASS TUBE 3 (beam line side)    //
1014     // -------------------------------------//
1015     innerRadiusBrassTube3 = 13.5 *mm;
1016     outerRadiusBrassTube3 = 21.5 *mm;
1017     hightBrassTube3 = 20.0 *mm;
1018     startAngleBrassTube3 = 0.*deg;
1019     spanningAngleBrassTube3 = 360.*deg;
1020     brassTube3XPosition = -458.0 *mm;
1021     
1022     solidBrassTube3 = new G4Tubs("BrassTube3",
1023                                  innerRadiusBrassTube3,
1024                                  outerRadiusBrassTube3,
1025                                  hightBrassTube3/2,
1026                                  startAngleBrassTube3,
1027                                  spanningAngleBrassTube3);
1028     
1029     logicBrassTube3 = new G4LogicalVolume(solidBrassTube3,
1030                                           brassTube3Material,
1031                                           "BrassTube3",
1032                                           0, 0, 0);
1033     
1034     physiBrassTube3 = new G4PVPlacement(G4Transform3D(rm,
1035                                                       G4ThreeVector(brassTube3XPosition,
1036                                                                     0.,
1037                                                                     0.)),
1038                                         "BrassTube3",
1039                                         logicBrassTube3,
1040                                         physicalTreatmentRoom,
1041                                         false,
1042                                         0);
1043     
1044     logicBrassTube3 -> SetVisAttributes(darkOrange3);
1045     
1046     // ----------------------------------------------//
1047     //     BRASS TUBE 2 (inside the PMMA support)    //
1048     // ----------------------------------------------//
1049     
1050     innerRadiusBrassTube2 = 13.5 *mm;
1051     outerRadiusBrassTube2 = 21.5 *mm;
1052     hightBrassTube2 = nozzleSupportXSize;
1053     startAngleBrassTube2 = 0.*deg;
1054     spanningAngleBrassTube2 = 360.*deg;
1055     
1056     
1057     solidBrassTube2 = new G4Tubs("BrassTube2",
1058                                  innerRadiusBrassTube2,
1059                                  outerRadiusBrassTube2,
1060                                  hightBrassTube2/2,
1061                                  startAngleBrassTube2,
1062                                  spanningAngleBrassTube2);
1063     
1064     logicBrassTube2 = new G4LogicalVolume(solidBrassTube2,
1065                                           brassTube2Material,
1066                                           "BrassTube2",
1067                                           0, 0, 0);
1068     physiBrassTube2 = new G4PVPlacement(0,
1069                                         G4ThreeVector(0,0.,0.),
1070                                         logicBrassTube2,
1071                                         "BrassTube2",
1072                                         logicHoleNozzleSupport,
1073                                         false,
1074                                         0);
1075     
1076     logicBrassTube2 -> SetVisAttributes(darkOrange3);
1077     
1078     // ---------------------------------//
1079     //     BRASS TUBE 1 (phantom side)    //
1080     // ---------------------------------//
1081     innerRadiusBrassTube= 18.*mm;
1082     outerRadiusBrassTube = 21.5 *mm;
1083     hightBrassTube = 208.0 *mm;
1084     startAngleBrassTube = 0.*deg;
1085     spanningAngleBrassTube = 360.*deg;
1086     brassTubeXPosition = -294 *mm;
1087     solidBrassTube = new G4Tubs("BrassTube",
1088                                 innerRadiusBrassTube,
1089                                 outerRadiusBrassTube,
1090                                 hightBrassTube/2,
1091                                 startAngleBrassTube,
1092                                 spanningAngleBrassTube);
1093     
1094     logicBrassTube = new G4LogicalVolume(solidBrassTube,
1095                                          brassTubeMaterial,
1096                                          "BrassTube",
1097                                          0, 0, 0);
1098     
1099     physiBrassTube = new G4PVPlacement(G4Transform3D(rm,
1100                                                      G4ThreeVector(brassTubeXPosition,
1101                                                                    0.,
1102                                                                    0.)),
1103                                        "BrassTube",
1104                                        logicBrassTube,
1105                                        physicalTreatmentRoom,
1106                                        false,
1107                                        0);
1108     
1109     logicBrassTube -> SetVisAttributes(darkOrange3);
1110 }
1111 
1112 /////////////////////////////////////////////////////////////////////////////
1113 void PassiveCarbonBeamLine::HadrontherapyBeamFinalCollimator()
1114 {
1115     // -----------------------//
1116     //     FINAL COLLIMATOR   //
1117     //------------------------//
1118     outerRadiusFinalCollimator = 21.5*mm;
1119     hightFinalCollimator = 7.0 *mm;
1120     startAngleFinalCollimator = 0.*deg;
1121     spanningAngleFinalCollimator = 360.*deg;
1122     finalCollimatorXPosition = -186.5 *mm;
1123     
1124     G4double phi = 90. *deg;
1125     
1126     // Matrix definition for a 90 deg rotation. Also used for other volumes
1127     G4RotationMatrix rm;
1128     rm.rotateY(phi);
1129     
1130     solidFinalCollimator = new G4Tubs("FinalCollimator",
1131                                       innerRadiusFinalCollimator,
1132                                       outerRadiusFinalCollimator,
1133                                       hightFinalCollimator/2,
1134                                       startAngleFinalCollimator,
1135                                       spanningAngleFinalCollimator);
1136     
1137     logicFinalCollimator = new G4LogicalVolume(solidFinalCollimator,
1138                                                finalCollimatorMaterial,
1139                                                "FinalCollimator",
1140                                                0,
1141                                                0,
1142                                                0);
1143     
1144     physiFinalCollimator = new G4PVPlacement(G4Transform3D(rm,
1145                                                            G4ThreeVector(finalCollimatorXPosition,0.,0.)),
1146                                              "FinalCollimator",
1147                                              logicFinalCollimator,
1148                                              physicalTreatmentRoom,
1149                                              false,
1150                                              0);
1151     
1152     logicFinalCollimator -> SetVisAttributes(yellow);
1153 }
1154 
1155 
1156 /////////////////////////////////////////////////////////////////////////////
1157 /////////////////////////// MESSENGER ///////////////////////////////////////
1158 /////////////////////////////////////////////////////////////////////////////
1159 
1160 void PassiveCarbonBeamLine::SetRippleFilterXPosition(G4double value)
1161 {
1162     PhysiRippleFilter -> SetTranslation(G4ThreeVector(value, 0., 0.));
1163     G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1164     G4cout << "The Ripple Filter is translated to"<< value/mm <<"mm along the X axis" <<G4endl;
1165 }
1166 
1167 
1168 /////////////////////////////////////////////////////////////////////////////
1169 void PassiveCarbonBeamLine::SetInnerRadiusFinalCollimator(G4double value)
1170 {
1171     solidFinalCollimator -> SetInnerRadius(value);
1172     G4RunManager::GetRunManager() -> GeometryHasBeenModified();
1173     G4cout<<"Inner Radius of the final collimator is (mm):"
1174     << solidFinalCollimator -> GetInnerRadius()/mm
1175     << G4endl;
1176 }
1177 
1178 /////////////////////////////////////////////////////////////////////////////
1179 void PassiveCarbonBeamLine::SetRippleFilterMaterial(G4String materialChoice)
1180 {
1181     if (G4Material* RFMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice, false) )
1182     {
1183         if (RFMaterial)
1184         {
1185             rippleFilterMaterial  = RFMaterial;
1186             LogicRippleFilter -> SetMaterial(RFMaterial);
1187             LogicRippleFilterBase -> SetMaterial(RFMaterial);
1188             LogicRippleFilterTrd -> SetMaterial(RFMaterial);
1189             G4cout << "The material of the Ripple Filter has been changed to " << materialChoice << G4endl;
1190         }
1191     }
1192     else
1193     {
1194         G4cout << "WARNING: material \"" << materialChoice << "\" doesn't exist in NIST elements/materials"
1195         " table [located in $G4INSTALL/source/materials/src/G4NistMaterialBuilder.cc]" << G4endl;
1196         G4cout << "Use command \"/parameter/nist\" to see full materials list!" << G4endl;
1197     }
1198 }
1199 
1200 
1201