GeoModel - GeoModelCore
GeoAccessVolAndSTAction.cxx
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "GeoModelKernel/GeoAccessVolAndSTAction.h"
6 
7 #include "GeoModelKernel/GeoNameTag.h"
8 #include "GeoModelKernel/GeoSerialDenominator.h"
9 #include <string>
10 
11 GeoAccessVolAndSTAction::GeoAccessVolAndSTAction(unsigned int index)
12  : m_volume(0)
13  , m_serialTransformer(0)
14  , m_transform(GeoTrf::Transform3D::Identity())
15  , m_defTransform(GeoTrf::Transform3D::Identity())
16  , m_index(index)
17  , m_counter(0)
18  , m_nameTag(0)
19  , m_serialDenominator(0)
20  , m_idTag(0)
21  , m_serialDenomPosition(0)
22 {
23  setDepthLimit(1);
24 }
25 
26 GeoAccessVolAndSTAction::~GeoAccessVolAndSTAction()
27 {
28 }
29 
30 void GeoAccessVolAndSTAction::handleTransform(const GeoTransform *xform)
31 {
32  m_pendingTransformList.push_back (xform);
33 }
34 
35 void GeoAccessVolAndSTAction::handlePhysVol(const GeoPhysVol *vol)
36 {
37  // Return if we have not got any children
38  if(getPath()->getLength()-1 == 0)
39  return;
40 
41  // Otherwise check if the index equals the counter:
42  if(m_index == m_counter) {
43  m_volume = vol;
44  m_serialTransformer = 0;
45  unsigned int listSize = m_pendingTransformList.size();
46 
47  if(listSize == 0) {
48  // do nothing....
49  }
50  else if(listSize == 1) {
51  m_transform = m_pendingTransformList[0]->getTransform(nullptr);
52  m_defTransform = m_pendingTransformList[0]->getDefTransform(nullptr);
53  }
54  else {
55  for(unsigned int t=0; t<m_pendingTransformList.size(); t++) {
56  m_transform = m_transform * m_pendingTransformList[t]->getTransform(nullptr);
57  m_defTransform = m_defTransform * m_pendingTransformList[t]->getDefTransform(nullptr);
58  }
59  }
60  terminate ();
61  }
62  else {
63  m_idTag = 0;
64  m_nameTag = 0;
65  m_pendingTransformList.erase(m_pendingTransformList.begin(),
66  m_pendingTransformList.end());
67  }
68 
69  m_counter++;
70 }
71 
72 void GeoAccessVolAndSTAction::handleFullPhysVol(const GeoFullPhysVol *vol)
73 {
74  // Return if we have not got any children
75  if(getPath()->getLength()-1 == 0)
76  return;
77 
78  // Otherwise check if the index equals the counter:
79  if(m_index == m_counter)
80  {
81  m_volume = vol;
82  m_serialTransformer = 0;
83 
84  unsigned int listSize = m_pendingTransformList.size();
85  if(listSize == 0) {
86  // do nothing....
87  }
88  else if(listSize == 1) {
89  m_transform = m_pendingTransformList[0]->getTransform(nullptr);
90  m_defTransform = m_pendingTransformList[0]->getDefTransform(nullptr);
91  }
92  else {
93  for(unsigned int t = 0; t < m_pendingTransformList.size (); t++) {
94  m_transform = m_transform * m_pendingTransformList[t]->getTransform(nullptr);
95  m_defTransform = m_defTransform * m_pendingTransformList[t]->getDefTransform(nullptr);
96  }
97  }
98  terminate();
99  }
100  else {
101  m_pendingTransformList.erase (m_pendingTransformList.begin(),
102  m_pendingTransformList.end());
103  m_nameTag = 0;
104  m_idTag = 0;
105  }
106 
107  m_counter++;
108 }
109 
110 PVConstLink GeoAccessVolAndSTAction::getVolume() const
111 {
112  return m_volume;
113 }
114 
115 const GeoTrf::Transform3D & GeoAccessVolAndSTAction::getTransform() const
116 {
117  return m_transform;
118 }
119 
120 const GeoTrf::Transform3D & GeoAccessVolAndSTAction::getDefTransform() const
121 {
122  return m_defTransform;
123 }
124 
125 const std::string & GeoAccessVolAndSTAction::getName() const
126 {
127  if(m_name.empty()) {
128  if(m_nameTag) {
129  m_name = m_nameTag->getName();
130  }
131  else if(m_serialDenominator) {
132  m_name = m_serialDenominator->getBaseName() + std::to_string(m_index-m_serialDenomPosition);
133  }
134  else {
135  m_name = "ANON";
136  }
137  }
138  return m_name;
139 }
140 
141 void GeoAccessVolAndSTAction::handleNameTag(const GeoNameTag *nameTag)
142 {
143  m_nameTag = nameTag;
144  m_serialDenominator = 0;
145  m_serialDenomPosition = 0;
146 }
147 
148 void GeoAccessVolAndSTAction::handleSerialDenominator(const GeoSerialDenominator *sD)
149 {
150  m_serialDenominator = sD;
151  m_serialDenomPosition = m_counter;
152 }
153 
154 void GeoAccessVolAndSTAction::handleSerialTransformer(const GeoSerialTransformer *sT)
155 {
156  m_pendingTransformList.erase(m_pendingTransformList.begin(),
157  m_pendingTransformList.end());
158 
159  if(m_index == m_counter) {
160  m_volume = 0;
161  m_serialTransformer = sT;
162  terminate();
163  }
164  else {
165  m_idTag = 0;
166  m_nameTag = 0;
167  m_counter++;
168  }
169 }
170 
171 const GeoSerialTransformer* GeoAccessVolAndSTAction::getSerialTransformer() const
172 {
173  return m_serialTransformer;
174 }
175 
176 void GeoAccessVolAndSTAction::handleIdentifierTag(const GeoIdentifierTag *idTag)
177 {
178  m_idTag = idTag;
179 }
180 
181 Query<unsigned int> GeoAccessVolAndSTAction::getId() const
182 {
183  if(m_idTag) {
184  return Query<unsigned int>(m_idTag->getIdentifier());
185  }
186  else {
187  return Query<unsigned int>();
188  }
189 }
190 
191 
192 
193 
This class generates a name for all physical volumes following it. The name is a prefix string follow...
This class represent a physical volume whose absolute default and aligned positions are known and hel...
This class gives a name to the next physical volume.
Definition: GeoNameTag.h:17
This class gives an integral identifer to the following physical volume.
This class takes a physical volume and places it according to a transformation field, N times.
A basic geometrical (Euclidean) transform. Can return a GeoTrf::Transform3D. Reference counted...
Definition: GeoTransform.h:22
A GeoPhysVol is a physical volume for normal recursive access only. This means, normally, that it represents a piece of detector that nobody cares about except for tracing engines like GEANT. More specifically:
Definition: GeoPhysVol.h:31