Import Geant4 10.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 14:11:04 +02:00
parent c9b32a6c0a
commit d4af681f38
4886 changed files with 420149 additions and 1023309 deletions
@@ -26,7 +26,7 @@
/// \file analysis/AnaEx03/src/HistoManager.cc
/// \brief Implementation of the HistoManager class
//
// $Id: HistoManager.cc 74272 2013-10-02 14:48:50Z gcosmo $
// $Id: HistoManager.cc 92373 2015-08-31 08:51:33Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -35,16 +35,13 @@
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#ifdef G4ANALYSIS_USE
#include "AIDA/AIDA.h"
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoManager::HistoManager()
:fAF(0),fTree(0), fNtuple1(0), fNtuple2(0)
{
#ifdef G4ANALYSIS_USE
// Creating the analysis factory
//
fAF = AIDA_createAnalysisFactory();
@@ -53,7 +50,6 @@ HistoManager::HistoManager()
<< " problem creating the AIDA analysis factory."
<< G4endl;
}
#endif
// histograms
for (G4int k=0; k<MaxHisto; k++) fHisto[k] = 0;
@@ -63,99 +59,97 @@ HistoManager::HistoManager()
HistoManager::~HistoManager()
{
#ifdef G4ANALYSIS_USE
delete fAF;
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::book()
void HistoManager::Book()
{
#ifdef G4ANALYSIS_USE
if(!fAF) return;
if (! fAF) return;
// Creating a tree container to handle histograms and ntuples.
// This tree is associated to an output file.
//
G4String fileName = "AnaEx03";
G4String fileType = "root"; // hbook root xml
G4String fileOption = " ";
//// G4String fileOption = "uncompress compress=no"; //for xml
//// G4String fileOption = "--noErrors"; //for hbook
// Creating a tree container to handle histograms and ntuples.
// This tree is associated to an output file.
//
G4String fileName = "AnaEx03";
G4String fileType = "root"; // hbook root xml
G4String fileOption = " ";
//// G4String fileOption = "uncompress compress=no"; //for xml
//// G4String fileOption = "--noErrors"; //for hbook
fileName = fileName + "." + fileType;
G4bool readOnly = false;
G4bool createNew = true;
AIDA::ITreeFactory* tf = fAF->createTreeFactory();
fTree = tf->create(fileName, fileType, readOnly, createNew, fileOption);
delete tf;
if(!fTree) {
G4cout << " HistoManager::book :"
<< " problem creating the AIDA tree with "
<< " storeName = " << fileName
<< " storeType = " << fileType
<< " readOnly = " << readOnly
<< " createNew = " << createNew
<< " options = " << fileOption
<< G4endl;
return;
}
// Creating a histogram factory, whose histograms will be handled by the tree
//
AIDA::IHistogramFactory* hf = fAF->createHistogramFactory(*fTree);
// create histos in subdirectory "histograms"
//
fTree->mkdir("histograms");
fTree->cd("histograms");
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;
fTree->cd("..");
// Creating a ntuple factory, handled by the tree
//
AIDA::ITupleFactory* ntf = fAF->createTupleFactory(*fTree);
// create 1 ntuple in subdirectory "tuples"
//
fTree->mkdir("tuples");
fTree->cd("tuples");
fNtuple1 = ntf->create("101", "Edep", "double Eabs, Egap");
fNtuple2 = ntf->create("102", "TrackL", "double Labs, Lgap");
delete ntf;
fTree->cd("..");
G4cout << "\n----> Histogram Tree is opened in " << fileName << G4endl;
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::save()
{
#ifdef G4ANALYSIS_USE
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 fTree;
fTree = 0;
fileName = fileName + "." + fileType;
G4bool readOnly = false;
G4bool createNew = true;
AIDA::ITreeFactory* tf = fAF->createTreeFactory();
fTree = tf->create(fileName, fileType, readOnly, createNew, fileOption);
delete tf;
if(!fTree) {
G4cout << " HistoManager::book :"
<< " problem creating the AIDA tree with "
<< " storeName = " << fileName
<< " storeType = " << fileType
<< " readOnly = " << readOnly
<< " createNew = " << createNew
<< " options = " << fileOption
<< G4endl;
return;
}
#endif
// Creating a histogram factory, whose histograms will be handled by the tree
//
AIDA::IHistogramFactory* hf = fAF->createHistogramFactory(*fTree);
// create histos in subdirectory "histograms"
//
fTree->mkdir("histograms");
fTree->cd("histograms");
// id = 0
fHisto[0] = hf->createHistogram1D("EAbs", "EAbs: Edep in absorber", 100, 0., 800*MeV);
// id = 1
fHisto[1] = hf->createHistogram1D("EGap", "EGap: Edep in gap", 100, 0., 100*MeV);
// id = 2
fHisto[2] = hf->createHistogram1D("LAbs", "LAbs: trackL in absorber", 100, 0., 1*m);
// id = 3
fHisto[3] = hf->createHistogram1D("LGap", "LGap: trackL in gap", 100, 0., 50*cm);
for ( G4int i=0; i<MaxHisto; ++i ) {
if (! fHisto[i]) G4cout << "\n can't create histo " << i << G4endl;
}
delete hf;
fTree->cd("..");
// Creating a ntuple factory, handled by the tree
//
AIDA::ITupleFactory* ntf = fAF->createTupleFactory(*fTree);
// create 1 ntuple in subdirectory "tuples"
//
fTree->mkdir("tuples");
fTree->cd("tuples");
fNtuple1 = ntf->create("Ntuple1", "Edep", "double Eabs, Egap");
fNtuple2 = ntf->create("Ntuple2", "TrackL", "double Labs, Lgap");
delete ntf;
fTree->cd("..");
G4cout << "\n----> Output file is open in " << fileName << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::Save()
{
if (! (fAF && fTree)) return;
fTree->commit(); // Writing the histograms to the file
fTree->close(); // and closing the tree (and the file)
G4cout << "\n----> Histograms and ntuples are saved\n" << G4endl;
delete fTree;
fTree = 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -168,9 +162,8 @@ void HistoManager::FillHisto(G4int ih, G4double xbin, G4double weight)
<< G4endl;
return;
}
#ifdef G4ANALYSIS_USE
if (fHisto[ih]) fHisto[ih]->fill(xbin, weight);
#endif
if (fHisto[ih]) fHisto[ih]->fill(xbin, weight);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -182,14 +175,12 @@ void HistoManager::Normalize(G4int ih, G4double fac)
<< " does not exist. (fac=" << fac << ")" << G4endl;
return;
}
#ifdef G4ANALYSIS_USE
if (fHisto[ih]) fHisto[ih]->scale(fac);
#endif
if (fHisto[ih]) fHisto[ih]->scale(fac);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifdef G4ANALYSIS_USE
void HistoManager::FillNtuple(G4double energyAbs, G4double energyGap,
G4double trackLAbs, G4double trackLGap)
{
@@ -204,34 +195,26 @@ void HistoManager::FillNtuple(G4double energyAbs, G4double energyGap,
fNtuple2->addRow();
}
}
#else
void HistoManager::FillNtuple(G4double, G4double, G4double, G4double)
{
return;
}
#endif
void HistoManager::PrintStatistic()
{
#ifdef G4ANALYSIS_USE
if(fHisto[1]) {
G4cout << "\n ----> print histograms statistic \n" << G4endl;
G4cout
<< " EAbs : mean = " << G4BestUnit(fHisto[1]->mean(), "Energy")
<< " rms = " << G4BestUnit(fHisto[1]->rms(), "Energy") << G4endl;
G4cout
<< " EGap : mean = " << G4BestUnit(fHisto[2]->mean(), "Energy")
<< " rms = " << G4BestUnit(fHisto[2]->rms(), "Energy") << G4endl;
G4cout
<< " LAbs : mean = " << G4BestUnit(fHisto[3]->mean(), "Length")
<< " rms = " << G4BestUnit(fHisto[3]->rms(), "Length") << G4endl;
G4cout
<< " LGap : mean = " << G4BestUnit(fHisto[4]->mean(), "Length")
<< " rms = " << G4BestUnit(fHisto[4]->rms(), "Length") << G4endl;
G4cout << "\n ----> print histograms statistic \n" << G4endl;
for ( G4int i=0; i<MaxHisto; ++i ) {
AIDA::IHistogram1D* h1 = fHisto[i];
G4String title = h1->title();
// extract name as first 4 characters from title, as aida seems not to keep
// histogram name
const G4String name = title(0,4);
G4String unitCategory;
if (name[0] == 'E' ) unitCategory = "Energy";
if (name[0] == 'L' ) unitCategory = "Length";
G4cout << name
<< ": mean = " << G4BestUnit(h1->mean(), unitCategory)
<< " rms = " << G4BestUnit(h1->rms(), unitCategory )
<< G4endl;
}
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......