22 using namespace DD4hep;
23 using namespace DD4hep::Alignments;
36 AlignmentStack::StackEntry::StackEntry(
DetElement element,
const std::string& p,
const Delta& del,
double ov)
37 : detector(element), delta(del), path(p), overlap(ov)
44 : detector(e.detector), delta(e.delta), path(e.path), overlap(e.overlap)
109 throw runtime_error(
"AlignmentStack> Stack not allocated -- may not be retrieved!");
115 throw runtime_error(
"AlignmentStack> Stack already allocated. Multiple copies are not allowed!");
122 return _stack().get() != 0;
131 throw runtime_error(
"AlignmentStack> Attempt to delete non existing stack.");
136 if ( entry.get() && !full_path.empty() ) {
137 entry->path = full_path;
140 throw runtime_error(
"AlignmentStack> Attempt to apply an invalid alignment entry.");
150 if ( entry.get() && !entry->path.empty() ) {
151 Stack::const_iterator i =
m_stack.find(entry->path);
155 if ( !entry->detector.isValid() ) {
156 throw runtime_error(
"AlignmentStack> Invalid alignment entry [No such detector]");
158 printout(
INFO,
"AlignmentStack",
"Add node:%s",entry->path.c_str());
159 m_stack.insert(make_pair(entry->path,entry.get()));
163 throw runtime_error(
"AlignmentStack> The entry with path "+entry->path+
164 " cannot be re-aligned twice in one transaction.");
166 throw runtime_error(
"AlignmentStack> Attempt to apply an invalid alignment entry.");
171 Stack::iterator i =
m_stack.begin();
177 throw runtime_error(
"AlignmentStack> Alignment stack is empty. "
178 "Cannot pop entries - check size first!");
183 vector<const StackEntry*> result;
184 result.reserve(
m_stack.size());
185 for(Stack::const_iterator i=
m_stack.begin(); i !=
m_stack.end(); ++i)
186 result.push_back((*i).second);
StackEntry & operator=(const StackEntry &e)
Assignment operator.
dd4hep_ptr & adopt(T *ptr)
Assignment operator.
virtual ~StackEntry()
Default destructor.
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.
static void decrement(T *)
Decrement count according to type information.
DetElement detector
Reference to the detector element.
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.
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.
void destroyObjects(M &m)
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.
std::string path
Path to the misaligned volume.
static AlignmentStack & get()
Static client accessor.
static dd4hep_ptr< AlignmentStack > & _stack()
StackEntry & setOverlapPrecision(double precision=0.001)
Set the precision for the overlap check (otherwise the default is 0.001 cm)
static void increment(T *)
Increment count according to type information.
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.
StackEntry(DetElement p, const std::string &placement, const Delta &t, double ov)
Fully initializing constructor.
int printout(PrintLevel severity, const char *src, const char *fmt,...)
Calls the display action with a given severity level.
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.