Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // @(#)root/eve:$Id$
0002 // Author: Matevz 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_REveCalo
0013 #define ROOT_REveCalo
0014 
0015 #include "ROOT/REveElement.hxx"
0016 #include "ROOT/REveProjectionBases.hxx"
0017 #include "ROOT/REveProjectionManager.hxx"
0018 
0019 #include "TAtt3D.h"
0020 #include "TAttBBox.h"
0021 #include "ROOT/REveCaloData.hxx"
0022 
0023 class TClass;
0024 
0025 namespace ROOT {
0026 namespace Experimental {
0027 
0028 class REveRGBAPalette;
0029 class REveCaloViz : public REveElement,
0030                     public TAtt3D,
0031                     public TAttBBox,
0032                     public REveProjectable
0033 {
0034 
0035 private:
0036    REveCaloViz& operator=(const REveCaloViz&) = delete;
0037 
0038 protected:
0039    REveCaloData* fData;           // event data reference
0040    Bool_t        fCellIdCacheOK;  // data cell ids cache state
0041 
0042    Double_t      fEtaMin;
0043    Double_t      fEtaMax;
0044 
0045    Double_t      fPhi;
0046    Double_t      fPhiOffset;     // phi range +/- offset
0047 
0048    Bool_t        fAutoRange;     // set eta phi limits on DataChanged()
0049 
0050    Float_t       fBarrelRadius;  // barrel raidus in cm
0051    Float_t       fEndCapPosF;     // forward end cap z coordinate in cm
0052    Float_t       fEndCapPosB;     // backward end cap z coordinate in cm (should be < 0)
0053 
0054    Float_t       fPlotEt;        // plot E or Et.
0055 
0056    Float_t           fMaxTowerH;  // bounding box z dimesion
0057    Bool_t            fScaleAbs;
0058    Float_t           fMaxValAbs;
0059 
0060    Bool_t            fValueIsColor;   // Interpret signal value as RGBA color.
0061    REveRGBAPalette*  fPalette;        // Pointer to signal-color palette.
0062 
0063 
0064    void AssignCaloVizParameters(REveCaloViz* cv);
0065 
0066    void SetupHeight(Float_t value, Int_t slice, Float_t& height) const;
0067 
0068    virtual void BuildCellIdCache() = 0;
0069 
0070 public:
0071    REveCaloViz(REveCaloData* data=nullptr, const char* n="REveCaloViz", const char* t="");
0072 
0073    ~REveCaloViz() override;
0074 
0075    bool RequiresExtraSelectionData() const override { return true; };
0076    virtual REveElement* ForwardSelection();
0077    virtual REveElement* ForwardEdit();
0078 
0079    TClass* ProjectedClass(const REveProjection* p) const override;
0080    virtual Float_t GetValToHeight() const;
0081    // virtual void    CellSelectionChanged() {}
0082 
0083    virtual void    SetScaleAbs(Bool_t x) { fScaleAbs = x; }
0084 
0085    REveCaloData* GetData() const { return fData; }
0086    void    SetData(REveCaloData* d);
0087    void    DataChanged();
0088    Float_t GetMaxVal() const;
0089 
0090    Bool_t  AssertCellIdCache() const;
0091    void    InvalidateCellIdCache() { fCellIdCacheOK=kFALSE; ResetBBox(); };
0092 
0093    Float_t GetDataSliceThreshold(Int_t slice) const;
0094    void    SetDataSliceThreshold(Int_t slice, Float_t val);
0095    Color_t GetDataSliceColor(Int_t slice) const;
0096    void    SetDataSliceColor(Int_t slice, Color_t col);
0097 
0098    Float_t GetBarrelRadius() const { return fBarrelRadius; }
0099    void    SetBarrelRadius(Float_t r) { fBarrelRadius = r; ResetBBox(); }
0100    Float_t GetEndCapPos   () const { return fEndCapPosF; } // get end cap position, assuming fEndCapPosF = -fEndCapPosB
0101    Float_t GetForwardEndCapPos   () const { return fEndCapPosF; }
0102    Float_t GetBackwardEndCapPos   () const { return fEndCapPosB; }
0103    void    SetEndCapPos   (Float_t z) { fEndCapPosF = z; fEndCapPosB = -z; ResetBBox(); }
0104    void    SetForwardEndCapPos (Float_t z) { fEndCapPosF = z; ResetBBox(); }
0105    void    SetBackwardEndCapPos(Float_t z) { fEndCapPosB = z; ResetBBox(); }
0106 
0107    Bool_t  GetPlotEt() const { return fPlotEt; }
0108    void    SetPlotEt(Bool_t x);
0109 
0110    void    SetMaxTowerH(Float_t x) { fMaxTowerH = x; }
0111    Float_t GetMaxTowerH() const    { return fMaxTowerH; }
0112    Bool_t  GetScaleAbs() const { return fScaleAbs; }
0113    void    SetMaxValAbs(Float_t x) { fMaxValAbs = x; }
0114    Float_t GetMaxValAbs() const    { return fMaxValAbs; }
0115 
0116    Float_t GetTransitionEta() const;
0117    Float_t GetTransitionEtaForward() const;
0118    Float_t GetTransitionEtaBackward() const;
0119    Float_t GetTransitionTheta() const;
0120    Float_t GetTransitionThetaForward() const;
0121    Float_t GetTransitionThetaBackward() const;
0122 
0123    REveRGBAPalette* GetPalette() const { return fPalette; }
0124    void             SetPalette(REveRGBAPalette* p);
0125 
0126    REveRGBAPalette* AssertPalette();
0127    Bool_t  GetValueIsColor()   const { return fValueIsColor;}
0128    void    SetValueIsColor(Bool_t x) { fValueIsColor = x;}
0129 
0130    Bool_t  GetAutoRange()   const { return fAutoRange; }
0131    void    SetAutoRange(Bool_t x) { fAutoRange = x; }
0132 
0133    void    SetEta(Float_t l, Float_t u);
0134    Float_t GetEta()    const { return 0.5f*(fEtaMin+fEtaMax); }
0135    Float_t GetEtaMin() const { return fEtaMin; }
0136    Float_t GetEtaMax() const { return fEtaMax; }
0137    Float_t GetEtaRng() const { return fEtaMax-fEtaMin; }
0138 
0139    void    SetPhi(Float_t phi)    { SetPhiWithRng(phi, fPhiOffset); }
0140    void    SetPhiRng(Float_t rng) { SetPhiWithRng(fPhi, rng); }
0141    void    SetPhiWithRng(Float_t x, Float_t r);
0142    Float_t GetPhi()    const { return fPhi; }
0143    Float_t GetPhiMin() const { return fPhi-fPhiOffset; }
0144    Float_t GetPhiMax() const { return fPhi+fPhiOffset; }
0145    Float_t GetPhiRng() const { return 2.0f*fPhiOffset; }
0146 
0147    Bool_t  CellInEtaPhiRng (REveCaloData::CellData_t&) const;
0148 
0149    Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;
0150    virtual void WriteCoreJsonSelection(nlohmann::json &j,  REveCaloData::vCellId_t) = 0;
0151 };
0152 
0153 /**************************************************************************/
0154 /**************************************************************************/
0155 
0156 class REveCalo3D : public REveCaloViz
0157 {
0158 private:
0159    REveCalo3D& operator=(const REveCalo3D&) = delete;
0160 
0161    void MakeBarrelCell(const REveCaloData::CellGeom_t &cellData, float towerH, Float_t& offset, float *pnts) const;
0162    void MakeEndCapCell(const REveCaloData::CellGeom_t &cellData, float towerH, Float_t& offset, float *pnts) const;
0163 
0164 protected:
0165    REveCaloData::vCellId_t fCellList;
0166 
0167    Bool_t    fRnrEndCapFrame;
0168    Bool_t    fRnrBarrelFrame;
0169 
0170    Float_t   fFrameWidth;
0171    Color_t   fFrameColor;
0172    Char_t    fFrameTransparency;
0173 
0174    void BuildCellIdCache() override;
0175 
0176 public:
0177    REveCalo3D(REveCaloData* d=nullptr, const char* n="REveCalo3D", const char* t="");
0178    ~REveCalo3D() override {}
0179    void ComputeBBox() override;
0180 
0181    Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;
0182    void WriteCoreJsonSelection(nlohmann::json &j,  REveCaloData::vCellId_t) override;
0183    void BuildRenderData() override;
0184 
0185    void    SetFrameWidth(Float_t w) { fFrameWidth = w; }
0186    Float_t GetFrameWidth() const    { return fFrameWidth; }
0187 
0188    void SetRnrFrame(Bool_t e, Bool_t b)         { fRnrEndCapFrame = e; fRnrBarrelFrame = b; }
0189    void GetRnrFrame(Bool_t &e, Bool_t &b) const { e = fRnrEndCapFrame; b = fRnrBarrelFrame; }
0190    void SetRnrEndCapFrame(Bool_t r) { fRnrEndCapFrame = r; }
0191    void SetRnrBarrelFrame(Bool_t r) { fRnrBarrelFrame = r; }
0192    Bool_t GetRnrEndCapFrame() const { return fRnrEndCapFrame; }
0193    Bool_t GetRnrBarrelFrame() const { return fRnrBarrelFrame; }
0194 
0195    void   SetFrameTransparency(Char_t x) { fFrameTransparency = x; }
0196    Char_t GetFrameTransparency() const { return fFrameTransparency; }
0197 
0198    void NewTowerPicked(Int_t tower, Int_t slice, Int_t selectionId, Bool_t multi);
0199 };
0200 
0201 /**************************************************************************/
0202 /**************************************************************************/
0203 
0204 class REveCalo2D : public REveCaloViz,
0205                    public REveProjected
0206 {
0207 public:
0208    typedef std::vector<REveCaloData::vCellId_t*>           vBinCells_t;
0209    typedef std::vector<REveCaloData::vCellId_t*>::iterator vBinCells_i;
0210 
0211 private:
0212    REveCalo2D& operator=(const REveCalo2D&) = delete;
0213 
0214    REveProjection::EPType_e  fOldProjectionType;
0215    void CellSelectionChangedInternal(REveCaloData::vCellId_t& cells, std::vector<REveCaloData::vCellId_t*>& cellLists);
0216 
0217    void MakeRPhiCell(Float_t phiMin, Float_t phiMax,
0218                      Float_t towerH, Float_t offset, float* pntsOut) const;
0219 
0220    void MakeRhoZCell(Float_t thetaMin, Float_t thetaMax,
0221                      Float_t& offset, Bool_t isBarrel,  Bool_t phiPlus, Float_t towerH, float *pntsOut) const;
0222 
0223    void BuildRenderDataRPhi();
0224    void BuildRenderDataRhoZ();
0225 
0226 protected:
0227    std::vector<REveCaloData::vCellId_t*>   fCellLists;
0228 
0229    std::vector<REveCaloData::vCellId_t*>   fCellListsSelected;
0230    std::vector<REveCaloData::vCellId_t*>   fCellListsHighlighted;
0231 
0232    Float_t                                 fMaxESumBin;
0233    Float_t                                 fMaxEtSumBin;
0234 
0235    void BuildCellIdCache() override;
0236 
0237    void SetDepthLocal(Float_t x) override { fDepth = x; }
0238 
0239    bool IsRPhi() const;
0240 
0241 public:
0242    REveCalo2D(const char* n="REveCalo2D", const char* t="");
0243    ~REveCalo2D() override;
0244 
0245    void SetProjection(REveProjectionManager* proj, REveProjectable* model) override;
0246    void UpdateProjection() override;
0247    void ComputeBBox() override;
0248 
0249    void    SetScaleAbs(Bool_t) override;
0250 
0251    Float_t GetValToHeight() const override;
0252 
0253    Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;
0254    void WriteCoreJsonSelection(nlohmann::json &j,  REveCaloData::vCellId_t) override;
0255    void BuildRenderData() override;
0256 
0257    void NewBinPicked(Int_t bin, Int_t slice, Int_t selectionId, Bool_t multi);
0258 
0259    const REveCalo2D::vBinCells_t& GetBinLists() const { return fCellLists; }
0260 };
0261 
0262 /**************************************************************************/
0263 /**************************************************************************/
0264 
0265 class REveCaloLego : public REveCaloViz
0266 {
0267 public:
0268    enum EProjection_e { kAuto, k3D, k2D };
0269    enum E2DMode_e     { kValColor, kValSize, kValSizeOutline };
0270    enum EBoxMode_e    { kNone, kFrontBack, kBack};
0271 
0272 private:
0273    REveCaloLego& operator=(const REveCaloLego&) = delete;
0274 
0275 protected:
0276    REveCaloData::vCellId_t fCellList;
0277 
0278    Color_t                 fFontColor;
0279    Color_t                 fGridColor;
0280    Color_t                 fPlaneColor;
0281    Char_t                  fPlaneTransparency;
0282 
0283    Int_t                   fNZSteps; // Z axis label step in GeV
0284    Float_t                 fZAxisStep;
0285 
0286    Bool_t                  fAutoRebin;
0287    Int_t                   fPixelsPerBin;
0288    Bool_t                  fNormalizeRebin;
0289 
0290    EProjection_e           fProjection;
0291    E2DMode_e               f2DMode;
0292    EBoxMode_e              fBoxMode;  // additional scale info
0293 
0294    Bool_t                  fDrawHPlane;
0295    Float_t                 fHPlaneVal;
0296 
0297    Bool_t                  fHasFixedHeightIn2DMode;
0298    Float_t                 fFixedHeightValIn2DMode; // 1% of whole height
0299 
0300    Int_t                   fDrawNumberCellPixels;
0301    Int_t                   fCellPixelFontSize;
0302 
0303    void BuildCellIdCache() override;
0304 
0305 public:
0306    REveCaloLego(REveCaloData* data=nullptr, const char* n="REveCaloLego", const char* t="");
0307    ~REveCaloLego() override{}
0308 
0309    void ComputeBBox() override;
0310    virtual void  SetData(REveCaloData* d);
0311 
0312    Color_t  GetFontColor() const { return fFontColor; }
0313    void     SetFontColor(Color_t ci) { fFontColor=ci; }
0314 
0315    Color_t  GetGridColor() const { return fGridColor; }
0316    void     SetGridColor(Color_t ci) { fGridColor=ci; }
0317 
0318    Color_t  GetPlaneColor() const { return fPlaneColor; }
0319    void     SetPlaneColor(Color_t ci) { fPlaneColor=ci; }
0320 
0321    Char_t   GetPlaneTransparency() const { return fPlaneTransparency; }
0322    void     SetPlaneTransparency(Char_t t) { fPlaneTransparency=t; }
0323 
0324    Int_t    GetNZSteps() const { return fNZSteps; }
0325    void     SetNZSteps(Int_t s) { fNZSteps = s;}
0326 
0327    Int_t    GetPixelsPerBin() const { return fPixelsPerBin; }
0328    void     SetPixelsPerBin(Int_t bw) { fPixelsPerBin = bw; }
0329 
0330    Bool_t   GetAutoRebin() const { return fAutoRebin; }
0331    void     SetAutoRebin(Bool_t s) { fAutoRebin = s;}
0332 
0333    Bool_t   GetNormalizeRebin() const { return fNormalizeRebin; }
0334    void     SetNormalizeRebin(Bool_t s) { fNormalizeRebin = s; fCellIdCacheOK=kFALSE;}
0335 
0336    EProjection_e  GetProjection() const { return fProjection; }
0337    void           SetProjection(EProjection_e p) { fProjection = p; }
0338 
0339    void       Set2DMode(E2DMode_e p) { f2DMode = p; }
0340    E2DMode_e  Get2DMode() { return f2DMode; }
0341 
0342    bool       GetHasFixedHeightIn2DMode() const { return fHasFixedHeightIn2DMode; }
0343    void       SetHasFixedHeightIn2DMode(bool x) { fHasFixedHeightIn2DMode = x; }
0344 
0345    float      GetFixedHeightValIn2DMode() const  { return fFixedHeightValIn2DMode; }
0346    void       SetFixedHeightValIn2DMode(float x) { fFixedHeightValIn2DMode = x; }
0347 
0348    void        SetBoxMode(EBoxMode_e p) { fBoxMode = p; }
0349    EBoxMode_e  GetBoxMode() { return fBoxMode; }
0350 
0351    Bool_t   GetDrawHPlane() const { return fDrawHPlane; }
0352    void     SetDrawHPlane(Bool_t s) { fDrawHPlane = s;}
0353 
0354    Float_t  GetHPlaneVal() const { return fHPlaneVal; }
0355    void     SetHPlaneVal(Float_t s) { fHPlaneVal = s;}
0356 
0357    Int_t    GetDrawNumberCellPixels() { return fDrawNumberCellPixels; }
0358    void     SetDrawNumberCellPixels(Int_t x) { fDrawNumberCellPixels = x; }
0359    Int_t    GetCellPixelFontSize() { return fCellPixelFontSize; }
0360    void     SetCellPixelFontSize(Int_t x) { fCellPixelFontSize = x; }
0361 };
0362 
0363 } // namespace Experimental
0364 } // namespace ROOT
0365 
0366 #endif