Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
eventgenerator/HepMC/HepMCEx01/src/ExN04DetectorConstruction.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 //
26 /// \file eventgenerator/HepMC/HepMCEx01/src/ExN04DetectorConstruction.cc
27 /// \brief Implementation of the ExN04DetectorConstruction class
28 //
29 // $Id: ExN04DetectorConstruction.cc 77801 2013-11-28 13:33:20Z gcosmo $
30 //
31 
32 #include "G4Box.hh"
33 #include "G4Colour.hh"
34 #include "G4Element.hh"
35 #include "G4ElementTable.hh"
36 #include "G4FieldManager.hh"
37 #include "G4LogicalVolume.hh"
38 #include "G4Material.hh"
39 #include "G4MaterialTable.hh"
40 #include "G4PVParameterised.hh"
41 #include "G4PVPlacement.hh"
42 #include "G4ThreeVector.hh"
43 #include "G4Tubs.hh"
44 #include "G4RotationMatrix.hh"
45 #include "G4Transform3D.hh"
47 #include "G4SDManager.hh"
48 #include "G4SystemOfUnits.hh"
49 #include "G4VisAttributes.hh"
50 #include "ExN04CalorimeterParametrisation.hh"
51 #include "ExN04CalorimeterROGeometry.hh"
52 #include "ExN04CalorimeterSD.hh"
53 #include "ExN04DetectorConstruction.hh"
54 #include "ExN04Field.hh"
55 #include "ExN04MuonSD.hh"
56 #include "ExN04TrackerParametrisation.hh"
57 #include "ExN04TrackerSD.hh"
58 
59 
60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 {
63 #include "ExN04DetectorParameterDef.icc"
64  DefineMaterials();
65 }
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
69 {
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 void ExN04DetectorConstruction::DefineMaterials()
74 {
75  //-------------------------------------------------------------------------
76  // Materials
77  //-------------------------------------------------------------------------
78 
79  G4double a, z, density;
80  G4int nel;
81 
82  G4Element* H = new G4Element("Hydrogen", "H", z=1., a= 1.01*g/mole);
83  G4Element* C = new G4Element("Carbon", "C", z=6., a= 12.01*g/mole);
84  G4Element* N = new G4Element("Nitrogen", "N", z=7., a= 14.01*g/mole);
85  G4Element* O = new G4Element("Oxygen", "O", z=8., a= 16.00*g/mole);
86 
87  fAir = new G4Material("Air", density= 1.29*mg/cm3, nel=2);
88  fAir-> AddElement(N, 70.*perCent);
89  fAir-> AddElement(O, 30.*perCent);
90 
91  fLead = new G4Material("Lead", z=82., a= 207.19*g/mole, density= 11.35*g/cm3);
92 
93  fAr = new G4Material("ArgonGas",z=18., a= 39.95*g/mole, density=1.782*mg/cm3);
94 
95  fSilicon = new G4Material("Silicon", z=14., a= 28.09*g/mole,
96  density= 2.33*g/cm3);
97 
98  fScinti = new G4Material("Scintillator", density= 1.032*g/cm3, nel=2);
99  fScinti-> AddElement(C, 9);
100  fScinti-> AddElement(H, 10);
101 }
102 
103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
105 {
106  //-------------------------------------------------------------------------
107  // Magnetic field
108  //-------------------------------------------------------------------------
109 
110  static G4bool fieldIsInitialized = false;
111  if ( !fieldIsInitialized ) {
112  ExN04Field* myField = new ExN04Field;
113  G4FieldManager* fieldMgr
115  GetFieldManager();
116  fieldMgr-> SetDetectorField(myField);
117  fieldMgr-> CreateChordFinder(myField);
118  fieldIsInitialized = true;
119  }
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,
141  ftrkTubs_sphi, ftrkTubs_dphi);
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,
157  ftrkTubs_sphi, ftrkTubs_dphi);
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,
174  fcaloTubs_dz, fcaloTubs_sphi, fcaloTubs_dphi);
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,
190  fcaloRing_dz, fcaloRing_sphi, fcaloRing_dphi);
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 }
void SetForceWireframe(G4bool)
CLHEP::Hep3Vector G4ThreeVector
G4double z
Definition: TRTMaterials.hh:39
Definition: G4Box.hh:63
Definition: G4Tubs.hh:84
int G4int
Definition: G4Types.hh:78
G4double density
Definition: TRTMaterials.hh:39
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5205
bool G4bool
Definition: G4Types.hh:79
void SetROgeometry(G4VReadOutGeometry *value)
HepGeom::Transform3D G4Transform3D
static G4TransportationManager * GetTransportationManager()
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:67
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
HepRotation & rotateZ(double delta)
Definition: Rotation.cc:92
float perCent
Definition: hepunit.py:239
double G4double
Definition: G4Types.hh:76
Air AddElement(elN,.7)
void SetVisAttributes(const G4VisAttributes *pVA)
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)
G4int nel
Definition: TRTMaterials.hh:41