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_DDG4EVENTHANDLER_H
0014 #define DDEVE_DDG4EVENTHANDLER_H
0015 
0016 // Framework include files
0017 #include "DDEve/EventHandler.h"
0018 
0019 // C/C++ include files
0020 #include <map>
0021 #include <string>
0022 
0023 // Forward declarations
0024 class TTree;
0025 class TFile;
0026 class TBranch;
0027 
0028 /// Namespace for the AIDA detector description toolkit
0029 namespace dd4hep {
0030 
0031   /// Event I/O handler class for the dd4hep event display
0032   /* I/O handler for generic ROOT files produced by the DDG4 ROOT output stream
0033    * 
0034    * \author  M.Frank
0035    * \version 1.0
0036    * \ingroup DD4HEP_EVE
0037    */
0038   class DDG4EventHandler : public EventHandler  {
0039   public:
0040     typedef std::map<std::string,std::pair<TBranch*,void*> > Branches;
0041     typedef void* (*ParticleAccessor_t)(void*, DDEveParticle*);
0042     typedef void* (*HitAccessor_t)(void*, DDEveHit*);
0043   protected:
0044     /// Reference to data file
0045     std::pair<TFile*,TTree*> m_file;
0046     /// Branch map
0047     Branches m_branches;
0048     /// File entry number
0049     Long64_t m_entry;
0050     /// Function pointer to interprete hits
0051     HitAccessor_t m_simhitConverter;
0052     /// Function pointer to interprete particles
0053     ParticleAccessor_t m_particleConverter;
0054     /// Data collection map
0055     TypedEventCollections m_data;
0056   public:
0057     /// Standard constructor
0058     DDG4EventHandler();
0059     /// Default destructor
0060     virtual ~DDG4EventHandler();
0061 
0062     /// Access the map of simulation data collections
0063     virtual const TypedEventCollections& data()  const    override  { return m_data;  }
0064     /// Access the number of events on the current input data source (-1 if no data source connected)
0065     virtual long numEvents() const  override;
0066     /// Access the data source name
0067     std::string datasourceName() const  override;
0068     /// Access to the collection type by name
0069     virtual CollectionType collectionType(const std::string& collection) const  override;
0070     /// Call functor on hit collection
0071     virtual size_t collectionLoop(const std::string& collection, DDEveHitActor& actor)  override;
0072     /// Loop over collection and extract particle data
0073     virtual size_t collectionLoop(const std::string& collection, DDEveParticleActor& actor)  override;
0074     /// Open new data file
0075     virtual bool Open(const std::string& type, const std::string& file_name)  override;
0076     /// User overloadable function: Load the next event
0077     virtual bool NextEvent()  override;
0078     /// User overloadable function: Load the previous event
0079     virtual bool PreviousEvent()  override;
0080     /// Goto a specified event in the file
0081     virtual bool GotoEvent(long event_number)  override;
0082     /// Load the specified event
0083     Int_t ReadEvent(Long64_t n);
0084 
0085     ClassDefOverride(DDG4EventHandler,0);
0086   };
0087 
0088 }      /* End namespace dd4hep            */
0089 #endif // DDEVE_DDG4EVENTHANDLER_H
0090