ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExN04DetectorConstruction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ExN04DetectorConstruction.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 
31 #include "G4Box.hh"
32 #include "G4Colour.hh"
33 #include "G4Element.hh"
34 #include "G4NistManager.hh"
35 #include "G4FieldManager.hh"
36 #include "G4LogicalVolume.hh"
37 #include "G4Material.hh"
38 #include "G4MaterialTable.hh"
39 #include "G4PVParameterised.hh"
40 #include "G4PVPlacement.hh"
41 #include "G4ThreeVector.hh"
42 #include "G4Tubs.hh"
43 #include "G4RotationMatrix.hh"
44 #include "G4Transform3D.hh"
46 #include "G4SDManager.hh"
47 #include "G4SystemOfUnits.hh"
48 #include "G4VisAttributes.hh"
49 #include "ExN04CalorimeterParametrisation.hh"
50 #include "ExN04CalorimeterROGeometry.hh"
51 #include "ExN04CalorimeterSD.hh"
52 #include "ExN04DetectorConstruction.hh"
53 #include "ExN04Field.hh"
54 #include "ExN04MuonSD.hh"
55 #include "ExN04TrackerParametrisation.hh"
56 #include "ExN04TrackerSD.hh"
57 
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 {
63 #include "ExN04DetectorParameterDef.icc"
64 }
65 
66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68 {
69 }
70 
71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 {
74  //-------------------------------------------------------------------------
75  // Materials
76  //-------------------------------------------------------------------------
77  G4NistManager* nistManager = G4NistManager::Instance();
78  fAir = nistManager->FindOrBuildMaterial("G4_AIR");
79  fLead = nistManager->FindOrBuildMaterial("G4_Pb");
80  fSilicon = nistManager->FindOrBuildMaterial("G4_Si");
81 
82  G4double a, z, density;
83  G4int nel;
84 
85  // Argon gas
86  a= 39.95*g/mole;
87  density= 1.782e-03*g/cm3;
88  fAr= new G4Material("ArgonGas", z=18., a, density);
89 
90  // Scintillator
91  G4Element* elH = nistManager->FindOrBuildElement("H");
92  G4Element* elC = nistManager->FindOrBuildElement("C");
93  fScinti = new G4Material("Scintillator", density= 1.032*g/cm3, nel=2);
94  fScinti-> AddElement(elC, 9);
95  fScinti-> AddElement(elH, 10);
96 }
97 
98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
100 {
101  //-------------------------------------------------------------------------
102  // Magnetic field
103  //-------------------------------------------------------------------------
104 
105  static G4bool fieldIsInitialized = false;
106  if ( !fieldIsInitialized ) {
107  ExN04Field* myField = new ExN04Field;
108  G4FieldManager* fieldMgr
110  GetFieldManager();
111  fieldMgr-> SetDetectorField(myField);
112  fieldMgr-> CreateChordFinder(myField);
113  fieldIsInitialized = true;
114  }
115 
116  //-------------------------------------------------------------------------
117  // Materials
118  //-------------------------------------------------------------------------
119  DefineMaterials();
120 
121  //-------------------------------------------------------------------------
122  // Detector geometry
123  //-------------------------------------------------------------------------
124 
125  //------------------------------ experimental hall
126  G4Box* experimentalHall_box =
127  new G4Box("expHall_b", fexpHall_x, fexpHall_y, fexpHall_z);
128  G4LogicalVolume* experimentalHall_log =
129  new G4LogicalVolume(experimentalHall_box, fAir,"expHall_L", 0,0,0);
130  G4VPhysicalVolume * experimentalHall_phys =
131  new G4PVPlacement(0, G4ThreeVector(), experimentalHall_log,
132  "expHall_P", 0, false,0);
133  G4VisAttributes* experimentalHallVisAtt =
134  new G4VisAttributes(G4Colour(1.,1.,1.));
135  experimentalHallVisAtt-> SetForceWireframe(true);
136  experimentalHall_log-> SetVisAttributes(experimentalHallVisAtt);
137 
138  //------------------------------ tracker
139  G4VSolid* tracker_tubs
140  = new G4Tubs("trkTubs_tubs", ftrkTubs_rmin, ftrkTubs_rmax, ftrkTubs_dz,
142  G4LogicalVolume* tracker_log
143  = new G4LogicalVolume(tracker_tubs, fAr,"trackerT_L",0,0,0);
144  // G4VPhysicalVolume * tracker_phys =
145  new G4PVPlacement(0,G4ThreeVector(), tracker_log, "tracker_phys",
146  experimentalHall_log, false, 0);
147  G4VisAttributes* tracker_logVisAtt
148  = new G4VisAttributes(G4Colour(1.0,0.0,1.0));
149  tracker_logVisAtt->SetForceWireframe(true);
150  tracker_log->SetVisAttributes(tracker_logVisAtt);
151 
152  //------------------------------ tracker layers
153  // As an example for Parameterised volume
154  // dummy values for G4Tubs -- modified by parameterised volume
155  G4VSolid* trackerLayer_tubs
156  = new G4Tubs("trackerLayer_tubs", ftrkTubs_rmin, ftrkTubs_rmax, ftrkTubs_dz,
158  G4LogicalVolume* trackerLayer_log
159  = new G4LogicalVolume(trackerLayer_tubs, fSilicon,"trackerB_L",0,0,0);
160  G4VPVParameterisation* trackerParam
162  // dummy value : kXAxis -- modified by parameterised volume
163  // G4VPhysicalVolume *trackerLayer_phys =
164  new G4PVParameterised("trackerLayer_phys", trackerLayer_log, tracker_log,
165  kXAxis, fnotrkLayers, trackerParam);
166  G4VisAttributes* trackerLayer_logVisAtt
167  = new G4VisAttributes(G4Colour(0.5,0.0,1.0));
168  trackerLayer_logVisAtt->SetForceWireframe(true);
169  trackerLayer_log->SetVisAttributes(trackerLayer_logVisAtt);
170 
171  //------------------------------ calorimeter
172  G4VSolid* calorimeter_tubs
173  = new G4Tubs("calorimeter_tubs", fcaloTubs_rmin, fcaloTubs_rmax,
175  G4LogicalVolume* calorimeter_log
176  = new G4LogicalVolume(calorimeter_tubs, fScinti, "caloT_L",0,0,0);
177  // G4VPhysicalVolume * calorimeter_phys =
178  new G4PVPlacement(0,G4ThreeVector(), calorimeter_log, "caloM_P",
179  experimentalHall_log, false,0);
180  G4VisAttributes* calorimeter_logVisATT
181  = new G4VisAttributes(G4Colour(1.0,1.0,0.0));
182  calorimeter_logVisATT->SetForceWireframe(true);
183  calorimeter_log->SetVisAttributes(calorimeter_logVisATT);
184 
185  //------------------------------- Lead layers
186  // As an example for Parameterised volume
187  // dummy values for G4Tubs -- modified by parameterised volume
188  G4VSolid* caloLayer_tubs
189  = new G4Tubs("caloLayer_tubs", fcaloRing_rmin, fcaloRing_rmax,
191  G4LogicalVolume* caloLayer_log
192  = new G4LogicalVolume(caloLayer_tubs, fLead, "caloR_L",0,0,0);
193  G4VPVParameterisation* calorimeterParam
195  // dummy value : kXAxis -- modified by parameterised volume
196  // G4VPhysicalVolume * caloLayer_phys =
197  new G4PVParameterised("caloLayer_phys",caloLayer_log,calorimeter_log,
198  kXAxis, fnocaloLayers, calorimeterParam);
199  G4VisAttributes* caloLayer_logVisAtt
200  = new G4VisAttributes(G4Colour(0.7,1.0,0.0));
201  caloLayer_logVisAtt->SetForceWireframe(true);
202  caloLayer_log->SetVisAttributes(caloLayer_logVisAtt);
203 
204  //------------------------------ muon counters
205  // As an example of CSG volumes with rotation
206  G4VSolid* muoncounter_box
207  = new G4Box("muoncounter_box", fmuBox_width, fmuBox_thick, fmuBox_length);
208  G4LogicalVolume* muoncounter_log
209  = new G4LogicalVolume(muoncounter_box, fScinti, "mucounter_L",0,0,0);
210  G4VPhysicalVolume* muoncounter_phys;
211  for( G4int i = 0; i < fnomucounter; i++ ) {
212  G4double phi, x, y, z;
213  phi = 360.*deg/fnomucounter*i;
214  x = fmuBox_radius*std::sin(phi);
215  y = fmuBox_radius*std::cos(phi);
216  z = 0.*cm;
217  G4RotationMatrix rm;
218  rm.rotateZ(phi);
219  muoncounter_phys
220  = new G4PVPlacement(G4Transform3D(rm,G4ThreeVector(x,y,z)),
221  muoncounter_log, "muoncounter_P",
222  experimentalHall_log,false,i);
223  }
224  G4VisAttributes* muoncounter_logVisAtt
225  = new G4VisAttributes(G4Colour(0.0,1.0,1.0));
226  muoncounter_logVisAtt->SetForceWireframe(true);
227  muoncounter_log->SetVisAttributes(muoncounter_logVisAtt);
228 
229  //------------------------------------------------------------------
230  // Sensitive Detector
231  //------------------------------------------------------------------
232 
234 
235  G4String trackerSDname = "/mydet/tracker";
236  ExN04TrackerSD * trackerSD = new ExN04TrackerSD(trackerSDname);
237  SDman->AddNewDetector(trackerSD);
238  trackerLayer_log->SetSensitiveDetector(trackerSD);
239 
240  G4String calorimeterSDname = "/mydet/calorimeter";
241  ExN04CalorimeterSD* calorimeterSD = new ExN04CalorimeterSD(calorimeterSDname);
242  G4String ROgeometryName = "CalorimeterROGeom";
243  G4VReadOutGeometry* calRO = new ExN04CalorimeterROGeometry(ROgeometryName);
244  calRO->BuildROGeometry();
245  calorimeterSD->SetROgeometry(calRO);
246  SDman->AddNewDetector(calorimeterSD);
247  calorimeter_log->SetSensitiveDetector(calorimeterSD);
248 
249  G4String muonSDname = "/mydet/muon";
250  ExN04MuonSD* muonSD = new ExN04MuonSD(muonSDname);
251  SDman->AddNewDetector(muonSD);
252  muoncounter_log->SetSensitiveDetector(muonSD);
253 
254  //------------------------------------------------------------------
255  // Digitizer modules
256  //------------------------------------------------------------------
257 
258  return experimentalHall_phys;
259 }