Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Par02Output Class Reference

#include <Par02Output.hh>

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)
 
G4String GetFileName ()
 
void AppendName (G4bool app)
 
void StartAnalysis (G4int runID)
 
void EndAnalysis ()
 
void CreateNtuples ()
 
void CreateHistograms ()
 
void SaveTrack (SaveType aWhatToSave, G4int aPartID, G4int aPDG, G4ThreeVector aVector, G4double aResolution=0, G4double aEfficiency=1, G4double aEnergy=0)
 
void FillHistogram (G4int HNo, G4double value) const
 
 ~Par02Output ()
 

Static Public Member Functions

static Par02OutputInstance ()
 

Protected Member Functions

 Par02Output ()
 A default, protected constructor (due to singleton pattern). 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.

54  {
55  delete G4AnalysisManager::Instance();
56 }
Par02Output::Par02Output ( )
protected

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

Definition at line 48 of file Par02Output.cc.

48  : fFileNameWithRunNo( false ) {
49  fFileName = "DefaultOutput.root";
50 }

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.

75  {
76  fFileNameWithRunNo = aApp;
77 }
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.

147 {
148  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
149  analysisManager->CreateH1( "Pdiff", "momentum smeared in tracker", 100, 0.8, 1.2 );
150  analysisManager->SetH1XAxisTitle( 0, "p_{smeared}/p_{true}" );
151  analysisManager->SetH1YAxisTitle( 0, "Entries" );
152  analysisManager->CreateH1( "EMCalEdiff", "energy smeared in EMCal", 100, 0.8, 1.2 );
153  analysisManager->SetH1XAxisTitle( 1, "E_{smeared}/E_{true}" );
154  analysisManager->SetH1YAxisTitle( 1, "Entries" );
155  analysisManager->CreateH1( "HCalEdiff", "energy smeared in HCal", 100, 0.0, 2.0 );
156  analysisManager->SetH1XAxisTitle( 2, "E_{smeared}/E_{true}" );
157  analysisManager->SetH1YAxisTitle( 2, "Entries" );
158 }
G4int CreateH1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")
G4bool SetH1YAxisTitle(G4int id, const G4String &title)
G4bool SetH1XAxisTitle(G4int id, const G4String &title)

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.

108  {
110  G4String evName = "Event_";
111  evName += G4UIcommand::ConvertToString( event->GetEventID() );
112  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
113  fCurrentNtupleId = analysisManager->CreateNtuple( evName, evName );
114 
115  analysisManager->CreateNtupleIColumn( "particleID" ); // column Id = 0
116  analysisManager->CreateNtupleIColumn( "PID" ); // column Id = 1
117  analysisManager->CreateNtupleDColumn( "MC_pX" ); // column Id = 2
118  analysisManager->CreateNtupleDColumn( "MC_pY" ); // column Id = 3
119  analysisManager->CreateNtupleDColumn( "MC_pZ" ); // column Id = 4
120 
121  analysisManager->CreateNtupleDColumn( "tracker_res" ); // column Id = 5
122  analysisManager->CreateNtupleDColumn( "tracker_eff" ); // column Id = 6
123  analysisManager->CreateNtupleDColumn( "tracker_pX" ); // column Id = 7
124  analysisManager->CreateNtupleDColumn( "tracker_pY" ); // column Id = 8
125  analysisManager->CreateNtupleDColumn( "tracker_pZ" ); // column Id = 9
126 
127  analysisManager->CreateNtupleDColumn( "emcal_res" ); // column Id = 10
128  analysisManager->CreateNtupleDColumn( "emcal_eff" ); // column Id = 11
129  analysisManager->CreateNtupleDColumn( "emcal_X" ); // column Id = 12
130  analysisManager->CreateNtupleDColumn( "emcal_Y" ); // column Id = 13
131  analysisManager->CreateNtupleDColumn( "emcal_Z" ); // column Id = 14
132  analysisManager->CreateNtupleDColumn( "emcal_E" ); // column Id = 15
133 
134  analysisManager->CreateNtupleDColumn( "hcal_res" ); // column Id = 16
135  analysisManager->CreateNtupleDColumn( "hcal_eff" ); // column Id = 17
136  analysisManager->CreateNtupleDColumn( "hcal_X" ); // column Id = 18
137  analysisManager->CreateNtupleDColumn( "hcal_Y" ); // column Id = 19
138  analysisManager->CreateNtupleDColumn( "hcal_Z" ); // column Id = 20
139  analysisManager->CreateNtupleDColumn( "hcal_E" ); // column Id = 21
140 
141  analysisManager->FinishNtuple( fCurrentNtupleId );
142 }
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:372
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
const G4Event * GetCurrentEvent() const

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.

100  {
101  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
102  analysisManager->Write();
103  analysisManager->CloseFile();
104 }

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.

219  {
220  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
221  analysisManager->FillH1( aHistNo, aValue );
222 }
G4bool FillH1(G4int id, G4double value, G4double weight=1.0)

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.

81  {
82  return fFileName;
83 }
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.

60  {
61  if ( ! fPar02Output ) {
62  fPar02Output = new Par02Output();
63  }
64  return fPar02Output;
65 }
Par02Output()
A default, protected constructor (due to singleton pattern).
Definition: Par02Output.cc:48

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.

164  {
165  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
166  switch( aWhatToSave ) {
167  case Par02Output::eNoSave :
168  break;
169  case Par02Output::eSaveMC : {
170  analysisManager->FillNtupleIColumn( fCurrentNtupleId, 0, aPartID );
171  analysisManager->FillNtupleIColumn( fCurrentNtupleId, 1, aPDG );
172  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 2, aVector.x() );
173  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 3, aVector.y() );
174  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 4, aVector.z() );
175  fCurrentID = aPartID;
176  break;
177  }
179  if ( aPartID != fCurrentID ) G4cout <<
180  " Wrong particle - trying to save Tracker information of different particle"
181  << G4endl;
182  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 5, aResolution );
183  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 6, aEfficiency );
184  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 7, aVector.x() );
185  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 8, aVector.y() );
186  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 9, aVector.z() );
187  break;
188  }
189  case Par02Output::eSaveEMCal : {
190  if ( aPartID != fCurrentID ) G4cout <<
191  " Wrong particle - trying to save EMCal information of different particle"
192  << G4endl;
193  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 10, aResolution );
194  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 11, aEfficiency );
195  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 12, aVector.x() );
196  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 13, aVector.y() );
197  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 14, aVector.z() );
198  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 15, aEnergy );
199  break;
200  }
201  case Par02Output::eSaveHCal : {
202  if ( aPartID != fCurrentID ) G4cout <<
203  " Wrong particle - trying to save HCal information of different particle"
204  << G4endl;
205  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 16, aResolution );
206  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 17, aEfficiency );
207  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 18, aVector.x() );
208  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 19, aVector.y() );
209  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 20, aVector.z() );
210  analysisManager->FillNtupleDColumn( fCurrentNtupleId, 21, aEnergy );
211  analysisManager->AddNtupleRow( fCurrentNtupleId );
212  break;
213  }
214  }
215 }
double x() const
double z() const
G4bool FillNtupleIColumn(G4int id, G4int value)
G4GLOB_DLL std::ostream G4cout
G4bool FillNtupleDColumn(G4int id, G4double value)
double y() const
#define G4endl
Definition: G4ios.hh:61

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.

69  {
70  fFileName = aName;
71 }

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.

87  {
88  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
89  if ( fFileNameWithRunNo ) {
90  fFileName += "_run";
91  fFileName += G4UIcommand::ConvertToString( aRunID );
92  }
93  analysisManager->SetVerboseLevel( 1 );
94  analysisManager->SetFileName( fFileName );
95  analysisManager->OpenFile( fFileName );
96 }
void SetVerboseLevel(G4int verboseLevel)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:372
G4bool SetFileName(const G4String &fileName)
G4bool OpenFile(const G4String &fileName="")

Here is the call graph for this function:

Here is the caller graph for this function:


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