diff --git a/DDExamples/ILDExDet/include/VersatileDiskRowLayout.h b/DDExamples/ILDExDet/include/VersatileDiskRowLayout.h index 858d718fdcbfeb21e607391fc3574ff1cf77b344..47aedebaa2bc5289e44b155330985b0f2c3b16bc 100644 --- a/DDExamples/ILDExDet/include/VersatileDiskRowLayout.h +++ b/DDExamples/ILDExDet/include/VersatileDiskRowLayout.h @@ -21,10 +21,9 @@ namespace DD4hep { Geometry::DetElement module; Geometry::VersatileDiskRowLayoutSeg pads; + Geometry::VersatileDiskRowLayoutData *padData; Geometry::Tube tube; - void getExtension(); - /// Default empty constructor VersatileDiskRowLayout() : module(), pads(), tube() {} @@ -34,6 +33,7 @@ namespace DD4hep { /// Standard extension constructor. det is the NEW detector element e.g. when reflecting a detector VersatileDiskRowLayout(const VersatileDiskRowLayout& c,const Geometry::DetElement& det); + /// Default destructor virtual ~VersatileDiskRowLayout() {} diff --git a/DDExamples/ILDExDet/include/VersatileDiskRowLayoutSeg.h b/DDExamples/ILDExDet/include/VersatileDiskRowLayoutSeg.h index 435521ab5973c842a206e458e9478887093f058a..443068d8e2e0b77430ad7ed6de5e928df8448e2a 100644 --- a/DDExamples/ILDExDet/include/VersatileDiskRowLayoutSeg.h +++ b/DDExamples/ILDExDet/include/VersatileDiskRowLayoutSeg.h @@ -16,30 +16,32 @@ namespace DD4hep { namespace Geometry { - + struct Row{ + int _rowNumber; + int _nPads ; + double _padPitch; + double _rowHeight; + double _offset; + }; + + struct VersatileDiskRowLayoutData{ + VersatileDiskRowLayoutData(){}; + void addRow(int nPads, double padPitch, double rowHeight, double offset); + int setRMin(int rmin); + std::vector<Row> _rows ; + int _rMin; + int _nPads; + }; + struct VersatileDiskRowLayoutSeg : public Segmentation { - // public: /// Constructor to be used when reading the already parsed object template <typename Q> VersatileDiskRowLayoutSeg(const Handle<Q>& e) : Segmentation(e) {} /// Constructor to create a new segmentation object VersatileDiskRowLayoutSeg(); - void addRow(int nPads, double padPitch, double rowHeight, double offset); - int setRMin(int rmin); - - //protected: - struct Row{ - int _rowNumber; - int _nPads ; - double _padPitch; - double _rowHeight; - double _offset; - }; + }; + - std::vector<Row> _rows ; - int _rMin; - int _nPads; - }; }//Geometry }//DD4hep diff --git a/DDExamples/ILDExDet/src/VersatileDiskRowLayout.cpp b/DDExamples/ILDExDet/src/VersatileDiskRowLayout.cpp index 3261b65be4454a3761203ef32a6eb07750356303..5bf0443e1d204ee8f05686537153be7930f24050 100644 --- a/DDExamples/ILDExDet/src/VersatileDiskRowLayout.cpp +++ b/DDExamples/ILDExDet/src/VersatileDiskRowLayout.cpp @@ -12,6 +12,7 @@ #include "TGeoTube.h" #include <math.h> #include <iostream> +#include <cmath> using namespace std; @@ -23,6 +24,7 @@ namespace DD4hep { VersatileDiskRowLayout::VersatileDiskRowLayout(const Geometry::DetElement& d) : module(d) { pads = module.readout().segmentation(); tube = module.volume().solid(); + padData = pads.extension<VersatileDiskRowLayoutData>(); } /// Standard extension constructor. det is the NEW detector element e.g. when reflecting a detector @@ -31,22 +33,24 @@ namespace DD4hep { { pads = module.readout().segmentation(); tube = module.volume().solid(); + padData = pads.extension<VersatileDiskRowLayoutData>(); } + std::string VersatileDiskRowLayout::getPadType()const { return pads.type(); } int VersatileDiskRowLayout::getNPads()const { - return pads._nPads; + return padData->_nPads; } int VersatileDiskRowLayout::getNRows()const { - return pads._rows.size(); + return padData->_rows.size(); } int VersatileDiskRowLayout::getNPadsInRow(int row)const { - return pads._rows[row]._nPads; + return padData->_rows[row]._nPads; } double VersatileDiskRowLayout::getRowHeight(int row)const { diff --git a/DDExamples/ILDExDet/src/VersatileDiskRowLayoutSeg.cpp b/DDExamples/ILDExDet/src/VersatileDiskRowLayoutSeg.cpp index 52ef27f70956cd9a60801a1b051c21885bf453c9..ea695597be9a960f78c5ffb65dd15e9a10db5557 100644 --- a/DDExamples/ILDExDet/src/VersatileDiskRowLayoutSeg.cpp +++ b/DDExamples/ILDExDet/src/VersatileDiskRowLayoutSeg.cpp @@ -20,7 +20,7 @@ using namespace DD4hep::Geometry; VersatileDiskRowLayoutSeg::VersatileDiskRowLayoutSeg() : Segmentation("VersatileDiskRowLayoutSeg") {} -void VersatileDiskRowLayoutSeg::addRow(int nPads, double padPitch, double rowHeight, double offset) +void VersatileDiskRowLayoutData::addRow(int nPads, double padPitch, double rowHeight, double offset) { Row new_row; new_row._nPads=nPads; @@ -28,11 +28,11 @@ void VersatileDiskRowLayoutSeg::addRow(int nPads, double padPitch, double rowHei new_row._rowHeight=rowHeight; new_row._offset=offset; _rows.push_back(new_row); - std::cout<<"Added row: "<<nPads<<" "<<padPitch<<std::endl; + std::cout<<"Added row: "<<nPads<<" "<<new_row._nPads<<std::endl; _nPads+=nPads; } -int VersatileDiskRowLayoutSeg::setRMin(int rmin) +int VersatileDiskRowLayoutData::setRMin(int rmin) { _rMin=rmin; } @@ -40,11 +40,13 @@ int VersatileDiskRowLayoutSeg::setRMin(int rmin) //factory to fill object from compact xml static Ref_t create_VersatileDiskRowLayoutSeg(lcdd_t& /* lcdd */, const xml_h& e) { VersatileDiskRowLayoutSeg obj; - if ( e.hasAttr(_A(rmin)) ) obj.setRMin(e.attr<int>(_A(rmin))); + VersatileDiskRowLayoutData *dataExt=new VersatileDiskRowLayoutData(); + if ( e.hasAttr(_A(rmin)) ) dataExt->setRMin(e.attr<int>(_A(rmin))); //loop rows to fill VersatileDiskRowLayoutSeg for(xml_coll_t r(e,_X(row)); r; ++r) { - obj.addRow(r.attr<int>(_A(nPads)),r.attr<double>(_A(padPitch)),r.attr<double>(_A(rowHeight)),r.attr<double>(_A(offset))); + dataExt->addRow(r.attr<int>(_A(nPads)),r.attr<double>(_A(padPitch)),r.attr<double>(_A(rowHeight)),r.attr<double>(_A(offset))); } + obj.setExtension<VersatileDiskRowLayoutData>(dataExt); return obj; } DECLARE_XMLELEMENT(VersatileDiskRowLayoutSeg,create_VersatileDiskRowLayoutSeg);