Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-08 07:52:18

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