Import Geant4 5.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 16:57:27 +02:00
parent 330b82b769
commit 37fff30d2e
5733 changed files with 263867 additions and 74574 deletions
@@ -0,0 +1,288 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: XrayTelAnalysis.cc,v 1.8 2002/11/19 18:02:42 santin Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
// Author: A. Pfeiffer (Andreas.Pfeiffer@cern.ch)
// (copied from his UserAnalyser class)
//
// History:
// -----------
// 8 Nov 2002 GS Migration to AIDA 3
// 7 Nov 2001 MGP Implementation
//
// -------------------------------------------------------------------
#include "XrayTelAnalysis.hh"
#include "globals.hh"
#include "G4Track.hh"
#include "G4ios.hh"
#include "g4std/fstream"
#include "g4std/iomanip"
#include "G4SteppingManager.hh"
#include "G4ThreeVector.hh"
XrayTelAnalysis* XrayTelAnalysis::instance = 0;
XrayTelAnalysis::XrayTelAnalysis()
#ifdef G4ANALYSIS_USE
: analysisFactory(0)
, tree(0)
, histoFactory(0)
, tupleFactory(0)
#ifdef G4ANALYSIS_USE_PLOTTER
, plotterFactory(0)
, plotter(0)
#endif
#endif
{
#ifdef G4ANALYSIS_USE
histFileName = "xraytel";
histFileType = "hbook";
#endif
asciiFileName="xraytel.out";
G4std::ofstream asciiFile(asciiFileName, G4std::ios::app);
if(asciiFile.is_open()) {
asciiFile << "Energy (keV) x (mm) y (mm) z (mm)" << G4endl << G4endl;
}
}
XrayTelAnalysis::~XrayTelAnalysis()
{
#ifdef G4ANALYSIS_USE
#ifdef G4ANALYSIS_USE_PLOTTER
if (plotterFactory) delete plotterFactory;
plotterFactory = 0;
#endif
if (tupleFactory) delete tupleFactory;
tupleFactory = 0;
if (histoFactory) delete histoFactory;
histoFactory = 0;
if (tree) delete tree;
tree = 0;
if (analysisFactory) delete analysisFactory;
analysisFactory = 0;
#endif
}
XrayTelAnalysis* XrayTelAnalysis::getInstance()
{
if (instance == 0) instance = new XrayTelAnalysis;
return instance;
}
void XrayTelAnalysis::book()
{
#ifdef G4ANALYSIS_USE
//build up the factories
analysisFactory = AIDA_createAnalysisFactory();
if(analysisFactory) {
//parameters for the TreeFactory
G4bool fileExists = false;
G4bool readOnly = false;
AIDA::ITreeFactory* treeFactory = analysisFactory->createTreeFactory();
if(treeFactory) {
G4String histFileNameComplete;
histFileNameComplete = histFileName+".hbook";
tree = treeFactory->create(histFileNameComplete, "hbook", readOnly, fileExists);
G4cout << " Histogramfile: " << histFileNameComplete << G4endl;
if (tree) {
G4cout << "Tree store : " << tree->storeName() << G4endl;
G4cout << "Booked Hbook File " << G4endl;
//HistoFactory and TupleFactory depend on theTree
histoFactory = analysisFactory->createHistogramFactory ( *tree );
tupleFactory = analysisFactory->createTupleFactory ( *tree );
// Book histograms
histoFactory->createHistogram1D("1","Energy, all /keV", 100,0.,100.);
histoFactory->createHistogram2D("2","y-z, all /mm", 100,-500.,500.,100,-500.,500.);
histoFactory->createHistogram1D("3","Energy, entering detector /keV", 500,0.,500.);
histoFactory->createHistogram2D("4","y-z, entering detector /mm", 200,-50.,50.,200,-50.,50.);
// Book ntuples
AIDA::ITuple* ntuple10 = tupleFactory->create( "10", "Track ntuple",
"double energy,x,y,z,dirx,diry,dirz" );
assert(ntuple10);
}
delete treeFactory;
}
}
#endif
}
void XrayTelAnalysis::finish()
{
#ifdef G4ANALYSIS_USE
if (tree) {
// Committing the transaction with the tree
G4std::cout << "Committing..." << G4std::endl;
// write all histograms to file
tree->commit();
G4std::cout << "Closing the tree..." << G4std::endl;
// close (will again commit)
tree->close();
}
// extra delete as objects are created in book() method rather than during
// initialisation of class
#ifdef G4ANALYSIS_USE_PLOTTER
if (plotterFactory) delete plotterFactory;
#endif
if (tupleFactory) delete tupleFactory;
if (histoFactory) delete histoFactory;
if (tree) delete tree;
if (analysisFactory) delete analysisFactory;
#endif
}
void XrayTelAnalysis::analyseStepping(const G4Track& track, G4bool entering)
{
eKin = track.GetKineticEnergy()/keV;
G4ThreeVector pos = track.GetPosition()/mm;
y = pos.y();
z = pos.z();
G4ThreeVector dir = track.GetMomentumDirection();
dirX = dir.x();
dirY = dir.y();
dirZ = dir.z();
#ifdef G4ANALYSIS_USE
// Fill histograms, all tracks
AIDA::IHistogram1D* h1 = dynamic_cast<AIDA::IHistogram1D *> ( tree->find("1") );
h1->fill(eKin); // fill(x,y,weight)
AIDA::IHistogram2D* h2 = dynamic_cast<AIDA::IHistogram2D *> ( tree->find("2") );
h2->fill(y,z);
// Fill histograms and ntuple, tracks entering the detector
if (entering) {
// Fill and plot histograms
AIDA::IHistogram1D* h3 = dynamic_cast<AIDA::IHistogram1D *> ( tree->find("3") );
h3->fill(eKin);
AIDA::IHistogram2D* h4 = dynamic_cast<AIDA::IHistogram2D *> ( tree->find("4") );
h4->fill(y,z);
#ifdef G4ANALYSIS_USE_PLOTTER
plotAll();
#endif
}
// Fill ntuple
if (entering) {
AIDA::ITuple * ntuple = dynamic_cast<AIDA::ITuple *> ( tree->find("10") );
if (ntuple) {
// Fill the secondaries ntuple
ntuple->fill( ntuple->findColumn( "energy" ), (G4double) eKin );
ntuple->fill( ntuple->findColumn( "x" ), (G4double) x );
ntuple->fill( ntuple->findColumn( "y" ), (G4double) y );
ntuple->fill( ntuple->findColumn( "z" ), (G4double) z );
ntuple->fill( ntuple->findColumn( "dirx" ), (G4double) dirX );
ntuple->fill( ntuple->findColumn( "diry" ), (G4double) dirY );
ntuple->fill( ntuple->findColumn( "dirz" ), (G4double) dirZ );
ntuple->addRow(); // check for returning true ...
} else {
G4cout << "Ntuple not found" << G4endl;
}
}
#endif
// Write to file
if (entering) {
G4std::ofstream asciiFile(asciiFileName, G4std::ios::app);
if(asciiFile.is_open()) {
asciiFile << G4std::setiosflags(G4std::ios::fixed)
<< G4std::setprecision(3)
<< G4std::setiosflags(G4std::ios::right)
<< G4std::setw(10);
asciiFile << eKin;
asciiFile << G4std::setiosflags(G4std::ios::fixed)
<< G4std::setprecision(3)
<< G4std::setiosflags(G4std::ios::right)
<< G4std::setw(10);
asciiFile << x;
asciiFile << G4std::setiosflags(G4std::ios::fixed)
<< G4std::setprecision(3)
<< G4std::setiosflags(G4std::ios::right)
<< G4std::setw(10);
asciiFile << y;
asciiFile << G4std::setiosflags(G4std::ios::fixed)
<< G4std::setprecision(3)
<< G4std::setiosflags(G4std::ios::right)
<< G4std::setw(10);
asciiFile << z
<< G4endl;
asciiFile.close();
}
}
}
#ifdef G4ANALYSIS_USE_PLOTTER
void XrayTelAnalysis::plotAll()
{
if (!plotter) {
AIDA::IPlotterFactory* plotterFactory =
analysisFactory->createPlotterFactory();
if(plotterFactory) {
G4cout << "Creating the Plotter" << G4endl;
plotter = plotterFactory->create();
if(plotter) {
// Map the plotter on screen :
G4cout << "Showing the Plotter on screen" << G4endl;
plotter->show();
} else {
G4cout << "XrayTelAnalysis::plotAll: WARNING: Plotter not created" << G4endl;
}
delete plotterFactory;
} else {
G4cout << "XrayTelAnalysis::plotAll: WARNING: Plotter Factory not created" << G4endl;
}
}
if (plotter) {
AIDA::IHistogram1D* hp = dynamic_cast<AIDA::IHistogram1D *> ( tree->find("3") );
AIDA::IHistogram1D& h = *hp;
(plotter->currentRegion()).plot(h);
plotter->refresh();
}
}
#endif
@@ -1,215 +0,0 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// **********************************************************************
// * *
// * GEANT 4 xray_telescope advanced example *
// * *
// * MODULE: XrayTelAnalysisManager.cc *
// * ------- *
// * *
// * Version: 0.2 *
// * Date: 30/11/00 *
// * Author: A. Pfeiffer, G. Barrand, MG Pia, R Nartallo *
// * Organisation: ESA/ESTEC, Noordwijk, THe Netherlands *
// * *
// **********************************************************************
//
// CHANGE HISTORY
// --------------
//
// 07.12.2001 A.Pfeiffer
// - merged with Guy Barrand's AIDA 2.2 port
//
// 22.11.2001 G.Barrand
// - Adaptation to AIDA
//
// 30.11.2000 M.G. Pia, R. Nartallo
// - Simplification of code: removal of non-Lizard specific code
// - Inheritance directly from the base class G4VAnalysisManager instead
// of the derived class G4AnalysisManager
//
// 15.11.2000 A. Pfeiffer
// - Adaptation to Lizard
//
// 16.10.2000 G. Barrand
// - First implementation of XrayAnalysisManager
// - Provision of code for various AIDA and non-AIDA systems
//
// **********************************************************************
#include "g4std/fstream"
#include "G4ios.hh"
#include "G4Run.hh"
#include "G4Event.hh"
#include "G4Track.hh"
#include "G4VVisManager.hh"
#include "G4TrajectoryContainer.hh"
#include "G4Trajectory.hh"
#ifdef G4ANALYSIS_USE
#include <AIDA/IAnalysisFactory.h>
#include <AIDA/ITreeFactory.h>
#include <AIDA/ITree.h>
#include <AIDA/IHistogramFactory.h>
#include <AIDA/IHistogram1D.h>
#include <AIDA/IHistogram2D.h>
#include <AIDA/IPlotterFactory.h>
#include <AIDA/IPlotter.h>
#endif
#include "XrayTelAnalysis.hh"
XrayTelAnalysis* XrayTelAnalysis::instance = 0;
XrayTelAnalysis::XrayTelAnalysis(int argc,char** argv)
:analysisFactory(0)
,tree(0)
,enteringEnergyHistogram(0)
,yzHistogram(0)
{
#ifdef G4ANALYSIS_USE
// Hooking an AIDA compliant analysis system.
analysisFactory = AIDA_createAnalysisFactory();
if(analysisFactory) {
ITreeFactory* treeFactory = analysisFactory->createTreeFactory();
if(treeFactory) {
// tree = treeFactory->create(); // Tree in memory.
tree = treeFactory->create("XrayTel.root",false,false,"ROOT");
if(tree) {
IHistogramFactory* hFactory =
analysisFactory->createHistogramFactory(*tree);
if(hFactory) {
// Histogram creation (the below has a name and a label) :
enteringEnergyHistogram =
hFactory->create1D("ekin.vop","Entering energy",100,0,0.5);
// Book the histogram for the 2D position.
// Instead of using a scatter plot, just book enough bins ...
yzHistogram =
hFactory->create2D("position.vop","YZ",200, -50, 50, 200, -50, 50);
delete hFactory;
}
}
delete treeFactory; // Will not delete the ITree.
}
/*
The following lines set the plotter that is
needed in this example for a multiple histograms
visualization. Please see the README for more information
*/
IPlotterFactory* plotterFactory =
analysisFactory->createPlotterFactory(argc,argv);
if(plotterFactory) {
plotter = plotterFactory->create();
if(plotter) {
// Map the plotter on screen :
plotter->show();
// Set the page title :
plotter->setParameter("pageTitle","XrayTel");
// Have two plotting regions (one column, two rows).
plotter->createRegions(1,2);
// Attach histograms to plotter regions :
if(enteringEnergyHistogram) {
plotter->plot(*enteringEnergyHistogram);
plotter->next();
}
if(yzHistogram) {
plotter->plot(*yzHistogram);
}
}
delete plotterFactory;
}
}
#endif
}
XrayTelAnalysis::~XrayTelAnalysis()
{
#ifdef G4ANALYSIS_USE
delete plotter;
delete enteringEnergyHistogram;
delete yzHistogram;
delete analysisFactory;
#endif
}
XrayTelAnalysis* XrayTelAnalysis::getInstance(G4int argc, char** argv)
{
if (instance == 0) instance = new XrayTelAnalysis(argc, argv);
return instance;
}
void XrayTelAnalysis::book(){
#ifdef G4ANALYSIS_USE
if(enteringEnergyHistogram) enteringEnergyHistogram->reset();
if(yzHistogram) yzHistogram->reset();
#endif
}
void XrayTelAnalysis::finish(){
#ifdef G4ANALYSIS_USE
// the following things cannot be done in Run::EndOfRun()
// only now plot the energy of the particles
if(tree) tree->commit(); // Write histos in file.
// Give control to the GUI so that someone
// can play with the plotter. The plotter
// should be equipped with an "escape" (button)
// to return of the "interact" method.
G4cout << "Click the escape button to continue..." << G4endl;
if(plotter) plotter->interact();
#endif
}
void XrayTelAnalysis::analyseStepping(const G4Track& track, G4bool entering) {
#ifdef G4ANALYSIS_USE
G4ThreeVector pos = track.GetPosition();
if(enteringEnergyHistogram) {
enteringEnergyHistogram->fill(track.GetKineticEnergy());
}
if(yzHistogram) {
yzHistogram->fill(pos.y(), pos.z());
}
if(plotter) plotter->refresh();
#endif
}
@@ -1,169 +0,0 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: XrayTelAnalysis.cc-Anaphe,v 1.1 2001/12/10 16:06:37 pfeiffer Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// Author: A. Pfeiffer (Andreas.Pfeiffer@cern.ch)
// (copied from his UserAnalyser class)
//
// History:
// -----------
// 7 Nov 2001 MGP Implementation
//
// -------------------------------------------------------------------
#include "XrayTelAnalysis.hh"
#include "globals.hh"
#include "G4Track.hh"
#include "G4SteppingManager.hh"
#include "G4ThreeVector.hh"
XrayTelAnalysis* XrayTelAnalysis::instance = 0;
XrayTelAnalysis::XrayTelAnalysis()
{
histoManager = createIHistoManager();
ntFactory = Lizard::createNTupleFactory();
vectorFactory = createIVectorFactory();
plotter = createIPlotter();
}
XrayTelAnalysis::~XrayTelAnalysis()
{
delete ntFactory;
ntFactory = 0;
delete histoManager;
histoManager = 0;
delete vectorFactory;
vectorFactory = 0;
delete plotter;
plotter = 0;
}
XrayTelAnalysis* XrayTelAnalysis::getInstance()
{
if (instance == 0) instance = new XrayTelAnalysis;
return instance;
}
void XrayTelAnalysis::book()
{
histoManager->selectStore("XrayTel.his");
// Book histograms
histoManager->create1D("1","Energy, all", 20,0.,10.);
histoManager->create2D("2","y-z, all", 100,-500.,500.,100,-500.,500.);
histoManager->create1D("3","Energy, entering detector", 10,0.,1.);
histoManager->create2D("4","y-z, entering detector", 200,-50.,50.,200,-50.,50.);
// Divide the plot into 4 zones to show the 4 histograms during execution
plotter->zone(2,2,0,0);
// Book ntuples
ntuple = ntFactory->createC("XrayTel.his::1");
// Add and bind the attributes to the ntuple
if ( !( ntuple->addAndBind( "energy", eKin) &&
ntuple->addAndBind( "y" , y ) &&
ntuple->addAndBind( "z" , z ) &&
ntuple->addAndBind( "dirx" , dirX) &&
ntuple->addAndBind( "diry" , dirY) &&
ntuple->addAndBind( "dirz" , dirZ) ) )
{
delete ntuple;
G4Exception(" XrayTelAnalysis::book - Could not addAndBind ntuple");
}
}
void XrayTelAnalysis::finish()
{
// Store histograms
// Because of a Lizard feature, ntuples must be deleted at this stage,
// not in the destructor (otherwise the ntuples are not stored)
histoManager->store("1");
histoManager->store("3");
histoManager->store("2");
histoManager->store("4");
delete ntuple;
ntuple = 0;
G4cout << "Deleted ntuple" << G4endl;
}
void XrayTelAnalysis::analyseStepping(const G4Track& track, G4bool entering)
{
eKin = track.GetKineticEnergy();
G4ThreeVector pos = track.GetPosition();
y = pos.y();
z = pos.z();
G4ThreeVector dir = track.GetMomentumDirection();
dirX = dir.x();
dirY = dir.y();
dirZ = dir.z();
// Fill histograms, all tracks
IHistogram1D* h1 = histoManager->retrieveHisto1D("1");
h1->fill(eKin);
IHistogram2D* h2 = histoManager->retrieveHisto2D("2");
h2->fill(y,z);
// Fill histograms and ntuple, tracks entering the detector
if (entering)
{
// Fill and plot histograms
IHistogram1D* h3 = histoManager->retrieveHisto1D("3");
h3->fill(eKin);
plot1D(h1);
plot1D(h3);
IHistogram2D* h4 = histoManager->retrieveHisto2D("4");
h4->fill(y,z);
plot2D(h2);
plot2D(h4);
// Fill ntuple
ntuple->addRow();
}
}
void XrayTelAnalysis::plot1D(IHistogram1D* histo)
{
IVector* v = vectorFactory->from1D(histo);
plotter->plot(v,0);
plotter->refresh();
delete v;
}
void XrayTelAnalysis::plot2D(IHistogram2D* histo)
{
IVector* v = vectorFactory->from2D(histo);
plotter->plot(v,0);
plotter->refresh();
delete v;
}
@@ -63,7 +63,7 @@ XrayTelEventActionMessenger::XrayTelEventActionMessenger(XrayTelEventAction* EvA
DrawCmd->SetParameterName("choice",true);
DrawCmd->SetDefaultValue("charged");
DrawCmd->SetCandidates("none charged all");
DrawCmd->AvailableForStates(Idle);
DrawCmd->AvailableForStates(G4State_Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -82,8 +82,6 @@ void XrayTelSteppingAction::UserSteppingAction(const G4Step* step)
G4bool entering = false;
G4Track* track = step->GetTrack();
G4int stepNo = track->GetCurrentStepNumber();
G4String volName;
if (track->GetVolume()) volName = track->GetVolume()->GetName();
G4String nextVolName;
+4 -2
View File
@@ -34,14 +34,14 @@
// * Organisation: ESA/ESTEC, Noordwijk, THe Netherlands *
// * *
// **********************************************************************
//
//
// CHANGE HISTORY
// --------------
//
// 06.11.2000 R.Nartallo
// - First implementation of xray_telescope Physics list
// - Based on Chandra and XMM models
//
//
//
// **********************************************************************
@@ -56,6 +56,7 @@
#include "G4DAWNFILE.hh"
#include "G4GAGTree.hh"
#include "G4HepRepFile.hh"
#include "G4HepRep.hh"
#include "G4RayTracer.hh"
#include "G4VRML1File.hh"
#include "G4VRML2File.hh"
@@ -112,6 +113,7 @@ void XrayTelVisManager::RegisterGraphicsSystems () {
RegisterGraphicsSystem (new G4DAWNFILE);
RegisterGraphicsSystem (new G4GAGTree);
RegisterGraphicsSystem (new G4HepRepFile);
RegisterGraphicsSystem (new G4HepRep);
RegisterGraphicsSystem (new G4RayTracer);
RegisterGraphicsSystem (new G4VRML1File);
RegisterGraphicsSystem (new G4VRML2File);