Import Geant4 10.7.0 source tree
This commit is contained in:
@@ -27,9 +27,9 @@
|
||||
/// \brief Implementation of the HistoManager class
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "HistoManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
@@ -55,26 +55,29 @@ void HistoManager::Book()
|
||||
// in HistoManager.hh
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
analysisManager->SetVerboseLevel(1);
|
||||
// Only merge in MT mode to avoid warning when running in Sequential mode
|
||||
#ifdef G4MULTITHREADED
|
||||
analysisManager->SetNtupleMerging(true);
|
||||
|
||||
// Create directories
|
||||
#endif
|
||||
|
||||
// Create directories
|
||||
analysisManager->SetHistoDirectoryName("histo");
|
||||
analysisManager->SetNtupleDirectoryName("ntuple");
|
||||
|
||||
|
||||
// Open an output file
|
||||
//
|
||||
G4bool fileOpen = analysisManager->OpenFile("AnaEx01");
|
||||
if (! fileOpen) {
|
||||
G4cerr << "\n---> HistoManager::Book(): cannot open "
|
||||
G4cerr << "\n---> HistoManager::Book(): cannot open "
|
||||
<< analysisManager->GetFileName() << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Create histograms.
|
||||
// Histogram ids are generated automatically starting from 0.
|
||||
// The start value can be changed by:
|
||||
// analysisManager->SetFirstHistoId(1);
|
||||
|
||||
// analysisManager->SetFirstHistoId(1);
|
||||
|
||||
// id = 0
|
||||
analysisManager->CreateH1("EAbs","Edep in absorber (MeV)", 100, 0., 800*MeV);
|
||||
// id = 1
|
||||
@@ -87,8 +90,8 @@ void HistoManager::Book()
|
||||
// Create ntuples.
|
||||
// Ntuples ids are generated automatically starting from 0.
|
||||
// The start value can be changed by:
|
||||
// analysisManager->SetFirstMtupleId(1);
|
||||
|
||||
// analysisManager->SetFirstMtupleId(1);
|
||||
|
||||
// Create 1st ntuple (id = 0)
|
||||
analysisManager->CreateNtuple("Ntuple1", "Edep");
|
||||
analysisManager->CreateNtupleDColumn("Eabs"); // column Id = 0
|
||||
@@ -96,16 +99,16 @@ void HistoManager::Book()
|
||||
analysisManager->FinishNtuple();
|
||||
|
||||
// Create 2nd ntuple (id = 1)
|
||||
//
|
||||
//
|
||||
analysisManager->CreateNtuple("Ntuple2", "TrackL");
|
||||
analysisManager->CreateNtupleDColumn("Labs"); // column Id = 0
|
||||
analysisManager->CreateNtupleDColumn("Lgap"); // column Id = 1
|
||||
analysisManager->FinishNtuple();
|
||||
|
||||
fFactoryOn = true;
|
||||
|
||||
G4cout << "\n----> Output file is open in "
|
||||
<< analysisManager->GetFileName() << "."
|
||||
fFactoryOn = true;
|
||||
|
||||
G4cout << "\n----> Output file is open in "
|
||||
<< analysisManager->GetFileName() << "."
|
||||
<< analysisManager->GetFileType() << G4endl;
|
||||
}
|
||||
|
||||
@@ -114,13 +117,13 @@ void HistoManager::Book()
|
||||
void HistoManager::Save()
|
||||
{
|
||||
if (! fFactoryOn) return;
|
||||
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
analysisManager->Write();
|
||||
analysisManager->CloseFile();
|
||||
|
||||
analysisManager->CloseFile();
|
||||
|
||||
G4cout << "\n----> Histograms and ntuples are saved\n" << G4endl;
|
||||
|
||||
|
||||
delete G4AnalysisManager::Instance();
|
||||
fFactoryOn = false;
|
||||
}
|
||||
@@ -129,7 +132,7 @@ void HistoManager::Save()
|
||||
|
||||
void HistoManager::FillHisto(G4int ih, G4double xbin, G4double weight)
|
||||
{
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
analysisManager->FillH1(ih, xbin, weight);
|
||||
}
|
||||
|
||||
@@ -137,7 +140,7 @@ void HistoManager::FillHisto(G4int ih, G4double xbin, G4double weight)
|
||||
|
||||
void HistoManager::Normalize(G4int ih, G4double fac)
|
||||
{
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
G4H1* h1 = analysisManager->GetH1(ih);
|
||||
if (h1) h1->scale(fac);
|
||||
}
|
||||
@@ -146,17 +149,17 @@ void HistoManager::Normalize(G4int ih, G4double fac)
|
||||
|
||||
void HistoManager::FillNtuple(G4double energyAbs, G4double energyGap,
|
||||
G4double trackLAbs, G4double trackLGap)
|
||||
{
|
||||
{
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
// Fill 1st ntuple ( id = 0)
|
||||
analysisManager->FillNtupleDColumn(0, 0, energyAbs);
|
||||
analysisManager->FillNtupleDColumn(0, 1, energyGap);
|
||||
analysisManager->AddNtupleRow(0);
|
||||
analysisManager->AddNtupleRow(0);
|
||||
// Fill 2nd ntuple ( id = 1)
|
||||
analysisManager->FillNtupleDColumn(1, 0, trackLAbs);
|
||||
analysisManager->FillNtupleDColumn(1, 1, trackLGap);
|
||||
analysisManager->AddNtupleRow(1);
|
||||
}
|
||||
analysisManager->AddNtupleRow(1);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -165,21 +168,21 @@ void HistoManager::PrintStatistic()
|
||||
if (! fFactoryOn) return;
|
||||
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
|
||||
|
||||
G4cout << "\n ----> print histograms statistic \n" << G4endl;
|
||||
for ( G4int i=0; i<analysisManager->GetNofH1s(); ++i ) {
|
||||
G4String name = analysisManager->GetH1Name(i);
|
||||
G4H1* h1 = analysisManager->GetH1(i);
|
||||
|
||||
|
||||
G4String unitCategory;
|
||||
if (name[0U] == 'E' ) unitCategory = "Energy";
|
||||
if (name[0U] == 'E' ) unitCategory = "Energy";
|
||||
if (name[0U] == 'L' ) unitCategory = "Length";
|
||||
// we use an explicit unsigned int type for operator [] argument
|
||||
// to avoid problems with windows compiler
|
||||
|
||||
G4cout << name
|
||||
<< ": mean = " << G4BestUnit(h1->mean(), unitCategory)
|
||||
<< " rms = " << G4BestUnit(h1->rms(), unitCategory )
|
||||
<< ": mean = " << G4BestUnit(h1->mean(), unitCategory)
|
||||
<< " rms = " << G4BestUnit(h1->rms(), unitCategory )
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user