Geant4  10.02.p02
Par02Output Class Reference

Handling the saving to the file. More...

#include <Par02Output.hh>

+ Collaboration diagram for Par02Output:

Public Types

enum  SaveType {
  eNoSave, eSaveMC, eSaveTracker, eSaveEMCal,
  eSaveHCal
}
 Indicates to which ntuple to save the information. More...
 

Public Member Functions

void SetFileName (G4String name)
 Sets the file name of the output root file. More...
 
G4String GetFileName ()
 Gets the file name of the output root file. More...
 
void AppendName (G4bool app)
 Sets fFileNameWithRunNo that indicates whether to add the run number to the file name. More...
 
void StartAnalysis (G4int runID)
 Calls the G4AnalysisManager::Instance(). It sets the file name of the output file based on fFileName and fFileNameWithRunNo and opens the file. More...
 
void EndAnalysis ()
 Calls the G4AnalysisManager::Instance(). It writes to the output file and close it. More...
 
void CreateNtuples ()
 Creates Ntuples used to store information about particle (its ID, PDG code, energy deposits, etc.). To be called for each event in Par02EventAction. More...
 
void CreateHistograms ()
 Creates histograms to combine information from all the events in the run. To be called for each run in Par02RunAction. More...
 
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). More...
 
void FillHistogram (G4int HNo, G4double value) const
 Fills the histogram. More...
 
 ~Par02Output ()
 

Static Public Member Functions

static Par02OutputInstance ()
 Allows the access to the unique Par02Output object. More...
 

Protected Member Functions

 Par02Output ()
 A default, protected constructor (due to singleton pattern). More...
 

Private Attributes

G4String fFileName
 A name of the output root file. More...
 
G4bool fFileNameWithRunNo
 If true, a run number should be added to the file. Default: false. More...
 

Static Private Attributes

static Par02OutputfPar02Output = 0
 The pointer to the only Par02Output class object. More...
 
static G4ThreadLocal G4int fCurrentNtupleId = 0
 Current ntuple Id. More...
 
static G4ThreadLocal G4int fCurrentID = 0
 A control value of particle ID to ensure that data saved to various ntuples match the same particle. It is set when Monte Carlo information is saved and checked for all the detectors. More...
 

Detailed Description

Handling the saving to the file.

A singleton class that manages creation, writing to and closing of the Root output file.

Author
Anna Zaborowska

Definition at line 43 of file Par02Output.hh.

Member Enumeration Documentation

Indicates to which ntuple to save the information.

Enumerator
eNoSave 
eSaveMC 
eSaveTracker 
eSaveEMCal 
eSaveHCal 

Definition at line 47 of file Par02Output.hh.

Constructor & Destructor Documentation

Par02Output::~Par02Output ( )

Definition at line 54 of file Par02Output.cc.

Par02Output::Par02Output ( )
protected

A default, protected constructor (due to singleton pattern).

Definition at line 48 of file Par02Output.cc.

References fFileName.

Referenced by Instance().

+ Here is the caller graph for this function:

Member Function Documentation

void Par02Output::AppendName ( G4bool  app)

Sets fFileNameWithRunNo that indicates whether to add the run number to the file name.

Parameters
appIf add the run number.

Definition at line 75 of file Par02Output.cc.

References fFileNameWithRunNo.

void Par02Output::CreateHistograms ( )

Creates histograms to combine information from all the events in the run. To be called for each run in Par02RunAction.

Definition at line 146 of file Par02Output.cc.

References G4VAnalysisManager::CreateH1(), G4VAnalysisManager::SetH1XAxisTitle(), and G4VAnalysisManager::SetH1YAxisTitle().

Referenced by Par02RunAction::BeginOfRunAction().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Par02Output::CreateNtuples ( )

Creates Ntuples used to store information about particle (its ID, PDG code, energy deposits, etc.). To be called for each event in Par02EventAction.

Definition at line 108 of file Par02Output.cc.

References G4UIcommand::ConvertToString(), fCurrentNtupleId, G4RunManager::GetCurrentEvent(), and G4RunManager::GetRunManager().

Referenced by Par02EventAction::BeginOfEventAction().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Par02Output::EndAnalysis ( )

Calls the G4AnalysisManager::Instance(). It writes to the output file and close it.

Definition at line 100 of file Par02Output.cc.

References G4VAnalysisManager::CloseFile(), and G4VAnalysisManager::Write().

Referenced by Par02RunAction::EndOfRunAction().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Par02Output::FillHistogram ( G4int  HNo,
G4double  value 
) const

Fills the histogram.

Parameters
HNoNumber of a histogram (decided by the order of creation in CreateHistograms(), the first one is 0).
valueA value to be filled into the histogram.

Definition at line 219 of file Par02Output.cc.

References G4VAnalysisManager::FillH1().

Referenced by Par02FastSimModelEMCal::DoIt(), Par02FastSimModelHCal::DoIt(), and Par02FastSimModelTracker::DoIt().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

G4String Par02Output::GetFileName ( )

Gets the file name of the output root file.

Returns
The name of the file.

Definition at line 81 of file Par02Output.cc.

References fFileName.

Par02Output * Par02Output::Instance ( void  )
static

Allows the access to the unique Par02Output object.

Returns
A pointer to the Par02Output class.

Definition at line 60 of file Par02Output.cc.

References fPar02Output, and Par02Output().

Referenced by Par02EventAction::BeginOfEventAction(), Par02RunAction::BeginOfRunAction(), Par02FastSimModelEMCal::DoIt(), Par02FastSimModelHCal::DoIt(), Par02FastSimModelTracker::DoIt(), Par02RunAction::EndOfRunAction(), Par02RunAction::Par02RunAction(), Par02TrackingAction::PostUserTrackingAction(), and Par02RunAction::~Par02RunAction().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Par02Output::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).

Parameters
aWhatToSaveenum indicating what kind of information to store (in which ntuple).
aPartIDA unique ID within event (taken Geant TrackID).
aPDGA PDG code of a particle.
aVectorA vector to be stored (particle momentum in tracker or position of energy deposit in calorimeter).
aResolutionA resolution of the detector that was used.
aEfficiencyAn efficiency of the detector that was used.
aEnergyAn energy deposit (for calorimeters only: Par02Output::SaveType::eEMCal or Par02Output::SaveType::eHCal).

Definition at line 162 of file Par02Output.cc.

References G4VAnalysisManager::AddNtupleRow(), eNoSave, eSaveEMCal, eSaveHCal, eSaveMC, eSaveTracker, fCurrentID, fCurrentNtupleId, G4VAnalysisManager::FillNtupleDColumn(), G4VAnalysisManager::FillNtupleIColumn(), G4cout, and G4endl.

Referenced by Par02TrackingAction::PostUserTrackingAction().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Par02Output::SetFileName ( G4String  name)

Sets the file name of the output root file.

Parameters
nameThe name of the file.

Definition at line 69 of file Par02Output.cc.

References fFileName.

Referenced by Par02RunAction::Par02RunAction().

+ Here is the caller graph for this function:

void Par02Output::StartAnalysis ( G4int  runID)

Calls the G4AnalysisManager::Instance(). It sets the file name of the output file based on fFileName and fFileNameWithRunNo and opens the file.

Parameters
runIDA run number (to be added to file name if fFileNameWithRunNo is true).

Definition at line 87 of file Par02Output.cc.

References G4UIcommand::ConvertToString(), fFileName, fFileNameWithRunNo, G4VAnalysisManager::OpenFile(), G4VAnalysisManager::SetFileName(), and G4VAnalysisManager::SetVerboseLevel().

Referenced by Par02RunAction::BeginOfRunAction().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

G4ThreadLocal G4int Par02Output::fCurrentID = 0
staticprivate

A control value of particle ID to ensure that data saved to various ntuples match the same particle. It is set when Monte Carlo information is saved and checked for all the detectors.

Definition at line 129 of file Par02Output.hh.

Referenced by SaveTrack().

G4ThreadLocal G4int Par02Output::fCurrentNtupleId = 0
staticprivate

Current ntuple Id.

Definition at line 118 of file Par02Output.hh.

Referenced by CreateNtuples(), and SaveTrack().

G4String Par02Output::fFileName
private

A name of the output root file.

Definition at line 121 of file Par02Output.hh.

Referenced by GetFileName(), Par02Output(), SetFileName(), and StartAnalysis().

G4bool Par02Output::fFileNameWithRunNo
private

If true, a run number should be added to the file. Default: false.

Definition at line 124 of file Par02Output.hh.

Referenced by AppendName(), and StartAnalysis().

Par02Output * Par02Output::fPar02Output = 0
staticprivate

The pointer to the only Par02Output class object.

Definition at line 115 of file Par02Output.hh.

Referenced by Instance().


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