From 3797e583f9ddbc65fafddbbe20d87c2a7f3ecea4 Mon Sep 17 00:00:00 2001 From: Markus Frank <markus.frank@cern.ch> Date: Mon, 6 May 2013 11:14:13 +0000 Subject: [PATCH] Fix segmentation factory names for slic --- DDCore/include/DD4hep/Volumes.h | 3 ++- DDCore/src/Segementations.cpp | 11 +++++++++-- DDCore/src/Volumes.cpp | 10 +++++----- DDCore/src/plugins/Compact2Objects.cpp | 9 +++++++-- DDCore/src/plugins/LCDDConverter.cpp | 15 +++++++++++---- .../src/PolyhedraEndcapCalorimeter2_geo.cpp | 8 +++++--- 6 files changed, 39 insertions(+), 17 deletions(-) diff --git a/DDCore/include/DD4hep/Volumes.h b/DDCore/include/DD4hep/Volumes.h index d110ea6d0..15a338984 100644 --- a/DDCore/include/DD4hep/Volumes.h +++ b/DDCore/include/DD4hep/Volumes.h @@ -48,7 +48,8 @@ namespace DD4hep { * @version 1.0 */ struct PlacedVolume : Handle<TGeoNodeMatrix> { - typedef std::map<std::string,int> VolIDs; + typedef std::pair<std::string,int> VolID; + typedef std::vector<VolID> VolIDs; struct Object { /// Magic word unsigned long magic; diff --git a/DDCore/src/Segementations.cpp b/DDCore/src/Segementations.cpp index 416565416..7166ad512 100644 --- a/DDCore/src/Segementations.cpp +++ b/DDCore/src/Segementations.cpp @@ -82,6 +82,7 @@ SegmentationParams::Parameters SegmentationParams::parameters() const { const Object& obj = _data(); const Object::Data& data = obj.data; Parameters params; + //cout << "Segmentation:" << name() << " Type:" << typ << endl; if ( typ == "projective_cylinder" ) { params.push_back(make_pair("ntheta",data.cylindrical_binning.ntheta)); params.push_back(make_pair("nphi",data.cylindrical_binning.nphi)); @@ -95,12 +96,18 @@ SegmentationParams::Parameters SegmentationParams::parameters() const { params.push_back(make_pair("ntheta",data.cylindrical_binning.ntheta)); params.push_back(make_pair("nphi",data.cylindrical_binning.nphi)); } - else if ( typ == "grid_xy" || typ == "global_grid_xy" ) { + else if ( typ == "grid_xy" || + typ == "cartesian_grid_xy" || + typ == "global_grid_xy" + ) { params.push_back(make_pair("grid_size_x",data.cartesian_grid.grid_size_x)); params.push_back(make_pair("grid_size_y",data.cartesian_grid.grid_size_y)); params.push_back(make_pair("lunit",_toDouble("mm"))); } - else if ( typ == "grid_xyz" || typ == "global_grid_xyz" ) { + else if ( typ == "grid_xyz" || + typ == "cartesian_grid_xyz" || + typ == "global_grid_xyz" + ) { params.push_back(make_pair("grid_size_x",data.cartesian_grid.grid_size_x)); params.push_back(make_pair("grid_size_y",data.cartesian_grid.grid_size_y)); params.push_back(make_pair("grid_size_z",data.cartesian_grid.grid_size_z)); diff --git a/DDCore/src/Volumes.cpp b/DDCore/src/Volumes.cpp index 74cda30a8..77a5e02dc 100644 --- a/DDCore/src/Volumes.cpp +++ b/DDCore/src/Volumes.cpp @@ -213,25 +213,25 @@ namespace DD4hep { namespace Geometry { /// Add identifier PlacedVolume& PlacedVolume::addPhysVolID(const string& name, int value) { Object* obj = data<Object>(); - obj->volIDs[name] = value; + obj->volIDs.push_back(VolID(name,value)); return *this; } /// Volume material Material PlacedVolume::material() const -{ return Material::handle_t(m_element ? m_element->GetMedium() : 0); } +{ return Material::handle_t(m_element ? m_element->GetMedium() : 0); } /// Logical volume of this placement Volume PlacedVolume::volume() const -{ return Volume::handle_t(m_element ? m_element->GetVolume() : 0); } +{ return Volume::handle_t(m_element ? m_element->GetVolume() : 0); } /// Parent volume (envelope) Volume PlacedVolume::motherVol() const -{ return Volume::handle_t(m_element ? m_element->GetMotherVolume() : 0); } +{ return Volume::handle_t(m_element ? m_element->GetMotherVolume() : 0); } /// Access to the volume IDs const PlacedVolume::VolIDs& PlacedVolume::volIDs() const -{ return data<Object>()->volIDs; } +{ return data<Object>()->volIDs; } /// String dump string PlacedVolume::toString() const { diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp index 47c21e8c0..b53cd36aa 100644 --- a/DDCore/src/plugins/Compact2Objects.cpp +++ b/DDCore/src/plugins/Compact2Objects.cpp @@ -90,10 +90,15 @@ static Ref_t create_CartesianGridXY(lcdd_t& /* lcdd */, xml_h e) { if ( e.hasAttr(_U(gridSizeY)) ) obj.setGridSizeY(e.attr<double>(_U(gridSizeY))); return obj; } + DECLARE_XMLELEMENT(CartesianGridXY,create_CartesianGridXY); -namespace DD4hep { namespace Geometry { typedef CartesianGridXY EcalBarrelCartesianGridXY; }} -DECLARE_XMLELEMENT(EcalBarrelCartesianGridXY,create_CartesianGridXY); +namespace DD4hep { namespace Geometry { + typedef GridXYZ CartesianGridXYZ; + typedef GridXYZ EcalBarrelCartesianGridXY; +}} +DECLARE_XMLELEMENT(CartesianGridXYZ,create_GridXYZ); +DECLARE_XMLELEMENT(EcalBarrelCartesianGridXY,create_GridXYZ); static Ref_t create_ProjectiveCylinder(lcdd_t& /* lcdd */, xml_h e) { ProjectiveCylinder obj; diff --git a/DDCore/src/plugins/LCDDConverter.cpp b/DDCore/src/plugins/LCDDConverter.cpp index 99dc9b3d6..65c6e5007 100644 --- a/DDCore/src/plugins/LCDDConverter.cpp +++ b/DDCore/src/plugins/LCDDConverter.cpp @@ -119,9 +119,10 @@ xml_h LCDDConverter::handleMaterial(const string& name, const TGeoMedium* medium cout << "Converting material:" << name << endl; } if ( m->IsMixture() ) { - TGeoMixture* mix=(TGeoMixture*)m; + TGeoMixture *mix = (TGeoMixture*)m; const double *wmix = mix->GetWmixt(); - double sum = 0e0; + const int *nmix = mix->GetNmixt(); + double sum = 0e0; for (int i=0, n=mix->GetNelements(); i < n; i++) { TGeoElement *elt = mix->GetElement(i); handleElement(elt->GetName(),elt); @@ -130,8 +131,14 @@ xml_h LCDDConverter::handleMaterial(const string& name, const TGeoMedium* medium for (int i=0, n=mix->GetNelements(); i < n; i++) { TGeoElement *elt = mix->GetElement(i); string formula = elt->GetTitle()+string("_elm"); - mat.append(obj=xml_elt_t(geo.doc,_U(fraction))); - obj.setAttr(_U(n),wmix[i]/sum); + if ( nmix ) { + mat.append(obj=xml_elt_t(geo.doc,_U(composite))); + obj.setAttr(_U(n),nmix[i]); + } + else { + mat.append(obj=xml_elt_t(geo.doc,_U(fraction))); + obj.setAttr(_U(n),wmix[i]/sum); + } obj.setAttr(_U(ref),elt->GetName()); } } diff --git a/DDExamples/CLICSiD/src/PolyhedraEndcapCalorimeter2_geo.cpp b/DDExamples/CLICSiD/src/PolyhedraEndcapCalorimeter2_geo.cpp index 73cff046d..6084bc93a 100644 --- a/DDExamples/CLICSiD/src/PolyhedraEndcapCalorimeter2_geo.cpp +++ b/DDExamples/CLICSiD/src/PolyhedraEndcapCalorimeter2_geo.cpp @@ -70,9 +70,10 @@ static Ref_t create_detector(LCDD& lcdd, xml_h e, SensitiveDetector sens) { } ++layerType; } - + envelopeVol.setAttributes(lcdd,x_det.regionStr(),x_det.limitsStr(),x_det.visStr()); - DetElement sdet(det_name,x_det.id()); + + DetElement sdet(det_name+"_pos",x_det.id()); Volume motherVol = lcdd.pickMotherVolume(sdet); PlacedVolume physvol = motherVol.placeVolume(envelopeVol, Position(0,0,zmin+totalThickness/2), @@ -82,13 +83,14 @@ static Ref_t create_detector(LCDD& lcdd, xml_h e, SensitiveDetector sens) { sdet.setPlacement(physvol); if ( reflect ) { + DetElement rdet(det_name+"_neg",x_det.id()); physvol = motherVol.placeVolume(envelopeVol, Position(0,0,-(zmin+totalThickness/2)), Rotation(0,M_PI,M_PI/numsides)); physvol.addPhysVolID("system",det_id); physvol.addPhysVolID("barrel",2); - DetElement rdet(det_name+"_reflect",x_det.id()); rdet.setPlacement(physvol); + lcdd.addDetector(rdet); } return sdet; } -- GitLab