DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geant4OutputAction.h
Go to the documentation of this file.
1 // $Id: $
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 #ifndef DD4HEP_DDG4_GEANT4OUTPUTACTION_H
15 #define DD4HEP_DDG4_GEANT4OUTPUTACTION_H
16 
17 // Framework include files
18 #include "DDG4/Geant4EventAction.h"
19 
20 // Forward declarations
21 class G4Run;
22 class G4Event;
23 class G4VHitsCollection;
24 
25 
27 namespace DD4hep {
28 
30  namespace Simulation {
31 
32  // Forward declarations
33  class Geant4ParticleMap;
34 
36 
42  protected:
44  template <typename T> class OutputContext {
45  public:
46  const T* context;
47  void* userData;
48  OutputContext(const T* c)
49  : context(c), userData(0) {
50  }
51  template <typename U> U* data() const {
52  return (U*) userData;
53  }
54  };
55 
57  std::string m_output;
62  public:
64  Geant4OutputAction(Geant4Context* c, const std::string& nam);
66  virtual ~Geant4OutputAction();
68  virtual void configureFiber(Geant4Context* ctxt);
69 
71  virtual void begin(const G4Event* event);
73  virtual void end(const G4Event* event);
75  virtual void beginRun(const G4Run* run);
77  virtual void endRun(const G4Run* run);
78 
80  virtual void saveRun(const G4Run* run);
82  virtual void saveEvent(OutputContext<G4Event>& ctxt);
84  virtual void saveCollection(OutputContext<G4Event>& ctxt, G4VHitsCollection* collection);
86  virtual void commit(OutputContext<G4Event>& ctxt);
87  };
88 
89  } // End namespace Simulation
90 } // End namespace DD4hep
91 #endif // DD4HEP_DDG4_GEANT4OUTPUTACTION_H
virtual void saveRun(const G4Run *run)
Callback to store the Geant4 event.
virtual void configureFiber(Geant4Context *ctxt)
Set or update client for the use in a new thread fiber.
virtual void end(const G4Event *event)
End-of-event callback.
virtual void saveEvent(OutputContext< G4Event > &ctxt)
Callback to store the Geant4 event.
virtual void begin(const G4Event *event)
begin-of-event callback
virtual void commit(OutputContext< G4Event > &ctxt)
Commit data at end of filling procedure.
Geant4OutputAction(Geant4Context *c, const std::string &nam)
Standard constructor.
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:40
Concrete basic implementation of the Geant4 event action.
virtual ~Geant4OutputAction()
Default destructor.
Geant4ParticleMap * m_truth
Reference to MC truth object.
Data structure to map particles produced during the generation and the simulation.
virtual void beginRun(const G4Run *run)
Callback to initialize storing the Geant4 information.
virtual void saveCollection(OutputContext< G4Event > &ctxt, G4VHitsCollection *collection)
Callback to store each Geant4 hit collection.
virtual void endRun(const G4Run *run)
Callback to store the Geant4 run information.
Generic context to extend user, run and event information.
bool m_errorFatal
Property: "HandleErrorsAsFatal" Handle errors as fatal and rethrow eventual exceptions.
Base class to output Geant4 event data to persistent media.
std::string m_output
Property: "Output" output destination.