source: trunk/examples/novice/N07/src/ExN07ParallelWorld.cc@ 1328

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

update to geant4.9.3

File size: 6.0 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//
27// $Id: ExN07ParallelWorld.cc,v 1.1 2007/05/04 01:49:28 asaim Exp $
28// GEANT4 tag $Name: geant4-09-03-cand-01 $
29//
30//
31
32#include "ExN07ParallelWorld.hh"
33
34#include "G4Tubs.hh"
35#include "G4LogicalVolume.hh"
36#include "G4PVPlacement.hh"
37#include "G4PVReplica.hh"
38
39#include "G4SDManager.hh"
40#include "G4MultiFunctionalDetector.hh"
41#include "G4VPrimitiveScorer.hh"
42#include "G4PSEnergyDeposit.hh"
43#include "G4PSNofSecondary.hh"
44#include "G4PSTrackLength.hh"
45#include "G4PSNofStep.hh"
46#include "G4PSMinKinEAtGeneration.hh"
47#include "G4VSDFilter.hh"
48#include "G4SDParticleFilter.hh"
49#include "G4ios.hh"
50
51ExN07ParallelWorld::ExN07ParallelWorld(G4String worldName)
52:G4VUserParallelWorld(worldName),constructed(false),serial(false)
53{
54 for(size_t i=0;i<3;i++)
55 {
56 calorLogical[i] = 0;
57 layerLogical[i] = 0;
58 calorPhysical[i] = 0;
59 layerPhysical[i] = 0;
60 }
61 totalThickness = 2.0*m;
62 numberOfLayers = 20;
63 calName[0] = "Calor-AP";
64 calName[1] = "Calor-BP";
65 calName[2] = "Calor-CP";
66}
67
68ExN07ParallelWorld::~ExN07ParallelWorld()
69{;}
70
71void ExN07ParallelWorld::Construct()
72{
73 if(!constructed)
74 {
75 constructed = true;
76 SetupGeometry();
77 SetupDetectors();
78 }
79}
80
81void ExN07ParallelWorld::SetupGeometry()
82{
83 //
84 // World
85 //
86 G4VPhysicalVolume* ghostWorld = GetWorld();
87 G4LogicalVolume* worldLogical = ghostWorld->GetLogicalVolume();
88
89 //
90 // Calorimeter
91 //
92 G4VSolid* calorSolid = new G4Tubs("Calor",0.0,0.5*m,totalThickness/2.,0.0,360.*deg);
93 G4int i;
94 for(i=0;i<3;i++)
95 {
96 calorLogical[i] = new G4LogicalVolume(calorSolid,0,calName[i]);
97 if(serial)
98 {
99 calorPhysical[i] = new G4PVPlacement(0,
100 G4ThreeVector(0.,0.,G4double(i-1)*totalThickness),
101 calorLogical[i],calName[i],worldLogical,false,i);
102 }
103 else
104 {
105 calorPhysical[i] = new G4PVPlacement(0,
106 G4ThreeVector(0.,G4double(i-1)*m,0.),
107 calorLogical[i],calName[i],worldLogical,false,i);
108 }
109 }
110
111 //
112 // Layers --- as absorbers
113 //
114 G4VSolid* layerSolid = new G4Tubs("Layer",0.0,0.5*m,totalThickness/2.,0.0,360.*deg);
115 for(i=0;i<3;i++)
116 {
117 layerLogical[i] = new G4LogicalVolume(layerSolid,0,calName[i]+"_LayerLog");
118 layerPhysical[i] = new G4PVReplica(calName[i]+"_Layer",layerLogical[i],calorLogical[i],kRho,
119 numberOfLayers,0.5*m/numberOfLayers);
120 }
121
122}
123
124void ExN07ParallelWorld::SetupDetectors()
125{
126 G4SDManager::GetSDMpointer()->SetVerboseLevel(1);
127 G4String filterName, particleName;
128
129 G4SDParticleFilter* gammaFilter = new G4SDParticleFilter(filterName="gammaFilter",particleName="gamma");
130 G4SDParticleFilter* electronFilter = new G4SDParticleFilter(filterName="electronFilter",particleName="e-");
131 G4SDParticleFilter* positronFilter = new G4SDParticleFilter(filterName="positronFilter",particleName="e+");
132 G4SDParticleFilter* epFilter = new G4SDParticleFilter(filterName="epFilter");
133 epFilter->add(particleName="e-");
134 epFilter->add(particleName="e+");
135
136 for(G4int i=0;i<3;i++)
137 {
138 G4String detName = calName[i]+"_para";
139 G4MultiFunctionalDetector* det = new G4MultiFunctionalDetector(detName);
140
141 G4VPrimitiveScorer* primitive;
142 primitive = new G4PSEnergyDeposit("eDep");
143 det->RegisterPrimitive(primitive);
144 primitive = new G4PSNofSecondary("nGamma");
145 primitive->SetFilter(gammaFilter);
146 det->RegisterPrimitive(primitive);
147 primitive = new G4PSNofSecondary("nElectron");
148 primitive->SetFilter(electronFilter);
149 det->RegisterPrimitive(primitive);
150 primitive = new G4PSNofSecondary("nPositron");
151 primitive->SetFilter(positronFilter);
152 det->RegisterPrimitive(primitive);
153 primitive = new G4PSTrackLength("trackLength");
154 primitive->SetFilter(epFilter);
155 det->RegisterPrimitive(primitive);
156 primitive = new G4PSNofStep("nStep");
157 primitive->SetFilter(epFilter);
158 det->RegisterPrimitive(primitive);
159
160 G4SDManager::GetSDMpointer()->AddNewDetector(det);
161 layerLogical[i]->SetSensitiveDetector(det);
162 }
163 G4SDManager::GetSDMpointer()->SetVerboseLevel(0);
164}
165
166void ExN07ParallelWorld::SetSerialGeometry(G4bool ser)
167{
168 if(serial==ser) return;
169 serial=ser;
170 if(!constructed) return;
171 for(G4int i=0;i<3;i++)
172 {
173 if(serial)
174 { calorPhysical[i]->SetTranslation(G4ThreeVector(0.,0.,G4double(i-1)*2.*m)); }
175 else
176 { calorPhysical[i]->SetTranslation(G4ThreeVector(0.,G4double(i-1)*m,0.)); }
177 }
178}
179
Note: See TracBrowser for help on using the repository browser.