diff --git a/DDCore/include/DD4hep/Detector.h b/DDCore/include/DD4hep/Detector.h index 9bec26187ad048e2d119056bb525b0bf489c7701..44338fcda433d403c9d563cdc041d287d4899902 100644 --- a/DDCore/include/DD4hep/Detector.h +++ b/DDCore/include/DD4hep/Detector.h @@ -57,8 +57,7 @@ namespace DD4hep { Extensions extensions; /// Default constructor - Object() : magic(magic_word()), verbose(0), combineHits(0), ecut(0.0), - hitsCollection(), readout(), region(), limits(), extensions() {} + Object(); /// Internal object destructor: release extension object(s) ~Object(); }; diff --git a/DDCore/include/DD4hep/Objects.h b/DDCore/include/DD4hep/Objects.h index a01742b8c32757a3a047b234353748c4c80f5e71..f3dd434fd586c22e59127d5208098f20b854dc37 100644 --- a/DDCore/include/DD4hep/Objects.h +++ b/DDCore/include/DD4hep/Objects.h @@ -68,13 +68,21 @@ namespace DD4hep { struct Author : public Ref_t { /// Default constructor Author() : Ref_t() {} + /// Constructorto be used for assignment from a handle + Author(const Author& e) : Ref_t(e) {} /// Constructor to be used when reading the already parsed DOM tree template <typename Q> Author(const Handle<Q>& e) : Ref_t(e) {} /// Constructor to be used when creating a new DOM tree Author(LCDD& doc); - //void setAuthorName(const char* nam) { setAttr("name",nam); } - //void setAuthorEmail(const char* addr) { setAttr("email",addr); } + /// Access the auhor's name + std::string authorName() const; + /// Set the author's name + void setAuthorName(const std::string& nam); + /// Access the auhor's email address + std::string authorEmail() const; + /// Set the author's email address + void setAuthorEmail(const std::string& addr); }; /** @class Header Objects.h @@ -89,9 +97,15 @@ namespace DD4hep { std::string status; std::string version; std::string comment; + /// Standard constructor + Object(); + /// Default destructor + ~Object(); }; /// Default constructor Header() : Ref_t() {} + /// Constructorto be used for assignment from a handle + Header(const Header& e) : Ref_t(e) {} /// Constructor to be used when reading the already parsed DOM tree template <typename Q> Header(const Handle<Q>& e) : Ref_t(e) {} /// Constructor to be used when creating a new DOM tree @@ -134,6 +148,8 @@ namespace DD4hep { struct Constant : public Ref_t { /// Default constructor Constant() : Ref_t() {} + /// Constructorto be used for assignment from a handle + Constant(const Constant& e) : Ref_t(e) {} /// Constructor to be used when reading the already parsed DOM tree template <typename Q> Constant(const Handle<Q>& e) : Ref_t(e) {} @@ -185,25 +201,7 @@ namespace DD4hep { /// Default constructor ReflectRot() : Rotation(M_PI,0.,0.) {} }; -#if 0 - /** @class Transformation Objects.h - * - * @author M.Frank - * @version 1.0 - */ - struct Transform : public Handle<TGeoMatrix> { - /// Default constructor - Transform() : Handle<TGeoMatrix>() {} - /// Default constructor - Transform(TGeoMatrix* m) : Handle<TGeoMatrix>(m) {} - /// Constructor to be used when reading the already parsed DOM tree - template <typename Q> - Transform(const Handle<Q>& e) : Handle<TGeoMatrix>(e) {} - /// Constructor to be used when creating a new DOM tree. Automatically sets attributes - Transform(LCDD& doc, const std::string& name); - }; -#endif /** @class Atom Objects.h * * @author M.Frank @@ -212,7 +210,9 @@ namespace DD4hep { struct Atom : public Handle<TGeoElement> { /// Default constructor Atom() : Handle<TGeoElement>() {} - /// Constructor to be used when creating a new DOM tree + /// Constructorto be used for assignment from a handle + Atom(const Handle<TGeoElement>& e) : Handle<TGeoElement>(e) {} + /// Constructor to be used when creating from a object handle template <typename Q> Atom(const Handle<Q>& e) : Handle<TGeoElement>(e) {} /// Constructor to be used when reading the already parsed DOM tree @@ -227,11 +227,11 @@ namespace DD4hep { struct Material : public Handle<TGeoMedium> { /// Default constructor Material() : Handle<TGeoMedium>() {} - /// Constructor to be used when creating a new DOM tree + /// Constructorto be used for assignment from material handle + Material(const Handle<TGeoMedium>& e) : Handle<TGeoMedium>(e) {} + /// Constructorto be used for assignment from object handle template <typename Q> Material(const Handle<Q>& e) : Handle<TGeoMedium>(e) {} - /// Constructor to be used when reading the already parsed DOM tree - Material(const std::string& name); /// String representation of this object std::string toString() const; /// Access the radiation length of the undrelying material @@ -256,7 +256,10 @@ namespace DD4hep { int color; float alpha; unsigned char drawingStyle, lineStyle, showDaughters, visible; - Object() : magic(magic_word()), col(0), color(0), alpha(0), drawingStyle(SOLID), lineStyle(SOLID), showDaughters(true), visible(true) {} + /// Standard constructor + Object(); + /// Default destructor + ~Object(); }; /// Default constructor VisAttr() : Ref_t() {} @@ -365,18 +368,23 @@ namespace DD4hep { * @version 1.0 */ struct LimitSet : public Ref_t { - typedef std::set<Limit> Object; + struct Object : public std::set<Limit> { + /// Standard constructor + Object(); + /// Default destructor + ~Object(); + }; /// Constructor to be used when reading the already parsed DOM tree LimitSet() : Ref_t() {} /// Constructor to be used when reading the already parsed DOM tree template <typename Q> LimitSet(const Handle<Q>& e) : Ref_t(e) {} - /// Constructor to be used when creating a new DOM tree + /// Constructor to be used when creating a new object LimitSet(const std::string& name); /// Add new limit. Returns true if the new limit was added, false if it already existed. bool addLimit(const Limit& limit); /// Accessor to limits container - const Object& limits() const; + const std::set<Limit>& limits() const; }; /** @class Region Objects.h @@ -392,13 +400,17 @@ namespace DD4hep { bool store_secondaries; std::string lunit, eunit; std::vector<std::string> user_limits; + /// Standard constructor + Object(); + /// Default destructor + ~Object(); }; /// Default constructor Region() : Ref_t() {} /// Constructor to be used when reading the already parsed DOM tree template <typename Q> Region(const Handle<Q>& e) : Ref_t(e) {} - /// Constructor to be used when creating a new DOM tree + /// Constructor to be used when creating a new object Region(const std::string& name); /// Additional data accessor @@ -423,53 +435,21 @@ namespace DD4hep { const std::string& energyUnit() const; }; - /** @class IDSpec Objects.h - * - * @author M.Frank - * @version 1.0 - */ - struct IDSpec : public Ref_t { - /// Constructor to be used when reading the already parsed DOM tree - template <typename Q> - IDSpec(const Handle<Q>& e) : Ref_t(e) {} - /// Constructor to be used when creating a new DOM tree - IDSpec(LCDD& doc, const std::string& name, const IDDescriptor& dsc); - void addField(const std::string& name, const std::pair<int,int>& field); - }; - } /* End namespace Geometry */ } /* End namespace DD4hep */ namespace ROOT { namespace Math { typedef DD4hep::Geometry::Position Position; - -#if 0 // Already present according to Lorenzo - /// Addition of 2 positions - inline Position operator + (const Position& l, const Position& r) - { return Position(l.X()+r.X(),l.Y()+r.Y(),l.Z()+r.Z()); } - /// Subtraction of to positions - inline Position operator - (const Position& l, const Position& r) - { return Position(l.X()-r.X(),l.Y()-r.Y(),l.Z()-r.Z()); } - /// Positions scaling from right - inline Position operator / (const Position& l, double r) - { return Position(l.X()/r,l.Y()/r,l.Z()/r); } - /// Positions scaling from left - inline Position operator * (double l, const Position& r) - { return Position(r.X()*l,r.Y()*l,r.Z()*l); } - /// Positions scaling from right - inline Position operator * (const Position& l, double r) - { return Position(l.X()*r,l.Y()*r,l.Z()*r); } -#endif /// Dot product of 3-vectors. inline double operator * (const Position& l, const Position& r) - { return sqrt(l.X()*r.X() + l.Y()*r.Y() + l.Z()*r.Z()); } + { return sqrt(l.X()*r.X() + l.Y()*r.Y() + l.Z()*r.Z()); } /// Calculate the mean length of two vectors inline double mean_length(const Position& p1, const Position& p2) - { return 0.5* (p1.R() + p2.R()) / 2.0; } + { return 0.5* (p1.R() + p2.R()) / 2.0; } /// Calculate the mean direction of two vectors inline Position mean_direction(const Position& p1, const Position& p2) - { return 0.5 * (p1 + p2); } + { return 0.5 * (p1 + p2); } }} diff --git a/DDCore/src/Detector.cpp b/DDCore/src/Detector.cpp index b9bea66526492fa21ab3cf89fd73cb8c9feac1ac..9c1296801f11ab1ecc76aeb3270098ec1ee37fc0 100644 --- a/DDCore/src/Detector.cpp +++ b/DDCore/src/Detector.cpp @@ -7,6 +7,7 @@ // //==================================================================== +#include "DD4hep/InstanceCount.h" #include "DD4hep/IDDescriptor.h" #include "DD4hep/LCDD.h" #include "TGeoVolume.h" @@ -127,10 +128,21 @@ DetElement::Object::Object() alignment(), placement(), parent(), children(), worldTrafo(0), parentTrafo(0), referenceTrafo(0) { + InstanceCount::increment(this); } /// Internal object destructor: release extension object(s) DetElement::Object::~Object() { + for_each(children.begin(),children.end(), DestroyHandles<>()); + deletePtr(worldTrafo); + deletePtr(parentTrafo); + deletePtr(referenceTrafo); + volume.clear(); + readout.clear(); + alignment.clear(); + conditions.clear(); + placement.clear(); + parent.clear(); ExtensionMap& m = detelement_extensions(); for(Extensions::iterator i = extensions.begin(); i!=extensions.end(); ++i) { void* ptr = (*i).second; @@ -143,6 +155,7 @@ DetElement::Object::~Object() { } } extensions.clear(); + InstanceCount::decrement(this); } @@ -320,6 +333,7 @@ string DetElement::placementPath() const { return ""; } +/// Access detector type (structure, tracker, calorimeter, etc.). string DetElement::type() const { return m_element ? m_element->GetTitle() : ""; } @@ -556,9 +570,20 @@ bool DetElement::referenceToLocal(const Position& global, Position& local) cons return true; } +/// Default constructor +SensitiveDetector::Object::Object() + : magic(magic_word()), verbose(0), combineHits(0), ecut(0.0), + hitsCollection(), readout(), region(), limits(), extensions() +{ + InstanceCount::increment(this); +} + /// Internal object destructor: release extension object(s) SensitiveDetector::Object::~Object() { ExtensionMap& m = sensitive_detector_extensions(); + readout.clear(); + region.clear(); + limits.clear(); for(Extensions::iterator i = extensions.begin(); i!=extensions.end(); ++i) { void* ptr = (*i).second; if ( ptr ) { @@ -570,6 +595,7 @@ SensitiveDetector::Object::~Object() { } } extensions.clear(); + InstanceCount::decrement(this); } /// Constructor diff --git a/DDCore/src/LCDDImp.cpp b/DDCore/src/LCDDImp.cpp index ff00e8a716d05e59b9d5098e21e74d85f2623f3b..0790ab6ee50199f56e94f53108893434ca26e874 100644 --- a/DDCore/src/LCDDImp.cpp +++ b/DDCore/src/LCDDImp.cpp @@ -8,6 +8,7 @@ //==================================================================== #include "DD4hep/GeoHandler.h" +#include "DD4hep/InstanceCount.h" #include "LCDDImp.h" // C/C++ include files @@ -58,13 +59,14 @@ LCDDImp::LCDDImp() : m_world(), m_trackers(), m_worldVol(), m_trackingVol(), m_field("global"), m_buildType(BUILD_NONE) { + InstanceCount::increment(this); m_properties = new Properties(); //if ( 0 == gGeoManager ) { - gGeoManager = new TGeoManager(); - gGeoManager->AddNavigator(); - gGeoManager->SetCurrentNavigator(0); - cout << "Navigator:" << (void*)gGeoManager->GetCurrentNavigator() << endl; + m_manager = gGeoManager = new TGeoManager(); + m_manager->AddNavigator(); + m_manager->SetCurrentNavigator(0); + //cout << "Navigator:" << (void*)m_manager->GetCurrentNavigator() << endl; } //if ( 0 == gGeoIdentity ) { @@ -83,12 +85,33 @@ LCDDImp::LCDDImp() /// Standard destructor LCDDImp::~LCDDImp() { - if ( m_properties ) delete m_properties; - m_properties = 0; - if ( m_volManager.isValid() ) { - delete m_volManager.ptr(); - m_volManager = VolumeManager(); - } + DestroyHandles<> del; + destroyHandle(m_world); + destroyHandle(m_field); + destroyHandle(m_header); + destroyHandle(m_volManager); + destroyObject(m_properties); + for_each(m_readouts.begin(), m_readouts.end(), del); + for_each(m_idDict.begin(), m_idDict.end(), del); + for_each(m_limits.begin(), m_limits.end(), del); + for_each(m_regions.begin(), m_regions.end(), del); + //for_each(m_detectors.begin(), m_detectors.end(), del); + for_each(m_alignments.begin(), m_alignments.end(), del); + for_each(m_sensitive.begin(), m_sensitive.end(), del); + for_each(m_display.begin(), m_display.end(), del); + for_each(m_fields.begin(), m_fields.end(), del); + for_each(m_define.begin(), m_define.end(), del); + // for_each(m_materials.begin(), m_materials.end(), del); + //for_each(.begin(), .end(), del); + + m_trackers.clear(); + m_worldVol.clear(); + m_trackingVol.clear(); + m_invisibleVis.clear(); + m_materialVacuum.clear(); + m_materialAir.clear(); + delete m_manager; + InstanceCount::decrement(this); } Volume LCDDImp::pickMotherVolume(const DetElement&) const { // throw if not existing @@ -125,6 +148,15 @@ LCDD& LCDDImp::addField(const Ref_t& x) { return *this; } +/// Retrieve a matrial by it's name from the detector description +Material LCDDImp::material(const string& name) const { + TGeoMedium* mat = m_manager->GetMedium(name.c_str()); + if ( mat ) { + return Material(Ref_t(mat)); + } + throw runtime_error("Cannot find a material the reference name:"+name); +} + Handle<TObject> LCDDImp::getRefChild(const HandleMap& e, const string& name, bool do_throw) const { HandleMap::const_iterator i = e.find(name); if ( i != e.end() ) { @@ -331,7 +363,7 @@ namespace { } void LCDDImp::endDocument() { - TGeoManager* mgr = gGeoManager; + TGeoManager* mgr = m_manager; if ( !mgr->IsClosed() ) { LCDD& lcdd = *this; Material air = material("Air"); @@ -359,13 +391,13 @@ void LCDDImp::endDocument() { /// Since we allow now for anonymous shapes, /// we will rename them to use the name of the volume they are assigned to - //gGeoManager->SetTopVolume(m_worldVol); mgr->CloseGeometry(); m_world.setPlacement(PlacedVolume(mgr->GetTopNode())); - m_volManager = VolumeManager("World", m_world); + m_volManager = VolumeManager("World", m_world, VolumeManager::TREE); ShapePatcher patcher(m_volManager,m_world); patcher.patchShapes(); //patcher.printVolumes(); + cout << m_volManager << endl; } } @@ -387,7 +419,7 @@ void LCDDImp::init() { m_materialVacuum = material("Vacuum"); m_detectors.append(m_world); m_world.add(m_trackers); - gGeoManager->SetTopVolume(m_worldVol); + m_manager->SetTopVolume(m_worldVol); } } @@ -430,7 +462,7 @@ void LCDDImp::fromXML(const string& xmlfile, LCDDBuildType build_type) { } void LCDDImp::dump() const { - TGeoManager* mgr = gGeoManager; + TGeoManager* mgr = m_manager; mgr->SetVisLevel(4); mgr->SetVisOption(1); m_worldVol->Draw("ogl"); diff --git a/DDCore/src/Objects.cpp b/DDCore/src/Objects.cpp index a9425e5f08088f8e0a7c16d503d29b7b67a14c45..15af6bbada85b6dfd5c0867594defc345a0da288 100644 --- a/DDCore/src/Objects.cpp +++ b/DDCore/src/Objects.cpp @@ -9,6 +9,7 @@ #include "DD4hep/LCDD.h" #include "DD4hep/IDDescriptor.h" +#include "DD4hep/InstanceCount.h" #include "TMap.h" #include "TROOT.h" @@ -30,6 +31,36 @@ Author::Author(LCDD& /* lcdd */) { m_element = new TNamed("","author"); } +/// Access the auhor's name +std::string Author::authorName() const { + return m_element->GetName(); +} + +/// Set the author's name +void Author::setAuthorName(const std::string& nam) { + m_element->SetName(nam.c_str()); +} + +/// Access the auhor's email address +std::string Author::authorEmail() const { + return m_element->GetTitle(); +} + +/// Set the author's email address +void Author::setAuthorEmail(const std::string& addr) { + m_element->SetTitle(addr.c_str()); +} + +/// Standard constructor +Header::Object::Object() { + InstanceCount::increment(this); +} + +/// Default destructor +Header::Object::~Object() { + InstanceCount::decrement(this); +} + /// 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>(); @@ -136,13 +167,6 @@ Atom::Atom(const string& name, const string& formula, int Z, int N, double densi m_element = e; } -/// Constructor to be used when creating a new DOM tree -Material::Material(const string& name) { - //TGeoMaterial* mat = gGeoManager->GetMaterial(name.c_str()); - TGeoMedium* mat = gGeoManager->GetMedium(name.c_str()); - m_element = mat; -} - /// Access the radiation length of the undrelying material double Material::radLength() const { Handle<TGeoMedium> val(*this); @@ -163,6 +187,20 @@ string Material::toString() const { return os.str(); } +/// Standard constructor +VisAttr::Object::Object() + : magic(magic_word()), col(0), color(0), alpha(0), + drawingStyle(SOLID), lineStyle(SOLID), + showDaughters(true), visible(true) +{ + InstanceCount::increment(this); +} + +/// Default destructor +VisAttr::Object::~Object() { + InstanceCount::decrement(this); +} + /// Constructor to be used when creating a new DOM tree VisAttr::VisAttr(const string& name) { Value<TNamed,Object>* obj = new Value<TNamed,Object>(); @@ -329,6 +367,16 @@ string Limit::toString() const { return res; } +/// Standard constructor +LimitSet::Object::Object() { + InstanceCount::increment(this); +} + +/// Default destructor +LimitSet::Object::~Object() { + InstanceCount::decrement(this); +} + /// Constructor to be used when creating a new DOM tree LimitSet::LimitSet(const string& name) { assign(new Value<TNamed,Object>(),name,"limitset"); @@ -341,8 +389,20 @@ bool LimitSet::addLimit(const Limit& limit) { } /// Accessor to limits container -const LimitSet::Object& LimitSet::limits() const { - return *(data<Object>()); +const set<Limit>& LimitSet::limits() const { + const Object* o = data<Object>(); + return *o; +} + + +/// Standard constructor +Region::Object::Object() { + InstanceCount::increment(this); +} + +/// Default destructor +Region::Object::~Object() { + InstanceCount::decrement(this); } /// Constructor to be used when creating a new DOM tree @@ -415,6 +475,21 @@ const std::string& Region::energyUnit() const { #undef setAttr #if 0 + +/** @class IDSpec Objects.h + * + * @author M.Frank + * @version 1.0 + */ +struct IDSpec : public Ref_t { + /// Constructor to be used when reading the already parsed DOM tree + template <typename Q> + IDSpec(const Handle<Q>& e) : Ref_t(e) {} + /// Constructor to be used when creating a new DOM tree + IDSpec(LCDD& doc, const std::string& name, const IDDescriptor& dsc); + void addField(const std::string& name, const std::pair<int,int>& field); +}; + IDSpec::IDSpec(LCDD& lcdd, const string& name, const IDDescriptor& dsc) : RefElement(doc,Tag_idspec,name) { diff --git a/DDCore/src/plugins/LCDD2Output.cpp b/DDCore/src/plugins/LCDD2Output.cpp index cdb81ea65b92dea813eec2122966f93425230e96..0e409a5778f6057111b930dff3c883ee43da55d0 100644 --- a/DDCore/src/plugins/LCDD2Output.cpp +++ b/DDCore/src/plugins/LCDD2Output.cpp @@ -59,10 +59,10 @@ namespace DD4hep { } template <> void Printer<LimitSet>::operator()(const LimitSet& val) const { - const LimitSet::Object& o = val.limits(); + const set<Limit>& o = val.limits(); os << "++ LimitSet: " << val.name() << endl; val->TNamed::Print(); - for(LimitSet::Object::const_iterator i=o.begin(); i!=o.end(); ++i) { + for(set<Limit>::const_iterator i=o.begin(); i!=o.end(); ++i) { os << "++ Limit:" << (*i).name << " " << (*i).particles << " [" << (*i).unit << "] " << (*i).content << " " << (*i).value << endl; } @@ -121,26 +121,6 @@ namespace DD4hep { p((*i).second); } - void dumpTopVolume(); - template <> void Printer<const LCDD*>::operator()(const LCDD*const&) const { - //Header(lcdd.header()).fromCompact(doc,compact.child(Tag_info),Strng_t("In memory")); -#if 0 - PrintMap<Constant > (lcdd,os,lcdd.constants(), "List of Constants")(); - PrintMap<Material > (lcdd,os,lcdd.materials(), "List of Materials")(); - PrintMap<VisAttr > (lcdd,os,lcdd.visAttributes(),"List of Visualization attributes")(); - PrintMap<Position > (lcdd,os,lcdd.positions(), "List of Positions")(); - PrintMap<Rotation > (lcdd,os,lcdd.rotations(), "List of Rotations")(); - PrintMap<LimitSet > (lcdd,os,lcdd.readouts(), "List of Readouts")(); - PrintMap<Region > (lcdd,os,lcdd.regions(), "List of Regions")(); - PrintMap<DetElement> (lcdd,os,lcdd.detectors(), "List of DetElements")(); -#endif - //PrintMap<DetElement>(lcdd,os,lcdd.detectors(), "List of DetElements")(); - //PrintMap<VisAttr > (lcdd,os,lcdd.visAttributes(),"List of Visualization attributes")(); - //mpTopVolume(); - } - - void dumpVolume(TGeoVolume* vol, int level); - void dumpNode(TGeoNode* n, int level) { TGeoMatrix* mat = n->GetMatrix(); TGeoVolume* vol = n->GetVolume(); @@ -195,7 +175,25 @@ namespace DD4hep { } } - void dumpTopVolume() { - dumpVolume(gGeoManager->GetTopVolume(),0); + void dumpTopVolume(const LCDD& lcdd) { + dumpVolume(lcdd.manager().GetTopVolume(),0); } + + template <> void Printer<const LCDD*>::operator()(const LCDD*const&) const { + //Header(lcdd.header()).fromCompact(doc,compact.child(Tag_info),Strng_t("In memory")); +#if 0 + PrintMap<Constant > (lcdd,os,lcdd.constants(), "List of Constants")(); + PrintMap<Material > (lcdd,os,lcdd.materials(), "List of Materials")(); + PrintMap<VisAttr > (lcdd,os,lcdd.visAttributes(),"List of Visualization attributes")(); + PrintMap<Position > (lcdd,os,lcdd.positions(), "List of Positions")(); + PrintMap<Rotation > (lcdd,os,lcdd.rotations(), "List of Rotations")(); + PrintMap<LimitSet > (lcdd,os,lcdd.readouts(), "List of Readouts")(); + PrintMap<Region > (lcdd,os,lcdd.regions(), "List of Regions")(); + PrintMap<DetElement> (lcdd,os,lcdd.detectors(), "List of DetElements")(); +#endif + //PrintMap<DetElement>(lcdd,os,lcdd.detectors(), "List of DetElements")(); + //PrintMap<VisAttr > (lcdd,os,lcdd.visAttributes(),"List of Visualization attributes")(); + dumpTopVolume(lcdd); + } + } diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp index 9da9b26b23ce47544a32f2fc8ab8641ccd993367..9c2fcf1c7629a441895365ac33907edde995fd86 100644 --- a/DDCore/src/plugins/StandardPlugins.cpp +++ b/DDCore/src/plugins/StandardPlugins.cpp @@ -12,6 +12,7 @@ // Framework include files #include "DD4hep/Factories.h" #include "DD4hep/LCDD.h" + // ROOT includes #include "TGeoManager.h" #include "TGeoVolume.h" @@ -24,20 +25,18 @@ static void* create_lcdd_instance(const char* /* name */) { } DECLARE_CONSTRUCTOR(LCDD_constructor,create_lcdd_instance); -static long display(LCDD& /* lcdd */,int argc,char** argv) { - TGeoManager* mgr = gGeoManager; +static long display(LCDD& lcdd,int argc,char** argv) { + TGeoManager& mgr = lcdd.manager(); const char* opt = "ogl"; if ( argc > 0 ) { opt = argv[0]; } - if ( mgr ) { - mgr->SetVisLevel(4); - mgr->SetVisOption(1); - TGeoVolume* vol = mgr->GetTopVolume(); - if ( vol ) { - vol->Draw(opt); - return 1; - } + mgr.SetVisLevel(4); + mgr.SetVisOption(1); + TGeoVolume* vol = mgr.GetTopVolume(); + if ( vol ) { + vol->Draw(opt); + return 1; } return 0; }