diff --git a/DDCore/include/DD4hep/Shapes.h b/DDCore/include/DD4hep/Shapes.h index 81b2ae69d8f533df8851092de523a5af4487d1df..0d3a9d2afb9b0784286c32244f0699e59b6de034 100644 --- a/DDCore/include/DD4hep/Shapes.h +++ b/DDCore/include/DD4hep/Shapes.h @@ -499,6 +499,10 @@ namespace dd4hep { * No real correspondance to TGeo. In principle it's a boolean Solid based on a tube. * \see http://cmssdt.cern.ch/lxr/source/DetectorDescription/Core/src/TruncTubs.h * + * The Solid::dimension() and Solid::setDimension() calls for the TruncatedTube + * deliver/expect the parameters in the same order as the constructor: + * (zhalf, rmin, rmax, startPhi, deltaPhi, cutAtStart, cutAtDelta, cutInside) + * * \author M.Frank * \version 1.0 * \ingroup DD4HEP_CORE @@ -702,6 +706,10 @@ namespace dd4hep { * No real correspondance to TGeo. In principle it's a boolean Solid based on a tube. * \see http://cmssdt.cern.ch/lxr/source/DetectorDescription/Core/src/PseudoTrap.h * + * The Solid::dimension() and Solid::setDimension() calls for the PseudoTrap + * deliver/expect the parameters in the same order as the constructor: + * (x1, x2, y1, y2, z, radius, minusZ) + * * \author M.Frank * \version 1.0 * \ingroup DD4HEP_CORE @@ -729,8 +737,8 @@ namespace dd4hep { /// Constructor to create a new identified object with attribute initialization PseudoTrap(const std::string& nam, double x1, double x2, - double y1, double y2, double z, - double radius, bool minusZ) + double y1, double y2, + double z, double radius, bool minusZ) { this->make(nam, x1, x2, y1, y2, z, radius, minusZ); } /// Move Assignment operator diff --git a/DDCore/src/DetectorImp.cpp b/DDCore/src/DetectorImp.cpp index d32ca45e9e3c2959503bc7f22370961457721035..6b63f471856c33c1c349e6bed0bc0a031499a808 100644 --- a/DDCore/src/DetectorImp.cpp +++ b/DDCore/src/DetectorImp.cpp @@ -638,22 +638,23 @@ void DetectorImp::init() { Constant vac_const = getRefChild(m_define, "Vacuum", false); Box worldSolid; - m_materialAir = material(air_const.isValid() ? air_const->GetTitle() : "Air"); m_materialVacuum = material(vac_const.isValid() ? vac_const->GetTitle() : "Vacuum"); m_worldVol = m_manager->GetTopVolume(); if ( m_worldVol.isValid() ) { - worldSolid = m_worldVol.solid(); + worldSolid = m_worldVol.solid(); + m_materialAir = m_worldVol.material(); printout(INFO,"Detector", "*********** Use Top Node from manager as " - "world volume [%s]. BBox: %4.0f %4.0f %4.0f", - worldSolid->IsA()->GetName(), + "world volume [%s]. Material: %s BBox: %4.0f %4.0f %4.0f", + worldSolid->IsA()->GetName(), m_materialAir.name(), worldSolid->GetDX(), worldSolid->GetDY(), worldSolid->GetDZ()); } else { /// Construct the top level world element Solid parallelWorldSolid = Box("world_x", "world_y", "world_z"); - worldSolid = Box("world_x", "world_y", "world_z"); - m_worldVol = Volume("world_volume", worldSolid, m_materialAir); + worldSolid = Box("world_x", "world_y", "world_z"); + m_materialAir = material(air_const.isValid() ? air_const->GetTitle() : "Air"); + m_worldVol = Volume("world_volume", worldSolid, m_materialAir); parallelWorldSolid->SetName("parallel_world_solid"); printout(INFO,"Detector","*********** Created World volume with size: %4.0f %4.0f %4.0f", worldSolid->GetDX(), worldSolid->GetDY(), worldSolid->GetDZ()); diff --git a/DDCore/src/Shapes.cpp b/DDCore/src/Shapes.cpp index ee4b27d9692bc66273fdfedfcdbbef3213ed560d..455c7587dc19dcba9f857cfade8fa9b529e83bfe 100644 --- a/DDCore/src/Shapes.cpp +++ b/DDCore/src/Shapes.cpp @@ -718,10 +718,10 @@ namespace dd4hep { except("PseudoTrap","+++ Incompatible change of parameters."); } ((TGeoTranslation*)right_matrix)->SetTranslation(0,0,displacement); - stringstream params; - params << x1 << " " << x2 << " " << y1 << " " << y2 << " " << z << " " - << r << " " << char(atMinusZ ? '1' : '0') << " "; - right_matrix->SetTitle(params.str().c_str()); + stringstream str; + str << x1 << " " << x2 << " " << y1 << " " << y2 << " " << z << " " + << r << " " << char(atMinusZ ? '1' : '0') << " "; + right_matrix->SetTitle(str.str().c_str()); return; } // In general TGeoCompositeShape instances have an empty SetDimension call diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp index e652c1bdc79cd4faac3a661d0a8f6b4e850f5bd2..3c911aa5c48f1d89a88ea91a0afbfd4a46a82d05 100644 --- a/DDG4/src/Geant4Converter.cpp +++ b/DDG4/src/Geant4Converter.cpp @@ -494,64 +494,62 @@ void* Geant4Converter::handleMaterial(const string& name, Material medium) const G4MaterialPropertiesTable* tab = 0; TListIter propIt(&material->GetProperties()); for(TObject* obj=propIt.Next(); obj; obj = propIt.Next()) { - TNamed* n = (TNamed*)obj; - TGDMLMatrix* matrix = info.manager->GetGDMLMatrix(n->GetTitle()); + TNamed* named = (TNamed*)obj; + TGDMLMatrix* matrix = info.manager->GetGDMLMatrix(named->GetTitle()); Geant4GeometryInfo::PropertyVector* v = (Geant4GeometryInfo::PropertyVector*)handleMaterialProperties(matrix); if ( 0 == v ) { except("Geant4Converter", "++ FAILED to create G4 material %s [Cannot convert property:%s]", - material->GetName(), n->GetName()); + material->GetName(), named->GetName()); } if ( 0 == tab ) { tab = new G4MaterialPropertiesTable(); mat->SetMaterialPropertiesTable(tab); } - int idx = tab->GetPropertyIndex(n->GetName(), false); + int idx = tab->GetPropertyIndex(named->GetName(), false); if ( idx < 0 ) { - printout(ERROR, "Geant4Converter", "++ UNKNOWN Geant4 CONST Property: %-20s [IGNORED]", n->GetName()); + printout(ERROR, "Geant4Converter", "++ UNKNOWN Geant4 CONST Property: %-20s [IGNORED]", named->GetName()); continue; } // We need to convert the property from TGeo units to Geant4 units auto conv = g4PropertyConversion(idx); - double* bins = new double[v->bins.size()]; - double* vals = new double[v->bins.size()]; - for(size_t i=0, count=v->bins.size(); i<count; ++i) { - bins[i] = v->bins[i] * conv.first; - vals[i] = v->values[i] * conv.second; - } - G4MaterialPropertyVector* vec = - new G4MaterialPropertyVector(bins, vals, v->bins.size()); - delete [] bins; - delete [] vals; + vector<double> bins(v->bins), vals(v->values); + for(size_t i=0, count=bins.size(); i<count; ++i) + bins[i] *= conv.first, vals[i] *= conv.second; + + G4MaterialPropertyVector* vec = new G4MaterialPropertyVector(&bins[0], &vals[0], bins.size()); + tab->AddProperty(named->GetName(), vec); printout(lvl, "Geant4Converter", "++ Property: %-20s [%ld x %ld] -> %s ", - n->GetName(), matrix->GetRows(), matrix->GetCols(), n->GetTitle()); - tab->AddProperty(n->GetName(), vec); + named->GetName(), matrix->GetRows(), matrix->GetCols(), named->GetTitle()); + for(size_t i=0, count=v->bins.size(); i<count; ++i) + printout(lvl,named->GetName()," Geant4: %8.3g [MeV] TGeo: %8.3g [GeV] Conversion: %8.3g", + bins[i], v->bins[i], conv.first); } /// Attach the material properties if any TListIter cpropIt(&material->GetConstProperties()); for(TObject* obj=cpropIt.Next(); obj; obj = cpropIt.Next()) { Bool_t err = kFALSE; - TNamed* n = (TNamed*)obj; - double v = info.manager->GetProperty(n->GetTitle(),&err); + TNamed* named = (TNamed*)obj; + double v = info.manager->GetProperty(named->GetTitle(),&err); if ( err != kFALSE ) { except("Geant4Converter", "++ FAILED to create G4 material %s " "[Cannot convert const property: %s]", - material->GetName(), n->GetName()); + material->GetName(), named->GetName()); } if ( 0 == tab ) { tab = new G4MaterialPropertiesTable(); mat->SetMaterialPropertiesTable(tab); } - int idx = tab->GetConstPropertyIndex(n->GetName(), false); + int idx = tab->GetConstPropertyIndex(named->GetName(), false); if ( idx < 0 ) { - printout(ERROR, "Geant4Converter", "++ UNKNOWN Geant4 CONST Property: %-20s [IGNORED]", n->GetName()); + printout(ERROR, "Geant4Converter", "++ UNKNOWN Geant4 CONST Property: %-20s [IGNORED]", named->GetName()); continue; } // We need to convert the property from TGeo units to Geant4 units double conv = g4ConstPropertyConversion(idx); - printout(lvl, "Geant4Converter", "++ CONST Property: %-20s %g ", n->GetName(), v); - tab->AddConstProperty(n->GetName(), v * conv); + printout(lvl, "Geant4Converter", "++ CONST Property: %-20s %g ", named->GetName(), v); + tab->AddConstProperty(named->GetName(), v * conv); } #endif auto* ionization = mat->GetIonisation(); @@ -1326,8 +1324,8 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const { G4MaterialPropertiesTable* tab = 0; TListIter it(&optSurf->GetProperties()); for(TObject* obj = it.Next(); obj; obj = it.Next()) { - TNamed* n = (TNamed*)obj; - TGDMLMatrix *matrix = info.manager->GetGDMLMatrix(n->GetTitle()); + TNamed* named = (TNamed*)obj; + TGDMLMatrix* matrix = info.manager->GetGDMLMatrix(named->GetTitle()); if ( 0 == tab ) { tab = new G4MaterialPropertiesTable(); g4->SetMaterialPropertiesTable(tab); @@ -1336,14 +1334,28 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const { (Geant4GeometryInfo::PropertyVector*)handleMaterialProperties(matrix); if ( !v ) { // Error! except("Geant4OpticalSurface","++ Failed to convert opt.surface %s. Property table %s is not defined!", - optSurf->GetName(), n->GetTitle()); + optSurf->GetName(), named->GetTitle()); + } + int idx = tab->GetPropertyIndex(named->GetName(), false); + if ( idx < 0 ) { + printout(ERROR, "Geant4Converter", "++ UNKNOWN Geant4 Property: %-20s [IGNORED]", named->GetName()); + continue; } - G4MaterialPropertyVector* vec = - new G4MaterialPropertyVector(&v->bins[0], &v->values[0], v->bins.size()); - tab->AddProperty(n->GetName(), vec); + // We need to convert the property from TGeo units to Geant4 units + auto conv = g4PropertyConversion(idx); + vector<double> bins(v->bins), vals(v->values); + for(size_t i=0, count=v->bins.size(); i<count; ++i) + bins[i] *= conv.first, vals[i] *= conv.second; + G4MaterialPropertyVector* vec = new G4MaterialPropertyVector(&bins[0], &vals[0], bins.size()); + tab->AddProperty(named->GetName(), vec); + printout(debugSurfaces ? ALWAYS : DEBUG, "Geant4Converter", "++ Property: %-20s [%ld x %ld] --> %s", - n->GetName(), matrix->GetRows(), matrix->GetCols(), n->GetTitle()); + named->GetName(), matrix->GetRows(), matrix->GetCols(), named->GetTitle()); + for(size_t i=0, count=v->bins.size(); i<count; ++i) + printout(debugSurfaces ? ALWAYS : DEBUG, named->GetName(), + " Geant4: %8.3g [MeV] TGeo: %8.3g [GeV] Conversion: %8.3g", + bins[i], v->bins[i], conv.first); } info.g4OpticalSurfaces[optSurf] = g4; }