diff --git a/DDCore/include/DD4hep/Volumes.h b/DDCore/include/DD4hep/Volumes.h index 3637e11dc5cc7a53fa6f04c523fdebb1127fa893..1c3ab2f26ed8025bcfb1b803bc8863bdd0313c34 100644 --- a/DDCore/include/DD4hep/Volumes.h +++ b/DDCore/include/DD4hep/Volumes.h @@ -117,13 +117,14 @@ namespace DD4hep { Object(); /// Default destructor virtual ~Object(); + /// Copy the object void copy(const Object& c) { - magic=c.magic; - region=c.region; - limits=c.limits; - vis=c.vis; - sens_det=c.sens_det; - referenced=c.referenced; + magic = c.magic; + region = c.region; + limits = c.limits; + vis = c.vis; + sens_det = c.sens_det; + referenced = c.referenced; } }; @@ -167,42 +168,46 @@ namespace DD4hep { PlacedVolume placeVolume(const Volume& vol, const IdentityRot& pos) const; /// Attach attributes to the volume - void setAttributes(const LCDD& lcdd, - const std::string& region, - const std::string& limits, - const std::string& vis) const; + const Volume& setAttributes(const LCDD& lcdd, + const std::string& region, + const std::string& limits, + const std::string& vis) const; + /// Set the regional attributes to the volume. Note: If the name string is empty, the action is ignored. + const Volume& setRegion(const LCDD& lcdd, const std::string& name) const; /// Set the regional attributes to the volume - void setRegion(const Region& obj) const; + const Volume& setRegion(const Region& obj) const; /// Access to the handle to the region structure Region region() const; + /// Set the limits to the volume. Note: If the name string is empty, the action is ignored. + const Volume& setLimitSet(const LCDD& lcdd, const std::string& name) const; /// Set the limits to the volume - void setLimitSet(const LimitSet& obj) const; + const Volume& setLimitSet(const LimitSet& obj) const; /// Access to the limit set LimitSet limitSet() const; /// Set Visualization attributes to the volume - void setVisAttributes(const VisAttr& obj) const; - /// Set Visualization attributes to the volume - void setVisAttributes(const LCDD& lcdd, const std::string& name) const; + const Volume& setVisAttributes(const VisAttr& obj) const; + /// Set Visualization attributes to the volume. Note: If the name string is empty, the action is ignored. + const Volume& setVisAttributes(const LCDD& lcdd, const std::string& name) const; /// Access the visualisation attributes VisAttr visAttributes() const; /// Assign the sensitive detector structure - void setSensitiveDetector(const SensitiveDetector& obj) const; + const Volume& setSensitiveDetector(const SensitiveDetector& obj) const; /// Access to the handle to the sensitive detector Ref_t sensitiveDetector() const; /// Accessor if volume is sensitive (ie. is attached to a sensitive detector) bool isSensitive() const; /// Set the volume's solid shape - void setSolid(const Solid& s) const; + const Volume& setSolid(const Solid& s) const; /// Access to Solid (Shape) Solid solid() const; /// Set the volume's material - void setMaterial(const Material& m) const; + const Volume& setMaterial(const Material& m) const; /// Access to the Volume material Material material() const; diff --git a/DDCore/src/VolumeManager.cpp b/DDCore/src/VolumeManager.cpp index 0012ea5c264f0103dec5c17cbd5a1f7e57fa1269..9bb187f1ed7902ff4af75251975cda7ee6ac4a53 100644 --- a/DDCore/src/VolumeManager.cpp +++ b/DDCore/src/VolumeManager.cpp @@ -8,12 +8,14 @@ //==================================================================== // Framework include files #include "DD4hep/VolumeManager.h" +#include "DD4hep/Printout.h" // C/C++ includes #include <sstream> #include <iomanip> using namespace std; +using namespace DD4hep; using namespace DD4hep::Geometry; #define VOLUME_IDENTIFIER(id,mask) id @@ -41,7 +43,8 @@ namespace { scanPhysicalVolume(de, de, pv, ids, node_chain, elt_nodes); continue; } - cout << "++ Detector element " << de.name() << " has no placement." << endl; + printout(WARNING,"VolumeManager","++ Detector element %s of type %s has no placement.", + de.name(),de.type().c_str()); } } /// Find a detector element below with the corresponding placement @@ -75,19 +78,15 @@ namespace { ids.PlacedVolume::VolIDs::Base::insert(ids.end(),pv.volIDs().begin(),pv.volIDs().end()); if ( vol.isSensitive() ) { SensitiveDetector sd = vol.sensitiveDetector(); - Readout ro = sd.readout(); + Readout ro = sd.readout(); //Readout ro = parent.readout(); if ( ro.isValid() ) { add_entry(parent, e, node, ids, node_chain, elt_nodes); } else { - cout << "VolumeManager [" << parent.name() - << "]: Strange constellation volume " << pv.volume().name() - << " is sensitive, but has no readout!" - << " sd:" << sd.ptr() - << " ro:" << ro.ptr() << "," << ro.ptr() - // << " Id:" << ro.idSpec().ptr() - << endl; + printout(WARNING,"VolumeManager", + "%s: Strange constellation volume %s is sensitive, but has no readout! sd:%p ro:%p", + parent.name(), pv.volume().name(), sd.ptr(), ro.ptr()); } } for(Int_t idau=0, ndau=node->GetNdaughters(); idau<ndau; ++idau) { @@ -371,10 +370,12 @@ bool VolumeManager::adoptPlacement(VolumeID sys_id, Context* context) { if ( i == o.volumes.end() ) { o.volumes[vid] = context; o.phys_volumes[pv.ptr()] = context; -#if 0 - cout << "Inserted new volume:" << o.volumes.size() - << " ID:" << (void*)context->identifier << " Mask:" << (void*)context->mask << endl; -#endif + err << "Inserted new volume:" << setw(6) << left << o.volumes.size() + << " Ptr:" << (void*)context->placement.ptr() + << " [" << context->placement.name() << "]" + << " ID:" << (void*)context->identifier + << " Mask:" << (void*)context->mask; + printout(DEBUG,"VolumeManager",err.str().c_str()); return true; } err << "Attempt to register twice volume with identical volID " @@ -391,7 +392,7 @@ bool VolumeManager::adoptPlacement(VolumeID sys_id, Context* context) { for(PlacedVolume::VolIDs::Base::const_iterator vit = ids.begin(); vit != ids.end(); ++vit) err << (*vit).first << "=" << (*vit).second << "; "; } - cout << "++++[!!!] VolumeManager::adoptPlacement: " << err.str() << endl; + printout(DEBUG,"VolumeManager","++++[!!!] adoptPlacement: %s",err.str().c_str()); // throw runtime_error(err.str()); return false; } diff --git a/DDCore/src/Volumes.cpp b/DDCore/src/Volumes.cpp index 056867ccb23a23f8c9a6abe59e95262339d7b32a..b5a7605019222297be59b7d84b33edc3937a6563 100644 --- a/DDCore/src/Volumes.cpp +++ b/DDCore/src/Volumes.cpp @@ -337,19 +337,6 @@ Volume::Volume(const string& name, const Solid& s, const Material& m) { setMaterial(m); } -/// Set the volume's material -void Volume::setMaterial(const Material& m) const { - if ( m.isValid() ) { - TGeoMedium* medium = m._ptr<TGeoMedium>(); - if ( medium ) { - m_element->SetMedium(medium); - return; - } - throw runtime_error("Volume: Medium "+string(m.name())+" is not registered with geometry manager."); - } - throw runtime_error("Volume: Attempt to assign invalid material."); -} - static PlacedVolume _addNode(TGeoVolume* par, TGeoVolume* daughter, TGeoMatrix* transform) { TGeoVolume* parent = par; TObjArray* a = parent->GetNodes(); @@ -437,8 +424,26 @@ PlacedVolume Volume::placeVolume(const Volume& volume, const IdentityRot& /* rot throw runtime_error("Volume: Attempt to assign an invalid physical volume."); } +/// Set the volume's material +const Volume& Volume::setMaterial(const Material& m) const { + if ( m.isValid() ) { + TGeoMedium* medium = m._ptr<TGeoMedium>(); + if ( medium ) { + m_element->SetMedium(medium); + return *this; + } + throw runtime_error("Volume: Medium "+string(m.name())+" is not registered with geometry manager."); + } + throw runtime_error("Volume: Attempt to assign invalid material."); +} + +/// Access to the Volume material +Material Volume::material() const { + return Ref_t(m_element->GetMedium()); +} + /// Set Visualization attributes to the volume -void Volume::setVisAttributes(const VisAttr& attr) const { +const Volume& Volume::setVisAttributes(const VisAttr& attr) const { if ( attr.isValid() ) { VisAttr::Object* vis = attr.data<VisAttr::Object>(); Color_t bright = TColor::GetColorBright(vis->color); @@ -467,10 +472,11 @@ void Volume::setVisAttributes(const VisAttr& attr) const { m_element->SetVisDaughters(vis->showDaughters ? kTRUE : kFALSE); } _data(*this)->vis = attr; + return *this; } /// Set Visualization attributes to the volume -void Volume::setVisAttributes(const LCDD& lcdd, const string& name) const { +const Volume& Volume::setVisAttributes(const LCDD& lcdd, const string& name) const { if ( !name.empty() ) { VisAttr attr = lcdd.visAttributes(name); _data(*this)->vis = attr; @@ -489,10 +495,11 @@ void Volume::setVisAttributes(const LCDD& lcdd, const string& name) const { setVisAttributes(lcdd.visAttributes("InvisibleNoDaughters")); */ } + return *this; } /// Attach attributes to the volume -void Volume::setAttributes(const LCDD& lcdd, +const Volume& Volume::setAttributes(const LCDD& lcdd, const string& region, const string& limits, const string& vis) const @@ -500,61 +507,83 @@ void Volume::setAttributes(const LCDD& lcdd, if ( !region.empty() ) setRegion(lcdd.region(region)); if ( !limits.empty() ) setLimitSet(lcdd.limitSet(limits)); setVisAttributes(lcdd,vis); + return *this; +} + +/// Access the visualisation attributes +VisAttr Volume::visAttributes() const { + Object* o = _data(*this,false); + if ( o ) return o->vis; + return VisAttr(); } /// Set the volume's solid shape -void Volume::setSolid(const Solid& solid) const -{ m_element->SetShape(solid); } +const Volume& Volume::setSolid(const Solid& solid) const { + m_element->SetShape(solid); + return *this; +} + +/// Access to Solid (Shape) +Solid Volume::solid() const { + return Solid((*this)->GetShape()); +} /// Set the regional attributes to the volume -void Volume::setRegion(const Region& obj) const -{ _data(*this)->region = obj; } +const Volume& Volume::setRegion(const LCDD& lcdd, const string& name) const { + if ( !name.empty() ) { + return setRegion(lcdd.region(name)); + } + return *this; +} + +/// Set the regional attributes to the volume +const Volume& Volume::setRegion(const Region& obj) const { + _data(*this)->region = obj; + return *this; +} + +/// Access to the handle to the region structure +Region Volume::region() const { + return _data(*this)->region; +} + +/// Set the limits to the volume +const Volume& Volume::setLimitSet(const LCDD& lcdd, const string& name) const { + if ( !name.empty() ) { + return setLimitSet(lcdd.limitSet(name)); + } + return *this; +} /// Set the limits to the volume -void Volume::setLimitSet(const LimitSet& obj) const -{ _data(*this)->limits = obj; } +const Volume& Volume::setLimitSet(const LimitSet& obj) const { + _data(*this)->limits = obj; + return *this; +} + +/// Access to the limit set +LimitSet Volume::limitSet() const { + return _data(*this)->limits; +} /// Assign the sensitive detector structure -void Volume::setSensitiveDetector(const SensitiveDetector& obj) const { +const Volume& Volume::setSensitiveDetector(const SensitiveDetector& obj) const { //cout << "Setting sensitive detector '" << obj.name() << "' to volume:" << ptr() << " " << name() << endl; _data(*this)->sens_det = obj; + return *this; } /// Access to the handle to the sensitive detector -Ref_t Volume::sensitiveDetector() const -{ +Ref_t Volume::sensitiveDetector() const { const Object* o = _data(*this); return o->sens_det; } /// Accessor if volume is sensitive (ie. is attached to a sensitive detector) -bool Volume::isSensitive() const -{ return _data(*this)->sens_det.isValid(); } - -/// Access to Solid (Shape) -Solid Volume::solid() const -{ return Solid((*this)->GetShape()); } - -/// Access to the Volume material -Material Volume::material() const -{ return Ref_t(m_element->GetMedium()); } - -/// Access the visualisation attributes -VisAttr Volume::visAttributes() const { - Object* o = _data(*this,false); - if ( o ) return o->vis; - return VisAttr(); -} - -/// Access to the handle to the region structure -Region Volume::region() const { - return _data(*this)->region; +bool Volume::isSensitive() const { + return _data(*this)->sens_det.isValid(); } -/// Access to the limit set -LimitSet Volume::limitSet() const -{ return _data(*this)->limits; } - /// Constructor to be used when creating a new geometry tree. Assembly::Assembly(const string& name) { m_element = new Value<TGeoVolumeAssembly,Volume::Object>(name.c_str()); diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp index f994c070e4909a23fed915423680a7042fa7f720..e9eb14b709dad42d2765a418447c2811851102ed 100644 --- a/DDCore/src/plugins/Compact2Objects.cpp +++ b/DDCore/src/plugins/Compact2Objects.cpp @@ -59,7 +59,7 @@ namespace DD4hep { namespace { static UInt_t unique_mat_id = 0xAFFEFEED; void throw_print(const std::string& msg) { - printout(ERROR,"Compact2Objects",msg.c_str()); + printout(ERROR,"Compact",msg.c_str()); throw runtime_error(msg); } @@ -277,7 +277,7 @@ template <> void Converter<Material>::operator()(xml_h e) const { has_density = false; } - printout(DEBUG,"Compact2Objects","++ Creating material %s",matname); + printout(DEBUG,"Compact","++ Creating material %s",matname); mat = mix = new TGeoMixture(matname,composites.size(),dens_val); mat->SetRadLen(radlen_val,intlen_val); for(composites.reset(); composites; ++composites) { @@ -313,7 +313,7 @@ template <> void Converter<Material>::operator()(xml_h e) const { comp_mat = mgr.GetMaterial(nam.c_str()); dens += composites.attr<double>(_U(n)) * comp_mat->GetDensity(); } - printout(WARNING,"Compact2Objects","++ Material: %s with NO density. " + printout(WARNING,"Compact","++ Material: %s with NO density. " "Set density to %7.3 g/cm**3",matname,dens); mix->SetDensity(dens); } @@ -563,7 +563,7 @@ template <> void Converter<CartesianField>::operator()(xml_h e) const { lcdd.field().properties() = prp; } } - printout(ALWAYS,"Compact2Objects","++ Converted field: Successfully %s field %s [%s]", + printout(ALWAYS,"Compact","++ Converted field: Successfully %s field %s [%s]", msg.c_str(),name.c_str(),type.c_str()); } @@ -629,15 +629,15 @@ template <> void Converter<SensitiveDetector>::operator()(xml_h element) const else if ( ecut ) { // If no unit is given , we assume the correct Geant4 unit is used! sd.setEnergyCutoff(element.attr<double>(ecut)); } - printout(DEBUG,"Compact2Objects","SensitiveDetector-update: %-18s %-24s Hits:%-24s Cutoff:%f7.3f", + printout(DEBUG,"Compact","SensitiveDetector-update: %-18s %-24s Hits:%-24s Cutoff:%f7.3f", sd.name(),(" ["+sd.type()+"]").c_str(),sd.hitsCollection().c_str(),sd.energyCutoff()); } catch(const exception& e) { - printout(ERROR,"Compact2Objects","++ FAILED to convert sensitive detector: %s: %s", + printout(ERROR,"Compact","++ FAILED to convert sensitive detector: %s: %s", name.c_str(),e.what()); } catch(...) { - printout(ERROR,"Compact2Objects","++ FAILED to convert sensitive detector: %s: %s", + printout(ERROR,"Compact","++ FAILED to convert sensitive detector: %s: %s", name.c_str(),"UNKNONW Exception"); } } @@ -670,7 +670,7 @@ template <> void Converter<DetElement>::operator()(xml_h element) const { if ( attr_ro ) { Readout ro = lcdd.readout(element.attr<string>(attr_ro)); if ( !ro.isValid() ) { - throw runtime_error("No Readout structure present!"); + throw runtime_error("No Readout structure present for detector:"+name); } sd = SensitiveDetector(name,"sensitive"); sd.setHitsCollection(ro.name()); @@ -682,17 +682,16 @@ template <> void Converter<DetElement>::operator()(xml_h element) const { if ( det.isValid() ) { setChildTitles(make_pair(name,det)); } - cout << (det.isValid() ? "Converted" : "FAILED ") - << " subdetector:" << name << " of type " << type; - if ( sd.isValid() ) cout << " [" << sd.type() << "]"; - cout << endl; + printout(det.isValid() ? INFO : ERROR,"Compact","%s sibdetector:%s of type %s %s", + (det.isValid() ? "++ Converted" : "FAILED "),name.c_str(),type.c_str(), + (sd.isValid() ? ("["+sd.type()+"]").c_str() : "")); lcdd.addDetector(det); } catch(const exception& e) { - printout(ERROR,"Compact2Objects","++ FAILED to convert subdetector: %s: %s",name.c_str(),e.what()); + printout(ERROR,"Compact","++ FAILED to convert subdetector: %s: %s",name.c_str(),e.what()); } catch(...) { - printout(ERROR,"Compact2Objects","++ FAILED to convert subdetector: %s: %s",name.c_str(),"UNKNONW Exception"); + printout(ERROR,"Compact","++ FAILED to convert subdetector: %s: %s",name.c_str(),"UNKNONW Exception"); } } diff --git a/DDCore/src/plugins/LCDDConverter.cpp b/DDCore/src/plugins/LCDDConverter.cpp index 436e628b4c6e215d9bdde7b280d661e7b16f403f..da337cca82f125aa7b398d3f9084f6d21c224691 100644 --- a/DDCore/src/plugins/LCDDConverter.cpp +++ b/DDCore/src/plugins/LCDDConverter.cpp @@ -49,17 +49,6 @@ using namespace DD4hep::Geometry; using namespace DD4hep; using namespace std; -namespace { - typedef Position XYZRotation; - XYZRotation getXYZangles(const Double_t* r) { - Double_t cosb = sqrt(r[0]*r[0] + r[1]*r[1]); - if (cosb > 0.00001) { - return XYZRotation(atan2(r[5], r[8]), atan2(-r[2], cosb), atan2(r[1], r[0])); - } - return XYZRotation(atan2(-r[7], r[4]),atan2(-r[2], cosb),0); - } -} - void LCDDConverter::GeometryInfo::check(const string& name, const TNamed* n,map<string,const TNamed*>& m) const { map<string,const TNamed*>::const_iterator i=m.find(name); if ( i != m.end() ) { @@ -448,23 +437,29 @@ xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) c solid.append(first=xml_elt_t(geo.doc,_U(first))); solid.setAttr(_U(name),Unicode(name)); first.setAttr(_U(ref),ls->GetName()); - XYZRotation rot = getXYZangles(lm->Inverse().GetRotationMatrix()); const double *tr = lm->GetTranslation(); - + double phi=0., theta=0., psi=0.; + TGeoRotation rot; + if ((tr[0] != 0.0) || (tr[1] != 0.0) || (tr[2] != 0.0)) { first.append(obj=xml_elt_t(geo.doc,_U(firstposition))); obj.setAttr(_U(x),tr[0]*CM_2_MM); obj.setAttr(_U(y),tr[1]*CM_2_MM); obj.setAttr(_U(z),tr[2]*CM_2_MM); } - if ((rot.X() != 0.0) || (rot.Y() != 0.0) || (rot.Z() != 0.0)) { - first.append(obj=xml_elt_t(geo.doc,_U(firstrotation))); - obj.setAttr(_U(x),rot.X()*DEGREE_2_RAD); - obj.setAttr(_U(y),rot.Y()*DEGREE_2_RAD); - obj.setAttr(_U(z),rot.Z()*DEGREE_2_RAD); + if ( lm->Inverse().IsRotation() ) { + rot.SetMatrix(lm->Inverse().GetRotationMatrix()); + rot.GetAngles(phi,theta,psi); + if ( !(theta == 0.0 && phi == 0.0 && psi == 0.0) ) { + first.append(obj=xml_elt_t(geo.doc,_U(firstrotation))); + obj.setAttr(_U(x),theta*DEGREE_2_RAD); + obj.setAttr(_U(y),psi*DEGREE_2_RAD); + obj.setAttr(_U(z),phi*DEGREE_2_RAD); + } } TGeoMatrix& rinv = rm->Inverse(); - rot = getXYZangles(rinv.GetRotationMatrix()); + rot.SetMatrix(rinv.GetRotationMatrix()); + rot.GetAngles(phi,theta,psi); tr = rm->GetTranslation(); solid.append(second=xml_elt_t(geo.doc,_U(second))); second.setAttr(_U(ref),rs->GetName()); @@ -475,7 +470,7 @@ xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) c xml_ref_t pos = handlePosition(rnam+"pos",rm); solid.setRef(_U(positionref),pos.name()); } - if ((rot.X() != 0.0) || (rot.Y() != 0.0) || (rot.Z() != 0.0)) { + if ( !(theta == 0.0 && phi == 0.0 && psi == 0.0) ) { xml_ref_t rot = handleRotation(rnam+"rot",&rinv); solid.setRef(_U(rotationref),rot.name()); } @@ -525,15 +520,18 @@ xml_h LCDDConverter::handleRotation(const std::string& name, const TGeoMatrix* t GeometryInfo& geo = data(); xml_h rot = geo.xmlRotations[trafo]; if ( !rot ) { - XYZRotation r = getXYZangles(trafo->GetRotationMatrix()); - if ( r.X() != 0.0 || r.Y() != 0.0 || r.Z() != 0.0 ) { + double phi=0., theta=0., psi=0.; + TGeoRotation r; + r.SetMatrix(trafo->GetRotationMatrix()); + r.GetAngles(phi,theta,psi); + if ( !(theta == 0.0 && phi == 0.0 && psi == 0.0) ) { geo.checkRotation(name,trafo); geo.doc_define.append(rot=xml_elt_t(geo.doc,_U(rotation))); rot.setAttr(_U(name),name); - rot.setAttr(_U(x),r.X()); - rot.setAttr(_U(y),r.Y()); - rot.setAttr(_U(z),r.Z()); - rot.setAttr(_U(unit),"rad"); + rot.setAttr(_U(x),theta); + rot.setAttr(_U(y),psi); + rot.setAttr(_U(z),phi); + rot.setAttr(_U(unit),"deg"); } else if ( geo.identity_rot ) { rot = geo.identity_rot; diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp index d1f3f9c60e82fd236edc0ce966a1bbf704a9a3e9..16cfb5929f4c9ffacc089f2086fe6efbaa37e8b6 100644 --- a/DDCore/src/plugins/StandardPlugins.cpp +++ b/DDCore/src/plugins/StandardPlugins.cpp @@ -53,6 +53,14 @@ static long load_compact(LCDD& lcdd,int argc,char** argv) { } DECLARE_APPLY(DD4hepCompactLoader,load_compact); +static long load_xml(LCDD& lcdd,int argc,char** argv) { + string input = argv[0]; + cout << "Processing compact input file : " << input << endl; + lcdd.fromXML(input); + return 1; +} +DECLARE_APPLY(DD4hepXMLLoader,load_xml); + static long load_volmgr(LCDD& lcdd,int,char**) { try { LCDDImp* imp = dynamic_cast<LCDDImp*>(&lcdd); diff --git a/DDG4/include/DDG4/Defs.h b/DDG4/include/DDG4/Defs.h index 436b35c062ec3275408043a4de284f4c103c46d0..72866d8be40903767178408a97b76f313c5f5a32 100644 --- a/DDG4/include/DDG4/Defs.h +++ b/DDG4/include/DDG4/Defs.h @@ -29,7 +29,6 @@ namespace DD4hep { typedef Geometry::LCDD LCDD; typedef Geometry::Readout Readout; typedef Geometry::DetElement DetElement; - //typedef Geometry::SensitiveDetector SensitiveDetector; template<class HIT> struct HitCompare; template<class HIT> struct HitPositionCompare; @@ -37,12 +36,9 @@ namespace DD4hep { class Geant4Hit; class Geant4TrackerHit; class Geant4CalorimeterHit; - class Geant4SensitiveDetector; template <class T> class Geant4GenericSD; - - } // End namespace Simulation } // End namespace DD4hep #endif // DDG4_DEFS_H diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp index 977803286da5532ed0ad3d5639c7a35e21944348..c0b285c1648f416a7a8819dfedd5e5845ff827e6 100644 --- a/DDG4/src/Geant4Converter.cpp +++ b/DDG4/src/Geant4Converter.cpp @@ -146,7 +146,7 @@ void* Geant4Converter::handleElement(const string& name, const TGeoElement* elem } stringstream str; str << (*g4e); - printout(DEBUG,"Geant4Converter","++ Created G4 Element:%s",str.str().c_str()); + printout(DEBUG,"Geant4Converter","++ Created G4 %s",str.str().c_str()); } data().g4Elements[element] = g4e; } @@ -204,7 +204,7 @@ void* Geant4Converter::handleMaterial(const string& name, const TGeoMedium* medi } stringstream str; str << (*mat); - printout(DEBUG,"Geant4Converter","++ Created G4 Material:%s",str.str().c_str()); + printout(DEBUG,"Geant4Converter","++ Created G4 %s",str.str().c_str()); } data().g4Materials[medium] = mat; } @@ -755,12 +755,12 @@ string printSolid(G4VSolid* sol) { /// Print G4 placement void* Geant4Converter::printPlacement(const string& name, const TGeoNode* node) const { - G4GeometryInfo& info = data(); - G4PVPlacement* g4 = info.g4Placements[node]; - G4LogicalVolume* vol = info.g4Volumes[node->GetVolume()]; - G4LogicalVolume* mot = info.g4Volumes[node->GetMotherVolume()]; - G4VSolid* sol = vol->GetSolid(); - G4ThreeVector tr = g4->GetObjectTranslation(); + G4GeometryInfo& info = data(); + G4PVPlacement* g4 = info.g4Placements[node]; + G4LogicalVolume* vol = info.g4Volumes[node->GetVolume()]; + G4LogicalVolume* mot = info.g4Volumes[node->GetMotherVolume()]; + G4VSolid* sol = vol->GetSolid(); + G4ThreeVector tr = g4->GetObjectTranslation(); G4VSensitiveDetector* sd = vol->GetSensitiveDetector(); if ( !sd ) return g4; @@ -814,6 +814,11 @@ Geant4Converter& Geant4Converter::create(DetElement top) { // We do not have to handle defines etc. // All positions and the like are not really named. // Hence, start creating the G4 objects for materials, solids and log volumes. + Material mat = m_lcdd.material("Argon"); + handleMaterial(mat.name(),mat.ptr()); + mat = m_lcdd.material("Silicon"); + handleMaterial(mat.name(),mat.ptr()); + handle(this, geo.volumes, &Geant4Converter::collectVolume); handle(this, geo.solids, &Geant4Converter::handleSolid); printout(INFO,"Geant4Converter","++ Handled %ld solids.",geo.solids.size()); diff --git a/doc/display.mac b/doc/display.mac new file mode 100644 index 0000000000000000000000000000000000000000..f11b752692517599243552d7263e362162b030f1 --- /dev/null +++ b/doc/display.mac @@ -0,0 +1,6 @@ +/vis/scene/create +/vis/scene/add/hits +/vis/scene/add/trajectories +/vis/open OGLSX +/vis/viewer/panTo 0 0 +/vis/viewer/zoom 5.0