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/AnaEx02/src/HistoManager.cc
/// \brief Implementation of the HistoManager class
//
// $Id: HistoManager.cc 65827 2012-11-29 10:21:47Z gcosmo $
// $Id: HistoManager.cc 74272 2013-10-02 14:48:50Z gcosmo $
// GEANT4 tag $Name: geant4-09-04 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -43,21 +43,24 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoManager::HistoManager()
:rootFile(0),ntupl(0), Eabs(0), Egap(0) ,Labs(0), Lgap(0)
:fRootFile(0),
fNtuple1(0), fNtuple2(0),
fEabs(0), fEgap(0) ,fLabs(0), fLgap(0)
{
// histograms
for (G4int k=0; k<MaxHisto; k++) histo[k] = 0;
for (G4int k=0; k<MaxHisto; k++) fHisto[k] = 0;
// ntuple
ntupl = 0;
fNtuple1 = 0;
fNtuple2 = 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoManager::~HistoManager()
{
if ( rootFile ) delete rootFile;
if ( fRootFile ) delete fRootFile;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -68,30 +71,34 @@ void HistoManager::book()
// This tree is associated to an output file.
//
G4String fileName = "AnaEx02.root";
rootFile = new TFile(fileName,"RECREATE");
if(!rootFile) {
fRootFile = new TFile(fileName,"RECREATE");
if(!fRootFile) {
G4cout << " HistoManager::book :"
<< " problem creating the ROOT TFile "
<< G4endl;
return;
}
histo[1] = new TH1D("1", "Edep in absorber", 100, 0., 800*CLHEP::MeV);
if (!histo[1]) G4cout << "\n can't create histo 1" << G4endl;
histo[2] = new TH1D("2", "Edep in gap", 100, 0., 100*CLHEP::MeV);
if (!histo[2]) G4cout << "\n can't create histo 2" << G4endl;
histo[3] = new TH1D("3", "trackL in absorber", 100, 0., 1*CLHEP::m);
if (!histo[3]) G4cout << "\n can't create histo 3" << G4endl;
histo[4] = new TH1D("4", "trackL in gap", 100, 0., 50*CLHEP::cm);
if (!histo[4]) G4cout << "\n can't create histo 4" << G4endl;
fHisto[1] = new TH1D("1", "Edep in absorber", 100, 0., 800*CLHEP::MeV);
if (!fHisto[1]) G4cout << "\n can't create histo 1" << G4endl;
fHisto[2] = new TH1D("2", "Edep in gap", 100, 0., 100*CLHEP::MeV);
if (!fHisto[2]) G4cout << "\n can't create histo 2" << G4endl;
fHisto[3] = new TH1D("3", "trackL in absorber", 100, 0., 1*CLHEP::m);
if (!fHisto[3]) G4cout << "\n can't create histo 3" << G4endl;
fHisto[4] = new TH1D("4", "trackL in gap", 100, 0., 50*CLHEP::cm);
if (!fHisto[4]) G4cout << "\n can't create histo 4" << G4endl;
// create 1 ntuple in subdirectory "tuples"
// create 1st ntuple in subdirectory "tuples"
//
ntupl = new TTree("101", "Edep and TrackL");
ntupl->Branch("Eabs", &Eabs, "Eabs/D");
ntupl->Branch("Egap", &Egap, "Egap/D");
ntupl->Branch("Labs", &Labs, "Labs/D");
ntupl->Branch("Lgap", &Lgap, "Lgap/D");
fNtuple1 = new TTree("101", "Edep");
fNtuple1->Branch("Eabs", &fEabs, "Eabs/D");
fNtuple1->Branch("Egap", &fEgap, "Egap/D");
// create 2nd ntuple in subdirectory "tuples"
//
fNtuple2 = new TTree("102", "TrackL");
fNtuple2->Branch("Labs", &fLabs, "Labs/D");
fNtuple2->Branch("Lgap", &fLgap, "Lgap/D");
G4cout << "\n----> Histogram file is opened in " << fileName << G4endl;
@@ -101,9 +108,9 @@ void HistoManager::book()
void HistoManager::save()
{
if (rootFile) {
rootFile->Write(); // Writing the histograms to the file
rootFile->Close(); // and closing the tree (and the file)
if (fRootFile) {
fRootFile->Write(); // Writing the histograms to the file
fRootFile->Close(); // and closing the tree (and the file)
G4cout << "\n----> Histogram Tree is saved \n" << G4endl;
}
}
@@ -118,7 +125,7 @@ void HistoManager::FillHisto(G4int ih, G4double xbin, G4double weight)
<< G4endl;
return;
}
if (histo[ih]) { histo[ih]->Fill(xbin, weight); }
if (fHisto[ih]) { fHisto[ih]->Fill(xbin, weight); }
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -130,7 +137,7 @@ void HistoManager::Normalize(G4int ih, G4double fac)
<< " does not exist. (fac=" << fac << ")" << G4endl;
return;
}
if (histo[ih]) histo[ih]->Scale(fac);
if (fHisto[ih]) fHisto[ih]->Scale(fac);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -138,33 +145,34 @@ void HistoManager::Normalize(G4int ih, G4double fac)
void HistoManager::FillNtuple(G4double energyAbs, G4double energyGap,
G4double trackLAbs , G4double trackLGap )
{
Eabs = energyAbs;
Egap = energyGap;
Labs = trackLAbs;
Lgap = trackLGap;
fEabs = energyAbs;
fEgap = energyGap;
fLabs = trackLAbs;
fLgap = trackLGap;
if (ntupl) ntupl->Fill();
if (fNtuple1) fNtuple1->Fill();
if (fNtuple2) fNtuple2->Fill();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::PrintStatistic()
{
if(histo[1]) {
if(fHisto[1]) {
G4cout << "\n ----> print histograms statistic \n" << G4endl;
G4cout
<< " EAbs : mean = " << G4BestUnit(histo[1]->GetMean(), "Energy")
<< " rms = " << G4BestUnit(histo[1]->GetRMS(), "Energy") << G4endl;
<< " EAbs : mean = " << G4BestUnit(fHisto[1]->GetMean(), "Energy")
<< " rms = " << G4BestUnit(fHisto[1]->GetRMS(), "Energy") << G4endl;
G4cout
<< " EGap : mean = " << G4BestUnit(histo[2]->GetMean(), "Energy")
<< " rms = " << G4BestUnit(histo[2]->GetRMS(), "Energy") << G4endl;
<< " EGap : mean = " << G4BestUnit(fHisto[2]->GetMean(), "Energy")
<< " rms = " << G4BestUnit(fHisto[2]->GetRMS(), "Energy") << G4endl;
G4cout
<< " LAbs : mean = " << G4BestUnit(histo[3]->GetMean(), "Length")
<< " rms = " << G4BestUnit(histo[3]->GetRMS(), "Length") << G4endl;
<< " LAbs : mean = " << G4BestUnit(fHisto[3]->GetMean(), "Length")
<< " rms = " << G4BestUnit(fHisto[3]->GetRMS(), "Length") << G4endl;
G4cout
<< " LGap : mean = " << G4BestUnit(histo[4]->GetMean(), "Length")
<< " rms = " << G4BestUnit(histo[4]->GetRMS(), "Length") << G4endl;
<< " LGap : mean = " << G4BestUnit(fHisto[4]->GetMean(), "Length")
<< " rms = " << G4BestUnit(fHisto[4]->GetRMS(), "Length") << G4endl;
}
}