ATLAS Offline Software
VolumeHandle.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef VOLUMEHANDLE_H
6 #define VOLUMEHANDLE_H
7 
8 #include <vector>
9 
11 #include <QString>
12 
13 //Only initialises child classes on demand. And even then their SoNodes are not initialised until they must be shown.
15 class SoMaterial;
16 class SoSeparator;
17 class GeoMaterial;
18 #include <Inventor/C/errors/debugerror.h>
19 #include <Inventor/SbMatrix.h>
20 
21 class VolumeHandle {
22 public:
23 
25  MUONCHAMBERCHILD,//Top-level parent is muon chamber
26  MUONCHAMBER,//Muon chamber, adjusted to event data
27  MUONCHAMBER_DIRTY };//Muon chamber, not adjusted to event data
28  inline bool isInMuonChamber() const;//Muon chamber volume or muon chamber offspring
29  inline bool isMuonChamber() const;//Muon chamber volume (top-level volume)
30  inline void setMuonChamberDirty(bool);//Don't call unless isMuonChamber()
31  inline bool muonChamberDirty() const;//if is a muon chamber volume which is dirty
32  inline MuonChamberState muonChamberState() const;
33 
34  VolumeHandle(VolumeHandleSharedData * ,VolumeHandle * parent, const GeoPVConstLink&,int childNumber,
35  const MuonChamberState& mcs = NONMUONCHAMBER, const SbMatrix& accumTrans = SbMatrix() );
36 
37  virtual ~VolumeHandle();//lots of stuff to do here!
38  //Used (recursively) upon deletion (never delete before children are deleted).
39  void initialiseChildren();
40  inline bool childrenAreInitialised() const; //Always check this before getting the child list iterators
41  unsigned nChildren() const;//Works even before children are initialised
42 
43  SoMaterial * material();
44 
45  //Information for printout:
46  QString getName() const;
47  int copyNumber() const;//Returns -1 if doesnt have a valid copy number (because volume is not replicated), -2 in case of error.
48  quint32 hashID() const;//For vp1 persistification
49 
50  GeoPVConstLink geoPVConstLink() const;
51  const GeoMaterial * geoMaterial() const;
52  std::string getNameStdString() const;
53 
54  bool hasName(const std::string&) const;
55 
56  const SbMatrix& getGlobalTransformToVolume() const;//Transform from world to this volume.
57  SbMatrix getLocalTransformToVolume() const;//Transform from mother (=world for treetops) to this volume.
58 
59  bool isPositiveZ() const;//Uses getGlobalTransformToVolume to figure out whether Z of the transformation.
60 
62  // Navigation: //
64  typedef std::vector<VolumeHandle *> VolumeHandleList;
66  typedef VolumeHandleList::const_iterator VolumeHandleListConstItr;
67 
68  inline VolumeHandle * parent();//returns 0 if toplevel.
69  inline VolumeHandle * topLevelParent();//goes up through parents and returns the toplevel one (returns itself if toplevel).
70  inline VolumeHandleListItr childrenBegin();//Dont use if not childrenAreInitialised().
71  inline VolumeHandleListItr childrenEnd();//Dont use if not childrenAreInitialised()
72  inline VolumeHandle * child(int index) const;//Will crash if out of range!
73  inline int childNumber() const;
74 
75  // void zoomToVolume(SoCamera*, SoSeparator * root);
76  // void ensureVisibleInTreeWidget();
77 
78  inline VP1GeoFlags::VOLSTATE state() const;
79  void setState( const VP1GeoFlags::VOLSTATE& state );
80  void reset();//Set state of volume and all daughters to contracted
81  bool isAttached() const;
83 
84  bool isEther() const;
85  void expandMothersRecursivelyToNonEther();//expands the tree down to volumes that are either not ether or without children
86 
87  bool isInitialisedAndHasNonStandardShape() const;//True if the 3D shape of this volume can not be represented by standard VRML nodes.
88 
89  SoSeparator * nodeSoSeparator() const;//Returns pointer to 3D representation of volume (null if not built yet).
90  void ensureBuildNodeSep();
91 
92  //Convenience:
93  // void zap();
94  // void ensureVisible();
95  // void expandAllChildren(unsigned limit = 50);
96 
97  // void ensureVisibleInTreeWidget();
98  // double mass() const;
99  // int copyNumber() const;
100  // ...
101  // Get SoNodes, pvconstlink, ...
102 
103  void updateLabels();
104 
105  QByteArray getPersistifiableState() const;
106  void applyPersistifiableState(QByteArray);
107 
108  // Which subsystem I'm in?
110 
111  // For labels
112  virtual QString getDescriptiveName() const;
113  virtual QString muonChamberT0(unsigned int=0) const;
114 
115 public:
116  class Imp;//For once this is declared public. This is to avoid
117  //problems with datastream operators.
118 private:
119 
120  // Illegal to copy/assign a VolumeHandle:
123 
124  Imp * m_d;
125 
126  //Here for inline methods:
127  const int m_childNumber;//0 if the first child of parent, 1 if the second, etc.
128  const unsigned m_nchildren;//cached for efficiency.
130 
134  //Some of these could be moved to private implementation with some care:
135  bool haveParentsNotExpanded() const;
136  void attachAllContractedChildren();//also checks children of expanded children (recursively).
137  void detachAllContractedChildren();//also checks children of expanded children (recursively).
138 };
139 
141 // INLINES //
143 
146 inline bool VolumeHandle::childrenAreInitialised() const { return m_children.size()==m_nchildren; }
149 inline unsigned VolumeHandle::nChildren() const { return m_nchildren; }
150 inline VolumeHandle * VolumeHandle::child(int index) const { return m_children.at(index); }
151 inline int VolumeHandle::childNumber() const { return m_childNumber; }
158 inline void VolumeHandle::reset() {
161 }
162 inline QString VolumeHandle::getDescriptiveName() const {
163  QString name = getName();
164  name.remove("_Station");
165  return name;
166 }
167 
168 inline QString VolumeHandle::muonChamberT0(unsigned int ) const {
169  return QString();
170 }
171 
172 
173 #endif
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
VolumeHandle::isInitialisedAndHasNonStandardShape
bool isInitialisedAndHasNonStandardShape() const
Definition: VolumeHandle.cxx:656
VolumeHandle::muonChamberT0
virtual QString muonChamberT0(unsigned int=0) const
Definition: VolumeHandle.h:168
VolumeHandle::isInMuonChamber
bool isInMuonChamber() const
Definition: VolumeHandle.h:153
VolumeHandle::reset
void reset()
Definition: VolumeHandle.h:158
VolumeHandle::setMuonChamberDirty
void setMuonChamberDirty(bool)
Definition: VolumeHandle.h:156
VolumeHandle::subsystem
VP1GeoFlags::SubSystemFlag subsystem() const
Definition: VolumeHandle.cxx:585
index
Definition: index.py:1
VolumeHandle::muonChamberDirty
bool muonChamberDirty() const
Definition: VolumeHandle.h:157
VolumeHandle::setState
void setState(const VP1GeoFlags::VOLSTATE &state)
Definition: VolumeHandle.cxx:350
VolumeHandle::material
SoMaterial * material()
Definition: VolumeHandle.cxx:187
VolumeHandle::geoMaterial
const GeoMaterial * geoMaterial() const
Definition: VolumeHandle.cxx:507
VolumeHandle::attachAllContractedChildren
void attachAllContractedChildren()
Definition: VolumeHandle.cxx:422
VolumeHandle::topLevelParent
VolumeHandle * topLevelParent()
Definition: VolumeHandle.h:145
VolumeHandle::MuonChamberState
MuonChamberState
Definition: VolumeHandle.h:24
VolumeHandle::~VolumeHandle
virtual ~VolumeHandle()
Definition: VolumeHandle.cxx:113
VolumeHandle::Imp
Definition: VolumeHandle.cxx:48
VolumeHandle::MUONCHAMBER_DIRTY
@ MUONCHAMBER_DIRTY
Definition: VolumeHandle.h:27
VolumeHandle::child
VolumeHandle * child(int index) const
Definition: VolumeHandle.h:150
VolumeHandle::geoPVConstLink
GeoPVConstLink geoPVConstLink() const
Definition: VolumeHandle.cxx:163
VolumeHandle::m_parent
VolumeHandle * m_parent
Definition: VolumeHandle.h:131
VolumeHandle::m_children
VolumeHandleList m_children
Definition: VolumeHandle.h:132
VolumeHandle::m_d
Imp * m_d
Definition: VolumeHandle.h:124
VolumeHandle::parent
VolumeHandle * parent()
Definition: VolumeHandle.h:144
VolumeHandle::isMuonChamber
bool isMuonChamber() const
Definition: VolumeHandle.h:154
VolumeHandle::childrenBegin
VolumeHandleListItr childrenBegin()
Definition: VolumeHandle.h:147
VolumeHandle::childrenAreInitialised
bool childrenAreInitialised() const
Definition: VolumeHandle.h:146
VolumeHandle::getNameStdString
std::string getNameStdString() const
Definition: VolumeHandle.cxx:175
VolumeHandle::detachAllContractedChildren
void detachAllContractedChildren()
Definition: VolumeHandle.cxx:439
VolumeHandle::nodeSoSeparator
SoSeparator * nodeSoSeparator() const
Definition: VolumeHandle.cxx:232
VolumeHandle::operator=
VolumeHandle & operator=(const VolumeHandle &)
VolumeHandle::isPositiveZ
bool isPositiveZ() const
Definition: VolumeHandle.cxx:663
VolumeHandle::VolumeHandle
VolumeHandle(const VolumeHandle &)
VolumeHandle::m_state
VP1GeoFlags::VOLSTATE m_state
Definition: VolumeHandle.h:133
VolumeHandle::getPersistifiableState
QByteArray getPersistifiableState() const
Definition: VolumeHandle.cxx:539
VolumeHandle::m_muonChamberState
MuonChamberState m_muonChamberState
Definition: VolumeHandle.h:129
VolumeHandle::VolumeHandle
VolumeHandle(VolumeHandleSharedData *, VolumeHandle *parent, const GeoPVConstLink &, int childNumber, const MuonChamberState &mcs=NONMUONCHAMBER, const SbMatrix &accumTrans=SbMatrix())
Definition: VolumeHandle.cxx:97
VolumeHandle::copyNumber
int copyNumber() const
Definition: VolumeHandle.cxx:455
VP1GeoFlags::VOLSTATE
VOLSTATE
Definition: VP1GeoFlags.h:87
VolumeHandle::initialiseChildren
void initialiseChildren()
Definition: VolumeHandle.cxx:136
VolumeHandleSharedData
Definition: VolumeHandleSharedData.h:25
VolumeHandle::nChildren
unsigned nChildren() const
Definition: VolumeHandle.h:149
VolumeHandle::isEther
bool isEther() const
Definition: VolumeHandle.cxx:512
VolumeHandle
Definition: VolumeHandle.h:21
VP1GeoFlags.h
VolumeHandle::updateLabels
void updateLabels()
Definition: VolumeHandle.cxx:672
VolumeHandle::expandMothersRecursivelyToNonEther
void expandMothersRecursivelyToNonEther()
Definition: VolumeHandle.cxx:518
VolumeHandle::VolumeHandleList
std::vector< VolumeHandle * > VolumeHandleList
Definition: VolumeHandle.h:64
VolumeHandle::muonChamberState
MuonChamberState muonChamberState() const
Definition: VolumeHandle.h:155
VolumeHandle::haveParentsNotExpanded
bool haveParentsNotExpanded() const
Definition: VolumeHandle.cxx:416
VolumeHandle::ensureBuildNodeSep
void ensureBuildNodeSep()
Definition: VolumeHandle.cxx:238
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
VolumeHandle::childNumber
int childNumber() const
Definition: VolumeHandle.h:151
VolumeHandle::getName
QString getName() const
Definition: VolumeHandle.cxx:169
VolumeHandle::applyPersistifiableState
void applyPersistifiableState(QByteArray)
Definition: VolumeHandle.cxx:556
VolumeHandle::hashID
quint32 hashID() const
Definition: VolumeHandle.cxx:482
VolumeHandle::isAttached
bool isAttached() const
Definition: VolumeHandle.cxx:501
VolumeHandle::MUONCHAMBERCHILD
@ MUONCHAMBERCHILD
Definition: VolumeHandle.h:25
VolumeHandle::VolumeHandleListItr
VolumeHandleList::iterator VolumeHandleListItr
Definition: VolumeHandle.h:65
VolumeHandle::state
VP1GeoFlags::VOLSTATE state() const
Definition: VolumeHandle.h:152
VolumeHandle::hasName
bool hasName(const std::string &) const
Definition: VolumeHandle.cxx:181
VolumeHandle::m_childNumber
const int m_childNumber
Definition: VolumeHandle.h:127
VolumeHandle::getLocalTransformToVolume
SbMatrix getLocalTransformToVolume() const
Definition: VolumeHandle.cxx:494
VolumeHandle::MUONCHAMBER
@ MUONCHAMBER
Definition: VolumeHandle.h:26
VP1GeoFlags::SubSystemFlag
SubSystemFlag
Definition: VP1GeoFlags.h:30
VolumeHandle::NONMUONCHAMBER
@ NONMUONCHAMBER
Definition: VolumeHandle.h:24
VolumeHandle::m_nchildren
const unsigned m_nchildren
Definition: VolumeHandle.h:128
VolumeHandle::getGlobalTransformToVolume
const SbMatrix & getGlobalTransformToVolume() const
Definition: VolumeHandle.cxx:489
VolumeHandle::getDescriptiveName
virtual QString getDescriptiveName() const
Definition: VolumeHandle.h:162
VP1GeoFlags::CONTRACTED
@ CONTRACTED
Definition: VP1GeoFlags.h:87
VolumeHandle::contractDaughtersRecursively
void contractDaughtersRecursively()
Definition: VolumeHandle.cxx:403
VolumeHandle::childrenEnd
VolumeHandleListItr childrenEnd()
Definition: VolumeHandle.h:148
VolumeHandle::VolumeHandleListConstItr
VolumeHandleList::const_iterator VolumeHandleListConstItr
Definition: VolumeHandle.h:66