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