Import Geant4 10.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 11:51:14 +02:00
parent e2d2f9810a
commit 286caacf06
12421 changed files with 730077 additions and 502383 deletions
@@ -26,7 +26,7 @@
/// \file analysis/AnaEx03/src/HistoManager.cc
/// \brief Implementation of the HistoManager class
//
// $Id$
// $Id: HistoManager.cc 74272 2013-10-02 14:48:50Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -42,13 +42,13 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoManager::HistoManager()
:af(0),tree(0)
:fAF(0),fTree(0), fNtuple1(0), fNtuple2(0)
{
#ifdef G4ANALYSIS_USE
// Creating the analysis factory
//
af = AIDA_createAnalysisFactory();
if(!af) {
fAF = AIDA_createAnalysisFactory();
if(!fAF) {
G4cout << " HistoManager::HistoManager :"
<< " problem creating the AIDA analysis factory."
<< G4endl;
@@ -56,10 +56,7 @@ HistoManager::HistoManager()
#endif
// histograms
for (G4int k=0; k<MaxHisto; k++) histo[k] = 0;
// ntuple
ntupl = 0;
for (G4int k=0; k<MaxHisto; k++) fHisto[k] = 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -67,7 +64,7 @@ HistoManager::HistoManager()
HistoManager::~HistoManager()
{
#ifdef G4ANALYSIS_USE
delete af;
delete fAF;
#endif
}
@@ -76,7 +73,7 @@ HistoManager::~HistoManager()
void HistoManager::book()
{
#ifdef G4ANALYSIS_USE
if(!af) return;
if(!fAF) return;
// Creating a tree container to handle histograms and ntuples.
// This tree is associated to an output file.
@@ -90,10 +87,10 @@ void HistoManager::book()
fileName = fileName + "." + fileType;
G4bool readOnly = false;
G4bool createNew = true;
AIDA::ITreeFactory* tf = af->createTreeFactory();
tree = tf->create(fileName, fileType, readOnly, createNew, fileOption);
AIDA::ITreeFactory* tf = fAF->createTreeFactory();
fTree = tf->create(fileName, fileType, readOnly, createNew, fileOption);
delete tf;
if(!tree) {
if(!fTree) {
G4cout << " HistoManager::book :"
<< " problem creating the AIDA tree with "
<< " storeName = " << fileName
@@ -107,38 +104,39 @@ void HistoManager::book()
// Creating a histogram factory, whose histograms will be handled by the tree
//
AIDA::IHistogramFactory* hf = af->createHistogramFactory(*tree);
AIDA::IHistogramFactory* hf = fAF->createHistogramFactory(*fTree);
// create histos in subdirectory "histograms"
//
tree->mkdir("histograms");
tree->cd("histograms");
fTree->mkdir("histograms");
fTree->cd("histograms");
histo[1] = hf->createHistogram1D("1", "Edep in absorber", 100, 0., 800*MeV);
if (!histo[1]) G4cout << "\n can't create histo 1" << G4endl;
histo[2] = hf->createHistogram1D("2", "Edep in gap", 100, 0., 100*MeV);
if (!histo[2]) G4cout << "\n can't create histo 2" << G4endl;
histo[3] = hf->createHistogram1D("3", "trackL in absorber", 100, 0., 1*m);
if (!histo[3]) G4cout << "\n can't create histo 3" << G4endl;
histo[4] = hf->createHistogram1D("4", "trackL in gap", 100, 0., 50*cm);
if (!histo[4]) G4cout << "\n can't create histo 4" << G4endl;
fHisto[1] = hf->createHistogram1D("1", "Edep in absorber", 100, 0., 800*MeV);
if (!fHisto[1]) G4cout << "\n can't create histo 1" << G4endl;
fHisto[2] = hf->createHistogram1D("2", "Edep in gap", 100, 0., 100*MeV);
if (!fHisto[2]) G4cout << "\n can't create histo 2" << G4endl;
fHisto[3] = hf->createHistogram1D("3", "trackL in absorber", 100, 0., 1*m);
if (!fHisto[3]) G4cout << "\n can't create histo 3" << G4endl;
fHisto[4] = hf->createHistogram1D("4", "trackL in gap", 100, 0., 50*cm);
if (!fHisto[4]) G4cout << "\n can't create histo 4" << G4endl;
delete hf;
tree->cd("..");
fTree->cd("..");
// Creating a ntuple factory, handled by the tree
//
AIDA::ITupleFactory* ntf = af->createTupleFactory(*tree);
AIDA::ITupleFactory* ntf = fAF->createTupleFactory(*fTree);
// create 1 ntuple in subdirectory "tuples"
//
tree->mkdir("tuples");
tree->cd("tuples");
fTree->mkdir("tuples");
fTree->cd("tuples");
ntupl = ntf->create("101", "Edep and TrackL", "double Eabs, Egap, Labs, Lgap");
fNtuple1 = ntf->create("101", "Edep", "double Eabs, Egap");
fNtuple2 = ntf->create("102", "TrackL", "double Labs, Lgap");
delete ntf;
tree->cd("..");
fTree->cd("..");
G4cout << "\n----> Histogram Tree is opened in " << fileName << G4endl;
#endif
@@ -149,13 +147,13 @@ void HistoManager::book()
void HistoManager::save()
{
#ifdef G4ANALYSIS_USE
if (af && tree) {
tree->commit(); // Writing the histograms to the file
tree->close(); // and closing the tree (and the file)
if (fAF && fTree) {
fTree->commit(); // Writing the histograms to the file
fTree->close(); // and closing the tree (and the file)
G4cout << "\n----> Histogram Tree is saved \n" << G4endl;
delete tree;
tree = 0;
delete fTree;
fTree = 0;
}
#endif
}
@@ -171,7 +169,7 @@ void HistoManager::FillHisto(G4int ih, G4double xbin, G4double weight)
return;
}
#ifdef G4ANALYSIS_USE
if (histo[ih]) histo[ih]->fill(xbin, weight);
if (fHisto[ih]) fHisto[ih]->fill(xbin, weight);
#endif
}
@@ -185,7 +183,7 @@ void HistoManager::Normalize(G4int ih, G4double fac)
return;
}
#ifdef G4ANALYSIS_USE
if (histo[ih]) histo[ih]->scale(fac);
if (fHisto[ih]) fHisto[ih]->scale(fac);
#endif
}
@@ -195,12 +193,15 @@ void HistoManager::Normalize(G4int ih, G4double fac)
void HistoManager::FillNtuple(G4double energyAbs, G4double energyGap,
G4double trackLAbs, G4double trackLGap)
{
if (ntupl) {
ntupl->fill(0, energyAbs);
ntupl->fill(1, energyGap);
ntupl->fill(2, trackLAbs);
ntupl->fill(3, trackLGap);
ntupl->addRow();
if (fNtuple1) {
fNtuple1->fill(0, energyAbs);
fNtuple1->fill(1, energyGap);
fNtuple1->addRow();
}
if (fNtuple2) {
fNtuple2->fill(0, trackLAbs);
fNtuple2->fill(1, trackLGap);
fNtuple2->addRow();
}
}
#else
@@ -213,21 +214,21 @@ void HistoManager::FillNtuple(G4double, G4double, G4double, G4double)
void HistoManager::PrintStatistic()
{
#ifdef G4ANALYSIS_USE
if(histo[1]) {
if(fHisto[1]) {
G4cout << "\n ----> print histograms statistic \n" << G4endl;
G4cout
<< " EAbs : mean = " << G4BestUnit(histo[1]->mean(), "Energy")
<< " rms = " << G4BestUnit(histo[1]->rms(), "Energy") << G4endl;
<< " EAbs : mean = " << G4BestUnit(fHisto[1]->mean(), "Energy")
<< " rms = " << G4BestUnit(fHisto[1]->rms(), "Energy") << G4endl;
G4cout
<< " EGap : mean = " << G4BestUnit(histo[2]->mean(), "Energy")
<< " rms = " << G4BestUnit(histo[2]->rms(), "Energy") << G4endl;
<< " EGap : mean = " << G4BestUnit(fHisto[2]->mean(), "Energy")
<< " rms = " << G4BestUnit(fHisto[2]->rms(), "Energy") << G4endl;
G4cout
<< " LAbs : mean = " << G4BestUnit(histo[3]->mean(), "Length")
<< " rms = " << G4BestUnit(histo[3]->rms(), "Length") << G4endl;
<< " LAbs : mean = " << G4BestUnit(fHisto[3]->mean(), "Length")
<< " rms = " << G4BestUnit(fHisto[3]->rms(), "Length") << G4endl;
G4cout
<< " LGap : mean = " << G4BestUnit(histo[4]->mean(), "Length")
<< " rms = " << G4BestUnit(histo[4]->rms(), "Length") << G4endl;
<< " LGap : mean = " << G4BestUnit(fHisto[4]->mean(), "Length")
<< " rms = " << G4BestUnit(fHisto[4]->rms(), "Length") << G4endl;
}
#endif