Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // @(#)root/eve7:$Id$
0002 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007, 2018
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT7_REveTrans
0013 #define ROOT7_REveTrans
0014 
0015 #include <ROOT/REveVector.hxx>
0016 #include "TVector3.h"
0017 
0018 class TGeoMatrix;
0019 class TGeoHMatrix;
0020 class TBuffer3D;
0021 
0022 namespace ROOT {
0023 namespace Experimental {
0024 
0025 /******************************************************************************/
0026 // REveTrans -- 3D transformation in generalised coordinates
0027 /******************************************************************************/
0028 
0029 class REveTrans : public TObject
0030 {
0031 protected:
0032    Double32_t fM[16];
0033 
0034    mutable Float_t fA1;  //!
0035    mutable Float_t fA2;  //!
0036    mutable Float_t fA3;  //!
0037    mutable Bool_t fAsOK; //!
0038 
0039    // REveUtil
0040    Bool_t fUseTrans;     // use transformation matrix
0041    Bool_t fEditTrans;    // edit transformation in TGedFrame
0042    Bool_t fEditRotation; // edit rotation
0043    Bool_t fEditScale;    // edit scale
0044 
0045    Double_t Norm3Column(Int_t col);
0046    Double_t Orto3Column(Int_t col, Int_t ref);
0047 
0048 public:
0049    REveTrans();
0050    REveTrans(const REveTrans &t);
0051    REveTrans(const Double_t arr[16]);
0052    REveTrans(const Float_t arr[16]);
0053    ~REveTrans() override {}
0054 
0055    // General operations
0056 
0057    void UnitTrans();
0058    void ZeroTrans(Double_t w = 1.0);
0059    void UnitRot();
0060    void SetTrans(const REveTrans &t, Bool_t copyAngles = kTRUE);
0061    void SetFromArray(const Double_t arr[16]);
0062    void SetFromArray(const Float_t arr[16]);
0063    REveTrans &operator=(const REveTrans &t)
0064    {
0065       SetTrans(t);
0066       return *this;
0067    }
0068    void SetupRotation(Int_t i, Int_t j, Double_t f);
0069    void SetupFromToVec(const REveVector &from, const REveVector &to);
0070 
0071    void OrtoNorm3();
0072    Double_t Invert();
0073 
0074    void MultLeft(const REveTrans &t);
0075    void MultRight(const REveTrans &t);
0076    void operator*=(const REveTrans &t) { MultRight(t); }
0077 
0078    void TransposeRotationPart();
0079 
0080    REveTrans operator*(const REveTrans &t);
0081 
0082    // Move & Rotate
0083 
0084    void MoveLF(Int_t ai, Double_t amount);
0085    void Move3LF(Double_t x, Double_t y, Double_t z);
0086    void RotateLF(Int_t i1, Int_t i2, Double_t amount);
0087 
0088    void MovePF(Int_t ai, Double_t amount);
0089    void Move3PF(Double_t x, Double_t y, Double_t z);
0090    void RotatePF(Int_t i1, Int_t i2, Double_t amount);
0091 
0092    void Move(const REveTrans &a, Int_t ai, Double_t amount);
0093    void Move3(const REveTrans &a, Double_t x, Double_t y, Double_t z);
0094    void Rotate(const REveTrans &a, Int_t i1, Int_t i2, Double_t amount);
0095 
0096    // Element access
0097 
0098    Double_t *Array() { return fM; }
0099    const Double_t *Array() const { return fM; }
0100    Double_t *ArrX() { return fM; }
0101    const Double_t *ArrX() const { return fM; }
0102    Double_t *ArrY() { return fM + 4; }
0103    const Double_t *ArrY() const { return fM + 4; }
0104    Double_t *ArrZ() { return fM + 8; }
0105    const Double_t *ArrZ() const { return fM + 8; }
0106    Double_t *ArrT() { return fM + 12; }
0107    const Double_t *ArrT() const { return fM + 12; }
0108 
0109    Double_t operator[](Int_t i) const { return fM[i]; }
0110    Double_t &operator[](Int_t i) { return fM[i]; }
0111 
0112    Double_t CM(Int_t i, Int_t j) const { return fM[4 * j + i]; }
0113    Double_t &CM(Int_t i, Int_t j) { return fM[4 * j + i]; }
0114 
0115    Double_t operator()(Int_t i, Int_t j) const { return fM[4 * j + i - 5]; }
0116    Double_t &operator()(Int_t i, Int_t j) { return fM[4 * j + i - 5]; }
0117 
0118    // Base-vector interface
0119 
0120    void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z);
0121    void SetBaseVec(Int_t b, const TVector3 &v);
0122 
0123    TVector3 GetBaseVec(Int_t b) const;
0124    void GetBaseVec(Int_t b, TVector3 &v) const;
0125 
0126    // Position interface
0127 
0128    void SetPos(Double_t x, Double_t y, Double_t z);
0129    void SetPos(Double_t *x);
0130    void SetPos(Float_t *x);
0131    void SetPos(const REveTrans &t);
0132 
0133    void GetPos(Double_t &x, Double_t &y, Double_t &z) const;
0134    void GetPos(Double_t *x) const;
0135    void GetPos(Float_t *x) const;
0136    void GetPos(TVector3 &v) const;
0137    TVector3 GetPos() const;
0138 
0139    // Cardan angle interface
0140 
0141    void SetRotByAngles(Float_t a1, Float_t a2, Float_t a3);
0142    void SetRotByAnyAngles(Float_t a1, Float_t a2, Float_t a3, const char *pat);
0143    void GetRotAngles(Float_t *x) const;
0144 
0145    // Scaling
0146 
0147    void Scale(Double_t sx, Double_t sy, Double_t sz);
0148    Double_t Unscale();
0149    void Unscale(Double_t &sx, Double_t &sy, Double_t &sz);
0150    void GetScale(Double_t &sx, Double_t &sy, Double_t &sz) const;
0151    void SetScale(Double_t sx, Double_t sy, Double_t sz);
0152    void SetScaleX(Double_t sx);
0153    void SetScaleY(Double_t sy);
0154    void SetScaleZ(Double_t sz);
0155 
0156    // Operations on vectors
0157 
0158    void MultiplyIP(TVector3 &v, Double_t w = 1) const;
0159    void MultiplyIP(Double_t *v, Double_t w = 1) const;
0160    void MultiplyIP(Float_t *v, Double_t w = 1) const;
0161    TVector3 Multiply(const TVector3 &v, Double_t w = 1) const;
0162    void Multiply(const Double_t *vin, Double_t *vout, Double_t w = 1) const;
0163    void RotateIP(TVector3 &v) const;
0164    void RotateIP(Double_t *v) const;
0165    void RotateIP(Float_t *v) const;
0166    TVector3 Rotate(const TVector3 &v) const;
0167 
0168    void Print(Option_t *option = "") const override;
0169 
0170    // REveUtil stuff
0171 
0172    void SetFrom(Double_t *carr);
0173    void SetFrom(const TGeoMatrix &mat);
0174    void SetGeoHMatrix(TGeoHMatrix &mat);
0175    void SetBuffer3D(TBuffer3D &buff);
0176 
0177    Bool_t GetUseTrans() const { return fUseTrans; }
0178    void SetUseTrans(Bool_t v) { fUseTrans = v; }
0179 
0180    void SetEditRotation(Bool_t x) { fEditRotation = x; }
0181    void SetEditScale(Bool_t x) { fEditScale = x; }
0182    Bool_t GetEditRotation() { return fEditRotation; }
0183    Bool_t GetEditScale() { return fEditScale; }
0184 
0185    Bool_t GetEditTrans() const { return fEditTrans; }
0186    void SetEditTrans(Bool_t v) { fEditTrans = v; }
0187 
0188    Bool_t IsScale(Double_t low = 0.9, Double_t high = 1.1) const;
0189 
0190    ClassDefOverride(REveTrans, 1); // Column-major 4x4 transforamtion matrix for homogeneous coordinates.
0191 };
0192 
0193 std::ostream &operator<<(std::ostream &s, const REveTrans &t);
0194 
0195 } // namespace Experimental
0196 } // namespace ROOT
0197 
0198 #endif