Back to home page

EIC code displayed by LXR

 
 

    


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

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