Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:47

0001 /*************************************************************************
0002  * Copyright (C) 1995-2017, Rene Brun and Fons Rademakers.               *
0003  * All rights reserved.                                                  *
0004  *                                                                       *
0005  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0006  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0007  *************************************************************************/
0008 
0009 #ifndef ROOT7_RPadPos
0010 #define ROOT7_RPadPos
0011 
0012 #include "ROOT/RPadExtent.hxx"
0013 
0014 #include <array>
0015 #include <string>
0016 
0017 namespace ROOT {
0018 namespace Experimental {
0019 
0020 /** \class ROOT::Experimental::RPadPos
0021 \ingroup GpadROOT7
0022 \brief A position (horizontal and vertical) in a `RPad`.
0023 \author Axel Naumann <axel@cern.ch>
0024 \date 2017-07-07
0025 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
0026 */
0027 
0028 class RPadPos {
0029 
0030    RPadLength fHoriz;   ///<  horizontal part
0031 
0032    RPadLength fVert;    ///<   vertical part
0033 
0034 public:
0035 
0036    RPadPos() = default;
0037 
0038    RPadPos(const RPadLength& horiz, const RPadLength& vert) : RPadPos()
0039    {
0040       fHoriz = horiz;
0041       fVert = vert;
0042    }
0043 
0044    RPadPos(const RPadExtent &rhs) : RPadPos()
0045    {
0046       fHoriz = rhs.Horiz();
0047       fVert = rhs.Vert();
0048    }
0049 
0050    RPadLength &Horiz() { return fHoriz; }
0051    const RPadLength &Horiz() const { return fHoriz; }
0052 
0053    RPadLength &Vert() { return fVert; }
0054    const RPadLength &Vert() const { return fVert; }
0055 
0056 
0057    /// Add two `RPadPos`s.
0058    RPadPos &operator=(const RPadExtent &rhs)
0059    {
0060       fHoriz = rhs.Horiz();
0061       fVert = rhs.Vert();
0062       return *this;
0063    }
0064 
0065 
0066    /// Add two `RPadPos`s.
0067    friend RPadPos operator+(RPadPos lhs, const RPadExtent &rhs)
0068    {
0069       return {lhs.fHoriz + rhs.Horiz(), lhs.fVert + rhs.Vert()};
0070    }
0071 
0072    /// Subtract two `RPadPos`s.
0073    friend RPadPos operator-(RPadPos lhs, const RPadExtent &rhs)
0074    {
0075       return {lhs.fHoriz - rhs.Horiz(), lhs.fVert - rhs.Vert()};
0076    }
0077 
0078    /// Add a `RPadPos`.
0079    RPadPos &operator+=(const RPadExtent &rhs)
0080    {
0081       fHoriz += rhs.Horiz();
0082       fVert += rhs.Vert();
0083       return *this;
0084    };
0085 
0086    /// Subtract a `RPadPos`.
0087    RPadPos &operator-=(const RPadExtent &rhs)
0088    {
0089       fHoriz -= rhs.Horiz();
0090       fVert -= rhs.Vert();
0091       return *this;
0092    };
0093 
0094    /** \class ScaleFactor
0095        \ingroup GpadROOT7
0096        \brief A scale factor (separate factors for horizontal and vertical) for scaling a `RPadLength`.
0097    */
0098    struct ScaleFactor {
0099       double fHoriz; ///< Horizontal scale factor
0100       double fVert;  ///< Vertical scale factor
0101    };
0102 
0103    /// Scale a horizontally and vertically.
0104    /// \param scale - the scale factor,
0105    RPadPos &operator*=(const ScaleFactor &scale)
0106    {
0107       fHoriz *= scale.fHoriz;
0108       fVert *= scale.fVert;
0109       return *this;
0110    };
0111 };
0112 
0113 }
0114 }
0115 
0116 #endif