Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:29:21

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // Authors: Susanna Guatelli and Francesco Romano
0027 // susanna@uow.edu.au, francesco.romano@ct.infn.it
0028 
0029 // Modified by Jacopo Magini: j.magini@surrey.ac.uk
0030 
0031 // Modified by David Bolst: db001@uowmail.edu.au
0032 // Added geometry of "bridge" microdosimeter (ConstructSiliconBridgeDetector())
0033 
0034 #include "DetectorConstruction.hh"
0035 #include "globals.hh"
0036 #include "G4Element.hh"
0037 #include "G4Material.hh"
0038 #include "G4PVPlacement.hh"
0039 #include "G4LogicalVolume.hh"
0040 #include "G4Box.hh"
0041 #include "G4Tubs.hh"
0042 //#include "G4SubtractionSolid.hh"
0043 #include "G4FieldManager.hh"
0044 #include "G4TransportationManager.hh"
0045 #include "G4ChordFinder.hh"
0046 #include "G4Colour.hh"
0047 #include "G4VisAttributes.hh"
0048 #include "SensitiveDetector.hh"
0049 #include "G4SDManager.hh"
0050 #include "G4UserLimits.hh"
0051 #include "Randomize.hh"
0052 #include "G4ThreeVector.hh"
0053 #include "G4GeometryTolerance.hh"
0054 #include "G4GeometryManager.hh"
0055 #include "G4SystemOfUnits.hh"
0056 #include "G4NistManager.hh"
0057 
0058 DetectorConstruction::DetectorConstruction(AnalysisManager* analysis_manager, DetectorMessenger* detector_messenger)
0059 {
0060     analysis = analysis_manager;
0061     messenger = detector_messenger;
0062     
0063     detectorType = messenger -> GetDetectorType();
0064     detectorSizeWidth = messenger -> GetDetectorSizeWidth();
0065     detectorSizeThickness = messenger -> GetDetectorSizeThickness();
0066     secondStageSizeDim = messenger -> GetSecondStageSizeWidth();
0067     secondStageSizeThickness = messenger -> GetSecondStageSizeThickness();
0068     
0069     usingWaterPhantom = messenger -> IsPhantomEnabled();
0070     
0071     detectorPositionDepth = messenger -> GetDetectorPositionDepth();
0072     
0073     nistMan = G4NistManager::Instance();
0074 }
0075 
0076 DetectorConstruction::~DetectorConstruction(){
0077 
0078 }
0079 
0080 G4VPhysicalVolume* DetectorConstruction::Construct()
0081 {
0082     if( usingWaterPhantom == true ) ConstructWorldWithWaterPhantom(); // for medical applications
0083     else ConstructVacuumWorld(); // space applications
0084     
0085     if( detectorType == "Diamond" ) ConstructDiamondDetector();
0086     else if( detectorType == "MicroDiamond" ) ConstructMicroDiamondDetector();
0087     else if( detectorType == "Silicon" ) ConstructSiliconDetector();
0088     else if( detectorType == "SiliconBridge" ) ConstructSiliconBridgeDetector();
0089     else if( detectorType == "DiamondTelescope" ) ConstructDiamondTelescope();
0090     else if( detectorType ==  "SiCDetector") ConstructSiC();
0091     else
0092     {
0093         G4cout << "ERROR: " << detectorType << " is not an allowed detector type. ";
0094         return 0;
0095     }
0096     
0097     return physical_world;
0098 }
0099 
0100 void DetectorConstruction::ConstructWorldWithWaterPhantom()
0101 {
0102     //Define materials
0103     G4Material* air  = nistMan->FindOrBuildMaterial("G4_AIR");
0104     G4Material* water = G4NistManager::Instance()->FindOrBuildMaterial("G4_WATER");
0105     
0106     G4double phantomWidth = 5.*cm;
0107     G4double phantomLength = detectorPositionDepth + 2.*cm;
0108     
0109     G4double worldWidth = phantomWidth + 5*cm;
0110     G4double worldLength = phantomLength*2;
0111     
0112     // In a clinical setup, the water phantom is surrounded by air
0113     G4Box* world = new G4Box("world_box", worldWidth/2, worldWidth/2, worldLength/2);
0114     G4LogicalVolume* logical_world = new G4LogicalVolume(world, air, "world_log", 0,0,0);
0115     
0116     //set the logical world volume invisible
0117     logical_world -> SetVisAttributes(G4VisAttributes::GetInvisible());
0118     
0119     physical_world = new G4PVPlacement(0,
0120                                 G4ThreeVector(),
0121                                 logical_world, 
0122                                 "world_phys",
0123                                 0, 
0124                                 false, 
0125                                 0);
0126     
0127     G4Box* phantom_box = new G4Box("phantom_box", phantomWidth/2, phantomWidth/2, phantomLength/2);
0128     G4LogicalVolume* logical_phantom = new G4LogicalVolume(phantom_box, water, "phantom_log", 0,0,0);
0129     
0130     //the water phantom starts at z=0
0131     G4ThreeVector phantom_position = G4ThreeVector( 0., 0., -phantomLength/2 );
0132     
0133      new G4PVPlacement(0, phantom_position, logical_phantom,"phantom_phys",
0134                 logical_world, 
0135                 false, 0, 0);
0136      
0137      logical_phantom -> SetVisAttributes(G4VisAttributes(G4Colour(0., 0.2, 0.6)));
0138      
0139      // smaller inner volume where the detector will be placed
0140     G4double innerSize = 2.*cm;
0141     G4Box* inner_box = new G4Box("inner_box", innerSize/2, innerSize/2, innerSize/2);
0142     G4LogicalVolume* logical_inner = new G4LogicalVolume(inner_box, water, "inner_log",0,0,0);
0143     
0144     G4double innerDepth = phantomLength/2 -detectorPositionDepth;
0145     G4ThreeVector inner_position = G4ThreeVector( 0 , 0 , innerDepth );
0146     new G4PVPlacement(0, inner_position, logical_inner,"inner_phys",
0147                 logical_phantom, 
0148                 false, 0, 0);
0149     
0150     logical_inner -> SetVisAttributes(G4VisAttributes::GetInvisible());
0151     
0152     // private member of DetectorConstruction,
0153     // needed as mother volume for Construct*Detector()
0154     logical_motherVolumeForDetector = logical_inner;
0155     materialOfMotherVolume = water;
0156     
0157     // uncomment to enable a G4Region for the inner volume
0158     // e.g. in order to set different cuts
0159     //G4Region* inner_region = new G4Region("inner_region");
0160     //inner_region -> AddRootLogicalVolume( logical_highPVol );
0161 }
0162 
0163 void DetectorConstruction::ConstructVacuumWorld()
0164 {
0165         //Define Vacuum
0166     G4double Z = 1.;
0167     G4double A = 1.01*g/mole;
0168     G4double vacuumDensity = 1.e-25 *g/cm3;
0169     G4double pressure = 3.e-18*pascal;
0170     G4double temperature = 2.73*kelvin;
0171     G4Material* vacuum = new G4Material("Galactic", Z, A,
0172                          vacuumDensity,kStateGas,temperature,pressure);
0173     
0174     G4double worldSize = 10.*cm;
0175     
0176     G4Box* world_box = new G4Box("world_box", worldSize/2, worldSize/2, worldSize/2);
0177     G4LogicalVolume* logical_world = new G4LogicalVolume(world_box, vacuum, "world_log",0,0,0);
0178     physical_world = new G4PVPlacement(0,
0179                                 G4ThreeVector(),
0180                                 logical_world, 
0181                                 "world_phys",
0182                                 0, 
0183                                 false, 
0184                                 0);
0185     
0186     logical_world -> SetVisAttributes(G4VisAttributes::GetInvisible());
0187     
0188     logical_motherVolumeForDetector = logical_world;
0189     materialOfMotherVolume = vacuum;
0190 }
0191 
0192 void DetectorConstruction::ConstructDiamondDetector()
0193 {
0194 
0195 //Define each individual element
0196 //Define Oxygen
0197  G4double A = 16.0 * g/mole;
0198  G4double Z = 8;
0199  G4Element* elO = new G4Element ("Oxygen", "O", Z, A);
0200 
0201 //Define Hydrogen 
0202  A = 1.01 * g/mole;
0203  Z = 1;
0204  G4Element* elH = new G4Element ("Hydrogen", "H", Z, A);
0205 
0206 //Define Boron
0207  A = 10.8 * g/mole;
0208  Z = 5;
0209  G4Element* elB = new G4Element ("Boron", "B", Z, A);
0210 
0211 //Define Carbon
0212  A = 12.01 * g/mole;
0213  Z = 6;
0214  G4Element* elC = new G4Element ("Carbon", "C", Z, A);
0215 
0216 //Define diamond
0217  A = 12.01 * g/mole;
0218  Z = 6;
0219  G4Material* diamond = new G4Material("diamond", Z, A, 3.515*g/cm3);
0220             
0221 //Define dopant (boron doped diamond)
0222  G4Material* dopant = new G4Material("dopant", 3.514*g/cm3, 2);
0223  dopant -> AddElement(elC, 99.9994*perCent);
0224  dopant -> AddElement(elB, 0.0006*perCent);
0225 
0226  //Define Aluminium contacts (AlContact)
0227  A = 26.981 * g/mole;
0228  Z = 13;
0229  G4Material* AlContact = new G4Material("AlContact", Z, A, 2.7 *g/cm3);
0230 
0231  //Define Gold contact (AuContact)
0232  A = 196.97 * g/mole;
0233  Z = 79;
0234  G4Material* AuContact = new G4Material("AuContact", Z, A, 19.3 *g/cm3);
0235  
0236  //Define PMMA (C502H8)
0237  // NIST reference 
0238  G4Material* PMMA = new G4Material("PMMA", 1.19*g/cm3, 3);
0239  PMMA -> AddElement(elC, 5);
0240  PMMA -> AddElement(elO, 2);
0241  PMMA -> AddElement(elH, 8);
0242 
0243  
0244  // Define the geometry of the diamond microdosimeter
0245  // mother volume of the detector components
0246  G4double DiaVol_x = 300*micrometer;
0247  G4double DiaVol_y = 240*micrometer;
0248  G4double DiaVol_z = 150*micrometer; 
0249 
0250  G4Box* DiaVol_box = new G4Box("DiaVol_box",DiaVol_x,DiaVol_y,DiaVol_z);
0251 
0252  G4LogicalVolume* logical_DiaVol = new G4LogicalVolume(DiaVol_box, diamond, "DiaVol_log", 0,0,0);
0253  
0254  G4ThreeVector DiaVol_position = {0, 0, -DiaVol_z +detectorSizeThickness/2};
0255 
0256  new G4PVPlacement(0, DiaVol_position, logical_DiaVol,"DiaVol_phys",
0257               logical_motherVolumeForDetector, 
0258               false, 0, true);
0259 
0260  //VacBlock for contact placement
0261  G4double vacblock_x = 300*um;
0262  G4double vacblock_y = 240*um;
0263  G4double vacblock_z = 0.25*um; 
0264 
0265  // vacuum (or water) box to place other volumes in
0266  G4Box* vacblock_box = new G4Box("vacblock_box",vacblock_x,vacblock_y,vacblock_z);
0267 
0268  G4LogicalVolume* logical_vacblock = new G4LogicalVolume(vacblock_box, materialOfMotherVolume, "vacblock_log", 0,0,0);
0269 
0270  new G4PVPlacement(0, 
0271                G4ThreeVector(0,0,DiaVol_z - vacblock_z),
0272            logical_vacblock,
0273                "vacblock_phys",
0274                logical_DiaVol, 
0275                false, 
0276                0, true);
0277 //Bdl in DiaVol
0278  G4double Bdl_x = 300*micrometer;
0279  G4double Bdl_y = 240*micrometer;
0280  G4double Bdl_z = detectorSizeThickness/2; 
0281     
0282  G4Box* Bdl_box = new G4Box("Bdl_box",Bdl_x,Bdl_y,Bdl_z);
0283 
0284  G4LogicalVolume* logical_Bdl = new G4LogicalVolume(Bdl_box, dopant, "Bdl_log", 0,0,0);
0285 
0286  new G4PVPlacement(0, 
0287            G4ThreeVector(0,0,DiaVol_z - Bdl_z - vacblock_z- vacblock_z),
0288            logical_Bdl,
0289            "Bdl_phys",
0290                logical_DiaVol,   //mother volume 
0291                    false, 
0292            0, true);
0293 
0294  //Diamond SV
0295  G4double SV_x = detectorSizeWidth/2;
0296  G4double SV_y = detectorSizeWidth/2;
0297  G4double SV_z = Bdl_z; 
0298 
0299  G4Box* SV_box = new G4Box("SV_box",SV_x,SV_y,SV_z);
0300 
0301  G4LogicalVolume* logical_SV = new G4LogicalVolume(SV_box, diamond, "SV_log", 0,0,0);
0302 
0303  new G4PVPlacement(0, G4ThreeVector(-45*um,105*um,0*um), logical_SV,"SV_phys1",
0304             logical_Bdl,false, 0, true);
0305 
0306  new G4PVPlacement(0, G4ThreeVector(165*um,105*um,0*um), logical_SV,"SV_phys2",
0307            logical_Bdl, false, 0, true);
0308 
0309  new G4PVPlacement(0, G4ThreeVector(-45*um,-105*um,0*um),logical_SV,"SV_phys3", 
0310            logical_Bdl, false, 0, true);
0311 
0312  new G4PVPlacement(0, G4ThreeVector(165*um,-105*um,0*um),logical_SV,"SV_phys4",
0313            logical_Bdl, false, 0, true);
0314 
0315 //Al strips
0316 //10 nm thickness 
0317  G4double AlStrip_x = 240*um;
0318  G4double AlStrip_y = 240*um;
0319  G4double AlStrip_z = vacblock_z; 
0320 
0321  G4Box* AlStrip = new G4Box("AlStrip",AlStrip_x,AlStrip_y,AlStrip_z);
0322 
0323  G4LogicalVolume* logical_AlStrip = new G4LogicalVolume(AlStrip, AlContact, "AlStrip_log", 0,0,0);
0324 
0325  new G4PVPlacement(0, G4ThreeVector(60*um,0,0), logical_AlStrip, "AlStrip_phys",
0326                    logical_vacblock, false, 0, true);
0327 
0328 //gold cylinder in vacblock
0329  G4double innerRadiusOfTheTube1 = 0.*um;
0330  G4double outerRadiusOfTheTube1 = 45.*um;
0331  G4double heightOfTheTube1 = 10*nm;
0332  G4double startAngleOfTheTube1 = 0.*deg;
0333  G4double spanningAngleOfTheTube1 = 360.*deg;
0334 
0335  G4Tubs* GoldCylinder1 = new G4Tubs("GoldCylinder1", innerRadiusOfTheTube1, 
0336                             outerRadiusOfTheTube1,
0337                             heightOfTheTube1,
0338                             startAngleOfTheTube1, 
0339                             spanningAngleOfTheTube1);
0340     
0341  G4LogicalVolume* logical_GoldCylinder1 = new G4LogicalVolume(GoldCylinder1, AuContact, "GoldCylinder1_log", 0,0,0);
0342 
0343  new G4PVPlacement(0,G4ThreeVector(-245*um,0,-vacblock_z + heightOfTheTube1),
0344                        logical_GoldCylinder1,
0345                    "GoldCylinder1_phys",
0346                    logical_vacblock, false, 0, true);
0347 
0348 //gold contacts
0349  G4double innerRadiusOfTheTube2 = 0.*um;
0350  G4double outerRadiusOfTheTube2 = 45.*um;
0351  G4double heightOfTheTube2 = Bdl_z;
0352  G4double startAngleOfTheTube2 = 0.*deg;
0353  G4double spanningAngleOfTheTube2 = 360.*deg;
0354 
0355  G4Tubs* GoldCylinder2 = new G4Tubs("GoldCylinder2",
0356                             innerRadiusOfTheTube2, 
0357                             outerRadiusOfTheTube2,
0358                             heightOfTheTube2,
0359                             startAngleOfTheTube2, 
0360                             spanningAngleOfTheTube2);
0361     
0362  G4LogicalVolume* logical_GoldCylinder2 = new G4LogicalVolume(GoldCylinder2, AuContact, "GoldCylinder2_log", 0,0,0);
0363 
0364  new G4PVPlacement(0, G4ThreeVector(-245*um,0,0), logical_GoldCylinder2, "GoldCylinder2_phys",
0365            logical_Bdl, false, 0, true);
0366 
0367 //gold cylinder in DiaVol
0368  G4double innerRadiusOfTheTube3 = 0.*um;
0369  G4double outerRadiusOfTheTube3 = 45.*um;
0370  G4double heightOfTheTube3 = 75.*um -heightOfTheTube2 - heightOfTheTube1 ;
0371  G4double startAngleOfTheTube3 = 0.*deg;
0372  G4double spanningAngleOfTheTube3 = 360.*deg;
0373 
0374  G4Tubs* GoldCylinder3 = new G4Tubs("GoldCylinder3",
0375                             innerRadiusOfTheTube3, 
0376                             outerRadiusOfTheTube3,
0377                             heightOfTheTube3,
0378                             startAngleOfTheTube3, 
0379                             spanningAngleOfTheTube3);
0380     
0381 G4LogicalVolume* logical_GoldCylinder3 = new G4LogicalVolume(GoldCylinder3, AuContact, "GoldCylinder3_log", 0,0,0);
0382 
0383 new G4PVPlacement(0, G4ThreeVector(-245*um,0,DiaVol_z - heightOfTheTube3 - Bdl_z - Bdl_z - vacblock_z- vacblock_z),
0384                    logical_GoldCylinder3,
0385                    "GoldCylinder3_phys",
0386                    logical_DiaVol, 
0387                    false, 
0388                    0, true);
0389 
0390 // Visualisation attributes
0391 
0392         logical_DiaVol -> SetVisAttributes(G4VisAttributes(G4Colour(255,255,255))); //white
0393     logical_Bdl -> SetVisAttributes(G4VisAttributes(G4Colour(0,255,0)));        //green
0394     
0395     G4VisAttributes vis_SV(G4Colour(198, 226, 255));
0396     vis_SV.SetForceSolid(true);
0397     logical_SV -> SetVisAttributes(vis_SV);
0398         logical_vacblock -> SetVisAttributes(G4VisAttributes::GetInvisible());      
0399     logical_AlStrip -> SetVisAttributes(G4VisAttributes(G4Colour(0, 255, 255)));//cyan
0400     
0401     G4VisAttributes vis_GoldCylinder1(G4Colour(255, 255, 0));                    
0402     vis_GoldCylinder1.SetForceAuxEdgeVisible(true);
0403     logical_GoldCylinder1 -> SetVisAttributes(vis_GoldCylinder1);
0404     
0405     G4VisAttributes vis_GoldCylinder2(G4Colour(255, 255, 0));                    
0406     vis_GoldCylinder2.SetForceAuxEdgeVisible(true);
0407     logical_GoldCylinder2 -> SetVisAttributes(vis_GoldCylinder2); 
0408     
0409     G4VisAttributes vis_GoldCylinder3(G4Colour(255, 255, 0));                    
0410     vis_GoldCylinder3.SetForceAuxEdgeVisible(true);
0411     logical_GoldCylinder3 -> SetVisAttributes(vis_GoldCylinder3); 
0412   
0413 // no need to return the following, it's been stored earlier!
0414 //return physical_world; 
0415 
0416 }
0417 
0418 void DetectorConstruction::ConstructMicroDiamondDetector()
0419 {
0420     //Define each individual element
0421     //Define Boron
0422     G4double A = 10.8 * g/mole;
0423     G4double Z = 5;
0424     G4Element* elB = new G4Element ("Boron", "B", Z, A);
0425 
0426     //Define Carbon
0427     A = 12.01 * g/mole;
0428     Z = 6;
0429     G4Element* elC = new G4Element ("Carbon", "C", Z, A);
0430 
0431     //Define diamond
0432     A = 12.01 * g/mole;
0433     Z = 6;
0434     G4Material* diamond = new G4Material("diamond", Z, A, 3.515*g/cm3);
0435             
0436     //Define p-type diamond (boron doped diamond)
0437     G4Material* p_diamond = new G4Material("p_diamond", 3.514*g/cm3, 2);
0438     // Boron concentration used is 1e20 cm-3, considering the diamond density and a Boron atomic weight of 10.811u
0439     p_diamond -> AddElement(elC, 99.94887*perCent);
0440     p_diamond -> AddElement(elB, 0.05113*perCent);
0441 
0442     //Define chromium contact
0443     G4Material* chromium = nistMan->FindOrBuildMaterial("G4_Cr");
0444 
0445     // sentive volume
0446     G4double SVside = detectorSizeWidth /2.;
0447     G4double SVthickness = detectorSizeThickness /2.;
0448     G4double SVspacing = 200.*um; //edge-edge distance
0449     
0450     G4Box* SV_box = new G4Box("SV_box", SVside, SVside, SVthickness);
0451 
0452     G4LogicalVolume* logical_SV = new G4LogicalVolume(SV_box, diamond, "SV_log", 0,0,0);
0453     
0454     G4VisAttributes SVcolour(G4Colour(0.5, 0.5, 0.5));
0455     SVcolour.SetForceSolid(true);
0456     logical_SV -> SetVisAttributes(SVcolour);
0457 
0458     // chromium front-electrode
0459     G4double feThickness = 50.*nm /2.; // front-electrode thickness
0460 
0461     G4Box* fe_box = new G4Box("frontElec_box", SVside, SVside, feThickness);
0462 
0463     G4LogicalVolume* logical_fe = new G4LogicalVolume(fe_box, chromium, "frontElec_log", 0,0,0);
0464     
0465     G4VisAttributes fe_colour(G4Colour::Brown());
0466     fe_colour.SetForceSolid(false);
0467     logical_fe -> SetVisAttributes(fe_colour);
0468     
0469     // p-type diamond
0470     G4double pDthickness = 1.*um /2.; // p-type diamond back-electrode thickness
0471     
0472     G4Box* pD_box = new G4Box("pDiam_box", SVside, SVside, pDthickness);
0473     
0474     G4LogicalVolume* logical_pD = new G4LogicalVolume(pD_box, p_diamond, "pDiam_box", 0,0,0);
0475     
0476     G4VisAttributes pDcolour(G4Colour::Blue());
0477     pDcolour.SetForceSolid(false);
0478     
0479     logical_pD -> SetVisAttributes(pDcolour);
0480 
0481     // put them in place
0482     G4ThreeVector SVposition = {0., 0., 0}; //position of the first edge (left)
0483     G4ThreeVector fePosition = {0., 0., SVthickness + feThickness};
0484     G4ThreeVector pDposition = {0., 0., -SVthickness -pDthickness};
0485     
0486     G4double SVposition_x[4] = { -3.*SVside -1.5*SVspacing, -SVside -0.5*SVspacing, +SVside +0.5*SVspacing, +3.*SVside +1.5*SVspacing };
0487 
0488     std::ostringstream PVName;
0489 
0490     for( int i=0; i<4; i++)
0491     {   
0492         // sensitive volume
0493         SVposition[0] = SVposition_x[i];
0494         PVName << "SV_phys" << i;
0495         new G4PVPlacement(0, SVposition, logical_SV, PVName.str(),
0496                     logical_motherVolumeForDetector,
0497                     false, 0, true);
0498         PVName.str(""); //reset the string
0499         
0500         // chromium front-electrode
0501         PVName << "frontElec_phys" << i;
0502         fePosition[0] = SVposition[0];
0503         new G4PVPlacement(0, fePosition, logical_fe, PVName.str(),
0504                     logical_motherVolumeForDetector,
0505                     false, 0, true);
0506         PVName.str("");
0507         
0508         // p-type diamond back-electrode
0509         PVName << "pD_phys" << i;
0510         pDposition[0] = SVposition[0];
0511         new G4PVPlacement(0, pDposition, logical_pD, PVName.str(),
0512                     logical_motherVolumeForDetector,
0513                     false, 0, true);
0514         PVName.str("");     
0515     }
0516 
0517     // HPHT diamond substrate (only one big substrate for simplicity)
0518     G4double subs_x = 2.*mm /2.;
0519     G4double subs_y = 0.5*mm /2.; 
0520     G4double sub_z = 300.*micrometer /2.; 
0521     
0522     G4Box* sub_box = new G4Box("sub_box", subs_x, subs_y, sub_z);
0523     
0524     G4LogicalVolume* logical_sub = new G4LogicalVolume(sub_box, diamond, "sub_log", 0,0,0);
0525     
0526     G4ThreeVector subPosition = {0,0, -SVthickness -2.*pDthickness -sub_z};
0527     
0528     new G4PVPlacement(0, subPosition, logical_sub, "sub_phys",
0529                 logical_motherVolumeForDetector,
0530                 false, 0, true);
0531 
0532     G4VisAttributes subColour(G4Colour(0.5, 0.5, 0.5));
0533     subColour.SetForceSolid(false);
0534     logical_sub -> SetVisAttributes(subColour);
0535 }
0536 
0537 void DetectorConstruction::ConstructDiamondTelescope()
0538 {
0539     //Define each individual element
0540     //Define Boron
0541     G4double A = 10.8 * g/mole;
0542     G4double Z = 5;
0543     G4Element* elB = new G4Element ("Boron", "B", Z, A);
0544 
0545     //Define Carbon
0546     A = 12.01 * g/mole;
0547     Z = 6;
0548     G4Element* elC = new G4Element ("Carbon", "C", Z, A);
0549 
0550     //Define diamond
0551     A = 12.01 * g/mole;
0552     Z = 6;
0553     G4Material* diamond = new G4Material("diamond", Z, A, 3.515*g/cm3);
0554             
0555     //Define p-type diamond (boron doped diamond)
0556     G4Material* p_diamond = new G4Material("p_diamond", 3.514*g/cm3, 2);
0557     // Boron concentration used is 1e20 cm-3, considering the diamond density and a Boron atomic weight of 10.811u
0558     p_diamond -> AddElement(elC, 99.94887*perCent);
0559     p_diamond -> AddElement(elB, 0.05113*perCent);
0560 
0561     //Define chromium contact
0562     G4Material* chromium = nistMan->FindOrBuildMaterial("G4_Cr");
0563 
0564     // sentive volumes
0565     // DE
0566     G4double SV_DE_radius = detectorSizeWidth /2.;
0567     G4double SV_DE_thickness = detectorSizeThickness /2.;
0568     
0569     G4Tubs* SV_DE_cyl = new G4Tubs("SV_DE_cyl", 0.*mm, SV_DE_radius, SV_DE_thickness, 0*deg, 360*deg);
0570 
0571     G4LogicalVolume* logical_SV = new G4LogicalVolume(SV_DE_cyl, diamond, "SV_log", 0,0,0);
0572     
0573     G4VisAttributes SVcolour(G4Colour(0.5, 0.5, 0.5));
0574     SVcolour.SetForceSolid(true);
0575     logical_SV -> SetVisAttributes(SVcolour);
0576     
0577     // The E-stage diameter has to be at least the size of the DE.
0578     if( secondStageSizeDim < detectorSizeWidth )
0579     {
0580         G4cout << "WARNING: the telescope E-stage diameter set (" << secondStageSizeDim << ") is smaller than the DE-stage diameter (" << detectorSizeWidth << ").";
0581         G4cout << "To be compliant with the telescope structure, the E-stage diameter has to be at least the same size as the DE-stage diameter.";
0582         secondStageSizeDim = detectorSizeWidth;
0583         G4cout << "E-stage diameter set to default as the DE-stage diameter: " << secondStageSizeDim << ".";
0584     }
0585 
0586     // E stage
0587     G4double SV_E_thickness = secondStageSizeThickness /2.;
0588     G4double SV_E_radius = secondStageSizeDim /2.;
0589 
0590     G4Tubs* SV_E_cyl = new G4Tubs("SV_E_cyl", 0.*mm, SV_E_radius, SV_E_thickness, 0*deg, 360*deg);
0591 
0592     G4LogicalVolume* logical_SV_Estage = new G4LogicalVolume(SV_E_cyl, diamond, "SV_Estage_log", 0,0,0);
0593     
0594     G4VisAttributes SV_E_colour(G4Colour(0.7, 0.7, 0.7));
0595     SV_E_colour.SetForceSolid(true);
0596     logical_SV_Estage -> SetVisAttributes(SV_E_colour);
0597 
0598     // DE and E crystals - the DE and E sensitive volumes are embedded in bigger intrinsic diamond matrixes, since they are created by the electric field generated from the front and electrodes, respectively.
0599 
0600     // DE and E crystals thickensses are the same as the DE and E sensitive volumes, while their lateral size is bigger and usually few mm.
0601     // Default diamond crystals lateral size
0602     G4double d_crystal_width = 2.*mm /2.;
0603     
0604     if( d_crystal_width < secondStageSizeDim )
0605     {
0606         G4cout << "The default lateral size (" << d_crystal_width << ") of the diamond crystals in which the DE and the E stages are created was changed to be at least as big as the sensitive volumes (" << secondStageSizeDim << ".";
0607         d_crystal_width = secondStageSizeDim;
0608     }
0609 
0610     // DE crystal       
0611     G4Box* DE_crystal_box = new G4Box("DE_crystal_box", d_crystal_width, d_crystal_width, SV_DE_thickness);
0612 
0613     G4LogicalVolume* logical_DE_crystal = new G4LogicalVolume(DE_crystal_box, diamond, "DE_crystal_log", 0,0,0);
0614     
0615     G4VisAttributes Diamond_crystal_colour(G4Colour::White());
0616     Diamond_crystal_colour.SetForceSolid(false);
0617     logical_DE_crystal -> SetVisAttributes(Diamond_crystal_colour);
0618 
0619     // E crystal
0620     G4Box* E_crystal_box = new G4Box("E_crystal_box", d_crystal_width, d_crystal_width, SV_E_thickness);
0621 
0622     G4LogicalVolume* logical_E_crystal = new G4LogicalVolume(E_crystal_box, diamond, "E_crystal_log", 0,0,0);
0623     
0624     logical_E_crystal -> SetVisAttributes(Diamond_crystal_colour);
0625 
0626     // chromium front-electrode
0627     G4double feThickness = 100.*nm /2.; // front-electrode thickness
0628 
0629     G4Tubs* fe_cyl = new G4Tubs("frontElec_cyl", 0.*mm, SV_DE_radius, feThickness, 0*deg, 360*deg);
0630 
0631     G4LogicalVolume* logical_fe = new G4LogicalVolume(fe_cyl, chromium, "frontElec_log", 0,0,0);
0632     
0633     G4VisAttributes fe_colour(G4Colour::Brown());
0634     fe_colour.SetForceSolid(false);
0635     logical_fe -> SetVisAttributes(fe_colour);
0636 
0637     // chromium back-electrode
0638     G4Tubs* fe_cyl_back = new G4Tubs("backElec_cyl", 0.*mm, SV_E_radius, feThickness, 0*deg, 360*deg);
0639 
0640     G4LogicalVolume* logical_fe_back = new G4LogicalVolume(fe_cyl_back, chromium, "backElec_log", 0,0,0);
0641     
0642     logical_fe_back -> SetVisAttributes(fe_colour);
0643 
0644     // p-type diamond
0645     G4double pDthickness = 1.8*um /2.; // p-type diamond dead-layer thickness
0646     
0647     // the p-type diamond layer has the same lateral size as the intrinsic diamond crystals
0648     
0649     G4Box* pD_box = new G4Box("pDiam_box", d_crystal_width, d_crystal_width, pDthickness);
0650     
0651     G4LogicalVolume* logical_pD = new G4LogicalVolume(pD_box, p_diamond, "pDiam_log", 0,0,0);
0652     
0653     G4VisAttributes pDcolour(G4Colour::Blue());
0654     pDcolour.SetForceSolid(false);
0655     logical_pD -> SetVisAttributes(pDcolour);
0656     
0657     // put them in place
0658     G4ThreeVector DE_crystal_position = {0., 0., 0.}; // centre of DE SV is at selected depth position
0659     G4ThreeVector SVposition = {0., 0., 0.}; // the DE sensitive volume will be positioned into the DE crystal.
0660     G4ThreeVector fePosition = {0., 0., SV_DE_thickness + feThickness};
0661     G4ThreeVector pDposition = {0., 0., -SV_DE_thickness - pDthickness};
0662     G4ThreeVector E_crystal_position = {0., 0., -SV_DE_thickness - 2*pDthickness - SV_E_thickness};
0663     G4ThreeVector SV_E_position = {0., 0., 0.}; // the E sensitive volume will be positioned into the E crystal.
0664     G4ThreeVector bePosition = {0., 0., -SV_DE_thickness - 2.*pDthickness - 2.*SV_E_thickness - feThickness};
0665     
0666     // DE crystal
0667     new G4PVPlacement(0, DE_crystal_position, logical_DE_crystal, "DEstageCrystal_phys",
0668                 logical_motherVolumeForDetector,
0669                 false, 0, true);
0670     // DE sensitive volume
0671     new G4PVPlacement(0, SVposition, logical_SV, "SV_DE_phys",
0672                 logical_DE_crystal,
0673                 false, 0, true);
0674     // p-type diamond layer
0675     new G4PVPlacement(0, pDposition, logical_pD, "pD_phys",
0676                 logical_motherVolumeForDetector,
0677                 false, 0, true);
0678     // E crystal
0679     new G4PVPlacement(0, E_crystal_position, logical_E_crystal, "EstageCrystal_phys",
0680                 logical_motherVolumeForDetector,
0681                 false, 0, true);
0682     // E sensitive volume
0683     new G4PVPlacement(0, SV_E_position, logical_SV_Estage, "SV_E_phys",
0684                 logical_E_crystal,
0685                 false, 0, true);
0686     // front-electrode
0687     new G4PVPlacement(0, fePosition, logical_fe, "frontElec_phys",
0688                 logical_motherVolumeForDetector,
0689                 false, 0, true);
0690     // back electrode
0691     new G4PVPlacement(0, bePosition, logical_fe_back, "backElec_phys",
0692                 logical_motherVolumeForDetector,
0693                 false, 0, true);
0694 }
0695 
0696 void DetectorConstruction::ConstructSiliconDetector()
0697 {
0698     nistMan->SetVerbose(1);
0699 
0700     //Define each individual element
0701     //Define Nitrogen
0702     G4double A = 14.01 * g/mole;
0703     G4double Z = 7;
0704     G4Element* elN = new G4Element ("Nitrogen", "N", Z, A);
0705 
0706     //Define Oxygen
0707     A = 16.0 * g/mole;
0708     Z = 8;
0709     G4Element* elO = new G4Element ("Oxygen", "O", Z, A);
0710 
0711     //Define Hydrogen 
0712     A = 1.01 * g/mole;
0713     Z = 1;
0714     G4Element* elH = new G4Element ("Hydrogen", "H", Z, A);
0715 
0716     //Define Carbon
0717     A = 12.01 * g/mole;
0718     Z = 6;
0719     G4Element* elC = new G4Element ("Carbon", "C", Z, A);
0720     
0721     //Define Air   
0722     G4Material* Air = new G4Material("Air", 1.29*mg/cm3, 2);
0723     Air -> AddElement(elN, 70*perCent);
0724     Air -> AddElement(elO, 30*perCent);
0725  
0726     //Define PMMA (C502H8)
0727     // NIST reference 
0728     G4Material* PMMA = new G4Material("PMMA", 1.19*g/cm3, 3);
0729     PMMA -> AddElement(elC, 5);
0730     PMMA -> AddElement(elO, 2);
0731     PMMA -> AddElement(elH, 8);
0732 
0733     //define materials
0734     G4Material* silicon = nistMan->FindOrBuildMaterial("G4_Si");
0735     G4Material* SiO2 = nistMan->FindOrBuildMaterial("G4_SILICON_DIOXIDE");
0736     
0737     
0738      G4double SVspacing = 10.*um;   // distance between the edges of two SV
0739      
0740     // PMMA
0741     G4double PMMA_x = ( detectorSizeWidth*2. + SVspacing*3 ) /2.;
0742     G4double PMMA_y = ( detectorSizeWidth*2. + SVspacing*3 ) /2.;
0743     G4double PMMA_z = detectorSizeThickness /2.;
0744     
0745     G4Box* PMMA_box = new G4Box("PMMA_box", PMMA_x, PMMA_y, PMMA_z);
0746     
0747     G4LogicalVolume* logical_PMMA = new G4LogicalVolume(PMMA_box, PMMA, "PMMA_log", 0,0,0);
0748     
0749     new G4PVPlacement(0, G4ThreeVector(), logical_PMMA, "PMMA_phys",
0750                     logical_motherVolumeForDetector,
0751                     false, 0, true);
0752     
0753     logical_PMMA -> SetVisAttributes(G4VisAttributes(G4Colour(0., 1., 0.)));
0754     
0755     // sensitive volumes
0756     G4double SV_radius = detectorSizeWidth /2.; // full length
0757     G4double SV_thick = detectorSizeThickness /2.;
0758     
0759     G4Tubs* SV_cyl = new G4Tubs("SV_cyl", 0., SV_radius, SV_thick, 0.*deg, 360.*deg);
0760     //G4RotationMatrix* cylRot = new G4RotationMatrix;
0761     //cylRot->rotateY(M_PI/2.*rad);
0762         
0763     G4LogicalVolume* logical_SV = new G4LogicalVolume(SV_cyl, silicon, "SV_log", 0,0,0);
0764     
0765     G4VisAttributes SVcolour(G4Colour(0.5, 0.5, 0.5));
0766     SVcolour.SetForceSolid(true);
0767     logical_SV -> SetVisAttributes(SVcolour);
0768     
0769     G4ThreeVector SVposition;   //if(volumeName != "SV_phys1")
0770     
0771     SVposition = { +SVspacing/2. +SV_radius, +SVspacing/2. +SV_radius, 0. };
0772     new G4PVPlacement(0, SVposition, logical_SV, "SV_phys1",
0773                         logical_PMMA,
0774                         false, 0, true);
0775     /*new G4PVPlacement(cylRot, SVposition, logical_SV, "SV_phys1",
0776                         logical_PMMA,
0777                         false, 0, true);*/
0778 
0779     SVposition = { -SVspacing/2. -SV_radius, +SVspacing/2. +SV_radius, 0. };
0780     new G4PVPlacement(0, SVposition, logical_SV, "SV_phys2",
0781                         logical_PMMA,
0782                         false, 0, true);
0783     
0784     SVposition = { -SVspacing/2. -SV_radius, -SVspacing/2. -SV_radius, 0. };
0785     new G4PVPlacement(0, SVposition, logical_SV, "SV_phys3",
0786                         logical_PMMA,
0787                         false, 0, true);
0788                         
0789     SVposition = { +SVspacing/2. +SV_radius, -SVspacing/2. -SV_radius, 0. };
0790     new G4PVPlacement(0, SVposition, logical_SV, "SV_phys4",
0791                         logical_PMMA,
0792                         false, 0, true);
0793     
0794     // Si02 layer
0795     G4double oxyde_x = PMMA_x;
0796     G4double oxyde_y = PMMA_y;
0797     G4double oxyde_z = 1.*um /2.;
0798     
0799     G4Box* oxyde_box = new G4Box("oxyde_box", oxyde_x, oxyde_y, oxyde_z);
0800     
0801     G4LogicalVolume* logical_oxyde = new G4LogicalVolume(oxyde_box, SiO2, "oxyde_log", 0,0,0);
0802     
0803     G4ThreeVector oxyde_position = G4ThreeVector( 0, 0, -PMMA_z -oxyde_z );
0804     new G4PVPlacement(0, oxyde_position, logical_oxyde, "oxyde_phys",
0805                     logical_motherVolumeForDetector,
0806                     false, 0, true);
0807     
0808     logical_oxyde -> SetVisAttributes(G4VisAttributes(G4Colour(0.6, 0.6, 0.6)));
0809 }
0810 
0811 void DetectorConstruction::ConstructSiliconBridgeDetector()
0812 {
0813 //--------------------------------------------------------
0814 //--------------------- MATERIALS ------------------------
0815 //--------------------------------------------------------  
0816     //Define Water   
0817     //G4Material* Water  = nistMan->FindOrBuildMaterial("G4_WATER");
0818 
0819     //Define Polyethylene
0820     //G4Material* poly  = nistMan->FindOrBuildMaterial("G4_POLYETHYLENE");
0821     
0822     //Define PMMA
0823     //G4Material* perspex  = nistMan->FindOrBuildMaterial("G4_PLEXIGLASS"); //Default 1.19g
0824     
0825     //Define Aluminium
0826     G4Material* Aluminium = nistMan->FindOrBuildMaterial("G4_Al");
0827     
0828     //Define Silicon
0829     G4Material* silicon = nistMan->FindOrBuildMaterial("G4_Si");
0830     
0831     //Define Aluminium Oxide (this is acting as the ceremic)
0832     //G4Material* AlOx = nistMan->FindOrBuildMaterial("G4_ALUMINUM_OXIDE");
0833     
0834     //Define SiO
0835     G4Material* SiO2 = nistMan->FindOrBuildMaterial("G4_SILICON_DIOXIDE");
0836     
0837     //Define Pyrex Glass
0838     //G4Material* PyrexGlass = nistMan->FindOrBuildMaterial("G4_Pyrex_Glass");
0839     
0840 //--------------------------------------------------------
0841 //-------------------- Vis Attributes --------------------
0842 //--------------------------------------------------------  
0843     G4VisAttributes* wireFrameWhiteAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
0844     wireFrameWhiteAtt -> SetVisibility(true);
0845     wireFrameWhiteAtt -> SetForceWireframe(true);
0846     
0847     G4VisAttributes* wireFramePinkAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0)); 
0848     wireFramePinkAtt -> SetVisibility(true);
0849     wireFramePinkAtt -> SetForceWireframe(true);
0850     
0851     G4VisAttributes* solidGreyAtt = new G4VisAttributes(G4Colour(0.5, .5, .5)); 
0852     solidGreyAtt -> SetVisibility(true);
0853     solidGreyAtt -> SetForceSolid(true);
0854     
0855     G4VisAttributes* solidRedAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
0856     solidRedAtt -> SetVisibility(true);
0857     solidRedAtt -> SetForceSolid(true);
0858     
0859     G4VisAttributes* solidGreenAtt = new G4VisAttributes(G4Colour(0.0, 1.0, 0.0));
0860     solidGreenAtt -> SetVisibility(true);
0861     solidGreenAtt -> SetForceSolid(true);
0862     
0863     G4VisAttributes* solidYellowAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0));
0864     solidYellowAtt -> SetVisibility(true);
0865     solidYellowAtt -> SetForceSolid(true);
0866     
0867     G4VisAttributes* solidBlueAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0));
0868     solidBlueAtt -> SetVisibility(true);
0869     solidBlueAtt -> SetForceSolid(true);
0870     
0871 //--------------------------------------------------------
0872 //----------------------- Volumes ------------------------
0873 //--------------------------------------------------------
0874 
0875     G4RotationMatrix* rotMatW = new G4RotationMatrix;
0876     rotMatW->rotateY(0*deg);
0877     rotMatW->rotateX(-90*deg);
0878     rotMatW->rotateZ(0*deg);
0879 
0880 //------------------Detector Mother Volume------------------    
0881     G4double SVheight = detectorSizeThickness;
0882     G4double insulationThickness = 1.*micrometer;
0883     G4double SiOoverlayerBottomThickness = 1.7*micrometer;
0884     G4double AlOverlayerThickness = 1.7*micrometer;
0885     G4double AlOverlayerRadius = 4.*micrometer;
0886     G4double SiOoverlayerTopThickness = 1.43*micrometer;
0887     G4double SiOoverlayerTopRadius = 10.5/2. * micrometer;
0888     G4double overLayerThickness = AlOverlayerThickness + SiOoverlayerTopThickness;
0889 
0890     G4double baseSiThickness = 300.*micrometer;
0891     G4double detectorHeight = (SVheight + baseSiThickness + insulationThickness + SiOoverlayerBottomThickness + AlOverlayerThickness + SiOoverlayerTopThickness);
0892 
0893     G4double SVwidth = detectorSizeWidth;
0894     G4double pitch = 20.*micrometer; //distance between the odd and even rows
0895 
0896     G4double bridgingWidth = 20.*micrometer;
0897     G4double bridgingLength = 15.*micrometer;
0898     G4double bridingHeight = SVheight;
0899 
0900     G4double numberOfRows = 59;
0901     G4double numberOfColumns = (24*3);
0902     G4double SVareaWidth = (numberOfColumns * (SVwidth + bridgingWidth)) - 1.*bridgingWidth;
0903     G4double SVareaLength = numberOfRows*(SVwidth + pitch) - 1.*pitch;
0904     G4double bufferWidth = 100.*micrometer;
0905     G4double detectorWidth = SVareaWidth + bufferWidth;
0906     G4double detectorLength = SVareaLength + bufferWidth;
0907     
0908 //------------------Smaller Detector Mother Volume------------------    
0909     G4Box* detectorBox = new G4Box("detectorBox", detectorWidth/2., detectorHeight/2., detectorLength/2.);
0910     G4LogicalVolume* logicalDetectorReg = new G4LogicalVolume(detectorBox, materialOfMotherVolume, "detectorReg_log", 0,0,0);
0911     new G4PVPlacement(rotMatW, G4ThreeVector(0,0,0), logicalDetectorReg, "detectorRegPhys", logical_motherVolumeForDetector , false, 0, true);
0912 
0913     logicalDetectorReg -> SetVisAttributes(wireFrameWhiteAtt);
0914     
0915 //------------------Base Silicon Volume----------------------
0916     G4Box* basSiBox = new G4Box("baseSiBox", detectorWidth/2., baseSiThickness/2., detectorLength/2.);
0917     G4LogicalVolume* logicalbaseSi = new G4LogicalVolume(basSiBox, silicon, "baseSi_log", 0,0,0);
0918     new G4PVPlacement(0, G4ThreeVector(0,(-detectorHeight/2. + baseSiThickness/2.),0), logicalbaseSi, "baseSiPhys", logicalDetectorReg, false, 0, true);
0919     
0920     logicalbaseSi -> SetVisAttributes(wireFramePinkAtt);
0921 
0922 //---------------------Insulation Volume----------------------
0923     G4Box* SiOBox = new G4Box("SiOBox", detectorWidth/2., insulationThickness/2., detectorLength/2.);
0924     G4LogicalVolume* logicalSoI = new G4LogicalVolume(SiOBox, SiO2, "SoI_log", 0,0,0);
0925     new G4PVPlacement(0, G4ThreeVector(0,(detectorHeight/2. -overLayerThickness - SVheight - insulationThickness/2.),0), logicalSoI, "SoIPhys", logicalDetectorReg, false, 0, true);
0926 
0927     logicalSoI -> SetVisAttributes(solidGreyAtt);
0928 
0929 //----------------Sensitive Volume Region---------------------
0930 //This volume encapsulates the SVs and the "bridging" volumes
0931     G4Box* SVregBox = new G4Box("SVregBox", detectorWidth/2., SVheight/2., detectorLength/2.);
0932     G4LogicalVolume* logicalSVreg = new G4LogicalVolume(SVregBox, materialOfMotherVolume, "SVreg_log", 0,0,0);
0933     new G4PVPlacement(0, G4ThreeVector(0,(detectorHeight/2. - overLayerThickness - SVheight/2.),0), logicalSVreg, "SVregPhys", logicalDetectorReg, false, 0, true);
0934 
0935     logicalSVreg -> SetVisAttributes(wireFrameWhiteAtt);
0936 
0937 //----------------------Bridging Volume----------------------
0938 //This volume connects or "bridges" the main sensitive volumes 
0939 //together but effectively act as additional sensitive volumes
0940     G4Box* bridgeVolBox = new G4Box("bridgeVolBox", bridgingWidth/2., bridingHeight/2., bridgingLength/2.);
0941     G4LogicalVolume* logicalBridgeVol = new G4LogicalVolume(bridgeVolBox, silicon, "bridgeVol_log", 0,0,0);
0942 
0943     logicalBridgeVol -> SetVisAttributes(solidRedAtt);
0944     
0945 //---------------------SiO Bottom Overlayer------------------
0946     G4Box* SiObotLayerBox = new G4Box("SiObotLayerBox", SVwidth/2., SiOoverlayerBottomThickness/2., SVwidth/2.);
0947     G4LogicalVolume* logicalSiObotLayer = new G4LogicalVolume(SiObotLayerBox, SiO2, "logicalSiObotLayer", 0,0,0);
0948 
0949     logicalSiObotLayer -> SetVisAttributes(solidGreenAtt);
0950     
0951 //--------------SiO Bottom Overlayer Bridging Vol-------------
0952     G4Box* SiObotLayerBridgeBox = new G4Box("SiObotLayerBridgeBox", bridgingWidth/2., SiOoverlayerBottomThickness/2., bridgingLength/2.);
0953     G4LogicalVolume* logicalSiObotLayerBridge = new G4LogicalVolume(SiObotLayerBridgeBox, SiO2, "logicalSiObotLayer", 0,0,0);
0954 
0955     logicalSiObotLayerBridge -> SetVisAttributes(solidGreenAtt);
0956 
0957 //-----------------------Al contact ---------------------------
0958     G4Box* AlContactBox = new G4Box("AlContactBox", AlOverlayerRadius, AlOverlayerThickness/2., AlOverlayerRadius);
0959     G4LogicalVolume* logicalAlContact = new G4LogicalVolume(AlContactBox, Aluminium, "logicalAlContact", 0,0,0);
0960 
0961     logicalAlContact -> SetVisAttributes(solidYellowAtt);
0962 
0963 //----------------------SiO Top Overlayer---------------------- 
0964     G4Box* SiOtopLayerBox = new G4Box("SiOtopLayerBox", SiOoverlayerTopRadius, SiOoverlayerTopThickness/2., SiOoverlayerTopRadius);
0965     G4LogicalVolume* logicalSiOtopLayer = new G4LogicalVolume(SiOtopLayerBox, SiO2, "logicalSiOtopLayer", 0,0,0);
0966 
0967     logicalSiOtopLayer -> SetVisAttributes(solidBlueAtt);
0968 
0969 //--------------------Sensitive Volume--------------------------
0970     G4Box* sensitiveBridgeVolume = new G4Box("water_region_sphere", SVwidth/2., SVheight/2., SVwidth/2.);
0971     G4LogicalVolume* SV_log = new G4LogicalVolume(sensitiveBridgeVolume, silicon, "SV_log", 0,0,0);
0972 
0973     SV_log -> SetVisAttributes(solidYellowAtt);
0974     
0975 //---Placing SVs, 30x30 volumes and "bridging" volumes between them
0976 
0977     G4bool checkSVoverlap = false;
0978     
0979     //Placing "odd" SV rows/columns
0980     G4int globalCount = 100000;  
0981     
0982     for (G4double j = -SVareaLength/2.; j <= SVareaLength/2.; j+=2.*(SVwidth + bridgingWidth)) //creates each row
0983     {
0984         for (G4double i = -SVareaWidth/2.; i <= SVareaWidth/2.; i+=(SVwidth + bridgingWidth)) //goes through each odd row
0985         {
0986             //G4cout << "x: " << i/um << " z: " << j/um << G4endl;
0987             new G4PVPlacement(0, G4ThreeVector(i,0,j), SV_log , "physSensitiveBridgeVolume", logicalSVreg, false, globalCount, checkSVoverlap);
0988             
0989             new G4PVPlacement(0, G4ThreeVector(i,((detectorHeight/2. -overLayerThickness + SiOoverlayerBottomThickness/2.)),j), logicalSiObotLayer, "physSiObotLayer", logicalDetectorReg, false, globalCount, checkSVoverlap);
0990             
0991             new G4PVPlacement(0, G4ThreeVector(i,((detectorHeight/2. -overLayerThickness + SiOoverlayerBottomThickness + SiOoverlayerTopThickness/2.)),j), logicalSiOtopLayer, "physSiOtopLayer", logicalDetectorReg, false, globalCount, checkSVoverlap);
0992             
0993             globalCount++;  
0994         }
0995     }
0996     
0997     //Placing "even" SV rows/columns
0998     globalCount = 200000;  
0999     
1000     for (G4double j = (-SVareaLength/2. + SVwidth + bridgingWidth); j <= SVareaLength/2.; j+=2.*(SVwidth + bridgingWidth)) //creates each row
1001     {
1002         for (G4double i = -SVareaWidth/2.; i <= SVareaWidth/2.; i+=(SVwidth + bridgingWidth)) //goes through each odd row
1003         {
1004             //G4cout << "x: " << i/micrometer << " z: " << j/micrometer << G4endl;
1005 
1006             new G4PVPlacement(0, G4ThreeVector(i,0,j), SV_log , "physSensitiveBridgeVolume", logicalSVreg, false, globalCount, checkSVoverlap);
1007             
1008             new G4PVPlacement(0, G4ThreeVector(i,((detectorHeight/2. -overLayerThickness + SiOoverlayerBottomThickness/2.)),j), logicalSiObotLayer, "physSiObotLayer", logicalDetectorReg, false, globalCount, checkSVoverlap);
1009             
1010             new G4PVPlacement(0, G4ThreeVector(i,((detectorHeight/2. -overLayerThickness + SiOoverlayerBottomThickness + SiOoverlayerTopThickness/2.)),j), logicalSiOtopLayer, "physSiOtopLayer", logicalDetectorReg, false, globalCount, checkSVoverlap);
1011             
1012             globalCount++;
1013         }
1014     }
1015 
1016     //Placing "odd" bridging volumes rows/columns
1017     globalCount = 300000;
1018 
1019     for (G4double j = -SVareaLength/2.; j < SVareaLength/2.; j+=2.*(SVwidth + bridgingWidth)) //creates each row
1020     {
1021         for (G4double i = -SVareaWidth/2.; i < SVareaWidth/2.; i+=(SVwidth + bridgingWidth)) //goes through each odd row
1022         {
1023         if ( (i + (SVwidth + bridgingWidth)) < SVareaWidth/2.)
1024         {
1025             //G4cout << globalCount << G4endl;
1026             new G4PVPlacement(0, G4ThreeVector((i + SVwidth/2. + bridgingWidth/2.),0,(j+ bridgingLength/2.)), logicalBridgeVol , "sen_bridge", logicalSVreg, false, globalCount, checkSVoverlap);
1027             
1028             new G4PVPlacement(0, G4ThreeVector((i + SVwidth/2. + bridgingWidth/2.),((detectorHeight/2. -overLayerThickness + SiOoverlayerBottomThickness/2.)),(j+ bridgingLength/2.)), logicalSiObotLayerBridge, "physSiObotLayerBridge", logicalDetectorReg, false, globalCount, checkSVoverlap);
1029             
1030             //G4cout << "x: " << (i + SVwidth/2. + bridgingWidth/2.)/micrometer << " z: " << j/micrometer << G4endl;
1031             
1032             globalCount++;
1033         }   
1034         }
1035     }
1036 
1037     //Placing "even" bridging rows/columns
1038     globalCount = 400000;  
1039 
1040     for (G4double j = (-SVareaLength/2. + SVwidth + bridgingWidth); j < SVareaLength/2.; j+=2.*(SVwidth + bridgingWidth)) //creates each row
1041     {
1042         for (G4double i = -SVareaWidth/2.; i < SVareaWidth/2.; i+=(SVwidth + bridgingWidth)) //goes through each odd row
1043         {
1044         
1045         if ( (i+ (SVwidth + bridgingWidth)) < SVareaWidth/2.)
1046         {   
1047             //G4cout << globalCount << G4endl;
1048             new G4PVPlacement(0, G4ThreeVector((i + SVwidth/2. + bridgingWidth/2.),0,(j+ bridgingLength/2.)), logicalBridgeVol , "sen_bridge", logicalSVreg, false, globalCount, checkSVoverlap);
1049             
1050             //G4cout << "x: " << (i + SVwidth/2. + bridgingWidth/2.)/micrometer << " z: " << j/micrometer << G4endl;
1051             
1052             new G4PVPlacement(0, G4ThreeVector((i + SVwidth/2. + bridgingWidth/2.),((detectorHeight/2. -overLayerThickness + SiOoverlayerBottomThickness/2.)),(j+ bridgingLength/2.)), logicalSiObotLayerBridge, "physSiObotLayerBridge", logicalDetectorReg, false, globalCount, checkSVoverlap);
1053             
1054             globalCount++;
1055         }
1056             
1057         }
1058     }
1059     
1060 //----------------------------------------
1061     new G4PVPlacement(0, G4ThreeVector(0,0,0), logicalAlContact, "physAlContact", logicalSiObotLayer, false, 0, 1);
1062 }
1063 
1064 
1065 void DetectorConstruction::ConstructSiC()
1066 {
1067 
1068 //Define SiC
1069  G4double A = 12.01 * g/mole;
1070  G4double Z = 6;
1071 G4double A_Si=28.086*g/mole;
1072  G4double Z_Si=14;
1073 G4double density_SiC=3.22*g/cm3;
1074 G4Element *Si=new G4Element("Silicum","Si",Z_Si,A_Si);
1075 G4Element *C=new G4Element("Carbon","C",Z,A);
1076 G4Material *SiC=new G4Material("SiC", density_SiC,2);
1077 SiC->AddElement(Si,1);
1078 SiC->AddElement(C,1);
1079 
1080 /*G4Material *airNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes);
1081   G4Material *Silicon = G4NistManager::Instance()->FindOrBuildMaterial("G4_Si", isotopes);*/
1082 
1083     
1084 detectorSizeWidth=0.1*mm;
1085  detectorSizeThickness=22*um;//10*um;
1086 
1087  G4double substrate_thickness=370*um;
1088  
1089  G4double SV_x = detectorSizeWidth/2;
1090  G4double SV_y = detectorSizeWidth/2;
1091  G4double SV_z = detectorSizeThickness/2; 
1092 
1093  G4Box* SV_box = new G4Box("SV_box",SV_x,SV_y,SV_z);
1094 
1095  G4LogicalVolume* logical_SV = new G4LogicalVolume(SV_box, SiC, "SV_log", 0,0,0);
1096 
1097  new G4PVPlacement(0, G4ThreeVector(0*mm,0*mm,-SV_z), logical_SV,"SV_phys1",
1098             logical_motherVolumeForDetector,false, 0, true);
1099 
1100 
1101  G4Box* Substrate_box = new G4Box("Substrate_box",SV_x,SV_y,substrate_thickness/2); 
1102 
1103  
1104   G4LogicalVolume* logical_substrate = new G4LogicalVolume(Substrate_box, SiC, "substrate_log", 0,0,0);
1105 
1106   new G4PVPlacement(0, G4ThreeVector(0,0,-2*SV_z-substrate_thickness/2), logical_substrate,"substrate_phys",
1107               logical_motherVolumeForDetector, 
1108               false, 0, true);
1109    
1110  
1111 // Visualisation attributes
1112 
1113     G4VisAttributes vis_SV(G4Colour(198, 226, 255));
1114     vis_SV.SetForceSolid(true);
1115     logical_SV -> SetVisAttributes(vis_SV);
1116 }
1117 
1118 
1119 
1120 void DetectorConstruction::ConstructSDandField()
1121 {
1122    SensitiveDetector* SD = new SensitiveDetector("SD", "DetectorHitsCollection", true, analysis);
1123    G4SDManager::GetSDMpointer()->AddNewDetector(SD);
1124    SetSensitiveDetector("SV_log", SD);
1125 
1126     if (detectorType == "SiliconBridge")
1127     {
1128         SetSensitiveDetector("bridgeVol_log", SD);
1129     }
1130     else if (detectorType == "DiamondTelescope")
1131     {
1132         SensitiveDetector* SDs2 = new SensitiveDetector("SDs2", "DetectorStage2HitsCollection", false, analysis);
1133         G4SDManager::GetSDMpointer()->AddNewDetector(SDs2);
1134         SetSensitiveDetector("SV_Estage_log", SDs2);
1135     }
1136 }