Public Member Functions | Private Member Functions | Private Attributes | List of all members
EDepSim::RootPersistencyManager Class Reference

#include <EDepSimRootPersistencyManager.hh>

Inheritance diagram for EDepSim::RootPersistencyManager:
EDepSim::PersistencyManager

Public Member Functions

 RootPersistencyManager ()
 
virtual ~RootPersistencyManager ()
 
bool IsOpen ()
 
TFile * GetTFile () const
 Return a pointer to the current TFile. More...
 
virtual G4bool Store (const G4Event *anEvent)
 Stores an event to the output file. More...
 
virtual G4bool Store (const G4Run *aRun)
 
virtual G4bool Store (const G4VPhysicalVolume *aWorld)
 
virtual G4bool Retrieve (G4Event *&e)
 Retrieve information from a file. These are not implemented. More...
 
virtual G4bool Retrieve (G4Run *&r)
 
virtual G4bool Retrieve (G4VPhysicalVolume *&w)
 
virtual G4bool Open (G4String dbname)
 
virtual G4bool Close (void)
 Make sure the output file is closed. More...
 
- Public Member Functions inherited from EDepSim::PersistencyManager
 PersistencyManager ()
 
virtual ~PersistencyManager ()
 
const TG4EventGetEventSummary ()
 
const std::vector< TG4PrimaryVertex > & GetPrimaries () const
 
const std::vector< TG4Trajectory > & GetTrajectories () const
 
const TG4HitSegmentDetectorsGetSegmentDetectors () const
 
virtual G4String GetFilename (void) const
 Return the output file name. More...
 
virtual void SetLengthThreshold (G4double thresh)
 
virtual G4double GetLengthThreshold () const
 Get the threshold for length in a sensitive detector. More...
 
virtual void SetGammaThreshold (G4double thresh)
 
virtual G4double GetGammaThreshold () const
 
virtual void SetNeutronThreshold (G4double thresh)
 
virtual G4double GetNeutronThreshold () const
 
virtual void SetTrajectoryPointAccuracy (double acc)
 
virtual double GetTrajectoryPointAccuracy (void) const
 
virtual void SetTrajectoryPointDeposit (double dep)
 
virtual double GetTrajectoryPointDeposit (void) const
 
virtual void SetSaveAllPrimaryTrajectories (bool val)
 
virtual bool GetSaveAllPrimaryTrajectories (void) const
 
virtual void AddTrajectoryBoundary (const G4String &boundary)
 
virtual void ClearTrajectoryBoundaries ()
 
void SetDetectorPartition (int partition)
 Set the detector mask. More...
 
int GetDetectorPartition () const
 Get the detector partition. More...
 

Private Member Functions

void MakeMCHeader (const G4Event *src)
 Make the MC Header and add it to truth. More...
 

Private Attributes

TFile * fOutput
 The ROOT output file that events are saved into. More...
 
TTree * fEventTree
 The event tree that contains the output events. More...
 
int fEventsNotSaved
 The number of events saved to the output file since the last write. More...
 

Additional Inherited Members

- Protected Member Functions inherited from EDepSim::PersistencyManager
void SetFilename (G4String file)
 
void UpdateSummaries (const G4Event *event)
 Update the event summary fields. More...
 
- Protected Attributes inherited from EDepSim::PersistencyManager
TG4Event fEventSummary
 A summary of the primary vertices in the event. More...
 

Detailed Description

Definition at line 20 of file EDepSimRootPersistencyManager.hh.

Constructor & Destructor Documentation

EDepSim::RootPersistencyManager::RootPersistencyManager ( )

Creates a root persistency manager. Through the "magic" of G4VPersistencyManager the ultimate base class, this declared to the G4 persistency management system. You can only have one active persistency class at any give moment.

Definition at line 20 of file EDepSimRootPersistencyManager.cc.

TFile * fOutput
The ROOT output file that events are saved into.
TTree * fEventTree
The event tree that contains the output events.
EDepSim::RootPersistencyManager::~RootPersistencyManager ( )
virtual

Definition at line 23 of file EDepSimRootPersistencyManager.cc.

23  {
24  if (fOutput) delete fOutput;
25  fOutput = NULL;
26 }
TFile * fOutput
The ROOT output file that events are saved into.

Member Function Documentation

bool EDepSim::RootPersistencyManager::Close ( void  )
virtual

Make sure the output file is closed.

Make sure the output file is closed. This is used to make sure that any information being summarized has been saved.

Reimplemented from EDepSim::PersistencyManager.

Definition at line 60 of file EDepSimRootPersistencyManager.cc.

60  {
61  if (!fOutput) {
62  EDepSimError("EDepSim::RootPersistencyManager::Close "
63  << "-- No Output File");
64  return false;
65  }
66 
67  fOutput->cd();
68 
69  fOutput->Write();
70  fOutput->Close();
71 
72  fEventTree = NULL;
73 
74  return true;
75 }
TFile * fOutput
The ROOT output file that events are saved into.
#define EDepSimError(outStream)
Definition: EDepSimLog.hh:503
TTree * fEventTree
The event tree that contains the output events.
TFile* EDepSim::RootPersistencyManager::GetTFile ( ) const
inline

Return a pointer to the current TFile.

Definition at line 34 of file EDepSimRootPersistencyManager.hh.

34 {return fOutput;}
TFile * fOutput
The ROOT output file that events are saved into.
bool EDepSim::RootPersistencyManager::IsOpen ( )

Return true if the ROOT output file is active. This means that the output file is open and ready to accept data.

Definition at line 28 of file EDepSimRootPersistencyManager.cc.

28  {
29  if (fOutput && fOutput->IsOpen()) {
30  fOutput->cd();
31  return true;
32  }
33  return false;
34 }
TFile * fOutput
The ROOT output file that events are saved into.
void EDepSim::RootPersistencyManager::MakeMCHeader ( const G4Event *  src)
private

Make the MC Header and add it to truth.

bool EDepSim::RootPersistencyManager::Open ( G4String  dbname)
virtual

Interface with PersistencyMessenger (open and close the database).

Reimplemented from EDepSim::PersistencyManager.

Definition at line 36 of file EDepSimRootPersistencyManager.cc.

36  {
37  if (fOutput) {
38  EDepSimLog("EDepSim::RootPersistencyManager::Open "
39  << "-- Delete current file pointer" );
40  }
41 
43 
44  EDepSimLog("EDepSim::RootPersistencyManager::Open " << GetFilename());
45 
46  fOutput = TFile::Open(GetFilename(), "RECREATE", "EDepSim Root Output");
47  fOutput->cd();
48 
49  fEventTree = new TTree("EDepSimEvents",
50  "Energy Deposition for Simulated Events");
51 
52  static TG4Event *pEvent = &fEventSummary;
53  fEventTree->Branch("Event","TG4Event",&pEvent);
54 
55  fEventsNotSaved = 0;
56 
57  return true;
58 }
#define EDepSimLog(outStream)
Definition: EDepSimLog.hh:717
int fEventsNotSaved
The number of events saved to the output file since the last write.
virtual G4String GetFilename(void) const
Return the output file name.
string filename
Definition: train.py:213
TG4Event fEventSummary
A summary of the primary vertices in the event.
TFile * fOutput
The ROOT output file that events are saved into.
TTree * fEventTree
The event tree that contains the output events.
virtual G4bool EDepSim::RootPersistencyManager::Retrieve ( G4Event *&  e)
inlinevirtual

Retrieve information from a file. These are not implemented.

Reimplemented from EDepSim::PersistencyManager.

Definition at line 42 of file EDepSimRootPersistencyManager.hh.

42 {e=NULL; return false;}
const double e
virtual G4bool EDepSim::RootPersistencyManager::Retrieve ( G4Run *&  r)
inlinevirtual

Reimplemented from EDepSim::PersistencyManager.

Definition at line 43 of file EDepSimRootPersistencyManager.hh.

43 {r=NULL; return false;}
virtual G4bool EDepSim::RootPersistencyManager::Retrieve ( G4VPhysicalVolume *&  w)
inlinevirtual

Reimplemented from EDepSim::PersistencyManager.

Definition at line 44 of file EDepSimRootPersistencyManager.hh.

44 {w=NULL; return false;}
bool EDepSim::RootPersistencyManager::Store ( const G4Event *  anEvent)
virtual

Stores an event to the output file.

Reimplemented from EDepSim::PersistencyManager.

Definition at line 77 of file EDepSimRootPersistencyManager.cc.

77  {
78  if (!fOutput) {
79  EDepSimError("EDepSim::RootPersistencyManager::Store "
80  << "-- No Output File");
81  return false;
82  }
83 
84  UpdateSummaries(anEvent);
85 
86  fOutput->cd();
87 
88  fEventTree->Fill();
89 
90  return true;
91 }
TFile * fOutput
The ROOT output file that events are saved into.
#define EDepSimError(outStream)
Definition: EDepSimLog.hh:503
TTree * fEventTree
The event tree that contains the output events.
void UpdateSummaries(const G4Event *event)
Update the event summary fields.
bool EDepSim::RootPersistencyManager::Store ( const G4Run *  aRun)
virtual

Reimplemented from EDepSim::PersistencyManager.

Definition at line 93 of file EDepSimRootPersistencyManager.cc.

93  {
94  return false;
95 }
bool EDepSim::RootPersistencyManager::Store ( const G4VPhysicalVolume *  aWorld)
virtual

Reimplemented from EDepSim::PersistencyManager.

Definition at line 97 of file EDepSimRootPersistencyManager.cc.

97  {
98  if (!fOutput) {
99  EDepSimError("EDepSim::RootPersistencyManager::Store "
100  << "-- No Output File");
101  return false;
102  }
103  if (!gGeoManager) {
104  EDepSimError("EDepSim::RootPersistencyManage::Store(world)"
105  << " -- Cannot be run before /edep/update");
106  return false;
107  }
108  fOutput->cd();
109  gGeoManager->Write();
110  return true;
111 }
TFile * fOutput
The ROOT output file that events are saved into.
#define EDepSimError(outStream)
Definition: EDepSimLog.hh:503

Member Data Documentation

int EDepSim::RootPersistencyManager::fEventsNotSaved
private

The number of events saved to the output file since the last write.

Definition at line 63 of file EDepSimRootPersistencyManager.hh.

TTree* EDepSim::RootPersistencyManager::fEventTree
private

The event tree that contains the output events.

Definition at line 60 of file EDepSimRootPersistencyManager.hh.

TFile* EDepSim::RootPersistencyManager::fOutput
private

The ROOT output file that events are saved into.

Definition at line 57 of file EDepSimRootPersistencyManager.hh.


The documentation for this class was generated from the following files: