Geant4  10.02.p01
G4VPhysicalVolume.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: G4VPhysicalVolume.cc 93287 2015-10-15 09:50:22Z gcosmo $
28 //
29 //
30 // class G4VPhysicalVolume Implementation
31 //
32 // --------------------------------------------------------------------
33 
34 #include "G4VPhysicalVolume.hh"
35 
36 #include "G4PhysicalVolumeStore.hh"
37 #include "G4LogicalVolume.hh"
38 
39 // This static member is thread local. For each thread, it points to the
40 // array of G4PVData instances.
41 //
42 template <class G4PVData> G4ThreadLocal
44 
45 // This new field helps to use the class G4PVManager
46 //
48 
49 // This method is similar to the constructor. It is used by each worker
50 // thread to achieve the same effect as that of the master thread exept
51 // to register the new created instance. This method is invoked explicitly.
52 // It does not create a new G4VPhysicalVolume instance.
53 // It only assign the value for the fields encapsulated by the class G4PVData.
54 //
56 InitialiseWorker( G4VPhysicalVolume* /*pMasterObject*/,
57  G4RotationMatrix *pRot,
58  const G4ThreeVector &tlate)
59 {
61 
62  this->SetRotation( pRot ); // G4MT_rot = pRot;
63  this->SetTranslation( tlate ); // G4MT_trans = tlate;
64  // G4PhysicalVolumeStore::Register(this);
65 }
66 
67 // This method is similar to the destructor. It is used by each worker
68 // thread to achieve the partial effect as that of the master thread.
69 // For G4VPhysicalVolume instances, nothing more to do here.
70 //
72 {
73 }
74 
75 // Returns the private data instance manager.
76 //
78 {
79  return subInstanceManager;
80 }
81 
82 // Constructor: init parameters and register in Store
83 //
85  const G4ThreeVector &tlate,
86  const G4String& pName,
87  G4LogicalVolume* pLogical,
89  : flogical(pLogical),
90  fname(pName), flmother(0)
91 {
93 
94  this->SetRotation( pRot ); // G4MT_rot = pRot;
95  this->SetTranslation( tlate ); // G4MT_trans = tlate;
96 
97  // Initialize 'Shadow' data structure - for use by object persistency
98  pvdata = new G4PVData();
99  pvdata->frot = pRot;
100  pvdata->ftrans = G4ThreeVector(tlate);
101 
103 }
104 
105 // Fake default constructor - sets only member data and allocates memory
106 // for usage restricted to object persistency.
107 //
109  : flogical(0), fname(""), flmother(0), pvdata(0)
110 {
111  // Register to store
112  //
114 
116 }
117 
118 // Destructor - remove from Store
119 //
121 {
122  delete pvdata;
124 }
125 
127 {
128  return 1;
129 }
130 
132 {
133  static G4RotationMatrix aRotM;
134  static G4RotationMatrix IdentityRM;
135 
136  G4RotationMatrix* retval = &IdentityRM;
137 
138  // Insure against frot being a null pointer
139  if(this->GetRotation())
140  {
141  aRotM = GetRotation()->inverse();
142  retval= &aRotM;
143  }
144  return retval;
145 }
146 
147 // Only implemented for placed and parameterised volumes.
148 // Not required for replicas.
149 //
151 {
152  return false;
153 }
G4VPhysicalVolume(G4RotationMatrix *pRot, const G4ThreeVector &tlate, const G4String &pName, G4LogicalVolume *pLogical, G4VPhysicalVolume *pMother)
CLHEP::Hep3Vector G4ThreeVector
CLHEP::HepRotation G4RotationMatrix
G4ThreeVector ftrans
static void Register(G4VPhysicalVolume *pSolid)
#define G4ThreadLocal
Definition: tls.hh:89
G4int CreateSubInstance()
int G4int
Definition: G4Types.hh:78
static G4GEOM_DLL G4PVManager subInstanceManager
static void DeRegister(G4VPhysicalVolume *pSolid)
void SetRotation(G4RotationMatrix *)
void InitialiseWorker(G4VPhysicalVolume *pMasterObject, G4RotationMatrix *pRot, const G4ThreeVector &tlate)
void TerminateWorker(G4VPhysicalVolume *pMasterObject)
static const G4PVManager & GetSubInstanceManager()
bool G4bool
Definition: G4Types.hh:79
void SlaveCopySubInstanceArray()
void SetTranslation(const G4ThreeVector &v)
const G4RotationMatrix * GetRotation() const
virtual G4int GetMultiplicity() const
G4RotationMatrix * GetObjectRotation() const
double G4double
Definition: G4Types.hh:76
virtual G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true, G4int errMax=1)
G4RotationMatrix * frot