Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:26

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 /*
0013  * PolarGridRPhi2.h
0014  *
0015  *  Created on: Sept 13, 2014
0016  *      Author: Marko Petric
0017  */
0018 
0019 #ifndef DDSEGMENTATION_POLARGRIDRPHI2_H
0020 #define DDSEGMENTATION_POLARGRIDRPHI2_H
0021 
0022 #include <DDSegmentation/PolarGrid.h>
0023 #include <cmath>
0024 #include <vector>
0025 
0026 namespace dd4hep {
0027   namespace DDSegmentation {
0028 
0029 
0030     /// A segmentation for arbitrary sizes in R and R-dependent sizes in Phi
0031     /**
0032      *  Note: Counting of phi-ids starts at the offset. There are no negative phi-IDs<br>
0033      * The grid_r_values give the boundaries of the bin, the grid_phi_values give the size of the bin for each radial bin
0034      * see also PolarGridRPhi2::setGridRValues and PolarGridRPhi2::setGridPhiValues<br>
0035      * Example:<br>
0036      @verbatim
0037      <segmentation type="PolarGridRPhi2"
0038      grid_r_values="3.2*cm 3.7*cm 4.9*cm 5.5*cm<br/>
0039      6.*cm 7.*cm 7.5*cm 8.7*cm<br/>
0040      9.5*cm 10.*cm 11.*cm 11.8*cm<br/>
0041      12.*cm 13.*cm 14.*cm 15.0*cm"
0042      grid_phi_values="360/(4*8)*degree 360/(5*8)*degree
0043      360/(6*8)*degree 360/(6*8)*degree
0044      360/(7*8)*degree 360/(8*8)*degree
0045      360/(9*8)*degree 360/(9*8)*degree
0046      360/(10*8)*degree 360/(11*8)*degree
0047      360/(12*8)*degree 360/(12*8)*degree
0048      360/(13*8)*degree 360/(14*8)*degree
0049      360/(15*8)*degree"
0050      offset_phi="-180.0*degree"
0051      />
0052      <id>system:8,barrel:3,layer:8,slice:5,r:32:16,phi:16</id>
0053      @endverbatim
0054      *    @version $Id$
0055      *    @date  2015-03
0056      */
0057     class PolarGridRPhi2: public PolarGrid {
0058     public:
0059       /// Default constructor passing the encoding string
0060       PolarGridRPhi2(const std::string& cellEncoding = "");
0061       /// Default constructor used by derived classes passing an existing decoder
0062       PolarGridRPhi2(const BitFieldCoder* decoder);
0063       /// destructor
0064       virtual ~PolarGridRPhi2();
0065 
0066       /// determine the position based on the cell ID
0067       virtual Vector3D position(const CellID& cellID) const;
0068       /// determine the cell ID based on the position
0069       virtual CellID cellID(const Vector3D& localPosition, const Vector3D& globalPosition, const VolumeID& volumeID) const;
0070       /// access the grid size in R
0071       std::vector<double> gridRValues() const {
0072         return _gridRValues;
0073       }
0074       /// access the grid size in Phi
0075       std::vector<double>  gridPhiValues() const {
0076         return _gridPhiValues;
0077       }
0078       /// access the coordinate offset in R
0079       double offsetR() const {
0080         return _offsetR;
0081       }
0082       /// access the coordinate offset in Phi
0083       double offsetPhi() const {
0084         return _offsetPhi;
0085       }
0086       /// access the field name used for R
0087       const std::string& fieldNameR() const {
0088         return _rId;
0089       }
0090       /// access the field name used for Phi
0091       const std::string& fieldNamePhi() const {
0092         return _phiId;
0093       }
0094       /// set the grid Boundaries in R
0095       void setGridRValues(double cellSize, int rID) {
0096         _gridRValues[rID] = cellSize;
0097       }
0098       /// set the grid size in Phi
0099       void setGridSizePhi(double cellSize, int phiID) {
0100         _gridPhiValues[phiID] = cellSize;
0101       }
0102 
0103       /// set the grid boundaries for R
0104       /// @param rValues The boundaries of the segments in radius, the first value is the lower boundary of the first bin, the highest value is the upper boundary of the last bin
0105       void setGridRValues(std::vector<double> const& rValues) {
0106         _gridRValues = std::vector<double>(rValues);
0107       }
0108 
0109       /// set the grid size in Phi for each bin in R
0110       /// @param phiValues The size in phi for each bin in R, this vector is one smaller than the vector for PolarGridRPhi2::setGridRValues
0111       void setGridPhiValues(std::vector<double> const& phiValues) {
0112         _gridPhiValues = std::vector<double>(phiValues);
0113       }
0114 
0115 
0116       /// set the coordinate offset in R
0117       void setOffsetR(double offset) {
0118         _offsetR = offset;
0119       }
0120       /// set the coordinate offset in Phi
0121       void setOffsetPhi(double offset) {
0122         _offsetPhi = offset;
0123       }
0124       /// set the field name used for X
0125       void setFieldNameR(const std::string& fieldName) {
0126         _rId = fieldName;
0127       }
0128       /// set the field name used for Y
0129       void setFieldNamePhi(const std::string& fieldName) {
0130         _phiId = fieldName;
0131       }
0132       /** \brief Returns a vector<double> of the cellDimensions of the given cell ID
0133           in natural order of dimensions: dr, r*dPhi
0134 
0135           Returns a vector of the cellDimensions of the given cell ID
0136           \param cellID is ignored as all cells have the same dimension
0137           \return std::vector<double> size 2:
0138           -# size in r
0139           -# size of r*dPhi at the radial centre of the pad
0140       */
0141       virtual std::vector<double> cellDimensions(const CellID& cellID) const;
0142 
0143     protected:
0144       /// the grid boundaries in R
0145       std::vector<double> _gridRValues;
0146       /// the coordinate offset in R
0147       double _offsetR;
0148       /// the grid sizes in Phi
0149       std::vector<double> _gridPhiValues;
0150       /// the coordinate offset in Phi
0151       double _offsetPhi;
0152       /// the field name used for R
0153       std::string _rId;
0154       /// the field name used for Phi
0155       std::string _phiId;
0156     };
0157 
0158   } /* namespace DDSegmentation */
0159 } /* namespace dd4hep */
0160 #endif // DDSEGMENTATION_POLARGRIDRPHI2_H