Import Geant4 4.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 16:18:25 +02:00
parent 36c080dca6
commit 921d3b1cda
3990 changed files with 185376 additions and 82884 deletions
@@ -0,0 +1,344 @@
//
// ********************************************************************
// * 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: GammaRayTelAnalysis.cc-AIDA,v 1.3 2001/12/07 13:20:20 pfeiffer Exp $
// GEANT4 tag $Name: geant4-04-00 $
// ------------------------------------------------------------
// GEANT 4 class implementation file
// CERN Geneva Switzerland
//
//
// ------------ GammaRayAnalysisManager ------
// by R.Giannitrapani, F.Longo & G.Santin (03 dic 2000)
//
// 07.12.2001 A.Pfeiffer
// - integrated Guy's addition of the ntuple
//
// 06.12.2001 A.Pfeiffer
// - updating to new design (singleton)
//
// 22.11.2001 G.Barrand
// - Adaptation to AIDA
//
// ************************************************************
#include "G4RunManager.hh"
#include "GammaRayTelAnalysis.hh"
#include "GammaRayTelDetectorConstruction.hh"
#include "GammaRayTelAnalysisMessenger.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>
#include <AIDA/ITupleFactory.h>
#include <AIDA/ITuple.h>
#endif
GammaRayTelAnalysis* GammaRayTelAnalysis::instance = 0;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
GammaRayTelAnalysis::GammaRayTelAnalysis(int argc,char** argv)
:GammaRayTelDetector(0)
,analysisFactory(0), tree(0), plotter(0), tuple(0)
,energy(0), hits(0), posXZ(0), posYZ(0)
,histo1DDraw("enable"),histo1DSave("enable"),histo2DDraw("enable")
,histo2DSave("enable"),histo2DMode("strip")
{
G4RunManager* runManager = G4RunManager::GetRunManager();
GammaRayTelDetector =
(GammaRayTelDetectorConstruction*)(runManager->GetUserDetectorConstruction());
#ifdef G4ANALYSIS_USE
// Define the messenger and the analysis system
analysisMessenger = new GammaRayTelAnalysisMessenger(this);
analysisFactory = AIDA_createAnalysisFactory();
if(analysisFactory) {
ITreeFactory* treeFactory = analysisFactory->createTreeFactory();
if(treeFactory) {
// Tree in memory :
//tree = treeFactory->create();
// Create a "tree" associated to a ROOT "store" (in RECREATE mode).
tree = treeFactory->create("GammaRayTel.root",false,false,"ROOT");
if(tree) {
IHistogramFactory* histoFactory =
analysisFactory->createHistogramFactory(*tree);
if(histoFactory) {
// Create histos :
int Nplane = GammaRayTelDetector->GetNbOfTKRLayers();
int Nstrip = GammaRayTelDetector->GetNbOfTKRStrips();
int Ntile = GammaRayTelDetector->GetNbOfTKRTiles();
float sizexy = GammaRayTelDetector->GetTKRSizeXY();
float sizez = GammaRayTelDetector->GetTKRSizeZ();
int N = Nstrip*Ntile;
// 1D histogram that store the energy deposition of the
// particle in the last (number 0) TKR X-plane
energy = histoFactory->create1D("1","Energy deposition in the last X plane (keV)", 100, 50, 200);
// 1D histogram that store the hits distribution along the TKR X-planes
hits = histoFactory->create1D("2","Hits distribution in the TKR X planes",Nplane, 0, Nplane-1);
// 2D histogram that store the position (mm) of the hits (XZ projection)
if (histo2DMode == "strip")
posXZ = histoFactory->create2D("3","Tracker Hits XZ (strip,plane)",
N, 0, N-1,
2*Nplane, 0, Nplane-1);
else
posXZ = histoFactory->create2D("3","Tracker Hits XZ (x,z) in mm",
sizexy/5, -sizexy/2, sizexy/2,
sizez/5, -sizez/2, sizez/2);
// 2D histogram that store the position (mm) of the hits (YZ projection)
if(histo2DMode=="strip")
posYZ = histoFactory->create2D("4","Tracker Hits YZ (strip,plane)",
N, 0, N-1,
2*Nplane, 0, Nplane-1);
else
posYZ = histoFactory->create2D("4","Tracker Hits YZ (y,z) in mm",
sizexy/5, -sizexy/2, sizexy/2,
sizez/5, -sizez/2, sizez/2);
delete histoFactory;
}
// Get a tuple factory :
ITupleFactory* tupleFactory = analysisFactory->createTupleFactory(*tree);
if(tupleFactory) {
// Create a tuple :
tuple = tupleFactory->create("tuple","tuple",
"energy plane x y z");
delete tupleFactory;
}
}
delete treeFactory; // Will not delete the ITree.
}
IPlotterFactory* plotterFactory =
analysisFactory->createPlotterFactory(argc,argv);
if(plotterFactory) {
plotter = plotterFactory->create();
if(plotter) {
plotter->show();
plotter->setParameter("pageTitle","Gamma Ray Tel");
}
delete plotterFactory;
}
}
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
GammaRayTelAnalysis::~GammaRayTelAnalysis() {
Finish();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void GammaRayTelAnalysis::Init()
{
}
void GammaRayTelAnalysis::Finish()
{
#ifdef G4ANALYSIS_USE
delete plotter;
delete analysisFactory; // Will delete tree and histos.
delete analysisMessenger;
analysisMessenger = 0;
#endif
}
GammaRayTelAnalysis* GammaRayTelAnalysis::getInstance(int argc,char** argv)
{
if (instance == 0) instance = new GammaRayTelAnalysis(argc,argv);
return instance;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
// This function fill the 2d histogram of the XZ positions
void GammaRayTelAnalysis::InsertPositionXZ(double x, double z)
{
#ifdef G4ANALYSIS_USE
if(posXZ) posXZ->fill(x, z);
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
// This function fill the 2d histogram of the YZ positions
void GammaRayTelAnalysis::InsertPositionYZ(double y, double z)
{
#ifdef G4ANALYSIS_USE
if(posYZ) posYZ->fill(y, z);
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
// This function fill the 1d histogram of the energy released in the last Si plane
void GammaRayTelAnalysis::InsertEnergy(double en)
{
#ifdef G4ANALYSIS_USE
if(energy) energy->fill(en);
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
// This function fill the 1d histogram of the hits distribution along the TKR planes
void GammaRayTelAnalysis::InsertHits(int nplane)
{
#ifdef G4ANALYSIS_USE
if(hits) hits->fill(nplane);
#endif
}
void GammaRayTelAnalysis::setNtuple(float E, float p, float x, float y, float z)
{
#ifdef G4ANALYSIS_USE
if(tuple) {
tuple->fill(0,E);
tuple->fill(1,p);
tuple->fill(2,x);
tuple->fill(3,y);
tuple->fill(4,z);
tuple->addRow();
}
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
/*
This member reset the histograms and it is called at the begin
of each run; here we put the inizialization so that the histograms have
always the right dimensions depending from the detector geometry
*/
void GammaRayTelAnalysis::BeginOfRun(G4int n)
{
#ifdef G4ANALYSIS_USE
if(energy) energy->reset();
if(hits) hits->reset();
if(posXZ) posXZ->reset();
if(posYZ) posYZ->reset();
// Set the plotter ; set the number of regions and attach histograms
// to plot for each region.
// It is done here, since then EndOfRun set regions
// for paper output.
if(plotter) {
if((histo2DDraw == "enable") && (histo1DDraw == "enable")) {
plotter->createRegions(2,2);
plotter->plot(*posXZ);
plotter->next();
plotter->plot(*posYZ);
plotter->next();
plotter->plot(*energy);
plotter->next();
plotter->plot(*hits);
} else if((histo1DDraw == "enable") && (histo2DDraw != "enable")) {
plotter->createRegions(1,2);
plotter->plot(*energy);
plotter->next();
plotter->plot(*hits);
} else if((histo1DDraw != "enable") && (histo2DDraw == "enable")) {
plotter->createRegions(1,2);
plotter->plot(*posXZ);
plotter->next();
plotter->plot(*posYZ);
} else { // Nothing to plot.
plotter->createRegions(1,1);
}
plotter->refresh();
}
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
/*
This member is called at the end of each run
*/
void GammaRayTelAnalysis::EndOfRun(G4int n)
{
#ifdef G4ANALYSIS_USE
if(tree) tree->commit();
if(plotter) {
// We set one single region for the plotter
plotter->createRegions(1,1);
// We now print the histograms, each one in a separate file
if(histo2DSave == "enable") {
char name[15];
sprintf(name,"posxz_%d.ps", n);
plotter->plot(*posXZ);
plotter->write(name,"PS");
sprintf(name,"posyz_%d.ps", n);
plotter->clearRegion();
plotter->plot(*posYZ);
plotter->write(name,"PS");
}
if(histo1DSave == "enable") {
char name[15];
sprintf(name,"energy_%d.ps", n);
plotter->plot(*energy);
plotter->write(name,"PS");
sprintf(name,"hits_%d.ps", n);
plotter->clearRegion();
plotter->plot(*hits);
plotter->write(name,"PS");
}
}
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
/* This member is called at the end of every event */
void GammaRayTelAnalysis::EndOfEvent(G4int flag)
{
// The plotter is updated only if there is some
// hits in the event
if(!flag) return;
#ifdef G4ANALYSIS_USE
if(plotter) plotter->refresh();
#endif
}
@@ -0,0 +1,405 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// Author: A. Pfeiffer (Andreas.Pfeiffer@cern.ch)
// (copied from his UserAnalyser class)
//
// History:
// -----------
// 7 Nov 2001 MGP Implementation
// 03 dic 2000 AnalysisManager by R.Giannitrapani, F.Longo & G.Santin
// 18 Nov 2001 G.Santin GammaRayTel analysis management modified
// according to the new design
//
// -------------------------------------------------------------------
#ifdef G4ANALYSIS_USE
#include "GammaRayTelAnalysis.hh"
#include "GammaRayTelAnalysisMessenger.hh"
#include "globals.hh"
#include "G4RunManager.hh"
#include "G4Track.hh"
#include "G4SteppingManager.hh"
#include "G4ThreeVector.hh"
#include "GammaRayTelDetectorConstruction.hh"
//using namespace Lizard;
GammaRayTelAnalysis* GammaRayTelAnalysis::instance = 0;
GammaRayTelAnalysis::GammaRayTelAnalysis() :
histoManager(0), vectorFactory(0),plotter(0),
histo1DDraw("enable"),histo1DSave("enable"),histo2DDraw("enable"),
histo2DSave("enable"),histo2DMode("strip"),
analysisMessenger(0)
{
}
GammaRayTelAnalysis::~GammaRayTelAnalysis()
{
Finish();
}
void GammaRayTelAnalysis::Init()
{
G4RunManager* runManager = G4RunManager::GetRunManager();
GammaRayTelDetector =
(GammaRayTelDetectorConstruction*)(runManager->GetUserDetectorConstruction());
analysisMessenger = new GammaRayTelAnalysisMessenger(this);
histoManager = createIHistoManager();
#ifdef G4ANALYSIS_USE_NTUPLE
ntFactory = Lizard::createNTupleFactory();
#endif
vectorFactory = createIVectorFactory();
plotter = createIPlotter();
}
void GammaRayTelAnalysis::Finish()
{
#ifdef G4ANALYSIS_USE_NTUPLE
delete ntFactory;
ntFactory = 0;
#endif
delete histoManager;
histoManager = 0;
delete vectorFactory;
vectorFactory = 0;
delete plotter;
plotter = 0;
delete analysisMessenger;
analysisMessenger = 0;
}
GammaRayTelAnalysis* GammaRayTelAnalysis::getInstance()
{
if (instance == 0) instance = new GammaRayTelAnalysis;
return instance;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
// This function fill the 2d histogram of the XZ positions
void GammaRayTelAnalysis::InsertPositionXZ(double x, double z)
{
IHistogram2D* posXZ = histoManager->retrieveHisto2D("3");
posXZ->fill(x, z);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
// This function fill the 2d histogram of the YZ positions
void GammaRayTelAnalysis::InsertPositionYZ(double y, double z)
{
IHistogram2D* posYZ = histoManager->retrieveHisto2D("4");
posYZ->fill(y, z);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
// This function fill the 1d histogram of the energy released in the last Si plane
void GammaRayTelAnalysis::InsertEnergy(double en)
{
IHistogram1D* energy = histoManager->retrieveHisto1D("1");
energy->fill(en);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
// This function fill the 1d histogram of the hits distribution along the TKR planes
void GammaRayTelAnalysis::InsertHits(int nplane)
{
IHistogram1D* hits = histoManager->retrieveHisto1D("2");
hits->fill(nplane);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
/*
This member reset the histograms and it is called at the begin
of each run; here we put the inizialization so that the histograms have
always the right dimensions depending from the detector geometry
*/
void GammaRayTelAnalysis::BeginOfRun(G4int n)
{
float sizexy, sizez;
int Nstrip, Nplane, Ntile, N;
char name[30];
Init();
// Relevant data from the detector to set the histograms dimensions
Nplane = GammaRayTelDetector->GetNbOfTKRLayers();
Nstrip = GammaRayTelDetector->GetNbOfTKRStrips();
Ntile = GammaRayTelDetector->GetNbOfTKRTiles();
sizexy = GammaRayTelDetector->GetTKRSizeXY();
sizez = GammaRayTelDetector->GetTKRSizeZ();
N = Nstrip*Ntile;
if (histoManager) {
sprintf(name,"gammaraytel%d.hbook", n);
histoManager->selectStore(name);
// Check if deleteHisto is enough, maybe we need to delete the object
histoManager->deleteHisto("1");
histoManager->create1D("1","Energy deposition in the last X plane (keV)", 100, 50., 200.);
// 1D histogram that store the hits distribution along the TKR X-planes
histoManager->deleteHisto("2");
histoManager->create1D("2","Hits distribution in the TKR X planes",
Nplane, 0, Nplane-1);
// 2D histogram that store the position (mm) of the hits (XZ projection)
histoManager->deleteHisto("3");
if (histo2DMode == "strip")
histoManager->create2D("3","Tracker Hits XZ (strip,plane)",
N, 0, N-1,
2*Nplane, 0, Nplane-1);
else
histoManager->create2D("3","Tracker Hits XZ (x,z) in mm",
sizexy/5, -sizexy/2, sizexy/2,
sizez/5, -sizez/2, sizez/2);
// 2D histogram that store the position (mm) of the hits (YZ projection)
histoManager->deleteHisto("4");
if(histo2DMode=="strip")
histoManager->create2D("4","Tracker Hits YZ (strip,plane)",
N, 0, N-1,
2*Nplane, 0, Nplane-1);
else
histoManager->create2D("4","Tracker Hits YZ (y,z) in mm",
sizexy/5, -sizexy/2, sizexy/2,
sizez/5, -sizez/2, sizez/2);
}
IHistogram2D* posXZ = histoManager->retrieveHisto2D("3");
if (posXZ)
posXZ->reset();
IHistogram2D* posYZ = histoManager->retrieveHisto2D("4");
if(posYZ)
posYZ->reset();
IHistogram1D* energy = histoManager->retrieveHisto1D("1");
if(energy)
energy->reset();
IHistogram1D* hits = histoManager->retrieveHisto1D("2");
if(hits)
hits->reset();
// We divide the plotter in the right nuber of zone depending
// on which histograms the user want to draw
if((histo2DDraw == "enable") && (histo1DDraw == "enable"))
plotter->zone(2,2,0,0);
else if((histo1DDraw == "enable") || (histo2DDraw == "enable"))
plotter->zone(1,2,0,0);
else
plotter->zone(1,1,0,0);
#ifdef G4ANALYSIS_USE_NTUPLE
// Book ntuples
sprintf(name,"gammaraytel%d.hbook::1", n);
ntuple = ntFactory->createC(name);
// Add and bind the attributes to the ntuple
if ( !( ntuple->addAndBind( "energy", ntEnergy) &&
ntuple->addAndBind( "plane" , ntPlane) &&
ntuple->addAndBind( "x" , ntX ) &&
ntuple->addAndBind( "y" , ntY ) &&
ntuple->addAndBind( "z" , ntZ ) ) ) {
delete ntuple;
G4Exception(" GammaRayTelAnalysis::BeginOfRun - Could not addAndBind ntuple");
}
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
/*
This member is called at the end of each run
*/
void GammaRayTelAnalysis::EndOfRun(G4int n)
{
// This variable contains the names of the PS files
char name[15];
// We define some vectors
IVector* vxz = 0;
IVector* vyz = 0;
IVector* ve = 0;
IVector* vhit = 0;
// Temporary we set one single zone for the plotter
plotter->zone(1,1,0,0);
// We now print the histograms, each one in a separate file
if(histo2DSave == "enable") {
IHistogram2D* posXZ = histoManager->retrieveHisto2D("3");
IHistogram2D* posYZ = histoManager->retrieveHisto2D("4");
plot2D(posXZ);
sprintf(name,"posxz_%d.ps", n);
plotter->psPrint(name);
plot2D(posYZ);
sprintf(name,"posyz_%d.ps", n);
plotter->psPrint(name);
}
if(histo1DSave == "enable") {
IHistogram1D* energy = histoManager->retrieveHisto1D("1");
IHistogram1D* hits = histoManager->retrieveHisto1D("2");
plot1D(energy);
sprintf(name,"energy_%d.ps", n);
plotter->psPrint(name);
plot1D(hits);
sprintf(name,"hits_%d.ps", n);
plotter->psPrint(name);
}
delete vxz;
delete vyz;
delete ve;
delete vhit;
// Store histograms
// Because of a Lizard feature, ntuples must be deleted at this stage,
// not in the destructor (otherwise the ntuples are not stored)
// In version 3.6.4 of Anaphe, no licence, storing other histograms after
// having stored a 2D one generates an error message "ERROR in HLNEXT"
// Histograms are stored correctly, in spite of the error message
// The same error message is issued if attempting to store 1D or 2D
// histograms after deleting a ntuple
histoManager->store("1");
histoManager->store("3");
histoManager->store("2");
histoManager->store("4");
#ifdef G4ANALYSIS_USE_NTUPLE
delete ntuple;
ntuple = 0;
G4cout << "Deleted ntuple" << G4endl;
#endif
// close files for this run
if (histoManager != 0) Finish();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
/* This member is called at the end of every event */
void GammaRayTelAnalysis::EndOfEvent(G4int flag)
{
// The histograms are updated only if there is some
// hits in the event
if(flag) Plot();
}
void GammaRayTelAnalysis::Plot()
{
// In a normal case we use the following line to use the standard plot
// analysisSystem->Plot(histo);
// We define some vectors
IVector* vxz = 0;
IVector* vyz = 0;
IVector* ve = 0;
IVector* vhit= 0;
// We fill them with the histograms and
// draw them
if(histo2DDraw == "enable")
{
IHistogram2D* posXZ = histoManager->retrieveHisto2D("3");
IHistogram2D* posYZ = histoManager->retrieveHisto2D("4");
plot2D(posXZ);
plot2D(posYZ);
plotter->refresh();
}
if(histo1DDraw == "enable")
{
IHistogram1D* energy = histoManager->retrieveHisto1D("1");
IHistogram1D* hits = histoManager->retrieveHisto1D("2");
plot1D(energy);
plot1D(hits);
plotter->refresh();
}
delete vxz;
delete vyz;
delete ve;
delete vhit;
}
void GammaRayTelAnalysis::plot1D(IHistogram1D* histo)
{
IVector* v = vectorFactory->from1D(histo);
plotter->plot(v,0);
plotter->refresh();
delete v;
}
void GammaRayTelAnalysis::plot2D(IHistogram2D* histo)
{
IVector* v = vectorFactory->from2D(histo);
plotter->plot(v,0);
plotter->refresh();
delete v;
}
#ifdef G4ANALYSIS_USE_NTUPLE
void GammaRayTelAnalysis::setNtuple(float E, float p, float x, float y, float z)
{
ntEnergy = E;
ntPlane = p;
ntX = x;
ntY = y;
ntZ = z;
ntuple->addRow();
}
#endif
#endif
@@ -1,334 +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: GammaRayTelAnalysisManager.cc,v 1.1.4.2 2001/06/28 20:18:40 gunter Exp $
// GEANT4 tag $Name: $
// ------------------------------------------------------------
// GEANT 4 class implementation file
// CERN Geneva Switzerland
//
//
// ------------ GammaRayAnalysisManager ------
// by R.Giannitrapani, F.Longo & G.Santin (03 dic 2000)
//
// ************************************************************
#ifdef G4ANALYSIS_USE
#include <stdlib.h>
#include "g4std/fstream"
#include "GammaRayTelAnalysisManager.hh"
#include "G4VAnalysisSystem.hh"
#include "GammaRayTelDetectorConstruction.hh"
#include "GammaRayTelAnalysisMessenger.hh"
#include <IHistogramFactory.h>
#include <IHistogram1D.h>
#include <IHistogram2D.h>
#include <IPlotter.h>
#include <IVector.h>
#include <IVectorFactory.h>
#include "G4LizardSystem.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
GammaRayTelAnalysisManager::GammaRayTelAnalysisManager(GammaRayTelDetectorConstruction* GammaRayTelDC):
GammaRayTelDetector(GammaRayTelDC),
posXZ(0), posYZ(0), energy(0), hits(0), histoFactory(0), pl(0),
histo1DDraw("enable"),histo1DSave("enable"),histo2DDraw("enable"),
histo2DSave("enable"),histo2DMode("strip")
{
// Define the messenger and the analysis system
analysisMessenger = new GammaRayTelAnalysisMessenger(this);
analysisSystem = new G4LizardSystem;
histoFactory = analysisSystem->GetHistogramFactory();
/*
The following lines set the plotter and the vectorfactory that
are needed in this example for a multiple histograms
visualization. Please see the README for more information
*/
fVectorFactory = createIVectorFactory();
pl = createIPlotter();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
GammaRayTelAnalysisManager::~GammaRayTelAnalysisManager() {
delete posXZ;
delete posYZ;
delete energy;
delete hits;
delete analysisSystem;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4bool GammaRayTelAnalysisManager::RegisterAnalysisSystem(G4VAnalysisSystem*)
{
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
IHistogramFactory* GammaRayTelAnalysisManager::GetHistogramFactory(const G4String& aSystem)
{
return histoFactory;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void GammaRayTelAnalysisManager::Store(IHistogram* histo, const G4String& ID)
{
analysisSystem->Store(histo, ID);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
/*
Since the Lizard interface and analysis classes in G4 are still
experimental, they lack for now the possibility to show directly
more than one histograms at the same time. In order to show 2 or 4 histo
in a single view in our example, we decided to override this implementation
and use directly the IPlotter interface for our needs. This will change
in future releases.
Please note that for visualization purpouses the histograms result
stretched along the x axis; when they are saved in a PostScript
file the proportions are the right ones.
*/
void GammaRayTelAnalysisManager::Plot(IHistogram* histo = 0)
{
// In a normal case we use the following line to use the standard plot
// analysisSystem->Plot(histo);
// We define some vectors
IVector* vxz = 0;
IVector* vyz = 0;
IVector* ve = 0;
IVector* vhit= 0;
// We fill them with the histograms and
// draw them
if(histo2DDraw == "enable")
{
vxz = fVectorFactory->from2D(dynamic_cast<IHistogram2D*>(posXZ));
vyz = fVectorFactory->from2D(dynamic_cast<IHistogram2D*>(posYZ));
pl->plot(vxz);
pl->plot(vyz);
pl->refresh();
}
if(histo1DDraw == "enable")
{
ve = fVectorFactory->from1D(dynamic_cast<IHistogram1D*>(energy));
vhit = fVectorFactory->from1D(dynamic_cast<IHistogram1D*>(hits));
pl->plot(ve);
pl->plot(vhit);
pl->refresh();
}
delete vxz;
delete vyz;
delete ve;
delete vhit;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
// This function fill the 2d histogram of the XZ positions
void GammaRayTelAnalysisManager::InsertPositionXZ(double x, double z)
{
posXZ->fill(x, z);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
// This function fill the 2d histogram of the YZ positions
void GammaRayTelAnalysisManager::InsertPositionYZ(double y, double z)
{
posYZ->fill(y, z);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
// This function fill the 1d histogram of the energy released in the last Si plane
void GammaRayTelAnalysisManager::InsertEnergy(double en)
{
energy->fill(en);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
// This function fill the 1d histogram of the hits distribution along the TKR planes
void GammaRayTelAnalysisManager::InsertHits(int nplane)
{
hits->fill(nplane);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
/*
This member reset the histograms and it is called at the begin
of each run; here we put the inizialization so that the histograms have
always the right dimensions depending from the detector geometry
*/
void GammaRayTelAnalysisManager::BeginOfRun()
{
float sizexy, sizez;
int nplane;
int Nstrip, Nplane, Ntile, N;
// Relevant data from the detector to set the histograms dimensions
Nplane = GammaRayTelDetector->GetNbOfTKRLayers();
Nstrip = GammaRayTelDetector->GetNbOfTKRStrips();
Ntile = GammaRayTelDetector->GetNbOfTKRTiles();
sizexy = GammaRayTelDetector->GetTKRSizeXY();
sizez = GammaRayTelDetector->GetTKRSizeZ();
N = Nstrip*Ntile;
if (histoFactory)
{
// 1D histogram that store the energy deposition of the
// particle in the last (number 0) TKR X-plane
histoFactory->destroy(energy);
energy = histoFactory->create1D("Energy deposition in the last X plane (keV)", 100, 50, 200);
// 1D histogram that store the hits distribution along the TKR X-planes
histoFactory->destroy(hits);
hits = histoFactory->create1D("Hits distribution in the TKR X planes",
Nplane, 0, Nplane-1);
// 2D histogram that store the position (mm) of the hits (XZ projection)
histoFactory->destroy(posXZ);
if (histo2DMode == "strip")
posXZ = histoFactory->create2D("Tracker Hits XZ (strip,plane)",
N, 0, N-1,
2*Nplane, 0, Nplane-1);
else
posXZ = histoFactory->create2D("Tracker Hits XZ (x,z) in mm",
sizexy/5, -sizexy/2, sizexy/2,
sizez/5, -sizez/2, sizez/2);
// 2D histogram that store the position (mm) of the hits (YZ projection)
histoFactory->destroy(posYZ);
if(histo2DMode=="strip")
posYZ = histoFactory->create2D("Tracker Hits YZ (strip,plane)",
N, 0, N-1,
2*Nplane, 0, Nplane-1);
else
posYZ = histoFactory->create2D("Tracker Hits YZ (y,z) in mm",
sizexy/5, -sizexy/2, sizexy/2,
sizez/5, -sizez/2, sizez/2);
}
if(posXZ)
posXZ->reset();
if(posYZ)
posYZ->reset();
if(energy)
energy->reset();
if(hits)
hits->reset();
// We divide the plotter in the right nuber of zone depending
// on which histograms the user want to draw
if((histo2DDraw == "enable") && (histo1DDraw == "enable"))
pl->zone(2,2);
else if((histo1DDraw == "enable") || (histo2DDraw == "enable"))
pl->zone(1,2);
else
pl->zone(1,1);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
/*
This member is called at the end of each run
*/
void GammaRayTelAnalysisManager::EndOfRun(G4int n)
{
// This variable contains the names of the PS files
char name[15];
// We define some vectors
IVector* vxz = 0;
IVector* vyz = 0;
IVector* ve = 0;
IVector* vhit = 0;
// Temporary we set one single zone for the plotter
pl->zone(1,1);
// We now print the histograms, each one in a separate file
if(histo2DSave == "enable")
{
vxz = fVectorFactory->from2D(dynamic_cast<IHistogram2D*>(posXZ));
vyz = fVectorFactory->from2D(dynamic_cast<IHistogram2D*>(posYZ));
sprintf(name,"posxz_%d.ps", n);
pl->plot(vxz);
pl->psPrint(name);
sprintf(name,"posyz_%d.ps", n);
pl->plot(vyz);
pl->psPrint(name);
}
if(histo1DSave == "enable")
{
ve = fVectorFactory->from1D(dynamic_cast<IHistogram1D*>(energy));
vhit = fVectorFactory->from1D(dynamic_cast<IHistogram1D*>(hits));
sprintf(name,"energy_%d.ps", n);
pl->plot(ve);
pl->psPrint(name);
sprintf(name,"hits_%d.ps", n);
pl->plot(vhit);
pl->psPrint(name);
}
delete vxz;
delete vyz;
delete ve;
delete vhit;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
/* This member is called at the end of every event */
void GammaRayTelAnalysisManager::EndOfEvent(G4int flag)
{
// The histograms are updated only if there is some
// hits in the event
if(flag) Plot();
}
#endif
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: GammaRayTelAnalysisMessenger.cc,v 1.1.4.2 2001/06/28 20:18:40 gunter Exp $
// GEANT4 tag $Name: $
// $Id: GammaRayTelAnalysisMessenger.cc,v 1.5 2001/12/04 11:40:28 flongo Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
// ------------------------------------------------------------
// GEANT 4 class implementation file
@@ -31,23 +31,24 @@
//
// ------------ GammaRayTelAnalysisMessenger ------
// by R.Giannitrapani, F.Longo & G.Santin (03 dic 2000)
//
// 20.11.01 G.Santin: modified according to the new GammaRayTelAnalysis.cc
// ************************************************************
#ifdef G4ANALYSIS_USE
#include "GammaRayTelAnalysisMessenger.hh"
#include "GammaRayTelAnalysisManager.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
#include "GammaRayTelAnalysisMessenger.hh"
#include "GammaRayTelAnalysis.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
GammaRayTelAnalysisMessenger::GammaRayTelAnalysisMessenger(GammaRayTelAnalysisManager* analysisManager)
:GammaRayTelAnalysis(analysisManager)
GammaRayTelAnalysisMessenger::GammaRayTelAnalysisMessenger(GammaRayTelAnalysis* analysis)
:gammaRayTelAnalysis(analysis)
{
GammaRayTelAnalysisDir = new G4UIdirectory("/analysis/");
GammaRayTelAnalysisDir->SetGuidance("GammaRayTel analysis control.");
gammaRayTelAnalysisDir = new G4UIdirectory("/analysis/");
gammaRayTelAnalysisDir->SetGuidance("GammaRayTel analysis control.");
/*
Commands for the 1D histograms (energy deposition in the last
@@ -139,21 +140,21 @@ void GammaRayTelAnalysisMessenger::SetNewValue(G4UIcommand* command,G4String new
// 1D Histograms
if( command == Histo1DDrawCmd )
{ GammaRayTelAnalysis->SetHisto1DDraw(newValue);}
{ gammaRayTelAnalysis->SetHisto1DDraw(newValue);}
if( command == Histo1DSaveCmd )
{ GammaRayTelAnalysis->SetHisto1DSave(newValue);}
{ gammaRayTelAnalysis->SetHisto1DSave(newValue);}
// 2D Histograms
if( command == Histo2DDrawCmd )
{ GammaRayTelAnalysis->SetHisto2DDraw(newValue);}
{ gammaRayTelAnalysis->SetHisto2DDraw(newValue);}
if( command == Histo2DSaveCmd )
{ GammaRayTelAnalysis->SetHisto2DSave(newValue);}
{ gammaRayTelAnalysis->SetHisto2DSave(newValue);}
if( command == Histo2DModeCmd )
{ GammaRayTelAnalysis->SetHisto2DMode(newValue);}
{ gammaRayTelAnalysis->SetHisto2DMode(newValue);}
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: GammaRayTelAnticoincidenceHit.cc,v 1.1.2.2 2001/06/28 20:18:41 gunter Exp $
// GEANT4 tag $Name: $
// $Id: GammaRayTelAnticoincidenceHit.cc,v 1.2 2001/07/11 09:56:57 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// ------------------------------------------------------------
// GEANT 4 class implementation file
// CERN Geneva Switzerland
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: GammaRayTelAnticoincidenceSD.cc,v 1.1.2.2 2001/06/28 20:18:41 gunter Exp $
// GEANT4 tag $Name: $
// $Id: GammaRayTelAnticoincidenceSD.cc,v 1.4 2001/11/29 11:19:18 griccard Exp $
// GEANT4 tag $Name: geant4-04-00 $
// ------------------------------------------------------------
// GEANT 4 class implementation file
// CERN Geneva Switzerland
@@ -32,7 +32,7 @@
// by R.Giannitrapani, F.Longo & G.Santin (13 nov 2000)
//
// ************************************************************
#include "G4RunManager.hh"
#include "GammaRayTelAnticoincidenceSD.hh"
#include "GammaRayTelAnticoincidenceHit.hh"
#include "GammaRayTelDetectorConstruction.hh"
@@ -46,10 +46,13 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
GammaRayTelAnticoincidenceSD::GammaRayTelAnticoincidenceSD(G4String name,
GammaRayTelDetectorConstruction* det)
:G4VSensitiveDetector(name),Detector(det)
GammaRayTelAnticoincidenceSD::GammaRayTelAnticoincidenceSD(G4String name)
:G4VSensitiveDetector(name)
{
G4RunManager* runManager = G4RunManager::GetRunManager();
Detector =
(GammaRayTelDetectorConstruction*)(runManager->GetUserDetectorConstruction());
NbOfACDLateralTiles = Detector->GetNbOfACDLateralTiles();
NbOfACDTopTiles = Detector->GetNbOfACDTopTiles();
@@ -105,7 +108,7 @@ G4bool GammaRayTelAnticoincidenceSD::ProcessHits(G4Step* aStep,G4TouchableHistor
G4int ACDTileNumber=acd_tile->GetCopyNo();
G4String ACDTileName = acd_tile->GetName();
G4cout << ACDTileName << " " << edep/keV << G4endl;
// G4cout << ACDTileName << " " << edep/keV << G4endl;
if (ACDTileName == "ACT" )
// The hit is on an top ACD tile (ACDType 0)
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: GammaRayTelCalorimeterHit.cc,v 1.1.2.2 2001/06/28 20:18:41 gunter Exp $
// GEANT4 tag $Name: $
// $Id: GammaRayTelCalorimeterHit.cc,v 1.2 2001/07/11 09:56:57 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// ------------------------------------------------------------
// GEANT 4 class implementation file
// CERN Geneva Switzerland
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: GammaRayTelCalorimeterSD.cc,v 1.1.2.2 2001/06/28 20:18:41 gunter Exp $
// GEANT4 tag $Name: $
// $Id: GammaRayTelCalorimeterSD.cc,v 1.4 2001/11/29 11:19:18 griccard Exp $
// GEANT4 tag $Name: geant4-04-00 $
// ------------------------------------------------------------
// GEANT 4 class implementation file
// CERN Geneva Switzerland
@@ -32,7 +32,7 @@
// by R.Giannitrapani, F.Longo & G.Santin (13 nov 2000)
//
// ************************************************************
#include "G4RunManager.hh"
#include "GammaRayTelCalorimeterSD.hh"
#include "GammaRayTelCalorimeterHit.hh"
#include "GammaRayTelDetectorConstruction.hh"
@@ -46,17 +46,22 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
GammaRayTelCalorimeterSD::GammaRayTelCalorimeterSD(G4String name,
GammaRayTelDetectorConstruction* det)
:G4VSensitiveDetector(name),Detector(det)
GammaRayTelCalorimeterSD::GammaRayTelCalorimeterSD(G4String name):G4VSensitiveDetector(name)
{
G4RunManager* runManager = G4RunManager::GetRunManager();
Detector =
(GammaRayTelDetectorConstruction*)(runManager->GetUserDetectorConstruction());
NbOfCALBars = Detector->GetNbOfCALBars();
NbOfCALLayers = Detector->GetNbOfCALLayers();
G4cout << NbOfCALBars << " bars " << G4endl;
G4cout << NbOfCALLayers << " layers " << G4endl;
//G4cout << NbOfCALBars << " bars " << G4endl;
//G4cout << NbOfCALLayers << " layers " << G4endl;
ChitXID = new G4int[NbOfCALBars][12];
ChitYID = new G4int[NbOfCALBars][12];
NbOfCALChannels = NbOfCALBars*NbOfCALLayers;
ChitXID = new G4int[NbOfCALChannels];
ChitYID = new G4int[NbOfCALChannels];
collectionName.insert("CalorimeterCollection");
}
@@ -74,11 +79,10 @@ void GammaRayTelCalorimeterSD::Initialize(G4HCofThisEvent*HCE)
{
CalorimeterCollection = new GammaRayTelCalorimeterHitsCollection
(SensitiveDetectorName,collectionName[0]);
for (G4int i=0;i<NbOfCALBars;i++)
for (G4int j=0;j<NbOfCALLayers;j++)
for (G4int i=0;i<NbOfCALChannels;i++)
{
ChitXID[i][j] = -1;
ChitYID[i][j] = -1;
ChitXID[i] = -1;
ChitYID[i] = -1;
};
}
@@ -105,13 +109,18 @@ G4bool GammaRayTelCalorimeterSD::ProcessHits(G4Step* aStep,G4TouchableHistory* R
PlaneNumber=cal_plane->GetCopyNo();
G4String PlaneName = cal_plane->GetName();
if (PlaneName == "CALLayerX" )
G4int NChannel = 0;
NChannel = PlaneNumber * NbOfCALBars + CALBarNumber;
if (PlaneName == "CALLayerX" )
// The hit is on an X CsI plane
{
// This is a new hit
if (ChitXID[CALBarNumber][PlaneNumber]==-1)
if (ChitXID[NChannel]==-1)
{
GammaRayTelCalorimeterHit* CalorimeterHit = new GammaRayTelCalorimeterHit;
CalorimeterHit->SetCALType(1);
@@ -119,13 +128,13 @@ G4bool GammaRayTelCalorimeterSD::ProcessHits(G4Step* aStep,G4TouchableHistory* R
CalorimeterHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
CalorimeterHit->SetCALPlaneNumber(PlaneNumber);
CalorimeterHit->SetCALBarNumber(CALBarNumber);
ChitXID[CALBarNumber][PlaneNumber] =
ChitXID[NChannel] =
CalorimeterCollection->insert(CalorimeterHit) -1;
}
else // This is not new
{
(*CalorimeterCollection)
[ChitXID[CALBarNumber][PlaneNumber]]->AddEnergy(edep);
[ChitXID[NChannel]]->AddEnergy(edep);
}
}
@@ -133,7 +142,7 @@ G4bool GammaRayTelCalorimeterSD::ProcessHits(G4Step* aStep,G4TouchableHistory* R
// The hit is on an Y CsI plane
{
// This is a new hit
if (ChitYID[CALBarNumber][PlaneNumber]==-1)
if (ChitYID[NChannel]==-1)
{
GammaRayTelCalorimeterHit* CalorimeterHit
= new GammaRayTelCalorimeterHit;
@@ -142,13 +151,13 @@ G4bool GammaRayTelCalorimeterSD::ProcessHits(G4Step* aStep,G4TouchableHistory* R
CalorimeterHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
CalorimeterHit->SetCALPlaneNumber(PlaneNumber);
CalorimeterHit->SetCALBarNumber(CALBarNumber);
ChitYID[CALBarNumber][PlaneNumber] =
ChitYID[NChannel] =
CalorimeterCollection->insert(CalorimeterHit)-1;
}
else // This is not new
{
(*CalorimeterCollection)
[ChitYID[CALBarNumber][PlaneNumber]]->AddEnergy(edep);
[ChitYID[NChannel]]->AddEnergy(edep);
}
}
@@ -167,12 +176,11 @@ void GammaRayTelCalorimeterSD::EndOfEvent(G4HCofThisEvent* HCE)
HCE->AddHitsCollection(HCID,CalorimeterCollection);
for (G4int i=0;i<NbOfCALBars;i++)
for (G4int j=0;j<NbOfCALLayers;j++)
{
ChitXID[i][j] = -1;
ChitYID[i][j] = -1;
};
for (G4int i=0;i<NbOfCALChannels;i++)
{
ChitXID[i] = -1;
ChitYID[i] = -1;
};
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: GammaRayTelDetectorConstruction.cc,v 1.5.2.2 2001/06/28 20:18:41 gunter Exp $
// GEANT4 tag $Name: $
// $Id: GammaRayTelDetectorConstruction.cc,v 1.9 2001/11/29 11:19:18 griccard Exp $
// GEANT4 tag $Name: geant4-04-00 $
// ------------------------------------------------------------
// GEANT 4 class implementation file
// CERN Geneva Switzerland
@@ -70,16 +70,14 @@ GammaRayTelDetectorConstruction::GammaRayTelDetectorConstruction()
solidACT(0),logicACT(0),physiACT(0),
solidACL1(0),logicACL1(0),physiACL1(0),
solidACL2(0),logicACL2(0),physiACL2(0),
solidConverter(0),logicConverter(0),physiConverter(0),
solidTKRDetectorX(0),logicTKRDetectorX(0),
solidTKRDetectorY(0),logicTKRDetectorY(0),
physiTKRDetectorX(0),physiTKRDetectorY(0),
solidCALDetectorX(0),logicCALDetectorX(0),physiCALDetectorX(0),
solidCALDetectorY(0),logicCALDetectorY(0),physiCALDetectorY(0),
solidTKRDetectorX(0),logicTKRDetectorX(0),physiTKRDetectorX(0),
solidTKRDetectorY(0),logicTKRDetectorY(0),physiTKRDetectorY(0),
solidCALLayerX(0),logicCALLayerX(0),physiCALLayerX(0),
solidCALLayerY(0),logicCALLayerY(0),physiCALLayerY(0),
solidPlane(0),logicPlane(0),physiPlane(0)
solidCALDetectorX(0),logicCALDetectorX(0),physiCALDetectorX(0),
solidCALDetectorY(0),logicCALDetectorY(0),physiCALDetectorY(0),
solidPlane(0),logicPlane(0),physiPlane(0),
solidConverter(0),logicConverter(0),physiConverter(0)
{
// default parameter values of the payload
@@ -132,7 +130,7 @@ void GammaRayTelDetectorConstruction::DefineMaterials()
G4double a, z, density;
G4int ncomponents, natoms;
G4double abundance, fractionmass;
G4double fractionmass;
G4double temperature, pressure;
//
@@ -151,36 +149,33 @@ void GammaRayTelDetectorConstruction::DefineMaterials()
a = 15.99*g/mole;
G4Element* O = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a);
a = 26.98*g/mole;
G4Element* Alumin = new G4Element(name="Aluminum" ,symbol="Al" , z= 13., a);
a = 28.09*g/mole;
G4Element* Silicon = new G4Element(name="Silicon", symbol="Si", z=14., a);
a= 55.845*g/mole;
G4Element* Iron = new G4Element(name="Iron", symbol="Fe", z=26.,a);
a = 126.904*g/mole;
G4Element* I = new G4Element(name="Iodine" ,symbol="I" , z= 53., a);
a = 132.905*g/mole;
G4Element* Cs = new G4Element(name="Cesium" ,symbol="Cs" , z= 55., a);
//
// define simple materials
//
a = 207.19*g/mole;
G4Element* Lead = new G4Element(name="Lead", symbol="Pb", z=82., a);
density = 2.700*g/cm3;
a = 26.98*g/mole;
G4Material* Al = new G4Material(name="Aluminium", z=13., a, density);
//
// define simple materials
//
density = 2.333*g/cm3;
a = 28.09*g/mole;
G4Material* Si = new G4Material(name="Silicon",z=14., a,density);
density = 19.3*g/cm3;
a = 183.84*g/mole;
G4Material* W = new G4Material(name="Tungsten", z=74., a, density);
density = 11.35*g/cm3;
a = 207.19*g/mole;
G4Material* Pb = new G4Material(name="Lead", z=82., a, density);
density = 7.87*g/cm3;
a= 55.845*g/mole;
G4Material* Fe = new G4Material(name="Iron", z=26.,a,density);
//
// define a material from elements. case 1: chemical molecule
//
@@ -192,8 +187,8 @@ void GammaRayTelDetectorConstruction::DefineMaterials()
density = 4.53*g/cm3;
G4Material* CsI = new G4Material(name="CesiumIodide", density, ncomponents=2);
CsI->AddElement(C, natoms=5);
CsI->AddElement(H, natoms=5);
CsI->AddElement(Cs, natoms=5);
CsI->AddElement(I, natoms=5);
//
// define a material from elements. case 2: mixture by fractional mass
@@ -203,11 +198,27 @@ void GammaRayTelDetectorConstruction::DefineMaterials()
G4Material* Air = new G4Material(name="Air" , density, ncomponents=2);
Air->AddElement(N, fractionmass=0.7);
Air->AddElement(O, fractionmass=0.3);
//
// examples of vacuum
//
density = 2.700*g/cm3;
G4Material* Al = new G4Material(name="Aluminum", density, ncomponents=1);
Al->AddElement(Alumin, fractionmass=1.);
density = 2.333*g/cm3;
G4Material* Si = new G4Material(name="Silicon", density, ncomponents=1);
Si->AddElement(Silicon, fractionmass=1.);
density = 7.87*g/cm3;
G4Material* Fe = new G4Material(name="Iron", density, ncomponents=1);
Fe->AddElement(Iron, fractionmass=1.);
density = 11.35*g/cm3;
G4Material* Pb = new G4Material(name="Lead", density, ncomponents=1);
Pb->AddElement(Lead, fractionmass=1.);
//
// examples of vacuum
//
density = universe_mean_density; //from PhysicalConstants.h
pressure = 3.e-18*pascal;
temperature = 2.73*kelvin;
@@ -224,7 +235,7 @@ void GammaRayTelDetectorConstruction::DefineMaterials()
//default materials of the payload
ConverterMaterial = Pb;
ConverterMaterial = W;
defaultMaterial = vacuum;
ACDMaterial = Sci;
CALMaterial = CsI;
@@ -481,22 +492,23 @@ G4VPhysicalVolume* GammaRayTelDetectorConstruction::ConstructPayload()
physiTKR,
false,
i);
physiPlane =
new G4PVPlacement(0,G4ThreeVector(0.,0.,
-TKRSizeZ/2+
2*TKRSiliconThickness +
TKRViewsDistance+
ConverterThickness+
TKRSupportThickness/2),
TKRSupportThickness/2+
(i)*TKRLayerDistance),
"Plane",
logicPlane,
physiTKR,
false,
i);
}
@@ -676,17 +688,18 @@ G4VPhysicalVolume* GammaRayTelDetectorConstruction::ConstructPayload()
if(!trackerSD)
{
trackerSD = new GammaRayTelTrackerSD("TrackerSD",this);
trackerSD = new GammaRayTelTrackerSD("TrackerSD");
SDman->AddNewDetector( trackerSD );
}
G4String ROgeometryName = "TrackerROGeom";
G4VReadOutGeometry* trackerRO =
new GammaRayTelTrackerROGeometry(ROgeometryName, this);
new GammaRayTelTrackerROGeometry(ROgeometryName);
trackerRO->BuildROGeometry();
trackerSD->SetROgeometry(trackerRO);
if (logicTKRActiveTileX)
logicTKRActiveTileX->SetSensitiveDetector(trackerSD); // ActiveTileX
if (logicTKRActiveTileY)
@@ -700,7 +713,7 @@ G4VPhysicalVolume* GammaRayTelDetectorConstruction::ConstructPayload()
if(!calorimeterSD)
{
calorimeterSD = new GammaRayTelCalorimeterSD("CalorimeterSD",this);
calorimeterSD = new GammaRayTelCalorimeterSD("CalorimeterSD");
SDman->AddNewDetector( calorimeterSD );
}
@@ -716,7 +729,7 @@ G4VPhysicalVolume* GammaRayTelDetectorConstruction::ConstructPayload()
if(!anticoincidenceSD)
{
anticoincidenceSD = new GammaRayTelAnticoincidenceSD
("AnticoincidenceSD",this);
("AnticoincidenceSD");
SDman->AddNewDetector( anticoincidenceSD );
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: GammaRayTelDetectorMessenger.cc,v 1.3.4.2 2001/06/28 20:18:41 gunter Exp $
// GEANT4 tag $Name: $
// $Id: GammaRayTelDetectorMessenger.cc,v 1.4 2001/07/11 09:56:58 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
// ------------------------------------------------------------
// GEANT 4 class implementation file
@@ -0,0 +1,102 @@
//
// ********************************************************************
// * 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: GammaRayTelDigi.cc,v 1.2 2001/12/13 13:44:55 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// ------------------------------------------------------------
// GEANT 4 class implementation file
// CERN Geneva Switzerland
//
//
// ------------ GammaRayTelDigi ------
// by F.Longo, R.Giannitrapani & G.Santin (21 oct 2001)
//
// ************************************************************
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
#include "GammaRayTelDigi.hh"
G4Allocator<GammaRayTelDigi> GammaRayTelDigiAllocator;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
GammaRayTelDigi::GammaRayTelDigi()
{
PlaneType = 0;
PlaneNumber = 0;
StripNumber=0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
GammaRayTelDigi::~GammaRayTelDigi()
{;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
GammaRayTelDigi::GammaRayTelDigi(const GammaRayTelDigi& right)
{
PlaneType = right.PlaneType;
PlaneNumber = right.PlaneNumber;
StripNumber = right.StripNumber;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
const GammaRayTelDigi& GammaRayTelDigi::operator=(const GammaRayTelDigi& right)
{
PlaneType = right.PlaneType;
PlaneNumber = right.PlaneNumber;
StripNumber = right.StripNumber;
return *this;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
int GammaRayTelDigi::operator==(const GammaRayTelDigi& right) const
{
return 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void GammaRayTelDigi::Draw()
{;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void GammaRayTelDigi::Print()
{;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -0,0 +1,152 @@
//
// ********************************************************************
// * 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: GammaRayTelDigitizer.cc,v 1.3 2001/12/04 11:40:28 flongo Exp $
// GEANT4 tag $Name: geant4-04-00 $
// ------------------------------------------------------------
// GEANT 4 class implementation file
// CERN Geneva Switzerland
//
//
// ------------ GammaRayTelDigitizer ------
// by F.Longo, R.Giannitrapani & G.Santin (13 nov 2000)
//
// ************************************************************
#include "GammaRayTelDigitizer.hh"
#include "GammaRayTelDigi.hh"
#include "GammaRayTelDigitizerMessenger.hh"
#include "GammaRayTelTrackerHit.hh"
#include "G4EventManager.hh"
#include "G4Event.hh"
#include "G4SDManager.hh"
#include "G4DigiManager.hh"
#include "G4ios.hh"
//#include "G4CollectionNameVector.hh"
#include "g4std/vector"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
GammaRayTelDigitizer::GammaRayTelDigitizer(G4String name)
:G4VDigitizerModule(name)
{
G4String colName = "DigitsCollection";
collectionName.push_back(colName);
Energy_Threshold = 120.*keV;
//create a messenger for this class
digiMessenger = new GammaRayTelDigitizerMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
GammaRayTelDigitizer::~GammaRayTelDigitizer()
{
delete digiMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void GammaRayTelDigitizer::Digitize()
{
DigitsCollection = new GammaRayTelDigitsCollection
("TrackerDigitizer","DigitsCollection"); // to create the Digi Collection
G4DigiManager* DigiMan = G4DigiManager::GetDMpointer();
G4int THCID;
// hits collections IDs
THCID = DigiMan->GetHitsCollectionID("TrackerCollection");
// Hits collection
GammaRayTelTrackerHitsCollection* THC = 0;
THC = (GammaRayTelTrackerHitsCollection*)
(DigiMan->GetHitsCollection(THCID));
if (THC)
{
G4int n_hit = THC->entries();
for (G4int i=0;i<n_hit;i++)
{
G4double ESil = (*THC)[i]->GetEdepSil();
G4int NStrip = (*THC)[i]->GetNStrip();
G4int NPlane = (*THC)[i]->GetNSilPlane();
G4int IsX = (*THC)[i]->GetPlaneType();
// digi generation only if energy deposit greater than threshold
if (ESil>Energy_Threshold)
{
GammaRayTelDigi* Digi = new GammaRayTelDigi();
Digi->SetPlaneNumber(NPlane);
Digi->SetPlaneType(IsX);
Digi->SetStripNumber(NStrip);
DigitsCollection->insert(Digi);
}
}
G4cout << "Number of tracker digits in this event = "
<< DigitsCollection->entries()
// << " " << DigitsCollection->GetName()
// << " " << DigitsCollection->GetDMname()
<< G4endl;
StoreDigiCollection(DigitsCollection);
G4int DCID = -1;
if(DCID<0)
{
// DigiMan->List();
DCID = DigiMan->GetDigiCollectionID("TrackerDigitizer/DigitsCollection");
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -0,0 +1,89 @@
//
// ********************************************************************
// * 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: GammaRayTelDigitizerMessenger.cc,v 1.1 2001/11/29 09:34:17 flongo Exp $
// GEANT4 tag $Name: geant4-04-00 $
// ------------------------------------------------------------
// GEANT 4 class implementation file
// CERN Geneva Switzerland
//
//
// ------------ GammaRayTelDigitizerMessenger ------
// by F.Longo, G.Santin & R.Giannitrapani (27 nov 2001)
//
// ************************************************************
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#include "GammaRayTelDigitizerMessenger.hh"
#include "GammaRayTelDigitizer.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
GammaRayTelDigitizerMessenger::GammaRayTelDigitizerMessenger
(GammaRayTelDigitizer* GammaRayTelDigit)
:GammaRayTelAction(GammaRayTelDigit)
{
ThresholdCmd = new G4UIcmdWithADoubleAndUnit("/digitizer/Threshold",this);
ThresholdCmd->SetGuidance("Energy deposition threshold for TKR digi generation");
ThresholdCmd->SetParameterName("choice",true);
ThresholdCmd->SetDefaultValue((G4double)20.*keV);
ThresholdCmd->SetRange("Threshold >=0.");
ThresholdCmd->SetUnitCategory("Energy");
ThresholdCmd->AvailableForStates(PreInit,Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
GammaRayTelDigitizerMessenger::~GammaRayTelDigitizerMessenger()
{
delete ThresholdCmd;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void GammaRayTelDigitizerMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
{
if( command == ThresholdCmd )
{
GammaRayTelAction->SetThreshold
(ThresholdCmd->GetNewDoubleValue(newValue));
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: GammaRayTelEventAction.cc,v 1.5.2.2 2001/06/28 20:18:41 gunter Exp $
// GEANT4 tag $Name: $
// $Id: GammaRayTelEventAction.cc,v 1.13 2001/12/04 13:23:52 flongo Exp $
// GEANT4 tag $Name: geant4-04-00 $
// ------------------------------------------------------------
// GEANT 4 class implementation file
// CERN Geneva Switzerland
@@ -31,6 +31,10 @@
// ------------ GammaRayTelEventAction ------
// by R.Giannitrapani, F.Longo & G.Santin (13 nov 2000)
//
// - inclusion of Digits by F.Longo & R.Giannitrapani (24 oct 2001)
//
// - Modification of analysis management by G.Santin (18 Nov 2001)
//
// ************************************************************
#include "GammaRayTelEventAction.hh"
@@ -38,10 +42,8 @@
#include "GammaRayTelAnticoincidenceHit.hh"
#include "GammaRayTelCalorimeterHit.hh"
#include "g4rw/tvordvec.h"
#ifdef G4ANALYSIS_USE
#include "GammaRayTelAnalysisManager.hh"
#include "GammaRayTelAnalysis.hh"
#endif
#include "G4Event.hh"
@@ -57,25 +59,25 @@
#include "G4UnitsTable.hh"
#include "Randomize.hh"
#include "GammaRayTelDigi.hh"
#include "GammaRayTelDigitizer.hh"
#include "G4DigiManager.hh"
// This file is a global variable in which we store energy deposition per hit
// and other relevant information
extern G4std::ofstream outFile;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#ifdef G4ANALYSIS_USE
GammaRayTelEventAction::GammaRayTelEventAction(GammaRayTelAnalysisManager* aMgr)
:drawFlag("all"),trackerCollID(-1), calorimeterCollID(-1),
anticoincidenceCollID(-1), analysisManager(aMgr)
{
}
#else
GammaRayTelEventAction::GammaRayTelEventAction()
:drawFlag("all"), trackerCollID(-1),calorimeterCollID(-1),
anticoincidenceCollID(-1)
{
:trackerCollID(-1),calorimeterCollID(-1),
anticoincidenceCollID(-1), drawFlag("all")
{
G4DigiManager * fDM = G4DigiManager::GetDMpointer();
GammaRayTelDigitizer * myDM = new GammaRayTelDigitizer( "TrackerDigitizer" );
fDM->AddNewModule(myDM);
}
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -90,22 +92,19 @@ void GammaRayTelEventAction::BeginOfEventAction(const G4Event* evt)
G4int evtNb = evt->GetEventID();
G4cout << "Event: " << evtNb << G4endl;
G4SDManager * SDman = G4SDManager::GetSDMpointer();
if (trackerCollID==-1)
{
trackerCollID = SDman->GetCollectionID("TrackerCollection");
}
if(anticoincidenceCollID==-1)
{
anticoincidenceCollID =
SDman->GetCollectionID("AnticoincidenceCollection");
}
if(calorimeterCollID==-1)
{
calorimeterCollID =
SDman->GetCollectionID("CalorimeterCollection");
}
if (trackerCollID==-1) {
trackerCollID = SDman->GetCollectionID("TrackerCollection");
}
if(anticoincidenceCollID==-1) {
anticoincidenceCollID =
SDman->GetCollectionID("AnticoincidenceCollection");
}
if(calorimeterCollID==-1) {
calorimeterCollID =
SDman->GetCollectionID("CalorimeterCollection");
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -125,6 +124,8 @@ void GammaRayTelEventAction::EndOfEventAction(const G4Event* evt)
GammaRayTelAnticoincidenceHitsCollection* AHC = 0;
G4DigiManager * fDM = G4DigiManager::GetDMpointer();
if (HCE)
{
THC = (GammaRayTelTrackerHitsCollection*)(HCE->GetHC(trackerCollID));
@@ -142,8 +143,8 @@ void GammaRayTelEventAction::EndOfEventAction(const G4Event* evt)
G4int NStrip, NPlane, IsX;
// This is a cycle on all the tracker hits of this event
for (int i=0;i<n_hit;i++)
for (int i=0;i<n_hit;i++)
{
// Here we put the hit data in a an ASCII file for
// later analysis
@@ -158,44 +159,83 @@ void GammaRayTelEventAction::EndOfEventAction(const G4Event* evt)
(*THC)[i]->GetPos().x()/mm <<" "<<
(*THC)[i]->GetPos().y()/mm <<" "<<
(*THC)[i]->GetPos().z()/mm <<" "<<
G4endl;
G4endl;
#ifdef G4ANALYSIS_USE
// Here we fill the histograms of the Analysis manager
if(IsX)
{
if (analysisManager->GetHisto2DMode()=="position")
analysisManager->InsertPositionXZ((*CHC)[i]->GetPos().x()/mm,(*CHC)[i]->GetPos().z()/mm);
else
analysisManager->InsertPositionXZ(NStrip, NPlane);
if (NPlane == 0) analysisManager->InsertEnergy(ESil/keV);
analysisManager->InsertHits(NPlane);
}
else
if (analysisManager->GetHisto2DMode()=="position")
analysisManager->InsertPositionYZ((*CHC)[i]->GetPos().y()/mm,(*CHC)[i]->GetPos().z()/mm);
else
analysisManager->InsertPositionYZ(NStrip, NPlane);
#endif
}
// Here we fill the histograms of the Analysis manager
GammaRayTelAnalysis* analysis = GammaRayTelAnalysis::getInstance();
if(IsX)
{
if (analysis->GetHisto2DMode()=="position")
analysis->InsertPositionXZ((*THC)[i]->GetPos().x()/mm,(*THC)[i]->GetPos().z()/mm);
else
analysis->InsertPositionXZ(NStrip, NPlane);
if (NPlane == 0) analysis->InsertEnergy(ESil/keV);
analysis->InsertHits(NPlane);
}
else
{
if (analysis->GetHisto2DMode()=="position")
analysis->InsertPositionYZ((*THC)[i]->GetPos().y()/mm,(*THC)[i]->GetPos().z()/mm);
else
analysis->InsertPositionYZ(NStrip, NPlane);
if (NPlane == 0) analysis->InsertEnergy(ESil/keV);
analysis->InsertHits(NPlane);
}
#ifdef G4ANALYSIS_USE_NTUPLE
analysis->setNtuple( ESil/keV, NPlane, (*THC)[i]->GetPos().x()/mm,
(*THC)[i]->GetPos().y()/mm,
(*THC)[i]->GetPos().z()/mm);
#endif
#endif
}
// Here we call the analysis manager function for visualization
#ifdef G4ANALYSIS_USE
analysisManager->EndOfEvent(n_hit);
GammaRayTelAnalysis* analysis = GammaRayTelAnalysis::getInstance();
analysis->EndOfEvent(n_hit);
#endif
}
GammaRayTelDigitizer * myDM =
(GammaRayTelDigitizer*)fDM->FindDigitizerModule( "TrackerDigitizer" );
myDM->Digitize();
G4int myDigiCollID = fDM->GetDigiCollectionID("DigitsCollection");
// G4cout << "digi collecion" << myDigiCollID << G4endl;
if(G4VVisManager::GetConcreteInstance())
{
for(G4int i=0; i<n_trajectories; i++)
{ G4Trajectory* trj = (G4Trajectory *)((*(evt->GetTrajectoryContainer()))[i]);
if (drawFlag == "all") trj->DrawTrajectory(50);
else if ((drawFlag == "charged")&&(trj->GetCharge() != 0.))
trj->DrawTrajectory(50);
}
GammaRayTelDigitsCollection * DC = (GammaRayTelDigitsCollection*)fDM->GetDigiCollection( myDigiCollID );
if(DC) {
// G4cout << "Total Digits " << DC->entries() << G4endl;
G4int n_digi = DC->entries();
G4int NStrip, NPlane, IsX;
for (G4int i=0;i<n_digi;i++) {
// Here we put the digi data in a an ASCII file for
// later analysis
NStrip = (*DC)[i]->GetStripNumber();
NPlane = (*DC)[i]->GetPlaneNumber();
IsX = (*DC)[i]->GetPlaneType();
outFile << G4std::setw(7) << event_id << " " << NStrip <<
" " << NPlane << " " << IsX << " " << G4endl;
}
}
if(G4VVisManager::GetConcreteInstance()) {
for(G4int i=0; i<n_trajectories; i++) {
G4Trajectory* trj = (G4Trajectory *)((*(evt->GetTrajectoryContainer()))[i]);
if (drawFlag == "all") trj->DrawTrajectory(50);
else if ((drawFlag == "charged")&&(trj->GetCharge() != 0.))
trj->DrawTrajectory(50);
}
}
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: GammaRayTelPhysicsList.cc,v 1.2.4.2 2001/06/28 20:18:42 gunter Exp $
// GEANT4 tag $Name: $
// $Id: GammaRayTelPhysicsList.cc,v 1.3 2001/07/11 09:56:58 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// ------------------------------------------------------------
// GEANT 4 class implementation file
// CERN Geneva Switzerland
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: GammaRayTelPrimaryGeneratorAction.cc,v 1.3.4.2 2001/06/28 20:18:42 gunter Exp $
// GEANT4 tag $Name: $
// $Id: GammaRayTelPrimaryGeneratorAction.cc,v 1.6 2001/11/29 11:19:18 griccard Exp $
// GEANT4 tag $Name: geant4-04-00 $
// ------------------------------------------------------------
// GEANT 4 class implementation file
// CERN Geneva Switzerland
@@ -36,6 +36,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#include "G4RunManager.hh"
#include "GammaRayTelPrimaryGeneratorAction.hh"
#include "GammaRayTelDetectorConstruction.hh"
@@ -49,11 +50,13 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
GammaRayTelPrimaryGeneratorAction::GammaRayTelPrimaryGeneratorAction
(GammaRayTelDetectorConstruction* GammaRayTelDC)
:GammaRayTelDetector(GammaRayTelDC),rndmFlag("off"),
nSourceType(0),nSpectrumType(0)
GammaRayTelPrimaryGeneratorAction::GammaRayTelPrimaryGeneratorAction()
:rndmFlag("off"),nSourceType(0),nSpectrumType(0)
{
G4RunManager* runManager = G4RunManager::GetRunManager();
GammaRayTelDetector =
(GammaRayTelDetectorConstruction*)(runManager->GetUserDetectorConstruction());
G4int n_particle = 1;
particleGun = new G4ParticleGun(n_particle);
@@ -98,7 +101,8 @@ void GammaRayTelPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
dir0 = G4ThreeVector(0.,0.,-1.);
G4double theta, phi, y, f;
G4double theta0,phi0;
G4double theta0=0.;
G4double phi0=0.;
switch(nSourceType) {
case 0:
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: GammaRayTelPrimaryGeneratorMessenger.cc,v 1.2.4.2 2001/06/28 20:18:42 gunter Exp $
// GEANT4 tag $Name: $
// $Id: GammaRayTelPrimaryGeneratorMessenger.cc,v 1.3 2001/07/11 09:56:58 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// ------------------------------------------------------------
// GEANT 4 class implementation file
// CERN Geneva Switzerland
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: GammaRayTelRunAction.cc,v 1.3.4.2 2001/06/28 20:18:42 gunter Exp $
// GEANT4 tag $Name: $
// $Id: GammaRayTelRunAction.cc,v 1.7 2001/12/04 11:40:28 flongo Exp $
// GEANT4 tag $Name: geant4-04-00 $
// ------------------------------------------------------------
// GEANT 4 class implementation file
// CERN Geneva Switzerland
@@ -30,6 +30,8 @@
//
// ------------ GammaRayTelRunAction ------
// by R.Giannitrapani, F.Longo & G.Santin (13 nov 2000)
// 18.11.2001 G.Santin
// - Modified the analysis management according to the new design
//
// ************************************************************
@@ -39,24 +41,21 @@
#include "GammaRayTelRunAction.hh"
#ifdef G4ANALYSIS_USE
#include "GammaRayTelAnalysis.hh"
#endif
#include <stdlib.h>
#include "G4Run.hh"
#include "G4UImanager.hh"
#include "G4VVisManager.hh"
#include "G4ios.hh"
extern ofstream outFile;
extern G4std::ofstream outFile;
#ifdef G4ANALYSIS_USE
GammaRayTelRunAction::GammaRayTelRunAction(GammaRayTelAnalysisManager* aMgr)
:analysisManager(aMgr)
{
}
#else
GammaRayTelRunAction::GammaRayTelRunAction()
{
}
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -84,7 +83,8 @@ void GammaRayTelRunAction::BeginOfRunAction(const G4Run* aRun)
// If analysis is used reset the histograms
#ifdef G4ANALYSIS_USE
analysisManager->BeginOfRun();
GammaRayTelAnalysis* analysis = GammaRayTelAnalysis::getInstance();
analysis->BeginOfRun(aRun->GetRunID());
#endif
}
@@ -102,7 +102,8 @@ void GammaRayTelRunAction::EndOfRunAction(const G4Run* aRun)
// If analysis is used, print out the histograms
#ifdef G4ANALYSIS_USE
analysisManager->EndOfRun(aRun->GetRunID());
GammaRayTelAnalysis* analysis = GammaRayTelAnalysis::getInstance();
analysis->EndOfRun(aRun->GetRunID());
#endif
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: GammaRayTelTrackerHit.cc,v 1.1.2.2 2001/06/28 20:18:42 gunter Exp $
// GEANT4 tag $Name: $
// $Id: GammaRayTelTrackerHit.cc,v 1.2 2001/07/11 09:56:58 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// ------------------------------------------------------------
// GEANT 4 class implementation file
// CERN Geneva Switzerland
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: GammaRayTelTrackerROGeometry.cc,v 1.1.2.2 2001/06/28 20:18:42 gunter Exp $
// GEANT4 tag $Name: $
// $Id: GammaRayTelTrackerROGeometry.cc,v 1.5 2001/11/29 11:19:18 griccard Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
//
// ------------------------------------------------------------
@@ -34,7 +34,7 @@
// by F.Longo, R.Giannitrapani & G.Santin (13 nov 2000)
//
// ************************************************************
#include "G4RunManager.hh"
#include "GammaRayTelTrackerROGeometry.hh"
#include "GammaRayTelDummySD.hh"
#include "GammaRayTelDetectorConstruction.hh"
@@ -53,14 +53,12 @@ GammaRayTelTrackerROGeometry::GammaRayTelTrackerROGeometry()
: G4VReadOutGeometry()
{
}
GammaRayTelTrackerROGeometry::GammaRayTelTrackerROGeometry(G4String aString,GammaRayTelDetectorConstruction* GammaRayTelDC)
:GammaRayTelDetector(GammaRayTelDC), G4VReadOutGeometry(aString)
{
}
GammaRayTelTrackerROGeometry::GammaRayTelTrackerROGeometry(G4String aString)
: G4VReadOutGeometry(aString)
:G4VReadOutGeometry(aString)
{
G4RunManager* runManager = G4RunManager::GetRunManager();
GammaRayTelDetector =
(GammaRayTelDetectorConstruction*)(runManager->GetUserDetectorConstruction());
}
GammaRayTelTrackerROGeometry::~GammaRayTelTrackerROGeometry()
@@ -326,8 +324,7 @@ G4VPhysicalVolume* GammaRayTelTrackerROGeometry::Build()
// as a flag only to check for sensitivity.
// (Could we make it by a simple cast of a non-NULL value ?)
GammaRayTelDummySD * dummySensi = new GammaRayTelDummySD;
GammaRayTelDummySD * dummySensi = new GammaRayTelDummySD("Orpo");
logicTKRStripX->SetSensitiveDetector(dummySensi);
logicTKRStripY->SetSensitiveDetector(dummySensi);
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: GammaRayTelTrackerSD.cc,v 1.1.2.2 2001/06/28 20:18:42 gunter Exp $
// GEANT4 tag $Name: $
// $Id: GammaRayTelTrackerSD.cc,v 1.6 2001/12/04 11:40:28 flongo Exp $
// GEANT4 tag $Name: geant4-04-00 $
// ------------------------------------------------------------
// GEANT 4 class implementation file
// CERN Geneva Switzerland
@@ -32,7 +32,7 @@
// by R.Giannitrapani, F.Longo & G.Santin (13 nov 2000)
//
// ************************************************************
#include "G4RunManager.hh"
#include "GammaRayTelTrackerSD.hh"
#include "GammaRayTelTrackerHit.hh"
@@ -49,17 +49,21 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
GammaRayTelTrackerSD::GammaRayTelTrackerSD(G4String name,
GammaRayTelDetectorConstruction* det)
:G4VSensitiveDetector(name),Detector(det)
GammaRayTelTrackerSD::GammaRayTelTrackerSD(G4String name):G4VSensitiveDetector(name)
{
G4RunManager* runManager = G4RunManager::GetRunManager();
Detector =
(GammaRayTelDetectorConstruction*)(runManager->GetUserDetectorConstruction());
G4int NbOfTKRTiles = Detector->GetNbOfTKRTiles();
NbOfTKRStrips = Detector->GetNbOfTKRStrips();
NbOfTKRLayers = Detector->GetNbOfTKRLayers();
NbOfTKRStrips = NbOfTKRStrips*NbOfTKRTiles;
ThitXID = new G4int[NbOfTKRStrips][30];
ThitYID = new G4int[NbOfTKRStrips][30];
NbOfTKRChannels = NbOfTKRStrips* NbOfTKRTiles * NbOfTKRLayers;
ThitXID = new G4int[NbOfTKRChannels];
ThitYID = new G4int[NbOfTKRChannels];
collectionName.insert("TrackerCollection");
}
@@ -77,20 +81,19 @@ void GammaRayTelTrackerSD::Initialize(G4HCofThisEvent*HCE)
{
TrackerCollection = new GammaRayTelTrackerHitsCollection
(SensitiveDetectorName,collectionName[0]);
for (G4int i=0;i<NbOfTKRStrips;i++)
for (G4int j=0;j<NbOfTKRLayers;j++)
{
ThitXID[i][j] = -1;
ThitYID[i][j] = -1;
};
for (G4int i=0;i<NbOfTKRChannels;i++)
{
ThitXID[i] = -1;
ThitYID[i] = -1;
};
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4bool GammaRayTelTrackerSD::ProcessHits(G4Step* aStep,G4TouchableHistory* ROhist)
{
G4double edep = aStep->GetTotalEnergyDeposit();
if ((edep/keV == 0.)) return false;
@@ -101,7 +104,7 @@ G4bool GammaRayTelTrackerSD::ProcessHits(G4Step* aStep,G4TouchableHistory* ROhis
// of the hit
G4TouchableHistory* theTouchable
= (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
G4VPhysicalVolume* phys_tile = theTouchable->GetVolume();
G4VPhysicalVolume* plane = phys_tile->GetMother();
@@ -125,26 +128,26 @@ G4bool GammaRayTelTrackerSD::ProcessHits(G4Step* aStep,G4TouchableHistory* ROhis
G4int NTile = (TileNumber%TileTotal);
G4int j=0;
G4int NChannel = 0;
for (j=0;j<TileTotal;j++)
{
{
if(NTile==j) StripNumber += StripTotal*NTile;
}
// G4cout << " Plane Number = " << PlaneNumber << " " << PlaneName << G4endl;
// G4cout << StripName << " " << StripNumber << G4endl;
NChannel = PlaneNumber*TileTotal*StripTotal + StripNumber;
/* G4cout << NChannel << " Channel Number" << G4endl;
G4cout << " Plane Number = " << PlaneNumber << " " << PlaneName
<< G4endl;
G4cout << StripName << " " << StripNumber << G4endl; */
ROhist->MoveUpHistory();
G4VPhysicalVolume* ROPlane = ROhist->GetVolume();
G4int ROPlaneNumber = ROPlane->GetCopyNo();
G4String ROPlaneName = ROPlane->GetName();
if (PlaneName == "TKRDetectorX" )
// The hit is on an X silicon plane
{
// This is a new hit
if (ThitXID[StripNumber][PlaneNumber]==-1)
if (ThitXID[NChannel]==-1)
{
GammaRayTelTrackerHit* TrackerHit = new GammaRayTelTrackerHit;
TrackerHit->SetPlaneType(1);
@@ -152,21 +155,21 @@ G4bool GammaRayTelTrackerSD::ProcessHits(G4Step* aStep,G4TouchableHistory* ROhis
TrackerHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
TrackerHit->SetNSilPlane(PlaneNumber);
TrackerHit->SetNStrip(StripNumber);
ThitXID[StripNumber][PlaneNumber] =
ThitXID[NChannel] =
TrackerCollection->insert(TrackerHit) -1;
}
else // This is not new
{
(*TrackerCollection)[ThitXID[StripNumber][PlaneNumber]]->AddSil(edep);
(*TrackerCollection)[ThitXID[NChannel]]->AddSil(edep);
// G4cout << "X" << PlaneNumber << " " << StripNumber << G4endl;
}
}
if (PlaneName == "TKRDetectorY")
// The hit is on an Y silicon plane
{
// This is a new hit
if (ThitYID[StripNumber][PlaneNumber]==-1)
if (ThitYID[NChannel]==-1)
{
GammaRayTelTrackerHit* TrackerHit = new GammaRayTelTrackerHit;
TrackerHit->SetPlaneType(0);
@@ -174,12 +177,12 @@ G4bool GammaRayTelTrackerSD::ProcessHits(G4Step* aStep,G4TouchableHistory* ROhis
TrackerHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
TrackerHit->SetNSilPlane(PlaneNumber);
TrackerHit->SetNStrip(StripNumber);
ThitYID[StripNumber][PlaneNumber] =
ThitYID[NChannel] =
TrackerCollection->insert(TrackerHit)-1;
}
else // This is not new
{
(*TrackerCollection)[ThitYID[StripNumber][PlaneNumber]]->AddSil(edep);
(*TrackerCollection)[ThitYID[NChannel]]->AddSil(edep);
// G4cout << "Y" << PlaneNumber << " " << StripNumber << G4endl;
}
}
@@ -199,12 +202,11 @@ void GammaRayTelTrackerSD::EndOfEvent(G4HCofThisEvent* HCE)
HCE->AddHitsCollection(HCID,TrackerCollection);
for (G4int i=0;i<NbOfTKRStrips;i++)
for (G4int j=0;j<NbOfTKRLayers;j++)
{
ThitXID[i][j] = -1;
ThitYID[i][j] = -1;
};
for (G4int i=0;i<NbOfTKRChannels;i++)
{
ThitXID[i] = -1;
ThitYID[i] = -1;
};
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -22,8 +22,8 @@
//
//
// $Id: GammaRayTelVisManager.cc,v 1.2.4.2 2001/06/28 20:18:43 gunter Exp $
// GEANT4 tag $Name: $
// $Id: GammaRayTelVisManager.cc,v 1.6 2001/11/23 17:39:04 santin Exp $
// GEANT4 tag $Name: geant4-04-00 $
// ------------------------------------------------------------
// GEANT 4 class implementation file
// CERN Geneva Switzerland
@@ -40,14 +40,21 @@
// Supported drivers...
// Not needing external packages or libraries...
#include "G4ASCIITree.hh"
#include "G4DAWNFILE.hh"
#include "G4GAGTree.hh"
//#include "G4HepRepFile.hh"
#include "G4RayTracer.hh"
#include "G4VRML1File.hh"
#include "G4VRML2File.hh"
// Needing external packages or libraries...
#ifdef G4VIS_USE_DAWN
#include "G4FukuiRenderer.hh"
#endif
#ifdef G4VIS_USE_DAWNFILE
#include "G4DAWNFILE.hh"
#endif
#ifdef G4VIS_USE_OPACS
#include "G4Wo.hh"
#include "G4Xo.hh"
@@ -81,11 +88,6 @@
#include "G4VRML2.hh"
#endif
#ifdef G4VIS_USE_VRMLFILE
#include "G4VRML1File.hh"
#include "G4VRML2File.hh"
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
GammaRayTelVisManager::GammaRayTelVisManager () {}
@@ -94,14 +96,21 @@ GammaRayTelVisManager::GammaRayTelVisManager () {}
void GammaRayTelVisManager::RegisterGraphicsSystems () {
// Graphics Systems not needing external packages or libraries...
RegisterGraphicsSystem (new G4ASCIITree);
RegisterGraphicsSystem (new G4DAWNFILE);
RegisterGraphicsSystem (new G4GAGTree);
// RegisterGraphicsSystem (new G4HepRepFile);
RegisterGraphicsSystem (new G4RayTracer);
RegisterGraphicsSystem (new G4VRML1File);
RegisterGraphicsSystem (new G4VRML2File);
// Graphics systems needing external packages or libraries...
#ifdef G4VIS_USE_DAWN
RegisterGraphicsSystem (new G4FukuiRenderer);
#endif
#ifdef G4VIS_USE_DAWNFILE
RegisterGraphicsSystem (new G4DAWNFILE);
#endif
#ifdef G4VIS_USE_OPACS
RegisterGraphicsSystem (new G4Wo);
RegisterGraphicsSystem (new G4Xo);
@@ -135,11 +144,6 @@ void GammaRayTelVisManager::RegisterGraphicsSystems () {
RegisterGraphicsSystem (new G4VRML2);
#endif
#ifdef G4VIS_USE_VRMLFILE
RegisterGraphicsSystem (new G4VRML1File);
RegisterGraphicsSystem (new G4VRML2File);
#endif
if (fVerbose > 0) {
G4cout <<
"\nYou have successfully chosen to use the following graphics systems."