SToGS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
SToGS_Ascii.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //----------------------------------------------------------------------------
27 
28 #ifndef SToGS_Ascii_h
29 #define SToGS_Ascii_h 1
30 
32 #include "G4Run.hh"
33 
34 #include <vector>
35 #include <fstream>
36 
38 namespace SToGS {
40 
42  class AsciiRun : public G4Run
43  {
44  protected:
46  G4int collcaloID;
47  protected:
49  std::ofstream &fOutputFile;
50  protected:
52  //std::pair < char, char > fEventMarkOff;
53 
54  public:
55  AsciiRun(std::ofstream &out);
56  virtual ~AsciiRun();
57 
58  virtual void RecordEvent(const G4Event* evt);
59  //virtual void Merge(const G4Run*);
60  };
62 
65  class AsciiAction : public AllActions
66  {
67  protected:
69  std::ofstream fOutputFile;
70  protected:
72  G4String fPathToData;
74  G4String fBaseName;
76  G4int fMaxEvents;
80  G4int fPrintModulo;
81 
82  protected:
84  // std::pair<G4int, G4int> HitsinCollection(const G4Event);
85 
87  virtual void OpenFile(G4int run_id);
89  virtual void CloseFile();
90 
91  public:
92  AsciiAction(G4String conffile = "setup/SToGS_ascii_actions.conf");
93  virtual ~AsciiAction()
94  {;}
95 
96  virtual G4Run* GenerateRun();
97 
98  virtual void BeginOfRunAction(const G4Run * /*therun*/);
99  virtual void EndOfRunAction(const G4Run * /*therun*/);
100  virtual void BeginOfEventAction(const G4Event * /*event*/);
101  virtual void EndOfEventAction(const G4Event * /*event*/);
102  // virtual void PreUserTrackingAction(const G4Track * /*atrack*/);
103  // virtual void PostUserTrackingAction(const G4Track * /*atrack*/);
104  // virtual void UserSteppingAction(const G4Step * /*step*/);
105  };
107 
109  class Ascii : public AllInOneUserActionInitialization<AsciiAction>
110  {
111  public:
112  Ascii(G4String conf = "setup/SToGS_ascii_actions.conf", G4String which_gene = "GPS", G4String which_gene_opt = "G4Macros/GPSPointLike.mac"):
113  AllInOneUserActionInitialization<AsciiAction>(conf,which_gene,which_gene_opt)
114  {;}
115  virtual ~Ascii()
116  {;}
117  };
118 
119 } // SToGS Namespace
120 
121 #endif /* SToGS_Ascii.hh */
122 
123 
124 
125 
virtual void EndOfRunAction(const G4Run *)
Definition: SToGS_Ascii.cc:272
virtual void BeginOfEventAction(const G4Event *)
Definition: SToGS_Ascii.cc:278
Extract informations from Geant4 using SToGS sensitives and write hits in ascii files.
Definition: SToGS_Ascii.hh:109
a G4 user's action manage by a single AllAction class
virtual ~AsciiRun()
Definition: SToGS_Ascii.cc:57
AsciiRun(std::ofstream &out)
A new event in the file starts/ends with the following characters.
Definition: SToGS_Ascii.cc:40
virtual ~Ascii()
Definition: SToGS_Ascii.hh:115
virtual void EndOfEventAction(const G4Event *)
Definition: SToGS_Ascii.cc:285
std::ofstream fOutputFile
current stream to output data
Definition: SToGS_Ascii.hh:69
virtual void BeginOfRunAction(const G4Run *)
Definition: SToGS_Ascii.cc:265
virtual G4Run * GenerateRun()
Definition: SToGS_Ascii.cc:247
G4int fMaxEvents
max numer of event per files ... better to limit because of ascii file could be uged ! ...
Definition: SToGS_Ascii.hh:76
G4int fRecordOption
0 [default] means keep all, 1 only events which gives at least one hit in the full detector ...
Definition: SToGS_Ascii.hh:78
AsciiAction(G4String conffile="setup/SToGS_ascii_actions.conf")
Definition: SToGS_Ascii.cc:150
This class just print out once a new run begins/ends with the run number and the number of events to ...
Definition: SToGS_Ascii.hh:65
G4String fBaseName
base for all the files
Definition: SToGS_Ascii.hh:74
std::ofstream & fOutputFile
current stream to output data
Definition: SToGS_Ascii.hh:49
virtual void CloseFile()
Make sure ths file is closed properly.
Definition: SToGS_Ascii.cc:231
virtual void OpenFile(G4int run_id)
Just check if there are collected hits in the collection.
Definition: SToGS_Ascii.cc:197
virtual void RecordEvent(const G4Event *evt)
Definition: SToGS_Ascii.cc:61
virtual ~AsciiAction()
Definition: SToGS_Ascii.hh:93
Base class that regroups in the same space all user's hooks. Convenient for sharing similar data...
G4int fPrintModulo
to print out status any fPrintModulo events
Definition: SToGS_Ascii.hh:80
Ascii(G4String conf="setup/SToGS_ascii_actions.conf", G4String which_gene="GPS", G4String which_gene_opt="G4Macros/GPSPointLike.mac")
Definition: SToGS_Ascii.hh:112
G4String fPathToData
directory where to output data
Definition: SToGS_Ascii.hh:72