Import Geant4 10.0.0 source tree
This commit is contained in:
@@ -73,10 +73,14 @@
|
||||
- histo 3 : total track length of charged particles in absorber per event
|
||||
- histo 4 : total track length of charged particles in gap per event
|
||||
|
||||
And 1 Ntuple :
|
||||
- one row per event : EnergyAbs EnergyGap TrackLAbs TrackLGap
|
||||
And 2 Ntuples :
|
||||
- ntuple 1:
|
||||
- one row per event : EnergyAbs EnergyGap
|
||||
- ntuple 1:
|
||||
- one row per event : TrackLAbs TrackLGap
|
||||
|
||||
These histos are booked in HistoManager and filled from EventAction.
|
||||
These histos and ntuples are booked in HistoManager and filled from
|
||||
EventAction.
|
||||
|
||||
One can control the name of the histograms file :
|
||||
- default name : AnaEx02
|
||||
|
||||
@@ -27,8 +27,7 @@
|
||||
/// \brief Main program of the analysis/AnaEx02 example
|
||||
//
|
||||
//
|
||||
// $Id: AnaEx02.cc 59868 2012-06-20 13:59:51Z gcosmo $
|
||||
// GEANT4 tag $Name: not supported by cvs2svn $
|
||||
// $Id: AnaEx02.cc 68015 2013-03-13 13:27:27Z gcosmo $
|
||||
//
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -23,11 +23,7 @@ include(${Geant4_USE_FILE})
|
||||
#----------------------------------------------------------------------------
|
||||
# Find ROOT (required package)
|
||||
#
|
||||
find_package(ROOT QUIET)
|
||||
if(NOT ROOT_FOUND)
|
||||
message(STATUS "G4 Examples: ROOT package not found. --> AnaEx02 example disabled")
|
||||
return()
|
||||
endif()
|
||||
find_package(ROOT REQUIRED)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Locate sources and headers for this project
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$Id: History 65827 2012-11-29 10:21:47Z gcosmo $
|
||||
$Id: History 68775 2013-04-05 12:50:10Z gcosmo $
|
||||
--------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -15,6 +15,10 @@ track of all tags.
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
02-04-13 I. Hrivnacova (AnaEx02-V09-06-00)
|
||||
- Create two ntuples instead of one in order to demonstrate
|
||||
how to do this with all tools.
|
||||
|
||||
28-11-12 G. Cosmo (AnaEx02-V09-05-04)
|
||||
- Fixed cases of variable shadowing.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$Id: README 61398 2012-09-04 09:55:39Z gcosmo $
|
||||
$Id: README 68775 2013-04-05 12:50:10Z gcosmo $
|
||||
--------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -75,10 +75,14 @@ $Id: README 61398 2012-09-04 09:55:39Z gcosmo $
|
||||
histo 3 : total track length of charged particles in absorber per event
|
||||
histo 4 : total track length of charged particles in gap per event
|
||||
|
||||
And 1 Ntuple :
|
||||
one row per event : EnergyAbs EnergyGap TrackLAbs TrackLGap
|
||||
And 2 Ntuples :
|
||||
- ntuple 1:
|
||||
- one row per event : EnergyAbs EnergyGap
|
||||
- ntuple 1:
|
||||
- one row per event : TrackLAbs TrackLGap
|
||||
|
||||
These histos are booked in HistoManager and filled from EventAction.
|
||||
These histos and ntuples are booked in HistoManager and filled from
|
||||
EventAction.
|
||||
|
||||
One can control the name of the histograms file :
|
||||
default name : AnaEx02
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file analysis/AnaEx02/include/HistoManager.hh
|
||||
/// \brief Definition of the HistoManager class
|
||||
//
|
||||
// $Id: HistoManager.hh 59868 2012-06-20 13:59:51Z gcosmo $
|
||||
// $Id: HistoManager.hh 74272 2013-10-02 14:48:50Z gcosmo $
|
||||
// GEANT4 tag $Name: geant4-09-04 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -67,14 +67,15 @@ class HistoManager
|
||||
|
||||
private:
|
||||
|
||||
TFile* rootFile;
|
||||
TH1D* histo[MaxHisto];
|
||||
TTree* ntupl;
|
||||
TFile* fRootFile;
|
||||
TH1D* fHisto[MaxHisto];
|
||||
TTree* fNtuple1;
|
||||
TTree* fNtuple2;
|
||||
|
||||
G4double Eabs;
|
||||
G4double Egap;
|
||||
G4double Labs;
|
||||
G4double Lgap;
|
||||
G4double fEabs;
|
||||
G4double fEgap;
|
||||
G4double fLabs;
|
||||
G4double fLgap;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user