Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExN04DetectorConstruction.cc
Go to the documentation of this file.
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 //
28 //
29 
30 #include "ExN04DetectorConstruction.hh"
31 #include "ExN04TrackerSD.hh"
32 #include "ExN04CalorimeterSD.hh"
33 #include "ExN04CalorimeterROGeometry.hh"
34 #include "ExN04MuonSD.hh"
35 #include "ExN04TrackerParametrisation.hh"
36 #include "ExN04CalorimeterParametrisation.hh"
37 #include "ExN04Field.hh"
38 
39 #include "G4Material.hh"
40 #include "G4MaterialTable.hh"
41 #include "G4Element.hh"
42 #include "G4ElementTable.hh"
43 #include "G4Box.hh"
44 #include "G4Tubs.hh"
45 #include "G4LogicalVolume.hh"
46 #include "G4ThreeVector.hh"
47 #include "G4PVPlacement.hh"
48 #include "G4PVParameterised.hh"
49 #include "G4Transform3D.hh"
50 #include "G4RotationMatrix.hh"
51 #include "G4FieldManager.hh"
53 #include "G4SDManager.hh"
54 #include "G4VisAttributes.hh"
55 #include "G4Colour.hh"
56 #include "G4SystemOfUnits.hh"
57 
59 {
60 
61 #include "ExN04DetectorParameterDef.icc"
62  DefineMaterials();
63 
64 }
65 
67 {;}
68 
69 void ExN04DetectorConstruction::DefineMaterials()
70 {
71  //-------------------------------------------------------------------------
72  // Materials
73  //-------------------------------------------------------------------------
74 
75  G4double a, z, density;
76  G4int nel;
77 
78  G4Element* H = new G4Element("Hydrogen", "H", z=1., a= 1.01*g/mole);
79  G4Element* C = new G4Element("Carbon", "C", z=6., a= 12.01*g/mole);
80  G4Element* N = new G4Element("Nitrogen", "N", z=7., a= 14.01*g/mole);
81  G4Element* O = new G4Element("Oxygen", "O", z=8., a= 16.00*g/mole);
82 
83  Air = new G4Material("Air", density= 1.29*mg/cm3, nel=2);
84  Air->AddElement(N, 70.*perCent);
85  Air->AddElement(O, 30.*perCent);
86 
87  Lead =
88  new G4Material("Lead", z=82., a= 207.19*g/mole, density= 11.35*g/cm3);
89 
90  Ar =
91  new G4Material("ArgonGas",z=18., a= 39.95*g/mole, density=1.782*mg/cm3);
92 
93  Silicon =
94  new G4Material("Silicon", z=14., a= 28.09*g/mole, density= 2.33*g/cm3);
95 
96  Scinti = new G4Material("Scintillator", density= 1.032*g/cm3, nel=2);
97  Scinti->AddElement(C, 9);
98  Scinti->AddElement(H, 10);
99 }
100 
102 {
103  //-------------------------------------------------------------------------
104  // Magnetic field
105  //-------------------------------------------------------------------------
106 
107  static G4bool fieldIsInitialized = false;
108  if(!fieldIsInitialized)
109  {
110  ExN04Field* myField = new ExN04Field;
111  G4FieldManager* fieldMgr
113  ->GetFieldManager();
114  fieldMgr->SetDetectorField(myField);
115  fieldMgr->CreateChordFinder(myField);
116  fieldIsInitialized = true;
117  }
118 
119 
120  //-------------------------------------------------------------------------
121  // Detector geometry
122  //-------------------------------------------------------------------------
123 
124  //------------------------------ experimental hall
125  G4Box * experimentalHall_box
126  = new G4Box("expHall_b",expHall_x,expHall_y,expHall_z);
127  G4LogicalVolume * experimentalHall_log
128  = new G4LogicalVolume(experimentalHall_box,Air,"expHall_L",0,0,0);
129  G4VPhysicalVolume * experimentalHall_phys
130  = new G4PVPlacement(0,G4ThreeVector(),experimentalHall_log,"expHall_P",
131  0,false,0);
132  G4VisAttributes* experimentalHallVisAtt
133  = new G4VisAttributes(G4Colour(1.0,1.0,1.0));
134  experimentalHallVisAtt->SetForceWireframe(true);
135  experimentalHall_log->SetVisAttributes(experimentalHallVisAtt);
136 
137  //------------------------------ tracker
138  G4VSolid * tracker_tubs
139  = new G4Tubs("trkTubs_tubs",trkTubs_rmin,trkTubs_rmax,trkTubs_dz,
140  trkTubs_sphi,trkTubs_dphi);
141  G4LogicalVolume * tracker_log
142  = new G4LogicalVolume(tracker_tubs,Ar,"trackerT_L",0,0,0);
143  // G4VPhysicalVolume * tracker_phys =
144  new G4PVPlacement(0,G4ThreeVector(),tracker_log,"tracker_phys",
145  experimentalHall_log,false,0);
146  G4VisAttributes* tracker_logVisAtt
147  = new G4VisAttributes(G4Colour(1.0,0.0,1.0));
148  tracker_logVisAtt->SetForceWireframe(true);
149  tracker_log->SetVisAttributes(tracker_logVisAtt);
150 
151  //------------------------------ tracker layers
152  // As an example for Parameterised volume
153  // dummy values for G4Tubs -- modified by parameterised volume
154  G4VSolid * trackerLayer_tubs
155  = new G4Tubs("trackerLayer_tubs",trkTubs_rmin,trkTubs_rmax,trkTubs_dz,
156  trkTubs_sphi,trkTubs_dphi);
157  G4LogicalVolume * trackerLayer_log
158  = new G4LogicalVolume(trackerLayer_tubs,Silicon,"trackerB_L",0,0,0);
159  G4VPVParameterisation * trackerParam
161  // dummy value : kXAxis -- modified by parameterised volume
162  // G4VPhysicalVolume *trackerLayer_phys =
163  new G4PVParameterised("trackerLayer_phys",trackerLayer_log,tracker_log,
164  kXAxis, notrkLayers, trackerParam);
165  G4VisAttributes* trackerLayer_logVisAtt
166  = new G4VisAttributes(G4Colour(0.5,0.0,1.0));
167  trackerLayer_logVisAtt->SetForceWireframe(true);
168  trackerLayer_log->SetVisAttributes(trackerLayer_logVisAtt);
169 
170  //------------------------------ calorimeter
171  G4VSolid * calorimeter_tubs
172  = new G4Tubs("calorimeter_tubs",caloTubs_rmin,caloTubs_rmax,
173  caloTubs_dz,caloTubs_sphi,caloTubs_dphi);
174  G4LogicalVolume * calorimeter_log
175  = new G4LogicalVolume(calorimeter_tubs,Scinti,"caloT_L",0,0,0);
176  // G4VPhysicalVolume * calorimeter_phys =
177  new G4PVPlacement(0,G4ThreeVector(),calorimeter_log,"caloM_P",
178  experimentalHall_log,false,0);
179  G4VisAttributes* calorimeter_logVisATT
180  = new G4VisAttributes(G4Colour(1.0,1.0,0.0));
181  calorimeter_logVisATT->SetForceWireframe(true);
182  calorimeter_log->SetVisAttributes(calorimeter_logVisATT);
183 
184  //------------------------------- Lead layers
185  // As an example for Parameterised volume
186  // dummy values for G4Tubs -- modified by parameterised volume
187  G4VSolid * caloLayer_tubs
188  = new G4Tubs("caloLayer_tubs",caloRing_rmin,caloRing_rmax,
189  caloRing_dz,caloRing_sphi,caloRing_dphi);
190  G4LogicalVolume * caloLayer_log
191  = new G4LogicalVolume(caloLayer_tubs,Lead,"caloR_L",0,0,0);
192  G4VPVParameterisation * calorimeterParam
194  // dummy value : kXAxis -- modified by parameterised volume
195  // G4VPhysicalVolume * caloLayer_phys =
196  new G4PVParameterised("caloLayer_phys",caloLayer_log,calorimeter_log,
197  kXAxis, nocaloLayers, calorimeterParam);
198  G4VisAttributes* caloLayer_logVisAtt
199  = new G4VisAttributes(G4Colour(0.7,1.0,0.0));
200  caloLayer_logVisAtt->SetForceWireframe(true);
201  caloLayer_log->SetVisAttributes(caloLayer_logVisAtt);
202 
203  //------------------------------ muon counters
204  // As an example of CSG volumes with rotation
205  G4VSolid * muoncounter_box
206  = new G4Box("muoncounter_box",muBox_width,muBox_thick,
207  muBox_length);
208  G4LogicalVolume * muoncounter_log
209  = new G4LogicalVolume(muoncounter_box,Scinti,"mucounter_L",0,0,0);
210  G4VPhysicalVolume * muoncounter_phys;
211  for(int i=0; i<nomucounter ; i++)
212  {
213  G4double phi, x, y, z;
214  phi = 360.*deg/nomucounter*i;
215  x = muBox_radius*std::sin(phi);
216  y = muBox_radius*std::cos(phi);
217  z = 0.*cm;
218  G4RotationMatrix rm;
219  rm.rotateZ(phi);
220  muoncounter_phys
221  = new G4PVPlacement(G4Transform3D(rm,G4ThreeVector(x,y,z)),
222  muoncounter_log, "muoncounter_P",
223  experimentalHall_log,false,i);
224  }
225  G4VisAttributes* muoncounter_logVisAtt
226  = new G4VisAttributes(G4Colour(0.0,1.0,1.0));
227  muoncounter_logVisAtt->SetForceWireframe(true);
228  muoncounter_log->SetVisAttributes(muoncounter_logVisAtt);
229 
230  //------------------------------------------------------------------
231  // Sensitive Detector
232  //------------------------------------------------------------------
233 
235 
236  G4String trackerSDname = "/mydet/tracker";
237  ExN04TrackerSD * trackerSD = new ExN04TrackerSD(trackerSDname);
238  SDman->AddNewDetector(trackerSD);
239  trackerLayer_log->SetSensitiveDetector(trackerSD);
240 
241  G4String calorimeterSDname = "/mydet/calorimeter";
242  ExN04CalorimeterSD * calorimeterSD = new ExN04CalorimeterSD(calorimeterSDname);
243  G4String ROgeometryName = "CalorimeterROGeom";
244  G4VReadOutGeometry* calRO = new ExN04CalorimeterROGeometry(ROgeometryName);
245  calRO->BuildROGeometry();
246  calorimeterSD->SetROgeometry(calRO);
247  SDman->AddNewDetector(calorimeterSD);
248  calorimeter_log->SetSensitiveDetector(calorimeterSD);
249 
250  G4String muonSDname = "/mydet/muon";
251  ExN04MuonSD * muonSD = new ExN04MuonSD(muonSDname);
252  SDman->AddNewDetector(muonSD);
253  muoncounter_log->SetSensitiveDetector(muonSD);
254 
255  //------------------------------------------------------------------
256  // Digitizer modules
257  //------------------------------------------------------------------
258 
259  return experimentalHall_phys;
260 }
261