Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/advanced/exp_microdosimetry/src/DetectorConstruction.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 //
  2 // ********************************************************************
  3 // * License and Disclaimer                                           *
  4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.                             *
 10 // *                                                                  *
 11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                                                  *
 18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // ********************************************************************
 25 //
 26 // Authors: Susanna Guatelli and Francesco Romano
 27 // susanna@uow.edu.au, francesco.romano@ct.infn.it
 28 
 29 // Modified by Jacopo Magini: j.magini@surrey.ac.uk
 30 
 31 // Modified by David Bolst: db001@uowmail.edu.au
 32 // Added geometry of "bridge" microdosimeter (ConstructSiliconBridgeDetector())
 33 
 34 #include "DetectorConstruction.hh"
 35 #include "globals.hh"
 36 #include "G4Element.hh"
 37 #include "G4Material.hh"
 38 #include "G4PVPlacement.hh"
 39 #include "G4LogicalVolume.hh"
 40 #include "G4Box.hh"
 41 #include "G4Tubs.hh"
 42 //#include "G4SubtractionSolid.hh"
 43 #include "G4FieldManager.hh"
 44 #include "G4TransportationManager.hh"
 45 #include "G4ChordFinder.hh"
 46 #include "G4Colour.hh"
 47 #include "G4VisAttributes.hh"
 48 #include "SensitiveDetector.hh"
 49 #include "G4SDManager.hh"
 50 #include "G4UserLimits.hh"
 51 #include "Randomize.hh"
 52 #include "G4ThreeVector.hh"
 53 #include "G4GeometryTolerance.hh"
 54 #include "G4GeometryManager.hh"
 55 #include "G4SystemOfUnits.hh"
 56 #include "G4NistManager.hh"
 57 
 58 DetectorConstruction::DetectorConstruction(AnalysisManager* analysis_manager, DetectorMessenger* detector_messenger)
 59 {
 60   analysis = analysis_manager;
 61   messenger = detector_messenger;
 62   
 63   detectorType = messenger -> GetDetectorType();
 64   detectorSizeWidth = messenger -> GetDetectorSizeWidth();
 65   detectorSizeThickness = messenger -> GetDetectorSizeThickness();
 66   secondStageSizeDim = messenger -> GetSecondStageSizeWidth();
 67   secondStageSizeThickness = messenger -> GetSecondStageSizeThickness();
 68   
 69   usingWaterPhantom = messenger -> IsPhantomEnabled();
 70   
 71   detectorPositionDepth = messenger -> GetDetectorPositionDepth();
 72   
 73   nistMan = G4NistManager::Instance();
 74 }
 75 
 76 DetectorConstruction::~DetectorConstruction(){
 77 
 78 }
 79 
 80 G4VPhysicalVolume* DetectorConstruction::Construct()
 81 {
 82   if( usingWaterPhantom == true ) ConstructWorldWithWaterPhantom(); // for medical applications
 83   else ConstructVacuumWorld(); // space applications
 84   
 85   if( detectorType == "Diamond" ) ConstructDiamondDetector();
 86   else if( detectorType == "MicroDiamond" ) ConstructMicroDiamondDetector();
 87   else if( detectorType == "Silicon" ) ConstructSiliconDetector();
 88   else if( detectorType == "SiliconBridge" ) ConstructSiliconBridgeDetector();
 89   else if( detectorType == "DiamondTelescope" ) ConstructDiamondTelescope();
 90   else if( detectorType ==  "SiCDetector") ConstructSiC();
 91   else
 92   {
 93     G4cout << "ERROR: " << detectorType << " is not an allowed detector type. ";
 94     return 0;
 95   }
 96   
 97   return physical_world;
 98 }
 99 
100 void DetectorConstruction::ConstructWorldWithWaterPhantom()
101 {
102   //Define materials
103   G4Material* air  = nistMan->FindOrBuildMaterial("G4_AIR");
104   G4Material* water = G4NistManager::Instance()->FindOrBuildMaterial("G4_WATER");
105   
106   G4double phantomWidth = 5.*cm;
107   G4double phantomLength = detectorPositionDepth + 2.*cm;
108   
109   G4double worldWidth = phantomWidth + 5*cm;
110   G4double worldLength = phantomLength*2;
111   
112   // In a clinical setup, the water phantom is surrounded by air
113   G4Box* world = new G4Box("world_box", worldWidth/2, worldWidth/2, worldLength/2);
114   G4LogicalVolume* logical_world = new G4LogicalVolume(world, air, "world_log", 0,0,0);
115   
116   //set the logical world volume invisible
117   logical_world -> SetVisAttributes(G4VisAttributes::GetInvisible());
118   
119   physical_world = new G4PVPlacement(0,
120                 G4ThreeVector(),
121                 logical_world, 
122                 "world_phys",
123                 0, 
124                 false, 
125                 0);
126   
127   G4Box* phantom_box = new G4Box("phantom_box", phantomWidth/2, phantomWidth/2, phantomLength/2);
128   G4LogicalVolume* logical_phantom = new G4LogicalVolume(phantom_box, water, "phantom_log", 0,0,0);
129   
130   //the water phantom starts at z=0
131   G4ThreeVector phantom_position = G4ThreeVector( 0., 0., -phantomLength/2 );
132   
133    new G4PVPlacement(0, phantom_position, logical_phantom,"phantom_phys",
134         logical_world, 
135         false, 0, 0);
136    
137    logical_phantom -> SetVisAttributes(G4VisAttributes(G4Colour(0., 0.2, 0.6)));
138    
139    // smaller inner volume where the detector will be placed
140   G4double innerSize = 2.*cm;
141   G4Box* inner_box = new G4Box("inner_box", innerSize/2, innerSize/2, innerSize/2);
142   G4LogicalVolume* logical_inner = new G4LogicalVolume(inner_box, water, "inner_log",0,0,0);
143   
144   G4double innerDepth = phantomLength/2 -detectorPositionDepth;
145   G4ThreeVector inner_position = G4ThreeVector( 0 , 0 , innerDepth );
146   new G4PVPlacement(0, inner_position, logical_inner,"inner_phys",
147         logical_phantom, 
148         false, 0, 0);
149   
150   logical_inner -> SetVisAttributes(G4VisAttributes::GetInvisible());
151   
152   // private member of DetectorConstruction,
153   // needed as mother volume for Construct*Detector()
154   logical_motherVolumeForDetector = logical_inner;
155   materialOfMotherVolume = water;
156   
157   // uncomment to enable a G4Region for the inner volume
158   // e.g. in order to set different cuts
159   //G4Region* inner_region = new G4Region("inner_region");
160   //inner_region -> AddRootLogicalVolume( logical_highPVol );
161 }
162 
163 void DetectorConstruction::ConstructVacuumWorld()
164 {
165     //Define Vacuum
166   G4double Z = 1.;
167   G4double A = 1.01*g/mole;
168   G4double vacuumDensity = 1.e-25 *g/cm3;
169   G4double pressure = 3.e-18*pascal;
170   G4double temperature = 2.73*kelvin;
171   G4Material* vacuum = new G4Material("Galactic", Z, A,
172              vacuumDensity,kStateGas,temperature,pressure);
173   
174   G4double worldSize = 10.*cm;
175   
176   G4Box* world_box = new G4Box("world_box", worldSize/2, worldSize/2, worldSize/2);
177   G4LogicalVolume* logical_world = new G4LogicalVolume(world_box, vacuum, "world_log",0,0,0);
178   physical_world = new G4PVPlacement(0,
179                 G4ThreeVector(),
180                 logical_world, 
181                 "world_phys",
182                 0, 
183                 false, 
184                 0);
185   
186   logical_world -> SetVisAttributes(G4VisAttributes::GetInvisible());
187   
188   logical_motherVolumeForDetector = logical_world;
189   materialOfMotherVolume = vacuum;
190 }
191 
192 void DetectorConstruction::ConstructDiamondDetector()
193 {
194 
195 //Define each individual element
196 //Define Oxygen
197  G4double A = 16.0 * g/mole;
198  G4double Z = 8;
199  G4Element* elO = new G4Element ("Oxygen", "O", Z, A);
200 
201 //Define Hydrogen 
202  A = 1.01 * g/mole;
203  Z = 1;
204  G4Element* elH = new G4Element ("Hydrogen", "H", Z, A);
205 
206 //Define Boron
207  A = 10.8 * g/mole;
208  Z = 5;
209  G4Element* elB = new G4Element ("Boron", "B", Z, A);
210 
211 //Define Carbon
212  A = 12.01 * g/mole;
213  Z = 6;
214  G4Element* elC = new G4Element ("Carbon", "C", Z, A);
215 
216 //Define diamond
217  A = 12.01 * g/mole;
218  Z = 6;
219  G4Material* diamond = new G4Material("diamond", Z, A, 3.515*g/cm3);
220       
221 //Define dopant (boron doped diamond)
222  G4Material* dopant = new G4Material("dopant", 3.514*g/cm3, 2);
223  dopant -> AddElement(elC, 99.9994*perCent);
224  dopant -> AddElement(elB, 0.0006*perCent);
225 
226  //Define Aluminium contacts (AlContact)
227  A = 26.981 * g/mole;
228  Z = 13;
229  G4Material* AlContact = new G4Material("AlContact", Z, A, 2.7 *g/cm3);
230 
231  //Define Gold contact (AuContact)
232  A = 196.97 * g/mole;
233  Z = 79;
234  G4Material* AuContact = new G4Material("AuContact", Z, A, 19.3 *g/cm3);
235  
236  //Define PMMA (C502H8)
237  // NIST reference 
238  G4Material* PMMA = new G4Material("PMMA", 1.19*g/cm3, 3);
239  PMMA -> AddElement(elC, 5);
240  PMMA -> AddElement(elO, 2);
241  PMMA -> AddElement(elH, 8);
242 
243  
244  // Define the geometry of the diamond microdosimeter
245  // mother volume of the detector components
246  G4double DiaVol_x = 300*micrometer;
247  G4double DiaVol_y = 240*micrometer;
248  G4double DiaVol_z = 150*micrometer; 
249 
250  G4Box* DiaVol_box = new G4Box("DiaVol_box",DiaVol_x,DiaVol_y,DiaVol_z);
251 
252  G4LogicalVolume* logical_DiaVol = new G4LogicalVolume(DiaVol_box, diamond, "DiaVol_log", 0,0,0);
253  
254  G4ThreeVector DiaVol_position = {0, 0, -DiaVol_z +detectorSizeThickness/2};
255 
256  new G4PVPlacement(0, DiaVol_position, logical_DiaVol,"DiaVol_phys",
257         logical_motherVolumeForDetector, 
258         false, 0, true);
259 
260  //VacBlock for contact placement
261  G4double vacblock_x = 300*um;
262  G4double vacblock_y = 240*um;
263  G4double vacblock_z = 0.25*um; 
264 
265  // vacuum (or water) box to place other volumes in
266  G4Box* vacblock_box = new G4Box("vacblock_box",vacblock_x,vacblock_y,vacblock_z);
267 
268  G4LogicalVolume* logical_vacblock = new G4LogicalVolume(vacblock_box, materialOfMotherVolume, "vacblock_log", 0,0,0);
269 
270  new G4PVPlacement(0, 
271              G4ThreeVector(0,0,DiaVol_z - vacblock_z),
272        logical_vacblock,
273              "vacblock_phys",
274              logical_DiaVol, 
275              false, 
276              0, true);
277 //Bdl in DiaVol
278  G4double Bdl_x = 300*micrometer;
279  G4double Bdl_y = 240*micrometer;
280  G4double Bdl_z = detectorSizeThickness/2; 
281   
282  G4Box* Bdl_box = new G4Box("Bdl_box",Bdl_x,Bdl_y,Bdl_z);
283 
284  G4LogicalVolume* logical_Bdl = new G4LogicalVolume(Bdl_box, dopant, "Bdl_log", 0,0,0);
285 
286  new G4PVPlacement(0, 
287        G4ThreeVector(0,0,DiaVol_z - Bdl_z - vacblock_z- vacblock_z),
288        logical_Bdl,
289        "Bdl_phys",
290              logical_DiaVol,   //mother volume 
291                    false, 
292        0, true);
293 
294  //Diamond SV
295  G4double SV_x = detectorSizeWidth/2;
296  G4double SV_y = detectorSizeWidth/2;
297  G4double SV_z = Bdl_z; 
298 
299  G4Box* SV_box = new G4Box("SV_box",SV_x,SV_y,SV_z);
300 
301  G4LogicalVolume* logical_SV = new G4LogicalVolume(SV_box, diamond, "SV_log", 0,0,0);
302 
303  new G4PVPlacement(0, G4ThreeVector(-45*um,105*um,0*um), logical_SV,"SV_phys1",
304         logical_Bdl,false, 0, true);
305 
306  new G4PVPlacement(0, G4ThreeVector(165*um,105*um,0*um), logical_SV,"SV_phys2",
307        logical_Bdl, false, 0, true);
308 
309  new G4PVPlacement(0, G4ThreeVector(-45*um,-105*um,0*um),logical_SV,"SV_phys3", 
310        logical_Bdl, false, 0, true);
311 
312  new G4PVPlacement(0, G4ThreeVector(165*um,-105*um,0*um),logical_SV,"SV_phys4",
313        logical_Bdl, false, 0, true);
314 
315 //Al strips
316 //10 nm thickness 
317  G4double AlStrip_x = 240*um;
318  G4double AlStrip_y = 240*um;
319  G4double AlStrip_z = vacblock_z; 
320 
321  G4Box* AlStrip = new G4Box("AlStrip",AlStrip_x,AlStrip_y,AlStrip_z);
322 
323  G4LogicalVolume* logical_AlStrip = new G4LogicalVolume(AlStrip, AlContact, "AlStrip_log", 0,0,0);
324 
325  new G4PVPlacement(0, G4ThreeVector(60*um,0,0), logical_AlStrip, "AlStrip_phys",
326                    logical_vacblock, false, 0, true);
327 
328 //gold cylinder in vacblock
329  G4double innerRadiusOfTheTube1 = 0.*um;
330  G4double outerRadiusOfTheTube1 = 45.*um;
331  G4double heightOfTheTube1 = 10*nm;
332  G4double startAngleOfTheTube1 = 0.*deg;
333  G4double spanningAngleOfTheTube1 = 360.*deg;
334 
335  G4Tubs* GoldCylinder1 = new G4Tubs("GoldCylinder1", innerRadiusOfTheTube1, 
336                         outerRadiusOfTheTube1,
337                         heightOfTheTube1,
338                         startAngleOfTheTube1, 
339                         spanningAngleOfTheTube1);
340   
341  G4LogicalVolume* logical_GoldCylinder1 = new G4LogicalVolume(GoldCylinder1, AuContact, "GoldCylinder1_log", 0,0,0);
342 
343  new G4PVPlacement(0,G4ThreeVector(-245*um,0,-vacblock_z + heightOfTheTube1),
344                    logical_GoldCylinder1,
345              "GoldCylinder1_phys",
346              logical_vacblock, false, 0, true);
347 
348 //gold contacts
349  G4double innerRadiusOfTheTube2 = 0.*um;
350  G4double outerRadiusOfTheTube2 = 45.*um;
351  G4double heightOfTheTube2 = Bdl_z;
352  G4double startAngleOfTheTube2 = 0.*deg;
353  G4double spanningAngleOfTheTube2 = 360.*deg;
354 
355  G4Tubs* GoldCylinder2 = new G4Tubs("GoldCylinder2",
356                         innerRadiusOfTheTube2, 
357                         outerRadiusOfTheTube2,
358                         heightOfTheTube2,
359                         startAngleOfTheTube2, 
360                         spanningAngleOfTheTube2);
361   
362  G4LogicalVolume* logical_GoldCylinder2 = new G4LogicalVolume(GoldCylinder2, AuContact, "GoldCylinder2_log", 0,0,0);
363 
364  new G4PVPlacement(0, G4ThreeVector(-245*um,0,0), logical_GoldCylinder2, "GoldCylinder2_phys",
365        logical_Bdl, false, 0, true);
366 
367 //gold cylinder in DiaVol
368  G4double innerRadiusOfTheTube3 = 0.*um;
369  G4double outerRadiusOfTheTube3 = 45.*um;
370  G4double heightOfTheTube3 = 75.*um -heightOfTheTube2 - heightOfTheTube1 ;
371  G4double startAngleOfTheTube3 = 0.*deg;
372  G4double spanningAngleOfTheTube3 = 360.*deg;
373 
374  G4Tubs* GoldCylinder3 = new G4Tubs("GoldCylinder3",
375                         innerRadiusOfTheTube3, 
376                         outerRadiusOfTheTube3,
377                         heightOfTheTube3,
378                         startAngleOfTheTube3, 
379                         spanningAngleOfTheTube3);
380   
381 G4LogicalVolume* logical_GoldCylinder3 = new G4LogicalVolume(GoldCylinder3, AuContact, "GoldCylinder3_log", 0,0,0);
382 
383 new G4PVPlacement(0, G4ThreeVector(-245*um,0,DiaVol_z - heightOfTheTube3 - Bdl_z - Bdl_z - vacblock_z- vacblock_z),
384              logical_GoldCylinder3,
385              "GoldCylinder3_phys",
386              logical_DiaVol, 
387              false, 
388              0, true);
389 
390 // Visualisation attributes
391 
392         logical_DiaVol -> SetVisAttributes(G4VisAttributes(G4Colour(255,255,255))); //white
393   logical_Bdl -> SetVisAttributes(G4VisAttributes(G4Colour(0,255,0)));        //green
394   
395   G4VisAttributes vis_SV(G4Colour(198, 226, 255));
396   vis_SV.SetForceSolid(true);
397   logical_SV -> SetVisAttributes(vis_SV);
398         logical_vacblock -> SetVisAttributes(G4VisAttributes::GetInvisible());    
399   logical_AlStrip -> SetVisAttributes(G4VisAttributes(G4Colour(0, 255, 255)));//cyan
400   
401   G4VisAttributes vis_GoldCylinder1(G4Colour(255, 255, 0));                    
402   vis_GoldCylinder1.SetForceAuxEdgeVisible(true);
403   logical_GoldCylinder1 -> SetVisAttributes(vis_GoldCylinder1);
404   
405   G4VisAttributes vis_GoldCylinder2(G4Colour(255, 255, 0));                    
406   vis_GoldCylinder2.SetForceAuxEdgeVisible(true);
407   logical_GoldCylinder2 -> SetVisAttributes(vis_GoldCylinder2); 
408   
409   G4VisAttributes vis_GoldCylinder3(G4Colour(255, 255, 0));                    
410   vis_GoldCylinder3.SetForceAuxEdgeVisible(true);
411   logical_GoldCylinder3 -> SetVisAttributes(vis_GoldCylinder3); 
412   
413 // no need to return the following, it's been stored earlier!
414 //return physical_world; 
415 
416 }
417 
418 void DetectorConstruction::ConstructMicroDiamondDetector()
419 {
420   //Define each individual element
421   //Define Boron
422   G4double A = 10.8 * g/mole;
423   G4double Z = 5;
424   G4Element* elB = new G4Element ("Boron", "B", Z, A);
425 
426   //Define Carbon
427   A = 12.01 * g/mole;
428   Z = 6;
429   G4Element* elC = new G4Element ("Carbon", "C", Z, A);
430 
431   //Define diamond
432   A = 12.01 * g/mole;
433   Z = 6;
434   G4Material* diamond = new G4Material("diamond", Z, A, 3.515*g/cm3);
435       
436   //Define p-type diamond (boron doped diamond)
437   G4Material* p_diamond = new G4Material("p_diamond", 3.514*g/cm3, 2);
438   // Boron concentration used is 1e20 cm-3, considering the diamond density and a Boron atomic weight of 10.811u
439   p_diamond -> AddElement(elC, 99.94887*perCent);
440   p_diamond -> AddElement(elB, 0.05113*perCent);
441 
442   //Define chromium contact
443   G4Material* chromium = nistMan->FindOrBuildMaterial("G4_Cr");
444 
445   // sentive volume
446   G4double SVside = detectorSizeWidth /2.;
447   G4double SVthickness = detectorSizeThickness /2.;
448   G4double SVspacing = 200.*um; //edge-edge distance
449   
450   G4Box* SV_box = new G4Box("SV_box", SVside, SVside, SVthickness);
451 
452   G4LogicalVolume* logical_SV = new G4LogicalVolume(SV_box, diamond, "SV_log", 0,0,0);
453   
454   G4VisAttributes SVcolour(G4Colour(0.5, 0.5, 0.5));
455   SVcolour.SetForceSolid(true);
456   logical_SV -> SetVisAttributes(SVcolour);
457 
458   // chromium front-electrode
459   G4double feThickness = 50.*nm /2.; // front-electrode thickness
460 
461   G4Box* fe_box = new G4Box("frontElec_box", SVside, SVside, feThickness);
462 
463   G4LogicalVolume* logical_fe = new G4LogicalVolume(fe_box, chromium, "frontElec_log", 0,0,0);
464   
465   G4VisAttributes fe_colour(G4Colour::Brown());
466   fe_colour.SetForceSolid(false);
467   logical_fe -> SetVisAttributes(fe_colour);
468   
469   // p-type diamond
470   G4double pDthickness = 1.*um /2.; // p-type diamond back-electrode thickness
471   
472   G4Box* pD_box = new G4Box("pDiam_box", SVside, SVside, pDthickness);
473   
474   G4LogicalVolume* logical_pD = new G4LogicalVolume(pD_box, p_diamond, "pDiam_box", 0,0,0);
475   
476   G4VisAttributes pDcolour(G4Colour::Blue());
477   pDcolour.SetForceSolid(false);
478   
479   logical_pD -> SetVisAttributes(pDcolour);
480 
481   // put them in place
482   G4ThreeVector SVposition = {0., 0., 0}; //position of the first edge (left)
483   G4ThreeVector fePosition = {0., 0., SVthickness + feThickness};
484   G4ThreeVector pDposition = {0., 0., -SVthickness -pDthickness};
485   
486   G4double SVposition_x[4] = { -3.*SVside -1.5*SVspacing, -SVside -0.5*SVspacing, +SVside +0.5*SVspacing, +3.*SVside +1.5*SVspacing };
487 
488   std::ostringstream PVName;
489 
490   for( int i=0; i<4; i++)
491   { 
492     // sensitive volume
493     SVposition[0] = SVposition_x[i];
494     PVName << "SV_phys" << i;
495     new G4PVPlacement(0, SVposition, logical_SV, PVName.str(),
496           logical_motherVolumeForDetector,
497           false, 0, true);
498     PVName.str(""); //reset the string
499     
500     // chromium front-electrode
501     PVName << "frontElec_phys" << i;
502     fePosition[0] = SVposition[0];
503     new G4PVPlacement(0, fePosition, logical_fe, PVName.str(),
504           logical_motherVolumeForDetector,
505           false, 0, true);
506     PVName.str("");
507     
508     // p-type diamond back-electrode
509     PVName << "pD_phys" << i;
510     pDposition[0] = SVposition[0];
511     new G4PVPlacement(0, pDposition, logical_pD, PVName.str(),
512           logical_motherVolumeForDetector,
513           false, 0, true);
514     PVName.str("");   
515   }
516 
517   // HPHT diamond substrate (only one big substrate for simplicity)
518   G4double subs_x = 2.*mm /2.;
519   G4double subs_y = 0.5*mm /2.; 
520   G4double sub_z = 300.*micrometer /2.; 
521   
522   G4Box* sub_box = new G4Box("sub_box", subs_x, subs_y, sub_z);
523   
524   G4LogicalVolume* logical_sub = new G4LogicalVolume(sub_box, diamond, "sub_log", 0,0,0);
525   
526   G4ThreeVector subPosition = {0,0, -SVthickness -2.*pDthickness -sub_z};
527   
528   new G4PVPlacement(0, subPosition, logical_sub, "sub_phys",
529         logical_motherVolumeForDetector,
530         false, 0, true);
531 
532   G4VisAttributes subColour(G4Colour(0.5, 0.5, 0.5));
533   subColour.SetForceSolid(false);
534   logical_sub -> SetVisAttributes(subColour);
535 }
536 
537 void DetectorConstruction::ConstructDiamondTelescope()
538 {
539   //Define each individual element
540   //Define Boron
541   G4double A = 10.8 * g/mole;
542   G4double Z = 5;
543   G4Element* elB = new G4Element ("Boron", "B", Z, A);
544 
545   //Define Carbon
546   A = 12.01 * g/mole;
547   Z = 6;
548   G4Element* elC = new G4Element ("Carbon", "C", Z, A);
549 
550   //Define diamond
551   A = 12.01 * g/mole;
552   Z = 6;
553   G4Material* diamond = new G4Material("diamond", Z, A, 3.515*g/cm3);
554       
555   //Define p-type diamond (boron doped diamond)
556   G4Material* p_diamond = new G4Material("p_diamond", 3.514*g/cm3, 2);
557   // Boron concentration used is 1e20 cm-3, considering the diamond density and a Boron atomic weight of 10.811u
558   p_diamond -> AddElement(elC, 99.94887*perCent);
559   p_diamond -> AddElement(elB, 0.05113*perCent);
560 
561   //Define chromium contact
562   G4Material* chromium = nistMan->FindOrBuildMaterial("G4_Cr");
563 
564   // sentive volumes
565   // DE
566   G4double SV_DE_radius = detectorSizeWidth /2.;
567   G4double SV_DE_thickness = detectorSizeThickness /2.;
568   
569   G4Tubs* SV_DE_cyl = new G4Tubs("SV_DE_cyl", 0.*mm, SV_DE_radius, SV_DE_thickness, 0*deg, 360*deg);
570 
571   G4LogicalVolume* logical_SV = new G4LogicalVolume(SV_DE_cyl, diamond, "SV_log", 0,0,0);
572   
573   G4VisAttributes SVcolour(G4Colour(0.5, 0.5, 0.5));
574   SVcolour.SetForceSolid(true);
575   logical_SV -> SetVisAttributes(SVcolour);
576   
577   // The E-stage diameter has to be at least the size of the DE.
578   if( secondStageSizeDim < detectorSizeWidth )
579   {
580     G4cout << "WARNING: the telescope E-stage diameter set (" << secondStageSizeDim << ") is smaller than the DE-stage diameter (" << detectorSizeWidth << ").";
581     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.";
582     secondStageSizeDim = detectorSizeWidth;
583     G4cout << "E-stage diameter set to default as the DE-stage diameter: " << secondStageSizeDim << ".";
584   }
585 
586   // E stage
587   G4double SV_E_thickness = secondStageSizeThickness /2.;
588   G4double SV_E_radius = secondStageSizeDim /2.;
589 
590   G4Tubs* SV_E_cyl = new G4Tubs("SV_E_cyl", 0.*mm, SV_E_radius, SV_E_thickness, 0*deg, 360*deg);
591 
592   G4LogicalVolume* logical_SV_Estage = new G4LogicalVolume(SV_E_cyl, diamond, "SV_Estage_log", 0,0,0);
593   
594   G4VisAttributes SV_E_colour(G4Colour(0.7, 0.7, 0.7));
595   SV_E_colour.SetForceSolid(true);
596   logical_SV_Estage -> SetVisAttributes(SV_E_colour);
597 
598   // 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.
599 
600   // 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.
601   // Default diamond crystals lateral size
602   G4double d_crystal_width = 2.*mm /2.;
603   
604   if( d_crystal_width < secondStageSizeDim )
605   {
606     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 << ".";
607     d_crystal_width = secondStageSizeDim;
608   }
609 
610   // DE crystal   
611   G4Box* DE_crystal_box = new G4Box("DE_crystal_box", d_crystal_width, d_crystal_width, SV_DE_thickness);
612 
613   G4LogicalVolume* logical_DE_crystal = new G4LogicalVolume(DE_crystal_box, diamond, "DE_crystal_log", 0,0,0);
614   
615   G4VisAttributes Diamond_crystal_colour(G4Colour::White());
616   Diamond_crystal_colour.SetForceSolid(false);
617   logical_DE_crystal -> SetVisAttributes(Diamond_crystal_colour);
618 
619   // E crystal
620   G4Box* E_crystal_box = new G4Box("E_crystal_box", d_crystal_width, d_crystal_width, SV_E_thickness);
621 
622   G4LogicalVolume* logical_E_crystal = new G4LogicalVolume(E_crystal_box, diamond, "E_crystal_log", 0,0,0);
623   
624   logical_E_crystal -> SetVisAttributes(Diamond_crystal_colour);
625 
626   // chromium front-electrode
627   G4double feThickness = 100.*nm /2.; // front-electrode thickness
628 
629   G4Tubs* fe_cyl = new G4Tubs("frontElec_cyl", 0.*mm, SV_DE_radius, feThickness, 0*deg, 360*deg);
630 
631   G4LogicalVolume* logical_fe = new G4LogicalVolume(fe_cyl, chromium, "frontElec_log", 0,0,0);
632   
633   G4VisAttributes fe_colour(G4Colour::Brown());
634   fe_colour.SetForceSolid(false);
635   logical_fe -> SetVisAttributes(fe_colour);
636 
637   // chromium back-electrode
638   G4Tubs* fe_cyl_back = new G4Tubs("backElec_cyl", 0.*mm, SV_E_radius, feThickness, 0*deg, 360*deg);
639 
640   G4LogicalVolume* logical_fe_back = new G4LogicalVolume(fe_cyl_back, chromium, "backElec_log", 0,0,0);
641   
642   logical_fe_back -> SetVisAttributes(fe_colour);
643 
644   // p-type diamond
645   G4double pDthickness = 1.8*um /2.; // p-type diamond dead-layer thickness
646   
647   // the p-type diamond layer has the same lateral size as the intrinsic diamond crystals
648   
649   G4Box* pD_box = new G4Box("pDiam_box", d_crystal_width, d_crystal_width, pDthickness);
650   
651   G4LogicalVolume* logical_pD = new G4LogicalVolume(pD_box, p_diamond, "pDiam_log", 0,0,0);
652   
653   G4VisAttributes pDcolour(G4Colour::Blue());
654   pDcolour.SetForceSolid(false);
655   logical_pD -> SetVisAttributes(pDcolour);
656   
657   // put them in place
658   G4ThreeVector DE_crystal_position = {0., 0., 0.}; // centre of DE SV is at selected depth position
659   G4ThreeVector SVposition = {0., 0., 0.}; // the DE sensitive volume will be positioned into the DE crystal.
660   G4ThreeVector fePosition = {0., 0., SV_DE_thickness + feThickness};
661   G4ThreeVector pDposition = {0., 0., -SV_DE_thickness - pDthickness};
662   G4ThreeVector E_crystal_position = {0., 0., -SV_DE_thickness - 2*pDthickness - SV_E_thickness};
663   G4ThreeVector SV_E_position = {0., 0., 0.}; // the E sensitive volume will be positioned into the E crystal.
664   G4ThreeVector bePosition = {0., 0., -SV_DE_thickness - 2.*pDthickness - 2.*SV_E_thickness - feThickness};
665   
666   // DE crystal
667   new G4PVPlacement(0, DE_crystal_position, logical_DE_crystal, "DEstageCrystal_phys",
668         logical_motherVolumeForDetector,
669         false, 0, true);
670   // DE sensitive volume
671   new G4PVPlacement(0, SVposition, logical_SV, "SV_DE_phys",
672         logical_DE_crystal,
673         false, 0, true);
674   // p-type diamond layer
675   new G4PVPlacement(0, pDposition, logical_pD, "pD_phys",
676         logical_motherVolumeForDetector,
677         false, 0, true);
678   // E crystal
679   new G4PVPlacement(0, E_crystal_position, logical_E_crystal, "EstageCrystal_phys",
680         logical_motherVolumeForDetector,
681         false, 0, true);
682   // E sensitive volume
683   new G4PVPlacement(0, SV_E_position, logical_SV_Estage, "SV_E_phys",
684         logical_E_crystal,
685         false, 0, true);
686   // front-electrode
687   new G4PVPlacement(0, fePosition, logical_fe, "frontElec_phys",
688         logical_motherVolumeForDetector,
689         false, 0, true);
690   // back electrode
691   new G4PVPlacement(0, bePosition, logical_fe_back, "backElec_phys",
692         logical_motherVolumeForDetector,
693         false, 0, true);
694 }
695 
696 void DetectorConstruction::ConstructSiliconDetector()
697 {
698   nistMan->SetVerbose(1);
699 
700   //Define each individual element
701   //Define Nitrogen
702   G4double A = 14.01 * g/mole;
703   G4double Z = 7;
704   G4Element* elN = new G4Element ("Nitrogen", "N", Z, A);
705 
706   //Define Oxygen
707   A = 16.0 * g/mole;
708   Z = 8;
709   G4Element* elO = new G4Element ("Oxygen", "O", Z, A);
710 
711   //Define Hydrogen 
712   A = 1.01 * g/mole;
713   Z = 1;
714   G4Element* elH = new G4Element ("Hydrogen", "H", Z, A);
715 
716   //Define Carbon
717   A = 12.01 * g/mole;
718   Z = 6;
719   G4Element* elC = new G4Element ("Carbon", "C", Z, A);
720   
721   //Define Air   
722   G4Material* Air = new G4Material("Air", 1.29*mg/cm3, 2);
723   Air -> AddElement(elN, 70*perCent);
724   Air -> AddElement(elO, 30*perCent);
725  
726   //Define PMMA (C502H8)
727   // NIST reference 
728   G4Material* PMMA = new G4Material("PMMA", 1.19*g/cm3, 3);
729   PMMA -> AddElement(elC, 5);
730   PMMA -> AddElement(elO, 2);
731   PMMA -> AddElement(elH, 8);
732 
733   //define materials
734   G4Material* silicon = nistMan->FindOrBuildMaterial("G4_Si");
735   G4Material* SiO2 = nistMan->FindOrBuildMaterial("G4_SILICON_DIOXIDE");
736   
737   
738    G4double SVspacing = 10.*um; // distance between the edges of two SV
739    
740   // PMMA
741   G4double PMMA_x = ( detectorSizeWidth*2. + SVspacing*3 ) /2.;
742   G4double PMMA_y = ( detectorSizeWidth*2. + SVspacing*3 ) /2.;
743   G4double PMMA_z = detectorSizeThickness /2.;
744   
745   G4Box* PMMA_box = new G4Box("PMMA_box", PMMA_x, PMMA_y, PMMA_z);
746   
747   G4LogicalVolume* logical_PMMA = new G4LogicalVolume(PMMA_box, PMMA, "PMMA_log", 0,0,0);
748   
749   new G4PVPlacement(0, G4ThreeVector(), logical_PMMA, "PMMA_phys",
750           logical_motherVolumeForDetector,
751           false, 0, true);
752   
753   logical_PMMA -> SetVisAttributes(G4VisAttributes(G4Colour(0., 1., 0.)));
754   
755   // sensitive volumes
756   G4double SV_radius = detectorSizeWidth /2.; // full length
757   G4double SV_thick = detectorSizeThickness /2.;
758   
759   G4Tubs* SV_cyl = new G4Tubs("SV_cyl", 0., SV_radius, SV_thick, 0.*deg, 360.*deg);
760   //G4RotationMatrix* cylRot = new G4RotationMatrix;
761   //cylRot->rotateY(M_PI/2.*rad);
762     
763   G4LogicalVolume* logical_SV = new G4LogicalVolume(SV_cyl, silicon, "SV_log", 0,0,0);
764   
765   G4VisAttributes SVcolour(G4Colour(0.5, 0.5, 0.5));
766   SVcolour.SetForceSolid(true);
767   logical_SV -> SetVisAttributes(SVcolour);
768   
769   G4ThreeVector SVposition; //if(volumeName != "SV_phys1")
770   
771   SVposition = { +SVspacing/2. +SV_radius, +SVspacing/2. +SV_radius, 0. };
772   new G4PVPlacement(0, SVposition, logical_SV, "SV_phys1",
773             logical_PMMA,
774             false, 0, true);
775   /*new G4PVPlacement(cylRot, SVposition, logical_SV, "SV_phys1",
776             logical_PMMA,
777             false, 0, true);*/
778 
779   SVposition = { -SVspacing/2. -SV_radius, +SVspacing/2. +SV_radius, 0. };
780   new G4PVPlacement(0, SVposition, logical_SV, "SV_phys2",
781             logical_PMMA,
782             false, 0, true);
783   
784   SVposition = { -SVspacing/2. -SV_radius, -SVspacing/2. -SV_radius, 0. };
785   new G4PVPlacement(0, SVposition, logical_SV, "SV_phys3",
786             logical_PMMA,
787             false, 0, true);
788             
789   SVposition = { +SVspacing/2. +SV_radius, -SVspacing/2. -SV_radius, 0. };
790   new G4PVPlacement(0, SVposition, logical_SV, "SV_phys4",
791             logical_PMMA,
792             false, 0, true);
793   
794   // Si02 layer
795   G4double oxyde_x = PMMA_x;
796   G4double oxyde_y = PMMA_y;
797   G4double oxyde_z = 1.*um /2.;
798   
799   G4Box* oxyde_box = new G4Box("oxyde_box", oxyde_x, oxyde_y, oxyde_z);
800   
801   G4LogicalVolume* logical_oxyde = new G4LogicalVolume(oxyde_box, SiO2, "oxyde_log", 0,0,0);
802   
803   G4ThreeVector oxyde_position = G4ThreeVector( 0, 0, -PMMA_z -oxyde_z );
804   new G4PVPlacement(0, oxyde_position, logical_oxyde, "oxyde_phys",
805           logical_motherVolumeForDetector,
806           false, 0, true);
807   
808   logical_oxyde -> SetVisAttributes(G4VisAttributes(G4Colour(0.6, 0.6, 0.6)));
809 }
810 
811 void DetectorConstruction::ConstructSiliconBridgeDetector()
812 {
813 //--------------------------------------------------------
814 //--------------------- MATERIALS ------------------------
815 //--------------------------------------------------------  
816   //Define Water   
817   //G4Material* Water  = nistMan->FindOrBuildMaterial("G4_WATER");
818 
819   //Define Polyethylene
820   //G4Material* poly  = nistMan->FindOrBuildMaterial("G4_POLYETHYLENE");
821   
822   //Define PMMA
823   //G4Material* perspex  = nistMan->FindOrBuildMaterial("G4_PLEXIGLASS"); //Default 1.19g
824   
825   //Define Aluminium
826   G4Material* Aluminium = nistMan->FindOrBuildMaterial("G4_Al");
827   
828   //Define Silicon
829   G4Material* silicon = nistMan->FindOrBuildMaterial("G4_Si");
830   
831   //Define Aluminium Oxide (this is acting as the ceremic)
832   //G4Material* AlOx = nistMan->FindOrBuildMaterial("G4_ALUMINUM_OXIDE");
833   
834   //Define SiO
835   G4Material* SiO2 = nistMan->FindOrBuildMaterial("G4_SILICON_DIOXIDE");
836   
837   //Define Pyrex Glass
838   //G4Material* PyrexGlass = nistMan->FindOrBuildMaterial("G4_Pyrex_Glass");
839   
840 //--------------------------------------------------------
841 //-------------------- Vis Attributes --------------------
842 //--------------------------------------------------------  
843   G4VisAttributes* wireFrameWhiteAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
844   wireFrameWhiteAtt -> SetVisibility(true);
845   wireFrameWhiteAtt -> SetForceWireframe(true);
846   
847   G4VisAttributes* wireFramePinkAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0)); 
848     wireFramePinkAtt -> SetVisibility(true);
849     wireFramePinkAtt -> SetForceWireframe(true);
850   
851   G4VisAttributes* solidGreyAtt = new G4VisAttributes(G4Colour(0.5, .5, .5)); 
852     solidGreyAtt -> SetVisibility(true);
853     solidGreyAtt -> SetForceSolid(true);
854   
855   G4VisAttributes* solidRedAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
856   solidRedAtt -> SetVisibility(true);
857   solidRedAtt -> SetForceSolid(true);
858   
859   G4VisAttributes* solidGreenAtt = new G4VisAttributes(G4Colour(0.0, 1.0, 0.0));
860   solidGreenAtt -> SetVisibility(true);
861   solidGreenAtt -> SetForceSolid(true);
862   
863   G4VisAttributes* solidYellowAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0));
864   solidYellowAtt -> SetVisibility(true);
865   solidYellowAtt -> SetForceSolid(true);
866   
867   G4VisAttributes* solidBlueAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0));
868   solidBlueAtt -> SetVisibility(true);
869   solidBlueAtt -> SetForceSolid(true);
870   
871 //--------------------------------------------------------
872 //----------------------- Volumes ------------------------
873 //--------------------------------------------------------
874 
875   G4RotationMatrix* rotMatW = new G4RotationMatrix;
876   rotMatW->rotateY(0*deg);
877   rotMatW->rotateX(-90*deg);
878   rotMatW->rotateZ(0*deg);
879 
880 //------------------Detector Mother Volume------------------  
881   G4double SVheight = detectorSizeThickness;
882   G4double insulationThickness = 1.*micrometer;
883   G4double SiOoverlayerBottomThickness = 1.7*micrometer;
884   G4double AlOverlayerThickness = 1.7*micrometer;
885   G4double AlOverlayerRadius = 4.*micrometer;
886   G4double SiOoverlayerTopThickness = 1.43*micrometer;
887   G4double SiOoverlayerTopRadius = 10.5/2. * micrometer;
888   G4double overLayerThickness = AlOverlayerThickness + SiOoverlayerTopThickness;
889 
890   G4double baseSiThickness = 300.*micrometer;
891   G4double detectorHeight = (SVheight + baseSiThickness + insulationThickness + SiOoverlayerBottomThickness + AlOverlayerThickness + SiOoverlayerTopThickness);
892 
893   G4double SVwidth = detectorSizeWidth;
894   G4double pitch = 20.*micrometer; //distance between the odd and even rows
895 
896   G4double bridgingWidth = 20.*micrometer;
897   G4double bridgingLength = 15.*micrometer;
898   G4double bridingHeight = SVheight;
899 
900   G4double numberOfRows = 59;
901   G4double numberOfColumns = (24*3);
902   G4double SVareaWidth = (numberOfColumns * (SVwidth + bridgingWidth)) - 1.*bridgingWidth;
903   G4double SVareaLength = numberOfRows*(SVwidth + pitch) - 1.*pitch;
904   G4double bufferWidth = 100.*micrometer;
905   G4double detectorWidth = SVareaWidth + bufferWidth;
906   G4double detectorLength = SVareaLength + bufferWidth;
907   
908 //------------------Smaller Detector Mother Volume------------------  
909   G4Box* detectorBox = new G4Box("detectorBox", detectorWidth/2., detectorHeight/2., detectorLength/2.);
910   G4LogicalVolume* logicalDetectorReg = new G4LogicalVolume(detectorBox, materialOfMotherVolume, "detectorReg_log", 0,0,0);
911   new G4PVPlacement(rotMatW, G4ThreeVector(0,0,0), logicalDetectorReg, "detectorRegPhys", logical_motherVolumeForDetector , false, 0, true);
912 
913   logicalDetectorReg -> SetVisAttributes(wireFrameWhiteAtt);
914   
915 //------------------Base Silicon Volume----------------------
916   G4Box* basSiBox = new G4Box("baseSiBox", detectorWidth/2., baseSiThickness/2., detectorLength/2.);
917   G4LogicalVolume* logicalbaseSi = new G4LogicalVolume(basSiBox, silicon, "baseSi_log", 0,0,0);
918   new G4PVPlacement(0, G4ThreeVector(0,(-detectorHeight/2. + baseSiThickness/2.),0), logicalbaseSi, "baseSiPhys", logicalDetectorReg, false, 0, true);
919   
920   logicalbaseSi -> SetVisAttributes(wireFramePinkAtt);
921 
922 //---------------------Insulation Volume----------------------
923   G4Box* SiOBox = new G4Box("SiOBox", detectorWidth/2., insulationThickness/2., detectorLength/2.);
924   G4LogicalVolume* logicalSoI = new G4LogicalVolume(SiOBox, SiO2, "SoI_log", 0,0,0);
925   new G4PVPlacement(0, G4ThreeVector(0,(detectorHeight/2. -overLayerThickness - SVheight - insulationThickness/2.),0), logicalSoI, "SoIPhys", logicalDetectorReg, false, 0, true);
926 
927   logicalSoI -> SetVisAttributes(solidGreyAtt);
928 
929 //----------------Sensitive Volume Region---------------------
930 //This volume encapsulates the SVs and the "bridging" volumes
931   G4Box* SVregBox = new G4Box("SVregBox", detectorWidth/2., SVheight/2., detectorLength/2.);
932   G4LogicalVolume* logicalSVreg = new G4LogicalVolume(SVregBox, materialOfMotherVolume, "SVreg_log", 0,0,0);
933   new G4PVPlacement(0, G4ThreeVector(0,(detectorHeight/2. - overLayerThickness - SVheight/2.),0), logicalSVreg, "SVregPhys", logicalDetectorReg, false, 0, true);
934 
935     logicalSVreg -> SetVisAttributes(wireFrameWhiteAtt);
936 
937 //----------------------Bridging Volume----------------------
938 //This volume connects or "bridges" the main sensitive volumes 
939 //together but effectively act as additional sensitive volumes
940   G4Box* bridgeVolBox = new G4Box("bridgeVolBox", bridgingWidth/2., bridingHeight/2., bridgingLength/2.);
941   G4LogicalVolume* logicalBridgeVol = new G4LogicalVolume(bridgeVolBox, silicon, "bridgeVol_log", 0,0,0);
942 
943   logicalBridgeVol -> SetVisAttributes(solidRedAtt);
944   
945 //---------------------SiO Bottom Overlayer------------------
946   G4Box* SiObotLayerBox = new G4Box("SiObotLayerBox", SVwidth/2., SiOoverlayerBottomThickness/2., SVwidth/2.);
947   G4LogicalVolume* logicalSiObotLayer = new G4LogicalVolume(SiObotLayerBox, SiO2, "logicalSiObotLayer", 0,0,0);
948 
949   logicalSiObotLayer -> SetVisAttributes(solidGreenAtt);
950   
951 //--------------SiO Bottom Overlayer Bridging Vol-------------
952   G4Box* SiObotLayerBridgeBox = new G4Box("SiObotLayerBridgeBox", bridgingWidth/2., SiOoverlayerBottomThickness/2., bridgingLength/2.);
953   G4LogicalVolume* logicalSiObotLayerBridge = new G4LogicalVolume(SiObotLayerBridgeBox, SiO2, "logicalSiObotLayer", 0,0,0);
954 
955   logicalSiObotLayerBridge -> SetVisAttributes(solidGreenAtt);
956 
957 //-----------------------Al contact ---------------------------
958   G4Box* AlContactBox = new G4Box("AlContactBox", AlOverlayerRadius, AlOverlayerThickness/2., AlOverlayerRadius);
959   G4LogicalVolume* logicalAlContact = new G4LogicalVolume(AlContactBox, Aluminium, "logicalAlContact", 0,0,0);
960 
961   logicalAlContact -> SetVisAttributes(solidYellowAtt);
962 
963 //----------------------SiO Top Overlayer---------------------- 
964   G4Box* SiOtopLayerBox = new G4Box("SiOtopLayerBox", SiOoverlayerTopRadius, SiOoverlayerTopThickness/2., SiOoverlayerTopRadius);
965   G4LogicalVolume* logicalSiOtopLayer = new G4LogicalVolume(SiOtopLayerBox, SiO2, "logicalSiOtopLayer", 0,0,0);
966 
967   logicalSiOtopLayer -> SetVisAttributes(solidBlueAtt);
968 
969 //--------------------Sensitive Volume--------------------------
970   G4Box* sensitiveBridgeVolume = new G4Box("water_region_sphere", SVwidth/2., SVheight/2., SVwidth/2.);
971   G4LogicalVolume* SV_log = new G4LogicalVolume(sensitiveBridgeVolume, silicon, "SV_log", 0,0,0);
972 
973   SV_log -> SetVisAttributes(solidYellowAtt);
974   
975 //---Placing SVs, 30x30 volumes and "bridging" volumes between them
976 
977   G4bool checkSVoverlap = false;
978   
979   //Placing "odd" SV rows/columns
980   G4int globalCount = 100000;  
981   
982   for (G4double j = -SVareaLength/2.; j <= SVareaLength/2.; j+=2.*(SVwidth + bridgingWidth)) //creates each row
983   {
984     for (G4double i = -SVareaWidth/2.; i <= SVareaWidth/2.; i+=(SVwidth + bridgingWidth)) //goes through each odd row
985     {
986       //G4cout << "x: " << i/um << " z: " << j/um << G4endl;
987       new G4PVPlacement(0, G4ThreeVector(i,0,j), SV_log , "physSensitiveBridgeVolume", logicalSVreg, false, globalCount, checkSVoverlap);
988       
989       new G4PVPlacement(0, G4ThreeVector(i,((detectorHeight/2. -overLayerThickness + SiOoverlayerBottomThickness/2.)),j), logicalSiObotLayer, "physSiObotLayer", logicalDetectorReg, false, globalCount, checkSVoverlap);
990       
991       new G4PVPlacement(0, G4ThreeVector(i,((detectorHeight/2. -overLayerThickness + SiOoverlayerBottomThickness + SiOoverlayerTopThickness/2.)),j), logicalSiOtopLayer, "physSiOtopLayer", logicalDetectorReg, false, globalCount, checkSVoverlap);
992       
993       globalCount++;  
994     }
995   }
996   
997   //Placing "even" SV rows/columns
998   globalCount = 200000;  
999   
1000   for (G4double j = (-SVareaLength/2. + SVwidth + bridgingWidth); j <= SVareaLength/2.; j+=2.*(SVwidth + bridgingWidth)) //creates each row
1001   {
1002     for (G4double i = -SVareaWidth/2.; i <= SVareaWidth/2.; i+=(SVwidth + bridgingWidth)) //goes through each odd row
1003     {
1004       //G4cout << "x: " << i/micrometer << " z: " << j/micrometer << G4endl;
1005 
1006       new G4PVPlacement(0, G4ThreeVector(i,0,j), SV_log , "physSensitiveBridgeVolume", logicalSVreg, false, globalCount, checkSVoverlap);
1007       
1008       new G4PVPlacement(0, G4ThreeVector(i,((detectorHeight/2. -overLayerThickness + SiOoverlayerBottomThickness/2.)),j), logicalSiObotLayer, "physSiObotLayer", logicalDetectorReg, false, globalCount, checkSVoverlap);
1009       
1010       new G4PVPlacement(0, G4ThreeVector(i,((detectorHeight/2. -overLayerThickness + SiOoverlayerBottomThickness + SiOoverlayerTopThickness/2.)),j), logicalSiOtopLayer, "physSiOtopLayer", logicalDetectorReg, false, globalCount, checkSVoverlap);
1011       
1012       globalCount++;
1013     }
1014   }
1015 
1016   //Placing "odd" bridging volumes rows/columns
1017   globalCount = 300000;
1018 
1019   for (G4double j = -SVareaLength/2.; j < SVareaLength/2.; j+=2.*(SVwidth + bridgingWidth)) //creates each row
1020   {
1021     for (G4double i = -SVareaWidth/2.; i < SVareaWidth/2.; i+=(SVwidth + bridgingWidth)) //goes through each odd row
1022     {
1023     if ( (i + (SVwidth + bridgingWidth)) < SVareaWidth/2.)
1024     {
1025       //G4cout << globalCount << G4endl;
1026       new G4PVPlacement(0, G4ThreeVector((i + SVwidth/2. + bridgingWidth/2.),0,(j+ bridgingLength/2.)), logicalBridgeVol , "sen_bridge", logicalSVreg, false, globalCount, checkSVoverlap);
1027       
1028       new G4PVPlacement(0, G4ThreeVector((i + SVwidth/2. + bridgingWidth/2.),((detectorHeight/2. -overLayerThickness + SiOoverlayerBottomThickness/2.)),(j+ bridgingLength/2.)), logicalSiObotLayerBridge, "physSiObotLayerBridge", logicalDetectorReg, false, globalCount, checkSVoverlap);
1029       
1030       //G4cout << "x: " << (i + SVwidth/2. + bridgingWidth/2.)/micrometer << " z: " << j/micrometer << G4endl;
1031       
1032       globalCount++;
1033     } 
1034     }
1035   }
1036 
1037   //Placing "even" bridging rows/columns
1038   globalCount = 400000;  
1039 
1040   for (G4double j = (-SVareaLength/2. + SVwidth + bridgingWidth); j < SVareaLength/2.; j+=2.*(SVwidth + bridgingWidth)) //creates each row
1041   {
1042     for (G4double i = -SVareaWidth/2.; i < SVareaWidth/2.; i+=(SVwidth + bridgingWidth)) //goes through each odd row
1043     {
1044     
1045     if ( (i+ (SVwidth + bridgingWidth)) < SVareaWidth/2.)
1046     { 
1047       //G4cout << globalCount << G4endl;
1048       new G4PVPlacement(0, G4ThreeVector((i + SVwidth/2. + bridgingWidth/2.),0,(j+ bridgingLength/2.)), logicalBridgeVol , "sen_bridge", logicalSVreg, false, globalCount, checkSVoverlap);
1049       
1050       //G4cout << "x: " << (i + SVwidth/2. + bridgingWidth/2.)/micrometer << " z: " << j/micrometer << G4endl;
1051       
1052       new G4PVPlacement(0, G4ThreeVector((i + SVwidth/2. + bridgingWidth/2.),((detectorHeight/2. -overLayerThickness + SiOoverlayerBottomThickness/2.)),(j+ bridgingLength/2.)), logicalSiObotLayerBridge, "physSiObotLayerBridge", logicalDetectorReg, false, globalCount, checkSVoverlap);
1053       
1054       globalCount++;
1055     }
1056       
1057     }
1058   }
1059   
1060 //----------------------------------------
1061   new G4PVPlacement(0, G4ThreeVector(0,0,0), logicalAlContact, "physAlContact", logicalSiObotLayer, false, 0, 1);
1062 }
1063 
1064 
1065 void DetectorConstruction::ConstructSiC()
1066 {
1067 
1068 //Define SiC
1069  G4double A = 12.01 * g/mole;
1070  G4double Z = 6;
1071 G4double A_Si=28.086*g/mole;
1072  G4double Z_Si=14;
1073 G4double density_SiC=3.22*g/cm3;
1074 G4Element *Si=new G4Element("Silicum","Si",Z_Si,A_Si);
1075 G4Element *C=new G4Element("Carbon","C",Z,A);
1076 G4Material *SiC=new G4Material("SiC", density_SiC,2);
1077 SiC->AddElement(Si,1);
1078 SiC->AddElement(C,1);
1079 
1080 /*G4Material *airNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes);
1081   G4Material *Silicon = G4NistManager::Instance()->FindOrBuildMaterial("G4_Si", isotopes);*/
1082 
1083   
1084 detectorSizeWidth=0.1*mm;
1085  detectorSizeThickness=22*um;//10*um;
1086 
1087  G4double substrate_thickness=370*um;
1088  
1089  G4double SV_x = detectorSizeWidth/2;
1090  G4double SV_y = detectorSizeWidth/2;
1091  G4double SV_z = detectorSizeThickness/2; 
1092 
1093  G4Box* SV_box = new G4Box("SV_box",SV_x,SV_y,SV_z);
1094 
1095  G4LogicalVolume* logical_SV = new G4LogicalVolume(SV_box, SiC, "SV_log", 0,0,0);
1096 
1097  new G4PVPlacement(0, G4ThreeVector(0*mm,0*mm,-SV_z), logical_SV,"SV_phys1",
1098         logical_motherVolumeForDetector,false, 0, true);
1099 
1100 
1101  G4Box* Substrate_box = new G4Box("Substrate_box",SV_x,SV_y,substrate_thickness/2); 
1102 
1103  
1104   G4LogicalVolume* logical_substrate = new G4LogicalVolume(Substrate_box, SiC, "substrate_log", 0,0,0);
1105 
1106   new G4PVPlacement(0, G4ThreeVector(0,0,-2*SV_z-substrate_thickness/2), logical_substrate,"substrate_phys",
1107         logical_motherVolumeForDetector, 
1108         false, 0, true);
1109    
1110  
1111 // Visualisation attributes
1112 
1113   G4VisAttributes vis_SV(G4Colour(198, 226, 255));
1114   vis_SV.SetForceSolid(true);
1115   logical_SV -> SetVisAttributes(vis_SV);
1116 }
1117 
1118 
1119 
1120 void DetectorConstruction::ConstructSDandField()
1121 {
1122    SensitiveDetector* SD = new SensitiveDetector("SD", "DetectorHitsCollection", true, analysis);
1123    G4SDManager::GetSDMpointer()->AddNewDetector(SD);
1124    SetSensitiveDetector("SV_log", SD);
1125 
1126   if (detectorType == "SiliconBridge")
1127   {
1128     SetSensitiveDetector("bridgeVol_log", SD);
1129   }
1130   else if (detectorType == "DiamondTelescope")
1131   {
1132     SensitiveDetector* SDs2 = new SensitiveDetector("SDs2", "DetectorStage2HitsCollection", false, analysis);
1133     G4SDManager::GetSDMpointer()->AddNewDetector(SDs2);
1134     SetSensitiveDetector("SV_Estage_log", SDs2);
1135   }
1136 }
1137