SToGS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
SToGS_BaseROOT.hh
Go to the documentation of this file.
1 
2 //
3 // ********************************************************************
4 // * License and Disclaimer *
5 // * *
6 // * The Geant4 software is copyright of the Copyright Holders of *
7 // * the Geant4 Collaboration. It is provided under the terms and *
8 // * conditions of the Geant4 Software License, included in the file *
9 // * LICENSE and available at http://cern.ch/geant4/license . These *
10 // * include a list of copyright holders. *
11 // * *
12 // * Neither the authors of this software system, nor their employing *
13 // * institutes,nor the agencies providing financial support for this *
14 // * work make any representation or warranty, express or implied, *
15 // * regarding this software system or assume any liability for its *
16 // * use. Please see the license in the file LICENSE and URL above *
17 // * for the full disclaimer and the limitation of liability. *
18 // * *
19 // * This code implementation is the result of the scientific and *
20 // * technical work of the GEANT4 collaboration. *
21 // * By using, copying, modifying or distributing the software (or *
22 // * any work based on the software) you agree to acknowledge its *
23 // * use in resulting scientific publications, and indicate your *
24 // * acceptance of all terms of the Geant4 Software license. *
25 // ********************************************************************
26 //
27 //----------------------------------------------------------------------------
28 
29 #ifndef SToGS_BaseROOT_h
30 #define SToGS_BaseROOT_h 1
31 
33 #include "G4Run.hh"
34 
35 class TFile;
36 class TTree;
37 
39 namespace SToGS {
41 
43  class BaseROOTTreeRun : public G4Run
44  {
45  protected:
47  protected:
49  G4int collcaloID;
50 
51  public:
52  BaseROOTTreeRun(G4int record_option = 0);
53  virtual ~BaseROOTTreeRun();
54 
55  //virtual void RecordEvent(const G4Event* evt);
56  //virtual void Merge(const G4Run*);
57  };
59 
62  class BaseROOTAction : public AllActions
63  {
64  protected:
66  TFile *fRootFile;
67  protected:
69  G4String fPathToData;
71  G4String fBaseName;
73  G4int fMaxEvents;
77  G4int fPrintModulo;
78  protected:
80  // std::pair<G4int, G4int> HitsinCollection(const G4Event);
81 
83  virtual void OpenFile(G4int run_id);
85  virtual void CloseFile();
86 
87  public:
88  BaseROOTAction(G4String conffile = "setup/SToGS_root_actions.conf");
89  virtual ~BaseROOTAction()
90  {;}
91 
92  virtual void BeginOfRunAction(const G4Run * /*therun*/);
93  virtual void EndOfRunAction(const G4Run * /*therun*/);
94  virtual void BeginOfEventAction(const G4Event * /*event*/);
95  virtual void EndOfEventAction(const G4Event * /*event*/);
96  virtual void PreUserTrackingAction(const G4Track * /*atrack*/)
97  {;}
98  virtual void PostUserTrackingAction(const G4Track * /*atrack*/)
99  {;}
100  // virtual void UserSteppingAction(const G4Step * /*step*/);
101  };
103  {
104  protected:
106  TTree *fTree;
107 
108  protected:
109  G4String fTreeName;
110  G4String fTreeTitle;
111 
112  protected:
114  virtual void OpenFile(G4int run_id);
116  virtual void CloseFile();
117 
118  public:
119  BaseROOTTreeAction(G4String conffile = "setup/SToGS_root_actions.conf");
120  virtual ~BaseROOTTreeAction();
121  };
122 
124 
126  class BaseROOTTree : public AllInOneUserActionInitialization<BaseROOTTreeAction>
127  {
128  public:
129  BaseROOTTree(G4String conf = "setup/SToGS_root_actions.conf", G4String which_gene = "GPS", G4String which_gene_opt = "G4Macros/GPSPointLike.mac"):
130  AllInOneUserActionInitialization<BaseROOTTreeAction>(conf,which_gene,which_gene_opt)
131  {;}
132  virtual ~BaseROOTTree()
133  {;}
134  };
135 
136 } // SToGS Namespace
137 
138 
139 #endif
Extract informations from Geant4 using SToGS sensitives and write hits in root tree.
G4String fBaseName
base for all the files
BaseROOTAction(G4String conffile="setup/SToGS_root_actions.conf")
BaseROOTTreeAction(G4String conffile="setup/SToGS_root_actions.conf")
TFile * fRootFile
the current root file
a G4 user's action manage by a single AllAction class
virtual void CloseFile()
Make sure ths file is closed properly.
virtual void PostUserTrackingAction(const G4Track *)
virtual void EndOfRunAction(const G4Run *)
virtual void PreUserTrackingAction(const G4Track *)
virtual void OpenFile(G4int run_id)
Open the stream depending of the configuration and attach the Tree to the file.
BaseROOTTree(G4String conf="setup/SToGS_root_actions.conf", G4String which_gene="GPS", G4String which_gene_opt="G4Macros/GPSPointLike.mac")
G4int fRecordOption
0 [default] means keep all, 1 only events which gives at least one hit in the full detector ...
virtual void BeginOfRunAction(const G4Run *)
TTree * fTree
the Tree to be filled
G4int fPrintModulo
to print out status any fPrintModulo events
virtual void EndOfEventAction(const G4Event *)
G4String fPathToData
directory where to output data
This class just print out once a new run begins/ends with the run number and the number of events to ...
G4int fMaxEvents
max numer of event per files ... better to limit because of BaseROOT file could be uged ! ...
virtual void BeginOfEventAction(const G4Event *)
virtual void CloseFile()
Make sure ths file is closed properly.
virtual void OpenFile(G4int run_id)
Just check if there are collected hits in the collection.
BaseROOTTreeRun(G4int record_option=0)
Base class that regroups in the same space all user's hooks. Convenient for sharing similar data...