Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // @(#)root/eve7:$Id$
0002 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
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_REveProjections
0013 #define ROOT7_REveProjections
0014 
0015 #include <ROOT/REveVector.hxx>
0016 
0017 #include <vector>
0018 #include <string>
0019 
0020 namespace ROOT {
0021 namespace Experimental {
0022 
0023 class REveTrans;
0024 
0025 ///////////////////////////////////////////////////////////////////////////////
0026 /// REveProjection
0027 /// Base for specific classes that implement non-linear projections.
0028 ///////////////////////////////////////////////////////////////////////////////
0029 
0030 class REveProjection {
0031 public:
0032    enum EPType_e { kPT_Unknown, kPT_RhoZ, kPT_RPhi,
0033                    kPT_XZ, kPT_YZ, kPT_ZX, kPT_ZY, kPT_3D, kPT_End };  // projection type
0034    enum EPProc_e { kPP_Plane, kPP_Distort, kPP_Full };                 // projection procedure
0035    enum EGeoMode_e { kGM_Unknown, kGM_Polygons, kGM_Segments };        // strategy for geometry projections
0036 
0037    struct PreScaleEntry_t {
0038       Float_t fMin{0}, fMax{0};
0039       Float_t fOffset{0};
0040       Float_t fScale{1};
0041 
0042       PreScaleEntry_t() = default;
0043 
0044       PreScaleEntry_t(Float_t min, Float_t max, Float_t off, Float_t scale)
0045          : fMin(min), fMax(max), fOffset(off), fScale(scale)
0046       {
0047       }
0048    };
0049 
0050    typedef std::vector<PreScaleEntry_t> vPreScale_t;
0051 
0052 protected:
0053    EPType_e fType;       // type
0054    EGeoMode_e fGeoMode;  // strategy of polygon projection (what to try first)
0055    std::string fName;    // name
0056 
0057    REveVector fCenter; // center of distortion
0058 
0059    bool fDisplaceOrigin; // displace point before projection
0060 
0061    Bool_t fUsePreScale;       // use pre-scaling
0062    vPreScale_t fPreScales[3]; // scaling before the distortion
0063 
0064    Float_t fDistortion;    // distortion
0065    Float_t fFixR;          // radius from which scaling remains constant
0066    Float_t fFixZ;          // z-coordinate from which scaling remains constant
0067    Float_t fPastFixRFac;   // relative scaling factor beyond fFixR as 10^x
0068    Float_t fPastFixZFac;   // relative scaling factor beyond fFixZ as 10^x
0069    Float_t fScaleR;        // scale factor to keep projected radius at fFixR fixed
0070    Float_t fScaleZ;        // scale factor to keep projected z-coordinate at fFixZ fixed
0071    Float_t fPastFixRScale; // relative scaling beyond fFixR
0072    Float_t fPastFixZScale; // relative scaling beyond fFixZ
0073    Float_t fMaxTrackStep;  // maximum distance between two points on a track
0074 
0075    void PreScaleVariable(Int_t dim, Float_t &v);
0076 
0077 public:
0078    REveProjection();
0079    virtual ~REveProjection() {}
0080 
0081    virtual Bool_t Is2D() const = 0;
0082    virtual Bool_t Is3D() const = 0;
0083 
0084    virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e p = kPP_Full) = 0;
0085 
0086    void ProjectPointfv(Float_t *v, Float_t d);
0087    void ProjectPointdv(Double_t *v, Float_t d);
0088    void ProjectVector(REveVector &v, Float_t d);
0089 
0090    void ProjectPointfv(const REveTrans *t, const Float_t *p, Float_t *v, Float_t d);
0091    void ProjectPointdv(const REveTrans *t, const Double_t *p, Double_t *v, Float_t d);
0092    void ProjectVector(const REveTrans *t, REveVector &v, Float_t d);
0093 
0094    const char *GetName() const { return fName.c_str(); }
0095    void SetName(const char *txt) { fName = txt; }
0096 
0097    const REveVector &RefCenter() const { return fCenter; }
0098    virtual void SetCenter(REveVector &v) { fCenter = v; }
0099    virtual Float_t *GetProjectedCenter();
0100 
0101    void SetDisplaceOrigin(bool);
0102    Bool_t GetDisplaceOrigin() const { return fDisplaceOrigin; }
0103 
0104    void SetType(EPType_e t) { fType = t; }
0105    EPType_e GetType() const { return fType; }
0106 
0107    void SetGeoMode(EGeoMode_e m) { fGeoMode = m; }
0108    EGeoMode_e GetGeoMode() const { return fGeoMode; }
0109 
0110    Bool_t GetUsePreScale() const { return fUsePreScale; }
0111    void SetUsePreScale(Bool_t x) { fUsePreScale = x; }
0112 
0113    void PreScalePoint(Float_t &x, Float_t &y);
0114    void PreScalePoint(Float_t &x, Float_t &y, Float_t &z);
0115    void AddPreScaleEntry(Int_t coord, Float_t max_val, Float_t scale);
0116    void ChangePreScaleEntry(Int_t coord, Int_t entry, Float_t new_scale);
0117    void ClearPreScales();
0118 
0119    void SetDistortion(Float_t d);
0120    Float_t GetDistortion() const { return fDistortion; }
0121    Float_t GetFixR() const { return fFixR; }
0122    Float_t GetFixZ() const { return fFixZ; }
0123    void SetFixR(Float_t x);
0124    void SetFixZ(Float_t x);
0125    Float_t GetPastFixRFac() const { return fPastFixRFac; }
0126    Float_t GetPastFixZFac() const { return fPastFixZFac; }
0127    void SetPastFixRFac(Float_t x);
0128    void SetPastFixZFac(Float_t x);
0129    Float_t GetMaxTrackStep() const { return fMaxTrackStep; }
0130    void SetMaxTrackStep(Float_t x) { fMaxTrackStep = TMath::Max(x, 1.0f); }
0131 
0132    virtual Bool_t HasSeveralSubSpaces() const { return kFALSE; }
0133    virtual Bool_t AcceptSegment(REveVector &, REveVector &, Float_t /*tolerance*/) const { return kTRUE; }
0134    virtual Int_t SubSpaceId(const REveVector &) const { return 0; }
0135    virtual Bool_t IsOnSubSpaceBoundrary(const REveVector &) const { return kFALSE; }
0136    virtual void BisectBreakPoint(REveVector &vL, REveVector &vR, Float_t eps_sqr);
0137    virtual void BisectBreakPoint(REveVector &vL, REveVector &vR, Bool_t project_result = kFALSE, Float_t depth = 0);
0138    virtual void SetDirectionalVector(Int_t screenAxis, REveVector &vec);
0139 
0140    // utils to draw axis
0141    REveVector GetOrthogonalCenter(int idx, REveVector &out);
0142    virtual Float_t GetValForScreenPos(Int_t ax, Float_t value);
0143    virtual Float_t GetScreenVal(Int_t ax, Float_t value);
0144    Float_t GetScreenVal(Int_t i, Float_t x, REveVector &dirVec, REveVector &oCenter);
0145    Float_t GetLimit(Int_t i, Bool_t pos);
0146 
0147    static Float_t fgEps;    // resolution of projected points
0148    static Float_t fgEpsSqr; // square of resolution of projected points
0149 };
0150 
0151 //==============================================================================
0152 // REveRhoZProjection
0153 // Rho/Z non-linear projection.
0154 //==============================================================================
0155 
0156 class REveRhoZProjection : public REveProjection {
0157 private:
0158    REveVector fProjectedCenter; // projected center of distortion.
0159 
0160 public:
0161    REveRhoZProjection();
0162    ~REveRhoZProjection() override {}
0163 
0164    Bool_t Is2D() const override { return kTRUE; }
0165    Bool_t Is3D() const override { return kFALSE; }
0166 
0167    void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc = kPP_Full) override;
0168 
0169    void SetCenter(REveVector &v) override;
0170    Float_t *GetProjectedCenter() override { return fProjectedCenter.Arr(); }
0171 
0172    Bool_t HasSeveralSubSpaces() const override { return kTRUE; }
0173    Bool_t AcceptSegment(REveVector &v1, REveVector &v2, Float_t tolerance) const override;
0174    Int_t SubSpaceId(const REveVector &v) const override;
0175    Bool_t IsOnSubSpaceBoundrary(const REveVector &v) const override;
0176    void SetDirectionalVector(Int_t screenAxis, REveVector &vec) override;
0177 };
0178 
0179 //==============================================================================
0180 // REveRPhiProjection
0181 // XY non-linear projection.
0182 //==============================================================================
0183 
0184 class REveRPhiProjection : public REveProjection {
0185 public:
0186    REveRPhiProjection();
0187    ~REveRPhiProjection() override {}
0188 
0189    Bool_t Is2D() const override { return kTRUE; }
0190    Bool_t Is3D() const override { return kFALSE; }
0191 
0192    void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc = kPP_Full) override;
0193 };
0194 
0195 //==============================================================================
0196 // REveXZProjection
0197 // XZ non-linear projection.
0198 //==============================================================================
0199 
0200 class REveXZProjection : public REveProjection {
0201 private:
0202    REveVector   fProjectedCenter; // projected center of distortion.
0203 
0204 public:
0205    REveXZProjection();
0206    ~REveXZProjection() override {}
0207 
0208    Bool_t Is2D() const override { return kTRUE;  }
0209    Bool_t Is3D() const override { return kFALSE; }
0210 
0211    void ProjectPoint(Float_t& x, Float_t& y, Float_t& z, Float_t d, EPProc_e proc = kPP_Full) override;
0212 
0213    void     SetCenter(REveVector& v) override;
0214    Float_t* GetProjectedCenter() override { return fProjectedCenter.Arr(); }
0215 
0216    void SetDirectionalVector(Int_t screenAxis, REveVector& vec) override;
0217 };
0218 
0219 //==============================================================================
0220 // REveYZProjection
0221 // YZ non-linear projection.
0222 //==============================================================================
0223 
0224 class REveYZProjection : public REveProjection {
0225 private:
0226    REveVector   fProjectedCenter; // projected center of distortion.
0227 
0228 public:
0229    REveYZProjection();
0230    ~REveYZProjection() override {}
0231 
0232    Bool_t Is2D() const override { return kTRUE;  }
0233    Bool_t Is3D() const override { return kFALSE; }
0234 
0235    void ProjectPoint(Float_t& x, Float_t& y, Float_t& z, Float_t d, EPProc_e proc = kPP_Full) override;
0236 
0237    void     SetCenter(REveVector& v) override;
0238    Float_t* GetProjectedCenter() override { return fProjectedCenter.Arr(); }
0239 
0240    void SetDirectionalVector(Int_t screenAxis, REveVector& vec) override;
0241 };
0242 
0243 //==============================================================================
0244 // REveZXProjection
0245 // ZX non-linear projection.
0246 //==============================================================================
0247 
0248 class REveZXProjection : public REveProjection {
0249 private:
0250    REveVector   fProjectedCenter; // projected center of distortion.
0251 
0252 public:
0253    REveZXProjection();
0254    ~REveZXProjection() override {}
0255 
0256    Bool_t Is2D() const override { return kTRUE;  }
0257    Bool_t Is3D() const override { return kFALSE; }
0258 
0259    void ProjectPoint(Float_t& x, Float_t& y, Float_t& z, Float_t d, EPProc_e proc = kPP_Full) override;
0260 
0261    void     SetCenter(REveVector& v) override;
0262    Float_t* GetProjectedCenter() override { return fProjectedCenter.Arr(); }
0263 
0264    void SetDirectionalVector(Int_t screenAxis, REveVector& vec) override;
0265 };
0266 
0267 //==============================================================================
0268 // REveZYProjection
0269 // ZY non-linear projection.
0270 //==============================================================================
0271 
0272 class REveZYProjection : public REveProjection {
0273 private:
0274    REveVector   fProjectedCenter; // projected center of distortion.
0275 
0276 public:
0277    REveZYProjection();
0278    ~REveZYProjection() override {}
0279 
0280    Bool_t Is2D() const override { return kTRUE;  }
0281    Bool_t Is3D() const override { return kFALSE; }
0282 
0283    void ProjectPoint(Float_t& x, Float_t& y, Float_t& z, Float_t d, EPProc_e proc = kPP_Full) override;
0284 
0285    void     SetCenter(REveVector& v) override;
0286    Float_t* GetProjectedCenter() override { return fProjectedCenter.Arr(); }
0287 
0288    void SetDirectionalVector(Int_t screenAxis, REveVector& vec) override;
0289 };
0290 
0291 //==============================================================================
0292 // REve3DProjection
0293 // 3D scaling "projection"
0294 //==============================================================================
0295 
0296 class REve3DProjection : public REveProjection {
0297 public:
0298    REve3DProjection();
0299    ~REve3DProjection() override {}
0300 
0301    Bool_t Is2D() const override { return kFALSE; }
0302    Bool_t Is3D() const override { return kTRUE; }
0303 
0304    void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc = kPP_Full) override;
0305 };
0306 
0307 } // namespace Experimental
0308 } // namespace ROOT
0309 
0310 #endif