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  * ProjectiveCylinder.cpp
0013  *
0014  *  Created on: Oct 31, 2013
0015  *      Author: Christian Grefe, CERN
0016  */
0017 
0018 #include <DDSegmentation/ProjectiveCylinder.h>
0019 #include <DDSegmentation/SegmentationUtil.h>
0020 
0021 #define _USE_MATH_DEFINES
0022 #include <cmath>
0023 
0024 namespace dd4hep {
0025 namespace DDSegmentation {
0026 
0027 using Util::thetaFromXYZ;
0028 using Util::phiFromXYZ;
0029 
0030 /// default constructor using an encoding string
0031 ProjectiveCylinder::ProjectiveCylinder(const std::string& cellEncoding) :
0032     CylindricalSegmentation(cellEncoding) {
0033     // define type and description
0034     _type = "ProjectiveCylinder";
0035     _description = "Projective segmentation in the global coordinates";
0036 
0037     // register all necessary parameters
0038     registerParameter("theta_bins", "Number of bins theta", _thetaBins, 1);
0039     registerParameter("phi_bins", "Number of bins phi", _phiBins, 1);
0040     registerParameter("offset_theta", "Angular offset in theta", _offsetTheta, 0., SegmentationParameter::AngleUnit, true);
0041     registerParameter("offset_phi", "Angular offset in phi", _offsetPhi, 0., SegmentationParameter::AngleUnit, true);
0042     registerIdentifier("identifier_theta", "Cell ID identifier for theta", _thetaID, "theta");
0043     registerIdentifier("identifier_phi", "Cell ID identifier for phi", _phiID, "phi");
0044 }
0045 
0046 
0047 /// Default constructor used by derived classes passing an existing decoder
0048 ProjectiveCylinder::ProjectiveCylinder(const BitFieldCoder* decode) :   CylindricalSegmentation(decode) {
0049     // define type and description
0050     _type = "ProjectiveCylinder";
0051     _description = "Projective segmentation in the global coordinates";
0052 
0053     // register all necessary parameters
0054     registerParameter("theta_bins", "Number of bins theta", _thetaBins, 1);
0055     registerParameter("phi_bins", "Number of bins phi", _phiBins, 1);
0056     registerParameter("offset_theta", "Angular offset in theta", _offsetTheta, 0., SegmentationParameter::AngleUnit, true);
0057     registerParameter("offset_phi", "Angular offset in phi", _offsetPhi, 0., SegmentationParameter::AngleUnit, true);
0058     registerIdentifier("identifier_theta", "Cell ID identifier for theta", _thetaID, "theta");
0059     registerIdentifier("identifier_phi", "Cell ID identifier for phi", _phiID, "phi");
0060 }
0061 
0062 /// destructor
0063 ProjectiveCylinder::~ProjectiveCylinder() {
0064 
0065 }
0066 
0067 /// determine the local based on the cell ID
0068 Vector3D ProjectiveCylinder::position(const CellID& cID) const {
0069     return Util::positionFromRThetaPhi(1.0, theta(cID), phi(cID));
0070 }
0071 
0072 /// determine the cell ID based on the position
0073 CellID ProjectiveCylinder::cellID(const Vector3D& /* localPosition */, const Vector3D& globalPosition, const VolumeID& vID) const {
0074         CellID cID = vID ;
0075     double lTheta = thetaFromXYZ(globalPosition);
0076     double lPhi = phiFromXYZ(globalPosition);
0077     _decoder->set(cID,_thetaID, positionToBin(lTheta, M_PI / (double) _thetaBins, _offsetTheta));
0078     _decoder->set(cID,_phiID  , positionToBin(lPhi, 2 * M_PI / (double) _phiBins, _offsetPhi));
0079     return cID;
0080 }
0081 
0082 /// determine the polar angle theta based on the cell ID
0083 double ProjectiveCylinder::theta(const CellID& cID) const {
0084         CellID thetaIndex = _decoder->get(cID,_thetaID);
0085     return M_PI * ((double) thetaIndex + 0.5) / (double) _thetaBins;
0086 }
0087 /// determine the azimuthal angle phi based on the cell ID
0088 double ProjectiveCylinder::phi(const CellID& cID) const {
0089         CellID phiIndex = _decoder->get(cID,_phiID);
0090     return 2. * M_PI * ((double) phiIndex + 0.5) / (double) _phiBins;
0091 }
0092 
0093 
0094 } /* namespace DDSegmentation */
0095 } /* namespace dd4hep */
0096