Import Geant4 9.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 15:58:43 +02:00
parent 96c8bcd0af
commit b79225fb37
7544 changed files with 245407 additions and 91099 deletions
@@ -36,8 +36,9 @@ exGPSAnalysisManager* exGPSAnalysisManager::instance = 0;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
exGPSAnalysisManager::exGPSAnalysisManager():
fileName("exgps.aida"),fileType("xml"),analysisFactory(0), hFactory(0), tFactory(0),
minpos(-10.),maxpos(10),mineng(0.),maxeng(1000.)
fileName("exgps.aida"),fileType("xml"),analysisFactory(0), tree(0),plotter(0),
minpos(-10.),maxpos(10),mineng(0.),maxeng(1000.),
enerHisto(0),posiXY(0),posiXZ(0),posiYZ(0),anglCTP(0),anglTP(0),tuple(0)
{
// Define the messenger and the analysis system
analysisMessenger = new exGPSAnalysisMessenger(this);
@@ -54,34 +55,8 @@ exGPSAnalysisManager::~exGPSAnalysisManager() {
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
IHistogramFactory* exGPSAnalysisManager::getHistogramFactory()
{
return hFactory;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
ITupleFactory* exGPSAnalysisManager::getTupleFactory()
{
return tFactory;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
IPlotter* exGPSAnalysisManager::createPlotter()
{
#ifdef JAIDA_HOME
if (analysisFactory)
{
IPlotterFactory* pf = analysisFactory->createPlotterFactory(0,0);
if (pf) return pf->create("Plotter");
}
#endif
return 0;
}
////////////////////////////////////////////////////////////////////////////////
//
exGPSAnalysisManager* exGPSAnalysisManager::getInstance ()
@@ -107,12 +82,14 @@ void exGPSAnalysisManager::Fill(G4String pname, G4double e,
G4double x, G4double y, G4double z,
G4double t, G4double p, G4double w)
{
enerHisto->fill(e/MeV,w);
posiXY->fill(x/cm,y/cm,w);
posiXZ->fill(x/cm,z/cm,w);
posiYZ->fill(y/cm,z/cm,w);
anglCTP->fill(p/deg,std::cos(t),w);
anglTP->fill(p/deg,t/deg,w);
if(enerHisto) {
enerHisto->fill(e/MeV,w);
posiXY->fill(x/cm,y/cm,w);
posiXZ->fill(x/cm,z/cm,w);
posiYZ->fill(y/cm,z/cm,w);
anglCTP->fill(p/deg,std::cos(t),w);
anglTP->fill(p/deg,t/deg,w);
}
if (plotter) plotter->refresh();
@@ -140,22 +117,35 @@ void exGPSAnalysisManager::Fill(G4String pname, G4double e,
*/
void exGPSAnalysisManager::BeginOfRun()
{
tree = 0;
plotter = 0;
enerHisto =0;
posiXY = posiXZ = posiYZ = anglCTP =anglTP = 0;
tuple = 0;
// Hooking an AIDA compliant analysis system.
analysisFactory = AIDA_createAnalysisFactory();
if(analysisFactory){
ITreeFactory* treeFactory = analysisFactory->createTreeFactory();
if(!analysisFactory) //Have to check that, it can fail.
{
G4cout << "exGPSAnalysisManager::BeginOfRun: can't get AIDA." << G4endl;
return;
}
AIDA::ITreeFactory* treeFactory = analysisFactory->createTreeFactory();
if(treeFactory)
{
tree = treeFactory->create(fileName,fileType,false,true,"compress=yes");
hFactory = analysisFactory->createHistogramFactory(*tree);
tFactory = analysisFactory->createTupleFactory(*tree);
if(!tree) //Have to check that, it can fail.
{
G4cout << "exGPSAnalysisManager::BeginOfRun:"
<< " can't create the AIDA::ITree : " << fileName << G4endl;
return;
}
delete treeFactory; // Will not delete the ITree.
}
//
enerHisto =0;
posiXY = posiXZ = posiYZ = anglCTP =anglTP = 0;
plotter = 0;
tuple = 0;
//
AIDA::IHistogramFactory* hFactory = analysisFactory->createHistogramFactory(*tree);
if (hFactory)
{
// Create the energy histogram
@@ -172,30 +162,35 @@ void exGPSAnalysisManager::BeginOfRun()
, 100, -1, 1);
anglTP = hFactory->createHistogram2D("Source phi-theta distribution",360,0,360
,180,0,180);
#ifdef JAIDA_HOME
plotter = createPlotter();
if (plotter)
{
plotter->createRegions(2,3);
plotter->region(0)->plot(*enerHisto);
plotter->region(1)->plot(*posiXY);
plotter->region(2)->plot(*posiXZ);
plotter->region(3)->plot(*posiYZ);
plotter->region(4)->plot(*anglCTP);
plotter->region(5)->plot(*anglTP);
plotter->show();
}
#endif
delete hFactory;
}
// Create a Tuple
AIDA::ITupleFactory* tFactory = analysisFactory->createTupleFactory(*tree);
if (tFactory)
{
tuple = tFactory->create("MyTuple","MyTuple","std::string Pname, std::double Energy, X, Y, Z, Theta, Phi, Weight","");
tuple = tFactory->create("MyTuple","MyTuple","string Pname, double Energy, X, Y, Z, Theta, Phi, Weight","");
delete tFactory;
}
AIDA::IPlotterFactory* pf = analysisFactory->createPlotterFactory(0,0);
if(pf)
{
plotter = pf->create();
if (plotter)
{
plotter->createRegions(2,3);
if(enerHisto) plotter->region(0)->plot(*enerHisto);
if(posiXY) plotter->region(1)->plot(*posiXY);
if(posiXZ) plotter->region(2)->plot(*posiXZ);
if(posiYZ) plotter->region(3)->plot(*posiYZ);
if(anglCTP) plotter->region(4)->plot(*anglCTP);
if(anglTP) plotter->region(5)->plot(*anglTP);
plotter->show();
}
delete pf;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -209,12 +204,20 @@ void exGPSAnalysisManager::EndOfRun()
{
if (!tree->commit()) G4cout << "Commit failed: no AIDA file produced!" << G4endl;
delete tree;
delete tFactory;
delete hFactory;
tree = 0;
// G4cout << "Warning: Geant4 will NOT continue unless you close the JAS-AIDA window." << G4endl;
delete analysisFactory;
delete plotter;
plotter = 0;
delete analysisFactory; //cleanup all AIDA related things.
analysisFactory = 0;
enerHisto = 0;
posiXY = posiXZ = posiYZ = anglCTP =anglTP = 0;
tuple = 0;
}
// dispose();
}
@@ -25,8 +25,6 @@
//
#ifdef G4ANALYSIS_USE
#include <AIDA/AIDA.h>
#include "exGPSAnalysisMessenger.hh"
#include "exGPSAnalysisManager.hh"
@@ -27,7 +27,6 @@
#include "exGPSEventAction.hh"
#ifdef G4ANALYSIS_USE
#include <AIDA/AIDA.h>
#include "exGPSAnalysisManager.hh"
#endif
@@ -88,7 +87,8 @@ void exGPSEventAction::EndOfEventAction(const G4Event* evt)
G4double E0=evt->GetPrimaryVertex(j)->GetPrimary(i)->GetG4code()->GetPDGMass();
E=std::sqrt(P*P+E0*E0);
E -= E0;
G4String pname = evt->GetPrimaryVertex(j)->GetPrimary(i)->GetG4code()->GetParticleName();
// G4String pname = evt->GetPrimaryVertex(j)->GetPrimary(i)->GetG4code()->GetParticleName();
G4double pid = G4double(evt->GetPrimaryVertex(j)->GetPrimary(i)->GetPDGcode());
//
direction=direction*(1./direction.mag());
direction = -direction; // reverse the direction
@@ -100,11 +100,13 @@ void exGPSEventAction::EndOfEventAction(const G4Event* evt)
y=position.y();
z=position.z();
w = evt->GetPrimaryVertex(j)->GetPrimary(i)->GetWeight();
exGPSAnalysisManager::getInstance()->Fill(pname,E,x,y,z,Theta,Phi,w);
// exGPSAnalysisManager::getInstance()->Fill(pname,E,x,y,z,Theta,Phi,w);
exGPSAnalysisManager::getInstance()->Fill(pid,E,x,y,z,Theta,Phi,w);
}
}
#endif
#ifdef G4VIS_USE
// extract the trajectories and draw them
if (G4VVisManager::GetConcreteInstance())
{
@@ -121,6 +123,7 @@ void exGPSEventAction::EndOfEventAction(const G4Event* evt)
trj->DrawTrajectory(0);
}
}
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -31,7 +31,7 @@
// and all its terms.
//
// $Id: exGPSEventActionMessenger.cc,v 1.3 2006/06/29 17:14:43 gunter Exp $
// GEANT4 tag $Name: geant4-09-01 $
// GEANT4 tag $Name: geant4-09-02 $
//
//
@@ -32,7 +32,6 @@
#include "G4ios.hh"
#ifdef G4ANALYSIS_USE
#include <AIDA/AIDA.h>
#include "exGPSAnalysisManager.hh"
#endif
@@ -54,11 +53,13 @@ void exGPSRunAction::BeginOfRunAction(const G4Run* aRun)
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
#ifdef G4VIS_USE
if (G4VVisManager::GetConcreteInstance())
{
G4UImanager* UI = G4UImanager::GetUIpointer();
UI->ApplyCommand("/vis/scene/notifyHandlers");
}
#endif
#ifdef G4ANALYSIS_USE
// If analysis is used reset the histograms
exGPSAnalysisManager::getInstance()->BeginOfRun();
@@ -69,9 +70,11 @@ void exGPSRunAction::BeginOfRunAction(const G4Run* aRun)
void exGPSRunAction::EndOfRunAction(const G4Run* )
{
#ifdef G4VIS_USE
if (G4VVisManager::GetConcreteInstance()) {
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update");
}
#endif
// If analysis is used
#ifdef G4ANALYSIS_USE
exGPSAnalysisManager::getInstance()->EndOfRun();