diff --git a/DDCore/include/DD4hep/IDDescriptor.h b/DDCore/include/DD4hep/IDDescriptor.h index 4b0796587fc9480b75ea245e5f63c30eae8fc145..b2f9e81ce773dcc51cf7ada74cfe329436fb7149 100644 --- a/DDCore/include/DD4hep/IDDescriptor.h +++ b/DDCore/include/DD4hep/IDDescriptor.h @@ -58,7 +58,7 @@ namespace DD4hep { * @version 1.0 * @date 2012/07/31 */ - struct Object { + struct Object : public TNamed { std::string description; FieldMap fieldMap; FieldIDs fieldIDs; diff --git a/DDCore/include/DD4hep/Segmentations.h b/DDCore/include/DD4hep/Segmentations.h index 3c431792fb5c6c68467bab8e1a6c75d3812da584..e8e85295855866addbe355136a2882d457697ff8 100644 --- a/DDCore/include/DD4hep/Segmentations.h +++ b/DDCore/include/DD4hep/Segmentations.h @@ -40,7 +40,7 @@ namespace DD4hep { * @author M.Frank * @version 1.0 */ - struct Object { + struct Object : public TNamed { /// Magic word to check object integrity unsigned long magic; /// Segmentation type (REGULAR or EXTENDED) @@ -104,8 +104,6 @@ namespace DD4hep { : Handle<Implementation>(e){} /// Constructor to create a new segmentation object (to be called by super class only) Segmentation(const std::string& type); - /// Accessor to ata structure - Object& _data() const { return *data<Object>(); } /// Access flag for hit positioning bool useForHitPosition() const; /// Segmentation type @@ -114,10 +112,10 @@ namespace DD4hep { template<typename IFACE, typename CONCRETE> IFACE* setExtension(CONCRETE* c) { return (IFACE*)i_setExtension(dynamic_cast<IFACE*>(c),typeid(IFACE),_delete<IFACE>); } /// Access extension element by the type - template <class T> T* extension() const { return (T*)i_extension(typeid(T)); } + template <class T> T* extensionUnchecked() const + { return (T*)object<Object>().data.extension.ptr; } /// Access extension element by the type - template <class T> T* extensionUnchecked() const { return (T*)_data().data.extension.ptr;} - + template <class T> T* extension() const { return (T*)i_extension(typeid(T)); } /// Compute the coordinate in one dimension given a eauidistant bin value. static double binCenter(int bin, double width) { return (double(bin) + .5) * width; } /// Compute the equidistant bin given a coordinate in one dimension. @@ -140,8 +138,6 @@ namespace DD4hep { /// Constructor to be used when reading the already parsed object SegmentationParams(const Segmentation& e) : Ref_t(e) {} - /// Accessor to ata structure - Object& _data() const { return *data<Object>(); } /// Segmentation type const std::string type() const; /// Access to the parameters diff --git a/DDCore/src/IDDescriptor.cpp b/DDCore/src/IDDescriptor.cpp index 72da4a2e617040f287d88aab51e7286744838203..1fa4668dbc1e58f19714d84090e046800625e5e5 100644 --- a/DDCore/src/IDDescriptor.cpp +++ b/DDCore/src/IDDescriptor.cpp @@ -58,7 +58,7 @@ namespace { } /// Standard constructor -IDDescriptor::Object::Object() : maxBit(0) { +IDDescriptor::Object::Object() : TNamed(), maxBit(0) { InstanceCount::increment(this); } @@ -70,7 +70,7 @@ IDDescriptor::Object::~Object() { /// Initializing constructor IDDescriptor::IDDescriptor(const string& description) { - Value<TNamed,Object>* obj = new Value<TNamed,Object>(); + Object* obj = new Object(); assign(obj,description,"iddescriptor"); _construct(obj, description); } diff --git a/DDCore/src/Objects.cpp b/DDCore/src/Objects.cpp index 15af6bbada85b6dfd5c0867594defc345a0da288..1f68daf77c7f95fa6dfdbadfce595ad0afedd572 100644 --- a/DDCore/src/Objects.cpp +++ b/DDCore/src/Objects.cpp @@ -52,7 +52,7 @@ void Author::setAuthorEmail(const std::string& addr) { } /// Standard constructor -Header::Object::Object() { +Header::Object::Object() : TNamed() { InstanceCount::increment(this); } @@ -63,7 +63,7 @@ Header::Object::~Object() { /// Constructor to be used when creating a new DOM tree Header::Header(const string& author, const string& url) { - Value<TNamed,Object>* ptr = new Value<TNamed,Object>(); + Object* ptr = new Object(); assign(ptr,author, url); } @@ -203,7 +203,7 @@ VisAttr::Object::~Object() { /// Constructor to be used when creating a new DOM tree VisAttr::VisAttr(const string& name) { - Value<TNamed,Object>* obj = new Value<TNamed,Object>(); + Object* obj = new Object(); assign(obj, name, "vis"); obj->color = 2; setLineStyle(SOLID); @@ -214,73 +214,73 @@ VisAttr::VisAttr(const string& name) { /// Get Flag to show/hide daughter elements bool VisAttr::showDaughters() const { - return _data().showDaughters; + return object<Object>().showDaughters; } /// Set Flag to show/hide daughter elements void VisAttr::setShowDaughters(bool value) { - _data().showDaughters = value; + object<Object>().showDaughters = value; } /// Get visibility flag bool VisAttr::visible() const { - return _data().visible; + return object<Object>().visible; } /// Set visibility flag void VisAttr::setVisible(bool value) { - _data().visible = value; + object<Object>().visible = value; } /// Get line style int VisAttr::lineStyle() const { - return _data().lineStyle; + return object<Object>().lineStyle; } /// Set line style void VisAttr::setLineStyle(int value) { - _data().lineStyle = value; + object<Object>().lineStyle = value; } /// Get drawing style int VisAttr::drawingStyle() const { - return _data().drawingStyle; + return object<Object>().drawingStyle; } /// Set drawing style void VisAttr::setDrawingStyle(int value) { - _data().drawingStyle = value; + object<Object>().drawingStyle = value; } /// Get alpha value float VisAttr::alpha() const { //TNamed* obj = first_value<TNamed>(*this); //obj->SetAlpha(value); - return _data().alpha; + return object<Object>().alpha; } /// Set alpha value void VisAttr::setAlpha(float value) { - _data().alpha = value; + object<Object>().alpha = value; //TNamed* obj = first_value<TNamed>(*this); //obj->SetAlpha(value); } /// Get object color int VisAttr::color() const { - return _data().color; + return object<Object>().color; } /// Set object color void VisAttr::setColor(float red, float green, float blue) { - Object& o = _data(); + Object& o = object<Object>(); o.color = TColor::GetColor(red,green,blue); o.col = gROOT->GetColor(o.color); } /// Get RGB values of the color (if valid) bool VisAttr::rgb(float& red, float& green, float& blue) const { - Object& o = _data(); + Object& o = object<Object>(); if ( o.col ) { TColor* c = (TColor*)o.col; c->GetRGB(red,green,blue); @@ -291,7 +291,7 @@ bool VisAttr::rgb(float& red, float& green, float& blue) const { /// String representation of this object string VisAttr::toString() const { - const VisAttr::Object* obj = &_data(); + const VisAttr::Object* obj = &object<Object>(); TColor* col = gROOT->GetColor(obj->color); char text[256]; ::snprintf(text,sizeof(text), @@ -379,7 +379,7 @@ LimitSet::Object::~Object() { /// Constructor to be used when creating a new DOM tree LimitSet::LimitSet(const string& name) { - assign(new Value<TNamed,Object>(),name,"limitset"); + assign(new Object(),name,"limitset"); } /// Add new limit. Returns true if the new limit was added, false if it already existed. @@ -407,7 +407,7 @@ Region::Object::~Object() { /// Constructor to be used when creating a new DOM tree Region::Region(const string& name) { - Value<TNamed,Object>* p = new Value<TNamed,Object>(); + Object* p = new Object(); assign(p, name, "region"); p->magic = magic_word(); p->store_secondaries = false; @@ -418,58 +418,58 @@ Region::Region(const string& name) { } Region& Region::setStoreSecondaries(bool value) { - _data().store_secondaries = value; + object<Object>().store_secondaries = value; return *this; } Region& Region::setThreshold(double value) { - _data().threshold = value; + object<Object>().threshold = value; return *this; } Region& Region::setCut(double value) { - _data().cut = value; + object<Object>().cut = value; return *this; } Region& Region::setLengthUnit(const string& unit) { - _data().lunit = unit; + object<Object>().lunit = unit; return *this; } Region& Region::setEnergyUnit(const string& unit) { - _data().eunit = unit; + object<Object>().eunit = unit; return *this; } /// Access references to user limits vector<string>& Region::limits() const { - return _data().user_limits; + return object<Object>().user_limits; } /// Access cut value double Region::cut() const { - return _data().cut; + return object<Object>().cut; } /// Access production threshold double Region::threshold() const { - return _data().threshold; + return object<Object>().threshold; } /// Access secondaries flag bool Region::storeSecondaries() const { - return _data().store_secondaries; + return object<Object>().store_secondaries; } /// Access the length unit const std::string& Region::lengthUnit() const { - return _data().lunit; + return object<Object>().lunit; } /// Access the energy unit const std::string& Region::energyUnit() const { - return _data().eunit; + return object<Object>().eunit; } #undef setAttr @@ -495,7 +495,7 @@ IDSpec::IDSpec(LCDD& lcdd, const string& name, const IDDescriptor& dsc) { const IDDescriptor::FieldIDs& f = dsc.ids(); const IDDescriptor::FieldMap& m = dsc.fields(); - _data().Attr_length = dsc.maxBit(); + object<Object>().Attr_length = dsc.maxBit(); for(IDDescriptor::FieldIDs::const_iterator i=f.begin(); i!=f.end();++i) { int ident = (*i).first; const string& nam = (*i).second; @@ -510,10 +510,10 @@ void IDSpec::addField(const string& name, const pair<int,int>& field) { void IDSpec::addField(const string& name, const pair<int,int>& field) { Element e(document(),Tag_idfield); - e._data().Attr_signed = field.second<0; - e._data().Attr_label = name; - e._data().Attr_start = field.first; - e._data().Attr_length = abs(field.second); + e.object<Object>().Attr_signed = field.second<0; + e.object<Object>().Attr_label = name; + e.object<Object>().Attr_start = field.first; + e.object<Object>().Attr_length = abs(field.second); m_element.append(e); } #endif diff --git a/DDCore/src/Segementations.cpp b/DDCore/src/Segementations.cpp index 3e797bbd2c983c1df2a6ec35cd8c00f953da7757..bf7171b6d5519020eae46d5a8bebf7416833875d 100644 --- a/DDCore/src/Segementations.cpp +++ b/DDCore/src/Segementations.cpp @@ -37,11 +37,11 @@ Segmentation::Object::~Object() { } Segmentation::Segmentation(const string& type) { - assign(new Value<TNamed,Segmentation::Object>(),"segmentation",type); + assign(new Object(),"segmentation",type); } bool Segmentation::useForHitPosition() const { - return _data().useForHitPosition != 0; + return object<Object>().useForHitPosition != 0; } /// Segmentation type @@ -51,7 +51,7 @@ const string Segmentation::type() const { /// Add an extension object to the detector element void* Segmentation::i_setExtension(void* ptr, const type_info& info, void (*destruct)(void*)) { - Object& o = _data(); + Object& o = object<Object>(); o.type = EXTENDED; o.data.extension.ptr = ptr; o.data.extension.info = &info; @@ -62,7 +62,7 @@ void* Segmentation::i_setExtension(void* ptr, const type_info& info, void (*dest /// Access an existing extension object from the detector element void* Segmentation::i_extension(const type_info& info) const { if ( isValid() ) { - Object::Data::Extension& o = _data().data.extension; + Object::Data::Extension& o = object<Object>().data.extension; if ( o.ptr ) { if ( &info == o.info ) { return o.ptr; @@ -84,7 +84,7 @@ const string SegmentationParams::type() const { /// Access to the parameters SegmentationParams::Parameters SegmentationParams::parameters() const { const string& typ = type(); - const Object& obj = _data(); + const Object& obj = object<Object>(); const Object::Data& data = obj.data; Parameters params; //cout << "Segmentation:" << name() << " Type:" << typ << endl; @@ -130,22 +130,22 @@ ProjectiveCylinder::ProjectiveCylinder() : Segmentation("projective_cylinder") /// Accessors: get number of bins in theta int ProjectiveCylinder::thetaBins() const { - return _data().data.cylindrical_binning.ntheta; + return object<Object>().data.cylindrical_binning.ntheta; } /// Accessors: get number of bins in phi int ProjectiveCylinder::phiBins() const { - return _data().data.cylindrical_binning.nphi; + return object<Object>().data.cylindrical_binning.nphi; } /// Accessors: set number of bins in theta void ProjectiveCylinder::setThetaBins(int value) { - _data().data.cylindrical_binning.ntheta = value; + object<Object>().data.cylindrical_binning.ntheta = value; } /// Accessors: set grid size in Y void ProjectiveCylinder::setPhiBins(int value) { - _data().data.cylindrical_binning.nphi = value; + object<Object>().data.cylindrical_binning.nphi = value; } NonProjectiveCylinder::NonProjectiveCylinder() @@ -154,21 +154,21 @@ NonProjectiveCylinder::NonProjectiveCylinder() } double NonProjectiveCylinder::gridSizeZ() const { - return _data().data.cylindrical_grid.grid_size_z; + return object<Object>().data.cylindrical_grid.grid_size_z; } double NonProjectiveCylinder::gridSizePhi() const { - return _data().data.cylindrical_grid.grid_size_phi; + return object<Object>().data.cylindrical_grid.grid_size_phi; } /// Accessors: set number of bins in theta void NonProjectiveCylinder::setThetaBinSize(double value) { - _data().data.cylindrical_grid.grid_size_phi = value; + object<Object>().data.cylindrical_grid.grid_size_phi = value; } /// Accessors: set grid size in Y void NonProjectiveCylinder::setPhiBinSize(double value) { - _data().data.cylindrical_grid.grid_size_z = value; + object<Object>().data.cylindrical_grid.grid_size_z = value; } @@ -180,22 +180,22 @@ ProjectiveZPlane::ProjectiveZPlane() /// Accessors: get number of bins in phi int ProjectiveZPlane::phiBins() const { - return _data().data.cylindrical_binning.nphi; + return object<Object>().data.cylindrical_binning.nphi; } /// Accessors: get number of bins in theta int ProjectiveZPlane::thetaBins() const { - return _data().data.cylindrical_binning.ntheta; + return object<Object>().data.cylindrical_binning.ntheta; } /// Accessors: set number of bins in theta void ProjectiveZPlane::setThetaBins(int value) { - _data().data.cylindrical_binning.ntheta = value; + object<Object>().data.cylindrical_binning.ntheta = value; } /// Accessors: set grid size in Y void ProjectiveZPlane::setPhiBins(int value) { - _data().data.cylindrical_binning.nphi = value; + object<Object>().data.cylindrical_binning.nphi = value; } GridXY::GridXY() @@ -211,28 +211,28 @@ GridXY::GridXY(const string& tag) GridXY::GridXY(const string& tag, double size_x, double size_y) : Segmentation(tag) { - _data().data.cartesian_grid.grid_size_x = size_x; - _data().data.cartesian_grid.grid_size_y = size_y; + object<Object>().data.cartesian_grid.grid_size_x = size_x; + object<Object>().data.cartesian_grid.grid_size_y = size_y; } /// Accessors: get grid size in X double GridXY::getGridSizeX() const { - return _data().data.cartesian_grid.grid_size_x; + return object<Object>().data.cartesian_grid.grid_size_x; } /// Accessors: get grid size in Y double GridXY::getGridSizeY() const { - return _data().data.cartesian_grid.grid_size_y; + return object<Object>().data.cartesian_grid.grid_size_y; } /// Accessors: set grid size in X void GridXY::setGridSizeX(double value) { - _data().data.cartesian_grid.grid_size_x = value; + object<Object>().data.cartesian_grid.grid_size_x = value; } /// Accessors: set grid size in Y void GridXY::setGridSizeY(double value) { - _data().data.cartesian_grid.grid_size_y = value; + object<Object>().data.cartesian_grid.grid_size_y = value; } /// Constructor to be used when creating a new DOM tree. @@ -245,9 +245,9 @@ GridXYZ::GridXYZ() GridXYZ::GridXYZ(double size_x, double size_y, double size_z) : GridXY("grid_xyz", size_x, size_y) { - _data().data.cartesian_grid.grid_size_z = size_z; + object<Object>().data.cartesian_grid.grid_size_z = size_z; } void GridXYZ::setGridSizeZ(double value) { - _data().data.cartesian_grid.grid_size_z = value; + object<Object>().data.cartesian_grid.grid_size_z = value; } diff --git a/DDCore/src/VolumeManager.cpp b/DDCore/src/VolumeManager.cpp index 6bf4f88567f950c1cd63dda45743c55f4892f332..5806159e01225f6294125515a3de965356463a48 100644 --- a/DDCore/src/VolumeManager.cpp +++ b/DDCore/src/VolumeManager.cpp @@ -235,7 +235,7 @@ VolumeManager::Context* VolumeManager::Object::search(const VolIdentifier& id) /// Initializing constructor to create a new object VolumeManager::VolumeManager(const string& nam, DetElement elt, Readout ro, int flags) { - Value<TNamed,Object>* ptr = new Value<TNamed,Object>(); + Object* ptr = new Object(); assign(ptr,nam,"VolumeManager"); if ( elt.isValid() ) { Populator p(*this); diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp index efcf76da1e4659dac6e28c72ad91eb3894dd2722..683b8d062930646d02f1667c3f59b0a810d10861 100644 --- a/DDCore/src/plugins/Compact2Objects.cpp +++ b/DDCore/src/plugins/Compact2Objects.cpp @@ -128,7 +128,7 @@ static Ref_t create_ConstantField(lcdd_t& /* lcdd */, xml_h e) { CartesianField obj; xml_comp_t field(e), strength(e.child(_U(strength))); string t = e.attr<string>(_U(field)); - Value<TNamed,ConstantField>* ptr = new Value<TNamed,ConstantField>(); + ConstantField* ptr = new ConstantField(); ptr->type = ::toupper(t[0])=='E' ? CartesianField::ELECTRIC : CartesianField::MAGNETIC; ptr->direction.SetX(strength.x()); ptr->direction.SetY(strength.y()); @@ -141,7 +141,7 @@ DECLARE_XMLELEMENT(ConstantField,create_ConstantField); static Ref_t create_SolenoidField(lcdd_t& lcdd, xml_h e) { xml_comp_t c(e); CartesianField obj; - Value<TNamed,SolenoidField>* ptr = new Value<TNamed,SolenoidField>(); + SolenoidField* ptr = new SolenoidField(); if ( c.hasAttr(_U(inner_radius)) ) ptr->innerRadius = c.attr<double>(_U(inner_radius)); else ptr->innerRadius = 0.0; if ( c.hasAttr(_U(outer_radius)) ) ptr->outerRadius = c.attr<double>(_U(outer_radius)); @@ -162,7 +162,7 @@ DECLARE_XMLELEMENT(solenoid,create_SolenoidField); static Ref_t create_DipoleField(lcdd_t& /* lcdd */, xml_h e) { xml_comp_t c(e); CartesianField obj; - Value<TNamed,DipoleField>* ptr = new Value<TNamed,DipoleField>(); + DipoleField* ptr = new DipoleField(); double val, lunit = c.attr<double>(_U(lunit)), funit = c.attr<double>(_U(funit)); if ( c.hasAttr(_U(zmin)) ) ptr->zmin = _multiply<double>(c.attr<string>(_U(zmin)),lunit);