Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-31 09:17:00

0001 // @(#)root/geom:$Id$
0002 // Author: Andrei Gheata   17/02/04
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, 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_TGeoPhysicalNode
0013 #define ROOT_TGeoPhysicalNode
0014 
0015 #include "TNamed.h"
0016 
0017 #include "TAttLine.h"
0018 
0019 // forward declarations
0020 class TGeoHMatrix;
0021 class TGeoMatrix;
0022 class TGeoVolume;
0023 class TGeoNode;
0024 class TGeoShape;
0025 class TGeoNavigator;
0026 class TObjArray;
0027 
0028 /// @details class representing an unique object associated with a path.
0029 class TGeoPhysicalNode : public TNamed, public TAttLine {
0030 protected:
0031    Int_t fLevel;             // depth in the geometry tree
0032    TObjArray *fMatrices;     // global transformation matrices
0033    TObjArray *fNodes;        // branch of nodes
0034    TGeoHMatrix *fMatrixOrig; // original local matrix of the last node in the path
0035 
0036    TGeoPhysicalNode(const TGeoPhysicalNode &) = delete;
0037    TGeoPhysicalNode &operator=(const TGeoPhysicalNode &) = delete;
0038 
0039    void SetAligned(Bool_t flag = kTRUE) { TObject::SetBit(kGeoPNodeAligned, flag); }
0040    Bool_t SetPath(const char *path);
0041    void SetBranchAsState();
0042 
0043 public:
0044    enum {
0045       kGeoPNodeFull = BIT(10),    // full branch is visible (default only last node)
0046       kGeoPNodeVisible = BIT(11), // this node is visible (default)
0047       kGeoPNodeVolAtt = BIT(12),  // preserve volume attributes (default)
0048       kGeoPNodeAligned = BIT(13)  // alignment bit
0049    };
0050 
0051    // constructors
0052    TGeoPhysicalNode();
0053    TGeoPhysicalNode(const char *path);
0054    // destructor
0055    ~TGeoPhysicalNode() override;
0056 
0057    Bool_t
0058    Align(TGeoMatrix *newmat = nullptr, TGeoShape *newshape = nullptr, Bool_t check = kFALSE, Double_t ovlp = 0.001);
0059    void cd() const;
0060    void Draw(Option_t *option = "") override;
0061    Int_t GetLevel() const { return fLevel; }
0062    TGeoHMatrix *GetMatrix(Int_t level = -1) const;
0063    TGeoHMatrix *GetOriginalMatrix() const { return fMatrixOrig; }
0064    TGeoNode *GetMother(Int_t levup = 1) const;
0065    TGeoNode *GetNode(Int_t level = -1) const;
0066    TGeoShape *GetShape(Int_t level = -1) const;
0067    TGeoVolume *GetVolume(Int_t level = -1) const;
0068 
0069    Bool_t IsAligned() const { return TObject::TestBit(kGeoPNodeAligned); }
0070    Bool_t IsMatchingState(TGeoNavigator *nav) const;
0071    Bool_t IsVolAttributes() const { return TObject::TestBit(kGeoPNodeVolAtt); }
0072    Bool_t IsVisible() const { return TObject::TestBit(kGeoPNodeVisible); }
0073    Bool_t IsVisibleFull() const { return TObject::TestBit(kGeoPNodeFull); }
0074 
0075    void Print(Option_t *option = "") const override;
0076    void Refresh();
0077 
0078    void SetMatrixOrig(const TGeoMatrix *local);
0079    void SetIsVolAtt(Bool_t flag = kTRUE) { TObject::SetBit(kGeoPNodeVolAtt, flag); }
0080    void SetVisibility(Bool_t flag = kTRUE) { TObject::SetBit(kGeoPNodeVisible, flag); }
0081    void SetVisibleFull(Bool_t flag = kTRUE) { TObject::SetBit(kGeoPNodeFull, flag); }
0082    void Paint(Option_t *option = "") override;
0083 
0084    ClassDefOverride(TGeoPhysicalNode, 1) // base class for physical nodes
0085 };
0086 
0087 /// @details class representing physical node entry having a unique name associated to a path.
0088 class TGeoPNEntry : public TNamed {
0089 private:
0090    enum EPNEntryFlags { kPNEntryOwnMatrix = BIT(14) };
0091    TGeoPhysicalNode *fNode;    // Physical node to which this applies
0092    const TGeoHMatrix *fMatrix; // Additional matrix
0093    TGeoHMatrix *fGlobalOrig;   // Original global matrix for the linked physical node
0094 
0095 protected:
0096    TGeoPNEntry(const TGeoPNEntry &pne) : TNamed(pne), fNode(pne.fNode), fMatrix(nullptr), fGlobalOrig(nullptr) {}
0097    TGeoPNEntry &operator=(const TGeoPNEntry &pne)
0098    {
0099       if (this != &pne) {
0100          TNamed::operator=(pne);
0101          fNode = pne.fNode;
0102          fMatrix = pne.fMatrix;
0103       }
0104       return *this;
0105    }
0106 
0107 public:
0108    TGeoPNEntry();
0109    TGeoPNEntry(const char *unique_name, const char *path);
0110    ~TGeoPNEntry() override;
0111 
0112    inline const char *GetPath() const { return GetTitle(); }
0113    const TGeoHMatrix *GetMatrix() const { return fMatrix; }
0114    TGeoHMatrix *GetMatrixOrig() const
0115    {
0116       if (fNode)
0117          return fNode->GetOriginalMatrix();
0118       else
0119          return nullptr;
0120    };
0121    TGeoHMatrix *GetGlobalOrig() const { return fGlobalOrig; }
0122    TGeoPhysicalNode *GetPhysicalNode() const { return fNode; }
0123    void SetMatrix(const TGeoHMatrix *matrix);
0124    void SetPhysicalNode(TGeoPhysicalNode *node);
0125 
0126    ClassDefOverride(TGeoPNEntry, 4) // a physical node entry with unique name
0127 };
0128 
0129 #endif