IAP GITLAB

Commit d6e62402 authored by Ralf Ulrich's avatar Ralf Ulrich

initial code

parent ec9b20a5
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(mQsim)
#----------------------------------------------------------------------------
# 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()
find_package(ROOT REQUIRED)
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
#
include(${Geant4_USE_FILE})
#add_definitions(${ROOT_CXX_FLAGS})
#----------------------------------------------------------------------------
# Locate sources and headers for this project
#
include_directories(${PROJECT_SOURCE_DIR}/include
${Geant4_INCLUDE_DIR} ${ROOT_INCLUDE_DIRS})
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(mQsim mQsim.cc ${sources} ${headers})
target_link_libraries(mQsim ${Geant4_LIBRARIES} ${ROOT_LIBRARIES})
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build RE01. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
#set(RE01_SCRIPTS
# sample.in vis.mac pythia_event.data
# )
#foreach(_script ${RE01_SCRIPTS})
# configure_file(
# ${PROJECT_SOURCE_DIR}/${_script}
# ${PROJECT_BINARY_DIR}/${_script}
# COPYONLY
# )
#endforeach()
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS mQsim DESTINATION bin)
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(musim)
#----------------------------------------------------------------------------
# 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()
find_package(ROOT REQUIRED)
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
#
include(${Geant4_USE_FILE})
#add_definitions(${ROOT_CXX_FLAGS})
#----------------------------------------------------------------------------
# Locate sources and headers for this project
#
include_directories(${PROJECT_SOURCE_DIR}/include
${Geant4_INCLUDE_DIR} ${ROOT_INCLUDE_DIRS})
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(musim musim.cc ${sources} ${headers})
target_link_libraries(musim ${Geant4_LIBRARIES} ${ROOT_LIBRARIES})
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build RE01. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
#set(RE01_SCRIPTS
# sample.in vis.mac pythia_event.data
# )
#foreach(_script ${RE01_SCRIPTS})
# configure_file(
# ${PROJECT_SOURCE_DIR}/${_script}
# ${PROJECT_BINARY_DIR}/${_script}
# COPYONLY
# )
#endforeach()
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS musim DESTINATION bin)
This diff is collapsed.
NaISpectrum()
{
TFile* f = TFile::Open("NaI_spectrum.root");
TGraph* g = f->Get("spectrum");
g->Draw("ap");
double h = 6.63e-34; // J s
double c = 3.00e8; // m/s
double e = 1.6e-19; // C
double nu = 300e-9; // m
double E = h*c / nu /e;
// 4.1328 eV
cout << E << endl;
double numin = 300;
double numax = 900;
double Emin = h*c/numax/e;
double Emax = h*c/numin/e;
double c = 0;
vector<double> vecx, vecy;
for (int i=0; i<20; ++i) {
double E = Emin + (Emax-Emin) / (19) * i;
c += g->Eval(E);
vecx.push_back(E);
vecy.push_back(g->Eval(E));
}
c *= (Emin-Emin) / 19;
for (int i=0; i<vecx.size(); ++i) {
vecy[i] = vecy[i] / c;
cout << vecx[i] << " " << vecy[i] << endl;
}
}
Uvec
2226355706
1071850947
536870912
1070468751
0
1072094641
2147483648
1072651016
3221225472
1069309475
0
1072443817
3758096384
1070976523
3221225472
1071289853
3221225472
1071071875
1073741824
1072058341
3221225472
1071770988
2684354560
1072088346
2684354560
1070711224
2147483648
1070880457
1073741824
1071679922
1610612736
1072530916
2147483648
1068991161
0
1068982748
0
1069137651
0
1070197808
2147483648
1071034997
1073741824
1072491767
0
1072063669
2147483648
1071669941
1610612736
1071425952
0
1071680817
3758096384
1072282005
2684354560
1071682361
3758096384
1072088295
536870912
1071021071
0
1072324201
2147483648
1072635588
0
1070427572
0
1071982849
0
1067871430
0
1070929070
3221225472
1072387045
536870912
1072033877
1073741824
1071564431
3221225472
1071035843
0
1071412029
2147483648
1072347747
2147483648
1071235651
2147483648
1071029980
3221225472
1072298428
3221225472
1070720400
1073741824
1070366753
0
1072463122
1610612736
1071035322
0
1070439559
2147483648
1071022557
2147483648
1072310601
1073741824
1070089151
0
1072211654
2684354560
1069739795
2147483648
1070769975
0
1072181015
1073741824
1071436856
3221225472
1071090647
2147483648
1070843502
2147483648
1069406139
0
1072621849
1610612736
1071955215
0
1072630482
1610612736
1072472133
2684354560
1071133674
1073741824
1069436211
0
1070807539
1073741824
1070584810
2147483648
1072057865
2147483648
1071089825
2147483648
1072598545
2684354560
1072155654
0
1068842061
0
1065626520
0
1072486891
3221225472
1072447619
2684354560
1071506370
0
1071649186
3221225472
1072596079
1610612736
1070456516
2147483648
1069718447
0
1072094211
1073741824
1069803954
2147483648
1069666405
0
1072668540
1610612736
1071931564
2147483648
1070292338
2147483648
1072659616
0
1069962324
2147483648
1070704689
2147483648
1072495071
2147483648
1072305576
3758096384
1071017549
3221225472
1069148266
0
1071011469
1073741824
1072437569
1073741824
1072182277
536870912
1071461100
1073741824
1072693247
2684354560
55
Uvec
2226355706
1071850947
536870912
1070468751
0
1072094641
2147483648
1072651016
3221225472
1069309475
0
1072443817
3758096384
1070976523
3221225472
1071289853
3221225472
1071071875
1073741824
1072058341
3221225472
1071770988
2684354560
1072088346
2684354560
1070711224
2147483648
1070880457
1073741824
1071679922
1610612736
1072530916
2147483648
1068991161
0
1068982748
0
1069137651
0
1070197808
2147483648
1071034997
1073741824
1072491767
0
1072063669
2147483648
1071669941
1610612736
1071425952
0
1071680817
3758096384
1072282005
2684354560
1071682361
3758096384
1072088295
536870912
1071021071
0
1072324201
2147483648
1072635588
0
1070427572
0
1071982849
0
1067871430
0
1070929070
3221225472
1072387045
536870912
1072033877
1073741824
1071564431
3221225472
1071035843
0
1071412029
2147483648
1072347747
2147483648
1071235651
2147483648
1071029980
3221225472
1072298428
3221225472
1070720400
1073741824
1070366753
0
1072463122
1610612736
1071035322
0
1070439559
2147483648
1071022557
2147483648
1072310601
1073741824
1070089151
0
1072211654
2684354560
1069739795
2147483648
1070769975
0
1072181015
1073741824
1071436856
3221225472
1071090647
2147483648
1070843502
2147483648
1069406139
0
1072621849
1610612736
1071955215
0
1072630482
1610612736
1072472133
2684354560
1071133674
1073741824
1069436211
0
1070807539
1073741824
1070584810
2147483648
1072057865
2147483648
1071089825
2147483648
1072598545
2684354560
1072155654
0
1068842061
0
1065626520
0
1072486891
3221225472
1072447619
2684354560
1071506370
0
1071649186
3221225472
1072596079
1610612736
1070456516
2147483648
1069718447
0
1072094211
1073741824
1069803954
2147483648
1069666405
0
1072668540
1610612736
1071931564
2147483648
1070292338
2147483648
1072659616
0
1069962324
2147483648
1070704689
2147483648
1072495071
2147483648
1072305576
3758096384
1071017549
3221225472
1069148266
0
1071011469
1073741824
1072437569
1073741824
1072182277
536870912
1071461100
1073741824
1072693247
2684354560
55
#include "G4RunManager.hh"
#if defined(G4UI_USE_QT)
#include "G4UIQt.hh"
#endif
#include "DetectorConstruction.hh"
#include "PhysicsList.hh"
#include "RunAction.hh"
#include "EventAction.hh"
#include "PrimaryGeneratorAction.hh"
#include "SteppingAction.hh"
#ifdef G4VIS_USE
#include "G4VisExecutive.hh"
#endif
#include <iostream>
using namespace std;
int
main(int argc, char** argv)
{
G4RunManager * runManager = new G4RunManager;
#ifdef G4VIS_USE
// Visualization manager construction
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
#endif
if (argc>1 && argc!=3) {
cout << "either start without arguments for GUI, or specify: mu+/mu- nEvt" << endl;
return 1;
}
const bool batch = (argc==3);
string proj = "mu+";
int nEvt = 10;
if (batch) {
proj = argv[1];
nEvt = atoi(argv[2]);
cout << "BATCH mode" << endl;
cout << "particle: " << proj << " n=" << nEvt<< endl;
}
DetectorConstruction* detector = new DetectorConstructionDet();
runManager->SetUserInitialization(detector);
runManager->SetUserInitialization(new PhysicsList);
runManager->SetUserAction(new PrimaryGeneratorActionDet(proj));
// runManager->SetUserAction(new SteppingActionDet());
runManager->SetUserAction(new RunAction());
runManager->SetUserAction(new EventAction());
runManager->Initialize();
#if defined(G4UI_USE_QT)
if (!batch) {
G4UIQt* ui = new G4UIQt(argc, argv);
ui->SessionStart();
// the line next to the "SessionStart" is necessary to finish the session
delete ui;
} else {
runManager->BeamOn(nEvt);
}
#elif
runManager->BeamOn(nEvt);
#endif
#ifdef G4VIS_USE
delete visManager;
#endif
delete runManager;
return 0;
}
#!/bin/bash
MIN=0.001
MAX=0.01
NBINS=20
NSIM=1000