Skip to content
Snippets Groups Projects
Commit 40580df2 authored by Markus Frank's avatar Markus Frank Committed by MarkusFrankATcernch
Browse files

Add AlignmentsNominalMap to have default alignment maps returning DetElement::nominal()

parent 0e8d67f1
No related branches found
No related tags found
No related merge requests found
...@@ -58,7 +58,7 @@ int AlignmentsPrinter::operator()(DetElement de, int level) const { ...@@ -58,7 +58,7 @@ int AlignmentsPrinter::operator()(DetElement de, int level) const {
AlignedVolumePrinter::AlignedVolumePrinter(ConditionsMap* m, const string& pref,int flg) AlignedVolumePrinter::AlignedVolumePrinter(ConditionsMap* m, const string& pref,int flg)
: AlignmentsPrinter(m, pref, flg) : AlignmentsPrinter(m, pref, flg)
{ {
name = "Alignmant"; name = "Alignment";
} }
/// Callback to output alignments information /// Callback to output alignments information
......
...@@ -25,6 +25,17 @@ using namespace DD4hep::Conditions; ...@@ -25,6 +25,17 @@ using namespace DD4hep::Conditions;
DD4HEP_INSTANTIATE_HANDLE_NAMED(Interna::ConditionObject); DD4HEP_INSTANTIATE_HANDLE_NAMED(Interna::ConditionObject);
namespace {
/// Simple cast union to perform pointer arithmetic on raw byte based memory
union _P {
const char* character;
const void* p_void;
void** pp_void;
const Interna::ConditionObject* o;
_P(const void* val) { p_void = val; }
};
}
/// Default constructor /// Default constructor
Interna::ConditionObject::ConditionObject() Interna::ConditionObject::ConditionObject()
: NamedObject(), value(), validity(), address(), comment(), data() : NamedObject(), value(), validity(), address(), comment(), data()
...@@ -46,19 +57,14 @@ Interna::ConditionObject::~ConditionObject() { ...@@ -46,19 +57,14 @@ Interna::ConditionObject::~ConditionObject() {
/// Data offset from the opaque data block pointer to the condition /// Data offset from the opaque data block pointer to the condition
size_t Interna::ConditionObject::offset() { size_t Interna::ConditionObject::offset() {
union _P { static _P p((void*)0x1000);
const char* c; const void* v; const ConditionObject* o; static size_t off = _P(&p.o->data.grammar).character - p.character + sizeof(p.o->data.grammar);
_P(const void* val) { v = val; }
};
static _P p((void*)0x1000), q(&p.o->data.grammar);
static size_t off = q.c - p.c + sizeof(p.o->data.grammar);
return off; return off;
} }
/// Access the bound data payload. Exception id object is unbound /// Access the bound data payload. Exception id object is unbound
void* Interna::ConditionObject::payload() const { void* Interna::ConditionObject::payload() const {
void** p = (void**)(((char*)this)+offset()); return *(_P(_P(this).character+offset()).pp_void);
return *p;
} }
/// Move data content: 'from' will be reset to NULL /// Move data content: 'from' will be reset to NULL
......
...@@ -54,14 +54,16 @@ int AlignmentCreator::operator()(DetElement de, int) const { ...@@ -54,14 +54,16 @@ int AlignmentCreator::operator()(DetElement de, int) const {
if ( de.ptr() != de.world().ptr() ) { if ( de.ptr() != de.world().ptr() ) {
Condition cond(de.path()+"#"+Alignments::Keys::deltaName,Alignments::Keys::deltaName); Condition cond(de.path()+"#"+Alignments::Keys::deltaName,Alignments::Keys::deltaName);
Delta& delta = cond.bind<Delta>(); Delta& delta = cond.bind<Delta>();
cond->hash = Alignments::Keys::deltaKey; cond->hash = ConditionKey(de.key(),Alignments::Keys::deltaKey).hash;
cond->setFlag(Condition::ACTIVE|Condition::ALIGNMENT_DELTA); cond->setFlag(Condition::ACTIVE|Condition::ALIGNMENT_DELTA);
/// Simply move everything by 1 mm in z. Not physical, but this is just an example... /// Simply move everything by 1 mm in z. Not physical, but this is just an example...
delta.translation.SetZ(delta.translation.Z()+0.1*dd4hep::cm); delta.translation.SetZ(delta.translation.Z()+0.1*dd4hep::cm);
delta.rotation = RotationZYX(0.999,1.001,0.999); delta.rotation = RotationZYX(0.999,1.001,0.999);
delta.flags |= Delta::HAVE_TRANSLATION|Delta::HAVE_ROTATION; delta.flags |= Delta::HAVE_TRANSLATION|Delta::HAVE_ROTATION;
manager.registerUnlocked(pool, cond); if ( !manager.registerUnlocked(pool, cond) ) {
printout(printLevel,"Example","++ Adding manually alignments for %s",de.path().c_str()); printout(WARNING,"Example","++ Failed to register condition %s.",cond.name());
}
printout(printLevel,"Example","++ Adding manually alignments for %s",cond.name());
} }
return 1; return 1;
} }
...@@ -123,9 +123,11 @@ static int alignment_example (Geometry::LCDD& lcdd, int argc, char** argv) { ...@@ -123,9 +123,11 @@ static int alignment_example (Geometry::LCDD& lcdd, int argc, char** argv) {
printout(ERROR,"Compute","Failed tro compute %ld alignments of type %s.", printout(ERROR,"Compute","Failed tro compute %ld alignments of type %s.",
ares.missing, iov_typ->str().c_str()); ares.missing, iov_typ->str().c_str());
} }
if ( i == 0 ) {
// What else ? let's access/print the current selection
Scanner(AlignedVolumePrinter(sl.get(),"Example"),lcdd.world());
}
} }
// What else ? let's access/print the current selection
Scanner(AlignedVolumePrinter(slice.get(),"Example"),lcdd.world());
printout(INFO,"Summary","Processed a total %ld conditions (S:%ld,L:%ld,C:%ld,M:%ld) and (C:%ld,M:%ld) alignments. Created:%ld.", printout(INFO,"Summary","Processed a total %ld conditions (S:%ld,L:%ld,C:%ld,M:%ld) and (C:%ld,M:%ld) alignments. Created:%ld.",
cond_total.total(), cond_total.selected, cond_total.loaded, cond_total.computed, cond_total.missing, cond_total.total(), cond_total.selected, cond_total.loaded, cond_total.computed, cond_total.missing,
align_total.computed, align_total.missing, total_created); align_total.computed, align_total.missing, total_created);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment