ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArG4
LArG4Barrel
src
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
5
#include "
PhysicalVolumeAccessor.h
"
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
22
PhysicalVolumeAccessor::PhysicalVolumeAccessor
(
const
std::string& name)
23
{
24
m_theLogicalVolume
=
GetLV
(name);
25
}
26
27
PhysicalVolumeAccessor::PhysicalVolumeAccessor
(
const
std::string& name,
28
const
std::string& PVname)
29
{
30
m_theLogicalVolume
=
GetLV
(name);
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
53
void
PhysicalVolumeAccessor::SetPhysicalVolumeList
(
const
std::string& name)
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::m_thePhysicalVolumes
PVMap m_thePhysicalVolumes
Definition
PhysicalVolumeAccessor.h:26
PhysicalVolumeAccessor::SetPhysicalVolumeList
void SetPhysicalVolumeList(const std::string &)
Definition
PhysicalVolumeAccessor.cxx:53
PhysicalVolumeAccessor::GetPhysicalVolume
const G4VPhysicalVolume * GetPhysicalVolume(int) const
Definition
PhysicalVolumeAccessor.cxx:42
PhysicalVolumeAccessor::GetLV
G4LogicalVolume * GetLV(const std::string &)
Definition
PhysicalVolumeAccessor.cxx:10
PhysicalVolumeAccessor::m_theLogicalVolume
G4LogicalVolume * m_theLogicalVolume
Definition
PhysicalVolumeAccessor.h:25
PhysicalVolumeAccessor::PhysicalVolumeAccessor
PhysicalVolumeAccessor(const std::string &)
Definition
PhysicalVolumeAccessor.cxx:22
Generated on
for ATLAS Offline Software by
1.17.0