source: trunk/source/geometry/management/include/G4LogicalVolume.icc @ 1340

Last change on this file since 1340 was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 13.9 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27// $Id: G4LogicalVolume.icc,v 1.25 2008/07/10 09:40:08 gcosmo Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-01 $
29//
30//
31// class G4LogicalVolume Inline Implementation file
32//
33// 10.20.97 - P. MoraDeFreitas : Added SetFastSimulation method.
34// 05.11.98 - M. Verderi: Add Get/Set methods for fBiasWeight
35// 09.11.98 - J. Apostolakis:  Changed MagneticField to FieldManager
36// 12.02.99 - S.Giani: Added set/get methods for voxelization quality
37// 18.04.01 - G.Cosmo: Migrated to STL vector
38// 17.05.02 - G.Cosmo: Added IsToOptimise() method
39// --------------------------------------------------------------------
40
41// ********************************************************************
42// GetName
43// ********************************************************************
44//
45inline
46G4String G4LogicalVolume::GetName() const
47{
48  return fName;
49}
50   
51// ********************************************************************
52// SetName
53// ********************************************************************
54//
55inline
56void G4LogicalVolume::SetName(const G4String& pName)
57{
58  fName = pName;
59}
60
61// ********************************************************************
62// GetFieldManager
63// ********************************************************************
64//
65inline
66G4FieldManager* G4LogicalVolume::GetFieldManager() const
67{
68  return fFieldManager;
69}
70
71// ********************************************************************
72// GetNoDaughters
73// ********************************************************************
74//
75inline
76G4int G4LogicalVolume::GetNoDaughters() const
77{
78  return fDaughters.size();
79}
80
81// ********************************************************************
82// GetDaughter
83// ********************************************************************
84//
85inline
86G4VPhysicalVolume* G4LogicalVolume::GetDaughter(const G4int i) const
87{
88  return fDaughters[i];
89}
90
91// ********************************************************************
92// GetFastSimulationManager
93// ********************************************************************
94//
95inline
96G4FastSimulationManager* G4LogicalVolume::GetFastSimulationManager () const
97{
98  G4FastSimulationManager* fFSM = 0;
99  if(fRegion) fFSM = fRegion->GetFastSimulationManager();
100  return fFSM;
101}
102
103// ********************************************************************
104// AddDaughter
105// ********************************************************************
106//
107inline
108void G4LogicalVolume::AddDaughter(G4VPhysicalVolume* pNewDaughter)
109{
110  if( !fDaughters.empty() && fDaughters[0]->IsReplicated() )
111  {
112    G4cerr << "ERROR - Attempt to place a volume in a mother volume" << G4endl
113           << "        already containing a replicated volume." << G4endl
114           << "        A volume can either contain several placements" << G4endl
115           << "        or a unique replica or parameterised volume !" << G4endl
116           << "           Mother logical volume: " << GetName() << G4endl
117           << "           Placing volume: " << pNewDaughter->GetName() << G4endl;
118    G4Exception("G4LogicalVolume::AddDaughter()", "InvalidSetup", FatalException,
119                "Replica or parameterised volume must be the only daughter !");
120  }
121
122  fMass = 0.;
123  fDaughters.push_back(pNewDaughter);
124
125  G4LogicalVolume* pDaughterLogical = pNewDaughter->GetLogicalVolume();
126
127  // Propagate the Field Manager, if the daughter has no field Manager.
128  //
129  G4FieldManager* pDaughterFieldManager = pDaughterLogical->GetFieldManager();
130
131  if( pDaughterFieldManager == 0 )
132  {
133    pDaughterLogical->SetFieldManager(fFieldManager, true);
134  }
135  if (fRegion)
136  {
137    PropagateRegion();
138    fRegion->RegionModified(true);
139  }
140}
141
142// ********************************************************************
143// IsDaughter
144// ********************************************************************
145//
146inline
147G4bool G4LogicalVolume::IsDaughter(const G4VPhysicalVolume* p) const
148{
149  G4PhysicalVolumeList::const_iterator i;
150  for ( i=fDaughters.begin(); i!=fDaughters.end(); ++i )
151  {
152    if (**i==*p) return true;
153  }
154  return false;
155}
156
157// ********************************************************************
158// RemoveDaughter
159// ********************************************************************
160//
161inline
162void G4LogicalVolume::RemoveDaughter(const G4VPhysicalVolume* p)
163{
164  G4PhysicalVolumeList::iterator i;
165  for ( i=fDaughters.begin(); i!=fDaughters.end(); ++i )
166  {
167    if (**i==*p)
168    {
169      fDaughters.erase(i);
170      break;
171    }
172  }
173  if (fRegion)
174  {
175    fRegion->RegionModified(true);
176  }
177  fMass = 0.;
178}
179
180// ********************************************************************
181// ClearDaughters
182// ********************************************************************
183//
184inline
185void G4LogicalVolume::ClearDaughters()
186{
187  G4PhysicalVolumeList::iterator i;
188  for ( i=fDaughters.begin(); i!=fDaughters.end(); ++i )
189  {
190    fDaughters.erase(i);
191  }
192  if (fRegion)
193  {
194    fRegion->RegionModified(true);
195  }
196  fMass = 0.;
197}
198
199// ********************************************************************
200// GetSolid
201// ********************************************************************
202//
203inline
204G4VSolid* G4LogicalVolume::GetSolid() const
205{
206  return fSolid;
207}
208
209// ********************************************************************
210// SetSolid
211// ********************************************************************
212//
213inline
214void G4LogicalVolume::SetSolid(G4VSolid *pSolid)
215{
216  assert(pSolid != 0);
217  fSolid=pSolid;
218  fMass = 0.;
219}
220
221// ********************************************************************
222// GetMaterial
223// ********************************************************************
224//
225inline
226G4Material* G4LogicalVolume::GetMaterial() const
227{
228  return fMaterial;
229}
230
231// ********************************************************************
232// SetMaterial
233// ********************************************************************
234//
235inline
236void G4LogicalVolume::SetMaterial(G4Material *pMaterial)
237{
238  fMaterial=pMaterial;
239  fMass = 0.;
240}
241
242// ********************************************************************
243// UpdateMaterial
244// ********************************************************************
245//
246inline
247void G4LogicalVolume::UpdateMaterial(G4Material *pMaterial)
248{
249  fMaterial=pMaterial;
250  if(fRegion) { fCutsCouple = fRegion->FindCouple(pMaterial); }
251  fMass = 0.;
252}
253
254// ********************************************************************
255// GetSensitiveDetector
256// ********************************************************************
257//
258inline
259G4VSensitiveDetector* G4LogicalVolume::GetSensitiveDetector() const
260{
261  return fSensitiveDetector;
262}
263
264// ********************************************************************
265// SetSensitiveDetector
266// ********************************************************************
267//
268inline
269void G4LogicalVolume::SetSensitiveDetector(G4VSensitiveDetector* pSDetector)
270{
271  fSensitiveDetector = pSDetector;
272}
273
274// ********************************************************************
275// GetUserLimits
276// ********************************************************************
277//
278inline
279G4UserLimits* G4LogicalVolume::GetUserLimits() const
280{
281  if(fUserLimits) return fUserLimits;
282  if(fRegion) return fRegion->GetUserLimits();
283  return 0;
284}
285
286// ********************************************************************
287// SetUserLimits
288// ********************************************************************
289//
290inline
291void G4LogicalVolume::SetUserLimits(G4UserLimits* pULimits)
292{
293  fUserLimits = pULimits;
294}
295
296// ********************************************************************
297// GetVoxelHeader
298// ********************************************************************
299//
300inline
301G4SmartVoxelHeader* G4LogicalVolume::GetVoxelHeader() const
302{
303  return fVoxel;
304}
305
306// ********************************************************************
307// SetVoxelHeader
308// ********************************************************************
309//
310inline
311void G4LogicalVolume::SetVoxelHeader(G4SmartVoxelHeader* pVoxel)
312{
313  fVoxel = pVoxel;
314}
315
316// ********************************************************************
317// GetSmartless
318// ********************************************************************
319//
320inline
321G4double G4LogicalVolume::GetSmartless() const
322{
323  return fSmartless;
324}
325
326// ********************************************************************
327// SetSmartless
328// ********************************************************************
329//
330inline
331void G4LogicalVolume::SetSmartless(G4double s)
332{
333  fSmartless = s;
334}
335
336// ********************************************************************
337// IsToOptimise
338// ********************************************************************
339//
340inline
341G4bool G4LogicalVolume::IsToOptimise() const
342{
343  return fOptimise;
344}
345
346// ********************************************************************
347// SetOptimisation
348// ********************************************************************
349//
350inline
351void G4LogicalVolume::SetOptimisation(G4bool optim)
352{
353  fOptimise = optim;
354}
355
356// ********************************************************************
357// IsRootRegion
358// ********************************************************************
359//
360inline
361G4bool G4LogicalVolume::IsRootRegion() const
362{
363  return fRootRegion;
364}
365
366// ********************************************************************
367// SetRegionRootFlag
368// ********************************************************************
369//
370inline
371void G4LogicalVolume::SetRegionRootFlag(G4bool rreg)
372{
373  fRootRegion = rreg;
374}
375
376// ********************************************************************
377// IsRegion
378// ********************************************************************
379//
380inline
381G4bool G4LogicalVolume::IsRegion() const
382{
383  G4bool reg = false;
384  if (fRegion) reg = true;
385  return reg;
386}
387
388// ********************************************************************
389// SetRegion
390// ********************************************************************
391//
392inline
393void G4LogicalVolume::SetRegion(G4Region* reg)
394{
395  fRegion = reg;
396}
397
398// ********************************************************************
399// GetRegion
400// ********************************************************************
401//
402inline
403G4Region* G4LogicalVolume::GetRegion() const
404{
405  return fRegion;
406}
407
408// ********************************************************************
409// PropagateRegion
410// ********************************************************************
411//
412inline
413void G4LogicalVolume::PropagateRegion()
414{
415  fRegion->ScanVolumeTree(this, true);
416}
417
418// ********************************************************************
419// GetMaterialCutsCouple
420// ********************************************************************
421//
422inline
423const G4MaterialCutsCouple* G4LogicalVolume::GetMaterialCutsCouple() const
424{
425  return fCutsCouple;
426}
427
428// ********************************************************************
429// SetMaterialCutsCouple
430// ********************************************************************
431//
432inline
433void G4LogicalVolume::SetMaterialCutsCouple(G4MaterialCutsCouple* cuts)
434{
435  fCutsCouple = cuts;
436}
437
438// ********************************************************************
439// Lock
440// ********************************************************************
441//
442inline
443void G4LogicalVolume::Lock()
444{
445  fLock = true;
446}
447
448// ********************************************************************
449// Operator ==
450// ********************************************************************
451//
452inline
453G4bool G4LogicalVolume::operator == ( const G4LogicalVolume& lv) const
454{
455  return (this==&lv) ? true : false;
456}
457
458// ********************************************************************
459// GetVisAttributes
460// ********************************************************************
461//
462inline
463const G4VisAttributes* G4LogicalVolume::GetVisAttributes () const
464{
465  return fVisAttributes;
466}
467
468// ********************************************************************
469// SetVisAttributes
470// ********************************************************************
471//
472inline
473void G4LogicalVolume::SetVisAttributes (const G4VisAttributes* pVA)
474{
475  fVisAttributes = pVA;
476}
477
478// ********************************************************************
479// SetBiasWeight
480// ********************************************************************
481//
482inline
483void G4LogicalVolume::SetBiasWeight(G4double w)
484{
485  fBiasWeight = w;
486}
487
488// ********************************************************************
489// GetBiasWeight
490// ********************************************************************
491//
492inline
493G4double G4LogicalVolume::GetBiasWeight() const
494{
495  return fBiasWeight;
496}
497
Note: See TracBrowser for help on using the repository browser.