DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
GlobalAlignmentStack.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
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 DDALIGN_GLOBALALIGNMENTSTACK_H
14 #define DDALIGN_GLOBALALIGNMENTSTACK_H
15 
16 // Framework include files
17 #include <DD4hep/Alignments.h>
18 #include <DD4hep/AlignmentData.h>
19 #include <DD4hep/Memory.h>
20 
21 
23 namespace dd4hep {
24 
26  namespace align {
27 
29 
35  public:
36  enum Flags {
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  };
45  //#if 0
47 
52  class StackEntry {
53  public:
59  std::string path;
61  double overlap = 0.0;
62 
64  StackEntry() = delete;
66  StackEntry(DetElement p, const std::string& placement, const Delta& t, double ov);
68  StackEntry(const StackEntry& e);
70  virtual ~StackEntry();
71 
73  StackEntry& operator=(const StackEntry& e) = default;
74 #if 0
75  bool overlapDefined() const { return delta.checkFlag(OVERLAP_DEFINED); }
78  bool checkOverlap() const { return delta.checkFlag(CHECKOVL_DEFINED); }
80  bool overlapValue() const { return delta.checkFlag(CHECKOVL_VALUE); }
82  bool hasMatrix() const { return delta.checkFlag(MATRIX_DEFINED); }
84  bool needsReset() const { return delta.checkFlag(RESET_VALUE); }
86  bool resetChildren() const { return delta.checkFlag(RESET_CHILDREN); }
87 
89  StackEntry& setReset(bool new_value=true);
91  StackEntry& setResetChildren(bool new_value=true);
93  StackEntry& setOverlapCheck(bool new_value=true);
95  StackEntry& setOverlapPrecision(double precision=0.001);
96 #endif
97  };
98  //#endif
99  //typedef AlignmentData StackEntry;
100  typedef std::map<std::string, StackEntry*> Stack;
101 
102  protected:
105 
108  public:
109 
111  virtual ~GlobalAlignmentStack();
112 
114  static GlobalAlignmentStack& get();
116  static void create();
118  static bool exists();
119 
121  static bool overlapDefined(const StackEntry& e) { return e.delta.checkFlag(OVERLAP_DEFINED); }
123  static bool checkOverlap(const StackEntry& e) { return e.delta.checkFlag(CHECKOVL_DEFINED); }
125  static bool overlapValue(const StackEntry& e) { return e.delta.checkFlag(CHECKOVL_VALUE); }
127  static bool hasMatrix(const StackEntry& e) { return e.delta.checkFlag(MATRIX_DEFINED); }
129  static bool needsReset(const StackEntry& e) { return e.delta.checkFlag(RESET_VALUE); }
131  static bool resetChildren(const StackEntry& e) { return e.delta.checkFlag(RESET_CHILDREN); }
132 
134  bool insert(const std::string& full_path, dd4hep_ptr<StackEntry>& new_entry);
136  bool insert(dd4hep_ptr<StackEntry>& new_entry);
138  void release();
140  size_t size() const { return m_stack.size(); }
142  bool add(dd4hep_ptr<StackEntry>& new_entry);
146  std::vector<const StackEntry*> entries() const;
147  };
148 
149  } /* End namespace detail */
150 } /* End namespace dd4hep */
151 #endif // DDALIGN_GLOBALALIGNMENTSTACK_H
dd4hep::align::GlobalAlignmentStack::get
static GlobalAlignmentStack & get()
Static client accessor.
Definition: GlobalAlignmentStack.cpp:95
dd4hep::align::GlobalAlignmentStack::Stack
std::map< std::string, StackEntry * > Stack
Definition: GlobalAlignmentStack.h:100
dd4hep::align::GlobalAlignmentStack::StackEntry::detector
DetElement detector
Reference to the detector element.
Definition: GlobalAlignmentStack.h:55
dd4hep::align::GlobalAlignmentStack::hasMatrix
static bool hasMatrix(const StackEntry &e)
Check if this alignment entry has a non unitary transformation matrix.
Definition: GlobalAlignmentStack.h:127
dd4hep::align::GlobalAlignmentStack::CHECKOVL_DEFINED
@ CHECKOVL_DEFINED
Definition: GlobalAlignmentStack.h:39
dd4hep::align::GlobalAlignmentStack
Alignment Stack object definition.
Definition: GlobalAlignmentStack.h:34
dd4hep::align::GlobalAlignmentStack::GlobalAlignmentStack
GlobalAlignmentStack()
Default constructor.
Definition: GlobalAlignmentStack.cpp:83
dd4hep::align::GlobalAlignmentStack::____LLLAST
@ ____LLLAST
Definition: GlobalAlignmentStack.h:43
dd4hep::align::GlobalAlignmentStack::create
static void create()
Create an alignment stack instance. The creation of a second instance will be refused.
Definition: GlobalAlignmentStack.cpp:102
Alignments.h
dd4hep::align::GlobalAlignmentStack::insert
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.
Definition: GlobalAlignmentStack.cpp:124
dd4hep::align::GlobalAlignmentStack::size
size_t size() const
Access size of the alignment stack.
Definition: GlobalAlignmentStack.h:140
dd4hep::align::GlobalAlignmentStack::Flags
Flags
Definition: GlobalAlignmentStack.h:36
dd4hep::align::GlobalAlignmentStack::StackEntry::overlap
double overlap
Parameter for overlap checking.
Definition: GlobalAlignmentStack.h:61
dd4hep::Delta
Class describing an condition to re-adjust an alignment.
Definition: AlignmentData.h:38
dd4hep::align::GlobalAlignmentStack::StackEntry::StackEntry
StackEntry()=delete
Default constructor.
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::align::GlobalAlignmentStack::CHECKOVL_VALUE
@ CHECKOVL_VALUE
Definition: GlobalAlignmentStack.h:40
dd4hep::align::GlobalAlignmentStack::entries
std::vector< const StackEntry * > entries() const
Get all path entries to be aligned. Note: transient!
Definition: GlobalAlignmentStack.cpp:173
dd4hep::align::GlobalAlignmentStack::StackEntry::delta
Delta delta
Delta transformation to be applied.
Definition: GlobalAlignmentStack.h:57
dd4hep::align::GlobalAlignmentStack::overlapValue
static bool overlapValue(const StackEntry &e)
Check if the overalp value is present.
Definition: GlobalAlignmentStack.h:125
dd4hep::align::GlobalAlignmentStack::RESET_CHILDREN
@ RESET_CHILDREN
Definition: GlobalAlignmentStack.h:42
dd4hep::align::GlobalAlignmentStack::checkOverlap
static bool checkOverlap(const StackEntry &e)
Check if the overlap flag checking is enabled.
Definition: GlobalAlignmentStack.h:123
StackEntry
GlobalAlignmentStack::StackEntry StackEntry
Definition: GlobalAlignmentParser.cpp:60
dd4hep::align::GlobalAlignmentStack::StackEntry::operator=
StackEntry & operator=(const StackEntry &e)=default
Assignment operator.
Memory.h
dd4hep::align::GlobalAlignmentStack::needsReset
static bool needsReset(const StackEntry &e)
Check flag if the node location should be reset.
Definition: GlobalAlignmentStack.h:129
dd4hep::align::GlobalAlignmentStack::StackEntry::~StackEntry
virtual ~StackEntry()
Default destructor.
Definition: GlobalAlignmentStack.cpp:48
dd4hep::align::GlobalAlignmentStack::MATRIX_DEFINED
@ MATRIX_DEFINED
Definition: GlobalAlignmentStack.h:38
dd4hep::align::GlobalAlignmentStack::overlapDefined
static bool overlapDefined(const StackEntry &e)
Check if the overlap flag checking is enabled.
Definition: GlobalAlignmentStack.h:121
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::align::GlobalAlignmentStack::pop
dd4hep_ptr< StackEntry > pop()
Retrieve an alignment entry of the current stack.
Definition: GlobalAlignmentStack.cpp:160
dd4hep::align::GlobalAlignmentStack::RESET_VALUE
@ RESET_VALUE
Definition: GlobalAlignmentStack.h:41
dd4hep::align::GlobalAlignmentStack::m_stack
Stack m_stack
The subdetector specific map of alignments caches.
Definition: GlobalAlignmentStack.h:104
dd4hep::align::GlobalAlignmentStack::StackEntry::path
std::string path
Path to the misaligned volume.
Definition: GlobalAlignmentStack.h:59
dd4hep::align::GlobalAlignmentStack::add
bool add(dd4hep_ptr< StackEntry > &new_entry)
Add a new entry to the cache. The key is the placement path.
Definition: GlobalAlignmentStack.cpp:139
dd4hep::align::GlobalAlignmentStack::~GlobalAlignmentStack
virtual ~GlobalAlignmentStack()
Default destructor. Careful with this one:
Definition: GlobalAlignmentStack.cpp:89
dd4hep::align::GlobalAlignmentStack::exists
static bool exists()
Check existence of alignment stack.
Definition: GlobalAlignmentStack.cpp:110
dd4hep::align::GlobalAlignmentStack::OVERLAP_DEFINED
@ OVERLAP_DEFINED
Definition: GlobalAlignmentStack.h:37
dd4hep::align::GlobalAlignmentStack::StackEntry
Stack entry definition.
Definition: GlobalAlignmentStack.h:52
dd4hep::align::GlobalAlignmentStack::release
void release()
Clear data content and remove the slignment stack.
Definition: GlobalAlignmentStack.cpp:115
AlignmentData.h
dd4hep::Delta::checkFlag
bool checkFlag(unsigned int mask) const
Check a given flag.
Definition: AlignmentData.h:79
dd4hep::align::GlobalAlignmentStack::resetChildren
static bool resetChildren(const StackEntry &e)
Check flag if the node location and all children should be reset.
Definition: GlobalAlignmentStack.h:131
dd4hep::dd4hep_ptr
Out version of the std auto_ptr implementation base either on auto_ptr or unique_ptr.
Definition: Memory.h:46