diff --git a/DDCore/include/DD4hep/Volumes.h b/DDCore/include/DD4hep/Volumes.h index d110ea6d05c12bb9e88cf5601296c0d68a484c72..15a33898484901ff0fc82171120c34aa6b7a1aa8 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 416565416e2074dcc7dd67f45f8191501e150bc8..7166ad5121d12d83fbbd06dd6f19d645b817d705 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 74cda30a899578419875749923a19bc701ce9956..77a5e02dc1d05b3f438e4c9958c1693dbbc0406a 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 47c21e8c05e606b401491f02f8375751b6cca9c0..b53cd36aa1455eeef0e3faa019f26d35f8ada3cd 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 99dc9b3d60d51e9f93ca08b92bf6578502558bbe..65c6e50072a3549b1b5f857cb49dc37b0433f0d9 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 73cff046d3a0b958f55c4b3d41fe5264b94ea311..6084bc93abd469c250f1727f272d7d09592965a1 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; }