Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // class G4VPhysicalVolume Implementation << 27 // 23 // 28 // 15.01.13, G.Cosmo, A.Dotti: Modified for th << 24 // $Id: G4VPhysicalVolume.cc,v 1.4 2001/07/11 09:59:21 gunter Exp $ 29 // 28.08.96, P.Kent: Replaced transform by rot << 25 // GEANT4 tag $Name: geant4-04-01 $ 30 // 25.07.96, P.Kent: Modified interface for ne << 26 // 31 // 24.07.95, P.Kent: First non-stub version << 27 // 32 // ------------------------------------------- << 28 // class G4VPhysicalVolume Implementation >> 29 // 09.11.99 J.Apostolakis Made GetObjectRotation() non-inline (it uses static) >> 30 // To be made obsolecent, in favour of more robust >> 31 // GetObjectRotationValue() 33 32 34 #include "G4VPhysicalVolume.hh" 33 #include "G4VPhysicalVolume.hh" 35 34 36 #include "G4PhysicalVolumeStore.hh" 35 #include "G4PhysicalVolumeStore.hh" 37 #include "G4LogicalVolume.hh" 36 #include "G4LogicalVolume.hh" 38 37 39 // This new field helps to use the class G4PVM << 40 // << 41 G4PVManager G4VPhysicalVolume::subInstanceMana << 42 << 43 // These macros change the references to field << 44 // in the class G4PVData. << 45 // << 46 #define G4MT_rot ((subInstanceManager.offset[i << 47 #define G4MT_tx ((subInstanceManager.offset[in << 48 #define G4MT_ty ((subInstanceManager.offset[in << 49 #define G4MT_tz ((subInstanceManager.offset[in << 50 #define G4MT_pvdata (subInstanceManager.offset << 51 << 52 // Constructor: init parameters and register i 38 // Constructor: init parameters and register in Store 53 // << 39 G4VPhysicalVolume::G4VPhysicalVolume(G4RotationMatrix *pRot, 54 G4VPhysicalVolume::G4VPhysicalVolume( G4Rotati << 40 const G4ThreeVector &tlate, 55 const G4ThreeV << 41 const G4String& pName, 56 const G4String << 42 G4LogicalVolume* pLogical, 57 G4Logica << 43 G4VPhysicalVolume* pMother) 58 G4VPhysi << 44 { 59 : flogical(pLogical), fname(pName) << 45 ftrans=tlate; 60 { << 46 frot=pRot; 61 instanceID = subInstanceManager.CreateSubIns << 47 SetName(pName); 62 << 48 SetLogicalVolume(pLogical); 63 this->SetRotation( pRot ); // G4MT_rot << 49 SetMother(pMother); 64 this->SetTranslation( tlate ); // G4MT_tra << 50 if (pMother) pMother->GetLogicalVolume()->AddDaughter(this); 65 << 51 G4PhysicalVolumeStore::Register(this); 66 // Initialize 'Shadow' data structure - for << 67 pvdata = new G4PVData(); << 68 pvdata->frot = pRot; << 69 pvdata->tx = tlate.x(); << 70 pvdata->ty = tlate.y(); << 71 pvdata->tz = tlate.z(); << 72 << 73 G4PhysicalVolumeStore::Register(this); << 74 } << 75 << 76 // Fake default constructor - sets only member << 77 // for usage restri << 78 // << 79 G4VPhysicalVolume::G4VPhysicalVolume( __void__ << 80 : fname("") << 81 { << 82 // Register to store << 83 // << 84 instanceID = subInstanceManager.CreateSubIns << 85 << 86 G4PhysicalVolumeStore::Register(this); << 87 } 52 } 88 53 89 // Destructor - remove from Store 54 // Destructor - remove from Store 90 // << 91 G4VPhysicalVolume::~G4VPhysicalVolume() 55 G4VPhysicalVolume::~G4VPhysicalVolume() 92 { 56 { 93 delete pvdata; << 57 G4PhysicalVolumeStore::DeRegister(this); 94 G4PhysicalVolumeStore::DeRegister(this); << 95 } << 96 << 97 // Set volume name and notify store of the cha << 98 // << 99 void G4VPhysicalVolume::SetName(const G4String << 100 { << 101 fname = pName; << 102 G4PhysicalVolumeStore::GetInstance()->SetMap << 103 } << 104 << 105 // This method is similar to the constructor. << 106 // thread to achieve the same effect as that o << 107 // to register the new created instance. This << 108 // It does not create a new G4VPhysicalVolume << 109 // It only assign the value for the fields enc << 110 // << 111 void G4VPhysicalVolume:: << 112 InitialiseWorker( G4VPhysicalVolume* /*pMaster << 113 G4RotationMatrix *pRot, << 114 const G4ThreeVector &tlate) << 115 { << 116 subInstanceManager.SlaveCopySubInstanceArray << 117 << 118 this->SetRotation( pRot ); // G4MT_rot << 119 this->SetTranslation( tlate ); // G4MT_tran << 120 // G4PhysicalVolumeStore::Register(this); << 121 } << 122 << 123 // Release memory allocated for offset << 124 // << 125 void G4VPhysicalVolume::Clean() << 126 { << 127 subInstanceManager.FreeSlave(); << 128 } << 129 << 130 // This method is similar to the destructor. I << 131 // thread to achieve the partial effect as tha << 132 // For G4VPhysicalVolume instances, nothing mo << 133 // << 134 void G4VPhysicalVolume::TerminateWorker( G4VPh << 135 { << 136 } << 137 << 138 // Returns the private data instance manager. << 139 // << 140 const G4PVManager& G4VPhysicalVolume::GetSubIn << 141 { << 142 return subInstanceManager; << 143 } << 144 << 145 G4int G4VPhysicalVolume::GetMultiplicity() con << 146 { << 147 return 1; << 148 } << 149 << 150 const G4ThreeVector G4VPhysicalVolume::GetTran << 151 { << 152 return G4ThreeVector(G4MT_tx, G4MT_ty, G4MT_ << 153 } << 154 << 155 void G4VPhysicalVolume::SetTranslation(const G << 156 { << 157 G4MT_tx=vec.x(); G4MT_ty=vec.y(); G4MT_tz=ve << 158 } << 159 << 160 const G4RotationMatrix* G4VPhysicalVolume::Get << 161 { << 162 return G4MT_rot; << 163 } << 164 << 165 G4RotationMatrix* G4VPhysicalVolume::GetRotati << 166 { << 167 return G4MT_rot; << 168 } << 169 << 170 void G4VPhysicalVolume::SetRotation(G4Rotation << 171 { << 172 G4MT_rot = pRot; << 173 } 58 } 174 59 175 G4RotationMatrix* G4VPhysicalVolume::GetObject 60 G4RotationMatrix* G4VPhysicalVolume::GetObjectRotation() const 176 { 61 { 177 static G4RotationMatrix aRotM; << 62 static G4RotationMatrix aRotM; 178 static G4RotationMatrix IdentityRM; << 63 static G4RotationMatrix IdentityRM; // Never changed (from "1") 179 << 64 G4RotationMatrix* retval; 180 G4RotationMatrix* retval = &IdentityRM; << 181 65 182 // Insure against frot being a null pointer 66 // Insure against frot being a null pointer 183 if(this->GetRotation() != nullptr) << 67 if(frot) 184 { << 68 { 185 aRotM = GetRotation()->inverse(); << 69 aRotM= frot->inverse(); 186 retval= &aRotM; << 70 retval= &aRotM; 187 } << 71 } >> 72 else >> 73 { >> 74 retval= &IdentityRM; >> 75 } 188 return retval; 76 return retval; 189 } << 190 << 191 G4RotationMatrix G4VPhysicalVolume::GetObjectR << 192 { << 193 G4RotationMatrix aRotM; // Initialised to << 194 << 195 // Insure against G4MT_rot being a null poin << 196 if(G4MT_rot) << 197 { << 198 aRotM = G4MT_rot->inverse(); << 199 } << 200 return aRotM; << 201 } << 202 << 203 G4ThreeVector G4VPhysicalVolume::GetObjectTra << 204 { << 205 return {G4MT_tx, G4MT_ty, G4MT_tz}; << 206 } << 207 << 208 const G4RotationMatrix* G4VPhysicalVolume::Get << 209 { << 210 return G4MT_rot; << 211 } << 212 << 213 G4ThreeVector G4VPhysicalVolume::GetFrameTran << 214 { << 215 return -G4ThreeVector(G4MT_tx, G4MT_ty, G4MT << 216 } << 217 << 218 // Only implemented for placed and parameteris << 219 // Not required for replicas. << 220 // << 221 G4bool G4VPhysicalVolume::CheckOverlaps(G4int, << 222 { << 223 return false; << 224 } 77 } 225 78