Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • clantz2/zdclg
  • shengy3/zdclg
  • dmaclea2/zdclg
3 results
Show changes
Commits on Source (47)
Showing with 30447 additions and 298 deletions
......@@ -4,34 +4,49 @@
#include "TTree.h"
#include "TStyle.h"
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[]){
TFile *f = new TFile( Form("%s.root",argv[1]) );
float xRange, zRange;
if(argc == 0) return 0;
TFile *f = new TFile( argv[1] );
if(f->IsZombie()){
cout << Form("%s.root does not exist... exiting",argv[1]) << endl;
return 0;
}
string name = argv[1];
if(name.find("/") != string::npos) name.erase( 0, name.find_last_of("/") + 1 );
if(name.find(".") != string::npos) name.erase( name.find_last_of(".") );
TTree *t = (TTree*)f->Get("lightGuide");
double x,y;
vector<double> *x=0,*z=0;
t->SetBranchAddress("X",&x);
t->SetBranchAddress("Y",&y);
t->SetBranchAddress("Z",&z);
xRange = (argc > 2) ? atof( argv[2] ) : 40.;
zRange = (argc > 3) ? atof( argv[3] ) : 80.;
TCanvas *c = new TCanvas("Data","Data",1280,720);
TH2D *h = new TH2D("eff","Relative Efficiency",40,-82,82,40,-42.875,42.875);
TH2D *h = new TH2D("eff","Relative Efficiency",44,-1*zRange/2.,zRange/2.,21,-1*xRange/2.,xRange/2.);
//h->SetCanExtend(0);
int nEvents = t->GetEntries();
for(int ev = 0; ev < nEvents; ev++){
t->GetEntry(ev);
h->Fill(y,x);
int nPoints = x->size();
for(int i = 0; i < nPoints; i++){
h->Fill(z->at(i),x->at(i));
}
}
gStyle->SetOptStat(0);
h->Scale(1.0/h->GetMaximum());
h->Draw("COLZ");
c->Print( Form("%s.png",argv[1]) );
h->SetAxisRange(0.4,1.0,"Z");
c->Print( Form("%s.png",name.c_str()) );
delete f;
return 1;
}
......@@ -19,14 +19,6 @@ endif()
list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
find_package (ROOT REQUIRED)
include(${ROOT_USE_FILE})
#----------------------------------------------------------------------------
# Find CADMesh
find_package(cadmesh)
include_directories(${CADMESH_INCLUDE_DIRS})
if(CADMESH_INCLUDE_DIRS)
add_definitions(-DCADMESH)
endif()
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
#
......@@ -44,11 +36,16 @@ file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
# Add the executable, and link it to the Geant4 libraries
#
add_executable(lightGuide lightGuide.cc ${sources} ${headers})
target_link_libraries(lightGuide ${Geant4_LIBRARIES} ${ROOT_LIBRARIES} cadmesh )
target_link_libraries(lightGuide ${Geant4_LIBRARIES} ${ROOT_LIBRARIES})
add_executable(plotHisto ${DEPENDENCIES} Analysis/plotHisto.cc)
TARGET_LINK_LIBRARIES(plotHisto ${ROOT_LIBRARIES})
#----------------------------------------------------------------------------
#Add Compiler flags
#
add_definitions(-Wno-shadow)
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build lightGuide. This is so that we can run the executable directly because it
......@@ -57,6 +54,8 @@ TARGET_LINK_LIBRARIES(plotHisto ${ROOT_LIBRARIES})
set(lightGuide_SCRIPTS
vis.mac
run1.mac
beam.mac
geometry.mac
)
foreach(_script ${lightGuide_SCRIPTS})
......@@ -70,9 +69,11 @@ endforeach()
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS lightGuide DESTINATION bin)
install(FILES run1.mac DESTINATION . )
install(FILES run2.mac DESTINATION . )
install(FILES runAndAnalyze.sh DESTINATION . )
install(FILES vis.mac DESTINATION . )
install(TARGETS lightGuide DESTINATION bin )
install(TARGETS plotHisto DESTINATION bin )
install(FILES run1.mac DESTINATION bin )
install(FILES geometry.mac DESTINATION bin )
install(FILES beam.mac DESTINATION bin )
install(FILES vis.mac DESTINATION bin)
install(FILES hist.mac DESTINATION bin)
install(DIRECTORY models/ DESTINATION models)
MIT License
Copyright (c) 2024 srlund2
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.
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
This simulation is based on OpNovice and OpNovice2
Build requirements
Geant4 compiled with GDML and additional datasets
ROOT
-CADMesh is required to read CAD models (i.e. stl, step), but is optional for compiling
main()
------
==> define Random Number Engine, initial seed, CAD input and GDML output
G4VUserPhysicsList
------------------
==> define particles; including *** G4OpticalPhoton ***
define processes; including *** G4Cerenkov ***
*** G4Scintillation ***
*** G4OpAbsorption ***
*** G4OpRayleigh ***
*** G4OpBoundaryProcess ***
Materials
---------
==> defines many materials for potential use
For our purposes the G4OpticalSurface AlSurface and the G4Material Al and Air
will be given optical properties and used for construction.
G4VUserDetectorConstruction
---------------------------
==> A light guide is made either by simple G4trd or by importing a model
via CADMesh.
define G4LogicalBorderSurface between the light guide and world volume
defines a PMT window sensitive detector at the top of the light guide
AlSurface properties can be modified via DetectorMessenger via the following commands
/lightGuide/surfaceModel
/lightGuide/surfaceType
/lightGuide/surfaceFinish
/lightGuide/surfaceSigmaAlpha
/lightGuide/surfaceProperty
examples can be found in run1.mac
G4VUserPrimaryGeneratorAction
-----------------------------
==> Use G4GeneralParticleSource to shoot an optical photon into the light guide
Particle type and distribution is set in run1.mac
G4UserRunAction
---------------
==> define G4Timer (start/stop)
define G4AnalysisManager (output .root file)
set verbose levels
PMTHit
------
==> stores G4int trackID,
G4ThreeVector pos; // Origin position of the photon
G4ThreeVector hit; // Location where the photon hit the PMT window
G4double energy; // Energy of the photon
G4ThreeVector momentum; // Momentum of the photon (direction)
G4double time; // Time of arrival of the photon
for each hit on the PMT sensitive detector
PMTSD
------
==> Records a PMTHit if the photon strikes the PMT window
G4UserEventAction
---------------
==> Adds data from a PMTHit to the output root file
Visualisation
-------------
The Visualization Manager is set in the main().
The initialisation of the drawing is done via a set of /vis/ commands
in the macro vis.mac. This macro is automatically read from
the main in case of interactive running mode.
HOW TO START
------------
- compile and link to generate an executable
```
% mkdir zdclg-build zdclg-install
% cd zdclg-build
% cmake -DCMAKE_INSTALL_PREFIX=../zdclg-install /path/to/zdclg
```
This example handles the program arguments in a new way.
It can be run with the following optional arguments:
```
% ./lightGuide [-m macro ]
[-u UIsession]
[-t nThreads]
[-r seed]
[-o outputFileName]
[-c CADmodelName filetype]
[-co GDMLoutFileName]
```
The -t option is available only in multi-threading mode
and it allows the user to override the Geant4 default number of
threads. The number of threads can be also set via G4FORCENUMBEROFTHREADS
environment variable which has the top priority.
- execute lightGuide in 'batch' mode from macro files
```
% ./lightGuide -m run1.mac
```
- execute lightGuide in 'interactive mode' with visualization
```
% ./lightGuide
....
Idle> type your commands. For instance:
Idle> /control/execute run1.mac
....
Idle> exit
```
### ZDC Light Guide Monte Carlo
This simulation is based on OpNovice and OpNovice2
#### Build requirements
- Geant4 compiled with GDML and additional datasets. Be sure to source geant4make.sh
```
source /path/to/geant4-install/share/Geant4-[version]/geant4make/geant4make.sh
```
- CERN ROOT
#### main()
define Random Number Engine, initial seed, CAD input and GDML output
#### G4VUserPhysicsList
- Define particles; including
- *** G4OpticalPhoton ***
- Define processes; including
- *** G4Cerenkov ***
- *** G4Scintillation ***
- *** G4OpAbsorption ***
- *** G4OpRayleigh ***
- *** G4OpBoundaryProcess ***
#### Materials
defines many materials for potential use
For our purposes the G4OpticalSurface AlSurface and the G4Material Al and Air
will be given optical properties and used for construction.
#### G4VUserDetectorConstruction
A light guide is made either by simple G4trd or by importing a model
via CADMesh.
define G4LogicalBorderSurface between the light guide and world volume
defines a PMT window sensitive detector at the top of the light guide
AlSurface properties can be modified via DetectorMessenger via the following commands
```
/lightGuide/surface/Model
/lightGuide/surface/Type
/lightGuide/surface/Finish
/lightGuide/surface/SigmaAlpha
/lightGuide/surface/Property
```
CAD models can be imported and positioned via
```
/lightGuide/model/CADmodel
/lightGuide/model/rotate
/lightGuide/model/translate
/lightGuide/model/translatePMT
```
The models must be in ASCII STL format in the current implementation.
And the optical properties of a sub volume of G4Air which the light guide sits in can be configured via
```
/lightGuide/gasProperty
```
examples of all of these can be found in run1.mac
#### G4VUserPrimaryGeneratorAction
Use G4GeneralParticleSource to shoot an optical photon into the light guide
Particle type and distribution is set in run1.mac
#### G4UserRunAction
define G4Timer (start/stop)
define G4AnalysisManager (output .root file)
set verbose levels
#### PMTHit
stores G4int trackID,
G4ThreeVector pos; // Origin position of the photon
G4ThreeVector hit; // Location where the photon hit the PMT window
G4double energy; // Energy of the photon
G4ThreeVector momentum; // Momentum of the photon (direction)
G4double time; // Time of arrival of the photon
for each hit on the PMT sensitive detector
#### PMTSD
Records a PMTHit if the photon strikes the PMT window
#### G4UserEventAction
Show how to count the number of secondary particles in an event
#### Visualisation
The Visualization Manager is set in the main().
The initialisation of the drawing is done via a set of /vis/ commands
in the macro vis.mac. This macro is automatically read from
the main in case of interactive running mode.
#### How to start
- compile and link to generate an executable
```
$ mkdir zdclg-build zdclg-install
$ cd zdclg-build
$ cmake -DCMAKE_INSTALL_PREFIX=../zdclg-install /path/to/zdclg
```
This example handles the program arguments in a new way.
It can be run with the following optional arguments:
```
$ ./lightGuide [-m macro ]
[-u UIsession]
[-t nThreads]
[-r seed]
[-o outputFileName]
```
The -t option is available only in multi-threading mode
and it allows the user to override the Geant4 default number of
threads. The number of threads can be also set via G4FORCENUMBEROFTHREADS
environment variable which has the top priority.
- execute lightGuide in 'batch' mode from macro files
```
$ ./lightGuide -m run1.mac
```
- execute lightGuide in 'interactive mode' with visualization
```
$ lightGuide
....
Idle> type your commands. For instance:
Idle> /control/execute run1.mac
....
Idle> exit
```
#----- Set the beam energy profile -----
/gps/particle opticalphoton
/gps/ene/type Gauss
/gps/ene/mono 4.75 eV
/gps/ene/sigma 10 eV
/gps/ene/min 1.9 eV
/gps/ene/max 7.6 eV
/gps/ene/gradient -200 MeV
/gps/polarization 0 0 0
#----- Set the beam geometry -----
# Circular beam source. Simulates a single fiber optic
#/gps/pos/type Beam
#/gps/pos/shape Circle
#/gps/pos/radius 0.75 mm
#/gps/pos/radius 1.5 mm
#/gps/pos/sigma_r 0.002 mm
# Rectangular plane for infinite resolution
/gps/pos/type Plane
/gps/pos/shape Rectangle
/gps/pos/halfx 40 mm
/gps/pos/halfy 68 mm
# the incident surface is in the x-z plane just below the gas
/gps/pos/rot1 1 0 0
/gps/pos/rot2 0 0 1
/gps/pos/centre 0. -0.1 0. mm
# the photons are emitted around the y-axis
/gps/ang/rot1 1 0 0
/gps/ang/rot2 0 0 1
/gps/ang/type beam1d
#----- Set beam angular dispersion from histogram -----
/gps/ang/surfnorm false
/gps/ang/type user
/control/execute hist.mac
#----- Set beam angular dispersion for fiber optic -----
# N.A. is 0.22 so acceptance cone is ~25.4 degrees
#/gps/ang/sigma_r 25.40 deg
/lightGuide/worldVolume 0.25 0.25 0.25 m
/lightGuide/envelope 89.75 113. 165. mm
/lightGuide/model/PMTDiameter 53 mm
/lightGuide/model/nSegmentsX 1
/lightGuide/model/nSegmentsZ 1
#----- Set the light guide to be used and position it -----
#If no model is selected, the program will default to a
#simplified version of the 2018 testbeam light guide
/lightGuide/model/CADmodel ../models/run2.stl
/lightGuide/model/translate 200 -125 0 mm
/lightGuide/model/translatePMT 0 -74.5 0 mm
#/lightGuide/model/CADmodel ../models/EMprototype.stl
#/lightGuide/model/translate 0 0 0 mm
#/lightGuide/model/translatePMT 0 -74.5 0 mm
#/lightGuide/model/CADmodel ../models/EMprototypeSingle.stl
#/lightGuide/model/translate 175.25 -27.75 -8 mm
#/lightGuide/model/translatePMT 0 0 0 mm
#/lightGuide/model/CADmodel ../models/2020WC.stl
#/lightGuide/model/rotate 0 0 90
#/lightGuide/model/translate 0 -319 0 mm
#/lightGuide/model/translatePMT 0 -119 0 mm
#----- Set surface properties of the light guide -----
#/lightGuide/surface/Model unified
#/lightGuide/surface/Type dielectric_metal
#/lightGuide/surface/Finish ground
#/lightGuide/surface/SigmaAlpha .1
#/lightGuide/surface/Property SPECULARLOBECONSTANT 0.000002 .4 0.000008 .4
#/lightGuide/surface/Property SPECULARSPIKECONSTANT 0.000002 .1 0.000008 .1
#/lightGuide/surface/Property BACKSCATTERCONSTANT 0.000002 .05 0.000008 .05
#/lightGuide/surface/Property REFLECTIVITY 0.000002 .89 0.000008 .89
#----- Set the refractive index of the gas the light guide is inside of -----
#/lightGuide/gasProperty RINDEX 0.000002 1.0 0.000008 1.0
/gps/hist/type theta
#/gps/hist/point -0.007400 0.000000
/gps/hist/point 0.000000 0.000059
/gps/hist/point 0.007400 0.000338
/gps/hist/point 0.014800 0.000512
/gps/hist/point 0.022200 0.000687
/gps/hist/point 0.029600 0.000990
/gps/hist/point 0.037000 0.001121
/gps/hist/point 0.044400 0.001404
/gps/hist/point 0.051800 0.001575
/gps/hist/point 0.059200 0.001921
/gps/hist/point 0.066600 0.002071
/gps/hist/point 0.074000 0.002209
/gps/hist/point 0.081400 0.002370
/gps/hist/point 0.088800 0.002663
/gps/hist/point 0.096200 0.002832
/gps/hist/point 0.103600 0.003022
/gps/hist/point 0.111000 0.003347
/gps/hist/point 0.118400 0.003500
/gps/hist/point 0.125800 0.003817
/gps/hist/point 0.133200 0.003972
/gps/hist/point 0.140600 0.004145
/gps/hist/point 0.148000 0.004303
/gps/hist/point 0.155400 0.004621
/gps/hist/point 0.162800 0.004762
/gps/hist/point 0.170200 0.005010
/gps/hist/point 0.177600 0.005308
/gps/hist/point 0.185000 0.005465
/gps/hist/point 0.192400 0.005574
/gps/hist/point 0.199800 0.005896
/gps/hist/point 0.207200 0.006192
/gps/hist/point 0.214600 0.006292
/gps/hist/point 0.222000 0.006516
/gps/hist/point 0.229400 0.006742
/gps/hist/point 0.236800 0.006942
/gps/hist/point 0.244200 0.007175
/gps/hist/point 0.251600 0.007442
/gps/hist/point 0.259000 0.007549
/gps/hist/point 0.266400 0.007859
/gps/hist/point 0.273800 0.007951
/gps/hist/point 0.281200 0.008102
/gps/hist/point 0.288600 0.008663
/gps/hist/point 0.296000 0.008789
/gps/hist/point 0.303400 0.009103
/gps/hist/point 0.310800 0.009285
/gps/hist/point 0.318200 0.009436
/gps/hist/point 0.325600 0.009630
/gps/hist/point 0.333000 0.009931
/gps/hist/point 0.340400 0.010256
/gps/hist/point 0.347800 0.010362
/gps/hist/point 0.355200 0.010797
/gps/hist/point 0.362600 0.010825
/gps/hist/point 0.370000 0.011403
/gps/hist/point 0.377400 0.011606
/gps/hist/point 0.384800 0.011730
/gps/hist/point 0.392200 0.011980
/gps/hist/point 0.399600 0.012238
/gps/hist/point 0.407000 0.012208
/gps/hist/point 0.414400 0.012737
/gps/hist/point 0.421800 0.013022
/gps/hist/point 0.429200 0.013560
/gps/hist/point 0.436600 0.013393
/gps/hist/point 0.444000 0.013733
/gps/hist/point 0.451400 0.014151
/gps/hist/point 0.458800 0.014394
/gps/hist/point 0.466200 0.014743
/gps/hist/point 0.473600 0.015354
/gps/hist/point 0.481000 0.015463
/gps/hist/point 0.488400 0.015805
/gps/hist/point 0.495800 0.016047
/gps/hist/point 0.503200 0.016040
/gps/hist/point 0.510600 0.016432
/gps/hist/point 0.518000 0.016911
/gps/hist/point 0.525400 0.017092
/gps/hist/point 0.532800 0.017341
/gps/hist/point 0.540200 0.017891
/gps/hist/point 0.547600 0.018050
/gps/hist/point 0.555000 0.018850
/gps/hist/point 0.562400 0.019253
/gps/hist/point 0.569800 0.019231
/gps/hist/point 0.577200 0.019886
/gps/hist/point 0.584600 0.020413
/gps/hist/point 0.592000 0.020505
/gps/hist/point 0.599400 0.021237
/gps/hist/point 0.606800 0.021726
/gps/hist/point 0.614200 0.022311
/gps/hist/point 0.621600 0.022637
/gps/hist/point 0.629000 0.023515
/gps/hist/point 0.636400 0.024492
/gps/hist/point 0.643800 0.025049
/gps/hist/point 0.651200 0.025821
/gps/hist/point 0.658600 0.026996
/gps/hist/point 0.666000 0.028316
/gps/hist/point 0.673400 0.007106
/gps/hist/point 0.680800 0.000000
/gps/hist/point 0.688200 0.000000
/gps/hist/point 0.695600 0.000000
/gps/hist/point 0.703000 0.000000
/gps/hist/point 0.710400 0.000000
/gps/hist/point 0.717800 0.000000
/gps/hist/point 0.725200 0.000000
# #OLD HIST.MAC
# /gps/hist/point 0.000000 0.000000
# /gps/hist/point 0.008726 0.001677
# /gps/hist/point 0.026179 0.002438
# /gps/hist/point 0.043632 0.002966
# /gps/hist/point 0.061085 0.003407
# /gps/hist/point 0.078538 0.003771
# /gps/hist/point 0.095990 0.004110
# /gps/hist/point 0.113443 0.004415
# /gps/hist/point 0.130896 0.004724
# /gps/hist/point 0.148349 0.005010
# /gps/hist/point 0.165801 0.005293
# /gps/hist/point 0.183254 0.005592
# /gps/hist/point 0.200707 0.005862
# /gps/hist/point 0.218160 0.006130
# /gps/hist/point 0.235613 0.006412
# /gps/hist/point 0.253065 0.006682
# /gps/hist/point 0.270518 0.006950
# /gps/hist/point 0.287971 0.007234
# /gps/hist/point 0.305424 0.007515
# /gps/hist/point 0.322876 0.007781
# /gps/hist/point 0.340329 0.008063
# /gps/hist/point 0.357782 0.008323
# /gps/hist/point 0.375235 0.008598
# /gps/hist/point 0.392687 0.008907
# /gps/hist/point 0.410140 0.009175
# /gps/hist/point 0.427593 0.009454
# /gps/hist/point 0.445046 0.009775
# /gps/hist/point 0.462499 0.010074
# /gps/hist/point 0.479951 0.010385
# /gps/hist/point 0.497404 0.010707
# /gps/hist/point 0.514857 0.011049
# /gps/hist/point 0.532310 0.011366
# /gps/hist/point 0.549762 0.011748
# /gps/hist/point 0.567215 0.012158
# /gps/hist/point 0.584668 0.012550
# /gps/hist/point 0.602121 0.012953
# /gps/hist/point 0.619574 0.013384
# /gps/hist/point 0.637026 0.013836
# /gps/hist/point 0.654479 0.014333
# /gps/hist/point 0.671932 0.014900
# /gps/hist/point 0.689385 0.015575
# /gps/hist/point 0.706837 0.016303
# /gps/hist/point 0.724290 0.017249
# /gps/hist/point 0.741743 0.018648
# /gps/hist/point 0.759196 0.019849
# /gps/hist/point 0.776649 0.020756
# /gps/hist/point 0.794101 0.021327
# /gps/hist/point 0.811554 0.019696
# /gps/hist/point 0.829007 0.018203
# /gps/hist/point 0.846460 0.017120
# /gps/hist/point 0.863912 0.016291
# /gps/hist/point 0.881365 0.015641
# /gps/hist/point 0.898818 0.015079
# /gps/hist/point 0.916271 0.014629
# /gps/hist/point 0.933724 0.014212
# /gps/hist/point 0.951176 0.013883
# /gps/hist/point 0.968629 0.013545
# /gps/hist/point 0.986082 0.013284
# /gps/hist/point 1.003535 0.013057
# /gps/hist/point 1.020988 0.012847
# /gps/hist/point 1.038440 0.012644
# /gps/hist/point 1.055893 0.012443
# /gps/hist/point 1.073346 0.012321
# /gps/hist/point 1.090799 0.012159
# /gps/hist/point 1.108251 0.012022
# /gps/hist/point 1.125704 0.011891
# /gps/hist/point 1.143157 0.011784
# /gps/hist/point 1.160610 0.011684
# /gps/hist/point 1.178063 0.011600
# /gps/hist/point 1.195515 0.011499
# /gps/hist/point 1.212968 0.011423
# /gps/hist/point 1.230421 0.011358
# /gps/hist/point 1.247874 0.011273
# /gps/hist/point 1.265326 0.011216
# /gps/hist/point 1.282779 0.011145
# /gps/hist/point 1.300232 0.011114
# /gps/hist/point 1.317685 0.011054
# /gps/hist/point 1.335137 0.011028
# /gps/hist/point 1.352590 0.010988
# /gps/hist/point 1.370043 0.010938
# /gps/hist/point 1.387496 0.010915
# /gps/hist/point 1.404949 0.010911
# /gps/hist/point 1.422401 0.010852
# /gps/hist/point 1.439854 0.010845
# /gps/hist/point 1.457307 0.010834
# /gps/hist/point 1.474760 0.010807
# /gps/hist/point 1.492212 0.010819
# /gps/hist/point 1.509665 0.010799
# /gps/hist/point 1.527118 0.010811
# /gps/hist/point 1.544571 0.009312
# /gps/hist/point 1.562024 0.008725
# /gps/hist/point 1.570700 0.000000
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file ASCIIPrimaryGenerator.hh
/// \brief Definition of the ASCIIPrimaryGenerator class
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef ASCIIPrimaryGenerator_h
#define ASCIIPrimaryGenerator_h 1
#include "G4VPrimaryGenerator.hh"
#include <fstream>
#include <vector>
class G4Event;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class ASCIIPrimaryGenerator : public G4VPrimaryGenerator
{
public:
ASCIIPrimaryGenerator();
~ASCIIPrimaryGenerator();
virtual void SetInputFile(G4String _name);
virtual void GetNextEvent( );
inline G4int GetnEvents(){return fnEvents;}
public:
virtual void GeneratePrimaryVertex(G4Event*);
private:
std::vector< G4ThreeVector >* fPositionVec;
std::vector< G4ThreeVector >* fMomentumVec;
std::vector< G4double >* fEnergyVec;
G4int fEventNo;
G4int fnEvents = 0;
std::ifstream fInputFile;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
This diff is collapsed.
......@@ -37,7 +37,9 @@
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4VUserDetectorConstruction.hh"
#include "G4GDMLParser.hh"
#include "G4SubtractionSolid.hh"
// #include "G4GDMLParser.hh"
#include "G4RunManager.hh"
#include "Materials.hh"
#include "DetectorMessenger.hh"
......@@ -51,53 +53,72 @@ class DetectorConstruction : public G4VUserDetectorConstruction
public:
virtual G4VPhysicalVolume* Construct();
void SetCADFilename (std::string name);
void SetCADFiletype (std::string type){m_filetype = type;}
void SetGDMLoutName (std::string name){GDMLoutput = name;}
void ConstructSDandField();
void BuildWorld ();
void BuildTrapezoidLG ();
void BuildPMT ();
void PlaceGeometry ();
void SetWorldVolume (G4ThreeVector arg);
void SetEnvelope (G4ThreeVector arg);
void SetRotation (G4ThreeVector arg);
void SetTranslation (G4ThreeVector arg);
void SetPMTTranslation (G4ThreeVector arg);
void SetPMTDiameter (G4double arg);
void SetLGthickness (G4double arg);
void UseCADModel (G4String fileName);
void OutputToGDML (G4String name);
void SetNSegmentsX (G4int arg);
void SetNSegmentsZ (G4int arg);
void SetSurfaceSigmaAlpha (G4double v);
void SetSurfaceModel (const G4OpticalSurfaceModel model);
void SetSurfaceFinish (const G4OpticalSurfaceFinish finish);
void SetSurfaceType (const G4SurfaceType type);
void SetSurfaceModel (const G4OpticalSurfaceModel model);
void SetSurfaceSigmaAlpha (G4double v);
void AddSurfaceMPV (const char* c, G4MaterialPropertyVector* mpv);
void SetRotationX (G4int arg);
void SetRotationY (G4int arg);
void SetRotationZ (G4int arg);
void SetOffsetX (G4double arg);
void SetOffsetY (G4double arg);
void SetOffsetZ (G4double arg);
void AddGasMPV (const char* c, G4MaterialPropertyVector* mpv);
private:
G4Box* m_solidWorld;
G4LogicalVolume* m_logicWorld;
G4VPhysicalVolume* m_physWorld;
G4LogicalVolume* m_logicLightGuide;
G4VPhysicalVolume* m_physLightGuide;
G4Box* m_solidFillGas;
G4LogicalVolume* m_logicFillGas;
G4VPhysicalVolume* m_physFillGas;
G4int m_rotX;
G4int m_rotY;
G4int m_rotZ;
G4double m_offsetX;
G4double m_offsetY;
G4double m_offsetZ;
Materials* materials;
std::string m_filename;
std::string m_filetype;
std::string GDMLoutput;
G4GDMLParser m_Parser;
DetectorMessenger* m_DetectorMessenger;
G4ThreeVector* m_worldDim;
G4ThreeVector* m_LGenvelope;
G4ThreeVector* m_LGpos;
G4ThreeVector* m_pmtPos;
G4RotationMatrix* m_rotation;
G4double m_pmtDia;
G4double m_PMTthickness;
G4double m_thickness;
G4int m_nSegmentsX;
G4int m_nSegmentsZ;
G4bool m_ConstructionHasBeenDone;
G4bool m_UsingCADmodel;
G4Box* m_solidWorld;
G4LogicalVolume* m_logicWorld;
G4VPhysicalVolume* m_physWorld;
G4Box* m_solidHalfWorld;
G4LogicalVolume* m_logicHalfWorld;
G4VPhysicalVolume* m_physHalfWorld;
G4Trd* m_inner;
G4Trd* m_outter;
G4SubtractionSolid* m_LightGuide;
G4LogicalVolume* m_logicLightGuide;
std::vector< G4VPhysicalVolume* > m_physLightGuide;
G4Tubs* m_solidPMT;
G4LogicalVolume* m_logicPMT;
std::vector< G4VPhysicalVolume* > m_physPMT;
std::vector< G4LogicalBorderSurface* > m_Surfvec;
Materials* materials;
G4Material* m_filler;
G4MaterialPropertiesTable* m_GasMPT;
// G4GDMLParser m_Parser;
G4RunManager* m_runMan;
DetectorMessenger* m_DetectorMessenger;
};
#endif /*DetectorConstruction_h*/
......@@ -42,6 +42,7 @@ class G4UIcmdWithAnInteger;
class G4UIcmdWithADouble;
class G4UIcmdWithADoubleAndUnit;
class G4UIcmdWithoutParameter;
class G4UIcmdWith3VectorAndUnit;
class DetectorMessenger: public G4UImessenger{
......@@ -57,21 +58,31 @@ class DetectorMessenger: public G4UImessenger{
DetectorConstruction* fDetector;
G4UIdirectory* flightGuideDir;
G4UIdirectory* fSurfaceDir;
G4UIdirectory* fModelDir;
// the model
G4UIcmdWithAString* fModelCmd;
G4UIcmdWith3VectorAndUnit* fWorldVolumeCmd;
G4UIcmdWith3VectorAndUnit* fEnvelopeCmd;
G4UIcmdWith3VectorAndUnit* fModelRotationCmd;
G4UIcmdWith3VectorAndUnit* fModelTranslationCmd;
G4UIcmdWith3VectorAndUnit* fPMTTranslationCmd;
G4UIcmdWithADoubleAndUnit* fPMTDiameterCmd;
G4UIcmdWithADoubleAndUnit* fLGThicknessCmd;
G4UIcmdWithAString* fOutputModelCmd;
G4UIcmdWithAnInteger* fNsegmentsXCmd;
G4UIcmdWithAnInteger* fNsegmentsZCmd;
// the surface
G4UIcmdWithAString* fSurfaceTypeCmd;
G4UIcmdWithAString* fSurfaceFinishCmd;
G4UIcmdWithAString* fSurfaceModelCmd;
G4UIcmdWithAString* fSurfaceFinishCmd;
G4UIcmdWithAString* fSurfaceTypeCmd;
G4UIcmdWithADouble* fSurfaceSigmaAlphaCmd;
G4UIcmdWithAString* fSurfaceMatPropVectorCmd;
G4UIcmdWithAString* fModelCmd;
G4UIcmdWithAnInteger* fModelRotationXCmd;
G4UIcmdWithAnInteger* fModelRotationYCmd;
G4UIcmdWithAnInteger* fModelRotationZCmd;
G4UIcmdWithADouble* fModelOffsetXCmd;
G4UIcmdWithADouble* fModelOffsetYCmd;
G4UIcmdWithADouble* fModelOffsetZCmd;
// the gas
G4UIcmdWithAString* fGasPropVectorCmd;
};
#endif
......@@ -36,11 +36,8 @@ class EventAction : public G4UserEventAction{
virtual ~EventAction();
virtual void BeginOfEventAction( const G4Event* event );
virtual void EndOfEventAction( const G4Event* event );
virtual void EndOfEventAction( const G4Event* event );
private:
G4int hitsCollID;
G4int fEventNo;
};
#endif
......@@ -48,6 +48,9 @@ public:
private:
int HCID;
HitsCollection* hitCollection;
std::vector< std::vector<double>* > fPtrVec;
bool VISUALIZE;
};
#endif
......@@ -28,8 +28,16 @@
#ifndef PrimaryGeneratorAction_h
#define PrimaryGeneratorAction_h 1
#include "TFile.h"
#include "TTree.h"
#include "G4VUserPrimaryGeneratorAction.hh"
#include "globals.hh"
#include "PrimaryGeneratorMessenger.hh"
#include "ASCIIPrimaryGenerator.hh"
#include "G4GeneralParticleSource.hh"
#include <vector>
class G4GeneralParticleSource;
class G4Event;
......@@ -42,10 +50,23 @@ class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
virtual ~PrimaryGeneratorAction();
public:
virtual void GeneratePrimaries(G4Event*);
virtual void GeneratePrimaries(G4Event*);
virtual void GeneratePrimariesFromRootFile(G4Event*);
virtual void SetInputFile(G4String _name);
inline G4int GetnEvents(){return fnEvents;}
private:
G4GeneralParticleSource* fParticleGun;
G4GeneralParticleSource* fParticleGun;
ASCIIPrimaryGenerator* fASCIIParticleGun;
PrimaryGeneratorMessenger* fMessenger;
G4int fnEvents;
G4bool fUseASCIIInput;
G4bool fUseRootInput;
TFile* fInputFile;
TTree* fInputTree;
std::vector<G4double> *x, *z, *px, *py, *pz, *Energy, *time;
G4int evNo;
};
#endif /*PrimaryGeneratorAction_h*/
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file lgAnalysis.hh
/// \brief Selection of the analysis technology
#ifndef lgAnalysis_h
#define lgAnalysis_h 1
#include "g4root.hh"
//#include "g4cvs.hh"
//#include "g4xml.hh"
#endif
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file optical/OpNovice2/include/DetectorMessenger.hh
/// \brief Definition of the DetectorMessenger class
//
//
//
#ifndef PrimaryGeneratorMessenger_h
#define PrimaryGeneratorMessenger_h 1
#include "globals.hh"
#include "G4UImessenger.hh"
class PrimaryGeneratorAction;
class G4UIdirectory;
class G4UIcommand;
class G4UIcmdWithAString;
class G4UIcmdWithAnInteger;
class G4UIcmdWithADouble;
class G4UIcmdWithADoubleAndUnit;
class G4UIcmdWithoutParameter;
class G4UIcmdWith3VectorAndUnit;
class PrimaryGeneratorMessenger: public G4UImessenger{
public:
PrimaryGeneratorMessenger(PrimaryGeneratorAction* );
~PrimaryGeneratorMessenger();
virtual void SetNewValue(G4UIcommand*, G4String);
private:
PrimaryGeneratorAction* fGenerator;
G4UIdirectory* fGeneratorDir;
G4UIcmdWithAString* fInputFileCmd;
};
#endif
......@@ -37,6 +37,8 @@
#include "globals.hh"
#include "G4UserRunAction.hh"
#include <vector>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class G4Timer;
......@@ -52,9 +54,14 @@ class RunAction : public G4UserRunAction
virtual void BeginOfRunAction(const G4Run* aRun);
virtual void EndOfRunAction(const G4Run* aRun);
std::vector< std::vector<double>* > GetVectors(){ return fPtrVec; }
inline void ClearVectors(){ for(auto vec : fPtrVec) vec->clear(); }
private:
G4Timer* fTimer;
G4String ffileName = "";
G4String m_fileName;
std::vector< std::vector<double>* > fPtrVec;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
......
......@@ -46,9 +46,7 @@ class SteppingAction : public G4UserSteppingAction
virtual void UserSteppingAction(const G4Step*);
private:
G4int fScintillationCounter;
G4int fCerenkovCounter;
G4int fEventNumber;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
......
......@@ -45,6 +45,7 @@
#include "DetectorConstruction.hh"
#include "ActionInitialization.hh"
#include "PrimaryGeneratorAction.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
......@@ -55,7 +56,7 @@
namespace {
void PrintUsage() {
G4cerr << " Usage: " << G4endl;
G4cerr << " lightGuide [-m macro ] [-u UIsession] [-t nThreads] [-r seed] [-o outputFileName] [-c CADmodelName filetype] [-co GDMLoutFileName] [-s ReflectiveSurfaceRoughness]"
G4cerr << " lightGuide [-m macro ] [-u UIsession] [-t nThreads] [-r seed] [-o outputFileName]"
<< G4endl;
G4cerr << " note: -t option is available only for multi-threaded mode."
<< G4endl;
......@@ -75,10 +76,7 @@ int main(int argc,char** argv)
G4String macro;
G4String session;
G4String output;
G4String CADmodel = "";
G4String filetype;
G4String CADoutFile = "";
G4String output = "", input = "";
#ifdef G4MULTITHREADED
G4int nThreads = 0;
#endif
......@@ -88,8 +86,7 @@ int main(int argc,char** argv)
if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
else if ( G4String(argv[i]) == "-u" ) session = argv[i+1];
else if ( G4String(argv[i]) == "-o" ) output = argv[i+1];
else if ( G4String(argv[i]) == "-c" ){CADmodel = argv[i+1]; filetype = argv[i+2];i++;}
else if ( G4String(argv[i]) == "-co" ) CADoutFile = argv[i+1];
else if ( G4String(argv[i]) == "-i" ) input = argv[i+1];
else if ( G4String(argv[i]) == "-r" ) myseed = atoi(argv[i+1]);
#ifdef G4MULTITHREADED
else if ( G4String(argv[i]) == "-t" ) {
......@@ -103,28 +100,6 @@ int main(int argc,char** argv)
}
//----------------- Check options against dependencies -----------------//
if(CADmodel != ""){
// Check if the user has GDML support and if they are asking for it
#ifndef G4LIB_USE_GDML
filetype.toLower();
if(filetype == "gdml"){
G4cout << "G4GDML not defined!!! aborting" << G4endl;
return 0;
}
if(CADoutFile != ""){
G4cout << "G4GDML not defined!!! Model will not be converted" << G4endl;
CADoutFile = "";
}
#endif
//If you want to use CADMesh but don't have it installed
if(filetype == "stl" && !CADMESH){
G4cout << "Cannot read STL models without CADMESH installed!!! aborting" << G4endl;
}
}
// Instantiate G4UIExecutive if interactive mode
G4UIExecutive* ui = nullptr;
if ( macro.size() == 0 ) {
......@@ -151,15 +126,9 @@ int main(int argc,char** argv)
// Set mandatory initialization classes
//
// Detector construction
DetectorConstruction* DetConst = new DetectorConstruction();
if(CADmodel != ""){
DetConst->SetCADFilename(CADmodel);
DetConst->SetCADFiletype(filetype);
DetConst->SetGDMLoutName(CADoutFile);
}
runManager-> SetUserInitialization(DetConst);
runManager->SetUserInitialization(new DetectorConstruction());
// Physics list
runManager-> SetUserInitialization(new PhysicsList());
runManager->SetUserInitialization(new PhysicsList());
// User action initialization
runManager->SetUserInitialization(new ActionInitialization(output));
......@@ -176,11 +145,14 @@ int main(int argc,char** argv)
// Get the pointer to the User Interface manager
//
G4UImanager* UImanager = G4UImanager::GetUIpointer();
if(input != ""){
G4String command = "/Input/FileName ";
UImanager->ApplyCommand(command+input);
}
if ( macro.size() ) {
// Batch mode
G4String command = "/control/execute ";
UImanager->ApplyCommand(command+macro);
UImanager->ExecuteMacroFile(macro);
}
else // Define UI session for interactive mode
{
......
This diff is collapsed.