ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
H02DetectorConstruction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file H02DetectorConstruction.cc
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 "G4Box.hh"
31 #include "G4ChordFinder.hh"
32 #include "G4Element.hh"
33 #include "G4NistManager.hh"
34 #include "G4FieldManager.hh"
35 #include "G4LogicalVolume.hh"
36 #include "G4Material.hh"
37 #include "G4PVPlacement.hh"
38 #include "G4SDManager.hh"
39 #include "G4SystemOfUnits.hh"
41 #include "G4Tubs.hh"
42 #include "G4VisAttributes.hh"
43 #include "H02Field.hh"
45 #include "H02MuonSD.hh"
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 // constants (detector parameters)
49 // [experimental hall]
50 static const G4double R_EXPHALL= 5.*m;
51 static const G4double DZ_EXPHALL= 10.*m;
52 
53 // [calorimeter]
54 static const G4double RIN_BARREL_CAL= 2.*m;
55 static const G4double ROUT_BARREL_CAL= 3.*m;
56 static const G4double DZ_BARREL_CAL= 5.*m;
57 
58 static const G4double RIN_ENDCAP_CAL= 1.*m;
59 static const G4double ROUT_ENDCAP_CAL= 3.*m;
60 static const G4double DZ_ENDCAP_CAL= 0.5*m;
61 
62 // [muon system]
63 static const G4double RIN_BARREL_MUON= 4.3*m;
64 // static const G4double ROUT_BARREL_MUON= 4.5*m;
65 static const G4double DX_BARREL_MUON= RIN_BARREL_MUON*std::cos(67.5*deg)-5.*cm;
66 static const G4double DY_BARREL_MUON= 10.*cm;
67 static const G4double DZ_BARREL_MUON= 7.*m;
68 
69 static const G4double RIN_ENDCAP_MUON= 1.*m;
70 static const G4double ROUT_ENDCAP_MUON= 4.5*m;
71 static const G4double DZ_ENDCAP_MUON= 10.*cm;
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 {
77 }
78 
79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
81 {
82 }
83 
84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
86 {
87  // ==============================================================
88  // Materials
89  // ==============================================================
90 
91  G4NistManager* nistManager = G4NistManager::Instance();
92  G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
93  G4Material* lead = nistManager->FindOrBuildMaterial("G4_Pb");
94 
95  // Argon gas
96  G4double a, z, density;
97  a= 39.95*g/mole;
98  density= 1.782e-03*g/cm3;
99  G4Material* ar= new G4Material("ArgonGas", z=18., a, density);
100 
101 
102  // ==============================================================
103  // Experimental Hall (world)
104  // ==============================================================
105  G4Tubs* expHallSolid=
106  new G4Tubs("EXP_HALL", 0., R_EXPHALL, DZ_EXPHALL, 0., 360.*deg);
107 
108  G4LogicalVolume* expHallLV=
109  new G4LogicalVolume(expHallSolid, air, "EXP_HALL_LV");
110 
111  // visualization attributes
112  G4VisAttributes* expHallVisAtt=
113  new G4VisAttributes(false, G4Colour(1., 1., 1.));
114  //expHallVisAtt-> SetForceWireframe(TRUE);
115  expHallLV-> SetVisAttributes(expHallVisAtt);
116 
117  G4PVPlacement* expHall= new G4PVPlacement(0, G4ThreeVector(), "EXP_HALL_PV",
118  expHallLV, 0, FALSE, 0);
119  // ... MV, MANY, copy#
120 
121  // ==============================================================
122  // each detector component
123  // ==============================================================
124  // calorimeter system
125  G4Tubs* barrelCalSolid=
126  new G4Tubs("BARREL_CAL", RIN_BARREL_CAL, ROUT_BARREL_CAL,
127  DZ_BARREL_CAL, 0., 360.*deg);
128 
129  G4Tubs* endcapCalSolid=
130  new G4Tubs("ENDCAP_CAL", RIN_ENDCAP_CAL, ROUT_ENDCAP_CAL,
131  DZ_ENDCAP_CAL, 0., 360.*deg);
132 
133  G4LogicalVolume* barrelCalLV=
134  new G4LogicalVolume(barrelCalSolid, lead, "BARREL_CAL_LV");
135 
136  G4LogicalVolume* endcapCalLV=
137  new G4LogicalVolume(endcapCalSolid, lead, "ENDCAP_CAL_LV");
138 
139  G4VisAttributes* calVisAtt=
140  new G4VisAttributes(true, G4Colour(0., 1., 1.));
141  barrelCalLV-> SetVisAttributes(calVisAtt);
142  endcapCalLV-> SetVisAttributes(calVisAtt);
143 
144  // G4PVPlacement* barrelCal=
145  new G4PVPlacement(0, G4ThreeVector(), "BARREL_CAL_PV",
146  barrelCalLV, expHall, FALSE, 0);
147 
148  G4ThreeVector posCal(0.,0.,6.*m);
149  // G4PVPlacement* endcapCal1=
150  new G4PVPlacement(0, posCal, "ENDCAP_CAL_PV",
151  endcapCalLV, expHall, FALSE, 0);
152 
153  //G4PVPlacement* endcapCal2=
154  new G4PVPlacement(0, -posCal, "ENDCAP_CAL_PV",
155  endcapCalLV, expHall, FALSE, 1);
156 
157  // muon system
158  G4Box* barrelMuonSolid= new G4Box("BARREL_MUON", DX_BARREL_MUON,
160  G4Tubs* endcapMuonSolid=
161  new G4Tubs("ENDCAP_MUON", RIN_ENDCAP_MUON, ROUT_ENDCAP_MUON,
162  DZ_ENDCAP_MUON, 0., 360.*deg);
163 
164  G4LogicalVolume* barrelMuonLV=
165  new G4LogicalVolume(barrelMuonSolid, ar, "BARREL_MUON_LV");
166 
167  G4LogicalVolume* endcapMuonLV=
168  new G4LogicalVolume(endcapMuonSolid, ar, "ENDCAP_MUON_LV");
169 
170  G4VisAttributes* muonVisAtt=
171  new G4VisAttributes(true, G4Colour(1., 1., 0.5));
172  //muonVisAtt-> SetForceWireframe(TRUE);
173  barrelMuonLV-> SetVisAttributes(muonVisAtt);
174  endcapMuonLV-> SetVisAttributes(muonVisAtt);
175 
176  const G4double dangle= 45.*deg;
179  rotM->rotateZ(90.*deg);
180 
181  for (G4int k=0; k<8; k++) {
182  G4Transform3D transformM(*rotM, posM);
183  new G4PVPlacement(transformM, "BARREL_MUON_PV",
184  barrelMuonLV, expHall, FALSE, k);
185  rotM->rotateZ(dangle);
186  posM.rotateZ(dangle);
187  }
188 
189  G4ThreeVector posMuon(0.,0.,8.*m);
190  // G4PVPlacement* endcapMuon1=
191  new G4PVPlacement(0, posMuon, "ENDCAP_MUON_PV",
192  endcapMuonLV, expHall, FALSE, 0);
193 
194  // G4PVPlacement* endcapMuon2=
195  new G4PVPlacement(0, -posMuon, "ENDCAP_MUON_PV",
196  endcapMuonLV, expHall, FALSE, 1);
197 
198 
199  // sensitive Detectors
201 
202  G4String muonSDname= "/mydet/muon";
203  H02MuonSD* muonSD= new H02MuonSD(muonSDname);
204  SDman-> AddNewDetector(muonSD);
205  barrelMuonLV-> SetSensitiveDetector(muonSD);
206  endcapMuonLV-> SetSensitiveDetector(muonSD);
207 
208  // magnetic field
209  H02Field* myfield = new H02Field;
210  G4FieldManager* fieldMgr=
212  fieldMgr-> SetDetectorField(myfield);
213  fieldMgr-> CreateChordFinder(myfield);
214 
215  return expHall;
216 }