Loading...
Searching...
No Matches
Par02Output.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/// \file Par02Output.hh
28/// \brief Definition of the Par02Output class
29
30#ifndef PAR02_OUTPUT_H
31#define PAR02_OUTPUT_H
32
33#include "G4ThreeVector.hh"
34#include "globals.hh"
35
36/// Handling the saving to the file.
37///
38/// A singleton class that manages creation, writing to and closing of the
39/// Root output file.
40/// @author Anna Zaborowska
41
42class Par02Output {
43 public:
44
45 /// Indicates to which ntuple to save the information.
47
48 /// Allows the access to the unique Par02Output object.
49 /// @return A pointer to the Par02Output class.
50 static Par02Output* Instance();
51
52 /// Sets the file name of the output root file.
53 /// @param name The name of the file.
54 void SetFileName( G4String name );
55
56 /// Gets the file name of the output root file.
57 /// @return The name of the file.
59
60 /// Sets fFileNameWithRunNo that indicates whether to add the run number
61 /// to the file name.
62 /// @param app If add the run number.
63 void AppendName( G4bool app );
64
65 /// Calls the G4AnalysisManager::Instance(). It sets the file name of the
66 /// output file based on fFileName and fFileNameWithRunNo and opens the file.
67 /// @param runID A run number (to be added to file name if fFileNameWithRunNo
68 /// is true).
69 void StartAnalysis( G4int runID );
70
71 /// Calls the G4AnalysisManager::Instance().
72 /// It writes to the output file and close it.
73 void EndAnalysis();
74
75 /// Creates Ntuples used to store information about particle (its ID, PDG code,
76 /// energy deposits, etc.). To be called for each event in Par02EventAction.
77 void CreateNtuples();
78
79 /// Creates histograms to combine information from all the events in the run.
80 /// To be called for each run in Par02RunAction.
81 void CreateHistograms();
82
83 /// Saves the information about the particle (track).
84 /// @param aWhatToSave enum indicating what kind of information to store
85 /// (in which ntuple).
86 /// @param aPartID A unique ID within event (taken Geant TrackID).
87 /// @param aPDG A PDG code of a particle.
88 /// @param aVector A vector to be stored (particle momentum in tracker or
89 /// position of energy deposit in calorimeter).
90 /// @param aResolution A resolution of the detector that was used.
91 /// @param aEfficiency An efficiency of the detector that was used.
92 /// @param aEnergy An energy deposit (for calorimeters only:
93 /// Par02Output::SaveType::eEMCal or Par02Output::SaveType::eHCal).
94 void SaveTrack( SaveType aWhatToSave, G4int aPartID, G4int aPDG,
95 G4ThreeVector aVector, G4double aResolution = 0,
96 G4double aEfficiency = 1, G4double aEnergy = 0 ) ;
97
98 /// Fills the histogram.
99 /// @param HNo Number of a histogram (decided by the order of creation
100 /// in CreateHistograms(), the first one is 0).
101 /// @param value A value to be filled into the histogram.
102 void FillHistogram( G4int HNo, G4double value ) const;
103
105
106 protected:
107
108 /// A default, protected constructor (due to singleton pattern).
109 Par02Output();
110
111 private:
112
113 /// The pointer to the only Par02Output class object.
115
116 /// Current ntuple Id
117 static G4ThreadLocal G4int fCurrentNtupleId;
118
119 /// A name of the output root file.
121
122 /// If true, a run number should be added to the file. Default: false.
124
125 /// A control value of particle ID to ensure that data saved to various ntuples
126 /// match the same particle. It is set when Monte Carlo information is saved
127 /// and checked for all the detectors.
128 static G4ThreadLocal G4int fCurrentID;
129};
130
131#endif
132
Handling the saving to the file.
static G4ThreadLocal G4int fCurrentNtupleId
Current ntuple Id.
void CreateHistograms()
Creates histograms to combine information from all the events in the run.
G4bool fFileNameWithRunNo
If true, a run number should be added to the file. Default: false.
void AppendName(G4bool app)
Sets fFileNameWithRunNo that indicates whether to add the run number to the file name.
void FillHistogram(G4int HNo, G4double value) const
Fills the histogram.
void CreateNtuples()
Creates Ntuples used to store information about particle (its ID, PDG code, energy deposits,...
void SetFileName(G4String name)
Sets the file name of the output root file.
void SaveTrack(SaveType aWhatToSave, G4int aPartID, G4int aPDG, G4ThreeVector aVector, G4double aResolution=0, G4double aEfficiency=1, G4double aEnergy=0)
Saves the information about the particle (track).
void StartAnalysis(G4int runID)
Calls the G4AnalysisManager::Instance().
static Par02Output * fPar02Output
The pointer to the only Par02Output class object.
G4String fFileName
A name of the output root file.
void EndAnalysis()
Calls the G4AnalysisManager::Instance().
SaveType
Indicates to which ntuple to save the information.
static G4ThreadLocal G4int fCurrentID
A control value of particle ID to ensure that data saved to various ntuples match the same particle.
Par02Output()
A default, protected constructor (due to singleton pattern).
G4String GetFileName()
Gets the file name of the output root file.
static Par02Output * Instance()
Allows the access to the unique Par02Output object.

Applications | User Support | Publications | Collaboration