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 "ExP02DetectorConstruction.hh" |
---|
28 | |
---|
29 | #include "G4Material.hh" |
---|
30 | #include "G4Box.hh" |
---|
31 | #include "G4Tubs.hh" |
---|
32 | #include "G4LogicalVolume.hh" |
---|
33 | #include "G4ThreeVector.hh" |
---|
34 | #include "G4PVPlacement.hh" |
---|
35 | #include "globals.hh" |
---|
36 | |
---|
37 | //ROOT |
---|
38 | #include "TROOT.h" |
---|
39 | #include "TFile.h" |
---|
40 | #include "TSystem.h" |
---|
41 | #include "Cintex/Cintex.h" |
---|
42 | |
---|
43 | #include "ExP02GeoTree.hh" |
---|
44 | |
---|
45 | ExP02DetectorConstruction::ExP02DetectorConstruction() |
---|
46 | : experimentalHall_log(0), tracker_log(0), |
---|
47 | calorimeterBlock_log(0), calorimeterLayer_log(0), |
---|
48 | experimentalHall_phys(0), calorimeterLayer_phys(0), |
---|
49 | calorimeterBlock_phys(0), tracker_phys(0) |
---|
50 | {;} |
---|
51 | |
---|
52 | ExP02DetectorConstruction::~ExP02DetectorConstruction() |
---|
53 | { |
---|
54 | } |
---|
55 | |
---|
56 | G4VPhysicalVolume* ExP02DetectorConstruction::Construct() |
---|
57 | { |
---|
58 | |
---|
59 | //------------------------------------------------------ materials |
---|
60 | |
---|
61 | G4double a; // atomic mass |
---|
62 | G4double z; // atomic number |
---|
63 | G4double density; |
---|
64 | |
---|
65 | G4Material* Ar = |
---|
66 | new G4Material("ArgonGas", z= 18., a= 39.95*g/mole, density= 1.782*mg/cm3); |
---|
67 | |
---|
68 | G4Material* Al = |
---|
69 | new G4Material("Aluminum", z= 13., a= 26.98*g/mole, density= 2.7*g/cm3); |
---|
70 | |
---|
71 | G4Material* Pb = |
---|
72 | new G4Material("Lead", z= 82., a= 207.19*g/mole, density= 11.35*g/cm3); |
---|
73 | |
---|
74 | //------------------------------------------------------ volumes |
---|
75 | |
---|
76 | //------------------------------ experimental hall (world volume) |
---|
77 | //------------------------------ beam line along x axis |
---|
78 | |
---|
79 | G4double expHall_x = 3.0*m; |
---|
80 | G4double expHall_y = 1.0*m; |
---|
81 | G4double expHall_z = 1.0*m; |
---|
82 | G4Box* experimentalHall_box |
---|
83 | = new G4Box("expHall_box",expHall_x,expHall_y,expHall_z); |
---|
84 | experimentalHall_log = new G4LogicalVolume(experimentalHall_box, |
---|
85 | Ar,"expHall_log",0,0,0); |
---|
86 | experimentalHall_phys = new G4PVPlacement(0,G4ThreeVector(), |
---|
87 | experimentalHall_log,"expHall",0,false,0); |
---|
88 | |
---|
89 | //------------------------------ a tracker tube |
---|
90 | |
---|
91 | G4double innerRadiusOfTheTube = 0.*cm; |
---|
92 | G4double outerRadiusOfTheTube = 60.*cm; |
---|
93 | G4double hightOfTheTube = 50.*cm; |
---|
94 | G4double startAngleOfTheTube = 0.*deg; |
---|
95 | G4double spanningAngleOfTheTube = 360.*deg; |
---|
96 | G4Tubs* tracker_tube = new G4Tubs("tracker_tube",innerRadiusOfTheTube, |
---|
97 | outerRadiusOfTheTube,hightOfTheTube, |
---|
98 | startAngleOfTheTube,spanningAngleOfTheTube); |
---|
99 | tracker_log = new G4LogicalVolume(tracker_tube,Al,"tracker_log",0,0,0); |
---|
100 | G4double trackerPos_x = -1.0*m; |
---|
101 | G4double trackerPos_y = 0.*m; |
---|
102 | G4double trackerPos_z = 0.*m; |
---|
103 | tracker_phys = new G4PVPlacement(0, |
---|
104 | G4ThreeVector(trackerPos_x,trackerPos_y,trackerPos_z), |
---|
105 | tracker_log,"tracker",experimentalHall_log,false,0); |
---|
106 | |
---|
107 | //------------------------------ a calorimeter block |
---|
108 | |
---|
109 | G4double block_x = 1.0*m; |
---|
110 | G4double block_y = 50.0*cm; |
---|
111 | G4double block_z = 50.0*cm; |
---|
112 | G4Box* calorimeterBlock_box = new G4Box("calBlock_box",block_x, |
---|
113 | block_y,block_z); |
---|
114 | calorimeterBlock_log = new G4LogicalVolume(calorimeterBlock_box, |
---|
115 | Pb,"caloBlock_log",0,0,0); |
---|
116 | G4double blockPos_x = 1.0*m; |
---|
117 | G4double blockPos_y = 0.0*m; |
---|
118 | G4double blockPos_z = 0.0*m; |
---|
119 | calorimeterBlock_phys = new G4PVPlacement(0, |
---|
120 | G4ThreeVector(blockPos_x,blockPos_y,blockPos_z), |
---|
121 | calorimeterBlock_log,"caloBlock",experimentalHall_log,false,0); |
---|
122 | |
---|
123 | //------------------------------ calorimeter layers |
---|
124 | |
---|
125 | G4double calo_x = 1.*cm; |
---|
126 | G4double calo_y = 40.*cm; |
---|
127 | G4double calo_z = 40.*cm; |
---|
128 | G4Box* calorimeterLayer_box = new G4Box("caloLayer_box", |
---|
129 | calo_x,calo_y,calo_z); |
---|
130 | calorimeterLayer_log = new G4LogicalVolume(calorimeterLayer_box, |
---|
131 | Al,"caloLayer_log",0,0,0); |
---|
132 | for(G4int i=0;i<19;i++) // loop for 19 layers |
---|
133 | { |
---|
134 | G4double caloPos_x = (i-9)*10.*cm; |
---|
135 | G4double caloPos_y = 0.0*m; |
---|
136 | G4double caloPos_z = 0.0*m; |
---|
137 | calorimeterLayer_phys = new G4PVPlacement(0, |
---|
138 | G4ThreeVector(caloPos_x,caloPos_y,caloPos_z), |
---|
139 | calorimeterLayer_log,"caloLayer",calorimeterBlock_log,false,i); |
---|
140 | } |
---|
141 | |
---|
142 | //------------------------------------------------------------------ |
---|
143 | |
---|
144 | // writing the geometry to a ROOT file |
---|
145 | |
---|
146 | // initialize ROOT |
---|
147 | TSystem ts; |
---|
148 | |
---|
149 | gSystem->Load("libClassesDict"); |
---|
150 | |
---|
151 | // ROOT::Cintex::Cintex::SetDebug(2); |
---|
152 | ROOT::Cintex::Cintex::Enable(); |
---|
153 | // gDebug = 1; |
---|
154 | |
---|
155 | const G4ElementTable* eltab = G4Element::GetElementTable(); |
---|
156 | const G4MaterialTable* mattab = G4Material::GetMaterialTable(); |
---|
157 | |
---|
158 | ExP02GeoTree* geotree = new ExP02GeoTree(experimentalHall_phys, eltab, mattab); |
---|
159 | |
---|
160 | TFile fo("geo.root","RECREATE"); |
---|
161 | |
---|
162 | fo.WriteObject(geotree, "my_geo"); |
---|
163 | |
---|
164 | return experimentalHall_phys; |
---|
165 | } |
---|
166 | |
---|