Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // @(#)root/eve:$Id$
0002 // Author: Alja Mrak-Tadel 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_TEveCaloLegoGL
0013 #define ROOT_TEveCaloLegoGL
0014 
0015 #include "TGLObject.h"
0016 #include "TGLAxisPainter.h"
0017 
0018 #include "TEveCaloData.h"
0019 #include "TEveVector.h"
0020 #include "TEveCalo.h"
0021 
0022 #include <map>
0023 #include <vector>
0024 
0025 class TEveCaloLego;
0026 
0027 class TEveCaloLegoGL : public TGLObject
0028 {
0029    friend class TEveCaloLegoOverlay;
0030 
0031 private:
0032    struct Cell2D_t
0033    {
0034       Int_t   fId;
0035       Float_t fSumVal;
0036       Int_t   fMaxSlice;
0037 
0038       Float_t  fX0, fX1, fY0, fY1;
0039 
0040       Cell2D_t(Int_t id, Float_t sumVal, Int_t maxSlice)
0041       {
0042          fId       = id;
0043          fSumVal   = sumVal;
0044          fMaxSlice = maxSlice;
0045          fX0 = fX1 = fY0 = fY1 = 0;
0046       }
0047 
0048       void SetGeom(Float_t x0, Float_t x1, Float_t y0, Float_t y1)
0049       {
0050          fX0 = x0; fX1 = x1;
0051          fY0 = y0; fY1 = y1;
0052       }
0053 
0054       Float_t MinSize() { return TMath::Min(fX1- fX0, fY1 - fY0); }
0055       Float_t X()       { return 0.5*(fX0 + fX1); }
0056       Float_t Y()       { return 0.5*(fY0 + fY1); }
0057    };
0058 
0059    typedef std::vector<Cell2D_t>             vCell2D_t;
0060    typedef std::vector<Cell2D_t>::iterator   vCell2D_i;
0061 
0062    typedef std::map<Int_t, UInt_t>           SliceDLMap_t;
0063    typedef std::map<Int_t, UInt_t>::iterator SliceDLMap_i;
0064 
0065    // histogram base
0066    mutable Color_t                   fGridColor;
0067    mutable Color_t                   fFontColor;
0068 
0069    mutable TAxis      *fEtaAxis;
0070    mutable TAxis      *fPhiAxis;
0071    mutable TAxis      *fZAxis;
0072    mutable TEveVector  fXAxisTitlePos;
0073    mutable TEveVector  fYAxisTitlePos;
0074    mutable TEveVector  fZAxisTitlePos;
0075    mutable TEveVector  fBackPlaneXConst[2];
0076    mutable TEveVector  fBackPlaneYConst[2];
0077 
0078    mutable TGLAxisPainter fAxisPainter;
0079 
0080    // cached
0081    TEveCaloLego                     *fM;
0082    mutable Bool_t                    fDLCacheOK;
0083    mutable vCell2D_t                 fCells2D;
0084 
0085    mutable TEveCaloData::RebinData_t fRebinData;
0086    mutable Float_t                   fMaxVal;
0087    mutable Float_t                   fValToPixel; // top logaritmic viewview
0088    mutable Int_t                     fCurrentPixelsPerBin;
0089 
0090    mutable SliceDLMap_t              fDLMap;
0091    mutable Bool_t                    fCells3D;
0092 
0093    mutable Int_t                     fBinStep;
0094 
0095    TEveCaloLegoGL(const TEveCaloLegoGL&);            // Stop default
0096    TEveCaloLegoGL& operator=(const TEveCaloLegoGL&); // Stop default
0097 
0098 private:
0099    void    GetScaleForMatrix(Float_t& sx, Float_t& sy, Float_t& sz) const;
0100    Int_t   GetGridStep(TGLRnrCtx &rnrCtx) const;
0101    void    RebinAxis(TAxis *orig, TAxis *curr) const;
0102 
0103    void    SetAxis3DTitlePos(TGLRnrCtx &rnrCtx, Float_t x0, Float_t x1, Float_t y0, Float_t y1) const;
0104    void    DrawAxis3D(TGLRnrCtx &rnrCtx) const;
0105    void    DrawAxis2D(TGLRnrCtx &rnrCtx) const;
0106    void    DrawHistBase(TGLRnrCtx &rnrCtx) const;
0107 
0108    // highlight
0109    void    DrawSelectedCells(TGLRnrCtx & rnrCtx, TEveCaloData::vCellId_t cells) const;
0110 
0111    // top view
0112    void    PrepareCell2DData(TEveCaloData::vCellId_t& cellList, vCell2D_t& cells2D) const;
0113    void    PrepareCell2DDataRebin(TEveCaloData::RebinData_t& rebinData, vCell2D_t& cells2D) const;
0114    void    DrawCells2D(TGLRnrCtx & rnrCtx, vCell2D_t& cells2D) const;
0115 
0116    // 3D view
0117    void    DrawCells3D(TGLRnrCtx & rnrCtx) const;
0118    void    MakeQuad(Float_t x, Float_t y, Float_t z, Float_t xw, Float_t yw, Float_t zh) const;
0119    void    Make3DDisplayList(TEveCaloData::vCellId_t& cellList, SliceDLMap_t& map, Bool_t select) const;
0120    void    Make3DDisplayListRebin(TEveCaloData::RebinData_t& rebinData, SliceDLMap_t& map, Bool_t select) const;
0121 
0122    void    WrapTwoPi(Float_t &min, Float_t &max) const;
0123 
0124 public:
0125    TEveCaloLegoGL();
0126    ~TEveCaloLegoGL() override;
0127 
0128    Bool_t SetModel(TObject* obj, const Option_t* opt = nullptr) override;
0129 
0130    void   SetBBox() override;
0131 
0132    void   DLCacheDrop() override;
0133    void   DLCachePurge() override;
0134 
0135    void   DirectDraw(TGLRnrCtx & rnrCtx) const override;
0136    void   DrawHighlight(TGLRnrCtx& rnrCtx, const TGLPhysicalShape* ps, Int_t lvl=-1) const override;
0137 
0138    Bool_t SupportsSecondarySelect() const override { return kTRUE; }
0139    Bool_t AlwaysSecondarySelect()   const override { return kTRUE; }
0140    void   ProcessSelection(TGLRnrCtx & rnrCtx, TGLSelectRecord & rec) override;
0141 
0142    ClassDefOverride(TEveCaloLegoGL, 0); // GL renderer class for TEveCaloLego.
0143 };
0144 
0145 //______________________________________________________________________________
0146 inline void TEveCaloLegoGL::WrapTwoPi(Float_t &min, Float_t &max) const
0147 {
0148    if (fM->GetData()->GetWrapTwoPi())
0149    {
0150       if (fM->GetPhiMax()>TMath::Pi() && max<=fM->GetPhiMin())
0151       {
0152          min += TMath::TwoPi();
0153          max += TMath::TwoPi();
0154       }
0155       else if (fM->GetPhiMin()<-TMath::Pi() && min>=fM->GetPhiMax())
0156       {
0157          min -= TMath::TwoPi();
0158          max -= TMath::TwoPi();
0159       }
0160    }
0161 }
0162 #endif