Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:21

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 #ifndef DDEVE_DISPLAY_H
0014 #define DDEVE_DISPLAY_H
0015 
0016 // Framework include files
0017 #include "DD4hep/Detector.h"
0018 #include "DD4hep/Printout.h"
0019 #include "DDEve/PopupMenu.h"
0020 #include "DDEve/EventHandler.h"
0021 #include "DDEve/DisplayConfiguration.h"
0022 
0023 // C/C++ include files
0024 #include <set>
0025 
0026 // Forward declarations
0027 class TEveCalo3D;
0028 class TEveCaloDataHist;
0029 class TEveElementList;
0030 class TEveManager;
0031 class TEveElement;
0032 class TEveCaloViz;
0033 class TGMenuBar;
0034 class TGClient;
0035 class TFile;
0036 
0037 /// Namespace for the AIDA detector description toolkit
0038 namespace dd4hep {
0039 
0040   // Forward declarations
0041   class View;
0042   class ViewMenu;
0043   class DD4hepMenu;
0044   class EventHandler;
0045   class ViewConfiguration;
0046   class CalodataConfiguration;
0047   class GenericEventHandler;
0048   class DisplayConfiguration;
0049 
0050   /// The main class of the DDEve display.
0051   /*
0052    * \author  M.Frank
0053    * \version 1.0
0054    * \ingroup DD4HEP_EVE
0055    */
0056   class Display : public EventConsumer {
0057   public:
0058     typedef DisplayConfiguration::ViewConfig         ViewConfig;
0059     typedef DisplayConfiguration::Config             DataConfig;
0060     typedef std::set<View*>                          Views;
0061     typedef std::set<DisplayConfiguration*>          Configurations;
0062     typedef std::set<PopupMenu*>                     Menus;
0063     typedef std::map<std::string, TEveElementList*>  Topics;
0064     typedef std::map<std::string, ViewConfig>        ViewConfigurations;
0065     typedef std::map<std::string, DataConfig>        DataConfigurations;
0066 
0067     /// Calorimeter data context for the DDEve event display
0068     struct CalodataContext {
0069       int slice = 0;
0070       TEveCalo3D* calo3D = 0;
0071       TEveCaloViz* caloViz = 0;
0072       TEveCaloDataHist* eveHist = 0;
0073       DisplayConfiguration::Config config;
0074       /// Default constructor
0075       CalodataContext() = default;
0076       /// Copy constructor
0077       CalodataContext(const CalodataContext& c) = default;
0078       /// Assignment operator
0079       CalodataContext& operator=(const CalodataContext& c) = default;
0080     };
0081 
0082     typedef std::map<std::string, CalodataContext> Calodata;
0083    
0084   protected:
0085     /// Reference to TEve manager
0086     TEveManager*         m_eve = 0;
0087     /// Reference to geometry hub
0088     Detector*            m_detDesc = 0;
0089     /// Reference to the event reader object
0090     GenericEventHandler* m_evtHandler = 0;
0091     /// Geometry item element list
0092     TEveElementList*     m_geoGlobal = 0;
0093     /// Event item element list
0094     TEveElementList*     m_eveGlobal = 0;
0095     /// Reference to the view menu
0096     ViewMenu*            m_viewMenu;
0097     /// Reference to the specialized ddeve menu
0098     DD4hepMenu*          m_dd4Menu;
0099     /// Geometry data topics
0100     Topics               m_geoTopics;
0101     /// Event data topics
0102     Topics               m_eveTopics;
0103     /// Container with configured event views
0104     Views                m_eveViews;
0105     /// Container with top level menues
0106     Menus                m_menus;
0107     /// Container with view configurations
0108     ViewConfigurations   m_viewConfigs;
0109     /// Container with calorimeter data display configurations
0110     DataConfigurations   m_calodataConfigs;
0111     /// Container with non-calorimeter data display configurations
0112     DataConfigurations   m_collectionsConfigs;
0113     /// Container with calorimeter data (projections)
0114     Calodata             m_calodata;
0115     /// TGeoManager visualisation level
0116     int                  m_visLevel;
0117     /// Load level for the eve geometry
0118     int                  m_loadLevel;
0119     /// Name of the event handler plugin
0120     std::string          m_eventHandlerName;
0121 
0122   public:
0123     /// Standard constructor
0124     Display(TEveManager* eve);
0125     /// Default destructor
0126     virtual ~Display();
0127 
0128     /// Access to geometry hub
0129     Detector& detectorDescription() const;
0130     /// Access to the EVE manager
0131     TEveManager& manager() const                           { return *m_eve;             }
0132     /// Access View configurations
0133     const ViewConfigurations& viewConfigurations() const   { return m_viewConfigs;      }
0134     /// Set Vis level in geo manager (either from XML or BEFORE XML file was loaded)
0135     void setVisLevel(int new_level)                        { m_visLevel = new_level;    }
0136     /// Set Eve Geometry load level in manager (either from XML or BEFORE XML file was loaded)
0137     void setLoadLevel(int new_level)                       { m_loadLevel = new_level;   }
0138     /// Get Event Handler Plugin name
0139     std::string getEventHandlerName()                      { return m_eventHandlerName; }
0140     /// Set Event Handler Plugin name
0141     void setEventHandlerName(const std::string& nam)       { m_eventHandlerName = nam;  }
0142 
0143     /// Access to X-client
0144     TGClient& client() const;
0145 
0146     /// Load geometry with panel
0147     void ChooseGeometry();
0148     /// Load geometry from compact xml file
0149     void LoadXML(const char* xmlFile);
0150     /// Load geometry from compact xml file
0151     void LoadGeometryRoot(const char* rootFile);
0152     /// Open ROOT file
0153     TFile* Open(const char* rootFile) const;
0154 
0155     /// Access to the event reader
0156     GenericEventHandler& eventHandler() const;
0157 
0158     /// Open standard message box
0159     void MessageBox(PrintLevel level, const std::string& text, const std::string& title="") const;
0160 
0161     /// Popup XML file chooser. returns chosen file name; empty on cancel
0162     std::string OpenXmlFileDialog(const std::string& default_dir)  const;
0163 
0164     /// Popup ROOT file chooser. returns chosen file name; empty on cancel
0165     std::string OpenEventFileDialog(const std::string& default_dir)  const;
0166 
0167     /// Load 'levels' Children into the geometry scene
0168     void LoadGeoChildren(TEveElement* start, int levels, bool redraw);
0169     /// Make a set of nodes starting from a top element (in-)visible with a given depth
0170     void MakeNodesVisible(TEveElement* e, bool visible, int level);
0171 
0172     /// Import configuration parameters
0173     void ImportConfiguration(const DisplayConfiguration& config);
0174 
0175     /// Access a data filter by name. Data filters are used to customize views
0176     const ViewConfig* GetViewConfiguration(const std::string& name)  const;
0177     /// Access a data filter by name. Data filters are used to customize views
0178     const DataConfig* GetCalodataConfiguration(const std::string& name)  const;
0179     /// Access to calo data histograms by name as defined in the configuration
0180     CalodataContext& GetCaloHistogram(const std::string& name);
0181 
0182     /// Register to the main event scene on new events
0183     virtual void RegisterEvents(View* view);
0184     /// Unregister from the main event scene
0185     virtual void UnregisterEvents(View* view);
0186 
0187     /// Access / Create global geometry element
0188     TEveElementList& GetGeo();
0189     /// Access/Create an geometry topic by name
0190     virtual TEveElementList& GetGeoTopic(const std::string& name);
0191     /// Access/Create an geometry topic by name. Throws exception if the topic does not exist
0192     virtual TEveElementList& GetGeoTopic(const std::string& name)  const;
0193 
0194     /// Call to import geometry elements 
0195     void ImportGeo(TEveElement* el);
0196     /// Call to import geometry elements by topic
0197     void ImportGeo(const std::string& topic, TEveElement* el);
0198 
0199     /// Access/Create an event topic by name
0200     virtual TEveElementList& GetEveTopic(const std::string& name);
0201     /// Access/Create an event topic by name. Throws exception if the topic does not exist
0202     virtual TEveElementList& GetEveTopic(const std::string& name)  const;
0203 
0204     /// Call to import top level event elements 
0205     void ImportEvent(TEveElement* el);
0206     /// Call to import event elements by topic
0207     void ImportEvent(const std::string& topic, TEveElement* el);
0208 
0209     /// Consumer overload: open file
0210     virtual void OnFileOpen(EventHandler& handler)  override;
0211     /// EventConsumer overload: Consumer event data
0212     virtual void OnNewEvent(EventHandler& handler)  override;
0213 
0214     /// Build the DDEve specific menues. Default bar is the ROOT browser's bar
0215     virtual void BuildMenus(TGMenuBar* menuBar=0);
0216     /// Add new menu to the main menu bar
0217     virtual void AddMenu(TGMenuBar* menuBar, PopupMenu* menu, int hints=kLHintsNormal);
0218 
0219     ClassDefOverride(Display,0);
0220   };
0221 }      /* End namespace dd4hep   */
0222 #endif // DDEVE_DISPLAY_H
0223