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