Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:42

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