From f26ffa0b19eedeff5d878aa80f9394e9bff30fd1 Mon Sep 17 00:00:00 2001 From: Andre Sailer <andre.philippe.sailer@cern.ch> Date: Wed, 18 Mar 2015 15:33:19 +0000 Subject: [PATCH] PolarGridRPhi2: Allow for vector of Phi Values --- .../include/DDSegmentation/PolarGridRPhi2.h | 26 +++++++++---------- DDSegmentation/src/PolarGridRPhi2.cpp | 8 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/DDSegmentation/include/DDSegmentation/PolarGridRPhi2.h b/DDSegmentation/include/DDSegmentation/PolarGridRPhi2.h index f339dc138..2a3163eb0 100644 --- a/DDSegmentation/include/DDSegmentation/PolarGridRPhi2.h +++ b/DDSegmentation/include/DDSegmentation/PolarGridRPhi2.h @@ -31,8 +31,8 @@ public: return _gridRValues; } /// access the grid size in Phi - double gridSizePhi() const { - return _gridSizePhi; + std::vector<double> gridPhiValues() const { + return _gridPhiValues; } /// access the coordinate offset in R double offsetR() const { @@ -51,12 +51,12 @@ public: return _phiId; } /// set the grid size in R - void setgridRValues(double cellSize, int value) { - _gridRValues[value] = cellSize; + void setgridRValues(double cellSize, int position) { + _gridRValues[position] = cellSize; } /// set the grid size in Phi - void setGridSizePhi(double cellSize) { - _gridSizePhi = cellSize; + void setGridSizePhi(double cellSize, int position) { + _gridPhiValues[position] = cellSize; } /// set the coordinate offset in R void setOffsetR(double offset) { @@ -76,17 +76,17 @@ public: } protected: - /// the grid size in X + /// the grid boundaries in R std::vector<double> _gridRValues; - /// the coordinate offset in X + /// the coordinate offset in R double _offsetR; - /// the grid size in Y - double _gridSizePhi; - /// the coordinate offset in Y + /// the grid sizes in Phi + std::vector<double> _gridPhiValues; + /// the coordinate offset in Phi double _offsetPhi; - /// the field name used for X + /// the field name used for R std::string _rId; - /// the field name used for Y + /// the field name used for Phi std::string _phiId; }; diff --git a/DDSegmentation/src/PolarGridRPhi2.cpp b/DDSegmentation/src/PolarGridRPhi2.cpp index 3b9efcabd..5c978e148 100644 --- a/DDSegmentation/src/PolarGridRPhi2.cpp +++ b/DDSegmentation/src/PolarGridRPhi2.cpp @@ -20,8 +20,8 @@ PolarGridRPhi2::PolarGridRPhi2(const string& cellEncoding) : _description = "Polar RPhi segmentation in the local XY-plane"; // register all necessary parameters - registerParameter("grid_r_values", "Vector or R values", _gridRValues, std::vector<double>(), SegmentationParameter::LengthUnit, true); - registerParameter("grid_size_phi", "Cell size in Phi", _gridSizePhi, 1., SegmentationParameter::AngleUnit); + registerParameter("grid_r_values", "Vector of R values", _gridRValues, std::vector<double>(), SegmentationParameter::LengthUnit, true); + registerParameter("grid_phi_values", "Cell size in Phi", _gridPhiValues, std::vector<double>(), SegmentationParameter::AngleUnit); registerParameter("offset_r", "Cell offset in R", _offsetR, 0., SegmentationParameter::LengthUnit, true); registerParameter("offset_phi", "Cell offset in Phi", _offsetPhi, 0., SegmentationParameter::AngleUnit, true); registerIdentifier("identifier_r", "Cell ID identifier for R", _rId, "r"); @@ -38,7 +38,7 @@ Vector3D PolarGridRPhi2::position(const CellID& cellID) const { _decoder->setValue(cellID); Vector3D position; double R = binToPosition((*_decoder)[_rId].value(), _gridRValues[0], _offsetR); - double phi = binToPosition((*_decoder)[_phiId].value(), _gridSizePhi, _offsetPhi); + double phi = binToPosition((*_decoder)[_phiId].value(), _gridPhiValues[0], _offsetPhi); position.X = R * cos(phi); position.Y = R * sin(phi); @@ -53,7 +53,7 @@ Vector3D PolarGridRPhi2::position(const CellID& cellID) const { double R = sqrt( localPosition.X * localPosition.X + localPosition.Y * localPosition.Y ); (*_decoder)[_rId] = positionToBin(R, _gridRValues[0], _offsetR); - (*_decoder)[_phiId] = positionToBin(phi, _gridSizePhi, _offsetPhi); + (*_decoder)[_phiId] = positionToBin(phi, _gridPhiValues[0], _offsetPhi); return _decoder->getValue(); } -- GitLab