source: trunk/examples/extended/runAndEvent/RE01/src/RE01DetectorConstruction.cc @ 807

Last change on this file since 807 was 807, checked in by garnier, 16 years ago

update

File size: 10.1 KB
Line 
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// $Id: RE01DetectorConstruction.cc,v 1.3 2006/06/29 17:43:46 gunter Exp $
27// GEANT4 tag $Name:  $
28//
29
30
31#include "RE01DetectorConstruction.hh"
32#include "RE01TrackerSD.hh"
33#include "RE01CalorimeterSD.hh"
34#include "RE01CalorimeterROGeometry.hh"
35#include "RE01TrackerParametrisation.hh"
36#include "RE01CalorimeterParametrisation.hh"
37#include "RE01Field.hh"
38#include "RE01RegionInformation.hh"
39
40#include "G4Material.hh"
41#include "G4MaterialTable.hh"
42#include "G4Element.hh"
43#include "G4ElementTable.hh"
44#include "G4Box.hh"
45#include "G4Tubs.hh"
46#include "G4LogicalVolume.hh"
47#include "G4ThreeVector.hh"
48#include "G4PVPlacement.hh"
49#include "G4PVParameterised.hh"
50#include "G4Transform3D.hh"
51#include "G4RotationMatrix.hh"
52#include "G4FieldManager.hh"
53#include "G4TransportationManager.hh"
54#include "G4SDManager.hh"
55#include "G4VisAttributes.hh"
56#include "G4Colour.hh"
57#include "G4Region.hh"
58#include "G4RegionStore.hh"
59
60RE01DetectorConstruction::RE01DetectorConstruction()
61{
62
63#include "RE01DetectorParameterDef.icc"
64
65}
66
67RE01DetectorConstruction::~RE01DetectorConstruction()
68{;}
69
70G4VPhysicalVolume* RE01DetectorConstruction::Construct()
71{
72  //-------------------------------------------------------------------------
73  // Magnetic field
74  //-------------------------------------------------------------------------
75/******************************************************************
76  static G4bool fieldIsInitialized = false;
77  if(!fieldIsInitialized)
78  {
79    RE01Field* myField = new RE01Field;
80    G4FieldManager* fieldMgr
81      = G4TransportationManager::GetTransportationManager()
82        ->GetFieldManager();
83    fieldMgr->SetDetectorField(myField);
84    fieldMgr->CreateChordFinder(myField);
85    fieldIsInitialized = true;
86  }
87*******************************************************************/
88  //-------------------------------------------------------------------------
89  // Materials
90  //-------------------------------------------------------------------------
91
92  G4double a, iz, z, density;
93  G4String name, symbol;
94  G4int nel;
95
96  a = 1.01*g/mole;
97  G4Element* elH = new G4Element(name="Hydrogen", symbol="H", iz=1., a);
98
99  a = 12.01*g/mole;
100  G4Element* elC = new G4Element(name="Carbon", symbol="C", iz=6., a);
101
102  a = 14.01*g/mole;
103  G4Element* elN = new G4Element(name="Nitrogen", symbol="N", iz=7., a);
104
105  a = 16.00*g/mole;
106  G4Element* elO = new G4Element(name="Oxygen", symbol="O", iz=8., a);
107
108  density = 1.29e-03*g/cm3;
109  G4Material* Air = new G4Material(name="Air", density, nel=2);
110  Air->AddElement(elN, .7);
111  Air->AddElement(elO, .3);
112
113  a = 207.19*g/mole;
114  density = 11.35*g/cm3;
115  G4Material* Lead = new G4Material(name="Lead", z=82., a, density);
116
117  a = 39.95*g/mole;
118  density = 1.782e-03*g/cm3;
119  G4Material* Ar = new G4Material(name="ArgonGas", z=18., a, density);
120
121  a = 28.09*g/mole;
122  density = 2.33*g/cm3;
123  G4Material * Silicon = new G4Material(name="Silicon", z=14., a, density);
124
125  density = 1.032*g/cm3;
126  G4Material* Scinti = new G4Material(name="Scintillator", density, nel=2);
127  Scinti->AddElement(elC, 9);
128  Scinti->AddElement(elH, 10);
129
130  //-------------------------------------------------------------------------
131  // Detector geometry
132  //-------------------------------------------------------------------------
133
134  //------------------------------ experimental hall
135  G4Box * experimentalHall_box
136    = new G4Box("expHall_b",expHall_x,expHall_y,expHall_z);
137  G4LogicalVolume * experimentalHall_log
138    = new G4LogicalVolume(experimentalHall_box,Air,"expHall_L",0,0,0);
139  G4VPhysicalVolume * experimentalHall_phys
140    = new G4PVPlacement(0,G4ThreeVector(),experimentalHall_log,"expHall_P",
141                        0,false,0);
142  G4VisAttributes* experimentalHallVisAtt
143    = new G4VisAttributes(G4Colour(1.0,1.0,1.0));
144  experimentalHallVisAtt->SetForceWireframe(true);
145  experimentalHall_log->SetVisAttributes(experimentalHallVisAtt);
146  G4Region* defaultRegion = (*(G4RegionStore::GetInstance()))[0];
147  RE01RegionInformation* defaultRInfo = new RE01RegionInformation();
148  defaultRInfo->SetWorld();
149  defaultRegion->SetUserInformation(defaultRInfo);
150
151  //------------------------------ tracker
152  G4VSolid * tracker_tubs
153    = new G4Tubs("trkTubs_tubs",trkTubs_rmin,trkTubs_rmax,trkTubs_dz,
154                 trkTubs_sphi,trkTubs_dphi);
155  G4LogicalVolume * tracker_log
156    = new G4LogicalVolume(tracker_tubs,Ar,"trackerT_L",0,0,0);
157  // G4VPhysicalVolume * tracker_phys =
158      new G4PVPlacement(0,G4ThreeVector(),tracker_log,"tracker_phys",
159                        experimentalHall_log,false,0);
160  G4VisAttributes* tracker_logVisAtt
161    = new G4VisAttributes(G4Colour(1.0,0.0,1.0));
162  tracker_logVisAtt->SetForceWireframe(true);
163  tracker_log->SetVisAttributes(tracker_logVisAtt);
164  G4Region* trackerRegion = new G4Region("TrackerRegion");
165  RE01RegionInformation* trackerInfo = new RE01RegionInformation();
166  trackerInfo->SetTracker();
167  trackerRegion->SetUserInformation(trackerInfo);
168  tracker_log->SetRegion(trackerRegion);
169  trackerRegion->AddRootLogicalVolume(tracker_log);
170
171
172  //------------------------------ tracker layers
173  // As an example for Parameterised volume
174  // dummy values for G4Tubs -- modified by parameterised volume
175  G4VSolid * trackerLayer_tubs
176    = new G4Tubs("trackerLayer_tubs",trkTubs_rmin,trkTubs_rmax,trkTubs_dz,
177                 trkTubs_sphi,trkTubs_dphi);
178  G4LogicalVolume * trackerLayer_log
179    = new G4LogicalVolume(trackerLayer_tubs,Silicon,"trackerB_L",0,0,0);
180  G4VPVParameterisation * trackerParam
181    = new RE01TrackerParametrisation;
182  // dummy value : kXAxis -- modified by parameterised volume
183  // G4VPhysicalVolume *trackerLayer_phys =
184      new G4PVParameterised("trackerLayer_phys",trackerLayer_log,tracker_log,
185                           kXAxis, notrkLayers, trackerParam);
186  G4VisAttributes* trackerLayer_logVisAtt
187    = new G4VisAttributes(G4Colour(0.5,0.0,1.0));
188  trackerLayer_logVisAtt->SetForceWireframe(true);
189  trackerLayer_log->SetVisAttributes(trackerLayer_logVisAtt);
190
191  //------------------------------ calorimeter
192  G4VSolid * calorimeter_tubs
193    = new G4Tubs("calorimeter_tubs",caloTubs_rmin,caloTubs_rmax,
194                  caloTubs_dz,caloTubs_sphi,caloTubs_dphi);
195  G4LogicalVolume * calorimeter_log
196    = new G4LogicalVolume(calorimeter_tubs,Scinti,"caloT_L",0,0,0);
197  // G4VPhysicalVolume * calorimeter_phys =
198      new G4PVPlacement(0,G4ThreeVector(),calorimeter_log,"caloM_P",
199                        experimentalHall_log,false,0);
200  G4VisAttributes* calorimeter_logVisATT
201    = new G4VisAttributes(G4Colour(1.0,1.0,0.0));
202  calorimeter_logVisATT->SetForceWireframe(true);
203  calorimeter_log->SetVisAttributes(calorimeter_logVisATT);
204  G4Region* calorimeterRegion = new G4Region("CalorimeterRegion");
205  RE01RegionInformation* calorimeterInfo = new RE01RegionInformation();
206  calorimeterInfo->SetCalorimeter();
207  calorimeterRegion->SetUserInformation(calorimeterInfo);
208  calorimeter_log->SetRegion(calorimeterRegion);
209  calorimeterRegion->AddRootLogicalVolume(calorimeter_log);
210
211  //------------------------------- Lead layers
212  // As an example for Parameterised volume
213  // dummy values for G4Tubs -- modified by parameterised volume
214  G4VSolid * caloLayer_tubs
215    = new G4Tubs("caloLayer_tubs",caloRing_rmin,caloRing_rmax,
216                  caloRing_dz,caloRing_sphi,caloRing_dphi);
217  G4LogicalVolume * caloLayer_log
218    = new G4LogicalVolume(caloLayer_tubs,Lead,"caloR_L",0,0,0);
219  G4VPVParameterisation * calorimeterParam
220    = new RE01CalorimeterParametrisation;
221  // dummy value : kXAxis -- modified by parameterised volume
222  // G4VPhysicalVolume * caloLayer_phys =
223      new G4PVParameterised("caloLayer_phys",caloLayer_log,calorimeter_log,
224                           kXAxis, nocaloLayers, calorimeterParam);
225  G4VisAttributes* caloLayer_logVisAtt
226    = new G4VisAttributes(G4Colour(0.7,1.0,0.0));
227  caloLayer_logVisAtt->SetForceWireframe(true);
228  caloLayer_log->SetVisAttributes(caloLayer_logVisAtt);
229
230  //------------------------------------------------------------------
231  // Sensitive Detector
232  //------------------------------------------------------------------
233
234  G4SDManager* SDman = G4SDManager::GetSDMpointer();
235
236  G4String trackerSDname = "/mydet/tracker";
237  RE01TrackerSD * trackerSD = new RE01TrackerSD(trackerSDname);
238  SDman->AddNewDetector(trackerSD);
239  trackerLayer_log->SetSensitiveDetector(trackerSD);
240
241  G4String calorimeterSDname = "/mydet/calorimeter";
242  RE01CalorimeterSD * calorimeterSD = new RE01CalorimeterSD(calorimeterSDname);
243  G4String ROgeometryName = "CalorimeterROGeom";
244  G4VReadOutGeometry* calRO = new RE01CalorimeterROGeometry(ROgeometryName);
245  calRO->BuildROGeometry();
246  calorimeterSD->SetROgeometry(calRO);
247  SDman->AddNewDetector(calorimeterSD);
248  calorimeter_log->SetSensitiveDetector(calorimeterSD);
249
250  return experimentalHall_phys;
251}
252
Note: See TracBrowser for help on using the repository browser.