diff --git a/DDCore/include/DD4hep/DetElement.h b/DDCore/include/DD4hep/DetElement.h index 3fcff9d4537240355576b38323d01ecb898acb37..7d75f6ea25b6223c046fcf647cd0f513fafe3e60 100644 --- a/DDCore/include/DD4hep/DetElement.h +++ b/DDCore/include/DD4hep/DetElement.h @@ -197,20 +197,21 @@ namespace dd4hep { typedef std::map<std::string, DetElement> Children; enum CopyParameters { - COPY_NONE = 0, - COPY_PLACEMENT = 1 << 0, - COPY_PARENT = 1 << 1, - COPY_ALIGNMENT = 1 << 2, + COPY_NONE = 0, + COPY_PLACEMENT = 1 << 0, + COPY_PARENT = 1 << 1, + COPY_ALIGNMENT = 1 << 2, + PROPAGATE_PARENT_ID = 1 << 3, LAST }; enum UpdateParam { - CONDITIONS_CHANGED = 1<<0, - PLACEMENT_CHANGED = 1<<1, - SOMETHING_CHANGED = 1<<2, - PLACEMENT_ELEMENT = 1<<20, - PLACEMENT_HIGHEST = 1<<21, - PLACEMENT_DETECTOR = 1<<22, + CONDITIONS_CHANGED = 1<<0, + PLACEMENT_CHANGED = 1<<1, + SOMETHING_CHANGED = 1<<2, + PLACEMENT_ELEMENT = 1<<20, + PLACEMENT_HIGHEST = 1<<21, + PLACEMENT_DETECTOR = 1<<22, PLACEMENT_NONE }; diff --git a/DDCore/src/DetectorInterna.cpp b/DDCore/src/DetectorInterna.cpp index 97d05218c06e9898e641925073527ee6a59766e1..5af73f6c0a8267e27beb2146c1d080113e39ef12 100644 --- a/DDCore/src/DetectorInterna.cpp +++ b/DDCore/src/DetectorInterna.cpp @@ -118,7 +118,8 @@ DetElementObject* DetElementObject::clone(int new_id, int flg) const { obj->children.clear(); for (const auto& i : children ) { const DetElementObject& d = i.second._data(); - DetElement c = d.clone(obj->id, DetElement::COPY_PLACEMENT); + int child_id = flg&DetElement::PROPAGATE_PARENT_ID ? obj->id : d.id; + DetElement c = d.clone(child_id, DetElement::COPY_PLACEMENT); c->SetName(d.GetName()); c->SetTitle(d.GetTitle()); bool r = obj->children.emplace(c.name(), c).second;