Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
H02DetectorConstruction.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 // H02DetectorConstruction.cc
31 // $Id$
32 //
33 // ====================================================================
35 
36 #include "G4Element.hh"
37 #include "G4Material.hh"
38 
39 #include "G4LogicalVolume.hh"
40 #include "G4PVPlacement.hh"
41 #include "G4VisAttributes.hh"
42 #include "G4Tubs.hh"
43 #include "G4Box.hh"
44 
45 #include "G4SDManager.hh"
46 #include "H02MuonSD.hh"
47 
48 // for magnetic field
49 #include "G4FieldManager.hh"
51 #include "G4ChordFinder.hh"
52 #include "H02Field.hh"
53 
54 #include "G4SystemOfUnits.hh"
55 
56 // ====================================================================
57 //
58 // constants (detector parameters)
59 //
60 // ====================================================================
61 // [experimental hall]
62 static const G4double R_EXPHALL= 5.*m;
63 static const G4double DZ_EXPHALL= 10.*m;
64 
65 // [calorimeter]
66 static const G4double RIN_BARREL_CAL= 2.*m;
67 static const G4double ROUT_BARREL_CAL= 3.*m;
68 static const G4double DZ_BARREL_CAL= 5.*m;
69 
70 static const G4double RIN_ENDCAP_CAL= 1.*m;
71 static const G4double ROUT_ENDCAP_CAL= 3.*m;
72 static const G4double DZ_ENDCAP_CAL= 0.5*m;
73 
74 // [muon system]
75 static const G4double RIN_BARREL_MUON= 4.3*m;
76 static const G4double ROUT_BARREL_MUON= 4.5*m;
77 static const G4double DX_BARREL_MUON= RIN_BARREL_MUON*std::cos(67.5*deg)-5.*cm;
78 static const G4double DY_BARREL_MUON= 10.*cm;
79 static const G4double DZ_BARREL_MUON= 7.*m;
80 
81 static const G4double RIN_ENDCAP_MUON= 1.*m;
82 static const G4double ROUT_ENDCAP_MUON= 4.5*m;
83 static const G4double DZ_ENDCAP_MUON= 10.*cm;
84 
85 // ====================================================================
86 //
87 // class description
88 //
89 // ====================================================================
90 
94 {
95 }
96 
100 {
101 }
102 
103 
107 {
108  // ==============================================================
109  // Materials
110  // ==============================================================
111 
112  G4double a, iz, z, density;
114  G4int nel;
115 
116  a= 1.01*g/mole;
117  G4Element* elH= new G4Element(name="Hydrogen", symbol="H", iz=1., a);
118 
119  a= 12.01*g/mole;
120  G4Element* elC= new G4Element(name="Carbon", symbol="C", iz=6., a);
121 
122  a= 14.01*g/mole;
123  G4Element* elN= new G4Element(name="Nitrogen", symbol="N", iz=7., a);
124 
125  a = 16.00*g/mole;
126  G4Element* elO= new G4Element(name="Oxygen", symbol="O", iz=8., a);
127 
128  density= 1.29e-03*g/cm3;
129  G4Material* Air= new G4Material(name="Air", density, nel=2);
130  Air-> AddElement(elN, .7);
131  Air-> AddElement(elO, .3);
132 
133  a= 207.19*g/mole;
134  density= 11.35*g/cm3;
135  G4Material* Lead= new G4Material(name="Lead", z=82., a, density);
136 
137  a= 39.95*g/mole;
138  density= 1.782e-03*g/cm3;
139  G4Material* Ar= new G4Material(name="ArgonGas", z=18., a, density);
140 
141  density= 1.032*g/cm3;
142  G4Material* Scinti= new G4Material(name="Scintillator", density, nel=2);
143  Scinti-> AddElement(elC, 9);
144  Scinti-> AddElement(elH, 10);
145 
146 
147  // ==============================================================
148  // Experimental Hall (world)
149  // ==============================================================
150  G4Tubs* expHallSolid=
151  new G4Tubs("EXP_HALL", 0., R_EXPHALL, DZ_EXPHALL, 0., 360.*deg);
152 
153  G4LogicalVolume* expHallLV=
154  new G4LogicalVolume(expHallSolid, Air, "EXP_HALL_LV");
155 
156  // visualization attributes
157  G4VisAttributes* expHallVisAtt=
158  new G4VisAttributes(false, G4Colour(1., 1., 1.));
159  //expHallVisAtt-> SetForceWireframe(TRUE);
160  expHallLV-> SetVisAttributes(expHallVisAtt);
161 
162  G4PVPlacement* expHall= new G4PVPlacement(0, G4ThreeVector(), "EXP_HALL_PV",
163  expHallLV, 0, FALSE, 0);
164  // ... MV, MANY, copy#
165 
166  // ==============================================================
167  // each detector component
168  // ==============================================================
169  // calorimeter system
170  G4Tubs* barrelCalSolid=
171  new G4Tubs("BARREL_CAL", RIN_BARREL_CAL, ROUT_BARREL_CAL,
172  DZ_BARREL_CAL, 0., 360.*deg);
173 
174  G4Tubs* endcapCalSolid=
175  new G4Tubs("ENDCAP_CAL", RIN_ENDCAP_CAL, ROUT_ENDCAP_CAL,
176  DZ_ENDCAP_CAL, 0., 360.*deg);
177 
178  G4LogicalVolume* barrelCalLV=
179  new G4LogicalVolume(barrelCalSolid, Lead, "BARREL_CAL_LV");
180 
181  G4LogicalVolume* endcapCalLV=
182  new G4LogicalVolume(endcapCalSolid, Lead, "ENDCAP_CAL_LV");
183 
184  G4VisAttributes* calVisAtt=
185  new G4VisAttributes(true, G4Colour(0., 1., 1.));
186  barrelCalLV-> SetVisAttributes(calVisAtt);
187  endcapCalLV-> SetVisAttributes(calVisAtt);
188 
189  // G4PVPlacement* barrelCal=
190  new G4PVPlacement(0, G4ThreeVector(), "BARREL_CAL_PV",
191  barrelCalLV, expHall, FALSE, 0);
192 
193  G4ThreeVector posCal(0.,0.,6.*m);
194  // G4PVPlacement* endcapCal1=
195  new G4PVPlacement(0, posCal, "ENDCAP_CAL_PV",
196  endcapCalLV, expHall, FALSE, 0);
197 
198  //G4PVPlacement* endcapCal2=
199  new G4PVPlacement(0, -posCal, "ENDCAP_CAL_PV",
200  endcapCalLV, expHall, FALSE, 1);
201 
202  // muon system
203  G4Box* barrelMuonSolid= new G4Box("BARREL_MUON", DX_BARREL_MUON,
204  DY_BARREL_MUON, DZ_BARREL_MUON);
205  G4Tubs* endcapMuonSolid=
206  new G4Tubs("ENDCAP_MUON", RIN_ENDCAP_MUON, ROUT_ENDCAP_MUON,
207  DZ_ENDCAP_MUON, 0., 360.*deg);
208 
209  G4LogicalVolume* barrelMuonLV=
210  new G4LogicalVolume(barrelMuonSolid, Ar, "BARREL_MUON_LV");
211 
212  G4LogicalVolume* endcapMuonLV=
213  new G4LogicalVolume(endcapMuonSolid, Ar, "ENDCAP_MUON_LV");
214 
215  G4VisAttributes* muonVisAtt=
216  new G4VisAttributes(true, G4Colour(1., 1., 0.5));
217  //muonVisAtt-> SetForceWireframe(TRUE);
218  barrelMuonLV-> SetVisAttributes(muonVisAtt);
219  endcapMuonLV-> SetVisAttributes(muonVisAtt);
220 
221  const G4double dangle= 45.*deg;
222  G4ThreeVector posM(RIN_BARREL_MUON+DY_BARREL_MUON/2., 0., 0.);
224  rotM->rotateZ(90.*deg);
225 
226  for (G4int k=0; k<8; k++) {
227  G4Transform3D transformM(*rotM, posM);
228  new G4PVPlacement(transformM, "BARREL_MUON_PV",
229  barrelMuonLV, expHall, FALSE, k);
230  rotM->rotateZ(dangle);
231  posM.rotateZ(dangle);
232  }
233 
234  G4ThreeVector posMuon(0.,0.,8.*m);
235  // G4PVPlacement* endcapMuon1=
236  new G4PVPlacement(0, posMuon, "ENDCAP_MUON_PV",
237  endcapMuonLV, expHall, FALSE, 0);
238 
239  // G4PVPlacement* endcapMuon2=
240  new G4PVPlacement(0, -posMuon, "ENDCAP_MUON_PV",
241  endcapMuonLV, expHall, FALSE, 1);
242 
243 
244  // sensitive Detectors
246 
247  G4String muonSDname= "/mydet/muon";
248  H02MuonSD* muonSD= new H02MuonSD(muonSDname);
249  SDman-> AddNewDetector(muonSD);
250  barrelMuonLV-> SetSensitiveDetector(muonSD);
251  endcapMuonLV-> SetSensitiveDetector(muonSD);
252 
253  // magnetic field
254  H02Field* myfield = new H02Field;
255  G4FieldManager* fieldMgr=
257  fieldMgr-> SetDetectorField(myfield);
258  fieldMgr-> CreateChordFinder(myfield);
259 
260  return expHall;
261 }
262