ATLAS Offline Software
PhysicalVolumeAccessor.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "G4LogicalVolumeStore.hh"
7 #include <string>
8 #include <assert.h>
9 
10 G4LogicalVolume* PhysicalVolumeAccessor::GetLV(const std::string& name)
11 {
12  G4LogicalVolumeStore *lvs=G4LogicalVolumeStore::GetInstance();
13  for (unsigned int i=0;i<lvs->size();i++)
14  {
15  std::string lname=((lvs->operator[](i))->GetName());
16  if (name==lname)
17  return (lvs->operator[](i));
18  }
19  return nullptr;
20 }
21 
23 {
25 }
26 
28  const std::string& PVname)
29 {
31  assert (m_theLogicalVolume!=nullptr);
32  for (unsigned int i=0;i<m_theLogicalVolume->GetNoDaughters();i++)
33  {
34  G4VPhysicalVolume *pv=m_theLogicalVolume->GetDaughter(i);
35  if (PVname == static_cast<const std::string&>(pv->GetName()))
36  {
37  m_thePhysicalVolumes[pv->GetCopyNo()]=pv;
38  }
39  }
40 }
41 
42 const G4VPhysicalVolume* PhysicalVolumeAccessor::GetPhysicalVolume(int icopy) const
43 {
44  auto physVolIter = m_thePhysicalVolumes.find(icopy);
45  if (physVolIter!=m_thePhysicalVolumes.end())
46  return physVolIter->second;
47  else
48  {
49  return nullptr;
50  }
51 }
52 
54 {
55  // assert (m_thePhysicalVolumes.size()==0);
56  for (unsigned int i=0;i<m_theLogicalVolume->GetNoDaughters();i++)
57  {
58  G4VPhysicalVolume *pv=m_theLogicalVolume->GetDaughter(i);
59  if (name == static_cast<const std::string&>(pv->GetName()))
60  {
61  m_thePhysicalVolumes[pv->GetCopyNo()]=pv;
62  }
63  }
64 }
PhysicalVolumeAccessor.h
PhysicalVolumeAccessor::GetLV
G4LogicalVolume * GetLV(const std::string &)
Definition: PhysicalVolumeAccessor.cxx:10
lumiFormat.i
int i
Definition: lumiFormat.py:85
PhysicalVolumeAccessor::m_thePhysicalVolumes
PVMap m_thePhysicalVolumes
Definition: PhysicalVolumeAccessor.h:26
PhysicalVolumeAccessor::PhysicalVolumeAccessor
PhysicalVolumeAccessor(const std::string &)
Definition: PhysicalVolumeAccessor.cxx:22
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
PhysicalVolumeAccessor::SetPhysicalVolumeList
void SetPhysicalVolumeList(const std::string &)
Definition: PhysicalVolumeAccessor.cxx:53
PhysicalVolumeAccessor::GetPhysicalVolume
const G4VPhysicalVolume * GetPhysicalVolume(int) const
Definition: PhysicalVolumeAccessor.cxx:42
python.changerun.pv
pv
Definition: changerun.py:81
PhysicalVolumeAccessor::m_theLogicalVolume
G4LogicalVolume * m_theLogicalVolume
Definition: PhysicalVolumeAccessor.h:25