GeoModel - GeoModelCore
GeoAccessVolumeAction.cxx
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "GeoModelKernel/GeoAccessVolumeAction.h"
6 #include "GeoModelKernel/GeoNameTag.h"
7 #include "GeoModelKernel/GeoSerialDenominator.h"
8 #include "GeoModelKernel/GeoSerialIdentifier.h"
9 
10 #include <string>
11 
12 GeoAccessVolumeAction::GeoAccessVolumeAction(unsigned int Index, const GeoVAlignmentStore* store)
13  : m_transform(GeoTrf::Transform3D::Identity())
14  , m_defTransform(GeoTrf::Transform3D::Identity())
15  , m_index(Index)
16  , m_counter(0)
17  , m_nameTag(nullptr)
18  , m_serialDenominator(nullptr)
19  , m_idTag(nullptr)
20  , m_serialDenomPosition(0)
21  , m_serialIdentifier(nullptr)
22  , m_serialIdentPosition(0)
23  , m_alignStore(store)
24 {
25  setDepthLimit (1);
26  m_pendingTransformList.reserve(1);
27 }
28 
29 GeoAccessVolumeAction::~GeoAccessVolumeAction()
30 {
31 }
32 
34 {
35  m_pendingTransformList.push_back (xform);
36 }
37 
39 {
40  //
41  // Return if we have not got to any children:
42  //
43  if(getPath()->getLength()-1 == 0)
44  return;
45  //
46  // Otherwise check if the index equals the counter:
47  //
48  if(m_index == m_counter) {
49  m_volume = vol;
50  unsigned int listSize = m_pendingTransformList.size ();
51  if(listSize == 0) {
52  // do nothing....
53  }
54  else if(listSize == 1) {
55  m_transform = m_pendingTransformList[0]->getTransform(m_alignStore);
56  m_defTransform = m_pendingTransformList[0]->getDefTransform(m_alignStore);
57  }
58  else {
59  for(unsigned int t = 0; t < m_pendingTransformList.size (); t++) {
60  m_transform = m_transform * m_pendingTransformList[t]->getTransform(m_alignStore);
61  m_defTransform = m_defTransform * m_pendingTransformList[t]->getDefTransform(m_alignStore);
62  }
63  }
64  terminate();
65  }
66  else {
67  m_idTag = nullptr;
68  m_nameTag = nullptr;
69  m_pendingTransformList.erase (m_pendingTransformList.begin (),
70  m_pendingTransformList.end ());
71  }
72  //
73  // Increment the counter:
74  //
75  m_counter++;
76 }
77 
79 {
80  //
81  // Return if we have not got to any children:
82  //
83  if(getPath()->getLength()-1 == 0)
84  return;
85  //
86  // Otherwise check if the index equals the counter:
87  //
88  if(m_index == m_counter) {
89  m_volume = vol;
90  unsigned int listSize = m_pendingTransformList.size ();
91  if(listSize == 0) {
92  // do nothing....
93  }
94  else if(listSize == 1) {
95  m_transform = m_pendingTransformList[0]->getTransform(m_alignStore);
96  m_defTransform = m_pendingTransformList[0]->getDefTransform(m_alignStore);
97  }
98  else {
99  for(unsigned int t = 0; t < m_pendingTransformList.size (); t++) {
100  m_transform = m_transform * m_pendingTransformList[t]->getTransform(m_alignStore);
101  m_defTransform = m_defTransform * m_pendingTransformList[t]->getDefTransform(m_alignStore);
102  }
103  }
104  terminate();
105  }
106  else {
107  m_pendingTransformList.erase (m_pendingTransformList.begin (),
108  m_pendingTransformList.end ());
109  m_nameTag = nullptr;
110  m_idTag = nullptr;
111  }
112  //
113  // Increment the counter:
114  //
115  m_counter++;
116 }
117 
119 {
120  return m_volume;
121 }
122 
123 const GeoTrf::Transform3D & GeoAccessVolumeAction::getTransform () const
124 {
125  return m_transform;
126 }
127 
128 const GeoTrf::Transform3D & GeoAccessVolumeAction::getDefTransform () const
129 {
130  return m_defTransform;
131 }
132 
133 const std::string & GeoAccessVolumeAction::getName () const
134 {
135  if(m_name.empty()) {
136  if(m_nameTag) {
137  m_name = m_nameTag->getName();
138  }
139  else if(m_serialDenominator) {
140  m_name = m_serialDenominator->getBaseName() + std::to_string(m_index-m_serialDenomPosition);
141  }
142  else {
143  m_name = "ANON";
144  }
145  }
146  return m_name;
147 }
148 
150 {
151  m_nameTag = nameTag;
152  m_serialDenominator = nullptr;
153  m_serialDenomPosition = 0;
154 }
155 
157 {
158  m_serialDenominator = sD;
159  m_serialDenomPosition = m_counter;
160 }
161 
163 {
164  //
165  // Otherwise check if the index equals the counter:
166  //
167  if(m_index < m_counter + sT->getNCopies()) {
168  unsigned int copy = m_index - m_counter;
169  m_volume = sT->getVolume();
170  for(unsigned int t = 0; t < m_pendingTransformList.size (); t++) {
171  m_transform = m_transform * m_pendingTransformList[t]->getTransform(m_alignStore);
172  m_defTransform = m_defTransform * m_pendingTransformList[t]->getDefTransform(m_alignStore);
173  }
174  m_transform = m_transform * sT->getTransform (copy);
175  m_defTransform = m_defTransform * sT->getTransform (copy);
176  m_counter += (copy + 1);
177  terminate ();
178  }
179  else {
180  m_idTag = nullptr;
181  m_nameTag = nullptr;
182  m_pendingTransformList.erase(m_pendingTransformList.begin (),
183  m_pendingTransformList.end ());
184  m_counter += sT->getNCopies();
185  }
186 }
187 
189 {
190  m_idTag = idTag;
191  m_serialIdentifier = nullptr;
192  m_serialIdentPosition = 0;
193 }
194 
196 {
197  Query<int> id;
198  if(m_idTag) {
199  id = Query<int>(m_idTag->getIdentifier());
200  }
201  else if(m_serialIdentifier) {
202  id = Query<int>(m_index - m_serialIdentPosition + m_serialIdentifier->getBaseId());
203  }
204  return id;
205 }
206 
208 {
209  m_serialIdentifier = sI;
210  m_serialIdentPosition = m_counter;
211 }
Like a GeoSerialDenominator. Identifies volumes, including virtual volumes.
This class generates a name for all physical volumes following it. The name is a prefix string follow...
virtual void handleFullPhysVol(const GeoFullPhysVol *vol) override
Handles a physical volume.
virtual void handleSerialDenominator(const GeoSerialDenominator *sD) override
Handles a Serial Denominator.
virtual void handleSerialTransformer(const GeoSerialTransformer *sT) override
Handles a Serial Transformer.
virtual void handleIdentifierTag(const GeoIdentifierTag *idTag) override
Handles an Identifier Tag.
Abstract base class for GeoModel alignment stores The interface allows to store/retrieve transformati...
PVConstLink getVolume() const
Returns the selected physical volume or nullptr if not found.
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
virtual void handleSerialIdentifier(const GeoSerialIdentifier *sI) override
Handles an Serial Identifier.
const std::string & getName() const
Returns the name of the volume. From nametag or serial denominator.
Query< int > getId() const
Returns the id of the volume. From the identifier.
This class gives an integral identifer to the following physical volume.
virtual void handleNameTag(const GeoNameTag *nameTag) override
Handles a Name Tag.
const GeoTrf::Transform3D & getDefTransform() const
Returns the default ransformation to the volume.
virtual void handleTransform(const GeoTransform *xform) override
Handles a Transform.
This class takes a physical volume and places it according to a transformation field, N times.
const GeoTrf::Transform3D & getTransform() const
Returns the transformation to the volume.
virtual void handlePhysVol(const GeoPhysVol *vol) override
Handles a physical volume.
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