Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/management/src/G4LogicalVolume.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 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/G4LogicalVolume.cc (Version 11.3.0) and /geometry/management/src/G4LogicalVolume.cc (Version 1.1)


                                                   >>   1 // This code implementation is the intellectual property of
                                                   >>   2 // the GEANT4 collaboration.
                                                   >>   3 //
                                                   >>   4 // By copying, distributing or modifying the Program (or any work
                                                   >>   5 // based on the Program) you indicate your acceptance of this statement,
                                                   >>   6 // and all its terms.
                                                   >>   7 //
                                                   >>   8 // $Id: G4LogicalVolume.cc,v 1.3 1999/12/15 14:49:52 gunter Exp $
                                                   >>   9 // GEANT4 tag $Name: geant4-01-01 $
  1 //                                                 10 //
  2 // ******************************************* << 
  3 // * License and Disclaimer                    << 
  4 // *                                           << 
  5 // * The  Geant4 software  is  copyright of th << 
  6 // * the Geant4 Collaboration.  It is provided << 
  7 // * conditions of the Geant4 Software License << 
  8 // * LICENSE and available at  http://cern.ch/ << 
  9 // * include a list of copyright holders.      << 
 10 // *                                           << 
 11 // * Neither the authors of this software syst << 
 12 // * institutes,nor the agencies providing fin << 
 13 // * work  make  any representation or  warran << 
 14 // * regarding  this  software system or assum << 
 15 // * use.  Please see the license in the file  << 
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                           << 
 18 // * This  code  implementation is the result  << 
 19 // * technical work of the GEANT4 collaboratio << 
 20 // * By using,  copying,  modifying or  distri << 
 21 // * any work based  on the software)  you  ag << 
 22 // * use  in  resulting  scientific  publicati << 
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // ******************************************* << 
 25 //                                                 11 // 
 26 // class G4LogicalVolume implementation        <<  12 // class G4LogicalVolume Implementation
 27 //                                                 13 //
 28 // 15.01.13 G.Cosmo, A.Dotti: Modified for thr <<  14 // History:
 29 // 01.03.05 G.Santin: Added flag for optional  <<  15 // 12.02.99 S.Giani: Deafult initialization of voxelization quality.
 30 // 17.05.02 G.Cosmo: Added flag for optional o <<  16 // 10.20.97 - P. MoraDeFreitas : "Fast" replaces "Parameterisation" in
 31 // 12.02.99 S.Giani: Default initialization of <<  17 //            class/method names. (release B.00 for parameterisation).
 32 // 04.08.97 P.M.DeFreitas: Added methods for p <<  18 // 04.08.97 P.MoraDeFreitas/J.A. Added methods for ParameterisedSimulation 
 33 // 11.07.95 P.Kent: Initial version            <<  19 // 19.08.96 P.Kent Modified for G4VSensitive Detector
 34 // ------------------------------------------- <<  20 // 11.07.95 P.Kent Initial version
 35                                                    21 
 36 #include "G4LogicalVolume.hh"                      22 #include "G4LogicalVolume.hh"
 37 #include "G4LogicalVolumeStore.hh"                 23 #include "G4LogicalVolumeStore.hh"
 38 #include "G4VSolid.hh"                         << 
 39 #include "G4Material.hh"                       << 
 40 #include "G4VPVParameterisation.hh"            << 
 41 #include "G4VisAttributes.hh"                  << 
 42                                                << 
 43 #include "G4UnitsTable.hh"                     << 
 44                                                << 
 45 G4LVData::G4LVData() {;}                       << 
 46                                                << 
 47 // This new field helps to use the class G4LVM << 
 48 //                                             << 
 49 G4LVManager G4LogicalVolume::subInstanceManage << 
 50                                                << 
 51 // These macros change the references to field << 
 52 // in the class G4LVData.                      << 
 53 //                                             << 
 54 #define G4MT_solid     ((subInstanceManager.of << 
 55 #define G4MT_sdetector ((subInstanceManager.of << 
 56 #define G4MT_fmanager  ((subInstanceManager.of << 
 57 #define G4MT_material  ((subInstanceManager.of << 
 58 #define G4MT_mass      ((subInstanceManager.of << 
 59 #define G4MT_ccouple   ((subInstanceManager.of << 
 60 #define G4MT_instance  (subInstanceManager.off << 
 61                                                << 
 62 // ******************************************* << 
 63 // Constructor - sets member data and adds to  << 
 64 //               voxel pointer for optimisatio << 
 65 //               Initialises daughter vector t << 
 66 // ******************************************* << 
 67 //                                             << 
 68 G4LogicalVolume::G4LogicalVolume( G4VSolid* pS << 
 69                                   G4Material*  << 
 70                             const G4String& na << 
 71                                   G4FieldManag << 
 72                                   G4VSensitive << 
 73                                   G4UserLimits << 
 74                                   G4bool optim << 
 75  : fDaughters(0,(G4VPhysicalVolume*)nullptr),  << 
 76    fOptimise(optimise)                         << 
 77 {                                              << 
 78   // Initialize 'Shadow'/master pointers - for << 
 79   //                                           << 
 80   fSolid = pSolid;                             << 
 81   fSensitiveDetector = pSDetector;             << 
 82   fFieldManager = pFieldMgr;                   << 
 83                                                << 
 84   instanceID = subInstanceManager.CreateSubIns << 
 85   AssignFieldManager(pFieldMgr);               << 
 86                                                << 
 87   G4MT_mass = 0.;                              << 
 88   G4MT_ccouple = nullptr;                      << 
 89                                                << 
 90   SetSolid(pSolid);                            << 
 91   SetMaterial(pMaterial);                      << 
 92   SetName(name);                               << 
 93   SetSensitiveDetector(pSDetector);            << 
 94   SetUserLimits(pULimits);                     << 
 95                                                << 
 96   // Initialize 'Shadow' data structure - for  << 
 97   //                                           << 
 98   lvdata = new G4LVData();                     << 
 99   lvdata->fSolid = pSolid;                     << 
100   lvdata->fMaterial = pMaterial;               << 
101                                                << 
102   //                                           << 
103   // Add to store                              << 
104   //                                           << 
105   G4LogicalVolumeStore::Register(this);        << 
106 }                                              << 
107                                                    24 
108 // ******************************************* <<  25 // Constructor - set member data and add to logical Store, zero voxel ptr
109 // Fake default constructor - sets only member <<  26 //               Initialises daughter vector to 0 length
110 //                            for usage restri <<  27 G4LogicalVolume::G4LogicalVolume( G4VSolid *pSolid,  G4Material *pMaterial,
111 // ******************************************* <<  28           const G4String& name,
112 //                                             <<  29           G4FieldManager *pFieldMgr,
113 G4LogicalVolume::G4LogicalVolume( __void__& )  <<  30           G4VSensitiveDetector *pSDetector,
114  : fDaughters(0,(G4VPhysicalVolume*)nullptr),  <<  31           G4UserLimits *pULimits) : 
115 {                                              <<  32    fDaughters(0), fVoxel(0), fSmartless(2.), fVisAttributes (0) , fFastSimulationManager (0),
116   instanceID = subInstanceManager.CreateSubIns <<  33    fIsEnvelope(FALSE), fFieldManager(pFieldMgr)
117                                                <<  34 {
118   SetSensitiveDetector(nullptr);    // G4MT_sd <<  35     SetSolid(pSolid);
119   SetFieldManager(nullptr, false);  // G4MT_fm <<  36     SetMaterial(pMaterial);
120                                                <<  37     SetName(name);
121   G4MT_mass = 0.;                              <<  38     SetSensitiveDetector(pSDetector);
122   G4MT_ccouple = nullptr;                      <<  39     SetUserLimits(pULimits);    
123                                                <<  40     // Add to solid Store
124   // Add to store                              <<  41     G4LogicalVolumeStore::Register(this);
125   //                                           << 
126   G4LogicalVolumeStore::Register(this);        << 
127 }                                                  42 }
128                                                    43 
129 // ******************************************* <<  44 // Destructor - remove from solid Store
130 // Destructor - Removes itself from solid Stor << 
131 // NOTE: Not virtual                               45 // NOTE: Not virtual
132 // ******************************************* << 
133 //                                             << 
134 G4LogicalVolume::~G4LogicalVolume()                46 G4LogicalVolume::~G4LogicalVolume()
135 {                                                  47 {
136   if (!fLock && fRootRegion)  // De-register r <<  48     G4LogicalVolumeStore::DeRegister(this);
137   {                           // and flagged a << 
138     fRegion->RemoveRootLogicalVolume(this, tru << 
139   }                                            << 
140   delete lvdata;                               << 
141   G4LogicalVolumeStore::DeRegister(this);      << 
142 }                                              << 
143                                                << 
144 // ******************************************* << 
145 // SetName - Set volume name and notify store  << 
146 // ******************************************* << 
147 //                                             << 
148 void G4LogicalVolume::SetName(const G4String&  << 
149 {                                              << 
150   fName = pName;                               << 
151   G4LogicalVolumeStore::GetInstance()->SetMapV << 
152 }                                                  49 }
153                                                    50 
154 // ******************************************* <<  51 //  As this method is recursive, inlining it is harder (and asking for it 
155 // InitialiseWorker                            <<  52 //  is pointless if not counterproductive: it will increase code size)
156 //                                             << 
157 // This method is similar to the constructor.  << 
158 // thread to achieve the same effect as that o << 
159 // to register the new created instance. This  << 
160 // It does not create a new G4LogicalVolume in << 
161 // for the fields encapsulated by the class G4 << 
162 // ******************************************* << 
163 //                                                 53 //
164 void G4LogicalVolume::                         <<  54 void G4LogicalVolume::SetFastSimulationManager (
165 InitialiseWorker( G4LogicalVolume* /*pMasterOb <<  55   G4FastSimulationManager* pNewFastSimul,
166                   G4VSolid* pSolid,            <<  56   G4bool IsEnvelope) 
167                   G4VSensitiveDetector* pSDete <<  57 {
168 {                                              <<  58   if(!fIsEnvelope || IsEnvelope) {
169   subInstanceManager.SlaveCopySubInstanceArray <<  59      fIsEnvelope=IsEnvelope;
170                                                <<  60      fFastSimulationManager = pNewFastSimul;
171   SetSolid(pSolid);                            <<  61 
172   SetSensitiveDetector(pSDetector); //  How th <<  62      G4int NoDaughters=GetNoDaughters();
173   AssignFieldManager(fFieldManager);           <<  63      while((NoDaughters--)>0){
174    // Should be set - but a per-thread copy is <<  64         G4LogicalVolume *DaughterLogVol; 
175    // Must not call SetFieldManager(), which p <<  65         DaughterLogVol= GetDaughter(NoDaughters)->GetLogicalVolume();
176                                                <<  66         if(DaughterLogVol->GetFastSimulationManager() != pNewFastSimul) {
177 #ifdef CLONE_FIELD_MGR                         <<  67            DaughterLogVol->SetFastSimulationManager(pNewFastSimul,FALSE);
178   // Create a field FieldManager by cloning    <<  68         }
179   //                                           <<  69      }
180   G4FieldManager workerFldMgr = fFieldManager- << 
181   if( created || (GetFieldManager() != workerF << 
182   {                                            << 
183     SetFieldManager(fFieldManager, false); //  << 
184   }                                                70   }
185   else                                         << 
186   {                                            << 
187     // Field manager existed and is equal to c << 
188     //                                         << 
189     AssignFieldManager(workerFldMgr);          << 
190   }                                            << 
191 #endif                                         << 
192 }                                              << 
193                                                << 
194 // ******************************************* << 
195 // Clean                                       << 
196 // ******************************************* << 
197 //                                             << 
198 void G4LogicalVolume::Clean()                  << 
199 {                                              << 
200   subInstanceManager.FreeSlave();              << 
201 }                                                  71 }
202                                                    72 
203 // ******************************************* << 
204 // TerminateWorker                             << 
205 //                                             << 
206 // This method is similar to the destructor. I << 
207 // thread to achieve the partial effect as tha << 
208 // For G4LogicalVolume instances, nothing more << 
209 // ******************************************* << 
210 //                                             << 
211 void G4LogicalVolume::                             73 void G4LogicalVolume::
212 TerminateWorker( G4LogicalVolume* /*pMasterObj <<  74 ClearEnvelopeForFastSimulation( G4LogicalVolume* motherLogVol) 
213 {                                                  75 {
214 }                                              <<  76   if( fIsEnvelope ) {
                                                   >>  77      G4FastSimulationManager* NewFastSimulationVal=NULL;
215                                                    78 
216 // ******************************************* <<  79      // This is no longer an envelope !
217 // GetSubInstanceManager                       <<  80      fIsEnvelope=FALSE;
218 //                                             << 
219 // Returns the private data instance manager.  << 
220 // ******************************************* << 
221 //                                             << 
222 const G4LVManager& G4LogicalVolume::GetSubInst << 
223 {                                              << 
224   return subInstanceManager;                   << 
225 }                                              << 
226                                                << 
227 // ******************************************* << 
228 // GetFieldManager                             << 
229 // ******************************************* << 
230 //                                             << 
231 G4FieldManager* G4LogicalVolume::GetFieldManag << 
232 {                                              << 
233   return G4MT_fmanager;                        << 
234 }                                              << 
235                                                    81 
236 // ******************************************* <<  82      if( motherLogVol == NULL ) {
237 // AssignFieldManager                          <<  83   motherLogVol = this->FindMotherLogicalVolumeForEnvelope();
238 // ******************************************* <<  84 
239 //                                             <<  85      } else {
240 void G4LogicalVolume::AssignFieldManager( G4Fi <<  86         //  Check that motherLogVol is this' mother.
241 {                                              <<  87         //   If not, raise exception and set it to NULL.
242   G4MT_fmanager= fldMgr;                       <<  88         if ( FALSE ){
243   if(G4Threading::IsMasterThread())  { fFieldM <<  89      G4Exception(
244 }                                              <<  90             "G4LogicalVolume::ClearEnvelope Gave wrong mother LogicalVolume" );
245                                                <<  91      motherLogVol = NULL;
246 // ******************************************* <<  92   }
247 // IsExtended                                  <<  93      }
248 // ******************************************* <<  94      // Reset the ParameterisedSimulation values of self and all daughters
249 //                                             <<  95      //    (after ensuring the mother was given correctly or was found)
250 G4bool G4LogicalVolume::IsExtended() const     <<  96      if( motherLogVol != NULL ) {
251 {                                              <<  97     NewFastSimulationVal = motherLogVol->
252   return false;                                <<  98       GetFastSimulationManager();
253 }                                              <<  99     this->SetFastSimulationManager (NewFastSimulationVal,
254                                                << 100               FALSE);
255 // ******************************************* << 101      }
256 // SetFieldManager                             << 102   }else{
257 // ******************************************* << 103      G4Exception("Called G4LogicalVolume::ClearEnvelope for a non-envelope Logical Volume" );
258 //                                             << 
259 void                                           << 
260 G4LogicalVolume::SetFieldManager(G4FieldManage << 
261                                  G4bool        << 
262 {                                              << 
263   AssignFieldManager(pNewFieldMgr);            << 
264                                                << 
265   auto NoDaughters = GetNoDaughters();         << 
266   while ( (NoDaughters--)>0 )                  << 
267   {                                            << 
268     G4LogicalVolume* DaughterLogVol;           << 
269     DaughterLogVol = GetDaughter(NoDaughters)- << 
270     if ( forceAllDaughters || (DaughterLogVol- << 
271     {                                          << 
272       DaughterLogVol->SetFieldManager(pNewFiel << 
273     }                                          << 
274   }                                            << 
275 }                                              << 
276                                                << 
277 // ******************************************* << 
278 // AddDaughter                                 << 
279 // ******************************************* << 
280 //                                             << 
281 void G4LogicalVolume::AddDaughter(G4VPhysicalV << 
282 {                                              << 
283   EVolume daughterType = pNewDaughter->VolumeT << 
284                                                << 
285   // The type of the navigation needed is dete << 
286   //                                           << 
287   if( fDaughters.empty() )                     << 
288   {                                            << 
289     fDaughtersVolumeType = daughterType;       << 
290   }                                            << 
291   else                                         << 
292   {                                            << 
293     // Check consistency of detector descripti << 
294                                                << 
295     // 1. A replica or parameterised volume ca << 
296     //                                         << 
297     if( fDaughters[0]->IsReplicated() )        << 
298     {                                          << 
299       std::ostringstream message;              << 
300       message << "ERROR - Attempt to place a v << 
301         << G4endl                              << 
302         << "        already containing a repli << 
303         << "        A volume can either contai << 
304         << "        or a unique replica or par << 
305         << "           Mother logical volume:  << 
306         << "           Placing volume: " << pN << 
307         << G4endl;                             << 
308       G4Exception("G4LogicalVolume::AddDaughte << 
309                   FatalException, message,     << 
310                   "Replica or parameterised vo << 
311     }                                          << 
312     else                                       << 
313     {                                          << 
314       // 2. Ensure that Placement and External << 
315       //                                       << 
316       if(  daughterType != fDaughtersVolumeTyp << 
317       {                                        << 
318         std::ostringstream message;            << 
319         message << "ERROR - Attempt to place a << 
320           << G4endl                            << 
321           << "        already containing a dif << 
322           << "        A volume can either cont << 
323           << "        - one or more placements << 
324           << "        - one or more 'external' << 
325           << "          Mother logical volume: << 
326           << "          Volume being placed: " << 
327           << G4endl;                           << 
328         G4Exception("G4LogicalVolume::AddDaugh << 
329                     FatalException, message,   << 
330                     "Cannot mix placements and << 
331       }                                        << 
332     }                                          << 
333   }                                            << 
334                                                << 
335   // Invalidate previous calculation of mass - << 
336   //                                           << 
337   G4MT_mass = 0.;                              << 
338   fDaughters.push_back(pNewDaughter);          << 
339                                                << 
340   G4LogicalVolume* pDaughterLogical = pNewDaug << 
341                                                << 
342   // Propagate the Field Manager, if the daugh << 
343   //                                           << 
344   G4FieldManager* pDaughterFieldManager = pDau << 
345                                                << 
346   // Avoid propagating the fieldManager pointe << 
347   // and daughter's one is null as well...     << 
348   //                                           << 
349   if( (G4MT_fmanager != nullptr ) && (pDaughte << 
350   {                                            << 
351     pDaughterLogical->SetFieldManager(G4MT_fma << 
352   }                                            << 
353   if (fRegion != nullptr)                      << 
354   {                                            << 
355     PropagateRegion();                         << 
356     fRegion->RegionModified(true);             << 
357   }                                               104   }
358 }                                                 105 }
359                                                   106 
360 // ******************************************* << 107 void G4LogicalVolume::SetFieldManager (
361 // RemoveDaughter                              << 108   G4FieldManager* pNewFieldMgr,
362 // ******************************************* << 109         G4bool          forceAllDaughters) 
363 //                                             << 110 {
364 void G4LogicalVolume::RemoveDaughter(const G4V << 111   fFieldManager = pNewFieldMgr;
365 {                                              << 112 
366   for (auto i=fDaughters.cbegin(); i!=fDaughte << 113   G4int NoDaughters=GetNoDaughters();
367   {                                            << 114   while((NoDaughters--)>0){
368     if (**i==*p)                               << 115     G4LogicalVolume *DaughterLogVol; 
369     {                                          << 116     DaughterLogVol= GetDaughter(NoDaughters)->GetLogicalVolume();
370       fDaughters.erase(i);                     << 117     if(forceAllDaughters || (DaughterLogVol->GetFieldManager() != 0)) {
371       break;                                   << 118       DaughterLogVol->SetFieldManager(pNewFieldMgr, forceAllDaughters);
372     }                                          << 
373   }                                            << 
374   if (fRegion != nullptr)                      << 
375   {                                            << 
376     fRegion->RegionModified(true);             << 
377   }                                            << 
378   G4MT_mass = 0.;                              << 
379 }                                              << 
380                                                << 
381 // ******************************************* << 
382 // ClearDaughters                              << 
383 // ******************************************* << 
384 //                                             << 
385 void G4LogicalVolume::ClearDaughters()         << 
386 {                                              << 
387   fDaughters.erase(fDaughters.cbegin(), fDaugh << 
388   if (fRegion != nullptr)                      << 
389   {                                            << 
390     fRegion->RegionModified(true);             << 
391   }                                            << 
392   G4MT_mass = 0.;                              << 
393 }                                              << 
394                                                << 
395 // ******************************************* << 
396 // ResetMass                                   << 
397 // ******************************************* << 
398 //                                             << 
399 void G4LogicalVolume::ResetMass()              << 
400 {                                              << 
401   G4MT_mass= 0.0;                              << 
402 }                                              << 
403                                                << 
404 // ******************************************* << 
405 // GetSolid                                    << 
406 // ******************************************* << 
407 //                                             << 
408 G4VSolid* G4LogicalVolume::GetSolid(G4LVData & << 
409 {                                              << 
410   return instLVdata.fSolid;                    << 
411 }                                              << 
412                                                << 
413 G4VSolid* G4LogicalVolume::GetSolid() const    << 
414 {                                              << 
415   return this->GetSolid( subInstanceManager.of << 
416 }                                              << 
417                                                << 
418 // ******************************************* << 
419 // SetSolid                                    << 
420 // ******************************************* << 
421 //                                             << 
422 void G4LogicalVolume::SetSolid(G4VSolid *pSoli << 
423 {                                              << 
424                                                << 
425   G4MT_solid = pSolid;                         << 
426   this->ResetMass();                           << 
427 }                                              << 
428                                                << 
429 void G4LogicalVolume::SetSolid(G4LVData& instL << 
430 {                                              << 
431   instLVdata.fSolid = pSolid;                  << 
432   instLVdata.fMass = 0.0;                      << 
433 }                                              << 
434                                                << 
435 // ******************************************* << 
436 // GetMaterial                                 << 
437 // ******************************************* << 
438 //                                             << 
439 G4Material* G4LogicalVolume::GetMaterial() con << 
440 {                                              << 
441   return G4MT_material;                        << 
442 }                                              << 
443                                                << 
444 // ******************************************* << 
445 // SetMaterial                                 << 
446 // ******************************************* << 
447 //                                             << 
448 void G4LogicalVolume::SetMaterial(G4Material*  << 
449 {                                              << 
450   G4MT_material = pMaterial;                   << 
451   G4MT_mass = 0.0;                             << 
452 }                                              << 
453                                                << 
454 // ******************************************* << 
455 // UpdateMaterial                              << 
456 // ******************************************* << 
457 //                                             << 
458 void G4LogicalVolume::UpdateMaterial(G4Materia << 
459 {                                              << 
460   G4MT_material=pMaterial;                     << 
461   if (fRegion != nullptr) { G4MT_ccouple = fRe << 
462   G4MT_mass = 0.0;                             << 
463 }                                              << 
464                                                << 
465 // ******************************************* << 
466 // GetSensitiveDetector                        << 
467 // ******************************************* << 
468 //                                             << 
469 G4VSensitiveDetector* G4LogicalVolume::GetSens << 
470 {                                              << 
471   return G4MT_sdetector;                       << 
472 }                                              << 
473                                                << 
474 // ******************************************* << 
475 // SetSensitiveDetector                        << 
476 // ******************************************* << 
477 //                                             << 
478 void G4LogicalVolume::SetSensitiveDetector(G4V << 
479 {                                              << 
480   G4MT_sdetector = pSDetector;                 << 
481   if (G4Threading::IsMasterThread())  { fSensi << 
482 }                                              << 
483                                                << 
484 // ******************************************* << 
485 // GetMaterialCutsCouple                       << 
486 // ******************************************* << 
487 //                                             << 
488 const G4MaterialCutsCouple* G4LogicalVolume::G << 
489 {                                              << 
490   return G4MT_ccouple;                         << 
491 }                                              << 
492                                                << 
493 // ******************************************* << 
494 // SetMaterialCutsCouple                       << 
495 // ******************************************* << 
496 //                                             << 
497 void G4LogicalVolume::SetMaterialCutsCouple(G4 << 
498 {                                              << 
499   G4MT_ccouple = cuts;                         << 
500 }                                              << 
501                                                << 
502 // ******************************************* << 
503 // IsAncestor                                  << 
504 //                                             << 
505 // Finds out if the current logical volume is  << 
506 // physical volume                             << 
507 // ******************************************* << 
508 //                                             << 
509 G4bool                                         << 
510 G4LogicalVolume::IsAncestor(const G4VPhysicalV << 
511 {                                              << 
512   G4bool isDaughter = IsDaughter(aVolume);     << 
513   if (!isDaughter)                             << 
514   {                                            << 
515     for (auto itDau = fDaughters.cbegin(); itD << 
516     {                                          << 
517       isDaughter = (*itDau)->GetLogicalVolume( << 
518       if (isDaughter)  break;                  << 
519     }                                             119     }
520   }                                               120   }
521   return isDaughter;                           << 
522 }                                              << 
523                                                   121 
524 // ******************************************* << 
525 // TotalVolumeEntities                         << 
526 //                                             << 
527 // Returns the total number of physical volume << 
528 // in the tree represented by the current logi << 
529 // ******************************************* << 
530 //                                             << 
531 G4int G4LogicalVolume::TotalVolumeEntities() c << 
532 {                                              << 
533   G4int vols = 1;                              << 
534   for (auto itDau = fDaughters.cbegin(); itDau << 
535   {                                            << 
536     G4VPhysicalVolume* physDaughter = (*itDau) << 
537     vols += physDaughter->GetMultiplicity()    << 
538            *physDaughter->GetLogicalVolume()-> << 
539   }                                            << 
540   return vols;                                 << 
541 }                                              << 
542                                                << 
543 // ******************************************* << 
544 // GetMass                                     << 
545 //                                             << 
546 // Returns the mass of the logical volume tree << 
547 // estimated geometrical volume of each solid  << 
548 // to the logical volume and its daughters.    << 
549 // NOTE: the computation may require considera << 
550 //       depending from the complexity of the  << 
551 //       The returned value is cached and can  << 
552 //       calls (default), unless recomputation << 
553 //       'true' for the boolean argument in in << 
554 //       be forced if the geometry setup has c << 
555 //       call. By setting the 'propagate' bool << 
556 //       method returns the mass of the presen << 
557 //       (subtracted for the volume occupied b << 
558 //       The extra argument 'parMaterial' is i << 
559 //       consider cases of geometrical paramet << 
560 // ******************************************* << 
561 //                                             << 
562 G4double G4LogicalVolume::GetMass(G4bool force << 
563                                   G4bool propa << 
564                                   G4Material*  << 
565 {                                              << 
566   // Return the cached non-zero value, if not  << 
567   //                                           << 
568   if ( ((G4MT_mass) != 0.0) && (!forced) )  {  << 
569                                                << 
570   // Global density and computed mass associat << 
571   // volume without considering its daughters  << 
572   //                                           << 
573   G4Material* logMaterial = parMaterial != nul << 
574   if (logMaterial == nullptr)                  << 
575   {                                            << 
576     std::ostringstream message;                << 
577     message << "No material associated to the  << 
578             << fName << " !" << G4endl         << 
579             << "Sorry, cannot compute the mass << 
580     G4Exception("G4LogicalVolume::GetMass()",  << 
581                 FatalException, message);      << 
582     return 0.0;                                << 
583   }                                            << 
584   if ( GetSolid() == nullptr )                 << 
585   {                                            << 
586     std::ostringstream message;                << 
587     message << "No solid is associated to the  << 
588             << fName << " !" << G4endl         << 
589             << "Sorry, cannot compute the mass << 
590     G4Exception("G4LogicalVolume::GetMass()",  << 
591                 FatalException, message);      << 
592     return 0.0;                                << 
593   }                                            << 
594   G4double globalDensity = logMaterial->GetDen << 
595   G4double motherMass = GetSolid()->GetCubicVo << 
596   G4double massSum = motherMass;               << 
597                                                << 
598   // For each daughter in the tree, subtract t << 
599   // and if required by the propagate flag, ad << 
600   // one computed recursively                  << 
601                                                << 
602   for (auto itDau = fDaughters.cbegin(); itDau << 
603   {                                            << 
604     G4VPhysicalVolume* physDaughter = (*itDau) << 
605     G4LogicalVolume* logDaughter = physDaughte << 
606     G4double subMass = 0.0;                    << 
607     G4VSolid* daughterSolid = nullptr;         << 
608     G4Material* daughterMaterial = nullptr;    << 
609                                                << 
610     // Compute the mass to subtract and to add << 
611     // considering its multiplicity (i.e. repl << 
612     // eventually its parameterisation (by sol << 
613     //                                         << 
614     for (auto i=0; i<physDaughter->GetMultipli << 
615     {                                          << 
616       G4VPVParameterisation* physParam = physD << 
617       if (physParam != nullptr)                << 
618       {                                        << 
619         daughterSolid = physParam->ComputeSoli << 
620         daughterSolid->ComputeDimensions(physP << 
621         daughterMaterial = physParam->ComputeM << 
622       }                                        << 
623       else                                     << 
624       {                                        << 
625         daughterSolid = logDaughter->GetSolid( << 
626         daughterMaterial = logDaughter->GetMat << 
627       }                                        << 
628       subMass = daughterSolid->GetCubicVolume( << 
629                                                << 
630       // Subtract the daughter's portion for t << 
631       // add the real daughter's mass computed << 
632       //                                       << 
633       massSum -= subMass;                      << 
634       if (propagate)                           << 
635       {                                        << 
636         massSum += logDaughter->GetMass(true,  << 
637       }                                        << 
638     }                                          << 
639   }                                            << 
640   G4MT_mass = massSum;                         << 
641   return massSum;                              << 
642 }                                                 122 }
643                                                   123 
644 // ******************************************* << 124 //  The following method returns a meaningful result IF and only IF
645 // Change the daughters volume type -- checkin << 125 //  the current logical volume has exactly one physical volume that
646 //                                             << 126 //  uses it.
647 //  Undertakes primitive checking, to ensure t << 127 
648 //  are made:                                  << 128 G4LogicalVolume* 
649 //    - any type to 'external'  ( user respons << 129 G4LogicalVolume::FindMotherLogicalVolumeForEnvelope()
650 //    - the type proposed is checked against t << 130 {
651 //       (for potential switch back to 'intern << 131   G4LogicalVolume* motherLogVol= 0;
652 //  Returns success (true) or failure (false)  << 132   G4LogicalVolumeStore *Store = G4LogicalVolumeStore::GetInstance();
653 //                                             << 133 
654 G4bool G4LogicalVolume::ChangeDaughtersType(EV << 134   // Look for the current volume's mother volume.
655 {                                              << 135 
656   G4bool works = false;                        << 136   for (G4int LV=0;LV < Store->entries(); LV++){
657   if( aType == kExternal )                     << 137      G4LogicalVolume *aLogVol;
658   {                                            << 138     
659     // It is the responsibility of External Na << 139      aLogVol= Store->at(LV);
660     //                                         << 140      if( (aLogVol!=this) &&         // Don't look for it inside itself...
661     fDaughtersVolumeType = aType;              << 141   (aLogVol->GetFastSimulationManager()!=NULL)){
662     works = true;                              << 142       
                                                   >> 143         for (G4int daughter=0; daughter < aLogVol->GetNoDaughters();
                                                   >> 144        daughter++){
                                                   >> 145      if( aLogVol->GetDaughter(daughter)->GetLogicalVolume()==this) { 
                                                   >> 146         // "- Oh Dear, aLogVol is my mother !!!"
                                                   >> 147         motherLogVol = aLogVol;
                                                   >> 148         break;
                                                   >> 149      }
                                                   >> 150   }
                                                   >> 151      }
663   }                                               152   }
664   else                                         << 153   return motherLogVol;
665   {                                            << 
666     EVolume expectedVType = DeduceDaughtersTyp << 
667     works = (expectedVType == aType);          << 
668     if ( works )                               << 
669     {                                          << 
670       fDaughtersVolumeType = aType;            << 
671     }                                          << 
672   }                                            << 
673   return works;                                << 
674 }                                              << 
675                                                << 
676 // ******************************************* << 
677 // SetVisAttributes - copy version             << 
678 // ******************************************* << 
679 //                                             << 
680 void G4LogicalVolume::SetVisAttributes (const  << 
681 {                                              << 
682   if (G4Threading::IsWorkerThread()) return;   << 
683   fVisAttributes = std::make_shared<const G4Vi << 
684 }                                              << 
685                                                << 
686 // ******************************************* << 
687 // SetVisAttributes                            << 
688 // ******************************************* << 
689 //                                             << 
690 void G4LogicalVolume::SetVisAttributes (const  << 
691 {                                              << 
692   if (G4Threading::IsWorkerThread()) return;   << 
693   fVisAttributes = std::shared_ptr<const G4Vis << 
694 }                                                 154 }
695                                                   155