Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE01DetectorConstruction.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 // $Id$
30 //
31 
33 #include "RE01TrackerSD.hh"
34 #include "RE01CalorimeterSD.hh"
38 #include "RE01Field.hh"
39 #include "RE01RegionInformation.hh"
40 
41 #include "G4NistManager.hh"
42 #include "G4Material.hh"
43 #include "G4MaterialTable.hh"
44 #include "G4Element.hh"
45 #include "G4ElementTable.hh"
46 #include "G4Box.hh"
47 #include "G4Tubs.hh"
48 #include "G4LogicalVolume.hh"
49 #include "G4ThreeVector.hh"
50 #include "G4PVPlacement.hh"
51 #include "G4PVParameterised.hh"
52 #include "G4Transform3D.hh"
53 #include "G4RotationMatrix.hh"
54 #include "G4FieldManager.hh"
56 #include "G4SDManager.hh"
57 #include "G4VisAttributes.hh"
58 #include "G4Colour.hh"
59 #include "G4Region.hh"
60 #include "G4RegionStore.hh"
61 #include "G4SystemOfUnits.hh"
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 {
67 #include "RE01DetectorParameterDef.icc"
68 }
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72 {;}
73 
74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 {
77  //-------------------------------------------------------------------------
78  // Magnetic field
79  //-------------------------------------------------------------------------
80  /******************************************************************
81  static G4bool fieldIsInitialized = false;
82  if(!fieldIsInitialized)
83  {
84  RE01Field* myField = new RE01Field;
85  G4FieldManager* fieldMgr
86  = G4TransportationManager::GetTransportationManager()
87  ->GetFieldManager();
88  fieldMgr->SetDetectorField(myField);
89  fieldMgr->CreateChordFinder(myField);
90  fieldIsInitialized = true;
91  }
92  *******************************************************************/
93  //-------------------------------------------------------------------------
94  // Materials
95  //-------------------------------------------------------------------------
96 
97  G4double a, iz, density;
99  G4int nel;
100 
101  a = 1.01*g/mole;
102  G4Element* elH = new G4Element(name="Hydrogen", symbol="H", iz=1., a);
103 
104  a = 12.01*g/mole;
105  G4Element* elC = new G4Element(name="Carbon", symbol="C", iz=6., a);
106 
107  // Material Information imported from NIST database.
109  G4Material* air = NISTman->FindOrBuildMaterial("G4_AIR");
110  G4Material* lead = NISTman->FindOrBuildMaterial("G4_Pb");
111  G4Material* arGas = NISTman->FindOrBuildMaterial("G4_Ar");
112  G4Material* silicon = NISTman->FindOrBuildMaterial("G4_Si");
113 
114  density = 1.032*g/cm3;
115  G4Material* scinti = new G4Material(name="Scintillator", density, nel=2);
116  scinti->AddElement(elC, 9);
117  scinti->AddElement(elH, 10);
118 
119  //-------------------------------------------------------------------------
120  // Detector geometry
121  //-------------------------------------------------------------------------
122  //------------------------------ experimental hall
123  G4Box * experimentalHall_box
124  = new G4Box("expHall_b",fExpHall_x,fExpHall_y,fExpHall_z);
125  G4LogicalVolume * experimentalHall_log
126  = new G4LogicalVolume(experimentalHall_box,air,"expHall_L",0,0,0);
127  G4VPhysicalVolume * experimentalHall_phys
128  = new G4PVPlacement(0,G4ThreeVector(),experimentalHall_log,"expHall_P",
129  0,false,0);
130  G4VisAttributes* experimentalHallVisAtt
131  = new G4VisAttributes(G4Colour(1.0,1.0,1.0));
132  experimentalHallVisAtt->SetForceWireframe(true);
133  experimentalHall_log->SetVisAttributes(experimentalHallVisAtt);
134  G4Region* defaultRegion = (*(G4RegionStore::GetInstance()))[0];
135  RE01RegionInformation* defaultRInfo = new RE01RegionInformation();
136  defaultRInfo->SetWorld();
137  defaultRInfo->Print();
138  defaultRegion->SetUserInformation(defaultRInfo);
139 
140  //------------------------------ tracker
141  G4VSolid * tracker_tubs
142  = new G4Tubs("trkTubs_tubs",fTrkTubs_rmin,fTrkTubs_rmax,fTrkTubs_dz,
143  fTrkTubs_sphi,fTrkTubs_dphi);
144  G4LogicalVolume * tracker_log
145  = new G4LogicalVolume(tracker_tubs,arGas,"trackerT_L",0,0,0);
146  // G4VPhysicalVolume * tracker_phys =
147  new G4PVPlacement(0,G4ThreeVector(),tracker_log,"tracker_phys",
148  experimentalHall_log,false,0);
149  G4VisAttributes* tracker_logVisAtt
150  = new G4VisAttributes(G4Colour(1.0,0.0,1.0));
151  tracker_logVisAtt->SetForceWireframe(true);
152  tracker_log->SetVisAttributes(tracker_logVisAtt);
153  G4Region* trackerRegion = new G4Region("TrackerRegion");
154  RE01RegionInformation* trackerInfo = new RE01RegionInformation();
155  trackerInfo->SetTracker();
156  trackerRegion->SetUserInformation(trackerInfo);
157  tracker_log->SetRegion(trackerRegion);
158  trackerRegion->AddRootLogicalVolume(tracker_log);
159 
160  //------------------------------ tracker layers
161  // As an example for Parameterised volume
162  // dummy values for G4Tubs -- modified by parameterised volume
163  G4VSolid * trackerLayer_tubs
164  = new G4Tubs("trackerLayer_tubs",fTrkTubs_rmin,fTrkTubs_rmax,fTrkTubs_dz,
165  fTrkTubs_sphi,fTrkTubs_dphi);
166  G4LogicalVolume * trackerLayer_log
167  = new G4LogicalVolume(trackerLayer_tubs,silicon,"trackerB_L",0,0,0);
168  G4VPVParameterisation * trackerParam
170  // dummy value : kXAxis -- modified by parameterised volume
171  // G4VPhysicalVolume *trackerLayer_phys =
172  new G4PVParameterised("trackerLayer_phys",trackerLayer_log,tracker_log,
173  kXAxis, fNotrkLayers, trackerParam);
174  G4VisAttributes* trackerLayer_logVisAtt
175  = new G4VisAttributes(G4Colour(0.5,0.0,1.0));
176  trackerLayer_logVisAtt->SetForceWireframe(true);
177  trackerLayer_log->SetVisAttributes(trackerLayer_logVisAtt);
178 
179  //------------------------------ calorimeter
180  G4VSolid * calorimeter_tubs
181  = new G4Tubs("calorimeter_tubs",fCaloTubs_rmin,fCaloTubs_rmax,
182  fCaloTubs_dz,fCaloTubs_sphi,fCaloTubs_dphi);
183  G4LogicalVolume * calorimeter_log
184  = new G4LogicalVolume(calorimeter_tubs,scinti,"caloT_L",0,0,0);
185  // G4VPhysicalVolume * calorimeter_phys =
186  new G4PVPlacement(0,G4ThreeVector(),calorimeter_log,"caloM_P",
187  experimentalHall_log,false,0);
188  G4VisAttributes* calorimeter_logVisATT
189  = new G4VisAttributes(G4Colour(1.0,1.0,0.0));
190  calorimeter_logVisATT->SetForceWireframe(true);
191  calorimeter_log->SetVisAttributes(calorimeter_logVisATT);
192  G4Region* calorimeterRegion = new G4Region("CalorimeterRegion");
193  RE01RegionInformation* calorimeterInfo = new RE01RegionInformation();
194  calorimeterInfo->SetCalorimeter();
195  calorimeterRegion->SetUserInformation(calorimeterInfo);
196  calorimeter_log->SetRegion(calorimeterRegion);
197  calorimeterRegion->AddRootLogicalVolume(calorimeter_log);
198 
199  //------------------------------- Lead layers
200  // As an example for Parameterised volume
201  // dummy values for G4Tubs -- modified by parameterised volume
202  G4VSolid * caloLayer_tubs
203  = new G4Tubs("caloLayer_tubs",fCaloRing_rmin,fCaloRing_rmax,
204  fCaloRing_dz,fCaloRing_sphi,fCaloRing_dphi);
205  G4LogicalVolume * caloLayer_log
206  = new G4LogicalVolume(caloLayer_tubs,lead,"caloR_L",0,0,0);
207  G4VPVParameterisation * calorimeterParam
209  // dummy value : kXAxis -- modified by parameterised volume
210  // G4VPhysicalVolume * caloLayer_phys =
211  new G4PVParameterised("caloLayer_phys",caloLayer_log,calorimeter_log,
212  kXAxis, fNocaloLayers, calorimeterParam);
213  G4VisAttributes* caloLayer_logVisAtt
214  = new G4VisAttributes(G4Colour(0.7,1.0,0.0));
215  caloLayer_logVisAtt->SetForceWireframe(true);
216  caloLayer_log->SetVisAttributes(caloLayer_logVisAtt);
217 
218  //------------------------------------------------------------------
219  // Sensitive Detector
220  //------------------------------------------------------------------
222 
223  G4String trackerSDname = "/mydet/tracker";
224  RE01TrackerSD * trackerSD = new RE01TrackerSD(trackerSDname);
225  SDman->AddNewDetector(trackerSD);
226  trackerLayer_log->SetSensitiveDetector(trackerSD);
227 
228  G4String calorimeterSDname = "/mydet/calorimeter";
229  RE01CalorimeterSD * calorimeterSD = new RE01CalorimeterSD(calorimeterSDname);
230  G4String ROgeometryName = "CalorimeterROGeom";
231  G4VReadOutGeometry* calRO = new RE01CalorimeterROGeometry(ROgeometryName);
232  calRO->BuildROGeometry();
233  calorimeterSD->SetROgeometry(calRO);
234  SDman->AddNewDetector(calorimeterSD);
235  calorimeter_log->SetSensitiveDetector(calorimeterSD);
236 
237  return experimentalHall_phys;
238 }
239