Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VDivisionParameterisation.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// class G4VDivisionParameterisation Implementation file
30//
31// 26.05.03 - P.Arce, Initial version
32// 08.04.04 - I.Hrivnacova, Implemented reflection
33// 21.04.10 - M.Asai, Added gaps
34// --------------------------------------------------------------------
35
37#include "G4VSolid.hh"
38#include "G4VPhysicalVolume.hh"
39#include "G4RotationMatrix.hh"
40#include "G4ReflectedSolid.hh"
42
44
45//--------------------------------------------------------------------------
48 G4double step, G4double offset,
49 DivisionType divType, G4VSolid* motherSolid )
50 : faxis(axis), fnDiv( nDiv), fwidth(step), foffset(offset),
51 fDivisionType(divType), fmotherSolid( motherSolid ), fReflectedSolid(false),
52 fDeleteSolid(false), theVoluFirstCopyNo(1), fhgap(0.)
53{
54#ifdef G4DIVDEBUG
55 if (verbose >= 1)
56 {
57 G4cout << " G4VDivisionParameterisation no divisions " << fnDiv
58 << " = " << nDiv << G4endl
59 << " offset " << foffset << " = " << offset << G4endl
60 << " step " << fwidth << " = " << step << G4endl;
61 }
62#endif
64}
65
66//--------------------------------------------------------------------------
68{
69 if (fDeleteSolid) delete fmotherSolid;
70}
71
72//--------------------------------------------------------------------------
76{
78 if (solid->GetEntityType() == "G4ReflectedSolid")
79 {
80 solid = ((G4ReflectedSolid*)solid)->GetConstituentMovedSolid();
81 }
82 return solid;
83}
84
85//--------------------------------------------------------------------------
86void
88ChangeRotMatrix( G4VPhysicalVolume *physVol, G4double rotZ ) const
89{
91 rm->rotateZ( rotZ );
92 //----- set rotation
93 //----- delete first old rotation matrix
94 G4RotationMatrix* rmold = physVol->GetRotation();
95 delete rmold;
96 physVol->SetRotation(rm);
97}
98
99//--------------------------------------------------------------------------
100G4int
102CalculateNDiv( G4double motherDim, G4double width, G4double offset ) const
103{
104#ifdef G4DIVDEBUG
105 G4cout << " G4VDivisionParameterisation::CalculateNDiv: "
106 << ( motherDim - offset ) / width
107 << " Motherdim: " << motherDim << ", Offset: " << offset
108 << ", Width: " << width << G4endl;
109#endif
110
111 return G4int( ( motherDim - offset ) / width );
112}
113
114//--------------------------------------------------------------------------
117CalculateWidth( G4double motherDim, G4int nDiv, G4double offset ) const
118{
119#ifdef G4DIVDEBUG
120 G4cout << " G4VDivisionParameterisation::CalculateWidth: "
121 << ( motherDim - offset ) / nDiv
122 << ", Motherdim: " << motherDim << ", Offset: " << offset
123 << ", Number of divisions: " << nDiv << G4endl;
124#endif
125
126 return ( motherDim - offset ) / nDiv;
127}
128
129//--------------------------------------------------------------------------
131{
132 G4double maxPar = GetMaxParameter();
133 CheckOffset( maxPar );
134 CheckNDivAndWidth( maxPar );
135}
136
137//--------------------------------------------------------------------------
139{
140 if( foffset >= maxPar )
141 {
142 std::ostringstream message;
143 message << "Configuration not supported." << G4endl
144 << "Division of solid " << fmotherSolid->GetName()
145 << " has too big offset = " << G4endl
146 << " " << foffset << " > " << maxPar << " !";
147 G4Exception("G4VDivisionParameterisation::CheckOffset()",
148 "GeomDiv0001", FatalException, message);
149 }
150}
151
152//--------------------------------------------------------------------------
154{
156 && (foffset + fwidth*fnDiv - maxPar > kCarTolerance ) )
157 {
158 std::ostringstream message;
159 message << "Configuration not supported." << G4endl
160 << "Division of solid " << fmotherSolid->GetName()
161 << " has too big offset + width*nDiv = " << G4endl
162 << " " << foffset + fwidth*fnDiv << " > "
163 << foffset << ". Width = "
164 << G4endl
165 << " " << fwidth << ". nDiv = " << fnDiv << " !";
166 G4Exception("G4VDivisionParameterisation::CheckNDivAndWidth()",
167 "GeomDiv0001", FatalException, message);
168 }
169}
170
171//--------------------------------------------------------------------------
173{
174 // take into account reflection in the offset
175 G4double offset = foffset;
177
178 return offset;
179}
180
181
@ FatalException
CLHEP::HepRotation G4RotationMatrix
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
HepRotation & rotateZ(double delta)
Definition: Rotation.cc:92
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
void ChangeRotMatrix(G4VPhysicalVolume *physVol, G4double rotZ=0.) const
virtual G4double GetMaxParameter() const =0
G4VDivisionParameterisation(EAxis axis, G4int nDiv, G4double width, G4double offset, DivisionType divType, G4VSolid *motherSolid=0)
G4double CalculateWidth(G4double motherDim, G4int nDiv, G4double offset) const
G4int CalculateNDiv(G4double motherDim, G4double width, G4double offset) const
virtual G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
virtual G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
const G4RotationMatrix * GetRotation() const
void SetRotation(G4RotationMatrix *)
G4String GetName() const
virtual G4GeometryType GetEntityType() const =0
EAxis
Definition: geomdefs.hh:54
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41