DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AlignmentStack.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation for LCD
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DD4HEP_ALIGNMENT_ALIGNMENTSTACK_H
14 #define DD4HEP_ALIGNMENT_ALIGNMENTSTACK_H
15 
16 // Framework include files
17 #include "DD4hep/Alignments.h"
18 #include "DD4hep/Objects.h"
19 #include "DD4hep/Memory.h"
20 
21 
23 namespace DD4hep {
24 
26  namespace Alignments {
27 
29 
35  public:
36  enum {
37  OVERLAP_DEFINED = 1<<20,
38  MATRIX_DEFINED = 1<<21,
40  CHECKOVL_VALUE = 1<<23,
41  RESET_VALUE = 1<<24,
42  RESET_CHILDREN = 1<<25,
43  ____LLLAST = 1<<31
44  } Flags;
45 
47 
52  struct StackEntry {
58  std::string path;
60  double overlap;
61 
63  StackEntry(DetElement p, const std::string& placement, const Delta& t, double ov);
65  StackEntry(const StackEntry& e);
67  virtual ~StackEntry();
68 
71 
73  bool overlapDefined() const { return delta.checkFlag(OVERLAP_DEFINED); }
75  bool checkOverlap() const { return delta.checkFlag(CHECKOVL_DEFINED); }
77  bool overlapValue() const { return delta.checkFlag(CHECKOVL_VALUE); }
79  bool hasMatrix() const { return delta.checkFlag(MATRIX_DEFINED); }
81  bool needsReset() const { return delta.checkFlag(RESET_VALUE); }
83  bool resetChildren() const { return delta.checkFlag(RESET_CHILDREN); }
84 
86  StackEntry& setReset(bool new_value=true);
88  StackEntry& setResetChildren(bool new_value=true);
90  StackEntry& setOverlapCheck(bool new_value=true);
92  StackEntry& setOverlapPrecision(double precision=0.001);
93  };
94  typedef std::map<std::string, StackEntry*> Stack;
95 
96  protected:
99 
101  AlignmentStack();
102  public:
103 
105  virtual ~AlignmentStack();
106 
108  static AlignmentStack& get();
110  static void create();
112  static bool exists();
114  bool insert(const std::string& full_path, dd4hep_ptr<StackEntry>& new_entry);
116  bool insert(dd4hep_ptr<StackEntry>& new_entry);
118  void release();
120  size_t size() const { return m_stack.size(); }
122  bool add(dd4hep_ptr<StackEntry>& new_entry);
126  std::vector<const StackEntry*> entries() const;
127  };
128 
129  } /* End namespace Geometry */
130 } /* End namespace DD4hep */
131 #endif /* DD4HEP_ALIGNMENT_ALIGNMENTSTACK_H */
StackEntry & operator=(const StackEntry &e)
Assignment operator.
virtual ~StackEntry()
Default destructor.
bool overlapDefined() const
Check if the overlap flag checking is enabled.
bool add(dd4hep_ptr< StackEntry > &new_entry)
Add a new entry to the cache. The key is the placement path.
bool insert(const std::string &full_path, dd4hep_ptr< StackEntry > &new_entry)
Add a new entry to the cache. The key is the placement path.
bool checkFlag(unsigned int mask) const
Check a given flag.
Definition: AlignmentData.h:90
enum DD4hep::Alignments::AlignmentStack::@15 Flags
DetElement detector
Reference to the detector element.
std::map< std::string, StackEntry * > Stack
virtual ~AlignmentStack()
Default destructor. Careful with this one:
Delta delta
Delta transformation to be applied.
Out version of the std auto_ptr implementation base either on auto_ptr or unique_ptr.
Definition: Memory.h:43
return e
Definition: Volumes.cpp:297
double overlap
Parameter for overlap checking.
void release()
Clear data content and remove the slignment stack.
DD4hep::Geometry::DetElement DetElement
static bool exists()
Check existence of alignment stack.
bool hasMatrix() const
Check if this alignment entry has a non unitary transformation matrix.
size_t size() const
Access size of the alignment stack.
bool needsReset() const
Check flag if the node location should be reset.
StackEntry & setReset(bool new_value=true)
Set flag to reset the entry to it's ideal geometrical position.
Class describing an condition to re-adjust an alignment.
Definition: AlignmentData.h:49
std::string path
Path to the misaligned volume.
StackEntry & setOverlapPrecision(double precision=0.001)
Set the precision for the overlap check (otherwise the default is 0.001 cm)
bool checkOverlap() const
Check if the overlap flag checking is enabled.
Stack m_stack
The subdetector specific map of alignments caches.
StackEntry & setOverlapCheck(bool new_value=true)
Set flag to check overlaps.
std::vector< const StackEntry * > entries() const
Get all path entries to be aligned. Note: transient!
StackEntry & setResetChildren(bool new_value=true)
Set flag to reset the entry's children to their ideal geometrical position.
bool resetChildren() const
Check flag if the node location and all children should be reset.
StackEntry(DetElement p, const std::string &placement, const Delta &t, double ov)
Fully initializing constructor.
Stack entry definition.
bool overlapValue() const
Check if the overalp value is present.
static void create()
Create an alignment stack instance. The creation of a second instance will be refused.
AlignmentStack()
Default constructor.
Alignment Stack object definition.
dd4hep_ptr< StackEntry > pop()
Retrieve an alignment entry of the current stack.