Back to home page

EIC code displayed by LXR

 
 

    


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

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_GENERICEVENTHANDLER_H
0014 #define DDEVE_GENERICEVENTHANDLER_H
0015 
0016 // Framework include files
0017 #include "DDEve/EventHandler.h"
0018 
0019 // Forward declarations
0020 
0021 /// Namespace for the AIDA detector description toolkit
0022 namespace dd4hep {
0023 
0024   /// Event handler base class. Interface to all DDEve I/O actions
0025   /** 
0026    *  \author  M.Frank
0027    *  \version 1.0
0028    *  \ingroup DD4HEP_EVE
0029    */
0030   class GenericEventHandler : public EventHandler  {
0031   protected:
0032     /// Subscriber set
0033     typedef std::set<EventConsumer*> Subscriptions;
0034     std::map<std::string,EventHandler*> m_handlers;
0035     EventHandler* m_current;
0036     /// Data subscriptions (unordered)
0037     Subscriptions m_subscriptions;
0038 
0039     EventHandler* current() const;
0040   public:
0041     /// Standard constructor
0042     GenericEventHandler();
0043     /// Default destructor
0044     virtual ~GenericEventHandler();
0045     /// Access the map of simulation data collections
0046     virtual const TypedEventCollections& data()  const  override   { return current()->data();  }
0047     /// Access the number of events on the current input data source (-1 if no data source connected)
0048     virtual long numEvents() const  override;
0049     /// Access the data source name
0050     virtual std::string datasourceName() const  override;
0051     /// Access to the collection type by name
0052     virtual CollectionType collectionType(const std::string& collection) const  override;
0053     /// Loop over collection and extract data
0054     virtual size_t collectionLoop(const std::string& collection, DDEveHitActor& actor)  override;
0055     /// Loop over collection and extract particle data
0056     virtual size_t collectionLoop(const std::string& collection, DDEveParticleActor& actor)  override;
0057     /// Open a new event data file
0058     virtual bool Open(const std::string& type, const std::string& file_name)  override;
0059     /// Load the next event
0060     virtual bool NextEvent()  override;
0061     /// User overloadable function: Load the previous event
0062     virtual bool PreviousEvent()  override;
0063     /// Goto a specified event in the file
0064     virtual bool GotoEvent(long event_number)  override;
0065     /// Subscribe to notification of new data present
0066     virtual void Subscribe(EventConsumer* display);
0067     /// Unsubscribe from notification of new data present
0068     virtual void Unsubscribe(EventConsumer* display);
0069 
0070 #ifndef __CINT__
0071     /// Notfy all subscribers
0072     virtual void NotifySubscribers(void (EventConsumer::*pmf)(EventHandler&));
0073 #endif
0074  
0075     ClassDefOverride(GenericEventHandler,0);
0076   };
0077 } /* End namespace dd4hep   */
0078 
0079 #endif // DDEVE_GENERICEVENTHANDLER_H
0080