Skip to content
Snippets Groups Projects
Commit 3cab195d authored by Alfonso's avatar Alfonso
Browse files

primo commit

parents
Branches
No related tags found
No related merge requests found
Showing
with 1296 additions and 0 deletions
CMakeCache.txt
CMakeFiles/*
CMakeScripts/*
build/*
cmake_install.cmake
*.build/*
*.root
Debug/*
.DS_Store
*.xcodeproj
*.root
*.fits
*.dat
response_matrix*/*
results*/*
background*/*
test.gdml
#----------------------------------------------------------------------------
# Setup the project
#
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(xgis_m7-main)
#----------------------------------------------------------------------------
# Find Geant4 package, activating all available UI and Vis drivers by default.
# You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui
# to build a batch mode only executable
#
option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
if(WITH_GEANT4_UIVIS)
find_package(Geant4 REQUIRED ui_all vis_all)
else()
find_package(Geant4 REQUIRED)
endif()
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
# Setup include directory for this project (superfluo)
#
include(${Geant4_USE_FILE})
include_directories(${PROJECT_SOURCE_DIR}/include)
#----------------------------------------------------------------------------
# Locate sources and headers for this project
# NB: headers are included so they will show up in IDEs
#
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
#----------------------------------------------------------------------------
# Add the executable, and link it to the Geant4 libraries
#
add_executable(xgis_M7 xgis_M7.cc ${sources} ${headers})
target_link_libraries(xgis_M7 ${Geant4_LIBRARIES})
#----------------------------------------------------------------------------
# compiler meno rigoroso
#
set(CMAKE_CXX_FLAGS "-fpermissive")
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build xgis. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
# (serve solo se fai la build directory)
set(MACROS_SCRIPTS
)
foreach(_script ${MACROS_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
#----------------------------------------------------------------------------
# For internal Geant4 use - but has no effect if you build this
# example standalone
#
add_custom_target(xgis_m7-main DEPENDS xgis_M7)
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS xgis_M7 DESTINATION bin)
This diff is collapsed.
# dati area efficace
# Energy[keV] Ndet/Ngen SDD Scint
0.1 0.5002 50020 0
1 0.4999 49999 0
10 0.4898 48988 0
20 0.4125 17916 23338
30 0.4065 6556 34096
40 0.4087 4927 35943
50 0.4120 3350 37854
60 0.4152 2510 39016
100 0.4235 1319 41039
# 150 0.4522 970 44257
# 200 0.4425 969 43288
# 300 0.6232 1047 61281
# 400 0.6256 1005 61558
# 500 0.6064 1008 59634
# 600 0.5859 1033 57560
# 700 0.5655 994 55562
# 800 0.5466 999 53661
# 1000 0.5137 947 50425
# 2000 0.4208 1012 41075
# 3000 0.3926 1213 38051
# 5000 0.3880 1512 37296
# 7000 0.4020 2045 38163
#10000 0.4281 2934 39880
# detector_params.inp
# Parameter file for XGIS
# Geometrical dimensions
SCINT_X = 0.45 # X side of scintillator module (in cm)
SCINT_Y = 0.45 # Y side of scintillator module (in cm)
SCINT_Z = 3.0 # Z side of scintillator module (in cm)
SCINT_GAP = 0.05 # Gap between adjacent scintillator bars
COLL_SIDE_THICK = 0.1 # Side collimator thickness (in cm)
BUS_THICK = 20. # Bottom bus dummy thickness (in cm)
BUS_HEIGHT = 150. # Spacecraft bus height (in cm)
BUS_SIDE = 100. # Spacecraft bus side (in cm)
SDD_THICK = 450.0 # SDD thickness (in um)
MASK_X = 56.1 # X side of the coded mask (in cm)
MASK_Y = 56.1 # Y side of the coded mask (in cm)
MASK_THICK = 1000. # Thickness of the coded mask (in um)
MASK_FOCAL = 63. # Focal distance btw. mask and detector (in cm)
COLL_UPPER_1_THICK = 1000.0 # Upper internal collimator thickness (in um)
COLL_UPPER_2_THICK = 250.0 # Upper external collimator thickness (in um)
COLL_UPPER_2_HEIGHT = 63.0 # Upper external collimator height (in cm)
OPTICAL_COUPLER_THICK = 1.0 # Optical coupler thickness (in mm)
# Module parameters
N_SIDE = 89 # Number of scintillator bars per side (89x89=7921-81)
N_SLICES_PER_BAR = 1 # Number of voxels (slices) for each scintillator bar
N_MASK_ELEM_PER_SIDE = 16 # Number of mask elements per side (+16 vuoti)
# Materials
SCINT_MATERIAL = G4_CESIUM_IODIDE # Material of the scintillator
COLL_SIDE_MATERIAL = G4_W # Material of the side collimator
BUS_MATERIAL = G4_Al # Material of the bus
SDD_MATERIAL = G4_Si # Material of the SDD
MASK_MATERIAL = G4_W # Material of the coded mask
COLL_UPPER_1_MATERIAL = G4_Al # Material of the upper internal collimator
COLL_UPPER_2_MATERIAL = G4_W # Material of the upper external collimator
OPTICAL_COUPLER_MATERIAL = Silicone # Material of the optical coupler
This diff is collapsed.
// ConfigFile.h
// Class for reading named values from configuration files
// Richard J. Wagner v2.1 24 May 2004 wagnerr@umich.edu
// Copyright (c) 2004 Richard J. Wagner
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
// Typical usage
// -------------
//
// Given a configuration file "settings.inp":
// atoms = 25
// length = 8.0 # nanometers
// name = Reece Surcher
//
// Named values are read in various ways, with or without default values:
// ConfigFile config( "settings.inp" );
// int atoms = config.read<int>( "atoms" );
// double length = config.read( "length", 10.0 );
// string author, title;
// config.readInto( author, "name" );
// config.readInto( title, "title", string("Untitled") );
//
// See file example.cpp for more examples.
#ifndef CONFIGFILE_H
#define CONFIGFILE_H
#include <string>
#include <map>
#include <iostream>
#include <fstream>
#include <sstream>
using std::string;
class ConfigFile {
// Data
protected:
string myDelimiter; // separator between key and value
string myComment; // separator between value and comments
string mySentry; // optional string to signal end of file
std::map<string,string> myContents; // extracted keys and values
typedef std::map<string,string>::iterator mapi;
typedef std::map<string,string>::const_iterator mapci;
// Methods
public:
ConfigFile( string filename,
string delimiter = "=",
string comment = "#",
string sentry = "EndConfigFile" );
ConfigFile();
// Search for key and read value or optional default value
template<class T> T read( const string& key ) const; // call as read<T>
template<class T> T read( const string& key, const T& value ) const;
template<class T> bool readInto( T& var, const string& key ) const;
template<class T>
bool readInto( T& var, const string& key, const T& value ) const;
// Modify keys and values
template<class T> void add( string key, const T& value );
void remove( const string& key );
// Check whether key exists in configuration
bool keyExists( const string& key ) const;
// Check or change configuration syntax
string getDelimiter() const { return myDelimiter; }
string getComment() const { return myComment; }
string getSentry() const { return mySentry; }
string setDelimiter( const string& str )
{ string old = myDelimiter; myDelimiter = str; return old; }
string setComment( const string& str )
{ string old = myComment; myComment = str; return old; }
// Write or read configuration
friend std::ostream& operator<<( std::ostream& os, const ConfigFile& cf );
friend std::istream& operator>>( std::istream& is, ConfigFile& cf );
protected:
template<class T> static string T_as_string( const T& t );
template<class T> static T string_as_T( const string& s );
static void trim( string& s );
// Exception types
public:
struct file_not_found {
string filename;
file_not_found( const string& filename_ = string() )
: filename(filename_) {} };
struct key_not_found { // thrown only by T read(key) variant of read()
string key;
key_not_found( const string& key_ = string() )
: key(key_) {} };
};
/* static */
template<class T>
string ConfigFile::T_as_string( const T& t )
{
// Convert from a T to a string
// Type T must support << operator
std::ostringstream ost;
ost << t;
return ost.str();
}
/* static */
template<class T>
T ConfigFile::string_as_T( const string& str )
{
// Convert from a string to a T
// Type T must support >> operator
T t;
std::istringstream ist(str);
ist >> t;
return t;
}
/* static */
template<>
inline string ConfigFile::string_as_T<string>( const string& str )
{
// Convert from a string to a string
// In other words, do nothing
return str;
}
/* static */
template<>
inline bool ConfigFile::string_as_T<bool>( const string& str )
{
// Convert from a string to a bool
// Interpret "false", "F", "no", "n", "0" as false
// Interpret "true", "T", "yes", "y", "1", "-1", or anything else as true
bool b = true;
string sup = str;
for( string::iterator p = sup.begin(); p != sup.end(); ++p )
*p = toupper(*p); // make string all caps
if( sup==string("FALSE") || sup==string("F") ||
sup==string("NO") || sup==string("N") ||
sup==string("0") || sup==string("NONE") )
b = false;
return b;
}
template<class T>
T ConfigFile::read( const string& key ) const
{
// Read the value corresponding to key
mapci p = myContents.find(key);
if( p == myContents.end() ) throw key_not_found(key);
return string_as_T<T>( p->second );
}
template<class T>
T ConfigFile::read( const string& key, const T& value ) const
{
// Return the value corresponding to key or given default value
// if key is not found
mapci p = myContents.find(key);
if( p == myContents.end() ) return value;
return string_as_T<T>( p->second );
}
template<class T>
bool ConfigFile::readInto( T& var, const string& key ) const
{
// Get the value corresponding to key and store in var
// Return true if key is found
// Otherwise leave var untouched
mapci p = myContents.find(key);
bool found = ( p != myContents.end() );
if( found ) var = string_as_T<T>( p->second );
return found;
}
template<class T>
bool ConfigFile::readInto( T& var, const string& key, const T& value ) const
{
// Get the value corresponding to key and store in var
// Return true if key is found
// Otherwise set var to given default
mapci p = myContents.find(key);
bool found = ( p != myContents.end() );
if( found )
var = string_as_T<T>( p->second );
else
var = value;
return found;
}
template<class T>
void ConfigFile::add( string key, const T& value )
{
// Add a key with given value
string v = T_as_string( value );
trim(key);
trim(v);
myContents[key] = v;
return;
}
#endif // CONFIGFILE_H
// Release notes:
// v1.0 21 May 1999
// + First release
// + Template read() access only through non-member readConfigFile()
// + ConfigurationFileBool is only built-in helper class
//
// v2.0 3 May 2002
// + Shortened name from ConfigurationFile to ConfigFile
// + Implemented template member functions
// + Changed default comment separator from % to #
// + Enabled reading of multiple-line values
//
// v2.1 24 May 2004
// + Made template specializations inline to avoid compiler-dependent linkage
// + Allowed comments within multiple-line values
// + Enabled blank line termination for multiple-line values
// + Added optional sentry to detect end of configuration file
// + Rewrote messy trimWhitespace() function as elegant trim()
#ifndef DetectorConstruction_H
#define DetectorConstruction_H 1
class G4LogicalVolume;
class G4VPhysicalVolume;
class G4Material;
class SensitiveDetector;
class G4VPVParameterisation;
#include "G4VUserDetectorConstruction.hh"
// Mandatory user class that defines the detector used in the
// simulation, its geometry and its materials.
// Derived from the G4VUserDetectorConstruction initialisation
// abstract base class.
class DetectorConstruction : public G4VUserDetectorConstruction
{
public:
DetectorConstruction(); // Constructor
~DetectorConstruction(); // Destructor
private:
// Method to construct the detector
G4VPhysicalVolume* Construct();
// Method to construct the sensitive detector
void ConstructSDandField();
// Method to define the materials
void DefineMaterials();
// Method to read the values of parameters from file
void DefineParameters();
public:
// Get methods
// Method to get the world physical volume
const G4VPhysicalVolume* GetWorld() {return experimentalHall_phys;};
// Method to get the world dimensions
G4double GetWorldSide() {return worldSide;};
// Method to get the Scint physical volume
const G4VPhysicalVolume* GetScint() {return scint_phys;};
// Methods to get the scintillator bar dimensions
G4double GetScintX() {return scint_x;};
G4double GetScintY() {return scint_y;};
G4double GetScintZ() {return scint_z;};
G4double GetScintGap() {return scint_gap;};
// Methods to get the geometrical parameters
G4int GetNumberOfBars() {return n_side;};
G4int GetNumberOfSlicesPerBar() {return NbOfSlicesPerBar;};
G4int GetNumberOfMaskElementsPerSide() {return n_mask_elem_side;};
// Methods to get the side collimator dimensions
G4double GetCollSideThick() {return coll_side_thick;};
G4double GetCollSideHeight() {return coll_side_height;};
// Methods to get the SDD dimensions
G4double GetSDDThick() {return sdd_thick;};
// Methods to get the bus dimensions
G4double GetBusThick() {return bus_thick;};
G4double GetBusHeight() {return bus_height;};
G4double GetBusSide() {return bus_side;};
// Methods to get the optical coupler dimensions
G4double GetOptCouplerThick() {return optCoupler_thick;};
// Methods to get the mask dimensions
G4double GetMaskSideX() {return mask_side_x;};
G4double GetMaskSideY() {return mask_side_y;};
G4double GetMaskThick() {return mask_thick;};
G4double GetMaskFocalDistance() {return mask_focalDistance;};
// Methods to get the upper collimator dimensions
G4double GetCollUpper1Thick() {return coll_upper1_thick;};
G4double GetCollUpper2Thick() {return coll_upper2_thick;};
G4double GetCollUpper2Height() {return coll_upper2_height;};
// Methods to get the materials
G4Material* GetScintMaterial() {return scintMaterial;};
G4Material* GetCollSideMaterial() {return collSideMaterial;};
G4Material* GetSDDMaterial() {return sddMaterial;};
G4Material* GetBusMaterial() {return busMaterial;};
G4Material* GetMaskMaterial() {return maskMaterial;};
// Set methods
// Method to set the world dimensions
void SetWorldSide(G4double wside) {worldSide = wside;};
// Methods to set the scintillator bar dimensions
void SetScintX(G4double scintsidex) {scint_x = scintsidex;};
void SetScintY(G4double scintsidey) {scint_y = scintsidey;};
void SetScintZ(G4double scintsidez) {scint_z = scintsidez;};
void SetScintGap(G4double scintgap) {scint_gap = scintgap;};
// Methods to set the geometrical parameters
void SetNumberOfBars(G4int nb) {n_side = nb;};
void SetNumberOfSlicesPerBar(G4int nb) {NbOfSlicesPerBar = nb;};
void SetNumberOfMaskElementsPerSide(G4int nb) {n_mask_elem_side = nb;};
// Methods to set the side collimator dimensions
void SetCollSideThick(G4double ct) {coll_side_thick = ct;};
void SetCollSideHeight(G4double ch) {coll_side_height = ch;};
// Methods to set the mask dimensions
void SetMaskSideX(G4double msx) {mask_side_x = msx;};
void SetMaskSideY(G4double msy) {mask_side_y = msy;};
void SetMaskThick(G4double mt) {mask_thick = mt;};
void SetMaskFocalDistance(G4double mfd) {mask_focalDistance = mfd;};
// Methods to set the upper collimator dimensions
void SetCollUpper1Thick(G4double ct1) {coll_upper1_thick = ct1;};
void SetCollUpper2Thick(G4double ct2) {coll_upper2_thick = ct2;};
void SetCollUpper2Height(G4double ch2) {coll_upper2_height = ch2;};
// Methods to set the SDD dimensions
void SetSDDThick(G4double sddt) {sdd_thick = sddt;};
// Methods to set the bus dimensions
void SetBusThick(G4double bt) {bus_thick = bt;};
void SetBusHeight(G4double bh) {bus_height = bh;};
void SetBusSide(G4double bs) {bus_side = bs;};
// Methods to set the optical coupler dimensions
void SetOptCouplerThick(G4double opt) {optCoupler_thick = opt;};
// Methods to set the materials
void SetScintMaterial (G4String);
void SetCollSideMaterial (G4String);
void SetBusMaterial (G4String);
void SetSDDMaterial (G4String);
void SetMaskMaterial (G4String);
void SetCollUpper1Material (G4String);
void SetCollUpper2Material (G4String);
void SetOptCouplerMaterial (G4String);
// Print a list of parameters
void PrintParameters();
// Geometry update
void UpdateGeometry();
private:
// Logical volumes
G4LogicalVolume* experimentalHall_log;
G4LogicalVolume* scint_log;
G4LogicalVolume* sddUpper_log;
G4LogicalVolume* sddLower_log;
G4LogicalVolume* optCoupler_log;
G4LogicalVolume* coll_sideXp_log;
G4LogicalVolume* coll_sideXm_log;
G4LogicalVolume* coll_sideYp_log;
G4LogicalVolume* coll_sideYm_log;
G4LogicalVolume* bus1_log;
G4LogicalVolume* bus2_log;
G4LogicalVolume* mask_log;
G4LogicalVolume* coll_upper1Xp_log;
G4LogicalVolume* coll_upper1Xm_log;
G4LogicalVolume* coll_upper1Yp_log;
G4LogicalVolume* coll_upper1Ym_log;
G4LogicalVolume* coll_upper2Xp_log;
G4LogicalVolume* coll_upper2Xm_log;
G4LogicalVolume* coll_upper2Yp_log;
G4LogicalVolume* coll_upper2Ym_log;
// Parameterisations
G4VPVParameterisation* scintParam;
G4VPVParameterisation* maskParam;
// Physical volumes
G4VPhysicalVolume* experimentalHall_phys;
G4VPhysicalVolume* scint_phys;
G4VPhysicalVolume* sddUpper_phys;
G4VPhysicalVolume* sddLower_phys;
G4VPhysicalVolume* optCoupler_phys;
G4VPhysicalVolume* coll_sideXp_phys;
G4VPhysicalVolume* coll_sideXm_phys;
G4VPhysicalVolume* coll_sideYp_phys;
G4VPhysicalVolume* coll_sideYm_phys;
G4VPhysicalVolume* bus1_phys;
G4VPhysicalVolume* bus2_phys;
G4VPhysicalVolume* mask_phys;
G4VPhysicalVolume* coll_upper1Xp_phys;
G4VPhysicalVolume* coll_upper1Xm_phys;
G4VPhysicalVolume* coll_upper1Yp_phys;
G4VPhysicalVolume* coll_upper1Ym_phys;
G4VPhysicalVolume* coll_upper2Xp_phys;
G4VPhysicalVolume* coll_upper2Xm_phys;
G4VPhysicalVolume* coll_upper2Yp_phys;
G4VPhysicalVolume* coll_upper2Ym_phys;
// World dimensions
G4double worldSide;
// Scint dimensions
G4double scint_x;
G4double scint_y;
G4double scint_z;
G4double scint_gap;
// Geometrical parameters
G4int n_side;
G4int NbOfSlicesPerBar;
G4int n_mask_elem_side;
// Side Collimator dimensions
G4double coll_side_thick;
G4double coll_side_height;
// SDD dimensions
G4double sdd_thick;
// Optical coupler dimensions
G4double optCoupler_thick;
// Bottom bus thickness
G4double bus_thick;
G4double bus_height;
G4double bus_side;
// Mask dimensions
G4double mask_side_x;
G4double mask_side_y;
G4double mask_thick;
G4double mask_focalDistance;
// Upper Collimator dimensions
G4double coll_upper1_thick;
G4double coll_upper2_thick;
G4double coll_upper2_height;
// Materials
G4Material* defaultMaterial;
G4Material* sddMaterial;
G4Material* scintMaterial;
G4Material* collSideMaterial;
G4Material* busMaterial;
G4Material* maskMaterial;
G4Material* collUpper1Material;
G4Material* collUpper2Material;
G4Material* optCouplerMaterial;
};
#endif
#ifndef DETECTORHIT_HH
#define DETECTORHIT_HH
#include <vector>
#include <utility>
#include "G4VHit.hh"
#include "G4THitsCollection.hh"
#include "G4Allocator.hh"
#include "G4Types.hh"
#include "G4ThreeVector.hh"
#include "G4LogicalVolume.hh"
#include "tls.hh"
// General purpose:
// Represents a hit and contains relevant information about the hit.
// (The user implementation should provide functionalities which allow to
// assign and retrieve hit information).
// Hit objects can be created in the sensitive detector, and may be used
// at the end of events to accumulate hit information.
//
// Purpose of the class in this implementation:
// Represents a hit in the detector, where the relevant hit information is
// the energy deposited by the particle and its location
// G4VHit is the abstract base class for creating hit objects.
class DetectorHit : public G4VHit {
public:
DetectorHit(); // Default constructor
DetectorHit(G4int xp, G4int yp); // Alternate constructor
virtual ~DetectorHit(); // Destructor
// Assignment and comparison operators:
const DetectorHit& operator= (const DetectorHit& right);
int operator==(const DetectorHit& right) const;
// The hit class has user-defined new and delete operators to speed up
// the generation and deletion of hits objects:
inline void* operator new(size_t);
inline void operator delete(void* hit);
// The G4VHit provides two methods, which can be overloaded by the user to
// visualize hits or to print information about hits.
// Here, these methods are not used (dummy implementation):
virtual void Draw() { }
virtual void Print() { }
// The current hit object can be used to keep track of:
// a. The energy deposit
// b. The ID of the sector of deposit
// c. The coordinates of the voxel in which the energy deposit happened
// The following methods allow to set, accumulate and get the energy deposit:
inline void SetEnergyDeposit(G4double energy) {energyDeposit = energy;}
inline void AddEnergyDeposit(G4double energy) {energyDeposit += energy;}
inline G4double GetEnergyDeposit() {return energyDeposit;}
// The following methods allow to set and get the ID of the scintillator bar:
inline void SetScintID(G4int id) {scintID = id;}
inline G4int GetScintID() {return scintID;}
// The following methods allow to set and get the ID of the readout sector:
inline void SetPixelID(G4int id) {pixelID = id;}
inline G4int GetPixelID() {return pixelID;}
// The following methods allow to set and get the coordinates of the readout sector:
inline void SetLocationPixelX(G4double id) {locpixelX = id;}
inline void SetLocationPixelY(G4double id) {locpixelY = id;}
inline void SetLocationPixelZ(G4double id) {locpixelZ = id;}
inline G4double GetLocationPixelX() {return locpixelX;}
inline G4double GetLocationPixelY() {return locpixelY;}
inline G4double GetLocationPixelZ() {return locpixelZ;}
// The following methods allow to set and get the time:
inline void SetTime(G4double t) {globaltime = t;}
inline G4int GetTime() {return globaltime;}
private:
G4double energyDeposit;
G4int scintID;
G4int pixelID;
G4double locpixelX;
G4double locpixelY;
G4double locpixelZ;
G4double globaltime;
};
typedef G4THitsCollection<DetectorHit> DetectorHitsCollection;
extern G4ThreadLocal G4Allocator<DetectorHit>* DetectorHitAllocator;
inline void* DetectorHit::operator new(size_t) {
// Implementation of the new operator
if(!DetectorHitAllocator) DetectorHitAllocator = new G4Allocator<DetectorHit>;
return (void*) DetectorHitAllocator->MallocSingle();
}
inline void DetectorHit::operator delete(void* hit) {
// Implementation of the delete operator
DetectorHitAllocator->FreeSingle((DetectorHit*) hit);
}
#endif // DETECTORHIT_HH
// Dummy sensitive used only to flag sensitivity
// in cells of RO geometry.
#ifndef DummySD_h
#define DummySD_h 1
#include "G4VSensitiveDetector.hh"
class G4Step;
class DummySD : public G4VSensitiveDetector
{
public:
DummySD();
~DummySD() {}
void Initialize(G4HCofThisEvent*) {}
G4bool ProcessHits(G4Step*,G4TouchableHistory*) {return false;}
void EndOfEvent(G4HCofThisEvent*) {}
void clear() {}
void DrawAll() {}
void PrintAll() {}
};
DummySD::DummySD()
: G4VSensitiveDetector("dummySD")
{}
#endif
#ifndef MaskParameterisation_H
#define MaskParameterisation_H 1
#include "globals.hh"
#include "G4VPVParameterisation.hh"
class G4VPhysicalVolume;
class G4Box;
// Dummy declarations to get rid of warnings...
class G4Trd;
class G4Trap;
class G4Cons;
class G4Orb;
class G4Sphere;
class G4Torus;
class G4Para;
class G4Box;
class G4Hype;
class G4Tubs;
class G4Polycone;
class G4Polyhedra;
class G4BREPSolidPolyhedra;
class MaskParameterisation : public G4VPVParameterisation
{
public:
MaskParameterisation(G4double, G4double, G4int);
virtual ~MaskParameterisation();
void ComputeTransformation (const G4int copyNo, G4VPhysicalVolume* physVol) const;
private: // Dummy declarations to get rid of warnings...
void ComputeDimensions (G4Trd&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Trap&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Cons&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Sphere&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Orb&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Torus&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Para&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Box&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Hype&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Tubs&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Polycone&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Polyhedra&,const G4int,const G4VPhysicalVolume*) const {}
// void ComputeDimensions (G4BREPSolidPolyhedra&,const G4int,const G4VPhysicalVolume*) const {}
private:
G4double fSideX;
G4double fSideY;
G4int nSide;
};
#endif
#ifndef ModuleParameterisation_H
#define ModuleParameterisation_H 1
#include "globals.hh"
#include "G4VPVParameterisation.hh"
class G4VPhysicalVolume;
class G4Box;
// Dummy declarations to get rid of warnings...
class G4Trd;
class G4Trap;
class G4Cons;
class G4Orb;
class G4Sphere;
class G4Torus;
class G4Para;
class G4Box;
class G4Hype;
class G4Tubs;
class G4Polycone;
class G4Polyhedra;
class G4BREPSolidPolyhedra;
class ModuleParameterisation : public G4VPVParameterisation
{
public:
ModuleParameterisation(G4double, G4double, G4int);
virtual ~ModuleParameterisation();
void ComputeTransformation (const G4int copyNo, G4VPhysicalVolume* physVol) const;
private: // Dummy declarations to get rid of warnings...
void ComputeDimensions (G4Trd&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Trap&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Cons&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Sphere&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Orb&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Torus&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Para&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Box&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Hype&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Tubs&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Polycone&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Polyhedra&,const G4int,const G4VPhysicalVolume*) const {}
// void ComputeDimensions (G4BREPSolidPolyhedra&,const G4int,const G4VPhysicalVolume*) const {}
private:
G4double fSpacing;
G4double fLength;
G4int fSide;
};
#endif
#ifndef PhysicsList_H
#define PhysicsList_H 1
#include "G4VModularPhysicsList.hh"
#include "G4VPhysicsConstructor.hh"
#include "globals.hh"
class G4VPhysicsConstructor;
class PhysicsList: public G4VModularPhysicsList
{
public:
PhysicsList(); // Constructor
~PhysicsList(); // Destructor
protected:
// Construct particle and physics processes
void ConstructParticle();
void ConstructProcess();
// Define cuts
void SetCuts();
private:
G4VPhysicsConstructor* fEmPhysicsList;
std::vector<G4VPhysicsConstructor*> fHadronPhys;
G4VPhysicsConstructor* fDecPhysicsList;
G4VPhysicsConstructor* fRadioDecPhysicsList;
};
#endif
#ifndef PrimaryGeneratorAction_H
#define PrimaryGeneratorAction_H 1
#include "G4VUserPrimaryGeneratorAction.hh"
#include "DetectorConstruction.hh"
// Mandatory user class that defines the properties of the
// particle gun and run initialization
// Derived from the G4VUserPrimaryGeneratorAction initialisation
// abstract base class.
class G4GeneralParticleSource;
class G4Event;
class DetectorConstruction;
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
PrimaryGeneratorAction(); // Constructor
virtual ~PrimaryGeneratorAction(); // Destructor
public:
// This method generates the primary particles
void GeneratePrimaries(G4Event* anEvent);
private:
G4GeneralParticleSource* particleGun;
};
#endif
#ifndef SDDDetectorHit_HH
#define SDDDetectorHit_HH
#include <vector>
#include <utility>
#include "G4VHit.hh"
#include "G4THitsCollection.hh"
#include "G4Allocator.hh"
#include "G4Types.hh"
#include "G4ThreeVector.hh"
#include "G4LogicalVolume.hh"
#include "tls.hh"
// General purpose:
// Represents a hit and contains relevant information about the hit.
// (The user implementation should provide functionalities which allow to
// assign and retrieve hit information).
// Hit objects can be created in the sensitive detector, and may be used
// at the end of events to accumulate hit information.
//
// Purpose of the class in this implementation:
// Represents a hit in the detector, where the relevant hit information is
// the energy deposited by the particle and its location
// G4VHit is the abstract base class for creating hit objects.
class SDDDetectorHit : public G4VHit {
public:
SDDDetectorHit(); // Default constructor
SDDDetectorHit(G4int xp, G4int yp); // Alternate constructor
virtual ~SDDDetectorHit(); // Destructor
// Assignment and comparison operators:
const SDDDetectorHit& operator= (const SDDDetectorHit& right);
int operator==(const SDDDetectorHit& right) const;
// The hit class has user-defined new and delete operators to speed up
// the generation and deletion of hits objects:
inline void* operator new(size_t);
inline void operator delete(void* hit);
// The G4VHit provides two methods, which can be overloaded by the user to
// visualize hits or to print information about hits.
// Here, these methods are not used (dummy implementation):
virtual void Draw() { }
virtual void Print() { }
// The current hit object can be used to keep track of:
// a. The energy deposit
// b. The ID of the sector of deposit
// c. The coordinates of the voxel in which the energy deposit happened
// The following methods allow to set, accumulate and get the energy deposit:
inline void SetEnergyDeposit(G4double energy) {energyDeposit = energy;}
inline void AddEnergyDeposit(G4double energy) {energyDeposit += energy;}
inline G4double GetEnergyDeposit() {return energyDeposit;}
// The following methods allow to set and get the ID of the readout sector:
inline void SetPixelID(G4int id) {pixelID = id;}
inline G4int GetPixelID() {return pixelID;}
// The following methods allow to set and get the coordinates of the readout sector:
inline void SetLocationPixelX(G4double id) {locpixelX = id;}
inline void SetLocationPixelY(G4double id) {locpixelY = id;}
inline G4double GetLocationPixelX() {return locpixelX;}
inline G4double GetLocationPixelY() {return locpixelY;}
// The following methods allow to set and get the time:
inline void SetTime(G4double t) {globaltime = t;}
inline G4int GetTime() {return globaltime;}
private:
G4double energyDeposit;
G4int pixelID;
G4double locpixelX;
G4double locpixelY;
G4double globaltime;
};
typedef G4THitsCollection<SDDDetectorHit> SDDDetectorHitsCollection;
extern G4ThreadLocal G4Allocator<SDDDetectorHit>* SDDDetectorHitAllocator;
inline void* SDDDetectorHit::operator new(size_t) {
// Implementation of the new operator
if(!SDDDetectorHitAllocator) SDDDetectorHitAllocator = new G4Allocator<SDDDetectorHit>;
return (void*) SDDDetectorHitAllocator->MallocSingle();
}
inline void SDDDetectorHit::operator delete(void* hit) {
// Implementation of the delete operator
SDDDetectorHitAllocator->FreeSingle((SDDDetectorHit*) hit);
}
#endif // SDDDetectorHit_HH
#ifndef SDDSensitiveDetector_HH
#define SDDSensitiveDetector_HH
#include "SDDDetectorHit.hh"
#include "G4VSensitiveDetector.hh"
#include "globals.hh"
class G4Step;
class G4HCofThisEvent;
class G4TouchableHistory;
// G4VSensitiveDetector is the abstract base class for sensitive detectors.
class SDDSensitiveDetector : public G4VSensitiveDetector
{
public:
SDDSensitiveDetector(G4String SDuniqueName, G4double, G4int, G4int);
// Constructor w/name of SD and array dim.
virtual ~SDDSensitiveDetector(); // Destructor
// The G4VSDDSensitiveDetector class has two methods, which may be overloaded
// by the user: Initialize and EndOfEvent. These two methods are invoked
// at the beginning and the end of each event.
virtual void Initialize(G4HCofThisEvent*);
virtual void EndOfEvent(G4HCofThisEvent*);
protected:
// The principal purpose of a sensitive detector is to construct hit objects
// using information from particle steps.
// These hits should be created in the ProcessHits function, which is called
// each time a particle performs a step inside a logical volume which has a
// sensitive detector attached.
// Two arguments are passed to the ProcessHits method:
// 1) The first one is the current G4Step object, which can be used to
// retrieve information about the step like energy loss, physics
// processes,...
// 2) The second argument is a G4TouchableHistory object for the read-out
// geometry (if a read-out geometry was assigned to the sensitive
// detector), which can be used e.g. to determine read-out channels,...
virtual G4bool ProcessHits(G4Step* step, G4TouchableHistory* hist);
private:
SDDDetectorHitsCollection* hitsCollection;
G4int hitsCollectionID;
G4double cellSide;
const int numberOfCellsX;
const int numberOfCellsY;
int **CellID;
void initArray();
};
#endif // SDDSensitiveDetector_HH
#ifndef SENSITIVEDETECTOR_HH
#define SENSITIVEDETECTOR_HH
#include "DetectorHit.hh"
#include "G4VSensitiveDetector.hh"
#include "globals.hh"
class G4Step;
class G4HCofThisEvent;
class G4TouchableHistory;
// G4VSensitiveDetector is the abstract base class for sensitive detectors.
class SensitiveDetector : public G4VSensitiveDetector
{
public:
SensitiveDetector(G4String SDuniqueName, int, G4double, G4double, int);
// Constructor w/name of SD and array dim.
virtual ~SensitiveDetector(); // Destructor
// The G4VSensitiveDetector class has two methods, which may be overloaded
// by the user: Initialize and EndOfEvent. These two methods are invoked
// at the beginning and the end of each event.
virtual void Initialize(G4HCofThisEvent*);
virtual void EndOfEvent(G4HCofThisEvent*);
protected:
// The principal purpose of a sensitive detector is to construct hit objects
// using information from particle steps.
// These hits should be created in the ProcessHits function, which is called
// each time a particle performs a step inside a logical volume which has a
// sensitive detector attached.
// Two arguments are passed to the ProcessHits method:
// 1) The first one is the current G4Step object, which can be used to
// retrieve information about the step like energy loss, physics
// processes,...
// 2) The second argument is a G4TouchableHistory object for the read-out
// geometry (if a read-out geometry was assigned to the sensitive
// detector), which can be used e.g. to determine read-out channels,...
virtual G4bool ProcessHits(G4Step* step, G4TouchableHistory* hist);
private:
DetectorHitsCollection* hitsCollection;
G4int hitsCollectionID;
G4int numberOfBarsPerSide;
G4double barLength;
G4double barSide;
G4double sliceLength;
const int numberOfCellsX;
const int numberOfCellsY;
int **CellID;
void initArray();
};
#endif // SENSITIVEDETECTOR_HH
#ifndef UserActionInitialization_h
#define UserActionInitialization_h 1
#include "G4VUserActionInitialization.hh"
class DetectorConstruction;
class UserActionInitialization : public G4VUserActionInitialization
{
public:
UserActionInitialization(); // Constructor
virtual ~UserActionInitialization(); // Destructor
virtual void Build() const;
virtual void BuildForMaster() const;
};
#endif
#ifndef USEREVENTACTION_HH
#define USEREVENTACTION_HH
#include "G4Timer.hh"
#include "G4UserEventAction.hh"
#include "globals.hh"
#include "G4ThreeVector.hh"
// Defining actions performed at the beginning and/or the end of each event
// G4UserEventAction is the base class for defining user actions performed at
// the beginning and/or end of each event.
class UserRunAction;
class UserEventAction : public G4UserEventAction
{
public:
UserEventAction(); // Constructor
virtual ~UserEventAction(); // Destructor
// G4UserEventAction has two methods, BeginOfEventAction and
// EndOfEventAction, which can be overloaded by the user to define specific
// actions performed at the beginning and at the end of each event.
// Information about the event can be retrieved from the G4Event objects
// passed to these functions.
void BeginOfEventAction(const G4Event*);
void EndOfEventAction(const G4Event*);
};
#endif // USEREVENTACTION_HH
#ifndef USERRUN_HH
#define USERRUN_HH
#include "G4Run.hh"
#include "G4Event.hh"
#include "globals.hh"
// To collect data over worker threads at the end of an event loop, derived class of G4Run should be used.
// The base class defines the following virtual methods:
// void RecordEvent(const G4Event*)
// Method to be overwritten by the user for recording events in this (thread-local) run.
// Invoke G4Run base-class method for recording data member in the base class.
// If the user in the past has implemented an access to hits or scores in his/her UserEventAction::EndOfEventAction(),
// (s)he can simply move that code segment to this RecordEvent() method. See the following sample code.
// void Merge(const G4Run*)
// Method to be overwritten by the user for merging local Run object to the global Run object.
// Invoke G4Run base-class method to merge data member in the base class.
class UserRun : public G4Run
{
public:
UserRun();
virtual ~UserRun();
void RecordEvent(const G4Event*);
void Merge(const G4Run*);
private:
G4int hitsCollectionIndex;
G4int SDDhitsCollectionIndex;
};
#endif // USERRUN_HH
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment