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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.1)


  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 // $Id: G4VPhysicalVolume.cc 83991 2014-09-26 09:22:26Z gcosmo $
                                                   >>  28 //
                                                   >>  29 // 
 26 // class G4VPhysicalVolume Implementation          30 // class G4VPhysicalVolume Implementation
 27 //                                                 31 //
 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 // -------------------------------------------     32 // --------------------------------------------------------------------
 33                                                    33 
 34 #include "G4VPhysicalVolume.hh"                    34 #include "G4VPhysicalVolume.hh"
 35                                                    35 
 36 #include "G4PhysicalVolumeStore.hh"                36 #include "G4PhysicalVolumeStore.hh"
 37 #include "G4LogicalVolume.hh"                      37 #include "G4LogicalVolume.hh"
 38                                                    38 
 39 // This new field helps to use the class G4PVM <<  39 // This static member is thread local. For each thread, it points to the
 40 //                                             <<  40 // array of G4PVData instances.
 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 << 
 53 //                                             << 
 54 G4VPhysicalVolume::G4VPhysicalVolume( G4Rotati << 
 55                                 const G4ThreeV << 
 56                                 const G4String << 
 57                                       G4Logica << 
 58                                       G4VPhysi << 
 59   : flogical(pLogical), fname(pName)           << 
 60 {                                              << 
 61   instanceID = subInstanceManager.CreateSubIns << 
 62                                                << 
 63   this->SetRotation( pRot );       // G4MT_rot << 
 64   this->SetTranslation( tlate );   // G4MT_tra << 
 65                                                << 
 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 //                                                 41 //
 79 G4VPhysicalVolume::G4VPhysicalVolume( __void__ <<  42 template <class G4PVData> G4ThreadLocal
 80   : fname("")                                  <<  43 G4PVData* G4GeomSplitter<G4PVData>::offset = 0;
 81 {                                              << 
 82   // Register to store                         << 
 83   //                                           << 
 84   instanceID = subInstanceManager.CreateSubIns << 
 85                                                << 
 86   G4PhysicalVolumeStore::Register(this);       << 
 87 }                                              << 
 88                                                    44 
 89 // Destructor -  remove from Store             <<  45 // This new field helps to use the class G4PVManager
 90 //                                             << 
 91 G4VPhysicalVolume::~G4VPhysicalVolume()        << 
 92 {                                              << 
 93   delete pvdata;                               << 
 94   G4PhysicalVolumeStore::DeRegister(this);     << 
 95 }                                              << 
 96                                                << 
 97 // Set volume name and notify store of the cha << 
 98 //                                                 46 //
 99 void G4VPhysicalVolume::SetName(const G4String <<  47 G4PVManager G4VPhysicalVolume::subInstanceManager;
100 {                                              << 
101   fname = pName;                               << 
102   G4PhysicalVolumeStore::GetInstance()->SetMap << 
103 }                                              << 
104                                                    48 
105 // This method is similar to the constructor.      49 // This method is similar to the constructor. It is used by each worker
106 // thread to achieve the same effect as that o     50 // thread to achieve the same effect as that of the master thread exept
107 // to register the new created instance. This      51 // to register the new created instance. This method is invoked explicitly.
108 // It does not create a new G4VPhysicalVolume      52 // It does not create a new G4VPhysicalVolume instance.
109 // It only assign the value for the fields enc     53 // It only assign the value for the fields encapsulated by the class G4PVData.
110 //                                                 54 //
111 void G4VPhysicalVolume::                           55 void G4VPhysicalVolume::
112 InitialiseWorker( G4VPhysicalVolume* /*pMaster     56 InitialiseWorker( G4VPhysicalVolume* /*pMasterObject*/,
113                   G4RotationMatrix *pRot,          57                   G4RotationMatrix *pRot,
114                   const G4ThreeVector &tlate)      58                   const G4ThreeVector &tlate)
115 {                                                  59 {
116   subInstanceManager.SlaveCopySubInstanceArray     60   subInstanceManager.SlaveCopySubInstanceArray();
117                                                    61 
118   this->SetRotation( pRot );      // G4MT_rot      62   this->SetRotation( pRot );      // G4MT_rot   = pRot;
119   this->SetTranslation( tlate );  // G4MT_tran     63   this->SetTranslation( tlate );  // G4MT_trans = tlate;
120   //  G4PhysicalVolumeStore::Register(this);       64   //  G4PhysicalVolumeStore::Register(this);
121 }                                                  65 }
122                                                    66 
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     67 // This method is similar to the destructor. It is used by each worker
131 // thread to achieve the partial effect as tha     68 // thread to achieve the partial effect as that of the master thread.
132 // For G4VPhysicalVolume instances, nothing mo     69 // For G4VPhysicalVolume instances, nothing more to do here.
133 //                                                 70 //
134 void G4VPhysicalVolume::TerminateWorker( G4VPh     71 void G4VPhysicalVolume::TerminateWorker( G4VPhysicalVolume* /*pMasterObject*/)
135 {                                                  72 {
136 }                                                  73 }
137                                                    74 
138 // Returns the private data instance manager.      75 // Returns the private data instance manager.
139 //                                                 76 //
140 const G4PVManager& G4VPhysicalVolume::GetSubIn     77 const G4PVManager& G4VPhysicalVolume::GetSubInstanceManager()
141 {                                                  78 {
142   return subInstanceManager;                       79   return subInstanceManager;
143 }                                                  80 }
144                                                    81 
145 G4int G4VPhysicalVolume::GetMultiplicity() con <<  82 // Constructor: init parameters and register in Store
                                                   >>  83 //
                                                   >>  84 G4VPhysicalVolume::G4VPhysicalVolume( G4RotationMatrix *pRot,
                                                   >>  85                                 const G4ThreeVector &tlate,
                                                   >>  86                                 const G4String& pName,
                                                   >>  87                                       G4LogicalVolume* pLogical,
                                                   >>  88                                       G4VPhysicalVolume* )
                                                   >>  89   : flogical(pLogical),
                                                   >>  90     fname(pName), flmother(0)
146 {                                                  91 {
147   return 1;                                    <<  92   instanceID = subInstanceManager.CreateSubInstance();
148 }                                              << 
149                                                    93 
150 const G4ThreeVector G4VPhysicalVolume::GetTran <<  94   this->SetRotation( pRot );       // G4MT_rot = pRot;
151 {                                              <<  95   this->SetTranslation( tlate );   // G4MT_trans = tlate;
152   return G4ThreeVector(G4MT_tx, G4MT_ty, G4MT_ <<  96   G4PhysicalVolumeStore::Register(this);
153 }                                                  97 }
154                                                    98 
155 void G4VPhysicalVolume::SetTranslation(const G <<  99 // Fake default constructor - sets only member data and allocates memory
                                                   >> 100 //                            for usage restricted to object persistency.
                                                   >> 101 //
                                                   >> 102 G4VPhysicalVolume::G4VPhysicalVolume( __void__& )
                                                   >> 103   : flogical(0), fname(""), flmother(0)
156 {                                                 104 {
157   G4MT_tx=vec.x(); G4MT_ty=vec.y(); G4MT_tz=ve << 105   // Register to store
158 }                                              << 106   //
                                                   >> 107   instanceID = subInstanceManager.CreateSubInstance();
159                                                   108 
160 const G4RotationMatrix* G4VPhysicalVolume::Get << 109   G4PhysicalVolumeStore::Register(this);
161 {                                              << 
162   return G4MT_rot;                             << 
163 }                                                 110 }
164                                                   111 
165 G4RotationMatrix* G4VPhysicalVolume::GetRotati << 112 // Destructor -  remove from Store
                                                   >> 113 //
                                                   >> 114 G4VPhysicalVolume::~G4VPhysicalVolume() 
166 {                                                 115 {
167   return G4MT_rot;                             << 116   G4PhysicalVolumeStore::DeRegister(this);
168 }                                                 117 }
169                                                   118 
170 void G4VPhysicalVolume::SetRotation(G4Rotation << 119 G4int G4VPhysicalVolume::GetMultiplicity() const
171 {                                                 120 {
172   G4MT_rot = pRot;                             << 121   return 1;
173 }                                                 122 }
174                                                   123 
175 G4RotationMatrix* G4VPhysicalVolume::GetObject    124 G4RotationMatrix* G4VPhysicalVolume::GetObjectRotation() const
176 {                                                 125 {
177   static G4RotationMatrix aRotM;                  126   static G4RotationMatrix aRotM;
178   static G4RotationMatrix IdentityRM;             127   static G4RotationMatrix IdentityRM;
179                                                   128 
180   G4RotationMatrix* retval = &IdentityRM;         129   G4RotationMatrix* retval = &IdentityRM;
181                                                   130 
182   // Insure against frot being a null pointer     131   // Insure against frot being a null pointer
183   if(this->GetRotation() != nullptr)           << 132   if(this->GetRotation())
184   {                                               133   {
185      aRotM = GetRotation()->inverse();            134      aRotM = GetRotation()->inverse();
186      retval= &aRotM;                              135      retval= &aRotM;
187   }                                               136   }
188   return retval;                                  137   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 }                                                 138 }
217                                                   139 
218 // Only implemented for placed and parameteris    140 // Only implemented for placed and parameterised volumes.
219 // Not required for replicas.                     141 // Not required for replicas.
220 //                                                142 //
221 G4bool G4VPhysicalVolume::CheckOverlaps(G4int,    143 G4bool G4VPhysicalVolume::CheckOverlaps(G4int, G4double, G4bool, G4int)
222 {                                                 144 {
223   return false;                                   145   return false;
224 }                                                 146 }
225                                                   147