Geant4_10
RE06ParallelWorld.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: RE06ParallelWorld.cc 75123 2013-10-28 09:53:28Z gcosmo $
30 //
31 
32 #include "RE06ParallelWorld.hh"
33 
34 #include "G4Tubs.hh"
35 #include "G4LogicalVolume.hh"
36 #include "G4PVPlacement.hh"
37 #include "G4PVReplica.hh"
38 
39 #include "G4SDManager.hh"
41 #include "G4VPrimitiveScorer.hh"
42 #include "G4PSEnergyDeposit.hh"
43 #include "G4PSNofSecondary.hh"
44 #include "G4PSTrackLength.hh"
45 #include "G4PSNofStep.hh"
47 #include "G4VSDFilter.hh"
48 #include "G4SDParticleFilter.hh"
49 #include "G4ios.hh"
50 #include "G4SystemOfUnits.hh"
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
55 :G4VUserParallelWorld(worldName),
56  fConstructed(false),
57  fSerial(false),
58  fTotalThickness(2.0*m),
59  fNumberOfLayers(20)
60 {
61  for(size_t i=0;i<3;i++)
62  {
63  fCalorLogical[i] = 0;
64  fLayerLogical[i] = 0;
65  fCalorPhysical[i] = 0;
66  fLayerPhysical[i] = 0;
67  }
68  fCalName[0] = "Calor-AP";
69  fCalName[1] = "Calor-BP";
70  fCalName[2] = "Calor-CP";
71 }
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 
76 {;}
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79 
81 {
82  if(!fConstructed)
83  {
84  fConstructed = true;
85  SetupGeometry();
86  //SetupDetectors();
87  }
88 }
89 
90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
91 
93 {
94  SetupDetectors();
95 }
96 
97 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
98 void RE06ParallelWorld::SetupGeometry()
99 {
100  //
101  // World
102  //
103  G4VPhysicalVolume* ghostWorld = GetWorld();
104  G4LogicalVolume* worldLogical = ghostWorld->GetLogicalVolume();
105 
106  //
107  // Calorimeter
108  //
109  G4VSolid* calorSolid
110  = new G4Tubs("Calor",0.0,0.5*m,fTotalThickness/2.,0.0,360.*deg);
111  G4int i;
112  for(i=0;i<3;i++)
113  {
114  fCalorLogical[i] = new G4LogicalVolume(calorSolid,0,fCalName[i]);
115  if(fSerial)
116  {
117  fCalorPhysical[i] = new G4PVPlacement(0,
118  G4ThreeVector(0.,0.,G4double(i-1)*fTotalThickness),
119  fCalorLogical[i],fCalName[i],worldLogical,false,i);
120  }
121  else
122  {
123  fCalorPhysical[i] = new G4PVPlacement(0,
124  G4ThreeVector(0.,G4double(i-1)*m,0.),
125  fCalorLogical[i],fCalName[i],worldLogical,false,i);
126  }
127  }
128 
129  //
130  // Layers --- as absorbers
131  //
132  G4VSolid* layerSolid
133  = new G4Tubs("Layer",0.0,0.5*m,fTotalThickness/2.,0.0,360.*deg);
134  for(i=0;i<3;i++)
135  {
136  fLayerLogical[i]
137  = new G4LogicalVolume(layerSolid,0,fCalName[i]+"_LayerLog");
138  fLayerPhysical[i]
139  = new G4PVReplica(fCalName[i]+"_Layer",fLayerLogical[i],fCalorLogical[i],
140  kRho,fNumberOfLayers,0.5*m/fNumberOfLayers);
141  }
142 
143 }
144 
145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
146 
147 void RE06ParallelWorld::SetupDetectors()
148 {
150  G4String filterName, particleName;
151 
152  G4SDParticleFilter* gammaFilter
153  = new G4SDParticleFilter(filterName="gammaFilter",particleName="gamma");
154  G4SDParticleFilter* electronFilter
155  = new G4SDParticleFilter(filterName="electronFilter",particleName="e-");
156  G4SDParticleFilter* positronFilter
157  = new G4SDParticleFilter(filterName="positronFilter",particleName="e+");
158  G4SDParticleFilter* epFilter
159  = new G4SDParticleFilter(filterName="epFilter");
160  epFilter->add(particleName="e-");
161  epFilter->add(particleName="e+");
162 
163  for(G4int i=0;i<3;i++)
164  {
165  G4String detName = fCalName[i]+"_para";
167 
168  G4VPrimitiveScorer* primitive;
169  primitive = new G4PSEnergyDeposit("eDep");
170  det->RegisterPrimitive(primitive);
171  primitive = new G4PSNofSecondary("nGamma");
172  primitive->SetFilter(gammaFilter);
173  det->RegisterPrimitive(primitive);
174  primitive = new G4PSNofSecondary("nElectron");
175  primitive->SetFilter(electronFilter);
176  det->RegisterPrimitive(primitive);
177  primitive = new G4PSNofSecondary("nPositron");
178  primitive->SetFilter(positronFilter);
179  det->RegisterPrimitive(primitive);
180  primitive = new G4PSTrackLength("trackLength");
181  primitive->SetFilter(epFilter);
182  det->RegisterPrimitive(primitive);
183  primitive = new G4PSNofStep("nStep");
184  primitive->SetFilter(epFilter);
185  det->RegisterPrimitive(primitive);
186 
188  SetSensitiveDetector(fLayerLogical[i], det);
189  }
191 
192 }
193 
194 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
195 
197 {
198  if(fSerial==serial) return;
199  fSerial=serial;
200  if(!fConstructed) return;
201  for(G4int i=0;i<3;i++)
202  {
203  if(fSerial)
204  {
205  fCalorPhysical[i]
206  ->SetTranslation(G4ThreeVector(0.,0.,G4double(i-1)*2.*m));
207  }
208  else
209  {
210  fCalorPhysical[i]
211  ->SetTranslation(G4ThreeVector(0.,G4double(i-1)*m,0.));
212  }
213  }
214 }
215 
216 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool RegisterPrimitive(G4VPrimitiveScorer *)
CLHEP::Hep3Vector G4ThreeVector
G4VPhysicalVolume * GetWorld()
void SetVerboseLevel(G4int vl)
Definition: G4SDManager.hh:90
Definition: G4Tubs.hh:84
void SetFilter(G4VSDFilter *f)
virtual void ConstructSD()
Definition of the RE06ParallelWorld class.
RE06ParallelWorld(G4String worldName)
void SetSerialGeometry(G4bool ser)
int G4int
Definition: G4Types.hh:78
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
virtual void Construct()
bool G4bool
Definition: G4Types.hh:79
void SetTranslation(const G4ThreeVector &v)
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:67
G4LogicalVolume * GetLogicalVolume() const
void add(const G4String &particleName)
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
double G4double
Definition: G4Types.hh:76
virtual ~RE06ParallelWorld()
Definition: geomdefs.hh:54