Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PVReplica.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// class G4PVReplica Implementation
31//
32// ----------------------------------------------------------------------
33
34#include "G4PVReplica.hh"
35#include "G4LogicalVolume.hh"
36
38 G4LogicalVolume* pLogical,
39 G4VPhysicalVolume* pMother,
40 const EAxis pAxis,
41 const G4int nReplicas,
42 const G4double width,
43 const G4double offset )
44 : G4VPhysicalVolume(0, G4ThreeVector(), pName, pLogical, pMother),
45 fcopyNo(-1), fRegularVolsId(0)
46{
47 if ((!pMother) || (!pMother->GetLogicalVolume()))
48 {
49 std::ostringstream message;
50 message << "NULL pointer specified as mother volume." << G4endl
51 << "The world volume cannot be sliced or parameterised !";
52 G4Exception("G4PVReplica::G4PVReplica()", "GeomVol0002",
53 FatalException, message);
54 return;
55 }
56 G4LogicalVolume* motherLogical = pMother->GetLogicalVolume();
57 if (pLogical == motherLogical)
58 {
59 G4Exception("G4PVReplica::G4PVReplica()", "GeomVol0002",
60 FatalException, "Cannot place a volume inside itself!");
61 return;
62 }
63 SetMotherLogical(motherLogical);
64 motherLogical->AddDaughter(this);
65 if (motherLogical->GetNoDaughters() != 1)
66 {
67 std::ostringstream message;
68 message << "Replica or parameterised volume must be the only daughter !"
69 << G4endl
70 << " Mother physical volume: " << pMother->GetName() << G4endl
71 << " Replicated volume: " << pName;
72 G4Exception("G4PVReplica::G4PVReplica()", "GeomVol0002",
73 FatalException, message);
74 return;
75 }
76 CheckAndSetParameters (pAxis, nReplicas, width, offset);
77}
78
80 G4LogicalVolume* pLogical,
81 G4LogicalVolume* pMotherLogical,
82 const EAxis pAxis,
83 const G4int nReplicas,
84 const G4double width,
85 const G4double offset )
86 : G4VPhysicalVolume(0,G4ThreeVector(),pName,pLogical,0),
87 fcopyNo(-1), fRegularVolsId(0)
88{
89 if (!pMotherLogical)
90 {
91 std::ostringstream message;
92 message << "NULL pointer specified as mother volume for "
93 << pName << ".";
94 G4Exception("G4PVReplica::G4PVReplica()", "GeomVol0002",
95 FatalException, message);
96 return;
97 }
98 if (pLogical == pMotherLogical)
99 {
100 G4Exception("G4PVReplica::G4PVReplica()", "GeomVol0002",
101 FatalException, "Cannot place a volume inside itself!");
102 return;
103 }
104 pMotherLogical->AddDaughter(this);
105 SetMotherLogical(pMotherLogical);
106 if (pMotherLogical->GetNoDaughters() != 1)
107 {
108 std::ostringstream message;
109 message << "Replica or parameterised volume must be the only daughter !"
110 << G4endl
111 << " Mother logical volume: " << pMotherLogical->GetName()
112 << G4endl
113 << " Replicated volume: " << pName;
114 G4Exception("G4PVReplica::G4PVReplica()", "GeomVol0002",
115 FatalException, message);
116 return;
117 }
118 CheckAndSetParameters (pAxis, nReplicas, width, offset);
119}
120
121void G4PVReplica::CheckAndSetParameters( const EAxis pAxis,
122 const G4int nReplicas,
123 const G4double width,
124 const G4double offset)
125{
126 if (nReplicas<1)
127 {
128 G4Exception("G4PVReplica::CheckAndSetParameters()", "GeomVol0002",
129 FatalException, "Illegal number of replicas.");
130 }
131 fnReplicas=nReplicas;
132 if (width<0)
133 {
134 G4Exception("G4PVReplica::CheckAndSetParameters()", "GeomVol0002",
135 FatalException, "Width must be positive.");
136 }
137 fwidth = width;
138 foffset = offset;
139 faxis = pAxis;
140
141 // Create rotation matrix for phi axis case & check axis is valid
142 //
143 G4RotationMatrix* pRMat=0;
144 switch (faxis)
145 {
146 case kPhi:
147 pRMat=new G4RotationMatrix();
148 if (!pRMat)
149 {
150 G4Exception("G4PVReplica::CheckAndSetParameters()", "GeomVol0003",
151 FatalException, "Rotation matrix allocation failed.");
152 }
153 SetRotation(pRMat);
154 break;
155 case kRho:
156 case kXAxis:
157 case kYAxis:
158 case kZAxis:
159 case kUndefined:
160 break;
161 default:
162 G4Exception("G4PVReplica::CheckAndSetParameters()", "GeomVol0002",
163 FatalException, "Unknown axis of replication.");
164 break;
165 }
166}
167
169 : G4VPhysicalVolume(a), faxis(kZAxis), fnReplicas(0), fwidth(0.),
170 foffset(0.), fcopyNo(-1), fRegularStructureCode(0), fRegularVolsId(0)
171{
172}
173
175{
176 if ( faxis==kPhi )
177 {
178 delete GetRotation();
179 }
180}
181
183{
184 return false;
185}
186
188{
189 return fcopyNo;
190}
191
193{
194 fcopyNo = newCopyNo;
195}
196
198{
199 return true;
200}
201
203{
204 return false;
205}
206
208{
209 return 0;
210}
211
213{
214 return fnReplicas;
215}
216
217
218
220 G4int& nReplicas,
221 G4double& width,
222 G4double& offset,
223 G4bool& consuming ) const
224{
225 axis = faxis;
226 nReplicas = fnReplicas;
227 width = fwidth;
228 offset = foffset;
229 consuming = true;
230}
231
233{
234 return (fRegularVolsId!=0);
235}
236
238{
239 return fRegularVolsId;
240}
241
243{
244 fRegularVolsId= Code;
245}
@ FatalException
CLHEP::HepRotation G4RotationMatrix
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
G4int GetNoDaughters() const
G4String GetName() const
void AddDaughter(G4VPhysicalVolume *p)
G4int GetRegularStructureId() const
Definition: G4PVReplica.cc:237
G4bool IsMany() const
Definition: G4PVReplica.cc:182
G4double fwidth
Definition: G4PVReplica.hh:136
virtual void SetCopyNo(G4int CopyNo)
Definition: G4PVReplica.cc:192
G4bool IsReplicated() const
Definition: G4PVReplica.cc:197
G4PVReplica(const G4String &pName, G4LogicalVolume *pLogical, G4LogicalVolume *pMother, const EAxis pAxis, const G4int nReplicas, const G4double width, const G4double offset=0)
Definition: G4PVReplica.cc:79
virtual G4int GetMultiplicity() const
Definition: G4PVReplica.cc:212
G4int fnReplicas
Definition: G4PVReplica.hh:135
G4double foffset
Definition: G4PVReplica.hh:136
virtual G4VPVParameterisation * GetParameterisation() const
Definition: G4PVReplica.cc:207
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
Definition: G4PVReplica.cc:219
virtual G4bool IsParameterised() const
Definition: G4PVReplica.cc:202
G4bool IsRegularStructure() const
Definition: G4PVReplica.cc:232
virtual G4int GetCopyNo() const
Definition: G4PVReplica.cc:187
virtual void SetRegularStructureId(G4int Code)
Definition: G4PVReplica.cc:242
virtual ~G4PVReplica()
Definition: G4PVReplica.cc:174
const G4RotationMatrix * GetRotation() const
G4LogicalVolume * GetLogicalVolume() const
const G4String & GetName() const
void SetRotation(G4RotationMatrix *)
void SetMotherLogical(G4LogicalVolume *pMother)
#define Code
Definition: deflate.h:70
EAxis
Definition: geomdefs.hh:54
@ kPhi
Definition: geomdefs.hh:54
@ kYAxis
Definition: geomdefs.hh:54
@ kXAxis
Definition: geomdefs.hh:54
@ kZAxis
Definition: geomdefs.hh:54
@ kUndefined
Definition: geomdefs.hh:54
@ kRho
Definition: geomdefs.hh:54
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41