Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 09:36:49

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 //==========================================================================
0011 /*
0012  * PolarGridRPhi.cpp
0013  *
0014  *  Created on: Sept 16, 2014
0015  *      Author: Marko Petric
0016  */
0017 
0018 #include <DDSegmentation/PolarGridRPhi.h>
0019 
0020 namespace dd4hep {
0021 namespace DDSegmentation {
0022 
0023 /// default constructor using an encoding string
0024 PolarGridRPhi::PolarGridRPhi(const std::string& cellEncoding) :
0025         PolarGrid(cellEncoding) {
0026     // define type and description
0027     _type = "PolarGridRPhi";
0028     _description = "Polar RPhi segmentation in the local XY-plane";
0029 
0030     // register all necessary parameters
0031     registerParameter("grid_size_r", "Cell size in R", _gridSizeR, 1., SegmentationParameter::LengthUnit);
0032     registerParameter("grid_size_phi", "Cell size in Phi", _gridSizePhi, 1., SegmentationParameter::AngleUnit);
0033     registerParameter("offset_r", "Cell offset in R", _offsetR, 0., SegmentationParameter::LengthUnit, true);
0034     registerParameter("offset_phi", "Cell offset in Phi", _offsetPhi, 0., SegmentationParameter::AngleUnit, true);
0035     registerIdentifier("identifier_r", "Cell ID identifier for R", _rId, "r");
0036     registerIdentifier("identifier_phi", "Cell ID identifier for Phi", _phiId, "phi");
0037 }
0038 
0039 
0040 /// Default constructor used by derived classes passing an existing decoder
0041 PolarGridRPhi::PolarGridRPhi(const BitFieldCoder* decode) : PolarGrid(decode) {
0042     // define type and description
0043     _type = "PolarGridRPhi";
0044     _description = "Polar RPhi segmentation in the local XY-plane";
0045 
0046     // register all necessary parameters
0047     registerParameter("grid_size_r", "Cell size in R", _gridSizeR, 1., SegmentationParameter::LengthUnit);
0048     registerParameter("grid_size_phi", "Cell size in Phi", _gridSizePhi, 1., SegmentationParameter::AngleUnit);
0049     registerParameter("offset_r", "Cell offset in R", _offsetR, 0., SegmentationParameter::LengthUnit, true);
0050     registerParameter("offset_phi", "Cell offset in Phi", _offsetPhi, 0., SegmentationParameter::AngleUnit, true);
0051     registerIdentifier("identifier_r", "Cell ID identifier for R", _rId, "r");
0052     registerIdentifier("identifier_phi", "Cell ID identifier for Phi", _phiId, "phi");
0053 }
0054 
0055 /// destructor
0056 PolarGridRPhi::~PolarGridRPhi() {
0057 
0058 }
0059 
0060 /// determine the position based on the cell ID
0061 Vector3D PolarGridRPhi::position(const CellID& cID) const {
0062     Vector3D cellPosition;
0063     double R =   binToPosition(_decoder->get(cID,_rId),   _gridSizeR,   _offsetR);
0064     double phi = binToPosition(_decoder->get(cID,_phiId), _gridSizePhi, _offsetPhi);
0065     
0066     cellPosition.X = R * cos(phi);
0067     cellPosition.Y = R * sin(phi);
0068     
0069     return cellPosition;
0070 }
0071 
0072 /// determine the cell ID based on the position
0073   CellID PolarGridRPhi::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const {
0074     double phi = atan2(localPosition.Y,localPosition.X);
0075     double R = sqrt( localPosition.X * localPosition.X + localPosition.Y * localPosition.Y );
0076     CellID cID = vID ;
0077     _decoder->set(cID,_rId  , positionToBin(R, _gridSizeR, _offsetR));
0078     _decoder->set(cID,_phiId, positionToBin(phi, _gridSizePhi, _offsetPhi));
0079     return cID;
0080 }
0081 
0082 std::vector<double> PolarGridRPhi::cellDimensions(const CellID& cID) const {
0083   const double rPhiSize = binToPosition(_decoder->get(cID,_rId), _gridSizeR, _offsetR)*_gridSizePhi;
0084 #if __cplusplus >= 201103L
0085   return {_gridSizeR, rPhiSize};
0086 #else
0087   std::vector<double> cellDims(2,0.0);
0088   cellDims[0] = _gridSizeR;
0089   cellDims[1] = rPhiSize;
0090   return cellDims;
0091 #endif
0092 }
0093 
0094 
0095 } /* namespace DDSegmentation */
0096 } /* namespace dd4hep */
0097