DD4hep  1.28.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/Objects.h"
20 #include "DD4hep/Memory.h"
21 
22 
24 namespace dd4hep {
25 
27  namespace align {
28 
30 
36  public:
37  enum Flags {
38  OVERLAP_DEFINED = 1<<20,
39  MATRIX_DEFINED = 1<<21,
41  CHECKOVL_VALUE = 1<<23,
42  RESET_VALUE = 1<<24,
43  RESET_CHILDREN = 1<<25,
44  ____LLLAST = 1<<31
45  };
46  //#if 0
48 
53  class StackEntry {
54  public:
60  std::string path;
62  double overlap = 0.0;
63 
65  StackEntry() = delete;
67  StackEntry(DetElement p, const std::string& placement, const Delta& t, double ov);
69  StackEntry(const StackEntry& e);
71  virtual ~StackEntry();
72 
74  StackEntry& operator=(const StackEntry& e) = default;
75 #if 0
76  bool overlapDefined() const { return delta.checkFlag(OVERLAP_DEFINED); }
79  bool checkOverlap() const { return delta.checkFlag(CHECKOVL_DEFINED); }
81  bool overlapValue() const { return delta.checkFlag(CHECKOVL_VALUE); }
83  bool hasMatrix() const { return delta.checkFlag(MATRIX_DEFINED); }
85  bool needsReset() const { return delta.checkFlag(RESET_VALUE); }
87  bool resetChildren() const { return delta.checkFlag(RESET_CHILDREN); }
88 
90  StackEntry& setReset(bool new_value=true);
92  StackEntry& setResetChildren(bool new_value=true);
94  StackEntry& setOverlapCheck(bool new_value=true);
96  StackEntry& setOverlapPrecision(double precision=0.001);
97 #endif
98  };
99  //#endif
100  //typedef AlignmentData StackEntry;
101  typedef std::map<std::string, StackEntry*> Stack;
102 
103  protected:
106 
109  public:
110 
112  virtual ~GlobalAlignmentStack();
113 
115  static GlobalAlignmentStack& get();
117  static void create();
119  static bool exists();
120 
122  static bool overlapDefined(const StackEntry& e) { return e.delta.checkFlag(OVERLAP_DEFINED); }
124  static bool checkOverlap(const StackEntry& e) { return e.delta.checkFlag(CHECKOVL_DEFINED); }
126  static bool overlapValue(const StackEntry& e) { return e.delta.checkFlag(CHECKOVL_VALUE); }
128  static bool hasMatrix(const StackEntry& e) { return e.delta.checkFlag(MATRIX_DEFINED); }
130  static bool needsReset(const StackEntry& e) { return e.delta.checkFlag(RESET_VALUE); }
132  static bool resetChildren(const StackEntry& e) { return e.delta.checkFlag(RESET_CHILDREN); }
133 
135  bool insert(const std::string& full_path, dd4hep_ptr<StackEntry>& new_entry);
137  bool insert(dd4hep_ptr<StackEntry>& new_entry);
139  void release();
141  size_t size() const { return m_stack.size(); }
143  bool add(dd4hep_ptr<StackEntry>& new_entry);
147  std::vector<const StackEntry*> entries() const;
148  };
149 
150  } /* End namespace detail */
151 } /* End namespace dd4hep */
152 #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:101
dd4hep::align::GlobalAlignmentStack::StackEntry::detector
DetElement detector
Reference to the detector element.
Definition: GlobalAlignmentStack.h:56
dd4hep::align::GlobalAlignmentStack::hasMatrix
static bool hasMatrix(const StackEntry &e)
Check if this alignment entry has a non unitary transformation matrix.
Definition: GlobalAlignmentStack.h:128
dd4hep::align::GlobalAlignmentStack::CHECKOVL_DEFINED
@ CHECKOVL_DEFINED
Definition: GlobalAlignmentStack.h:40
dd4hep::align::GlobalAlignmentStack
Alignment Stack object definition.
Definition: GlobalAlignmentStack.h:35
dd4hep::align::GlobalAlignmentStack::GlobalAlignmentStack
GlobalAlignmentStack()
Default constructor.
Definition: GlobalAlignmentStack.cpp:83
dd4hep::align::GlobalAlignmentStack::____LLLAST
@ ____LLLAST
Definition: GlobalAlignmentStack.h:44
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:141
dd4hep::align::GlobalAlignmentStack::Flags
Flags
Definition: GlobalAlignmentStack.h:37
dd4hep::align::GlobalAlignmentStack::StackEntry::overlap
double overlap
Parameter for overlap checking.
Definition: GlobalAlignmentStack.h:62
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:41
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:58
dd4hep::align::GlobalAlignmentStack::overlapValue
static bool overlapValue(const StackEntry &e)
Check if the overalp value is present.
Definition: GlobalAlignmentStack.h:126
dd4hep::align::GlobalAlignmentStack::RESET_CHILDREN
@ RESET_CHILDREN
Definition: GlobalAlignmentStack.h:43
dd4hep::align::GlobalAlignmentStack::checkOverlap
static bool checkOverlap(const StackEntry &e)
Check if the overlap flag checking is enabled.
Definition: GlobalAlignmentStack.h:124
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:130
dd4hep::align::GlobalAlignmentStack::StackEntry::~StackEntry
virtual ~StackEntry()
Default destructor.
Definition: GlobalAlignmentStack.cpp:48
dd4hep::align::GlobalAlignmentStack::MATRIX_DEFINED
@ MATRIX_DEFINED
Definition: GlobalAlignmentStack.h:39
dd4hep::align::GlobalAlignmentStack::overlapDefined
static bool overlapDefined(const StackEntry &e)
Check if the overlap flag checking is enabled.
Definition: GlobalAlignmentStack.h:122
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:42
dd4hep::align::GlobalAlignmentStack::m_stack
Stack m_stack
The subdetector specific map of alignments caches.
Definition: GlobalAlignmentStack.h:105
dd4hep::align::GlobalAlignmentStack::StackEntry::path
std::string path
Path to the misaligned volume.
Definition: GlobalAlignmentStack.h:60
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:38
dd4hep::align::GlobalAlignmentStack::StackEntry
Stack entry definition.
Definition: GlobalAlignmentStack.h:53
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:132
dd4hep::dd4hep_ptr
Out version of the std auto_ptr implementation base either on auto_ptr or unique_ptr.
Definition: Memory.h:46