DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
DDG4EventHandler.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DDEVE_DDG4EVENTHANDLER_H
14 #define DDEVE_DDG4EVENTHANDLER_H
15 
16 // Framework include files
17 #include "DDEve/EventHandler.h"
18 
19 // C/C++ include files
20 #include <map>
21 #include <string>
22 
23 // Forward declarations
24 class TTree;
25 class TFile;
26 class TBranch;
27 
29 namespace dd4hep {
30 
32  /* I/O handler for generic ROOT files produced by the DDG4 ROOT output stream
33  *
34  * \author M.Frank
35  * \version 1.0
36  * \ingroup DD4HEP_EVE
37  */
38  class DDG4EventHandler : public EventHandler {
39  public:
40  typedef std::map<std::string,std::pair<TBranch*,void*> > Branches;
41  typedef void* (*ParticleAccessor_t)(void*, DDEveParticle*);
42  typedef void* (*HitAccessor_t)(void*, DDEveHit*);
43  protected:
45  std::pair<TFile*,TTree*> m_file;
49  Long64_t m_entry;
56  public:
60  virtual ~DDG4EventHandler();
61 
63  virtual const TypedEventCollections& data() const override { return m_data; }
65  virtual long numEvents() const override;
67  std::string datasourceName() const override;
69  virtual CollectionType collectionType(const std::string& collection) const override;
71  virtual size_t collectionLoop(const std::string& collection, DDEveHitActor& actor) override;
73  virtual size_t collectionLoop(const std::string& collection, DDEveParticleActor& actor) override;
75  virtual bool Open(const std::string& type, const std::string& file_name) override;
77  virtual bool NextEvent() override;
79  virtual bool PreviousEvent() override;
81  virtual bool GotoEvent(long event_number) override;
83  Int_t ReadEvent(Long64_t n);
84 
86  };
87 
88 } /* End namespace dd4hep */
89 #endif // DDEVE_DDG4EVENTHANDLER_H
90 
dd4hep::DDEveParticleActor
Event data actor base class for particles. Used to extract data from concrete classes.
Definition: EventHandler.h:55
dd4hep::DDEveHit
DDEve event classes: Basic hit.
Definition: DDEveEventData.h:29
dd4hep::DDG4EventHandler::Open
virtual bool Open(const std::string &type, const std::string &file_name) override
Open new data file.
Definition: DDG4EventHandler.cpp:189
dd4hep::DDG4EventHandler::m_file
std::pair< TFile *, TTree * > m_file
Reference to data file.
Definition: DDG4EventHandler.h:45
dd4hep::EventHandler
Event handler base class: Interface to all DDEve I/O actions.
Definition: EventHandler.h:67
dd4hep::DDG4EventHandler
Event I/O handler class for the dd4hep event display.
Definition: DDG4EventHandler.h:38
dd4hep::DDG4EventHandler::ReadEvent
Int_t ReadEvent(Long64_t n)
Load the specified event.
Definition: DDG4EventHandler.cpp:158
dd4hep::DDG4EventHandler::GotoEvent
virtual bool GotoEvent(long event_number) override
Goto a specified event in the file.
Definition: DDG4EventHandler.cpp:81
dd4hep::DDEveHitActor
Event data actor base class for hits. Used to extract data from concrete classes.
Definition: EventHandler.h:43
dd4hep::DDG4EventHandler::PreviousEvent
virtual bool PreviousEvent() override
User overloadable function: Load the previous event.
Definition: DDG4EventHandler.cpp:76
dd4hep::DDG4EventHandler::collectionLoop
virtual size_t collectionLoop(const std::string &collection, DDEveHitActor &actor) override
Call functor on hit collection.
Definition: DDG4EventHandler.cpp:118
dd4hep::DDG4EventHandler::m_particleConverter
ParticleAccessor_t m_particleConverter
Function pointer to interprete particles.
Definition: DDG4EventHandler.h:53
dd4hep::DDG4EventHandler::data
virtual const TypedEventCollections & data() const override
Access the map of simulation data collections.
Definition: DDG4EventHandler.h:63
dd4hep::DDG4EventHandler::Branches
std::map< std::string, std::pair< TBranch *, void * > > Branches
Definition: DDG4EventHandler.h:40
dd4hep::DDG4EventHandler::m_simhitConverter
HitAccessor_t m_simhitConverter
Function pointer to interprete hits.
Definition: DDG4EventHandler.h:51
dd4hep::DDG4EventHandler::m_branches
Branches m_branches
Branch map.
Definition: DDG4EventHandler.h:47
EventHandler.h
dd4hep::EventHandler::CollectionType
CollectionType
Definition: EventHandler.h:69
dd4hep::DDG4EventHandler::~DDG4EventHandler
virtual ~DDG4EventHandler()
Default destructor.
Definition: DDG4EventHandler.cpp:61
dd4hep::DDG4EventHandler::numEvents
virtual long numEvents() const override
Access the number of events on the current input data source (-1 if no data source connected)
Definition: DDG4EventHandler.cpp:86
dd4hep::DDG4EventHandler::datasourceName
std::string datasourceName() const override
Access the data source name.
Definition: DDG4EventHandler.cpp:94
dd4hep::DDG4EventHandler::ParticleAccessor_t
void *(* ParticleAccessor_t)(void *, DDEveParticle *)
Definition: DDG4EventHandler.h:41
dd4hep::DDG4EventHandler::m_data
TypedEventCollections m_data
Data collection map.
Definition: DDG4EventHandler.h:55
dd4hep::DDG4EventHandler::HitAccessor_t
void *(* HitAccessor_t)(void *, DDEveHit *)
Definition: DDG4EventHandler.h:42
dd4hep::DDG4EventHandler::ClassDefOverride
ClassDefOverride(DDG4EventHandler, 0)
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::DDG4EventHandler::NextEvent
virtual bool NextEvent() override
User overloadable function: Load the next event.
Definition: DDG4EventHandler.cpp:71
dd4hep::DDG4EventHandler::collectionType
virtual CollectionType collectionType(const std::string &collection) const override
Access to the collection type by name.
Definition: DDG4EventHandler.cpp:102
dd4hep::DDEveParticle
Data structure to store the MC particle information.
Definition: DDEveEventData.h:56
dd4hep::EventHandler::TypedEventCollections
std::map< std::string, std::vector< Collection > > TypedEventCollections
Types collection: collections are grouped by type (class name)
Definition: EventHandler.h:80
dd4hep::DDG4EventHandler::DDG4EventHandler
DDG4EventHandler()
Standard constructor.
Definition: DDG4EventHandler.cpp:47
dd4hep::DDG4EventHandler::m_entry
Long64_t m_entry
File entry number.
Definition: DDG4EventHandler.h:49