Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExN07ParallelWorld.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 //
27 // $Id$
28 //
29 //
30 
31 #include "ExN07ParallelWorld.hh"
32 
33 #include "G4Tubs.hh"
34 #include "G4LogicalVolume.hh"
35 #include "G4PVPlacement.hh"
36 #include "G4PVReplica.hh"
37 
38 #include "G4SDManager.hh"
40 #include "G4VPrimitiveScorer.hh"
41 #include "G4PSEnergyDeposit.hh"
42 #include "G4PSNofSecondary.hh"
43 #include "G4PSTrackLength.hh"
44 #include "G4PSNofStep.hh"
46 #include "G4VSDFilter.hh"
47 #include "G4SDParticleFilter.hh"
48 #include "G4ios.hh"
49 #include "G4SystemOfUnits.hh"
50 
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 
69 {;}
70 
72 {
73  if(!constructed)
74  {
75  constructed = true;
76  SetupGeometry();
77  SetupDetectors();
78  }
79 }
80 
81 void 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 
124 void ExN07ParallelWorld::SetupDetectors()
125 {
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";
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 
161  layerLogical[i]->SetSensitiveDetector(det);
162  }
164 }
165 
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