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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /geometry/management/src/G4VPhysicalVolume.cc (Version 11.3.0) and /geometry/management/src/G4VPhysicalVolume.cc (Version 10.5.p1)


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