├── display ├── edepdisp_LinkDef.h ├── TEventManager.hxx ├── README ├── TG4HitChangeHandler.hxx ├── TTrajectoryChangeHandler.hxx ├── TVEventChangeHandler.hxx ├── TMatrixElement.hxx ├── TEventDisplay.hxx ├── CMakeLists.txt ├── TRecurseGeoManager.hxx └── eventDisplay.cxx ├── src ├── NESTVersion098 │ ├── WhatNew.pdf │ ├── ReadmeFirst.pdf │ ├── NEST_Companion.pdf │ ├── NESTSoftwareLicense.pdf │ └── Geant4SoftwareLicense.pdf ├── kinem │ ├── EDepSimVTimeFactory.cc │ ├── EDepSimVPositionFactory.cc │ ├── EDepSimVKinematicsFactory.cc │ ├── EDepSimFreePositionGenerator.cc │ ├── EDepSimFreeTimeGenerator.cc │ ├── EDepSimFixedTimeGenerator.cc │ ├── EDepSimFixedCountGenerator.cc │ ├── EDepSimFreeTimeFactory.cc │ ├── EDepSimFreePositionFactory.hh │ ├── EDepSimMeanCountGenerator.cc │ ├── EDepSimFixedCountGenerator.hh │ ├── EDepSimMeanCountGenerator.hh │ ├── EDepSimFreePositionFactory.cc │ ├── EDepSimNuMIRockKinematicsFactory.cc │ ├── EDepSimGPSKinematicsGenerator.cc │ ├── EDepSimFreeTimeFactory.hh │ ├── EDepSimFixedPositionGenerator.cc │ ├── EDepSimFixedTimeGenerator.hh │ ├── EDepSimGPSKinematicsFactory.cc │ ├── EDepSimFreeTimeGenerator.hh │ ├── EDepSimVTimeFactory.hh │ ├── EDepSimUniformPositionGenerator.hh │ ├── EDepSimUniformPositionGenerator.cc │ ├── EDepSimFreePositionGenerator.hh │ ├── EDepSimVPositionFactory.hh │ ├── EDepSimNuMIRockKinematicsFactory.hh │ ├── EDepSimVKinematicsFactory.hh │ ├── EDepSimDensityPositionGenerator.hh │ ├── EDepSimGPSKinematicsGenerator.hh │ ├── EDepSimFixedTimeFactory.hh │ ├── EDepSimFixedPositionFactory.hh │ ├── EDepSimFixedCountFactory.hh │ ├── EDepSimMeanCountFactory.hh │ ├── EDepSimDensityPositionFactory.hh │ ├── EDepSimUniformPositionFactory.hh │ ├── EDepSimVCountFactory.cc │ ├── EDepSimDensityPositionFactory.cc │ ├── EDepSimUniformPositionFactory.cc │ ├── EDepSimGPSKinematicsFactory.hh │ ├── EDepSimVPrimaryFactory.cc │ ├── EDepSimFixedPositionGenerator.hh │ ├── EDepSimFixedTimeFactory.cc │ ├── EDepSimNuMIRockKinematicsGenerator.hh │ ├── EDepSimFixedPositionFactory.cc │ ├── EDepSimFixedCountFactory.cc │ ├── EDepSimMeanCountFactory.cc │ ├── EDepSimVCountFactory.hh │ ├── EDepSimCombinationGenerator.cc │ ├── EDepSimCombinationGenerator.hh │ ├── EDepSimVCountGenerator.hh │ ├── EDepSimVTimeGenerator.hh │ ├── EDepSimSpillTimeGenerator.cc │ ├── EDepSimVPositionGenerator.hh │ ├── EDepSimVConstrainedPositionFactory.hh │ ├── EDepSimDensityPositionGenerator.cc │ ├── EDepSimSpillTimeGenerator.hh │ ├── EDepSimHEPEVTKinematicsFactory.hh │ ├── EDepSimHEPEVTKinematicsFactory.cc │ ├── EDepSimVPrimaryFactory.hh │ ├── EDepSimHEPEVTKinematicsGenerator.hh │ ├── EDepSimSpillTimeFactory.hh │ └── EDepSimRooTrackerKinematicsFactory.hh ├── EDepSimUserEventInformation.cc ├── EDepSimCreateRunManager.hh ├── EDepSimUserTrackingAction.hh ├── EDepSimUserStackingAction.hh ├── EDepSimUserEventAction.hh ├── EDepSimException.hh ├── EDepSimUserTrackingAction.cc ├── EDepSimSDFactory.cc ├── EDepSimUserEventInformation.hh ├── EDepSimPhysicsListMessenger.hh ├── captain │ ├── mcaptain-outer-vessel-outer-surface.txt │ ├── mcaptain-inner-vessel-inner-surface.txt │ ├── mcaptain-outer-vessel-inner-surface.txt │ ├── mcaptain-inner-vessel-outer-surface.txt │ ├── CaptPMTBuilder.hh │ ├── CaptWorldBuilder.hh │ ├── CaptExposedBuilder.hh │ ├── MiniCaptExposedBuilder.hh │ ├── CaptImmersedBuilder.hh │ ├── MiniCaptImmersedBuilder.hh │ ├── MiniCaptExposedBuilder.cc │ ├── captain-outer-vessel-outer-boundary.txt │ ├── CaptExposedBuilder.cc │ └── captain-outer-vessel-inner-boundary.txt ├── EDepSimSDFactory.hh ├── makeColors.C ├── EDepSimUserRunActionMessenger.hh ├── EDepSimVertexInfo.cc ├── EDepSimCreateRunManager.cc ├── edepsim-defaults-1.0.mac ├── EDepSimUserStackingAction.cc ├── EDepSimDetectorMessenger.hh ├── EDepSimPersistencyMessenger.hh ├── EDepSimTrajectoryMap.hh ├── EDepSimExtraPhysics.hh ├── CMakeLists.txt ├── EDepSimTrajectoryMap.cc ├── EDepSimUserRunAction.hh ├── EDepSimPhysicsList.hh ├── EDepSimInterpolator.hh ├── EDepSimRootPersistencyManager.hh ├── EDepSimArbEMField.hh ├── EDepSimSegmentSD.hh ├── EDepSimArbElecField.hh └── EDepSimArbMagField.hh ├── io ├── TG4HitSegment.cxx ├── TG4Event.cxx ├── TG4PrimaryVertex.cxx ├── TG4Trajectory.cxx ├── edepsim_io_LinkDef.h ├── TG4Event.h └── CMakeLists.txt ├── app └── CMakeLists.txt ├── .gitignore ├── test ├── ggdExample │ ├── __init__.py │ └── DetectorLayer.py ├── README ├── testGGD.sh ├── testEvents.sh └── ggdExample.cfg ├── inputs ├── raytrace.mac ├── muon-100.mac ├── proton-300.mac ├── muon-200.mac ├── electron-600.mac ├── rooTracker-overlay.mac ├── muon-burst-10000.mac ├── genie-example.mac ├── single-particle-gun.mac ├── muon-cone-10000.mac ├── muon-10000.mac ├── double-particle-gun.mac └── triple-particle-gun.mac ├── validate ├── fast-tests │ ├── 050DefaultGeometry.sh │ ├── 060GDMLGeometry.sh │ ├── 101FailHEPEvt.sh │ ├── 100TestGDML.sh │ ├── 100TestHEPEvt.sh │ ├── 110TestHEPEvtFlavors.sh │ └── 100TestTree.sh └── edep-sim-validate.sh ├── scripts ├── edepsim-commands-html.sh ├── edepsim-commands-text.sh └── edepsim-export-geometry.sh ├── CONTRIBUTORS ├── PackageConfig.cmake.in └── LICENSE /display/edepdisp_LinkDef.h: -------------------------------------------------------------------------------- 1 | #ifdef __CINT__ 2 | #pragma link C++ class EDep::TEventChangeManager+; 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /src/NESTVersion098/WhatNew.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClarkMcGrew/edep-sim/HEAD/src/NESTVersion098/WhatNew.pdf -------------------------------------------------------------------------------- /io/TG4HitSegment.cxx: -------------------------------------------------------------------------------- 1 | #include "TG4HitSegment.h" 2 | 3 | ClassImp(TG4HitSegment) 4 | TG4HitSegment::~TG4HitSegment() {} 5 | -------------------------------------------------------------------------------- /src/NESTVersion098/ReadmeFirst.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClarkMcGrew/edep-sim/HEAD/src/NESTVersion098/ReadmeFirst.pdf -------------------------------------------------------------------------------- /src/NESTVersion098/NEST_Companion.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClarkMcGrew/edep-sim/HEAD/src/NESTVersion098/NEST_Companion.pdf -------------------------------------------------------------------------------- /src/NESTVersion098/NESTSoftwareLicense.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClarkMcGrew/edep-sim/HEAD/src/NESTVersion098/NESTSoftwareLicense.pdf -------------------------------------------------------------------------------- /src/NESTVersion098/Geant4SoftwareLicense.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClarkMcGrew/edep-sim/HEAD/src/NESTVersion098/Geant4SoftwareLicense.pdf -------------------------------------------------------------------------------- /app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(edep-sim edepSim.cc) 2 | target_link_libraries(edep-sim LINK_PUBLIC edepsim) 3 | install(TARGETS edep-sim RUNTIME DESTINATION bin) 4 | -------------------------------------------------------------------------------- /io/TG4Event.cxx: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | #include "TG4Event.h" 4 | 5 | ClassImp(TG4Event) 6 | 7 | TG4Event::~TG4Event() {} 8 | 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .svn 2 | CVS 3 | dox 4 | Linux-* 5 | *~ 6 | *.make 7 | *.makesav 8 | *.lock 9 | .gdb* 10 | *.pyc 11 | Makefile 12 | *\#* 13 | *.root 14 | *_C.* 15 | *.pcm 16 | *.png 17 | -------------------------------------------------------------------------------- /test/ggdExample/__init__.py: -------------------------------------------------------------------------------- 1 | ################################################################# 2 | # Example GeGeDe module for use with edep-sim. 3 | ################################################################# 4 | -------------------------------------------------------------------------------- /test/README: -------------------------------------------------------------------------------- 1 | Unsupported test scripts to help develop (and debug) edep-sim 2 | 3 | These have been used to help develop different parts of edep-sim, they 4 | should not be considered as part of the main distribution, but might 5 | provide inspiration. 6 | -------------------------------------------------------------------------------- /test/testGGD.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | OUTPUT=testGGD.gdml 4 | 5 | if ! which gegede-cli >& /dev/null ; then 6 | echo The executable gegede-cli must be in your path. 7 | fi 8 | 9 | PYTHONPATH=$(pwd):${PYTHONPATH} gegede-cli -o ${OUTPUT} ggdExample.cfg 10 | -------------------------------------------------------------------------------- /io/TG4PrimaryVertex.cxx: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | #include "TG4PrimaryVertex.h" 4 | 5 | ClassImp(TG4PrimaryVertex) 6 | TG4PrimaryVertex::~TG4PrimaryVertex() {} 7 | 8 | ClassImp(TG4PrimaryParticle) 9 | TG4PrimaryParticle::~TG4PrimaryParticle() {} 10 | 11 | -------------------------------------------------------------------------------- /src/kinem/EDepSimVTimeFactory.cc: -------------------------------------------------------------------------------- 1 | #include "kinem/EDepSimVTimeFactory.hh" 2 | 3 | EDepSim::VTimeFactory::VTimeFactory( 4 | G4String name, 5 | EDepSim::UserPrimaryGeneratorMessenger* parent, 6 | bool makeDirectory) 7 | : EDepSim::VPrimaryFactory("time",name,parent,makeDirectory) {} 8 | 9 | EDepSim::VTimeFactory::~VTimeFactory() {} 10 | 11 | -------------------------------------------------------------------------------- /io/TG4Trajectory.cxx: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // $Id: TG4Trajectory.cxx,v 1.17 2011/09/12 13:43:38 mcgrew Exp $ 3 | // 4 | #include "TG4Trajectory.h" 5 | 6 | ClassImp(TG4Trajectory) 7 | ClassImp(TG4TrajectoryPoint) 8 | 9 | TG4Trajectory::~TG4Trajectory() {} 10 | TG4TrajectoryPoint::~TG4TrajectoryPoint() {} 11 | 12 | -------------------------------------------------------------------------------- /display/TEventManager.hxx: -------------------------------------------------------------------------------- 1 | #ifndef TEventManager_hxx_seen 2 | #include 3 | #include 4 | 5 | namespace EDep { 6 | /// The tree containing the event. 7 | extern TTree* gEDepSimTree; 8 | 9 | /// The event being displayed. 10 | extern TG4Event *gEDepSimEvent; 11 | 12 | extern int gEDepSimEntryNumber; 13 | } 14 | #endif 15 | -------------------------------------------------------------------------------- /inputs/raytrace.mac: -------------------------------------------------------------------------------- 1 | ############################################################ 2 | # Draw the active components of the detector. 3 | # 4 | 5 | /vis/open RayTracer 300x300 6 | 7 | /vis/rayTracer/target 0 0 0 mm 8 | /vis/rayTracer/eyePosition -5 0 0 m 9 | /vis/rayTracer/headAngle 90 deg 10 | /vis/rayTracer/span 7 deg 11 | /vis/rayTracer/trace raytrace.jpg 12 | 13 | -------------------------------------------------------------------------------- /src/kinem/EDepSimVPositionFactory.cc: -------------------------------------------------------------------------------- 1 | #include "kinem/EDepSimVPositionFactory.hh" 2 | 3 | EDepSim::VPositionFactory::VPositionFactory( 4 | G4String name, 5 | EDepSim::UserPrimaryGeneratorMessenger* parent, 6 | bool makeDirectory) 7 | : EDepSim::VPrimaryFactory("position",name,parent,makeDirectory) {} 8 | 9 | EDepSim::VPositionFactory::~VPositionFactory() {} 10 | 11 | -------------------------------------------------------------------------------- /validate/fast-tests/050DefaultGeometry.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Generate events using a non-trivial GDML geometry. 4 | # 5 | 6 | OUTPUT=050DefaultGeometry.root 7 | 8 | if [ -f ${OUTPUT} ]; then 9 | rm ${OUTPUT} 10 | fi 11 | 12 | cat > 050DefaultGeometry.mac <> ${MACRO} < ${MACRO} < ${MACRO} < 5 | #include "EDepSimUserEventInformation.hh" 6 | 7 | EDepSim::UserEventInformation::UserEventInformation() {} 8 | 9 | 10 | EDepSim::UserEventInformation::~UserEventInformation() {} 11 | 12 | void EDepSim::UserEventInformation::Print() const {} 13 | 14 | void EDepSim::UserEventInformation::InitializeEvent(void) {} 15 | 16 | -------------------------------------------------------------------------------- /src/kinem/EDepSimFixedTimeGenerator.cc: -------------------------------------------------------------------------------- 1 | #include "kinem/EDepSimVTimeGenerator.hh" 2 | #include "kinem/EDepSimFixedTimeGenerator.hh" 3 | 4 | EDepSim::FixedTimeGenerator::FixedTimeGenerator(G4String name, double time) 5 | : EDepSim::VTimeGenerator(name), fTime(time) {} 6 | 7 | EDepSim::FixedTimeGenerator::~FixedTimeGenerator() {} 8 | 9 | double EDepSim::FixedTimeGenerator::GetTime(const G4LorentzVector& /* vtx */) { 10 | return fTime; 11 | } 12 | 13 | bool EDepSim::FixedTimeGenerator::ForceTime() { 14 | return true; 15 | } 16 | -------------------------------------------------------------------------------- /src/kinem/EDepSimFixedCountGenerator.cc: -------------------------------------------------------------------------------- 1 | #include "kinem/EDepSimVCountGenerator.hh" 2 | #include "kinem/EDepSimFixedCountGenerator.hh" 3 | 4 | EDepSim::FixedCountGenerator::FixedCountGenerator(G4String name, 5 | int count, 6 | double intensity) 7 | : EDepSim::VCountGenerator(name,intensity), fCount(count) {} 8 | 9 | EDepSim::FixedCountGenerator::~FixedCountGenerator() {} 10 | 11 | int EDepSim::FixedCountGenerator::GetCount() {return fCount;} 12 | -------------------------------------------------------------------------------- /scripts/edepsim-commands-text.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ## A deprecated script to build the text documentation. Use the 3 | ## "build/make-doc.sh" script instead. 4 | 5 | MACRO=`mktemp -t edepsim.XXXXXXXXXX` || exit 1 6 | cat >> $MACRO < edepsim-command.temp 11 | 12 | LINE=`grep -n "^Command directory path : /$" edepsim-command.temp | grep -o '[0-9]*'` 13 | 14 | tail -n +${LINE} edepsim-command.temp > edepsim-command.list 15 | 16 | rm edepsim-command.temp 17 | rm $MACRO 18 | 19 | mv edepsim-command.list ../doc 20 | -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | CONTRIBUTOR ACKNOWLEDGEMENTS 2 | 3 | This is an alphabetical list of people making contributions to 4 | edep-sim. It is hopefully complete, and if there are mistakes, please 5 | let me (clark.mcgrew@stonybrook.edu) know. 6 | 7 | C. Backhouse -- Compilation improvements 8 | A. Cudd -- Arbitrary EM fields 9 | M. Kordosky -- New geometry shapes 10 | C. McGrew 11 | A. Mogan -- starting point for HEPEVT reader 12 | B. Viren -- Better ROOT integration 13 | 14 | The ideas here were developed within the T2K (ND280) and CAPTAIN 15 | collaborations. 16 | -------------------------------------------------------------------------------- /src/kinem/EDepSimFreeTimeFactory.cc: -------------------------------------------------------------------------------- 1 | #include "kinem/EDepSimVTimeFactory.hh" 2 | #include "kinem/EDepSimFreeTimeFactory.hh" 3 | #include "kinem/EDepSimFreeTimeGenerator.hh" 4 | 5 | EDepSim::FreeTimeFactory::FreeTimeFactory( 6 | EDepSim::UserPrimaryGeneratorMessenger* parent) 7 | : EDepSim::VTimeFactory("free",parent) { } 8 | 9 | EDepSim::FreeTimeFactory::~FreeTimeFactory() { } 10 | 11 | EDepSim::VTimeGenerator* EDepSim::FreeTimeFactory::GetGenerator() { 12 | EDepSim::VTimeGenerator* time = new EDepSim::FreeTimeGenerator(GetName()); 13 | return time; 14 | } 15 | -------------------------------------------------------------------------------- /src/kinem/EDepSimFreePositionFactory.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_FreePositionFactory_hh_seen 2 | #define EDepSim_FreePositionFactory_hh_seen 3 | 4 | #include "kinem/EDepSimVPositionFactory.hh" 5 | 6 | namespace EDepSim {class FreePositionFactory;} 7 | class EDepSim::FreePositionFactory : public EDepSim::VPositionFactory { 8 | public: 9 | FreePositionFactory(EDepSim::UserPrimaryGeneratorMessenger* parent); 10 | virtual ~FreePositionFactory(); 11 | 12 | /// Return the fixed vertex generator. 13 | EDepSim::VPositionGenerator* GetGenerator(); 14 | 15 | }; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/kinem/EDepSimMeanCountGenerator.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "kinem/EDepSimVCountGenerator.hh" 4 | #include "kinem/EDepSimMeanCountGenerator.hh" 5 | 6 | EDepSim::MeanCountGenerator::MeanCountGenerator(G4String name, 7 | double mean, 8 | double intensity) 9 | : EDepSim::VCountGenerator(name, intensity), fMean(mean) {} 10 | 11 | EDepSim::MeanCountGenerator::~MeanCountGenerator() {} 12 | 13 | int EDepSim::MeanCountGenerator::GetCount() { 14 | return G4Poisson(fMean); 15 | } 16 | -------------------------------------------------------------------------------- /src/EDepSimCreateRunManager.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_CreateRunManager_hh_seen 2 | ///////////////////////////////////////////////////////////////////// 3 | // $Id: EDepSimCreateRunManager.hh,v 1.2 2009/04/09 00:39:00 gum Exp $ 4 | 5 | #include 6 | #include 7 | 8 | /// Create the standard run manager for the detSim detector simulation. The 9 | /// caller is responsible for deleting the run manager. If a valid physics 10 | /// list name is defined, then that will be used for this run. 11 | namespace EDepSim { 12 | G4RunManager* CreateRunManager(G4String physicsList); 13 | } 14 | #endif 15 | -------------------------------------------------------------------------------- /src/EDepSimUserTrackingAction.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // $Id: EDepSim::UserTrackingAction.hh,v 1.3 2004/03/18 20:49:27 t2k Exp $ 3 | // 4 | #ifndef EDepSim_UserTrackingAction_h 5 | #define EDepSim_UserTrackingAction_h 1 6 | 7 | #include "G4UserTrackingAction.hh" 8 | class G4Track; 9 | 10 | namespace EDepSim {class UserTrackingAction;} 11 | class EDepSim::UserTrackingAction : public G4UserTrackingAction 12 | { 13 | public: 14 | UserTrackingAction(); 15 | virtual ~UserTrackingAction(); 16 | 17 | virtual void PreUserTrackingAction(const G4Track*); 18 | }; 19 | #endif 20 | -------------------------------------------------------------------------------- /src/kinem/EDepSimFixedCountGenerator.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_FixedCountGenerator_hh_seen 2 | #define EDepSim_FixedCountGenerator_hh_seen 3 | 4 | #include "kinem/EDepSimVCountGenerator.hh" 5 | 6 | namespace EDepSim {class FixedCountGenerator;} 7 | class EDepSim::FixedCountGenerator : public EDepSim::VCountGenerator { 8 | public: 9 | FixedCountGenerator(G4String name, int count, double intensity); 10 | virtual ~FixedCountGenerator(); 11 | 12 | /// Return the number of events to generate. 13 | int GetCount(); 14 | 15 | private: 16 | /// The number of events to generate. 17 | int fCount; 18 | }; 19 | #endif 20 | -------------------------------------------------------------------------------- /src/kinem/EDepSimMeanCountGenerator.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_MeanCountGenerator_hh_seen 2 | #define EDepSim_MeanCountGenerator_hh_seen 3 | 4 | #include "kinem/EDepSimVCountGenerator.hh" 5 | 6 | namespace EDepSim {class MeanCountGenerator;} 7 | class EDepSim::MeanCountGenerator : public EDepSim::VCountGenerator { 8 | public: 9 | MeanCountGenerator(G4String name, double mean, double intensity); 10 | virtual ~MeanCountGenerator(); 11 | 12 | /// Return the number of events to generate. 13 | int GetCount(); 14 | 15 | private: 16 | /// The number of events to generate. 17 | double fMean; 18 | }; 19 | #endif 20 | -------------------------------------------------------------------------------- /src/kinem/EDepSimFreePositionFactory.cc: -------------------------------------------------------------------------------- 1 | #include "kinem/EDepSimVPositionFactory.hh" 2 | #include "kinem/EDepSimFreePositionFactory.hh" 3 | #include "kinem/EDepSimFreePositionGenerator.hh" 4 | 5 | EDepSim::FreePositionFactory::FreePositionFactory( 6 | EDepSim::UserPrimaryGeneratorMessenger* parent) 7 | : EDepSim::VPositionFactory("free",parent,false) { 8 | } 9 | 10 | EDepSim::FreePositionFactory::~FreePositionFactory() { 11 | } 12 | 13 | EDepSim::VPositionGenerator* EDepSim::FreePositionFactory::GetGenerator() { 14 | EDepSim::VPositionGenerator* vertex = new EDepSim::FreePositionGenerator(GetName()); 15 | return vertex; 16 | } 17 | -------------------------------------------------------------------------------- /src/EDepSimUserStackingAction.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_UserStackingAction_hh_seen 2 | #define EDepSim_UserStackingAction_hh_seen 3 | 4 | #include "G4Track.hh" 5 | #include "G4UserStackingAction.hh" 6 | #include "G4ClassificationOfNewTrack.hh" 7 | 8 | /// Control which particles are actually tracked by G4. 9 | namespace EDepSim {class UserStackingAction;} 10 | class EDepSim::UserStackingAction : public G4UserStackingAction { 11 | public: 12 | UserStackingAction(); 13 | virtual ~UserStackingAction(); 14 | 15 | /// Check if a new track should be tracked. 16 | virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track*); 17 | }; 18 | #endif 19 | -------------------------------------------------------------------------------- /src/kinem/EDepSimNuMIRockKinematicsFactory.cc: -------------------------------------------------------------------------------- 1 | #include "kinem/EDepSimNuMIRockKinematicsFactory.hh" 2 | #include "kinem/EDepSimNuMIRockKinematicsGenerator.hh" 3 | 4 | EDepSim::NuMIRockKinematicsFactory::NuMIRockKinematicsFactory( 5 | EDepSim::UserPrimaryGeneratorMessenger* parent) 6 | : EDepSim::VKinematicsFactory("rock",parent,false) {} 7 | 8 | EDepSim::NuMIRockKinematicsFactory::~NuMIRockKinematicsFactory() {} 9 | 10 | EDepSim::VKinematicsGenerator* EDepSim::NuMIRockKinematicsFactory::GetGenerator() { 11 | EDepSim::VKinematicsGenerator* kine 12 | = new EDepSim::NuMIRockKinematicsGenerator(GetName(), "medium"); 13 | return kine; 14 | } 15 | -------------------------------------------------------------------------------- /src/EDepSimUserEventAction.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // $Id: EDepSim::UserEventAction.hh,v 1.4 2006/03/04 22:53:23 jnurep Exp $ 3 | // 4 | #ifndef EDepSim_UserEventAction_h 5 | #define EDepSim_UserEventAction_h 1 6 | 7 | #include 8 | 9 | class G4Event; 10 | 11 | namespace EDepSim {class UserEventAction;} 12 | class EDepSim::UserEventAction : public G4UserEventAction { 13 | public: 14 | UserEventAction(); 15 | virtual ~UserEventAction(); 16 | 17 | void BeginOfEventAction(const G4Event*); 18 | void EndOfEventAction(const G4Event*); 19 | 20 | }; 21 | 22 | #endif 23 | 24 | 25 | -------------------------------------------------------------------------------- /display/README: -------------------------------------------------------------------------------- 1 | # Debugging Display for edep-sim 2 | 3 | This is a simple debugging display to help visually validate the output of 4 | edep-sim. It's not a full (real) event display! It's included because it 5 | can be very helpful for getting a handle on what is going on in an event, 6 | but is not a substitute for a real display. 7 | 8 | This expects a root file produced by the EDepSim::RootPersistencyManager. 9 | It must contain a TGeoManager object named EDepSimGeometry, and a tree 10 | named EDepSimEvents. 11 | 12 | ## Running 13 | 14 | This can be run using "edep-disp ". Or as "edep-disp -h" to 15 | get a list of the command line parameters. 16 | 17 | -------------------------------------------------------------------------------- /src/EDepSimException.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_Exception_hh_seen 2 | #define EDepSim_Exception_hh_seen 3 | #include 4 | #include 5 | 6 | /// The standard exception from detsim. This is usually thrown by the 7 | /// EDepSimThrow macro. 8 | namespace EDepSim {class Exception;} 9 | class EDepSim::Exception : public std::exception { 10 | public: 11 | Exception() {} 12 | virtual ~Exception() throw() {} 13 | const char* what(void) const throw() {return "EDepSim::Exception";} 14 | }; 15 | 16 | /// Print an error message, and then throw an exception. 17 | #define EDepSimThrow(message) {EDepSimError(message);throw EDepSim::Exception();} 18 | #endif 19 | -------------------------------------------------------------------------------- /src/kinem/EDepSimGPSKinematicsGenerator.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "kinem/EDepSimGPSKinematicsGenerator.hh" 5 | 6 | EDepSim::GPSKinematicsGenerator::GPSKinematicsGenerator( 7 | const G4String& name, G4VPrimaryGenerator* gen) 8 | : EDepSim::VKinematicsGenerator(name), fGenerator(gen) {} 9 | 10 | EDepSim::GPSKinematicsGenerator::~GPSKinematicsGenerator() {} 11 | 12 | EDepSim::VKinematicsGenerator::GeneratorStatus 13 | EDepSim::GPSKinematicsGenerator::GeneratePrimaryVertex( 14 | G4Event* evt, const G4LorentzVector& /* position */) { 15 | fGenerator->GeneratePrimaryVertex(evt); 16 | return kSuccess; 17 | } 18 | -------------------------------------------------------------------------------- /display/TG4HitChangeHandler.hxx: -------------------------------------------------------------------------------- 1 | #ifndef TG4HitChangeHandler_hxx_seen 2 | #define TG4HitChangeHandler_hxx_seen 3 | 4 | #include "TVEventChangeHandler.hxx" 5 | 6 | namespace EDep { 7 | class TG4HitChangeHandler; 8 | } 9 | 10 | class TEveElementList; 11 | 12 | /// Handle drawing the GEANT4 (truth) hits. 13 | class EDep::TG4HitChangeHandler: public TVEventChangeHandler { 14 | public: 15 | TG4HitChangeHandler(); 16 | ~TG4HitChangeHandler(); 17 | 18 | /// Draw the trajectories into the current scene. 19 | virtual void Apply(); 20 | 21 | private: 22 | 23 | /// The GEANT4 hits to draw in the event. 24 | TEveElementList* fG4HitList; 25 | 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/kinem/EDepSimFreeTimeFactory.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_FreeTimeFactory_hh_seen 2 | #define EDepSim_FreeTimeFactory_hh_seen 3 | 4 | #include "kinem/EDepSimVTimeFactory.hh" 5 | 6 | namespace EDepSim {class FreeTimeFactory;} 7 | 8 | /// Create a generator that leaves the time of the vertex free. The vertex 9 | /// time will either be zero, or will be set by the Kinematics generator. 10 | class EDepSim::FreeTimeFactory : public EDepSim::VTimeFactory { 11 | public: 12 | FreeTimeFactory(EDepSim::UserPrimaryGeneratorMessenger* parent); 13 | virtual ~FreeTimeFactory(); 14 | 15 | /// Return the time generator. 16 | EDepSim::VTimeGenerator* GetGenerator(); 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/kinem/EDepSimFixedPositionGenerator.cc: -------------------------------------------------------------------------------- 1 | #include "kinem/EDepSimFixedPositionGenerator.hh" 2 | 3 | EDepSim::FixedPositionGenerator::FixedPositionGenerator( 4 | const G4String& name, const G4ThreeVector& pos) 5 | : EDepSim::VPositionGenerator(name), fPosition(pos) {} 6 | 7 | EDepSim::FixedPositionGenerator::~FixedPositionGenerator() {} 8 | 9 | G4LorentzVector EDepSim::FixedPositionGenerator::GetPosition() { 10 | return fPosition; 11 | } 12 | 13 | bool EDepSim::FixedPositionGenerator::ForcePosition() { 14 | return true; 15 | } 16 | 17 | void EDepSim::FixedPositionGenerator::SetPosition(const G4ThreeVector& pos) { 18 | fPosition.set(pos.x(),pos.y(),pos.z(),0); 19 | } 20 | -------------------------------------------------------------------------------- /display/TTrajectoryChangeHandler.hxx: -------------------------------------------------------------------------------- 1 | #ifndef TTrajectoryChangeHandler_hxx_seen 2 | #define TTrajectoryChangeHandler_hxx_seen 3 | 4 | #include "TVEventChangeHandler.hxx" 5 | 6 | namespace EDep { 7 | class TTrajectoryChangeHandler; 8 | } 9 | 10 | class TEveElementList; 11 | 12 | /// Handle drawing the trajectories. 13 | class EDep::TTrajectoryChangeHandler: public TVEventChangeHandler { 14 | public: 15 | TTrajectoryChangeHandler(); 16 | ~TTrajectoryChangeHandler(); 17 | 18 | /// Draw the trajectories into the current scene. 19 | virtual void Apply(); 20 | 21 | private: 22 | 23 | /// The trajectories to draw in the event. 24 | TEveElementList* fTrajectoryList; 25 | 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/kinem/EDepSimFixedTimeGenerator.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_FixedTimeGenerator_hh_seen 2 | #define EDepSim_FixedTimeGenerator_hh_seen 3 | 4 | #include "kinem/EDepSimVTimeGenerator.hh" 5 | 6 | namespace EDepSim {class FixedTimeGenerator;} 7 | class EDepSim::FixedTimeGenerator : public EDepSim::VTimeGenerator { 8 | public: 9 | FixedTimeGenerator(G4String name, double time); 10 | virtual ~FixedTimeGenerator(); 11 | 12 | /// Return the number of events to generate. 13 | double GetTime(const G4LorentzVector& vertex); 14 | 15 | /// Flag if the time should be forced. 16 | virtual bool ForceTime(); 17 | 18 | private: 19 | /// The number of events to generate. 20 | double fTime; 21 | }; 22 | #endif 23 | -------------------------------------------------------------------------------- /io/edepsim_io_LinkDef.h: -------------------------------------------------------------------------------- 1 | #ifdef __CINT__ 2 | #include "TG4Event.h" 3 | 4 | #pragma link C++ class TG4PrimaryParticle+; 5 | #pragma link C++ class std::vector+; 6 | 7 | #pragma link C++ class TG4PrimaryVertex+; 8 | #pragma link C++ class std::vector+; 9 | 10 | #pragma link C++ class TG4TrajectoryPoint+; 11 | #pragma link C++ class std::vector+; 12 | 13 | #pragma link C++ class TG4Trajectory+; 14 | #pragma link C++ class std::vector+; 15 | 16 | #pragma link C++ class TG4HitSegment+; 17 | #pragma link C++ class std::vector+; 18 | #pragma link C++ class std::map >+; 19 | 20 | #pragma link C++ class TG4Event+; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/kinem/EDepSimGPSKinematicsFactory.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "kinem/EDepSimGPSKinematicsFactory.hh" 4 | #include "kinem/EDepSimGPSKinematicsGenerator.hh" 5 | 6 | EDepSim::GPSKinematicsFactory::GPSKinematicsFactory( 7 | EDepSim::UserPrimaryGeneratorMessenger* parent) 8 | : EDepSim::VKinematicsFactory("gps",parent,false) { 9 | fGenerator = new G4GeneralParticleSource(); 10 | } 11 | 12 | EDepSim::GPSKinematicsFactory::~GPSKinematicsFactory() { 13 | delete fGenerator; 14 | } 15 | 16 | EDepSim::VKinematicsGenerator* EDepSim::GPSKinematicsFactory::GetGenerator() { 17 | EDepSim::VKinematicsGenerator* kine 18 | = new EDepSim::GPSKinematicsGenerator(GetName(), fGenerator); 19 | return kine; 20 | } 21 | -------------------------------------------------------------------------------- /src/kinem/EDepSimFreeTimeGenerator.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_FreeTimeGenerator_hh_seen 2 | #define EDepSim_FreeTimeGenerator_hh_seen 3 | 4 | #include "kinem/EDepSimVTimeGenerator.hh" 5 | 6 | namespace EDepSim {class FreeTimeGenerator;} 7 | 8 | /// Generate a "Free" time. This means that the default time of the vertex 9 | /// will be zero, but it is expected to be overridden by the kinematics 10 | /// generator. 11 | class EDepSim::FreeTimeGenerator : public EDepSim::VTimeGenerator { 12 | public: 13 | FreeTimeGenerator(G4String name); 14 | virtual ~FreeTimeGenerator(); 15 | 16 | /// Return the time of events to generate. 17 | double GetTime(const G4LorentzVector& vertex); 18 | 19 | /// Flag if the time should be forced (returns false). 20 | virtual bool ForceTime(); 21 | 22 | }; 23 | #endif 24 | -------------------------------------------------------------------------------- /src/kinem/EDepSimVTimeFactory.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_VTimeFactory_hh_seen 2 | #define EDepSim_VTimeFactory_hh_seen 3 | 4 | #include "kinem/EDepSimVPrimaryFactory.hh" 5 | 6 | namespace EDepSim {class VTimeGenerator;} 7 | 8 | namespace EDepSim {class VTimeFactory;} 9 | class EDepSim::VTimeFactory : public EDepSim::VPrimaryFactory { 10 | public: 11 | VTimeFactory(G4String name, 12 | EDepSim::UserPrimaryGeneratorMessenger* fParent, 13 | bool makeDirectory=true); 14 | virtual ~VTimeFactory(); 15 | 16 | /// Return a new generator enclosing the current factory state. The new 17 | /// generator method is pure virtual so it must be implemented by derived 18 | /// classes. 19 | virtual EDepSim::VTimeGenerator* GetGenerator() = 0; 20 | }; 21 | #endif 22 | -------------------------------------------------------------------------------- /src/kinem/EDepSimUniformPositionGenerator.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_UniformPositionGenerator_hh_seen 2 | #define EDepSim_UniformPositionGenerator_hh_seen 3 | 4 | #include "kinem/EDepSimVConstrainedPositionGenerator.hh" 5 | 6 | /// Select a position and time to be used as the vertex of a primary particle. 7 | namespace EDepSim {class UniformPositionGenerator;} 8 | class EDepSim::UniformPositionGenerator : public EDepSim::VConstrainedPositionGenerator { 9 | public: 10 | UniformPositionGenerator(const G4String& name); 11 | virtual ~UniformPositionGenerator(); 12 | 13 | /// Return a candidate vertex. 14 | virtual G4LorentzVector GetPosition(); 15 | 16 | /// Flag if the vertex should be forced to the candidate vertex returned 17 | /// by GetPosition(). 18 | virtual bool ForcePosition(); 19 | }; 20 | #endif 21 | -------------------------------------------------------------------------------- /src/kinem/EDepSimUniformPositionGenerator.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "kinem/EDepSimUniformPositionGenerator.hh" 4 | 5 | EDepSim::UniformPositionGenerator::UniformPositionGenerator(const G4String& name) 6 | : EDepSim::VConstrainedPositionGenerator(name) {} 7 | 8 | EDepSim::UniformPositionGenerator::~UniformPositionGenerator() {} 9 | 10 | G4LorentzVector EDepSim::UniformPositionGenerator::GetPosition() { 11 | for (int finiteLoop = 0; finiteLoop<100000; ++finiteLoop) { 12 | G4LorentzVector vtx = TrialPosition(); 13 | if (ValidPosition(vtx)) return vtx; 14 | } 15 | EDepSimError("EDepSim::UniformPositionGenerator::GetPosition:" 16 | << " No valid position found"); 17 | throw; 18 | } 19 | 20 | bool EDepSim::UniformPositionGenerator::ForcePosition() { 21 | return true; 22 | } 23 | -------------------------------------------------------------------------------- /src/kinem/EDepSimFreePositionGenerator.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_FreePositionGenerator_hh_seen 2 | #define EDepSim_FreePositionGenerator_hh_seen 3 | 4 | #include "kinem/EDepSimVPositionGenerator.hh" 5 | 6 | /// Select a position and time to be used as the vertex of a primary particle. 7 | namespace EDepSim {class FreePositionGenerator;} 8 | class EDepSim::FreePositionGenerator : public EDepSim::VPositionGenerator { 9 | public: 10 | FreePositionGenerator(const G4String& name); 11 | virtual ~FreePositionGenerator(); 12 | 13 | /// Return a candidate vertex (a dummy routine for 14 | /// EDepSim::FreePositionGenerator). 15 | virtual G4LorentzVector GetPosition(); 16 | 17 | /// Flag if the vertex should be forced to the candidate vertex returned 18 | /// by GetPosition(). 19 | virtual bool ForcePosition(); 20 | }; 21 | #endif 22 | -------------------------------------------------------------------------------- /src/kinem/EDepSimVPositionFactory.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_VPositionFactory_hh_seen 2 | #define EDepSim_VPositionFactory_hh_seen 3 | 4 | #include "kinem/EDepSimVPrimaryFactory.hh" 5 | 6 | namespace EDepSim {class VPositionGenerator;} 7 | 8 | namespace EDepSim {class VPositionFactory;} 9 | class EDepSim::VPositionFactory : public EDepSim::VPrimaryFactory { 10 | public: 11 | VPositionFactory(G4String name, 12 | EDepSim::UserPrimaryGeneratorMessenger* fParent, 13 | bool makeDirectory = true); 14 | virtual ~VPositionFactory(); 15 | 16 | /// Return a new generator enclosing the current factory state. The new 17 | /// generator method is pure virtual so it must be implemented by derived 18 | /// classes. 19 | virtual EDepSim::VPositionGenerator* GetGenerator() = 0; 20 | }; 21 | #endif 22 | -------------------------------------------------------------------------------- /display/TVEventChangeHandler.hxx: -------------------------------------------------------------------------------- 1 | #ifndef TVEventChangeHandler_hxx_seen 2 | #define TVEventChangeHandler_hxx_seen 3 | 4 | #include 5 | 6 | namespace EDep { 7 | class TVEventChangeHandler; 8 | } 9 | 10 | /// A base class for handlers called by TEventChangeManager. The 11 | /// TEventChangeManager keeps a vector of possible handlers that are used 12 | /// everytime the event has changed (or needs to be reset). The handlers need 13 | /// to implement the XXX class, and should check to see if they are enabled 14 | /// using the GUI class. 15 | class EDep::TVEventChangeHandler: public TObject { 16 | public: 17 | TVEventChangeHandler() {} 18 | virtual ~TVEventChangeHandler() {} 19 | 20 | /// Apply the change handler to the current event. This does all of the 21 | /// work. 22 | virtual void Apply() = 0; 23 | }; 24 | #endif 25 | -------------------------------------------------------------------------------- /src/kinem/EDepSimNuMIRockKinematicsFactory.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_NuMIRockKinematicsFactory_hh_seen 2 | #define EDepSim_NuMIRockKinematicsFactory_hh_seen 3 | 4 | #include "kinem/EDepSimVKinematicsFactory.hh" 5 | 6 | class G4VPrimaryGenerator; 7 | namespace EDepSim {class NuMIRockKinematicsGenerator;} 8 | 9 | namespace EDepSim {class NuMIRockKinematicsFactory;} 10 | class EDepSim::NuMIRockKinematicsFactory : public EDepSim::VKinematicsFactory { 11 | public: 12 | NuMIRockKinematicsFactory(EDepSim::UserPrimaryGeneratorMessenger* fParent); 13 | virtual ~NuMIRockKinematicsFactory(); 14 | 15 | /// Return a new generator enclosing the current factory state. The new 16 | /// generator method is pure virtual so it must be implemented by derived 17 | /// classes. 18 | virtual EDepSim::VKinematicsGenerator* GetGenerator(); 19 | 20 | }; 21 | #endif 22 | -------------------------------------------------------------------------------- /src/kinem/EDepSimVKinematicsFactory.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_VKinematicsFactory_hh_seen 2 | #define EDepSim_VKinematicsFactory_hh_seen 3 | 4 | #include "kinem/EDepSimVPrimaryFactory.hh" 5 | 6 | namespace EDepSim {class VKinematicsGenerator;} 7 | 8 | namespace EDepSim {class VKinematicsFactory;} 9 | class EDepSim::VKinematicsFactory : public EDepSim::VPrimaryFactory { 10 | public: 11 | VKinematicsFactory(G4String name, 12 | EDepSim::UserPrimaryGeneratorMessenger* fParent, 13 | bool makeDirectory=true); 14 | virtual ~VKinematicsFactory(); 15 | 16 | /// Return a new generator enclosing the current factory state. The new 17 | /// generator method is pure virtual so it must be implemented by derived 18 | /// classes. 19 | virtual EDepSim::VKinematicsGenerator* GetGenerator() = 0; 20 | }; 21 | #endif 22 | -------------------------------------------------------------------------------- /src/EDepSimUserTrackingAction.cc: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // $Id: EDepSim::UserTrackingAction.cc,v 1.6 2007/01/01 05:32:49 mcgrew Exp $ 3 | // 4 | #include "EDepSimUserTrackingAction.hh" 5 | #include "EDepSimTrajectory.hh" 6 | #include "EDepSimTrajectoryMap.hh" 7 | #include "EDepSimLog.hh" 8 | 9 | #include "globals.hh" 10 | #include "G4Track.hh" 11 | #include "G4TrackingManager.hh" 12 | 13 | EDepSim::UserTrackingAction::UserTrackingAction() {} 14 | 15 | EDepSim::UserTrackingAction::~UserTrackingAction() {} 16 | 17 | void EDepSim::UserTrackingAction::PreUserTrackingAction(const G4Track* trk) { 18 | EDepSimTrace("Pre-tracking action"); 19 | G4VTrajectory* traj = new EDepSim::Trajectory(trk); 20 | fpTrackingManager->SetTrajectory(traj); 21 | fpTrackingManager->SetStoreTrajectory(true); 22 | EDepSim::TrajectoryMap::Add(traj); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /src/kinem/EDepSimDensityPositionGenerator.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_DensityPositionGenerator_hh_seen 2 | #define EDepSim_DensityPositionGenerator_hh_seen 3 | 4 | #include "kinem/EDepSimVConstrainedPositionGenerator.hh" 5 | 6 | /// Select a position and time to be used as the vertex of a primary particle. 7 | namespace EDepSim {class DensityPositionGenerator;} 8 | class EDepSim::DensityPositionGenerator : public EDepSim::VConstrainedPositionGenerator { 9 | public: 10 | DensityPositionGenerator(const G4String& name); 11 | virtual ~DensityPositionGenerator(); 12 | 13 | /// Return a candidate vertex. 14 | virtual G4LorentzVector GetPosition(); 15 | 16 | /// Flag if the vertex should be forced to the candidate vertex returned 17 | /// by GetPosition(). 18 | virtual bool ForcePosition(); 19 | 20 | private: 21 | /// The maximum density in the detector. 22 | double fMaximumDensity; 23 | }; 24 | #endif 25 | -------------------------------------------------------------------------------- /src/EDepSimSDFactory.cc: -------------------------------------------------------------------------------- 1 | #include "EDepSimSDFactory.hh" 2 | #include "EDepSimSegmentSD.hh" 3 | #include "EDepSimException.hh" 4 | 5 | #include 6 | 7 | EDepSim::SDFactory::SDFactory(G4String type) 8 | : fType(type) {} 9 | 10 | 11 | EDepSim::SDFactory::~SDFactory() {} 12 | 13 | G4VSensitiveDetector* EDepSim::SDFactory::GetSD(G4String name) { 14 | return G4SDManager::GetSDMpointer()->FindSensitiveDetector(name); 15 | } 16 | 17 | G4VSensitiveDetector* EDepSim::SDFactory::MakeSD(G4String name) { 18 | G4VSensitiveDetector* sd = GetSD(name); 19 | if (!sd) { 20 | if (fType == "segment") { 21 | sd = new EDepSim::SegmentSD(name); 22 | } 23 | else { 24 | EDepSimError("No such sensitive detector " << name); 25 | EDepSimThrow("sensitive detector type not implemented"); 26 | } 27 | G4SDManager::GetSDMpointer()->AddNewDetector(sd); 28 | } 29 | return sd; 30 | } 31 | -------------------------------------------------------------------------------- /src/kinem/EDepSimGPSKinematicsGenerator.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_GPSKinematicsGenerator_hh_Seen 2 | #define EDepSim_GPSKinematicsGenerator_hh_Seen 3 | 4 | #include 5 | #include 6 | 7 | #include "kinem/EDepSimVKinematicsGenerator.hh" 8 | 9 | class G4Event; 10 | class G4VPrimaryGenerator; 11 | 12 | /// This is an interface to use the General Particle Source (GPS). 13 | namespace EDepSim {class GPSKinematicsGenerator;} 14 | class EDepSim::GPSKinematicsGenerator : public EDepSim::VKinematicsGenerator { 15 | public: 16 | GPSKinematicsGenerator(const G4String& name, 17 | G4VPrimaryGenerator* gps); 18 | virtual ~GPSKinematicsGenerator(); 19 | 20 | /// Add a primary vertex to the event. 21 | virtual GeneratorStatus 22 | GeneratePrimaryVertex(G4Event* evt, 23 | const G4LorentzVector& position); 24 | 25 | private: 26 | G4VPrimaryGenerator* fGenerator; 27 | }; 28 | #endif 29 | -------------------------------------------------------------------------------- /src/kinem/EDepSimFixedTimeFactory.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_FixedTimeFactory_hh_seen 2 | #define EDepSim_FixedTimeFactory_hh_seen 3 | 4 | #include "kinem/EDepSimVTimeFactory.hh" 5 | 6 | namespace EDepSim {class FixedTimeFactory;} 7 | class EDepSim::FixedTimeFactory : public EDepSim::VTimeFactory { 8 | public: 9 | FixedTimeFactory(EDepSim::UserPrimaryGeneratorMessenger* parent); 10 | virtual ~FixedTimeFactory(); 11 | 12 | /// Return the fixed time generator. 13 | EDepSim::VTimeGenerator* GetGenerator(); 14 | 15 | /// Set the time to be generated. 16 | void SetTime(double time) {fTime = time;} 17 | 18 | /// Get the time to be generated. 19 | double GetTime() const {return fTime;} 20 | 21 | /// Handle messages from the UI processor. 22 | void SetNewValue(G4UIcommand*, G4String); 23 | 24 | private: 25 | /// The time of particles to generate. 26 | double fTime; 27 | 28 | G4UIcmdWithADoubleAndUnit* fTimeCMD; 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/EDepSimUserEventInformation.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////// 2 | // $Id: EDepSim::UserEventInformation.hh,v 1.5 2008/01/14 17:01:57 mcgrew Exp $ 3 | 4 | #ifndef EDepSim_UserEventInformation_hh_seen 5 | #define EDepSim_UserEventInformation_hh_seen 6 | 7 | #include 8 | #include 9 | 10 | namespace EDepSim {class UserEventInformation;} 11 | class EDepSim::UserEventInformation : public G4VUserEventInformation { 12 | public: 13 | UserEventInformation(); 14 | virtual ~UserEventInformation(); 15 | 16 | /// Print information about the event. 17 | virtual void Print() const; 18 | 19 | /// Reset for a new event. This is needed since some event generators 20 | /// start creating an event, and then later decide to reject it. This 21 | /// allows the user information to be reset to the default values. 22 | void InitializeEvent(void); 23 | 24 | private: 25 | }; 26 | #endif 27 | -------------------------------------------------------------------------------- /src/kinem/EDepSimFixedPositionFactory.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_FixedPositionFactory_hh_seen 2 | #define EDepSim_FixedPositionFactory_hh_seen 3 | 4 | #include "kinem/EDepSimVPositionFactory.hh" 5 | 6 | namespace EDepSim {class FixedPositionFactory;} 7 | class EDepSim::FixedPositionFactory : public EDepSim::VPositionFactory { 8 | public: 9 | FixedPositionFactory(EDepSim::UserPrimaryGeneratorMessenger* parent); 10 | virtual ~FixedPositionFactory(); 11 | 12 | /// Return the fixed vertex generator. 13 | EDepSim::VPositionGenerator* GetGenerator(); 14 | 15 | /// Return the position for the next generator. 16 | G4ThreeVector GetPosition() {return fPosition;} 17 | 18 | /// Set the position for the next generator. 19 | void SetPosition(const G4ThreeVector& pos) {fPosition = pos;} 20 | 21 | void SetNewValue(G4UIcommand*, G4String); 22 | 23 | private: 24 | G4ThreeVector fPosition; 25 | 26 | G4UIcmdWith3VectorAndUnit* fPositionCMD; 27 | }; 28 | #endif 29 | -------------------------------------------------------------------------------- /inputs/muon-100.mac: -------------------------------------------------------------------------------- 1 | #################################################################### 2 | # 3 | # Generate a 100 MeV muon with an isotropic distribution. 4 | # 5 | # To generate 10 events, this can be run using edep-sim with the command 6 | # 7 | # edep-sim -C -u -e 10 muon-100.mac 8 | # 9 | 10 | # Create the first particle source. This source will be used to 11 | # specify the position of the vertex. The any of the GPS direction 12 | # and energy commands can be used. 13 | /gps/particle mu+ 14 | /gps/energy 100 MeV 15 | 16 | # This generates the position of the particle gun. It can be 17 | # used for the other particle guns to create a multi particle event. The 18 | # /gps/position command must come first. 19 | /gps/position 0.0 0.0 -15.0 cm 20 | /gps/pos/type Volume 21 | /gps/pos/shape Para 22 | /gps/pos/halfx 1 cm 23 | /gps/pos/halfy 1 cm 24 | /gps/pos/halfz 1 cm 25 | 26 | # Make an isotropic particle gun. 27 | /gps/ang/type iso 28 | 29 | # Do not include /run/beamOn here. 30 | -------------------------------------------------------------------------------- /src/kinem/EDepSimFixedCountFactory.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_FixedCountFactory_hh_seen 2 | #define EDepSim_FixedCountFactory_hh_seen 3 | 4 | #include "kinem/EDepSimVCountFactory.hh" 5 | 6 | namespace EDepSim {class FixedCountFactory;} 7 | class EDepSim::FixedCountFactory : public EDepSim::VCountFactory { 8 | public: 9 | FixedCountFactory(EDepSim::UserPrimaryGeneratorMessenger* parent); 10 | virtual ~FixedCountFactory(); 11 | 12 | /// Return the fixed count generator. 13 | EDepSim::VCountGenerator* GetGenerator(); 14 | 15 | /// Set the count to be generated. 16 | void SetNumber(int count) {fNumber = count;} 17 | 18 | /// Get the count to be generated. 19 | int GetNumber() const {return fNumber;} 20 | 21 | /// Handle messages from the UI processor. 22 | void SetNewValue(G4UIcommand*, G4String); 23 | 24 | private: 25 | /// The count of particles to generate. 26 | int fNumber; 27 | 28 | G4UIcmdWithAnInteger* fNumberCMD; 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/kinem/EDepSimMeanCountFactory.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_MeanCountFactory_hh_seen 2 | #define EDepSim_MeanCountFactory_hh_seen 3 | 4 | #include "kinem/EDepSimVCountFactory.hh" 5 | 6 | namespace EDepSim {class MeanCountFactory;} 7 | class EDepSim::MeanCountFactory : public EDepSim::VCountFactory { 8 | public: 9 | MeanCountFactory(EDepSim::UserPrimaryGeneratorMessenger* parent); 10 | virtual ~MeanCountFactory(); 11 | 12 | /// Return the mean count generator. 13 | EDepSim::VCountGenerator* GetGenerator(); 14 | 15 | /// Set the count to be generated. 16 | void SetNumber(double mean) {fNumber = mean;} 17 | 18 | /// Get the count to be generated. 19 | double GetNumber() const {return fNumber;} 20 | 21 | /// Handle messages from the UI processor. 22 | void SetNewValue(G4UIcommand*, G4String); 23 | 24 | private: 25 | /// The count of particles to generate. 26 | double fNumber; 27 | 28 | G4UIcmdWithADouble* fNumberCMD; 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /inputs/proton-300.mac: -------------------------------------------------------------------------------- 1 | #################################################################### 2 | # 3 | # Generate an isotropic 300 MeV proton. 4 | # 5 | # To generate 10 events, this can be run using edep-sim with the command 6 | # 7 | # edep-sim -C -u -e 10 muon-100.mac 8 | # 9 | 10 | # Create the first particle source. This source will be used to 11 | # specify the position of the vertex. The any of the GPS direction 12 | # and energy commands can be used. 13 | /gps/particle proton 14 | /gps/energy 300 MeV 15 | 16 | # This generates the position of the particle gun. It can be 17 | # used for the other particle guns to create a multi particle event. The 18 | # /gps/position command must come first. 19 | /gps/position 0.0 0.0 -15.0 cm 20 | /gps/pos/type Volume 21 | /gps/pos/shape Para 22 | /gps/pos/halfx 10 cm 23 | /gps/pos/halfy 10 cm 24 | /gps/pos/halfz 10 cm 25 | 26 | # This generates the direction of the particle gun. 27 | /gps/ang/type iso 28 | 29 | # Do not include /run/beamOn here. 30 | -------------------------------------------------------------------------------- /inputs/muon-200.mac: -------------------------------------------------------------------------------- 1 | #################################################################### 2 | # 3 | # Generate a 200 MeV muon along the X axis. 4 | # 5 | # To generate 10 events, this can be run using edep-sim with the command 6 | # 7 | # edep-sim -C -u -e 10 muon-200.mac 8 | # 9 | 10 | # Create the first particle source. This source will be used to 11 | # specify the position of the vertex. The any of the GPS direction 12 | # and energy commands can be used. 13 | /gps/particle mu- 14 | /gps/energy 200 MeV 15 | 16 | # This generates the position of the particle gun. It can be 17 | # used for the other particle guns to create a multi particle event. The 18 | # /gps/position command must come first. 19 | /gps/position 0.0 0.0 -15.0 cm 20 | /gps/pos/type Volume 21 | /gps/pos/shape Para 22 | /gps/pos/halfx 10 cm 23 | /gps/pos/halfy 10 cm 24 | /gps/pos/halfz 10 cm 25 | 26 | # This generates the direction of the particle gun. 27 | /gps/direction 1 0 0.1 28 | 29 | # Do not include /run/beamOn here. 30 | -------------------------------------------------------------------------------- /src/kinem/EDepSimDensityPositionFactory.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_DensityPositionFactory_hh_seen 2 | #define EDepSim_DensityPositionFactory_hh_seen 3 | 4 | #include "kinem/EDepSimVConstrainedPositionFactory.hh" 5 | 6 | namespace EDepSim {class DensityPositionFactory;} 7 | class EDepSim::DensityPositionFactory : public EDepSim::VConstrainedPositionFactory { 8 | public: 9 | DensityPositionFactory(EDepSim::UserPrimaryGeneratorMessenger* parent); 10 | virtual ~DensityPositionFactory(); 11 | 12 | /// Return the density vertex generator. This must call 13 | /// EDepSim::VConstrainedPositionFactory::GetGenerator(). 14 | EDepSim::VPositionGenerator* GetGenerator(); 15 | 16 | /// Create a new density vertex generator. The newly created vertex 17 | /// generator will be initialized by the factory. 18 | EDepSim::VPositionGenerator* CreateGenerator(); 19 | 20 | /// Handle messages from the UI processor. 21 | void SetNewValue(G4UIcommand*, G4String); 22 | 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/kinem/EDepSimUniformPositionFactory.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_UniformPositionFactory_hh_seen 2 | #define EDepSim_UniformPositionFactory_hh_seen 3 | 4 | #include "kinem/EDepSimVConstrainedPositionFactory.hh" 5 | 6 | namespace EDepSim {class UniformPositionFactory;} 7 | class EDepSim::UniformPositionFactory : public EDepSim::VConstrainedPositionFactory { 8 | public: 9 | UniformPositionFactory(EDepSim::UserPrimaryGeneratorMessenger* parent); 10 | virtual ~UniformPositionFactory(); 11 | 12 | /// Return the uniform vertex generator. This must call 13 | /// EDepSim::VConstrainedPositionFactory::GetGenerator(). 14 | EDepSim::VPositionGenerator* GetGenerator(); 15 | 16 | /// Create a new uniform vertex generator. The newly created vertex 17 | /// generator will be initialized by the factory. 18 | EDepSim::VPositionGenerator* CreateGenerator(); 19 | 20 | /// Handle messages from the UI processor. 21 | void SetNewValue(G4UIcommand*, G4String); 22 | 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/kinem/EDepSimVCountFactory.cc: -------------------------------------------------------------------------------- 1 | #include "kinem/EDepSimVCountFactory.hh" 2 | 3 | EDepSim::VCountFactory::VCountFactory( 4 | G4String name, 5 | EDepSim::UserPrimaryGeneratorMessenger* parent, 6 | bool makeDirectory) 7 | : EDepSim::VPrimaryFactory("count",name,parent,makeDirectory), fIntensity(0.0) 8 | { 9 | fIntensityCMD = new G4UIcmdWithADouble(CommandName("intensity"),this); 10 | fIntensityCMD->SetGuidance("Set the intensity for the events. This is" 11 | " only for documentation and is saved in the" 12 | " MC header."); 13 | fIntensityCMD->SetParameterName("intensity",false); 14 | } 15 | 16 | EDepSim::VCountFactory::~VCountFactory() { 17 | delete fIntensityCMD; 18 | } 19 | 20 | void EDepSim::VCountFactory::SetNewValue(G4UIcommand* command, 21 | G4String newValue) { 22 | if (command == fIntensityCMD) { 23 | SetIntensity(fIntensityCMD->GetNewDoubleValue(newValue)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /inputs/electron-600.mac: -------------------------------------------------------------------------------- 1 | ############################################################## 2 | # A macro that uses G4 particle gun to create a single particle 3 | # 4 | # To generate 10 events, this can be run using edep-sim with the command 5 | # 6 | # edep-sim -C -u -e 10 electron-600.mac 7 | # 8 | 9 | # Create the first particle source. This source will be used to 10 | # specify the position of the vertex. The any of the GPS direction 11 | # and energy commands can be used. 12 | /gps/particle e- 13 | /gps/energy 600 MeV 14 | 15 | # This generates the position of the first particle gun. It will be 16 | # used for the other particle guns. The /gps/position command must 17 | # come first. 18 | /gps/position 0.0 75.0 -10.0 cm 19 | /gps/pos/type Volume 20 | /gps/pos/shape Para 21 | /gps/pos/halfx 1 cm 22 | /gps/pos/halfy 1 cm 23 | /gps/pos/halfz 1 cm 24 | 25 | # This generates the direction of the first particle gun. 26 | /gps/ang/type beam1d 27 | /gps/ang/sigma_r 15 deg 28 | /gps/ang/rot2 0 0 -1 29 | 30 | # Don't include the beamOn here. 31 | -------------------------------------------------------------------------------- /inputs/rooTracker-overlay.mac: -------------------------------------------------------------------------------- 1 | ################################ 2 | # Add the GENIE events 3 | ################################ 4 | 5 | ## Replace this with the name of a GENIE rooTracker file 6 | /generator/kinematics/rooTracker/input rooTracker_overlay.root 7 | 8 | ## Use the T2K rooTracker input format. This is directly supported by GENIE. 9 | /generator/kinematics/set rooTracker 10 | 11 | ## Distribute the events based on the vertex in the rooTracker file. 12 | /generator/position/set free 13 | 14 | ## The overlay file will have markers at the end of each event. This tells 15 | ## edep-sim to generate vertices until it runs into an end-of-event marker. 16 | ## The value doesn't matter, but it needs to be larger than the maximum number 17 | ## of vertices in an event. 18 | /generator/count/fixed/number 100000 19 | /generator/count/set fixed 20 | 21 | ## Distribute the event times based onn the time in the rooTracker file. 22 | /generator/time/set free 23 | 24 | ## Make sure EDEPSIM updates the kinematics generator. 25 | /generator/add 26 | 27 | -------------------------------------------------------------------------------- /src/kinem/EDepSimDensityPositionFactory.cc: -------------------------------------------------------------------------------- 1 | #include "kinem/EDepSimVPositionFactory.hh" 2 | #include "kinem/EDepSimDensityPositionFactory.hh" 3 | #include "kinem/EDepSimDensityPositionGenerator.hh" 4 | 5 | EDepSim::DensityPositionFactory::DensityPositionFactory( 6 | EDepSim::UserPrimaryGeneratorMessenger* parent) 7 | : EDepSim::VConstrainedPositionFactory("density",parent) { 8 | } 9 | 10 | EDepSim::DensityPositionFactory::~DensityPositionFactory() { 11 | } 12 | 13 | EDepSim::VPositionGenerator* EDepSim::DensityPositionFactory::CreateGenerator() { 14 | EDepSim::VPositionGenerator* vtx 15 | = new EDepSim::DensityPositionGenerator(GetName()); 16 | return vtx; 17 | } 18 | 19 | EDepSim::VPositionGenerator* EDepSim::DensityPositionFactory::GetGenerator() { 20 | return EDepSim::VConstrainedPositionFactory::GetGenerator(); 21 | } 22 | 23 | void EDepSim::DensityPositionFactory::SetNewValue(G4UIcommand* command, 24 | G4String value) { 25 | EDepSim::VConstrainedPositionFactory::SetNewValue(command,value); 26 | } 27 | -------------------------------------------------------------------------------- /src/kinem/EDepSimUniformPositionFactory.cc: -------------------------------------------------------------------------------- 1 | #include "kinem/EDepSimVPositionFactory.hh" 2 | #include "kinem/EDepSimUniformPositionFactory.hh" 3 | #include "kinem/EDepSimUniformPositionGenerator.hh" 4 | 5 | EDepSim::UniformPositionFactory::UniformPositionFactory( 6 | EDepSim::UserPrimaryGeneratorMessenger* parent) 7 | : EDepSim::VConstrainedPositionFactory("uniform",parent) { 8 | } 9 | 10 | EDepSim::UniformPositionFactory::~UniformPositionFactory() { 11 | } 12 | 13 | EDepSim::VPositionGenerator* EDepSim::UniformPositionFactory::CreateGenerator() { 14 | EDepSim::VPositionGenerator* vtx 15 | = new EDepSim::UniformPositionGenerator(GetName()); 16 | return vtx; 17 | } 18 | 19 | EDepSim::VPositionGenerator* EDepSim::UniformPositionFactory::GetGenerator() { 20 | return EDepSim::VConstrainedPositionFactory::GetGenerator(); 21 | } 22 | 23 | void EDepSim::UniformPositionFactory::SetNewValue(G4UIcommand* command, 24 | G4String value) { 25 | EDepSim::VConstrainedPositionFactory::SetNewValue(command,value); 26 | } 27 | -------------------------------------------------------------------------------- /inputs/muon-burst-10000.mac: -------------------------------------------------------------------------------- 1 | #################################################################### 2 | # 3 | # Generate a burst of 10000 MeV muons with 100 muons per event. The burst 4 | # has is isotropic. 5 | # 6 | # To generate 10 events, this can be run using edep-sim with the command 7 | # 8 | # edep-sim -C -u -e 10 muon-burst-10000.mac 9 | # 10 | 11 | # Create the first particle source. This source will be used to 12 | # specify the position of the vertex. The any of the GPS direction 13 | # and energy commands can be used. 14 | /gps/particle mu+ 15 | /gps/energy 10000 MeV 16 | 17 | # This generates the position of the particle gun. It can be 18 | # used for the other particle guns to create a multi particle event. The 19 | # /gps/position command must come first. 20 | /gps/position 0.0 0.0 -1.0 m 21 | /gps/pos/type Volume 22 | /gps/pos/shape Para 23 | /gps/pos/halfx 1 cm 24 | /gps/pos/halfy 1 cm 25 | /gps/pos/halfz 1 cm 26 | 27 | # This generates the burst of muons in all directions. 28 | /gps/ang/type iso 29 | 30 | /gps/number 100 31 | 32 | # Do not include /run/beamOn here. 33 | -------------------------------------------------------------------------------- /src/kinem/EDepSimGPSKinematicsFactory.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_GPSKinematicsFactory_hh_seen 2 | #define EDepSim_GPSKinematicsFactory_hh_seen 3 | 4 | #include "kinem/EDepSimVKinematicsFactory.hh" 5 | 6 | class G4VPrimaryGenerator; 7 | namespace EDepSim {class GPSKinematicsGenerator;} 8 | 9 | namespace EDepSim {class GPSKinematicsFactory;} 10 | class EDepSim::GPSKinematicsFactory : public EDepSim::VKinematicsFactory { 11 | public: 12 | GPSKinematicsFactory(EDepSim::UserPrimaryGeneratorMessenger* fParent); 13 | virtual ~GPSKinematicsFactory(); 14 | 15 | /// Return a new generator enclosing the current factory state. The new 16 | /// generator method is pure virtual so it must be implemented by derived 17 | /// classes. 18 | virtual EDepSim::VKinematicsGenerator* GetGenerator(); 19 | 20 | private: 21 | /// The GPS G4VPrimaryGenerator that will be used for this kinematics 22 | /// generator. This must be created when the factory is constructed so 23 | /// that the GPS can add it's commands to the UI. There can be only one. 24 | G4VPrimaryGenerator* fGenerator; 25 | }; 26 | #endif 27 | -------------------------------------------------------------------------------- /src/kinem/EDepSimVPrimaryFactory.cc: -------------------------------------------------------------------------------- 1 | #include "kinem/EDepSimVPrimaryFactory.hh" 2 | 3 | EDepSim::VPrimaryFactory::VPrimaryFactory( 4 | G4String subdir, G4String name, 5 | EDepSim::UserPrimaryGeneratorMessenger* parent, 6 | bool makeDirectory) { 7 | fSubDirName = subdir; 8 | fName = name; 9 | fParent = parent; 10 | if (makeDirectory) { 11 | fDir = new G4UIdirectory(GetPath()); 12 | std::string guidance = "Control of the " + fName 13 | + " " + fSubDirName + " factory."; 14 | fDir->SetGuidance(guidance.c_str()); 15 | } 16 | else fDir = NULL; 17 | } 18 | 19 | EDepSim::VPrimaryFactory::~VPrimaryFactory() { 20 | if (fDir) delete fDir; 21 | } 22 | 23 | G4String EDepSim::VPrimaryFactory::GetPath() const { 24 | G4String dirName = fParent->GetPath() 25 | + GetSubDir() + "/" 26 | + GetName() + "/"; 27 | return dirName; 28 | } 29 | 30 | G4String EDepSim::VPrimaryFactory::GetName() const { 31 | return fName; 32 | } 33 | 34 | G4String EDepSim::VPrimaryFactory::GetSubDir() const { 35 | return fSubDirName; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /inputs/genie-example.mac: -------------------------------------------------------------------------------- 1 | ################################ 2 | # Add the GENIE events 3 | ################################ 4 | 5 | ## Replace this with the name of a GENIE rooTracker file 6 | /generator/kinematics/rooTracker/input FHC_numu.root 7 | 8 | ## Use the T2K rooTracker input format. This is directly supported by GENIE. 9 | /generator/kinematics/set rooTracker 10 | 11 | ## Distribute the events based on the density of the material. When done 12 | ## this way, the composition of the detector is ignored, so it's not 13 | ## a good way for physics, but it's OK for an example since you don't 14 | ## need to syncronize the GENIE and EDEPSIM geometries. 15 | /generator/position/density/sample DetEnclosure_lv 16 | /generator/position/set density 17 | 18 | /generator/count/fixed/number 26 19 | /generator/count/set fixed 20 | 21 | /generator/time/spill/start 0.0 ns 22 | /generator/time/spill/bunchCount 1000 23 | /generator/time/spill/bunchSep 10.0 ns 24 | /generator/time/spill/bunchLength 5.0 ns 25 | /generator/time/set spill 26 | 27 | ## Make sure EDEPSIM updates the kinematics generator. 28 | /generator/add 29 | 30 | -------------------------------------------------------------------------------- /src/kinem/EDepSimFixedPositionGenerator.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_FixedPositionGenerator_hh_seen 2 | #define EDepSim_FixedPositionGenerator_hh_seen 3 | 4 | #include 5 | #include 6 | 7 | #include "kinem/EDepSimVPositionGenerator.hh" 8 | 9 | /// Select a position and time to be used as the vertex of a primary particle. 10 | namespace EDepSim {class FixedPositionGenerator;} 11 | class EDepSim::FixedPositionGenerator : public EDepSim::VPositionGenerator { 12 | public: 13 | FixedPositionGenerator(const G4String& name, 14 | const G4ThreeVector& pos); 15 | virtual ~FixedPositionGenerator(); 16 | 17 | /// Return a candidate vertex. 18 | virtual G4LorentzVector GetPosition(); 19 | 20 | /// Set the position for the vertex. 21 | virtual void SetPosition(const G4ThreeVector& pos); 22 | 23 | /// Flag if the vertex should be forced to the candidate vertex returned 24 | /// by GetPosition(). 25 | virtual bool ForcePosition(); 26 | 27 | private: 28 | /// The position for this generator. 29 | G4LorentzVector fPosition; 30 | }; 31 | #endif 32 | -------------------------------------------------------------------------------- /validate/fast-tests/101FailHEPEvt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Write a ROOT file in the default geometry. This output file should 4 | # be tested to make sure that all of the fields are readable. 5 | 6 | OUTPUT=101FailHEPEvt.root 7 | 8 | if [ -f ${OUTPUT} ]; then 9 | rm ${OUTPUT} 10 | fi 11 | 12 | cat > 101FailHEPEvt.txt < 101FailHEPEvt.mac <SetGuidance("Set the time of events to generate."); 11 | fTimeCMD->SetParameterName("time",false); 12 | fTimeCMD->SetUnitCategory("Time"); 13 | 14 | } 15 | 16 | EDepSim::FixedTimeFactory::~FixedTimeFactory() { 17 | delete fTimeCMD; 18 | } 19 | 20 | void EDepSim::FixedTimeFactory::SetNewValue(G4UIcommand* command, 21 | G4String newValue) { 22 | if (command == fTimeCMD) { 23 | SetTime(fTimeCMD->GetNewDoubleValue(newValue)); 24 | } 25 | } 26 | 27 | EDepSim::VTimeGenerator* EDepSim::FixedTimeFactory::GetGenerator() { 28 | EDepSim::VTimeGenerator* time = new EDepSim::FixedTimeGenerator(GetName(), 29 | GetTime()); 30 | return time; 31 | } 32 | -------------------------------------------------------------------------------- /src/kinem/EDepSimNuMIRockKinematicsGenerator.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_NuMIRockKinematicsGenerator_hh 2 | #define EDepSim_NuMIRockKinematicsGenerator_hh 3 | //////////////////////////////////////////////////////////// 4 | // 5 | 6 | #include "kinem/EDepSimVKinematicsGenerator.hh" 7 | 8 | class G4Event; 9 | 10 | /// This is an interface approximate the rock muons entering CAPTAIN. 11 | namespace EDepSim {class NuMIRockKinematicsGenerator;} 12 | class EDepSim::NuMIRockKinematicsGenerator : public EDepSim::VKinematicsGenerator { 13 | public: 14 | /// Construct a new generator. The name is the name of the generator 15 | /// (e.g. GENIE, rock, &c). The fluxName is the name of the neutrino 16 | /// spectrum. 17 | NuMIRockKinematicsGenerator(const G4String& name, 18 | const G4String& fluxName); 19 | virtual ~NuMIRockKinematicsGenerator(); 20 | 21 | /// Add a primary vertex to the event. 22 | virtual GeneratorStatus GeneratePrimaryVertex(G4Event* evt, 23 | const G4LorentzVector& position); 24 | 25 | private: 26 | /// The static part of the file name field. 27 | std::string fFluxName; 28 | 29 | }; 30 | #endif 31 | -------------------------------------------------------------------------------- /src/captain/mcaptain-outer-vessel-outer-surface.txt: -------------------------------------------------------------------------------- 1 | // Inner boundary of the miniCAPTAIN cryostat inner vessel hand digitized 2 | // using engauge on Nov 22, 2015 by Clark McGrew. The coordinates are 3 | // measured in millimeters with the top of the cryostat at -X, the bottom at 4 | // +X, and the diameter located along the Y axis. The X coordinate is 5 | // measured from the top of the flange with the nominal LAr surface located 9 6 | // inches (609.6 mm) below the top surface of flange. 7 | // 8 | // COMMENT: This includes the lid and the flange as part of the inner vessel. 9 | // The outer vessel is assumed to stop when it reaches the lower edge of the 10 | // flange. 11 | 12 | 41.4583 1849.29 13 | 816.351 1850.03 14 | 854.435 1841.83 15 | 879.146 1827.45 16 | 906.956 1801.75 17 | 928.59 1777.07 18 | 952.296 1737.99 19 | 971.889 1695.81 20 | 988.393 1654.67 21 | 1010.06 1597.06 22 | 1030.71 1525.04 23 | 1047.26 1436.56 24 | 1063.81 1341.9 25 | 1071.1 1251.35 26 | 1080.53 1083.62 27 | 1078.54 1005.41 28 | 1072.45 914.841 29 | 1064.32 809.868 30 | 1040.76 699.734 31 | 1014.12 577.249 32 | 987.437 499.014 33 | 941.214 409.44 34 | 905.24 363.097 35 | 867.193 333.218 36 | 836.331 321.869 37 | 817.812 317.735 38 | 42.92 315.967 39 | -------------------------------------------------------------------------------- /inputs/single-particle-gun.mac: -------------------------------------------------------------------------------- 1 | ################################################################## 2 | # Macro that use G4 particle gun to create a single particle 3 | ################################################################## 4 | 5 | # To generate 10 events, this can be run using edep-sim with the command 6 | # 7 | # edep-sim -C -u -e 10 single-particle-gun.mac 8 | # 9 | 10 | # Create the first particle source. This source will be used to 11 | # specify the position of the vertex. The any of the GPS direction 12 | # and energy commands can be used. 13 | /gps/particle mu+ 14 | /gps/energy 600 MeV 15 | 16 | # This generates the position of the first particle gun. It will be 17 | # used for the other particle guns. The /gps/position command must 18 | # come first. 19 | /gps/position 0.0 0.0 -60.0 cm 20 | /gps/pos/type Volume 21 | /gps/pos/shape Para 22 | /gps/pos/halfx 1 cm 23 | /gps/pos/halfy 1 cm 24 | /gps/pos/halfz 1 cm 25 | 26 | # This generates the direction of the first particle gun. This aims 27 | # the particle downstream with the directions uniformly distributed in 28 | # a 10 deg cone around the X axis. 29 | /gps/ang/type iso 30 | /gps/ang/maxtheta 10 deg 31 | /gps/ang/rot1 0 0 1 32 | /gps/ang/rot2 0 1 0 33 | 34 | 35 | -------------------------------------------------------------------------------- /inputs/muon-cone-10000.mac: -------------------------------------------------------------------------------- 1 | #################################################################### 2 | # 3 | # Generate a 10000 MeV muon beamed in the down stream direction. 4 | # 5 | # To generate 10 events, this can be run using edep-sim with the command 6 | # 7 | # edep-sim -C -u -e 10 muon-cone-10000.mac 8 | # 9 | 10 | # Create the first particle source. This source will be used to 11 | # specify the position of the vertex. The any of the GPS direction 12 | # and energy commands can be used. 13 | /gps/particle mu+ 14 | /gps/energy 10000 MeV 15 | 16 | # This generates the position of the particle gun. It can be 17 | # used for the other particle guns to create a multi particle event. The 18 | # /gps/position command must come first. 19 | /gps/position 0.0 0.0 2.0 m 20 | /gps/pos/type Volume 21 | /gps/pos/shape Para 22 | /gps/pos/halfx 1 cm 23 | /gps/pos/halfy 1 cm 24 | /gps/pos/halfz 1 cm 25 | 26 | # This generates the direction of the muon. This aims 27 | # the particle downstream with the directions uniformly distributed in 28 | # a 10 deg cone around the Z axis. 29 | /gps/ang/type iso 30 | /gps/ang/maxtheta 45 deg 31 | /gps/ang/rot1 1 0 0 32 | /gps/ang/rot2 0 -1 0 33 | 34 | /gps/number 100 35 | 36 | # Do not include /run/beamOn here. 37 | -------------------------------------------------------------------------------- /src/kinem/EDepSimFixedPositionFactory.cc: -------------------------------------------------------------------------------- 1 | #include "kinem/EDepSimVPositionFactory.hh" 2 | #include "kinem/EDepSimFixedPositionFactory.hh" 3 | #include "kinem/EDepSimFixedPositionGenerator.hh" 4 | 5 | EDepSim::FixedPositionFactory::FixedPositionFactory( 6 | EDepSim::UserPrimaryGeneratorMessenger* parent) 7 | : EDepSim::VPositionFactory("fixed",parent), 8 | fPosition(0,0,0) { 9 | 10 | fPositionCMD = new G4UIcmdWith3VectorAndUnit(CommandName("position"),this); 11 | fPositionCMD->SetGuidance("Set the position of events to generate."); 12 | fPositionCMD->SetParameterName("x","y","z",false); 13 | fPositionCMD->SetUnitCategory("Length"); 14 | 15 | } 16 | 17 | EDepSim::FixedPositionFactory::~FixedPositionFactory() {} 18 | 19 | EDepSim::VPositionGenerator* EDepSim::FixedPositionFactory::GetGenerator() { 20 | EDepSim::VPositionGenerator* vertex 21 | = new EDepSim::FixedPositionGenerator(GetName(),GetPosition()); 22 | return vertex; 23 | } 24 | 25 | void EDepSim::FixedPositionFactory::SetNewValue(G4UIcommand* command, 26 | G4String newValue) { 27 | if (command == fPositionCMD) { 28 | SetPosition(fPositionCMD->GetNew3VectorValue(newValue)); 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /scripts/edepsim-export-geometry.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # DEPRECATED: Export an MC geometry to a geometry file. This prepares 4 | # a file that is ready to be used in the reconstruction. It only 5 | # works with the default geometry used for tests. This script is a 6 | # candidate to be removed. 7 | # 8 | # USAGE: ./edepsim-export-geometry.sh <1.0> ... 9 | # 10 | # Make a temporary macro file. 11 | MACRO=`mktemp -t edepsim.XXXXXXXXXX` || exit 1 12 | 13 | haveControl="" 14 | 15 | # write the control lines. 16 | while true; do 17 | CTRL=$1 18 | if [ x$CTRL == x ]; then 19 | break; 20 | fi 21 | 22 | shift 23 | CTRLVERS=$1 24 | if [ x$CTRLVERS == x ]; then 25 | echo Missing control file 26 | rm $MACRO 27 | exit 1 28 | fi 29 | 30 | haveControl=${haveControl}"-"${CTRL} 31 | 32 | echo /edep/control ${CTRL} ${CTRLVERS} >> $MACRO 33 | shift 34 | done 35 | 36 | if [ x$haveControl == x ]; then 37 | echo Missing control file 38 | rm $MACRO 39 | exit 1 40 | fi 41 | 42 | OUTPUT=export-geometry${haveControl}.root 43 | cat >> $MACRO < 8 | class G4VSensitiveDetector; 9 | 10 | /// Create an object to build a sensitive detector (SD) based on a name and 11 | /// type. The name of the SD will be used by the G4 SD manager to see if the 12 | /// detector already exists. If it doesn't then a new SD of "type" will be 13 | /// built. 14 | namespace EDepSim {class SDFactory;} 15 | class EDepSim::SDFactory { 16 | public: 17 | /// Build a factory to build sensitive detectors specified by "type". 18 | SDFactory(G4String type); 19 | virtual ~SDFactory(); 20 | 21 | /// Get pointer to a sensitive detector built by this factory, but return 22 | /// null if the detector doesn't exist. 23 | G4VSensitiveDetector* GetSD(G4String name); 24 | 25 | /// Get pointer to a sensitive detector built by this factory, and create 26 | /// a new sensitive detector if required. 27 | G4VSensitiveDetector* MakeSD(G4String name); 28 | 29 | private: 30 | /// The type of sensitive detector that this will build. 31 | G4String fType; 32 | 33 | }; 34 | #endif 35 | -------------------------------------------------------------------------------- /src/kinem/EDepSimFixedCountFactory.cc: -------------------------------------------------------------------------------- 1 | #include "kinem/EDepSimVCountFactory.hh" 2 | #include "kinem/EDepSimFixedCountFactory.hh" 3 | #include "kinem/EDepSimFixedCountGenerator.hh" 4 | 5 | EDepSim::FixedCountFactory::FixedCountFactory( 6 | EDepSim::UserPrimaryGeneratorMessenger* parent) 7 | : EDepSim::VCountFactory("fixed",parent), fNumber(1) { 8 | 9 | fNumberCMD = new G4UIcmdWithAnInteger(CommandName("number"),this); 10 | fNumberCMD->SetGuidance("Set the number of events to generate."); 11 | fNumberCMD->SetParameterName("count",false); 12 | 13 | } 14 | 15 | EDepSim::FixedCountFactory::~FixedCountFactory() { 16 | delete fNumberCMD; 17 | } 18 | 19 | void EDepSim::FixedCountFactory::SetNewValue(G4UIcommand* command, 20 | G4String newValue) { 21 | if (command == fNumberCMD) { 22 | SetNumber(fNumberCMD->GetNewIntValue(newValue)); 23 | } 24 | else { 25 | EDepSim::VCountFactory::SetNewValue(command,newValue); 26 | } 27 | } 28 | 29 | EDepSim::VCountGenerator* EDepSim::FixedCountFactory::GetGenerator() { 30 | EDepSim::VCountGenerator* counter 31 | = new EDepSim::FixedCountGenerator(GetName(), 32 | GetNumber(), 33 | GetIntensity()); 34 | return counter; 35 | } 36 | -------------------------------------------------------------------------------- /inputs/muon-10000.mac: -------------------------------------------------------------------------------- 1 | #################################################################### 2 | # 3 | # Generate a 10000 MeV muon beamed in the down stream direction. 4 | # 5 | # To generate 10 events with 100 muons each, this can be run using edep-sim 6 | # with the command 7 | # 8 | # edep-sim -C -u -e 10 muon-100.mac 9 | # 10 | 11 | 12 | # Create the first particle source. This source will be used to 13 | # specify the position of the vertex. The any of the GPS direction 14 | # and energy commands can be used. 15 | /gps/particle mu+ 16 | /gps/energy 10000 MeV 17 | 18 | # This generates the position of the particle gun. It can be 19 | # used for the other particle guns to create a multi particle event. The 20 | # /gps/position command must come first. 21 | /gps/position 0.0 0.0 -8.0 m 22 | /gps/pos/type Volume 23 | /gps/pos/shape Para 24 | /gps/pos/halfx 1000 cm 25 | /gps/pos/halfy 1000 cm 26 | /gps/pos/halfz 1 cm 27 | 28 | # This generates the direction of the muon. This aims 29 | # the particle downstream with the directions uniformly distributed in 30 | # a 10 deg cone around the Z axis. 31 | /gps/ang/type iso 32 | /gps/ang/maxtheta 15 deg 33 | /gps/ang/rot1 1 0 0 34 | /gps/ang/rot2 0 -1 0 35 | 36 | /generator/count/fixed/number 100 37 | /generator/count/set fixed 38 | 39 | /generator/add 40 | 41 | # Do not include /run/beamOn here. 42 | -------------------------------------------------------------------------------- /validate/fast-tests/100TestGDML.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Generate events using a non-trivial GDML geometry. 4 | # 5 | 6 | GDML=../fast-tests/100TestGDML.gdml 7 | OUTPUT=100TestGDML.root 8 | 9 | if [ -f ${OUTPUT} ]; then 10 | rm ${OUTPUT} 11 | fi 12 | 13 | cat > 100TestGDML.mac <SetGuidance("Set the mean number of events to generate."); 11 | fNumberCMD->SetParameterName("mean",false); 12 | 13 | } 14 | 15 | EDepSim::MeanCountFactory::~MeanCountFactory() { 16 | delete fNumberCMD; 17 | } 18 | 19 | void EDepSim::MeanCountFactory::SetNewValue(G4UIcommand* command, 20 | G4String newValue) { 21 | if (command == fNumberCMD) { 22 | SetNumber(fNumberCMD->GetNewDoubleValue(newValue)); 23 | } 24 | else { 25 | EDepSim::VCountFactory::SetNewValue(command,newValue); 26 | } 27 | } 28 | 29 | EDepSim::VCountGenerator* EDepSim::MeanCountFactory::GetGenerator() { 30 | EDepSim::VCountGenerator* counter = new EDepSim::MeanCountGenerator(GetName(), 31 | GetNumber(), 32 | GetIntensity()); 33 | return counter; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /src/makeColors.C: -------------------------------------------------------------------------------- 1 | // This is a macro to dump the ROOT colors to a include file suitable for 2 | // detSim. 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void makeColors() { 11 | const TColor* color = gROOT->GetColor(kBlue); 12 | TIter next(gROOT->GetListOfColors()); 13 | 14 | std::cout << "// Automatically generated map from the ROOT color index to" 15 | << std::endl 16 | << "// a G4Color. All of the alpha components are set to 1.0" 17 | << std::endl 18 | << "// This requires that the map include file is available." 19 | << std::endl; 20 | std::cout << "static std::map sRootColorToG4ColorMap;" 21 | << std::endl; 22 | std::cout << "if (sRootColorToG4ColorMap.empty()) {" 23 | << std::endl; 24 | TObject *obj; 25 | while ((obj = next())) { 26 | TColor* color = dynamic_cast(obj); 27 | std::cout << " sRootColorToG4ColorMap[" << color->GetNumber() 28 | << "] = G4Color(" << color->GetRed() 29 | << "," << color->GetGreen() 30 | << "," << color->GetBlue() 31 | << "," << 1.0 << ");" 32 | << std::endl; 33 | } 34 | std::cout << "}" 35 | << std::endl; 36 | } 37 | -------------------------------------------------------------------------------- /src/EDepSimUserRunActionMessenger.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // $Id: EDepSim::UserRunActionMessenger.hh,v 1.4 2011/07/19 20:57:44 mcgrew Exp $ 3 | // 4 | #ifndef EDepSim_UserRunActionMessenger_h 5 | #define EDepSim_UserRunActionMessenger_h 1 6 | 7 | #include 8 | #include "G4UImessenger.hh" 9 | #include "globals.hh" 10 | 11 | namespace EDepSim {class UserRunAction;} 12 | 13 | class G4UIdirectory; 14 | class G4UIcmdWithoutParameter; 15 | class G4UIcmdWithAString; 16 | class G4UIcmdWithAnInteger; 17 | 18 | namespace EDepSim {class UserRunActionMessenger;} 19 | class EDepSim::UserRunActionMessenger: public G4UImessenger { 20 | public: 21 | UserRunActionMessenger(EDepSim::UserRunAction*); 22 | virtual ~UserRunActionMessenger(); 23 | 24 | /// Handle messages from the UI processor. 25 | void SetNewValue(G4UIcommand*, G4String); 26 | 27 | /// Get the base directory for the messenger commands. 28 | G4String GetPath(); 29 | 30 | private: 31 | // need primary generator action to change the seed 32 | EDepSim::UserRunAction* fUserRunAction; 33 | 34 | G4UIdirectory* fDir; 35 | G4UIcmdWithAnInteger* fRandomSeedCmd; 36 | G4UIcmdWithoutParameter* fTimeRandomSeedCmd; 37 | G4UIcmdWithoutParameter* fShowRandomSeedCmd; 38 | G4UIcmdWithAnInteger* fDetSimRunIdCmd; 39 | G4UIcmdWithAnInteger* fDetSimSubrunIdCmd; 40 | 41 | }; 42 | #endif 43 | -------------------------------------------------------------------------------- /src/kinem/EDepSimVCountFactory.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_VCountFactory_hh_seen 2 | #define EDepSim_VCountFactory_hh_seen 3 | 4 | #include "kinem/EDepSimVPrimaryFactory.hh" 5 | 6 | namespace EDepSim {class VCountGenerator;} 7 | 8 | namespace EDepSim {class VCountFactory;} 9 | class EDepSim::VCountFactory : public EDepSim::VPrimaryFactory { 10 | public: 11 | VCountFactory(G4String name, 12 | EDepSim::UserPrimaryGeneratorMessenger* fParent, 13 | bool makeDirectory=true); 14 | virtual ~VCountFactory(); 15 | 16 | /// Return a new generator enclosing the current factory state. The new 17 | /// generator method is pure virtual so it must be implemented by derived 18 | /// classes. 19 | virtual EDepSim::VCountGenerator* GetGenerator() = 0; 20 | 21 | /// Set the intensity 22 | void SetIntensity(double v) {fIntensity = v;} 23 | 24 | /// Get the intensity. For a beam spill MC, this will represent the 25 | /// protons per pulse. 26 | double GetIntensity() const { return fIntensity;} 27 | 28 | /// Handle messages from the UI processor. 29 | void SetNewValue(G4UIcommand*, G4String); 30 | 31 | private: 32 | G4UIcmdWithADouble* fIntensityCMD; 33 | 34 | /// The intensity for this event. This is only documentation and is saved 35 | /// in the MC header. For a beam spill MC, this will represent the 36 | /// protons per pulse. 37 | double fIntensity; 38 | }; 39 | #endif 40 | -------------------------------------------------------------------------------- /src/EDepSimVertexInfo.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "EDepSimVertexInfo.hh" 4 | 5 | EDepSim::VertexInfo::VertexInfo() 6 | : fInformationalVertex(NULL), 7 | fInteractionNumber(0), fCrossSection(0.0), fDiffCrossSection(0.0), 8 | fWeight(1.0), fProbability(1.0) {} 9 | 10 | EDepSim::VertexInfo::~VertexInfo() { 11 | if (fInformationalVertex != NULL) delete fInformationalVertex; 12 | } 13 | 14 | const G4PrimaryVertex* EDepSim::VertexInfo::GetInformationalVertex(G4int i) const { 15 | if (i == 0) { 16 | return fInformationalVertex; 17 | } 18 | if (i<0) return NULL; 19 | const G4PrimaryVertex* infoVertex = fInformationalVertex; 20 | for (int j=0; j < i; j++) { 21 | if (infoVertex == NULL) return NULL; 22 | infoVertex = infoVertex->GetNext(); 23 | } 24 | return infoVertex; 25 | } 26 | 27 | void EDepSim::VertexInfo::AddInformationalVertex(G4PrimaryVertex* vtx) { 28 | if (!fInformationalVertex) { 29 | fInformationalVertex = vtx; 30 | } 31 | else { 32 | fInformationalVertex->SetNext(vtx); 33 | } 34 | } 35 | 36 | int EDepSim::VertexInfo::GetNumberOfInformationalVertex() const { 37 | int number = 0; 38 | const G4PrimaryVertex* infoVertex = fInformationalVertex; 39 | for (int j=0; j < 1000; j++) { 40 | if (infoVertex == NULL) return number; 41 | ++number; 42 | infoVertex = infoVertex->GetNext(); 43 | } 44 | return number; 45 | } 46 | -------------------------------------------------------------------------------- /display/TMatrixElement.hxx: -------------------------------------------------------------------------------- 1 | #ifndef TMatrixElement_hxx_seen 2 | #define TMatrixElement_hxx_seen 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace EDep { 10 | class TMatrixElement; 11 | } 12 | 13 | /// A Eve Element object to represent a 3x3 matrix (either the moments of a 14 | /// distribution, or the covariance) at a position. This can be used to 15 | /// represent clusters, or other objects, and handles some of the matrix 16 | /// algebra necessary. Since Eve can't draw a spheriod, the spheriod 17 | /// described by the matrix is drawn as an eliptical tube. If the longAxis 18 | /// variable is true, then the longest axis of the spheriod is used as the 19 | /// axis of the tube, but if it's false, the shortest axis of the spheriod is 20 | /// used as the axis of the tube. 21 | class EDep::TMatrixElement: public TEveGeoShape { 22 | public: 23 | TMatrixElement(const char* name, 24 | const TVector3& position, 25 | const TMatrixD& matrix, 26 | bool longAxis); 27 | TMatrixElement(const char* name, 28 | const TVector3& position, 29 | const TMatrixF& matrix, 30 | bool longAxis); 31 | virtual ~TMatrixElement(); 32 | 33 | private: 34 | void Initialize(const TVector3& position, 35 | const TMatrixD& matrix, 36 | bool longAxis); 37 | }; 38 | #endif 39 | -------------------------------------------------------------------------------- /src/kinem/EDepSimCombinationGenerator.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "EDepSimLog.hh" 5 | #include "EDepSimException.hh" 6 | #include "EDepSimCombinationGenerator.hh" 7 | 8 | EDepSim::CombinationGenerator::CombinationGenerator(int src, int dest, 9 | bool relative) 10 | : fSource(src), fDestination(dest), fRelative(relative) { } 11 | 12 | EDepSim::CombinationGenerator::~CombinationGenerator(void) {} 13 | 14 | void EDepSim::CombinationGenerator::GeneratePrimaryVertex(G4Event* evt) { 15 | 16 | if (fSource < 0 || fSource >= evt->GetNumberOfPrimaryVertex()) { 17 | abort(); 18 | } 19 | 20 | if (fDestination < 0 || fDestination >= evt->GetNumberOfPrimaryVertex()) { 21 | abort(); 22 | } 23 | 24 | G4ThreeVector src = evt->GetPrimaryVertex(fSource)->GetPosition(); 25 | double srcTime = evt->GetPrimaryVertex(fSource)->GetT0(); 26 | 27 | if (fRelative) { 28 | G4ThreeVector dest = evt->GetPrimaryVertex(fDestination)->GetPosition(); 29 | double destTime = evt->GetPrimaryVertex(fDestination)->GetT0(); 30 | src = src + dest; 31 | srcTime = srcTime + destTime; 32 | } 33 | 34 | evt->GetPrimaryVertex(fDestination)->SetPosition(src.x(),src.y(),src.z()); 35 | evt->GetPrimaryVertex(fDestination)->SetT0(srcTime); 36 | 37 | } 38 | 39 | G4String EDepSim::CombinationGenerator::GetName() { 40 | return "combination"; 41 | } 42 | -------------------------------------------------------------------------------- /src/EDepSimCreateRunManager.cc: -------------------------------------------------------------------------------- 1 | #include "EDepSimUserDetectorConstruction.hh" 2 | #include "EDepSimUserPrimaryGeneratorAction.hh" 3 | #include "EDepSimUserRunAction.hh" 4 | #include "EDepSimUserEventAction.hh" 5 | #include "EDepSimUserStackingAction.hh" 6 | #include "EDepSimUserTrackingAction.hh" 7 | #include "EDepSimDetectorMessenger.hh" 8 | 9 | #include "EDepSimCreateRunManager.hh" 10 | 11 | // The default physics list. 12 | #include "EDepSimPhysicsList.hh" 13 | 14 | G4RunManager* EDepSim::CreateRunManager(G4String physicsList) { 15 | // Set the mandatory initialization classes 16 | 17 | // Construct the default run manager 18 | G4RunManager* runManager = new G4RunManager; 19 | 20 | // Construct the detector construction class. 21 | EDepSim::UserDetectorConstruction* theDetector 22 | = new EDepSim::UserDetectorConstruction; 23 | runManager->SetUserInitialization(theDetector); 24 | 25 | // Add the physics list first. This is a G4 requirement! 26 | runManager->SetUserInitialization(new EDepSim::PhysicsList(physicsList)); 27 | 28 | // Set the other mandatory user action class 29 | runManager->SetUserAction(new EDepSim::UserPrimaryGeneratorAction); 30 | runManager->SetUserAction(new EDepSim::UserRunAction); 31 | runManager->SetUserAction(new EDepSim::UserEventAction); 32 | runManager->SetUserAction(new EDepSim::UserStackingAction); 33 | runManager->SetUserAction(new EDepSim::UserTrackingAction); 34 | 35 | return runManager; 36 | } 37 | -------------------------------------------------------------------------------- /src/captain/mcaptain-outer-vessel-inner-surface.txt: -------------------------------------------------------------------------------- 1 | // Inner boundary of the miniCAPTAIN cryostat outer vessel hand digitized 2 | // using engauge on Nov 22, 2015 by Clark McGrew. The coordinates are 3 | // measured in millimeters with the top of the cryostat at -X, the bottom at 4 | // +X, and the diameter located along the Y axis. The X coordinate is 5 | // measured from the top of the flange with the nominal LAr surface located 9 6 | // inches (609.6 mm) below the flange. The first point is at the approximate 7 | // top of the outer vessel which is located right below the flange. 8 | // 9 | // COMMENT: This assumes that the lid and the flange are part of the inner 10 | // vessel. The outer vessel stops when it reaches the lower edge of the 11 | // flange. 12 | // 13 | // COMMENT: The makePolycone.py script will use this to produce a "close" 14 | // volume. The output needs to be edited by hand to remove the top point so 15 | // that the outer volume is open on top. 16 | 17 | 43.5223 1843.12 18 | 818.415 1843.85 19 | 853.412 1835.65 20 | 883.272 1817.16 21 | 915.205 1784.26 22 | 950.247 1728.72 23 | 977.061 1667 24 | 1005.95 1587.79 25 | 1035.91 1461.25 26 | 1051.44 1371.73 27 | 1071.23 1123.74 28 | 1074.35 1083.61 29 | 1072.33 1043.48 30 | 1064.24 897.339 31 | 1057.11 818.094 32 | 1044.82 754.279 33 | 1027.42 661.646 34 | 1012.05 592.683 35 | 993.579 532.979 36 | 967.91 472.239 37 | 941.204 419.731 38 | 906.259 373.389 39 | 882.611 351.756 40 | 854.841 336.293 41 | 830.152 327.008 42 | 816.777 323.908 43 | 43.9422 323.172 44 | -------------------------------------------------------------------------------- /src/edepsim-defaults-1.0.mac: -------------------------------------------------------------------------------- 1 | # The default configuration file for the energy deposition simulation. 2 | # This sets up the "usual" defaults for that detector and should be 3 | # included any macro files. This is loaded by the edep-sim main program 4 | # compiled from app/edepSim.cc. It can also be explicitly included using: 5 | 6 | # /edep/control edepsim-defaults 1.0 7 | 8 | /control/verbose 2 9 | 10 | ############################################## 11 | # Define the default GEANT parameter settings 12 | ############################################## 13 | /run/verbose 0 14 | /event/verbose 0 15 | /tracking/verbose 0 16 | 17 | ############################################## 18 | # Set the thresholds for saving trajectories into the output file. All 19 | # primary particle trajectories are saved so these only apply to secondary 20 | # particles. Energy that is deposited by unsaved secondaries is "assigned" 21 | # to the "nearest" parent particle. 22 | ############################################## 23 | /edep/db/set/saveAllPrimTraj true 24 | /edep/db/set/lengthThreshold 1 mm 25 | /edep/db/set/trajectoryAccuracy 1 mm 26 | /edep/db/set/neutronThreshold 50 MeV 27 | /edep/db/set/gammaThreshold 10 MeV 28 | 29 | ############################################## 30 | # Set any physics limits. 31 | ############################################## 32 | 33 | # Set the default ionization model. The choices are 0) NEST which is slow, 34 | # general, and accurate, 1) DokeBirks which is about 200 times faster 35 | # than NEST, but only applicable to LAr (code stolen from NEST). 36 | /edep/phys/ionizationModel 1 37 | -------------------------------------------------------------------------------- /io/TG4Event.h: -------------------------------------------------------------------------------- 1 | #ifndef TG4Event_hxx_seen 2 | #define TG4Event_hxx_seen 3 | 4 | #include "TG4PrimaryVertex.h" 5 | #include "TG4Trajectory.h" 6 | #include "TG4HitSegment.h" 7 | 8 | #include 9 | 10 | class TG4Event : public TObject { 11 | public: 12 | TG4Event(void) {} 13 | virtual ~TG4Event(); 14 | 15 | /// The run number 16 | int RunId; 17 | 18 | /// The event number 19 | int EventId; 20 | 21 | /// A container of primary vertices (a vector). Sometimes, there is only 22 | /// one element, but you need to be careful since some neutrino events 23 | /// don't have any primary particles (e.g. neutral current events where 24 | /// the scattered nucleon is absorbed by the nucleus). It's also likely 25 | /// that an event will have multiple vertices (i.e. more than one 26 | /// interaction per spill). When no primary was provided, then a fake 27 | /// primary vertex will be inserted so that an empty event is generated. 28 | TG4PrimaryVertexContainer Primaries; 29 | 30 | /// A container of G4 trajectories (a vector). 31 | /// 32 | /// \note When trajectories are eliminated (e.g. very low energy electron 33 | /// trajectories) the TG4Trajectory::TrackId fields are adjusted so 34 | /// that (Trajectories[index].TrackId==index). 35 | TG4TrajectoryContainer Trajectories; 36 | 37 | /// A map of sensitive detector names and vectors of hit segments. The 38 | /// map is keyed using the sensitive volume name. 39 | TG4HitSegmentDetectors SegmentDetectors; 40 | 41 | ClassDef(TG4Event,1) 42 | }; 43 | #endif 44 | -------------------------------------------------------------------------------- /src/EDepSimUserStackingAction.cc: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // $Id: EDepSim::UserStackingAction.cc,v 1.4 2011/09/06 18:58:35 mcgrew Exp $ 3 | // 4 | 5 | #include "EDepSimUserStackingAction.hh" 6 | #include "EDepSimLog.hh" 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | EDepSim::UserStackingAction::UserStackingAction() { } 15 | 16 | EDepSim::UserStackingAction::~UserStackingAction() { } 17 | 18 | G4ClassificationOfNewTrack 19 | EDepSim::UserStackingAction::ClassifyNewTrack(const G4Track* aTrack) { 20 | // Get the particle type of the new track. 21 | const G4ParticleDefinition* particle = aTrack->GetDefinition(); 22 | 23 | // if (aTrack->GetCurrentStepNumber() > 0) return fUrgent; 24 | 25 | if (aTrack->GetParentID() <= 0) return fUrgent; 26 | 27 | // This is where we can throw away particles that we don't want to track. 28 | // Drop photons below the "lowest" nuclear lines. The lowest I know if is 29 | // about 6 keV, and atomic shells start messing with the cross section at 30 | // about 70 keV. 31 | if (particle->GetParticleName() == "gamma") { 32 | if (aTrack->GetKineticEnergy() < 10.*CLHEP::keV) return fKill; 33 | } 34 | 35 | if (particle->GetParticleName() == "opticalphoton") { 36 | return fKill; 37 | } 38 | 39 | if (particle->GetParticleName() == "thermalelectron") { 40 | return fKill; 41 | } 42 | 43 | return G4UserStackingAction::ClassifyNewTrack(aTrack); 44 | } 45 | -------------------------------------------------------------------------------- /test/ggdExample.cfg: -------------------------------------------------------------------------------- 1 | ############################################# 2 | # Use for the top level builder 3 | ############################################# 4 | [World] 5 | # This is a list of builders that will be provided 6 | # to configure. 7 | subbuilders = ["DetectorEnclosure"] 8 | 9 | # This is the python code class to be used. This can be found in 10 | # ggdExample/World.py 11 | class = ggdExample.World.Builder 12 | 13 | # The arguments to World.WorldBuilder.configure(). GeGeDe passes these 14 | # onto configure method 15 | material = "Air" 16 | dx = Q("10m") 17 | dy = Q("10m") 18 | dz = Q("10m") 19 | 20 | ############################################# 21 | ############################################# 22 | [DetectorEnclosure] 23 | class = ggdExample.DetectorEnclosure.Builder 24 | subbuilders = ["InactiveLayer", "ActiveLayer"] 25 | material = "Air" 26 | dx = Q("1m") 27 | dy = Q("1m") 28 | dz = Q("1m") 29 | repetitions = 25 30 | 31 | BField = "(3.0 T, 0.0 T, 0.0 G)" 32 | 33 | ############################################# 34 | ############################################# 35 | [ActiveLayer] 36 | class = ggdExample.DetectorLayer.Builder 37 | material = "Scintillator" 38 | dx = Q("50cm") 39 | dy = Q("50cm") 40 | dz = Q("1.75cm") 41 | Color = "blue" 42 | Opacity = "1.0" 43 | StepLimit = "1 mm" 44 | SensDet = "ActiveHits" 45 | 46 | ############################################# 47 | ############################################# 48 | [InactiveLayer] 49 | class = ggdExample.DetectorLayer.Builder 50 | material = "Lead" 51 | dx = Q("50cm") 52 | dy = Q("50cm") 53 | dz = Q("2.5mm") 54 | Color = "red" 55 | Opacity = "0.30" 56 | -------------------------------------------------------------------------------- /src/EDepSimDetectorMessenger.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_DetectorMessenger_h 2 | #define EDepSim_DetectorMessenger_h 1 3 | 4 | #include "globals.hh" 5 | #include "G4UImessenger.hh" 6 | 7 | namespace EDepSim {class UserDetectorConstruction;} 8 | class G4UIdirectory; 9 | class G4UIcmdWithAString; 10 | class G4UIcmdWithAnInteger; 11 | class G4UIcmdWithADoubleAndUnit; 12 | class G4UIcmdWithoutParameter; 13 | 14 | /// Handle the command line interface to change the geometry and other 15 | /// parameters associated with the EDepSim::m detector. 16 | namespace EDepSim {class DetectorMessenger;} 17 | class EDepSim::DetectorMessenger: public G4UImessenger { 18 | public: 19 | DetectorMessenger(EDepSim::UserDetectorConstruction*); 20 | virtual ~DetectorMessenger(); 21 | 22 | void SetNewValue(G4UIcommand*, G4String); 23 | 24 | private: 25 | EDepSim::UserDetectorConstruction* fConstruction; 26 | 27 | G4UIdirectory* fEDepSimDir; 28 | 29 | G4UIcmdWithoutParameter* fUpdateCmd; 30 | G4UIcmdWithAString* fPrintMassCmd; 31 | G4UIcmdWithoutParameter* fValidateCmd; 32 | G4UIcmdWithAString* fExportCmd; 33 | G4UIcommand* fControlCmd; 34 | G4UIcommand* fHitSagittaCmd; 35 | G4UIcommand* fHitSeparationCmd; 36 | G4UIcommand* fHitLengthCmd; 37 | G4UIcommand* fHitExcludedCmd; 38 | 39 | G4UIdirectory* fGDMLDir; 40 | G4UIcmdWithAString* fGDMLReadCmd; 41 | 42 | G4UIdirectory* fMaterialDir; 43 | G4UIcommand* fMaterialBirksCmd; 44 | 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/EDepSimPersistencyMessenger.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | 4 | #ifndef EDepSim_PersistencyMessenger_h 5 | #define EDepSim_PersistencyMessenger_h 1 6 | 7 | #include "G4UImessenger.hh" 8 | 9 | class G4UIdirectory; 10 | class G4UIcmdWithoutParameter; 11 | class G4UIcmdWithAString; 12 | class G4UIcmdWithABool; 13 | class G4UIcmdWithAnInteger; 14 | class G4UIcmdWithADoubleAndUnit; 15 | 16 | namespace EDepSim {class PersistencyManager;} 17 | 18 | namespace EDepSim {class PersistencyMessenger;} 19 | class EDepSim::PersistencyMessenger: public G4UImessenger { 20 | public: 21 | PersistencyMessenger(EDepSim::PersistencyManager* persistencyMgr); 22 | virtual ~PersistencyMessenger(); 23 | 24 | void SetNewValue(G4UIcommand* command,G4String newValues); 25 | G4String GetCurrentValue(G4UIcommand* command); 26 | 27 | private: 28 | EDepSim::PersistencyManager* fPersistencyManager; 29 | 30 | G4UIdirectory* fPersistencyDIR; 31 | G4UIdirectory* fPersistencySetDIR; 32 | G4UIcmdWithAString* fOpenCMD; 33 | G4UIcmdWithoutParameter* fCloseCMD; 34 | G4UIcmdWithADoubleAndUnit* fGammaThresholdCMD; 35 | G4UIcmdWithADoubleAndUnit* fNeutronThresholdCMD; 36 | G4UIcmdWithADoubleAndUnit* fLengthThresholdCMD; 37 | G4UIcmdWithABool* fSaveAllPrimaryTrajectoriesCMD; 38 | G4UIcmdWithADoubleAndUnit* fTrajectoryPointAccuracyCMD; 39 | G4UIcmdWithADoubleAndUnit* fTrajectoryPointDepositCMD; 40 | G4UIcmdWithAString* fTrajectoryBoundaryCMD; 41 | G4UIcmdWithoutParameter* fClearBoundariesCMD; 42 | 43 | }; 44 | #endif 45 | -------------------------------------------------------------------------------- /src/captain/mcaptain-inner-vessel-outer-surface.txt: -------------------------------------------------------------------------------- 1 | // Outer boundary of the miniCAPTAIN cryostat outer vessel hand digitized 2 | // using engauge on Nov 22, 2015 by Clark McGrew. The coordinates are 3 | // measured in millimeters with the top of the cryostat at -X, the bottom at 4 | // +X, and the diameter located along the Y axis. The X coordinate is 5 | // measured from the top of the flange with the nominal LAr surface located 9 6 | // inches (609.6 mm) below the flange. The first point is at the approximate 7 | // top of the outer vessel which is located right below the flange. 8 | // 9 | // COMMENT: This assumes that the lid and the flange are part of the inner 10 | // vessel. The outer vessel stops when it reaches the lower edge of the 11 | // flange. 12 | // 13 | // COMMENT: The makePolycone.py script will use this to produce a "close" 14 | // volume. The output needs to be edited by hand to remove the top point so 15 | // that the outer volume is open on top. 16 | 17 | -29.6058 1909.94 18 | 26.9933 1909.99 19 | 31.1646 1852.37 20 | 38.3789 1841.05 21 | 39.459 1787.54 22 | 806.119 1788.27 23 | 833.91 1782.12 24 | 858.619 1770.83 25 | 881.274 1754.38 26 | 918.358 1715.31 27 | 961.648 1643.32 28 | 1000.85 1538.39 29 | 1028.75 1424.19 30 | 1046.33 1327.48 31 | 1055.7 1219.43 32 | 1063.03 1084.63 33 | 1059.02 968.34 34 | 1049.86 864.395 35 | 1038.62 785.145 36 | 1020.17 704.86 37 | 993.51 605.014 38 | 965.791 536.04 39 | 934.975 476.324 40 | 889.748 421.74 41 | 858.899 397.013 42 | 834.212 385.669 43 | 806.43 382.556 44 | 40.799 381.826 45 | 39.8259 323.168 46 | 32.6302 314.928 47 | 27.5398 257.295 48 | -28.0303 257.242 49 | -29.8255 1060.95 50 | -------------------------------------------------------------------------------- /src/kinem/EDepSimCombinationGenerator.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_CombinationGenerator_hh_Seen 2 | #define EDepSim_CombinationGenerator_hh_Seen 3 | 4 | class G4Event; 5 | #include 6 | 7 | /// Copy the vertex position from the source to the destination 8 | /// G4PrimaryVertex object. This has the effect of making the particles in 9 | /// the vertices come from the same location (or vertex). This also has an 10 | /// option to set the position of the destination vertex relative to the 11 | /// source vertex. When this option is used, the source vertex position is 12 | /// added to the destination vertex (i.e. if the source vertex is [10,10,10] 13 | /// and the destination vertex is originally [1,1,1] the destination vertex 14 | /// becomes [11,11,11]. 15 | namespace EDepSim {class CombinationGenerator;} 16 | class EDepSim::CombinationGenerator: public G4VPrimaryGenerator { 17 | public: 18 | CombinationGenerator(int src, int dest, bool relative); 19 | virtual ~CombinationGenerator(); 20 | 21 | /// A pure virtual method to generate the actual primary particles which 22 | /// must be implemented in each derived class. 23 | virtual void GeneratePrimaryVertex(G4Event* evt); 24 | 25 | /// Return the name of this generator. 26 | G4String GetName(); 27 | 28 | private: 29 | /// The index of the source vertex to copy from. 30 | int fSource; 31 | 32 | /// The index of the destination vertex to copy to. 33 | int fDestination; 34 | 35 | /// A flag to indicate if the new vertex position is a direct copy of the 36 | /// source, or simply relative to the source. 37 | bool fRelative; 38 | }; 39 | #endif 40 | -------------------------------------------------------------------------------- /src/EDepSimTrajectoryMap.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_TrajectoryMap_hh_seen 2 | #define EDepSim_TrajectoryMap_hh_seen 3 | //////////////////////////////////////////////////////////// 4 | // $Id: EDepSim::TrajectoryMap.hh,v 1.1 2007/01/01 05:32:49 mcgrew Exp $ 5 | // 6 | 7 | #include 8 | 9 | class G4VTrajectory; 10 | 11 | /// Maintain a singleton map of track Id to the trajectory in the trajectory 12 | /// container. THIS IS NOT THREAD SAFE AND CAN NOT BE USED WITH MULTITHREAD 13 | /// GEANT4. 14 | namespace EDepSim {class TrajectoryMap;} 15 | class EDepSim::TrajectoryMap { 16 | public: 17 | ~TrajectoryMap() {} 18 | 19 | /// Provide a map between the track id and the trajectory object. 20 | static G4VTrajectory* Get(int trackId); 21 | 22 | /// Add a trajectory to the map. 23 | static void Add(G4VTrajectory* traj); 24 | 25 | /// Clear the trajectory map. This must be done in the 26 | /// EDepSim::UserEventAction::BeginOfEventAction() method. 27 | static void Clear(); 28 | 29 | /// Find the primary track ID for the current track. This is the primary 30 | /// that is the ultimate parent of the current track. 31 | static int FindPrimaryId(int trackId); 32 | 33 | private: 34 | /// A map to the trajectories information indexed the the track id. Be 35 | /// careful since the trajectory information is owned by the event, so if 36 | /// you try to use this after a trajectory has been deleted... bad things 37 | /// will happen. 38 | static std::map fMap; 39 | 40 | /// The constructor is private so that it can only be created using the 41 | /// static get method. 42 | TrajectoryMap() {} 43 | }; 44 | #endif 45 | -------------------------------------------------------------------------------- /src/captain/CaptPMTBuilder.hh: -------------------------------------------------------------------------------- 1 | #ifndef CaptPMTBuilder_hh_Seen 2 | #define CaptPMTBuilder_hh_Seen 3 | 4 | #include "EDepSimBuilder.hh" 5 | 6 | class G4LogicalVolume; 7 | 8 | /// Construct an unrotated PMT. In the local coordinate system, the 9 | /// PMT points along the positive Z direction. 10 | class CaptPMTBuilder : public EDepSim::Builder { 11 | public: 12 | CaptPMTBuilder(G4String name, EDepSim::Builder* parent) 13 | : EDepSim::Builder(name,parent) {Init();}; 14 | virtual ~CaptPMTBuilder(); 15 | 16 | /// Construct and return a G4 volume for the object. This is a pure 17 | /// virtual function, which means it must be implemented by the inheriting 18 | /// classes. This returns an unplaced logical volume which faces along 19 | /// the Z axis. 20 | virtual G4LogicalVolume *GetPiece(void); 21 | 22 | /// Get or set the length of the base. The base length measures from the 23 | /// face of the photocathode to the back of the PMT. 24 | /// @{ 25 | void SetBaseLength(double v) {fBaseLength = v;} 26 | double GetBaseLength() const {return fBaseLength;} 27 | /// @} 28 | 29 | /// Set the size of the PMT. 30 | /// @{ 31 | void SetSize(double v) {fSize = v;} 32 | double GetSize() const {return fSize;} 33 | /// @} 34 | 35 | /// Set that the PMT is round 36 | void SetRound(bool v) {fRoundPMT = v;} 37 | bool IsRound() const {return fRoundPMT;} 38 | 39 | private: 40 | void Init(void); 41 | 42 | /// The size of the PMT. 43 | double fSize; 44 | 45 | /// The length of the PMT base. 46 | double fBaseLength; 47 | 48 | /// Flag that the PMT is round (not square). 49 | bool fRoundPMT; 50 | 51 | }; 52 | #endif 53 | -------------------------------------------------------------------------------- /src/captain/CaptWorldBuilder.hh: -------------------------------------------------------------------------------- 1 | #ifndef CaptWorldBuilder_hh_Seen 2 | #define CaptWorldBuilder_hh_Seen 3 | 4 | #include "EDepSimBuilder.hh" 5 | 6 | class G4LogicalVolume; 7 | 8 | /// Construct the world volume. The origin is located at the center of the 9 | /// detector coordinate system. The world is mostly filled with air. 10 | class CaptWorldBuilder : public EDepSim::Builder { 11 | public: 12 | CaptWorldBuilder(G4String n, EDepSim::UserDetectorConstruction* c) 13 | : EDepSim::Builder(n,c) {Init();}; 14 | virtual ~CaptWorldBuilder(); 15 | 16 | /// Construct and return a G4 volume for the object. This is a pure 17 | /// virtual function, which means it must be implemented by the inheriting 18 | /// classes. This returns an unplaced logical volume which faces along 19 | /// the Z axis. 20 | virtual G4LogicalVolume *GetPiece(void); 21 | 22 | /// Set the length of the world 23 | void SetLength(double v) {fLength = v;} 24 | 25 | /// Set the width of the world 26 | void SetWidth(double v) {fWidth = v;} 27 | 28 | /// Set the height of the world 29 | void SetHeight(double v) {fHeight = v;} 30 | 31 | /// Get the length of the world 32 | double GetLength() {return fLength;} 33 | 34 | /// Get the width of the world 35 | double GetWidth() {return fWidth;} 36 | 37 | /// Get the height of the world 38 | double GetHeight() {return fHeight;} 39 | 40 | 41 | private: 42 | void Init(void); 43 | 44 | /// The distance along the X axis to simulate. 45 | double fLength; 46 | 47 | /// The side to side (Y) dimension to be simulated 48 | double fWidth; 49 | 50 | /// The height (Z) of the world coordinate system. 51 | double fHeight; 52 | 53 | }; 54 | #endif 55 | -------------------------------------------------------------------------------- /validate/fast-tests/100TestHEPEvt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Write a ROOT file in the default geometry. This output file should 4 | # be tested to make sure that all of the fields are readable. 5 | 6 | OUTPUT=100TestHEPEvt.root 7 | 8 | if [ -f ${OUTPUT} ]; then 9 | rm ${OUTPUT} 10 | fi 11 | 12 | cat > 100TestHEPEvt.txt < 100TestHEPEvt.mac < 5 | 6 | /// A base class used by ND20PrimaryGenerator to select the number of primary 7 | /// vertices to be generated for a G4Event. Classes derived from 8 | /// EDepSim::VCountGenerator are responsible for returning the number of 9 | /// successful calls to be made to the EDepSim::VKinematicsGenerator by the 10 | /// EDepSim::PrimaryGenerator object. Each call to EDepSim::VKinematicsGenerator will 11 | /// create a new "unique" primary vertex; however, it may result in multiple 12 | /// G4PrimaryVertex objects being added to the G4Event. The derived classes 13 | /// must override the (pure virtual) EDepSim::VCountGenerator::GetCount() object. 14 | /// This method must return an integer for the number of verticies to be 15 | /// generated. This count can be zero (or negative), in which case no 16 | /// verticies will be generated. 17 | namespace EDepSim {class VCountGenerator;} 18 | class EDepSim::VCountGenerator { 19 | public: 20 | VCountGenerator(const G4String& name, double intensity) 21 | : fName(name), fIntensity(intensity) {} 22 | virtual ~VCountGenerator() {} 23 | 24 | /// Return the number of events that should be generated. If the return 25 | /// value is less than or equal to zero, then no events are generated. 26 | virtual int GetCount() = 0; 27 | 28 | /// Return the name of the generator. 29 | G4String GetName() const {return fName;} 30 | 31 | /// Return the intensity for this generator. For a beam MC, this will be 32 | /// the number of protons per pulse. 33 | double GetIntensity() const {return fIntensity;} 34 | 35 | private: 36 | /// The name of the generator. 37 | G4String fName; 38 | 39 | /// The intensity for the generator. 40 | double fIntensity; 41 | 42 | }; 43 | #endif 44 | -------------------------------------------------------------------------------- /src/captain/CaptExposedBuilder.hh: -------------------------------------------------------------------------------- 1 | #ifndef CaptExposedBuilder_hh_Seen 2 | #define CaptExposedBuilder_hh_Seen 3 | 4 | #include "EDepSimBuilder.hh" 5 | class G4LogicalVolume; 6 | 7 | #include 8 | 9 | /// Construct the exposed part of the CAPTAIN detector. This builds exposed 10 | /// parts of the TPC that are in the argon gas. The exposed volume is 11 | /// returned as a cylinder filled with liquid argon. 12 | class CaptExposedBuilder : public EDepSim::Builder { 13 | public: 14 | CaptExposedBuilder(G4String name, EDepSim::Builder* parent) 15 | : EDepSim::Builder(name,parent) {Init();}; 16 | virtual ~CaptExposedBuilder(); 17 | 18 | /// Construct and return a G4 volume for the object. This is a pure 19 | /// virtual function, which means it must be implemented by the inheriting 20 | /// classes. This returns an unplaced logical volume which faces along 21 | /// the Z axis. 22 | virtual G4LogicalVolume *GetPiece(void); 23 | 24 | /// Return the offset of the intended origin of the volume relative to the 25 | /// center of the logical volume. To get the origin at the right location 26 | /// (say originPosition), the logical volume should be positioned at 27 | /// originPosition-GetOffset(). The offset is defined by the bottom of 28 | /// the wire plane assembly (a decision will be made in the future as to 29 | /// whether this is the bottom of the grid, or the bottom of the V plane. 30 | /// This means that the wires for the V plane are at a (very) small 31 | /// positive z coordinate. 32 | G4ThreeVector GetOffset() {return fOffset;} 33 | 34 | /// Get the radius of the exposed region. This is calculated. 35 | double GetRadius(); 36 | 37 | /// Get the height of the exposed region. This is calculated. 38 | double GetHeight(); 39 | 40 | private: 41 | void Init(void); 42 | 43 | G4ThreeVector fOffset; 44 | }; 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /validate/fast-tests/110TestHEPEvtFlavors.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Demonstrates the usage of the HEPEvt reader. This 4 | # example uses the ParticleBomb ("pbomb") input flavor. 5 | 6 | OUTPUT=110TestHEPEvtFlavors.root 7 | # Modify the following line if using gdml file 8 | #GEOM=my_geometry.gdml 9 | 10 | if [ -f ${OUTPUT} ]; then 11 | rm ${OUTPUT} 12 | fi 13 | 14 | ## Create macro file 15 | # Header line: event ID, vertex ID, no. particles in that vertex, 16 | # and vertex (x,y,z,t) 17 | # Particle lines: status code, PDG code, first mother, second mother, 18 | # first daughter, second daughter, px, py, pz, E, and mass 19 | cat > 110TestHEPEvtFlavors.txt < 110TestHEPEvtFlavors.mac < 8 | 9 | /// Construct the exposed part of the miniCAPTAIN detector. This builds 10 | /// exposed parts of the TPC that are in the argon gas. The exposed volume is 11 | /// returned as a cylinder filled with liquid argon. 12 | class MiniCaptExposedBuilder : public EDepSim::Builder { 13 | public: 14 | MiniCaptExposedBuilder(G4String name, EDepSim::Builder* parent) 15 | : EDepSim::Builder(name,parent) {Init();}; 16 | virtual ~MiniCaptExposedBuilder(); 17 | 18 | /// Construct and return a G4 volume for the object. This is a pure 19 | /// virtual function, which means it must be implemented by the inheriting 20 | /// classes. This returns an unplaced logical volume which faces along 21 | /// the Z axis. 22 | virtual G4LogicalVolume *GetPiece(void); 23 | 24 | /// Return the offset of the intended origin of the volume relative to the 25 | /// center of the logical volume. To get the origin at the right location 26 | /// (say originPosition), the logical volume should be positioned at 27 | /// originPosition-GetOffset(). The offset is defined by the bottom of 28 | /// the wire plane assembly (a decision will be made in the future as to 29 | /// whether this is the bottom of the grid, or the bottom of the V plane. 30 | /// This means that the wires for the V plane are at a (very) small 31 | /// positive z coordinate. 32 | G4ThreeVector GetOffset() {return fOffset;} 33 | 34 | /// Get the radius of the exposed region. This is calculated. 35 | double GetRadius(); 36 | 37 | /// Get the height of the exposed region. This is calculated. 38 | double GetHeight(); 39 | 40 | private: 41 | void Init(void); 42 | 43 | G4ThreeVector fOffset; 44 | }; 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /src/kinem/EDepSimVTimeGenerator.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_VTimeGenerator_hh_seen 2 | #define EDepSim_VTimeGenerator_hh_seen 3 | 4 | #include 5 | #include 6 | 7 | /// A base class used by ND20PrimaryGenerator to select candiate vertex times. 8 | /// Classes derived from EDepSim::VTimeGenerator are responsible for returning new 9 | /// candidate times that are passed to EDepSim::VKinematicsGenerator by the 10 | /// EDepSim::PrimaryGenerator object. Each call to EDepSim::VKinematicsGenerator will 11 | /// create a new "unique" primary vertex; however, it may ignore the candidate 12 | /// time. The derived classes must override two (pure virtual) 13 | /// EDepSim::VTimeGenerator methods. The EDepSim::VTimeGenerator::GetTime() must 14 | /// return the time which is used to fill the time component of a 15 | /// G4LorentzVector. It takes the candidate vertex position generated by the 16 | /// EDepSim::VPositionGenerator object so that it can correct for time of flight. 17 | /// The EDepSim::VTimeGenerator::ForceTime() method must return a boolean to flag 18 | /// whether the EDepSim::PrimaryGenerator should override the time selected by 19 | /// EDepSim::VKinematicsGenerator with the one returned by 20 | /// EDepSim::VTimeGenerator::GetTime(). The ForceTime method should generally 21 | /// return true. 22 | namespace EDepSim {class VTimeGenerator;} 23 | class EDepSim::VTimeGenerator { 24 | public: 25 | VTimeGenerator(const G4String& name) : fName(name) {} 26 | virtual ~VTimeGenerator() {} 27 | 28 | /// Return the time of the primary vertex. 29 | virtual double GetTime(const G4LorentzVector& vertex) = 0; 30 | 31 | /// Return true if this time should be forced for the primary vertex. 32 | virtual bool ForceTime() = 0; 33 | 34 | /// Return the name of the generator. 35 | G4String GetName() const {return fName;} 36 | 37 | private: 38 | /// The name of the generator. 39 | G4String fName; 40 | }; 41 | #endif 42 | -------------------------------------------------------------------------------- /src/EDepSimExtraPhysics.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_ExtraPhysics_hh_seen 2 | #define EDepSim_ExtraPhysics_hh_seen 3 | //////////////////////////////////////////////////////////// 4 | // $Id: EDepSim::ExtraPhysics.hh,v 1.1 2007/01/19 20:35:22 mcgrew Exp $ 5 | //////////////////////////////////////////////////////////// 6 | 7 | #include "globals.hh" 8 | 9 | #include "G4VPhysicsConstructor.hh" 10 | 11 | /// A G4VPhysicsConstructor to provide extra physics processes required by 12 | /// detSim such as step length limiters. The extra physics processes must be 13 | /// explicitly added to every physics list (as an EM list) that is created in 14 | /// EDepSim::PhysicsList::AddPhysicsList(); however, this only effects code 15 | /// actually in that method. This class should not be used outside of 16 | /// EDepSim::PhysicsList. Once this is defined, the step length can be limited in 17 | /// logical volumes as they are created by calling 18 | /// G4LogicalVolume::SetUsersLimits(new G4UserLimits(stepLength)). 19 | namespace EDepSim {class ExtraPhysics;} 20 | class EDepSim::ExtraPhysics: public G4VPhysicsConstructor { 21 | public: 22 | 23 | /// Construct the extra physics lists. The argument is the default 24 | /// recombination for argon. If the value is negative, then use NEST. 25 | explicit ExtraPhysics(); 26 | virtual ~ExtraPhysics(); 27 | 28 | virtual void ConstructParticle(); 29 | virtual void ConstructProcess(); 30 | 31 | /// Set the ionization model to be use. The ionization model calculates 32 | /// the amount of total deposited energy that will be visible as 33 | /// ionization. Because of how G4 works, the total energy deposited and 34 | /// the non-ionization energy are tabulated. The implemented models are: 35 | /// 0) Use NEST to make a detailed calculation. 1) Use 36 | /// EDepSim::SimpleScintillation to make a quick calculation. 37 | void SetIonizationModel(int m) {fIonizationModel=m;} 38 | 39 | private: 40 | 41 | int fIonizationModel; 42 | }; 43 | #endif 44 | -------------------------------------------------------------------------------- /src/kinem/EDepSimSpillTimeGenerator.cc: -------------------------------------------------------------------------------- 1 | #include "kinem/EDepSimVTimeGenerator.hh" 2 | #include "kinem/EDepSimSpillTimeGenerator.hh" 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | EDepSim::SpillTimeGenerator::SpillTimeGenerator( 10 | G4String name, double spillTime, double bunchSeparation, 11 | double bunchLength, const std::vector& bunchPower) 12 | : EDepSim::VTimeGenerator(name), fSpillTime(spillTime), 13 | fBunchSeparation(bunchSeparation), fBunchLength(bunchLength), 14 | fBunchPower(bunchPower) { 15 | if (fBunchPower.size()<1) fBunchPower.push_back(1.0); 16 | fMaxPower = 0.0; 17 | for (std::vector::iterator b = fBunchPower.begin(); 18 | b != fBunchPower.end(); 19 | ++b) { 20 | if (fMaxPower<(*b)) fMaxPower = *b; 21 | } 22 | 23 | if (fMaxPower<0.001) { 24 | EDepSimError("Spill created without any power in bunchs"); 25 | } 26 | } 27 | 28 | EDepSim::SpillTimeGenerator::~SpillTimeGenerator() {} 29 | 30 | double EDepSim::SpillTimeGenerator::GetTime(const G4LorentzVector& vtx) { 31 | // Choose a spill; 32 | int spills = fBunchPower.size(); 33 | int spill = 0; 34 | do { 35 | spill = int(spills*G4UniformRand()); 36 | if (spill>=spills) spill=spills-1; 37 | if (spill<0) spill = 0; 38 | } while (fBunchPower[spill] 2.0) { 47 | truncTime = G4RandGauss::shoot(0.0, 1.0); 48 | } 49 | time += fBunchLength*truncTime; 50 | 51 | return time; 52 | } 53 | 54 | bool EDepSim::SpillTimeGenerator::ForceTime() { 55 | return true; 56 | } 57 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | message("Energy Deposition Simulation") 2 | 3 | # Suck up all of the .cc files for the source. This isn't good CMAKE 4 | # practice, but it makes maintaining this file easier. 5 | # file(GLOB_RECURSE source *.cc) 6 | # file(GLOB_RECURSE includes EDepSim*.hh) 7 | file(GLOB edep_source *.cc) 8 | file(GLOB edep_includes *.cc) 9 | file(GLOB captain_source captain/*.cc) 10 | file(GLOB captain_includes captain/EDepSim*.hh) 11 | file(GLOB kinem_source kinem/*.cc) 12 | file(GLOB kinem_includes kinem/EDepSim*.hh) 13 | 14 | if(EDEPSIM_USE_NEST) 15 | file(GLOB nest_source NESTVersion098/*.cc) 16 | file(GLOB nest_includes NESTVersion098/EDepSim*.hh) 17 | else(EDEPSIM_USE_NEST) 18 | message("Not including NEST in the compilation") 19 | add_definitions(-DEDEPSIM_SKIP_NESTVersion098) 20 | endif(EDEPSIM_USE_NEST) 21 | 22 | set(source ${edep_source} ${captain_source} ${kinem_source} ${nest_source}) 23 | set(includes ${edep_includes} ${captain_includes} ${kinem_includes}) 24 | 25 | # Where the macro files can be found. 26 | add_definitions(-DDETSIM_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\") 27 | 28 | # Compile the base library with private I/O fields. 29 | add_definitions(-DEDEPSIM_FORCE_PRIVATE_FIELDS) 30 | 31 | # Build the library. 32 | add_library(edepsim SHARED ${source}) 33 | 34 | target_include_directories(edepsim PUBLIC 35 | "$" 36 | "$" 37 | "$") 38 | 39 | target_link_libraries(edepsim PUBLIC 40 | edepsim_io ${Geant4_LIBRARIES} ${ROOT_LIBRARIES}) 41 | 42 | # Install the G4 macro files used to control the MC. 43 | install(FILES edepsim-defaults-1.0.mac DESTINATION lib/EDepSim) 44 | 45 | # Install the library for edep-sim 46 | install(TARGETS edepsim 47 | EXPORT EDepSimTargets 48 | LIBRARY DESTINATION lib 49 | RUNTIME DESTINATION bin 50 | INCLUDES DESTINATION include/EDepSim ) 51 | 52 | # Install the header files. 53 | install(FILES ${includes} DESTINATION include/EDepSim) 54 | -------------------------------------------------------------------------------- /src/kinem/EDepSimVPositionGenerator.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_VPositionGenerator_hh_seen 2 | #define EDepSim_VPositionGenerator_hh_seen 3 | 4 | #include 5 | #include 6 | 7 | /// A base class used by ND20PrimaryGenerator to select candiate vertex 8 | /// positions. Classes derived from EDepSim::VPositionGenerator are responsible 9 | /// for returning new candidate positions that are passed to 10 | /// EDepSim::VKinematicsGenerator by the EDepSim::PrimaryGenerator object. Each call 11 | /// to EDepSim::VKinematicsGenerator will create a new "unique" primary vertex; 12 | /// however, it may ignore the candidate position. The derived classes must 13 | /// override two (pure virtual) EDepSim::VPositionGenerator methods. The 14 | /// EDepSim::VPositionGenerator::GetPosition() must return a G4LorentzVector 15 | /// object which the xyz components filled. The time component will be filled 16 | /// later by a EDepSim::VTimeGenerator derived object. The 17 | /// EDepSim::VPosition::ForcePosition() method must return a boolean to flag 18 | /// whether the EDepSim::PrimaryGenerator should override the position selected by 19 | /// EDepSim::VKinematicsGenerator with the one returned by 20 | /// EDepSim::VPositionGenerator::GetPosition(). The ForcePosition methods should 21 | /// generally return true. 22 | namespace EDepSim {class VPositionGenerator;} 23 | class EDepSim::VPositionGenerator { 24 | public: 25 | VPositionGenerator(const G4String& name) : fName(name) {} 26 | virtual ~VPositionGenerator() {} 27 | 28 | /// Return the candidate position for the primary vertex. 29 | virtual G4LorentzVector GetPosition() = 0; 30 | 31 | /// Return true if this position should be forced for the primary vertex 32 | /// (should generally return true). 33 | virtual bool ForcePosition() = 0; 34 | 35 | /// Return the name of the generator. 36 | G4String GetName() const {return fName;} 37 | 38 | private: 39 | /// The name of the generator. 40 | G4String fName; 41 | 42 | }; 43 | #endif 44 | -------------------------------------------------------------------------------- /src/captain/CaptImmersedBuilder.hh: -------------------------------------------------------------------------------- 1 | #ifndef CaptImmersedBuilder_hh_Seen 2 | #define CaptImmersedBuilder_hh_Seen 3 | 4 | #include "EDepSimBuilder.hh" 5 | class G4LogicalVolume; 6 | 7 | #include 8 | 9 | /// Construct the exposed part of the CAPTAIN detector. This builds exposed 10 | /// parts of the TPC that are in the argon gas. The exposed volume is 11 | /// returned as a cylinder filled with liquid argon. 12 | class CaptImmersedBuilder : public EDepSim::Builder { 13 | public: 14 | CaptImmersedBuilder(G4String name, EDepSim::Builder* parent) 15 | : EDepSim::Builder(name,parent) {Init();}; 16 | virtual ~CaptImmersedBuilder(); 17 | 18 | /// Construct and return a G4 volume for the object. This is a pure 19 | /// virtual function, which means it must be implemented by the inheriting 20 | /// classes. This returns an unplaced logical volume which faces along 21 | /// the Z axis. 22 | virtual G4LogicalVolume *GetPiece(void); 23 | 24 | /// Return the offset of the intended origin of the volume relative to the 25 | /// center of the logical volume. To get the origin at the right location 26 | /// (say originPosition), the logical volume should be positioned at 27 | /// originPosition-GetOffset(). The offset is defined by the bottom of 28 | /// the wire plane assembly (a decision will be made in the future as to 29 | /// whether this is the bottom of the grid, or the bottom of the V plane. 30 | /// This means that the wires for the V plane are at a (very) small 31 | /// positive z coordinate. 32 | G4ThreeVector GetOffset() {return fOffset;} 33 | 34 | /// Get the radius of the exposed region. This is calculated. 35 | double GetRadius(); 36 | 37 | /// Get the height of the exposed region. This is calculated. 38 | double GetHeight(); 39 | 40 | private: 41 | void Init(void); 42 | 43 | /// The offset of the exposed part of the TPC. This is calculated during 44 | /// GetPiece. 45 | G4ThreeVector fOffset; 46 | 47 | }; 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /test/ggdExample/DetectorLayer.py: -------------------------------------------------------------------------------- 1 | import gegede.builder 2 | from gegede import Quantity as Q 3 | 4 | class Builder(gegede.builder.Builder): 5 | ''' 6 | Build a single layer of the detector. 7 | material -- The material used to build the detector enclosure. 8 | dx, dy, dz -- The half size of the layer box. 9 | 10 | Remaining configuration parameters are added to the logical 11 | volume as pairs. 12 | ''' 13 | 14 | def configure(self, 15 | material = "Air", 16 | dx = Q("50cm"), 17 | dy = Q("50cm"), 18 | dz = Q("1cm"), 19 | **kwds): 20 | print("Configuring a detector layer " + self.name) 21 | self.material = material 22 | self.dx = dx 23 | self.dy = dy 24 | self.dz = dz 25 | self.otherKeywords = kwds 26 | pass 27 | 28 | def construct(self, geom): 29 | print("Constructing a detector layer " + self.name) 30 | 31 | ## Build the volume for this layer. The conventions are that 32 | ## the shape name ends in "_shape", and the volume name ends 33 | ## in "_LV". This reflects what is going to be build in 34 | ## GEANT4 (a G4Shape and a G4LogicalVolume). 35 | ## 36 | ## The shape and volume names need to be unique inside the 37 | ## GDML file. 38 | shape = geom.shapes.Box(self.name + "_shape", 39 | self.dx, self.dy, self.dz) 40 | volume = geom.structure.Volume(self.name + "_LV", 41 | 42 | material = self.material, 43 | shape = shape) 44 | 45 | ## Add the constructed volume to the builder. 46 | self.add_volume(volume) 47 | 48 | ## Add the aux type and aux values fields to the logical volume. 49 | for n, v in self.otherKeywords.items(): 50 | volume.params.append((n,v)) 51 | 52 | pass 53 | -------------------------------------------------------------------------------- /PackageConfig.cmake.in: -------------------------------------------------------------------------------- 1 | ########################## 2 | # A template for a Config.cmake that can be found by using 3 | # the find_package macro. This should be modified to import all of 4 | # the dependencies required by the local package. The template is 5 | # fairly generic, except for the "find_package" related code between 6 | # the beginning and ending boiler plate. 7 | # 8 | # This expect that any targets that are being exported will be 9 | # installed using a command like 10 | # 11 | # install(TARGETS myTarget 12 | # EXPORT Targets 13 | # etc) 14 | # 15 | # Note that the is set in the project( ) macro 16 | # that should be at the start of your top level CMakeLists.txt 17 | ########################## 18 | 19 | ############# BOILER PLATE 20 | # Include the cmake boiler plate. The next line should not be touched 21 | @PACKAGE_INIT@ 22 | ############# END BOILER PLATE 23 | 24 | ########################## 25 | # Add any specific packages that the current package depends on. This is 26 | # where the find_package commands needed to make the current package 27 | # compile should be listed. 28 | ########################## 29 | 30 | # EDepSim requires ROOT 31 | find_package(ROOT REQUIRED 32 | COMPONENTS Geom Physics Matrix MathCore Tree RIO) 33 | if(ROOT_FOUND) 34 | include(${ROOT_USE_FILE}) 35 | endif(ROOT_FOUND) 36 | 37 | # EDepSim needs GEANT4 if EDEPSIM_READONLY is not set to TRUE (usually it's 38 | # TRUE). 39 | if(NOT @EDEPSIM_READONLY@) 40 | find_package(Geant4 @Geant4_VERSION@ REQUIRED) 41 | if(Geant4_FOUND) 42 | include(${Geant4_USE_FILE}) 43 | endif(Geant4_FOUND) 44 | endif(NOT @EDEPSIM_READONLY@) 45 | 46 | ######################### 47 | # Leave the next couple of lines alone since it will automatically customize 48 | # for your package. 49 | ######################### 50 | 51 | ############# BOILER PLATE 52 | include("@CMAKE_INSTALL_PREFIX@/lib/cmake/@PROJECT_NAME@/@PROJECT_NAME@Targets.cmake") 53 | check_required_components("@PROJECT_NAME@") 54 | ############# END BOILER PLATE 55 | -------------------------------------------------------------------------------- /src/captain/MiniCaptImmersedBuilder.hh: -------------------------------------------------------------------------------- 1 | #ifndef MiniCaptImmersedBuilder_hh_Seen 2 | #define MiniCaptImmersedBuilder_hh_Seen 3 | 4 | #include "EDepSimBuilder.hh" 5 | class G4LogicalVolume; 6 | 7 | #include 8 | 9 | /// Construct the immersed part of the mini CAPTAIN detector. This builds 10 | /// immersed parts of the TPC that are in the argon liquid. The exposed 11 | /// volume is returned as a cylinder filled with liquid argon. 12 | class MiniCaptImmersedBuilder : public EDepSim::Builder { 13 | public: 14 | MiniCaptImmersedBuilder(G4String name, EDepSim::Builder* parent) 15 | : EDepSim::Builder(name,parent) {Init();}; 16 | virtual ~MiniCaptImmersedBuilder(); 17 | 18 | /// Construct and return a G4 volume for the object. This is a pure 19 | /// virtual function, which means it must be implemented by the inheriting 20 | /// classes. This returns an unplaced logical volume which faces along 21 | /// the Z axis. 22 | virtual G4LogicalVolume *GetPiece(void); 23 | 24 | /// Return the offset of the intended origin of the volume relative to the 25 | /// center of the logical volume. To get the origin at the right location 26 | /// (say originPosition), the logical volume should be positioned at 27 | /// originPosition-GetOffset(). The offset is defined by the bottom of 28 | /// the wire plane assembly (a decision will be made in the future as to 29 | /// whether this is the bottom of the grid, or the bottom of the V plane. 30 | /// This means that the wires for the V plane are at a (very) small 31 | /// positive z coordinate. 32 | G4ThreeVector GetOffset() {return fOffset;} 33 | 34 | /// Get the radius of the exposed region. This is calculated. 35 | double GetRadius(); 36 | 37 | /// Get the height of the exposed region. This is calculated. 38 | double GetHeight(); 39 | 40 | private: 41 | void Init(void); 42 | 43 | /// The offset of the exposed part of the TPC. This is calculated during 44 | /// GetPiece. 45 | G4ThreeVector fOffset; 46 | 47 | }; 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /src/EDepSimTrajectoryMap.cc: -------------------------------------------------------------------------------- 1 | #include "EDepSimTrajectoryMap.hh" 2 | #include "EDepSimTrajectory.hh" 3 | #include "EDepSimException.hh" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | std::map EDepSim::TrajectoryMap::fMap; 12 | 13 | void EDepSim::TrajectoryMap::Clear() { 14 | fMap.clear(); 15 | } 16 | 17 | void EDepSim::TrajectoryMap::Add(G4VTrajectory* traj) { 18 | int trackId = traj->GetTrackID(); 19 | fMap[trackId] = traj; 20 | } 21 | 22 | int EDepSim::TrajectoryMap::FindPrimaryId(int trackId) { 23 | int currentId = trackId; 24 | int parentId = trackId; 25 | int loopCount=0; 26 | for (loopCount=0;loopCount<10000;++loopCount) { 27 | G4VTrajectory* t = Get(currentId); 28 | if (!t) break; 29 | parentId = t->GetParentID(); 30 | // Check to see the search loop should terminate. 31 | G4VTrajectory* p = Get(parentId); 32 | // There is no parent so break so this is a primary trajectory. 33 | if (!p) break; 34 | // Decay products are primary trajectories since they should be 35 | // independently reconstructed 36 | EDepSim::Trajectory * edepTraj = dynamic_cast(t); 37 | if (!edepTraj) EDepSimThrow("Invalid Trajectory"); 38 | if (edepTraj->GetProcessName() == "Decay") break; 39 | // A parent ID of zero means that this particle is a primary particle, 40 | // so that makes it a primary trajectory too. 41 | if (parentId == 0) break; 42 | currentId = parentId; 43 | } 44 | if (loopCount>9999) { 45 | EDepSimLog("Infinite Loop in EDepSim::TrajectoryMap::FindPrimaryId(): " 46 | << "Track Id: " << trackId); 47 | } 48 | 49 | return currentId; 50 | } 51 | 52 | G4VTrajectory* EDepSim::TrajectoryMap::Get(int trackId) { 53 | std::map::iterator t = fMap.find(trackId); 54 | if (t == fMap.end()) { 55 | return NULL; 56 | } 57 | return t->second; 58 | } 59 | 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This software comprises of portions covered different licenses: 2 | 3 | 1) The portions derived from GEANT4 are distributed under the GEANT4 4 | software license reproduced in the "licenses" subdirectory. 5 | 6 | 2) The portions derived from NEST are distributed under the NEST software 7 | license reproduced in the "licenses" subdirectory. 8 | 9 | 3) The software presented here mostly comes from software I 10 | authored and contributed to multiple HEP collaborations. To the best 11 | of my knowledge, all of the code can be freely distributed for (at 12 | least) academic purposes. If you find portions of code in this 13 | distribution that I have misattributed, please contact me for proper 14 | attribution. 15 | 16 | 4) It is requested, but not required, that any discussion using the EDepSim 17 | source acknowledge its use. 18 | 19 | 5) The portions unique to this distribution, and which are not otherwise 20 | attributed, are distributed under the license below. 21 | 22 | MIT License 23 | 24 | Copyright (c) 2018, 2020, 2021 Clark McGrew 25 | 26 | Permission is hereby granted, free of charge, to any person obtaining a copy 27 | of this software and associated documentation files (the "Software"), to deal 28 | in the Software without restriction, including without limitation the rights 29 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 30 | copies of the Software, and to permit persons to whom the Software is 31 | furnished to do so, subject to the following conditions: 32 | 33 | The above copyright notice and this permission notice shall be included in all 34 | copies or substantial portions of the Software. 35 | 36 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 37 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 38 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 39 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 40 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 41 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 42 | SOFTWARE. 43 | -------------------------------------------------------------------------------- /src/captain/MiniCaptExposedBuilder.cc: -------------------------------------------------------------------------------- 1 | #include "MiniCaptExposedBuilder.hh" 2 | 3 | #include "EDepSimBuilder.hh" 4 | 5 | #include "EDepSimLog.hh" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | class MiniCaptExposedMessenger 20 | : public EDepSim::BuilderMessenger { 21 | private: 22 | MiniCaptExposedBuilder* fBuilder; 23 | 24 | public: 25 | MiniCaptExposedMessenger(MiniCaptExposedBuilder* c) 26 | : EDepSim::BuilderMessenger(c,"Control the exposed geometry."), 27 | fBuilder(c) {}; 28 | 29 | virtual ~MiniCaptExposedMessenger() {}; 30 | 31 | void SetNewValue(G4UIcommand *cmd, G4String val) { 32 | EDepSim::BuilderMessenger::SetNewValue(cmd,val); 33 | }; 34 | }; 35 | 36 | void MiniCaptExposedBuilder::Init(void) { 37 | SetMessenger(new MiniCaptExposedMessenger(this)); 38 | } 39 | 40 | MiniCaptExposedBuilder::~MiniCaptExposedBuilder() {} 41 | 42 | double MiniCaptExposedBuilder::GetRadius() { 43 | return 65*CLHEP::cm; 44 | } 45 | 46 | double MiniCaptExposedBuilder::GetHeight() { 47 | return 3*CLHEP::cm; 48 | } 49 | 50 | G4LogicalVolume *MiniCaptExposedBuilder::GetPiece(void) { 51 | 52 | #ifdef MAKE_EMPTY_EXPOSED 53 | G4LogicalVolume* logVolume 54 | = new G4LogicalVolume(new G4Tubs(GetName(), 55 | 0.0, GetRadius(), GetHeight()/2, 56 | 0*degree, 360*degree), 57 | FindMaterial("Argon_Gas"), 58 | GetName()); 59 | logVolume->SetVisAttributes(GetColor(logVolume)); 60 | 61 | G4ThreeVector center(0.0,0.0,-GetHeight()/2); 62 | fOffset = center; 63 | 64 | /// All the space above the drift region. 65 | center += G4ThreeVector(0.0,0.0,0.0); 66 | #else 67 | G4LogicalVolume* logVolume = NULL; 68 | #endif 69 | 70 | return logVolume; 71 | } 72 | -------------------------------------------------------------------------------- /src/captain/captain-outer-vessel-outer-boundary.txt: -------------------------------------------------------------------------------- 1 | // Outer boundary of the CAPTAIN cryostat outer vessel hand digitized using 2 | // engauge on Nov 20, 2015 by Clark McGrew. The coordinates are measured in 3 | // millimeters with the top of the cryostat at -X, the bottom at +X, and the 4 | // diameter located along the Y axis. The X coordinate is measured from the 5 | // top of the flange with the nominal LAr surface located 24 inches (609.6 mm) 6 | // below the flange. The first point is at the approximate top of the outer 7 | // vessel which is located right below the flange. 8 | // 9 | // COMMENT: This assumes that the lid and the flange are part of the inner 10 | // vessel. The outer vessel stops when it reaches the lower edge of the 11 | // flange. 12 | // 13 | // COMMENT: The makePolycone.py script will use this to produce a "close" 14 | // volume. The output needs to be edited by hand to remove the top point so 15 | // that the outer volume is open on top. 16 | 17 | 40.1097 -654.354 0 18 | 1851.05 -658.06 1 19 | 1877 -659.94 2 20 | 1901.09 -665.525 3 21 | 1923.32 -676.669 4 22 | 1943.7 -687.812 5 23 | 1964.07 -706.368 6 24 | 1980.73 -724.921 7 25 | 1995.54 -747.179 8 26 | 2014.04 -786.123 9 27 | 2039.94 -836.196 10 28 | 2060.28 -880.703 11 29 | 2078.77 -921.501 12 30 | 2108.35 -995.674 13 31 | 2139.78 -1077.26 14 32 | 2171.21 -1162.56 15 33 | 2189.68 -1221.89 16 34 | 2213.69 -1303.48 17 35 | 2237.69 -1399.89 18 36 | 2257.98 -1494.44 19 37 | 2274.57 -1590.84 20 38 | 2287.45 -1681.68 21 39 | 2294.78 -1765.1 22 40 | 2305.76 -1902.28 23 41 | 2307.5 -2017.2 24 42 | 2303.67 -2133.97 25 43 | 2292.37 -2308.2 26 44 | 2275.56 -2436.08 27 45 | 2253.19 -2558.39 28 46 | 2225.26 -2682.55 29 47 | 2202.93 -2765.94 30 48 | 2186.19 -2821.53 31 49 | 2163.88 -2891.94 32 50 | 2137.85 -2964.2 33 51 | 2113.7 -3021.64 34 52 | 2095.11 -3071.67 35 53 | 2074.67 -3119.84 36 54 | 2056.09 -3160.6 37 55 | 2041.23 -3192.1 38 56 | 2022.66 -3225.44 39 57 | 2011.51 -3253.23 40 58 | 1994.8 -3282.87 41 59 | 1978.09 -3312.51 42 60 | 1957.68 -3332.88 43 61 | 1935.42 -3351.4 44 62 | 1913.16 -3362.49 45 63 | 1894.62 -3369.89 46 64 | 1879.79 -3373.58 47 65 | 1868.66 -3375.42 48 66 | 1853.83 -3379.12 49 67 | 37.3255 -3377.26 50 68 | -------------------------------------------------------------------------------- /io/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | message("Energy Deposition Display") 2 | 3 | # Set the default verbosity of the compilation... 4 | # set(CMAKE_VERBOSE_MAKEFILE TRUE) 5 | 6 | # Configure the dependencies 7 | find_package(ROOT REQUIRED 8 | COMPONENTS Geom Physics Matrix MathCore Tree RIO) 9 | if(ROOT_FOUND) 10 | include(${ROOT_USE_FILE}) 11 | endif(ROOT_FOUND) 12 | 13 | # Define the source that should be used for the io part of edep-sim. 14 | set(source 15 | TG4PrimaryVertex.cxx 16 | TG4Trajectory.cxx 17 | TG4HitSegment.cxx 18 | TG4Event.cxx) 19 | 20 | set(includes 21 | TG4PrimaryVertex.h 22 | TG4Trajectory.h 23 | TG4HitSegment.h 24 | TG4Event.h) 25 | 26 | # Compile the base library with private I/O fields. 27 | add_definitions(-DEDEPSIM_FORCE_PRIVATE_FIELDS) 28 | 29 | # Make sure the current directories are available for the later 30 | # compilation. This is required to make ROOT_GENERATE_DICTIONARY 31 | # work. 32 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 33 | 34 | # Build the dictionary for the i/o classes. 35 | ROOT_GENERATE_DICTIONARY(G__edepsim_io 36 | TG4PrimaryVertex.h TG4Trajectory.h TG4HitSegment.h TG4Event.h 37 | OPTIONS -inlineInputHeader 38 | LINKDEF edepsim_io_LinkDef.h) 39 | 40 | # Build the library. 41 | add_library(edepsim_io SHARED ${source} G__edepsim_io.cxx) 42 | 43 | target_include_directories(edepsim_io PUBLIC 44 | "$" 45 | "$") 46 | 47 | target_link_libraries(edepsim_io PUBLIC ${ROOT_LIBRARIES}) 48 | 49 | # Install the library for edep-sim 50 | install(TARGETS edepsim_io 51 | EXPORT EDepSimTargets 52 | LIBRARY DESTINATION lib 53 | RUNTIME DESTINATION bin 54 | INCLUDES DESTINATION include/EDepSim ) 55 | 56 | # Install the header files. 57 | install(FILES ${includes} DESTINATION include/EDepSim) 58 | 59 | # If this is ROOT6 or later, then install the rootmap and pcm files. 60 | if(${ROOT_VERSION} VERSION_GREATER 6) 61 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libedepsim_io.rootmap 62 | DESTINATION lib) 63 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libedepsim_io_rdict.pcm 64 | DESTINATION lib) 65 | endif(${ROOT_VERSION} VERSION_GREATER 6) 66 | 67 | -------------------------------------------------------------------------------- /src/EDepSimUserRunAction.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // $Id: EDepSim::UserRunAction.hh,v 1.9 2011/07/19 20:55:13 mcgrew Exp $ 3 | // 4 | 5 | #ifndef EDepSim_UserRunAction_h 6 | #define EDepSim_UserRunAction_h 1 7 | 8 | #include "globals.hh" 9 | #include "G4UserRunAction.hh" 10 | 11 | class G4Run; 12 | class G4Timer; 13 | namespace EDepSim {class UserRunActionMessenger;} 14 | 15 | namespace EDepSim {class UserRunAction;} 16 | class EDepSim::UserRunAction : public G4UserRunAction { 17 | public: 18 | UserRunAction(); 19 | virtual ~UserRunAction(); 20 | 21 | public: 22 | void BeginOfRunAction(const G4Run*); 23 | void EndOfRunAction(const G4Run*); 24 | const G4Timer* GetRunTimer(void) const {return fTimer;}; 25 | 26 | /// Set the seed to a new value. This takes a long since the low-level 27 | /// random generate expects a long seed. 28 | void SetSeed(long); 29 | 30 | /// Get the seed that started the low level random generator. 31 | long GetSeed(void) const; 32 | 33 | /// Build a seed for the generator based on the system time. 34 | void SetTimeSeed(); 35 | 36 | /// Set the DetSim Run Id to a specific value. This is the first run id 37 | /// that will be used by GEANT. GEANT will automatically increment the 38 | /// run id everytime it starts a new internal run. The run id should be 39 | /// accessed through G4RunInfo (see G4RunManager). 40 | void SetDetSimRunId(int v); 41 | 42 | /// Set the DetSim Subrun Id to a specific value. This has no internal 43 | /// meaning and is just copied to the output event. 44 | void SetDetSimSubrunId(int v); 45 | 46 | /// Get the subrun id value. 47 | int GetDetSimSubrunId() const; 48 | 49 | private: 50 | /// The messenger for this action 51 | EDepSim::UserRunActionMessenger* fMessenger; 52 | 53 | /// The time that the run was started. 54 | G4String fStartTime; 55 | 56 | /// The time that the run was stopped. 57 | G4String fStopTime; 58 | 59 | /// The running time for the run. 60 | G4Timer* fTimer; 61 | 62 | /// The cached value of the subrun id. 63 | int fSubrunId; 64 | }; 65 | #endif 66 | -------------------------------------------------------------------------------- /src/kinem/EDepSimVConstrainedPositionFactory.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_VConstrainedPositionFactory_hh_seen 2 | #define EDepSim_VConstrainedPositionFactory_hh_seen 3 | 4 | #include "kinem/EDepSimVPositionFactory.hh" 5 | 6 | namespace EDepSim {class VConstrainedPositionGenerator;} 7 | namespace EDepSim {class VPositionGenerator;} 8 | 9 | namespace EDepSim {class VConstrainedPositionFactory;} 10 | class EDepSim::VConstrainedPositionFactory : public EDepSim::VPositionFactory { 11 | public: 12 | VConstrainedPositionFactory(G4String name, 13 | EDepSim::UserPrimaryGeneratorMessenger* fParent, 14 | bool makeDirectory = true); 15 | virtual ~VConstrainedPositionFactory(); 16 | 17 | /// Return a new generator enclosing the current factory state. The new 18 | /// generator method is pure virtual so it must be implemented by derived 19 | /// classes, but the derived generator must return the value from 20 | /// EDepSim::VConstrainedPositionFactory::GetGenerator(). 21 | virtual EDepSim::VPositionGenerator* GetGenerator(); 22 | 23 | /// Create a new generator that can be initialized. This is a pure 24 | /// virtual function so it must be implemented in the derived class. 25 | virtual EDepSim::VPositionGenerator* CreateGenerator() = 0; 26 | 27 | void SetNewValue(G4UIcommand*, G4String); 28 | 29 | private: 30 | 31 | EDepSim::VConstrainedPositionGenerator* fCurrent; 32 | 33 | G4UIcmdWithAString* fPositionSampleVolumeCMD; 34 | G4UIcmdWithoutParameter* fPositionClearCMD; 35 | G4UIcmdWithAString* fPositionVolumeCMD; 36 | G4UIcmdWithAString* fPositionNotVolumeCMD; 37 | G4UIcmdWithAString* fPositionMaterialCMD; 38 | G4UIcmdWithAString* fPositionNotMaterialCMD; 39 | G4UIcmdWithADoubleAndUnit* fPositionMinXCMD; 40 | G4UIcmdWithADoubleAndUnit* fPositionMinYCMD; 41 | G4UIcmdWithADoubleAndUnit* fPositionMinZCMD; 42 | G4UIcmdWithADoubleAndUnit* fPositionMinTCMD; 43 | G4UIcmdWithADoubleAndUnit* fPositionMaxXCMD; 44 | G4UIcmdWithADoubleAndUnit* fPositionMaxYCMD; 45 | G4UIcmdWithADoubleAndUnit* fPositionMaxZCMD; 46 | G4UIcmdWithADoubleAndUnit* fPositionMaxTCMD; 47 | 48 | }; 49 | #endif 50 | -------------------------------------------------------------------------------- /src/captain/CaptExposedBuilder.cc: -------------------------------------------------------------------------------- 1 | #include "CaptExposedBuilder.hh" 2 | 3 | #include "EDepSimBuilder.hh" 4 | 5 | #include "EDepSimLog.hh" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | class CaptExposedMessenger 20 | : public EDepSim::BuilderMessenger { 21 | private: 22 | CaptExposedBuilder* fBuilder; 23 | 24 | public: 25 | CaptExposedMessenger(CaptExposedBuilder* c) 26 | : EDepSim::BuilderMessenger(c,"Control the exposed geometry."), 27 | fBuilder(c) { 28 | 29 | }; 30 | 31 | virtual ~CaptExposedMessenger() { 32 | }; 33 | 34 | void SetNewValue(G4UIcommand *cmd, G4String val) { 35 | EDepSim::BuilderMessenger::SetNewValue(cmd,val); 36 | }; 37 | }; 38 | 39 | void CaptExposedBuilder::Init(void) { 40 | SetMessenger(new CaptExposedMessenger(this)); 41 | 42 | } 43 | 44 | CaptExposedBuilder::~CaptExposedBuilder() {} 45 | 46 | double CaptExposedBuilder::GetRadius() { 47 | double radius = 120*CLHEP::cm; 48 | return radius; 49 | } 50 | 51 | double CaptExposedBuilder::GetHeight() { 52 | return 20*CLHEP::cm; 53 | } 54 | 55 | G4LogicalVolume *CaptExposedBuilder::GetPiece(void) { 56 | 57 | std::cout << " Radius " << GetRadius() << std::endl; 58 | std::cout << " Height " << GetHeight() << std::endl; 59 | G4LogicalVolume* logVolume 60 | = new G4LogicalVolume(new G4Tubs(GetName(), 61 | 0.0, GetRadius(), GetHeight()/2, 62 | 0*CLHEP::degree, 360*CLHEP::degree), 63 | FindMaterial("Argon_Gas"), 64 | GetName()); 65 | logVolume->SetVisAttributes(GetColor(logVolume)); 66 | 67 | G4ThreeVector center(0.0,0.0,-GetHeight()/2-0.1*CLHEP::mm); 68 | fOffset = center; 69 | 70 | /// All the space above the drift region. 71 | center += G4ThreeVector(0.0,0.0,0.0); 72 | 73 | return logVolume; 74 | } 75 | -------------------------------------------------------------------------------- /src/captain/captain-outer-vessel-inner-boundary.txt: -------------------------------------------------------------------------------- 1 | // Inner boundary of the CAPTAIN cryostat outer vessel hand digitized using 2 | // engauge on Nov 20, 2015 by Clark McGrew. The coordinates are measured in 3 | // millimeters with the top of the cryostat at -X, the bottom at +X, and the 4 | // diameter located along the Y axis. The X coordinate is measured from the 5 | // top of the flange with the nominal LAr surface located 24 inches (609.6 mm) 6 | // below the flange. The first point is at the approximate top of the outer 7 | // vessel which is located right below the flange. 8 | // 9 | // COMMENT: This assumes that the lid and the flange are part of the inner 10 | // vessel. The outer vessel stops when it reaches the lower edge of the 11 | // flange. 12 | // 13 | // COMMENT: The makePolycone.py script will use this to produce a "close" 14 | // volume. The output needs to be edited by hand to remove the top point so 15 | // that the outer volume is open on top. 16 | 17 | 40.1021 -661.769 0 18 | 1843.63 -663.613 1 19 | 1865.87 -665.489 2 20 | 1899.23 -672.937 3 21 | 1919.61 -682.226 4 22 | 1956.65 -708.214 5 23 | 1988.12 -749.025 6 24 | 2008.47 -789.825 7 25 | 2032.52 -838.042 8 26 | 2069.51 -915.93 9 27 | 2106.49 -1006.79 10 28 | 2141.61 -1101.36 11 29 | 2174.88 -1195.93 12 30 | 2195.19 -1268.24 13 31 | 2221.05 -1357.24 14 32 | 2241.34 -1453.64 15 33 | 2256.1 -1520.39 16 34 | 2267.15 -1594.54 17 35 | 2280.03 -1689.09 18 36 | 2292.89 -1798.46 19 37 | 2300.17 -1930.07 20 38 | 2301.93 -2020.9 21 39 | 2298.13 -2111.72 22 40 | 2292.47 -2215.52 23 41 | 2283.08 -2334.14 24 42 | 2268.14 -2439.78 25 43 | 2247.64 -2545.41 26 44 | 2232.73 -2625.1 27 45 | 2219.7 -2678.84 28 46 | 2201.1 -2747.4 29 47 | 2184.35 -2804.84 30 48 | 2162.05 -2869.7 31 49 | 2139.73 -2940.11 32 50 | 2113.72 -3003.11 33 51 | 2091.41 -3060.54 34 52 | 2076.55 -3097.6 35 53 | 2057.97 -3140.21 36 54 | 2039.39 -3180.97 37 55 | 2020.82 -3219.88 38 56 | 2004.11 -3247.67 39 57 | 1991.1 -3277.31 40 58 | 1979.96 -3295.83 41 59 | 1968.82 -3312.5 42 60 | 1953.98 -3329.17 43 61 | 1939.14 -3340.28 44 62 | 1920.59 -3351.38 45 63 | 1900.19 -3360.63 46 64 | 1876.08 -3369.87 47 65 | 1864.96 -3371.71 48 66 | 1848.28 -3373.55 49 67 | 1835.3 -3373.54 50 68 | 37.3312 -3371.7 51 69 | -------------------------------------------------------------------------------- /src/kinem/EDepSimDensityPositionGenerator.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "EDepSimLog.hh" 10 | 11 | #include "kinem/EDepSimDensityPositionGenerator.hh" 12 | 13 | EDepSim::DensityPositionGenerator::DensityPositionGenerator(const G4String& name) 14 | : EDepSim::VConstrainedPositionGenerator(name), fMaximumDensity(-1) {} 15 | 16 | EDepSim::DensityPositionGenerator::~DensityPositionGenerator() {} 17 | 18 | G4LorentzVector EDepSim::DensityPositionGenerator::GetPosition() { 19 | if (fMaximumDensity < 0) { 20 | const G4MaterialTable* mTable = G4Material::GetMaterialTable(); 21 | for (G4MaterialTable::const_iterator m = mTable->begin(); 22 | m != mTable->end(); 23 | ++m) { 24 | fMaximumDensity = std::max(fMaximumDensity, (*m)->GetDensity()); 25 | } 26 | } 27 | // Get the navigator. 28 | G4Navigator* navigator 29 | = G4TransportationManager::GetTransportationManager() 30 | ->GetNavigatorForTracking(); 31 | for (int finiteLoop = 0; finiteLoop<100000; ++finiteLoop) { 32 | G4LorentzVector vtx = TrialPosition(); 33 | 34 | // Get the volume that contains the point. 35 | G4VPhysicalVolume* volume = navigator->LocateGlobalPointAndSetup(vtx); 36 | 37 | // Skip this vertex if it's not in a legal volume. 38 | if (!volume) continue; 39 | 40 | // Get the density. 41 | double density 42 | = volume->GetLogicalVolume()->GetMaterial()->GetDensity(); 43 | 44 | // Skip this vertex if it misses the sampling. 45 | if (density < fMaximumDensity*G4UniformRand()) continue; 46 | 47 | // The vertex meets the density sampling, so check if it is valid. 48 | if (ValidPosition(vtx)) return vtx; 49 | } 50 | EDepSimError("EDepSim::DensityPositionGenerator::GetPosition:" 51 | << " No valid position found"); 52 | throw; 53 | } 54 | 55 | bool EDepSim::DensityPositionGenerator::ForcePosition() { 56 | return true; 57 | } 58 | -------------------------------------------------------------------------------- /src/kinem/EDepSimSpillTimeGenerator.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_SpillTimeGenerator_hh_seen 2 | #define EDepSim_SpillTimeGenerator_hh_seen 3 | 4 | #include 5 | 6 | #include "kinem/EDepSimVTimeGenerator.hh" 7 | 8 | /// Generate an interaction time according to the spill parameters. This 9 | /// object is created using the EDepSim::SpillTimeFactory where the spill 10 | /// parameters can be set (there is more documentation there). The time of 11 | /// the interaction is adjusted for the neutrino travel time. 12 | namespace EDepSim {class SpillTimeGenerator;} 13 | class EDepSim::SpillTimeGenerator : public EDepSim::VTimeGenerator { 14 | public: 15 | /// Create the generatory. The name is for documentation, the spillTime 16 | /// gives the start time of the first bunch at the center of the EDepSim:: 17 | /// hall, the bunchSeparation is the time between bunch starts, and the 18 | /// bunchLength is the time length of a bunch with respect to it's start 19 | /// time. 20 | SpillTimeGenerator(G4String name, 21 | double spillTime, 22 | double bunchSeparation, 23 | double bunchLength, 24 | const std::vector& bunchPower); 25 | virtual ~SpillTimeGenerator(); 26 | 27 | /// Return the time of the event to be generated. 28 | double GetTime(const G4LorentzVector& vertex); 29 | 30 | /// Flag if the time should be forced. This tells the calling routine 31 | /// that the time returned by this generator should override any times 32 | /// found in the original vertex. This returns true, so that the 33 | /// generated spill time overrides the interaction time. 34 | virtual bool ForceTime(); 35 | 36 | private: 37 | /// The time that the neutrinos are crossing (0,0,0). 38 | double fSpillTime; 39 | 40 | /// The time between bunch starts. 41 | double fBunchSeparation; 42 | 43 | /// The length of a bunch. This is the gaussian width of the bunch. 44 | double fBunchLength; 45 | 46 | /// The power in each bunch. 47 | std::vector fBunchPower; 48 | 49 | /// The maximum power in a bunch. 50 | double fMaxPower; 51 | }; 52 | #endif 53 | -------------------------------------------------------------------------------- /src/EDepSimPhysicsList.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_PhysicsList_h 2 | #define EDepSim_PhysicsList_h 1 3 | 4 | #include "globals.hh" 5 | #include "G4VModularPhysicsList.hh" 6 | 7 | class G4VPhysicsConstructor; 8 | namespace EDepSim {class PhysicsListMessenger;} 9 | namespace EDepSim {class ExtraPhysics;} 10 | 11 | /// Use the G4PhysListFactory to select a physics list for this run. The 12 | /// physics list can be set from the PHYSLIST environment variable, or a macro 13 | /// file. All of the physics lists need to be defined before using the 14 | /// /run/initialize command. 15 | namespace EDepSim {class PhysicsList;} 16 | class EDepSim::PhysicsList: public G4VModularPhysicsList { 17 | public: 18 | 19 | /// Construct the physics list. If physName is a valid list, then it will 20 | /// be used. Otherwise, the physics list will be read first from the 21 | /// macro file, and then from the PHYSLIST environment variable. If all 22 | /// of thoses methods fail, then a G4 provided default will be used. 23 | explicit PhysicsList(G4String physName); 24 | 25 | virtual ~PhysicsList(); 26 | 27 | /// Set the physics list name to be used (this is used by the physics list 28 | /// messenger. 29 | void SetPhysicsListName(G4String pName); 30 | 31 | /// Used by GEANT4 to set the cuts defined below. 32 | virtual void SetCuts(); 33 | 34 | /// Set the range cut for photons. 35 | void SetCutForGamma(G4double); 36 | 37 | /// Set the range cut for electrons. 38 | void SetCutForElectron(G4double); 39 | 40 | /// Set the range cut for positrons. 41 | void SetCutForPositron(G4double); 42 | 43 | /// Set the recombination fraction for liquid argon (negative for using 44 | /// nest). 45 | void SetIonizationModel(bool); 46 | 47 | private: 48 | 49 | /// The gamma-ray range cut. 50 | G4double fCutForGamma; 51 | 52 | /// The electron range cut. 53 | G4double fCutForElectron; 54 | 55 | /// The positron range cut. 56 | G4double fCutForPositron; 57 | 58 | /// The extra physics list 59 | EDepSim::ExtraPhysics* fExtra; 60 | 61 | /// The messenger to control this class. 62 | EDepSim::PhysicsListMessenger* fMessenger; 63 | 64 | }; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /validate/fast-tests/100TestTree.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Write a ROOT file in the default geometry. This output file should 4 | # be tested to make sure that all of the fields are readable. 5 | 6 | OUTPUT=100TestTree.root 7 | 8 | if [ -f ${OUTPUT} ]; then 9 | rm ${OUTPUT} 10 | fi 11 | 12 | cat > 100TestTree.mac < 39 | #include 40 | #include 41 | 42 | namespace EDepSim {class Cubic;} 43 | 44 | class EDepSim::Cubic 45 | { 46 | public: 47 | Cubic(); 48 | 49 | double interpolate( 50 | const double* point, 51 | const std::vector>>& g, 52 | const double* delta, const double* offset) const; 53 | double interpolate( 54 | double x, double y, double z, 55 | const std::vector>>& g, 56 | double hx, double hy, double hz, double xo, double yo, double zo) 57 | const; 58 | 59 | private: 60 | double conv_kernel(double s) const; 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/kinem/EDepSimHEPEVTKinematicsFactory.cc: -------------------------------------------------------------------------------- 1 | #include "kinem/EDepSimHEPEVTKinematicsFactory.hh" 2 | #include "kinem/EDepSimHEPEVTKinematicsGenerator.hh" 3 | 4 | EDepSim::HEPEVTKinematicsFactory::HEPEVTKinematicsFactory( 5 | EDepSim::UserPrimaryGeneratorMessenger* parent) 6 | : EDepSim::VKinematicsFactory("hepevt",parent,false), 7 | fInputFile("not-open"), 8 | fFlavorName("pythia"), 9 | fVerbosity(0), 10 | fInputFileCMD(NULL), 11 | fFlavorCMD(NULL), 12 | fVerboseCMD(NULL) { 13 | 14 | fInputFileCMD = new G4UIcmdWithAString(CommandName("input"),this); 15 | fInputFileCMD->SetGuidance("Set the input file."); 16 | fInputFileCMD->SetParameterName("name",false); 17 | 18 | fFlavorCMD = new G4UIcmdWithAString(CommandName("flavor"),this); 19 | fFlavorCMD->SetGuidance("Choose input format."); 20 | fFlavorCMD->SetParameterName("flavorname",false); 21 | fFlavorCMD->SetCandidates("pythia pbomb marley"); 22 | 23 | fVerboseCMD = new G4UIcmdWithAnInteger(CommandName("verbose"),this); 24 | fVerboseCMD->SetGuidance("Set verbosity level (0 is default, 2 is max)."); 25 | fVerboseCMD->SetParameterName("number",false); 26 | } 27 | 28 | EDepSim::HEPEVTKinematicsFactory::~HEPEVTKinematicsFactory() { 29 | if (fInputFileCMD) delete fInputFileCMD; 30 | if (fFlavorCMD) delete fFlavorCMD; 31 | if (fVerboseCMD) delete fVerboseCMD; 32 | } 33 | 34 | EDepSim::VKinematicsGenerator* 35 | EDepSim::HEPEVTKinematicsFactory::GetGenerator() { 36 | EDepSim::VKinematicsGenerator* kine 37 | = new EDepSim::HEPEVTKinematicsGenerator(GetName(), 38 | GetInputFile(), 39 | GetFlavor(), 40 | GetVerbose()); 41 | return kine; 42 | } 43 | 44 | void EDepSim::HEPEVTKinematicsFactory::SetNewValue(G4UIcommand* command, 45 | G4String newValue) { 46 | if (command == fInputFileCMD) { 47 | SetInputFile(newValue); 48 | } 49 | else if (command == fFlavorCMD) { 50 | SetFlavor(newValue); 51 | } 52 | else if (command == fVerboseCMD) { 53 | SetVerbose(fVerboseCMD->GetNewIntValue(newValue)); 54 | } 55 | else{ 56 | EDepSimError("Nothing to set the value."); 57 | EDepSimThrow("EDepSim::HEPKinematicsFactory::SetNewValue(): Error"); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /display/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | set(CMAKE_BUILD_TYPE Debug) 4 | 5 | # Set the project name and version 6 | project(edep-disp) 7 | set(VERSION_MAJOR "1") 8 | set(VERSION_MINOR "0") 9 | set(VERSION_PATCH "0") 10 | set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") 11 | 12 | message("Energy Deposition Display -- ${VERSION}") 13 | 14 | # Set the default verbosity of the compilation... 15 | set(CMAKE_VERBOSE_MAKEFILE TRUE) 16 | 17 | # Configure the dependencies 18 | find_package(ROOT REQUIRED 19 | COMPONENTS Geom Physics Matrix MathCore Tree RIO 20 | Eve TreePlayer Ged RGL Gui Graf Graf3d) 21 | if(ROOT_FOUND) 22 | include(${ROOT_USE_FILE}) 23 | endif(ROOT_FOUND) 24 | 25 | if(ROOT_Eve_LIBRARY) 26 | message("Building the edep-disp event display") 27 | else(ROOT_Eve_LIBRARY) 28 | message("NOT BUILDING THE EVENT DISPLAY: eve not found") 29 | return() 30 | endif(ROOT_Eve_LIBRARY) 31 | 32 | # Suck up all of the source files. This isn't good CMAKE practice, 33 | # but it makes maintaining this file easier. 34 | file(GLOB_RECURSE source *.cxx) 35 | 36 | # Compile the base library with private I/O fields. 37 | add_definitions(-DEDEPSIM_FORCE_PRIVATE_FIELDS) 38 | 39 | # Make sure the current directories are available for the root 40 | # dictionary generation. 41 | include_directories(${CMAKE_CURRENT_LIST_DIR} 42 | ${CMAKE_CURRENT_SOURCE_DIR} 43 | ${CMAKE_CURRENT_SOURCE_DIR}/../io 44 | ${CMAKE_CURRENT_SOURCE_DIR}/../src) 45 | 46 | # Build the dictionary for the i/o classes. 47 | ROOT_GENERATE_DICTIONARY(G__edepdisp 48 | TEventChangeManager.hxx 49 | OPTIONS -inlineInputHeader 50 | LINKDEF edepdisp_LinkDef.h) 51 | 52 | # Build the library. 53 | add_library(edepdisp SHARED 54 | ${source} 55 | G__edepdisp.cxx) 56 | target_include_directories(edepdisp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) 57 | target_link_libraries(edepdisp PUBLIC ${ROOT_LIBRARIES} edepsim_io) 58 | install(TARGETS edepdisp LIBRARY DESTINATION lib) 59 | 60 | # Build the display 61 | add_executable(edep-disp eventDisplay.cxx) 62 | target_link_libraries(edep-disp LINK_PUBLIC edepdisp) 63 | install(TARGETS edep-disp RUNTIME DESTINATION bin) 64 | 65 | # If this is ROOT6 or later, then install the rootmap and pcm files. 66 | if(${ROOT_VERSION} VERSION_GREATER 6) 67 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libedepdisp.rootmap 68 | DESTINATION lib) 69 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libedepdisp_rdict.pcm 70 | DESTINATION lib) 71 | endif(${ROOT_VERSION} VERSION_GREATER 6) 72 | -------------------------------------------------------------------------------- /src/EDepSimRootPersistencyManager.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // $Id: EDepSim::RootPersistencyManager.hh,v 1.31 2011/09/06 18:58:35 mcgrew Exp $ 3 | // 4 | #ifndef EDepSim_RootPersistencyManager_hh_seen 5 | #define EDepSim_RootPersistencyManager_hh_seen 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | class TFile; 12 | class TTree; 13 | class TGeoManager; 14 | 15 | #include "EDepSimPersistencyManager.hh" 16 | 17 | /// Provide a root output for the geant 4 events. This just takes the summary 18 | /// from EDepSim::PersistencyManager and dumps it as a tree. 19 | namespace EDepSim {class RootPersistencyManager;} 20 | class EDepSim::RootPersistencyManager : public EDepSim::PersistencyManager { 21 | public: 22 | /// Creates a root persistency manager. Through the "magic" of 23 | /// G4VPersistencyManager the ultimate base class, this declared to the G4 24 | /// persistency management system. You can only have one active 25 | /// persistency class at any give moment. 26 | RootPersistencyManager(); 27 | virtual ~RootPersistencyManager(); 28 | 29 | /// Return true if the ROOT output file is active. This means that the 30 | /// output file is open and ready to accept data. 31 | bool IsOpen(); 32 | 33 | /// Return a pointer to the current TFile. 34 | TFile* GetTFile() const {return fOutput;} 35 | 36 | /// Stores an event to the output file. 37 | virtual G4bool Store(const G4Event* anEvent); 38 | virtual G4bool Store(const G4Run* aRun); 39 | virtual G4bool Store(const G4VPhysicalVolume* aWorld); 40 | 41 | /// Retrieve information from a file. These are not implemented. 42 | virtual G4bool Retrieve(G4Event *&e) {e=NULL; return false;} 43 | virtual G4bool Retrieve(G4Run* &r) {r=NULL; return false;} 44 | virtual G4bool Retrieve(G4VPhysicalVolume* &w) {w=NULL; return false;} 45 | 46 | /// Interface with PersistencyMessenger (open and close the 47 | /// database). 48 | virtual G4bool Open(G4String dbname); 49 | virtual G4bool Close(void); 50 | 51 | private: 52 | /// Make the MC Header and add it to truth. 53 | void MakeMCHeader(const G4Event* src); 54 | 55 | private: 56 | /// The ROOT output file that events are saved into. 57 | TFile *fOutput; 58 | 59 | /// The event tree that contains the output events. 60 | TTree *fEventTree; 61 | 62 | /// The number of events saved to the output file since the last write. 63 | int fEventsNotSaved; 64 | 65 | }; 66 | #endif 67 | -------------------------------------------------------------------------------- /display/TRecurseGeoManager.hxx: -------------------------------------------------------------------------------- 1 | #ifndef TRecurseGeoManager_hxx_seen 2 | #define TRecurseGeoManager_hxx_seen 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | class TRecurseGeoManager { 9 | public: 10 | TRecurseGeoManager() {} 11 | virtual ~TRecurseGeoManager() {} 12 | 13 | /// Apply the action recursively to every node starting with the current 14 | /// node (depth first). 15 | bool Apply(int depth=0) { 16 | TGeoNode * node = gGeoManager->GetCurrentNode(); 17 | if (!Action(depth)) { 18 | gGeoManager->CdUp(); 19 | return false; 20 | } 21 | 22 | for (int i=0; i< node->GetNdaughters(); ++i) { 23 | gGeoManager->CdDown(i); 24 | if (!Apply(depth+1)) { 25 | gGeoManager->CdUp(); 26 | return false; 27 | } 28 | } 29 | 30 | gGeoManager->CdUp(); 31 | return true; 32 | } 33 | 34 | /// An action to override. Return false if the recursion should be 35 | /// stopped. The action should act on the current node, and NOT change 36 | /// the geometry. The input argument (depth) is the current depth in the 37 | /// geometry (zero is the node where the recursion started). 38 | virtual bool Action(int depth) { 39 | TGeoNode* node = gGeoManager->GetCurrentNode(); 40 | TGeoExtension* extension; 41 | extension = node->GetUserExtension(); 42 | if (extension) { 43 | std::cout << "Have node user extension " << node->GetName() 44 | << " depth " << depth 45 | << std::endl; 46 | } 47 | extension = node->GetFWExtension(); 48 | if (extension) { 49 | std::cout << "Have node FW extension " << node->GetName() 50 | << " depth " << depth 51 | << std::endl; 52 | } 53 | TGeoVolume* volume = node->GetVolume(); 54 | extension = volume->GetUserExtension(); 55 | if (extension) { 56 | std::cout << "Have volume user extension " << volume->GetName() 57 | << " depth " << depth 58 | << std::endl; 59 | } 60 | extension = volume->GetFWExtension(); 61 | if (extension) { 62 | std::cout << "Have volume FW extension " << volume->GetName() 63 | << " depth " << depth 64 | << std::endl; 65 | } 66 | return true; 67 | } 68 | }; 69 | #endif 70 | -------------------------------------------------------------------------------- /src/kinem/EDepSimVPrimaryFactory.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_VPrimaryFactory_hh_seen 2 | #define EDepSim_VPrimaryFactory_hh_seen 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "EDepSimUserPrimaryGeneratorMessenger.hh" 19 | 20 | namespace EDepSim {class VPrimaryFactory;} 21 | class EDepSim::VPrimaryFactory : public G4UImessenger { 22 | public: 23 | VPrimaryFactory(G4String subdir, G4String name, 24 | EDepSim::UserPrimaryGeneratorMessenger* parent, 25 | bool makeDirectory); 26 | virtual ~VPrimaryFactory(); 27 | 28 | /// Return the full path for the factory. This returns the full name of 29 | /// the EDepSim::VPrimaryFactory. It should be used as a prefix for any 30 | /// messenger commands. The full path for the factory is constructed as 31 | /// "///". 32 | G4String GetPath() const; 33 | 34 | /// Return the short name of this factory. This is used to identify it in 35 | /// other messenger commands. The full path for the factory is 36 | /// constructed as "///". 37 | G4String GetName() const; 38 | 39 | /// Return the subdirectory name for this factory. The full path for the 40 | /// factory is constructed as "///". 41 | G4String GetSubDir() const; 42 | 43 | /// Handle messages from the UI processor. 44 | virtual void SetNewValue(G4UIcommand*, G4String) {}; 45 | 46 | protected: 47 | /// Build a command name with the directory prefix. 48 | G4String CommandName(G4String cmd) { 49 | G4String name = GetPath() + cmd; 50 | return name; 51 | }; 52 | 53 | private: 54 | /// The short name of this factory. 55 | G4String fName; 56 | 57 | /// The sub-directory holding this factory. 58 | G4String fSubDirName; 59 | 60 | /// The messenger that is holding this set of sub-commands. 61 | EDepSim::UserPrimaryGeneratorMessenger* fParent; 62 | 63 | /// The sub-directory for the local commands. The full name of the local 64 | /// subdirectory is "///" 65 | G4UIdirectory* fDir; 66 | }; 67 | #endif 68 | -------------------------------------------------------------------------------- /src/EDepSimArbEMField.hh: -------------------------------------------------------------------------------- 1 | // License and Disclaimer 2 | // 3 | // For use with software authored by the Geant4 Collaboration 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2020 Andrew Cudd 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a 10 | // copy of this software and associated documentation files (the "Software"), 11 | // to deal in the Software without restriction, including without limitation 12 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 | // and/or sell copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | // DEALINGS IN THE SOFTWARE. 26 | // 27 | // 28 | // class EDepSim::ArbEMField 29 | // 30 | // Class description: 31 | // 32 | // Class for storing and handling an arbitrary EM field. 33 | // 34 | // History: 35 | // - 2020.04.14 A.Cudd created 36 | // - 2020.07.28 C.McGrew updated license with permission of A.Cudd 37 | // 38 | // ------------------------------------------------------------------- 39 | 40 | #ifndef EDEPSIMARBEMFIELD_H 41 | #define EDEPSIMARBEMFIELD_H 42 | 43 | #include "G4Types.hh" 44 | #include "G4ElectroMagneticField.hh" 45 | 46 | namespace EDepSim { class ArbEMField; } 47 | 48 | class EDepSim::ArbEMField : public G4ElectroMagneticField 49 | { 50 | public: 51 | ArbEMField(); 52 | ArbEMField(G4Field* efield_in, G4Field* bfield_in); 53 | 54 | ArbEMField(const ArbEMField& cpy); 55 | ArbEMField& operator=(const ArbEMField& rhs); 56 | 57 | virtual ~ArbEMField(); 58 | 59 | virtual void GetFieldValue(const G4double pos[4], G4double *field) const; 60 | virtual G4bool DoesFieldChangeEnergy() const { return true; }; 61 | 62 | void SetEField(G4Field* efield_in) { efield = efield_in; }; 63 | void SetBField(G4Field* bfield_in) { bfield = bfield_in; }; 64 | 65 | private: 66 | G4Field* efield; 67 | G4Field* bfield; 68 | }; 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /src/kinem/EDepSimHEPEVTKinematicsGenerator.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_HEPEVTKinematicsGenerator_hh_Seen 2 | #define EDepSim_HEPEVTKinematicsGenerator_hh_Seen 3 | 4 | #include 5 | #include 6 | 7 | #include "kinem/EDepSimVKinematicsGenerator.hh" 8 | 9 | #include 10 | #include 11 | 12 | class G4Event; 13 | class G4VPrimaryGenerator; 14 | 15 | /// A class to read a HEPEVT file. This normally uses an internal processor, 16 | /// but can be forced (using #defines) to use the G4HEPEvtInterface. 17 | namespace EDepSim {class HEPEVTKinematicsGenerator;} 18 | class EDepSim::HEPEVTKinematicsGenerator : 19 | public EDepSim::VKinematicsGenerator { 20 | public: 21 | HEPEVTKinematicsGenerator(const G4String& name, 22 | const G4String& fileName, 23 | const G4String& flavor, 24 | int verbosity = 0); 25 | virtual ~HEPEVTKinematicsGenerator(); 26 | 27 | /// Add a primary vertex to the event. 28 | virtual GeneratorStatus 29 | GeneratePrimaryVertex(G4Event* evt, 30 | const G4LorentzVector& position); 31 | 32 | private: 33 | /// The primary generator when G4HEPEvtInterface is used (usually NULL). 34 | G4VPrimaryGenerator* fGenerator; 35 | 36 | /// The name of the input file (used for error messages) 37 | std::string fFileName; 38 | 39 | ///The input flavor (type of HEPEVT format) to be read 40 | std::string fFlavor; 41 | 42 | /// The number of lines read from the input file (used for error messages) 43 | int fCurrentLine; 44 | 45 | /// The verbosity of the output 46 | int fVerbosity; 47 | 48 | /// The input stream to be read. 49 | std::ifstream fInput; 50 | 51 | /// Get the next line of "tokens" from the input file. This returns the 52 | /// number of tokens that were read from the line, and zero when the file 53 | /// is empty. Comments in the file are prefixed by "#", and tokens are 54 | /// separated by white space. The expected format is 55 | /// \code 56 | /// token1 token2 token3 and so on # comments 57 | /// \endcode 58 | /// Lines that are empty, or only have comments are skipped, 59 | int GetTokens(std::vector& tokens); 60 | 61 | /// Parse a token as an integer. This will throw an error if the string 62 | /// is not a valid integer. 63 | int AsInteger(const std::string& token); 64 | 65 | /// Parse a token as a real number This will throw an error if the string 66 | /// is not a valid floating point number. 67 | double AsReal(const std::string& token); 68 | }; 69 | #endif 70 | -------------------------------------------------------------------------------- /display/eventDisplay.cxx: -------------------------------------------------------------------------------- 1 | #include "TEventDisplay.hxx" 2 | #include "TEventChangeManager.hxx" 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | void usage() { 16 | std::cout << "Usage: edep-disp [options] [input-file] " << std::endl; 17 | std::cout << " The edep-sim event display: " << std::endl; 18 | std::cout << " -g Toggle showing the geometry (on by default)." 19 | << std::endl; 20 | std::cout << " -s Show volumes containing (limit this to " 21 | << std::endl 22 | << " a few, or it's horribly slow." 23 | << std::endl; 24 | std::cout << " -S Clear the volumes that will be shown." 25 | << std::endl; 26 | std::cout << " -h This message." << std::endl; 27 | } 28 | 29 | int main(int argc, char **argv) { 30 | std::string fileName = ""; 31 | bool showGeometry = true; 32 | std::vector volumesToShow; 33 | 34 | while (1) { 35 | int c = getopt(argc, argv, "?hgs:S"); 36 | if (c == -1) break; 37 | switch (c) { 38 | case 'g': { 39 | // Show the geometry. 40 | showGeometry = not showGeometry; 41 | break; 42 | } 43 | case 's': { 44 | volumesToShow.push_back(optarg); 45 | break; 46 | } 47 | case 'S': { 48 | volumesToShow.clear(); 49 | break; 50 | } 51 | case '?': 52 | case 'h': 53 | default: 54 | usage(); 55 | return 1; 56 | } 57 | } 58 | 59 | // Check if there is an input file on the command line. 60 | if (argc - optind > 0) { 61 | fileName = argv[optind]; 62 | } 63 | 64 | TFile* eventSource = NULL; 65 | if (!fileName.empty()) { 66 | eventSource = new TFile(fileName.c_str()); 67 | } 68 | if (!eventSource) { 69 | usage(); 70 | return 1; 71 | } 72 | 73 | TApplication theApp("EventDisplay", 0, 0); 74 | theApp.ExitOnException(TApplication::kExit); 75 | 76 | EDep::TEventDisplay& ev = EDep::TEventDisplay::Get(); 77 | ev.EventChange().SetShowGeometry(showGeometry); 78 | for (std::vector::iterator v = volumesToShow.begin(); 79 | v != volumesToShow.end(); ++v) { 80 | ev.EventChange().AddVolumeToShow(*v); 81 | } 82 | ev.EventChange().SetEventSource(eventSource); 83 | 84 | theApp.Run(kFALSE); 85 | 86 | return 0; 87 | } 88 | 89 | 90 | -------------------------------------------------------------------------------- /src/kinem/EDepSimSpillTimeFactory.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_SpillTimeFactory_hh_seen 2 | #define EDepSim_SpillTimeFactory_hh_seen 3 | 4 | #include "kinem/EDepSimVTimeFactory.hh" 5 | 6 | /// A factory to create a time generator to distribute events according to the 7 | /// spill structure. The spill parameters should be set before the generator 8 | /// is created. The spill times are actually generated by an 9 | /// EDepSim::SpillTimeGenerator object. 10 | namespace EDepSim {class SpillTimeFactory;} 11 | class EDepSim::SpillTimeFactory : public EDepSim::VTimeFactory { 12 | public: 13 | SpillTimeFactory(EDepSim::UserPrimaryGeneratorMessenger* parent); 14 | virtual ~SpillTimeFactory(); 15 | 16 | /// Return the spill time generator. The spill parameters must be set 17 | /// before this is called. 18 | EDepSim::VTimeGenerator* GetGenerator(); 19 | 20 | /// Set the spill time. The spill time is the offset of start of the 21 | /// first bunch with respect to zero. This is the time that the bunch 22 | /// will cross the center of the EDepSim:: hall. 23 | void SetSpillTime(double spillTime) {fSpillTime=spillTime;} 24 | 25 | /// Set the number of bunchs (and reset the bunch power) in a spill. 26 | void SetBunchCount(int bunchs); 27 | 28 | /// Set the bunch separation. This is the time between the start of 29 | /// successive bunches. 30 | void SetBunchSeparation(double sep) {fBunchSeparation=sep;} 31 | 32 | /// Set the bunch length. This is the length of a bunch, and determines 33 | /// the end of the bunch with respect to the start. The start of the 34 | /// bunch is determined by the spill time, and the bunch separation. The 35 | /// bunch is modeled as a Gaussian with a sigma set to the Bunch Length. 36 | void SetBunchLength(double length) {fBunchLength=length;} 37 | 38 | /// Set the power for a bunch. The bunchs are numbered from ONE, and the 39 | /// nominal (default) power in a bunch is 1.0. 40 | void SetBunchPower(int bunch, double power); 41 | 42 | /// Handle messages from the UI processor. 43 | void SetNewValue(G4UIcommand*, G4String); 44 | 45 | private: 46 | /// The start time of the spill. 47 | double fSpillTime; 48 | 49 | /// The bunch separation. 50 | double fBunchSeparation; 51 | 52 | /// The bunch length. 53 | double fBunchLength; 54 | 55 | /// The power in each bunch. 56 | std::vector fBunchPower; 57 | 58 | G4UIcmdWithADoubleAndUnit* fSpillTimeCMD; 59 | G4UIcmdWithADoubleAndUnit* fBunchSepCMD; 60 | G4UIcmdWithADoubleAndUnit* fBunchLengthCMD; 61 | G4UIcmdWithAnInteger* fBunchCountCMD; 62 | G4UIcommand* fBunchPowerCMD; 63 | 64 | }; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /validate/edep-sim-validate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Run tests on edep-sim. The tests kept in the fast-tests 4 | # subdirectory will be run. Any tests that take a lot of time and are 5 | # for more detailed validation should be kept in slow-tests. The 6 | # slow-tests will only be run if the "-s" option is provided. 7 | # 8 | # This needs to be run in the validate subdirectory. 9 | # 10 | # The validation scripts are run in lexical order based on the script 11 | # name. This means that script "001MyName" is run before "002MyName", 12 | # and allows users to specify the script order. This script is used 13 | # in a few places. The following convention is suggested for script 14 | # naming. 15 | # 16 | # 000 -- Reserved for edep-sim-validate.sh 17 | # 18 | # 001-099 -- Scripts which don't require input. This includes any 19 | # scripts generating kinematic output that could be used by 20 | # edep-sim. 21 | # 22 | # 100-199 -- Scripts which generate edep-sim output files. 23 | # 24 | # 200-299 -- Scripts which produce "raw" hits (and might need 25 | # edep-sim input files). This is where the detector response 26 | # simulation is expected to be run. These scripts might also 27 | # produce calibrated hits. 28 | # 29 | # 300-399 -- Scripts which need uncalibrated hit objects. This is 30 | # where scripts that produce calibration coefficients are 31 | # expected to be found. 32 | # 33 | # 400-499 -- Scripts which produce calibrate uncalibrated hits 34 | # into calibrated hits. 35 | # 36 | # 500-599 -- Scripts which need calibrated objects. This is 37 | # where the reconstruction tests should be run. 38 | # 39 | # 600-699 -- Scripts which need reconstruction objects. 40 | # 41 | # 800-899 -- Scripts which produce summary trees. 42 | # 43 | # 900-999 -- Scripts looking at summary trees and validating physics 44 | # performance. 45 | 46 | 47 | TESTS="fast-tests" 48 | 49 | # Handle any input arguments 50 | TEMP=$(getopt -o 's' -n "$0" -- "$@") 51 | if [ $? -ne 0 ]; then 52 | echo "Error ..." 53 | exit 1 54 | fi 55 | eval set -- "$TEMP" 56 | unset TEMP 57 | while true; do 58 | case "$1" in 59 | '-s') 60 | TESTS="${TESTS} slow-tests" 61 | shift 62 | continue;; 63 | '--') 64 | shift 65 | break; 66 | esac 67 | done 68 | 69 | # Make a temporary macro file in the local directory. 70 | OUTPUT_DIR="output.$(date +%Y-%m-%d-%H%M)" 71 | mkdir ${OUTPUT_DIR} 72 | for i in $(find ${TESTS} -name "[0-9]*" -type f | grep -v "~" | sort); do 73 | if [ -x ${i} ]; then 74 | LOG=$(basename $i) 75 | echo "(cd $OUTPUT_DIR && ../${i} >& ${LOG}.log || echo FAIL: $i)" 76 | (cd $OUTPUT_DIR && ../${i} >& ${LOG}.log || echo FAIL: $i) 77 | fi 78 | done 79 | 80 | -------------------------------------------------------------------------------- /src/EDepSimSegmentSD.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // $Id: EDepSim::SegmentSD.hh,v 1.3 2007/01/01 05:36:12 mcgrew Exp $ 3 | // 4 | 5 | #ifndef EDepSim_SegmentSD_h 6 | #define EDepSim_SegmentSD_h 1 7 | 8 | #include "G4VSensitiveDetector.hh" 9 | #include "EDepSimLog.hh" 10 | #include "EDepSimHitSegment.hh" 11 | 12 | class G4HCofThisEvent; 13 | class G4Step; 14 | 15 | /// A sensitive detector to create EDepSim::HitSegment based hits. 16 | namespace EDepSim {class SegmentSD;} 17 | class EDepSim::SegmentSD : public G4VSensitiveDetector { 18 | 19 | public: 20 | SegmentSD(G4String name); 21 | virtual ~SegmentSD(); 22 | 23 | void Initialize(G4HCofThisEvent*); 24 | G4bool ProcessHits(G4Step*, G4TouchableHistory*); 25 | void EndOfEvent(G4HCofThisEvent*); 26 | 27 | /// Set the maximum sagitta for the EDepSim::HitSegment objects created by 28 | /// this sensitive detector. 29 | void SetMaximumHitSagitta(double sagitta) { 30 | EDepSimLog("Set max segment sagitta to " << sagitta 31 | << " for " << GetName()); 32 | fMaximumHitSagitta = sagitta; 33 | } 34 | double GetMaximumHitSagitta(void) {return fMaximumHitSagitta;} 35 | 36 | /// Set the maximum separation between deposits for the 37 | /// EDepSim::HitSegment objects created by this sensitive 38 | /// detector. 39 | void SetMaximumHitSeparation(double separation) { 40 | EDepSimLog("Set max segment separation to " << separation 41 | << " for " << GetName()); 42 | fMaximumHitSeparation = separation; 43 | } 44 | double GetMaximumHitSeparation(void) {return fMaximumHitSeparation;} 45 | 46 | /// Set the maximum length for the EDepSim::HitSegment objects 47 | /// created by this sensitive detector. 48 | void SetMaximumHitLength(double length) { 49 | EDepSimLog("Set max segment length to " << length 50 | << " for " << GetName()); 51 | fMaximumHitLength = length; 52 | } 53 | double GetMaximumHitLength(void) {return fMaximumHitLength;} 54 | 55 | private: 56 | /// The collection of hits that is being filled in the current event. It 57 | /// is constructed in Initialize, filled in ProcessHits, and added the the 58 | /// event in EndOfEvent. 59 | EDepSim::HitSegment::HitSegmentCollection* fHits; 60 | 61 | /// The hit collection id of fHits 62 | int fHCID; 63 | 64 | /// The maximum allowed sagitta; 65 | double fMaximumHitSagitta; 66 | 67 | /// The maximum distance between deposits that can be combined. 68 | double fMaximumHitSeparation; 69 | 70 | /// The maximum allowed length; 71 | double fMaximumHitLength; 72 | 73 | /// The last hit that was found. 74 | int fLastHit; 75 | }; 76 | 77 | #endif 78 | 79 | -------------------------------------------------------------------------------- /src/EDepSimArbElecField.hh: -------------------------------------------------------------------------------- 1 | // License and Disclaimer 2 | // 3 | // For use with software authored by the Geant4 Collaboration 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2020 Andrew Cudd 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a 10 | // copy of this software and associated documentation files (the "Software"), 11 | // to deal in the Software without restriction, including without limitation 12 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 | // and/or sell copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | // DEALINGS IN THE SOFTWARE. 26 | // 27 | // class EDepSim::ArbElecField 28 | // 29 | // Class description: 30 | // 31 | // Class for storing and handling an arbitrary electric field. 32 | // 33 | // History: 34 | // - 2020.04.14 A.Cudd created 35 | // - 2020.07.28 C.McGrew updated license with permission of A.Cudd 36 | // 37 | // ------------------------------------------------------------------- 38 | 39 | #ifndef EDEPSIMARBELECFIELD_H 40 | #define EDEPSIMARBELECFIELD_H 41 | 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | #include "G4Types.hh" 51 | #include "G4ElectricField.hh" 52 | #include "G4SystemOfUnits.hh" 53 | 54 | #include "EDepSimLog.hh" 55 | #include "EDepSimInterpolator.hh" 56 | 57 | namespace EDepSim { class ArbElecField; } 58 | 59 | class EDepSim::ArbElecField : public G4ElectricField 60 | { 61 | public: 62 | ArbElecField(); 63 | 64 | bool ReadFile(const std::string& fname); 65 | void PrintInfo() const; 66 | virtual void GetFieldValue(const G4double pos[4], G4double* field) const; 67 | 68 | private: 69 | std::string m_filename; 70 | std::array m_offset; 71 | std::array m_delta; 72 | std::vector>> m_field_x; 73 | std::vector>> m_field_y; 74 | std::vector>> m_field_z; 75 | }; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /src/EDepSimArbMagField.hh: -------------------------------------------------------------------------------- 1 | // License and Disclaimer 2 | // 3 | // For use with software authored by the Geant4 Collaboration 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2020 Andrew Cudd 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a 10 | // copy of this software and associated documentation files (the "Software"), 11 | // to deal in the Software without restriction, including without limitation 12 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 | // and/or sell copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | // DEALINGS IN THE SOFTWARE. 26 | // 27 | // 28 | // class EDepSim::ArbMagField 29 | // 30 | // Class description: 31 | // 32 | // Class for storing and handling an arbitrary magnetic field. 33 | // 34 | // History: 35 | // - 2020.04.14 A.Cudd created 36 | // - 2020.07.28 C.McGrew updated license with permission of A.Cudd 37 | // 38 | // ------------------------------------------------------------------- 39 | 40 | #ifndef EDEPSIMARBMAGFIELD_H 41 | #define EDEPSIMARBMAGFIELD_H 42 | 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | #include "G4Types.hh" 52 | #include "G4MagneticField.hh" 53 | #include 54 | 55 | #include "EDepSimLog.hh" 56 | #include "EDepSimInterpolator.hh" 57 | 58 | namespace EDepSim { class ArbMagField; } 59 | 60 | class EDepSim::ArbMagField : public G4MagneticField 61 | { 62 | public: 63 | ArbMagField(); 64 | 65 | bool ReadFile(const std::string& fname); 66 | void PrintInfo() const; 67 | virtual void GetFieldValue(const G4double pos[4], G4double* field) const; 68 | 69 | private: 70 | std::string m_filename; 71 | std::array m_offset; 72 | std::array m_delta; 73 | std::vector>> m_field_x; 74 | std::vector>> m_field_y; 75 | std::vector>> m_field_z; 76 | }; 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /inputs/triple-particle-gun.mac: -------------------------------------------------------------------------------- 1 | ################################################################## 2 | # A macro that uses the G4 particle gun to create three particles per event. 3 | ################################################################## 4 | 5 | # To generate 10 events, this can be run using edep-sim with the command 6 | # 7 | # edep-sim -C -u -e 10 triple-particle-gun.mac 8 | # 9 | 10 | # Make sure that the GPS generator is it's default state. 11 | /gps/source/clear 12 | 13 | # Enable generating multiple particle guns per event. 14 | /gps/source/multiplevertex true 15 | 16 | ####################################### 17 | # Create the first particle source 18 | ####################################### 19 | /gps/source/add 1 20 | 21 | # This source will be used to specify the position of the vertex. The 22 | # any of the GPS direction and energy commands can be used. 23 | /gps/particle mu- 24 | /gps/energy 7000 MeV 25 | 26 | # This generates the position of the first particle gun. It will be 27 | # used for the other particle guns. The /gps/position command must 28 | # come first. 29 | /gps/position 0.0 1.0 -0.5 m 30 | /gps/pos/type Volume 31 | /gps/pos/shape Para 32 | /gps/pos/halfx 1 cm 33 | /gps/pos/halfy 1 cm 34 | /gps/pos/halfz 1 cm 35 | 36 | # This generates the direction of the first particle gun. This aims 37 | # the particle downstream with the directions uniformly distributed in 38 | # a 10 deg cone around the X axis. 39 | /gps/ang/type iso 40 | /gps/ang/maxtheta 10 deg 41 | # /gps/ang/rot1 1 0 0 42 | # /gps/ang/rot2 0 -1 0 43 | /gps/ang/rot2 0 0 -1 44 | 45 | ######################################### 46 | # Create the second particle source. 47 | ######################################### 48 | /gps/source/add 2 49 | /gps/particle proton 50 | /gps/energy 3000 MeV 51 | 52 | # This generates the direction of the second particle gun. This aims 53 | # the particle downstream with the directions uniformly distributed in 54 | # a 25 deg cone. 55 | /gps/ang/type iso 56 | /gps/ang/maxtheta 25 deg 57 | # /gps/ang/rot1 1 0 0 58 | # /gps/ang/rot2 0 -1 0 59 | /gps/ang/rot2 0 0 -1 60 | 61 | 62 | ######################################### 63 | # Create the third particle source. 64 | ######################################### 65 | /gps/source/add 3 66 | /gps/particle e+ 67 | /gps/energy 2000 MeV 68 | 69 | # This generates the direction of the third particle gun. 70 | /gps/ang/type iso 71 | /gps/ang/maxtheta 25 deg 72 | # /gps/ang/rot1 1 0 0 73 | # /gps/ang/rot2 0 -1 0 74 | /gps/ang/rot2 0 0 -1 75 | 76 | # Create the GPS particle generator so it exists. This isn't necessary for a 77 | # single particle generator since DETSIM will create it by default, 78 | # but it must be done explicitly when generating multiple GPS 79 | # particles 80 | /generator/add 81 | 82 | # Copy the vertex position of the first particle into the second particle. 83 | /generator/combine 0 1 84 | 85 | # Copy the vertex position of the first particle into the third particle. 86 | /generator/combine 0 2 87 | -------------------------------------------------------------------------------- /src/kinem/EDepSimRooTrackerKinematicsFactory.hh: -------------------------------------------------------------------------------- 1 | #ifndef EDepSim_RooTrackerKinematicsFactory_hh_seen 2 | #define EDepSim_RooTrackerKinematicsFactory_hh_seen 3 | 4 | #include "kinem/EDepSimVKinematicsFactory.hh" 5 | 6 | class G4VPrimaryGenerator; 7 | namespace EDepSim {class RooTrackerKinematicsGenerator;} 8 | 9 | namespace EDepSim {class RooTrackerKinematicsFactory;} 10 | class EDepSim::RooTrackerKinematicsFactory : public EDepSim::VKinematicsFactory { 11 | public: 12 | RooTrackerKinematicsFactory(EDepSim::UserPrimaryGeneratorMessenger* fParent); 13 | virtual ~RooTrackerKinematicsFactory(); 14 | 15 | /// Return a new generator enclosing the current factory state. The new 16 | /// generator method is pure virtual so it must be implemented by derived 17 | /// classes. 18 | virtual EDepSim::VKinematicsGenerator* GetGenerator(); 19 | 20 | /// Set the input file to read. 21 | virtual void SetInputFile(const G4String& name) {fInputFile=name;} 22 | 23 | /// Get the input file to read. 24 | virtual const G4String& GetInputFile() const {return fInputFile;} 25 | 26 | /// Set the generator name. This is the name of the program that 27 | /// generated the rooTracker tree, and will be saved as documentation in 28 | /// the output file. 29 | virtual void SetGeneratorName(const G4String& name) {fGeneratorName = name;} 30 | 31 | /// Get the generator name. 32 | virtual const G4String& GetGeneratorName() const {return fGeneratorName;} 33 | 34 | /// Get the tree name. 35 | virtual const G4String& GetTreeName() const {return fTreeName;} 36 | 37 | /// Set the tree name. This is the path of the rooTracker tree in the 38 | /// input root file. 39 | virtual void SetTreeName(const G4String& name) {fTreeName = name;} 40 | 41 | /// Set the order that events in the input file will be used. 42 | virtual void SetOrder(const G4String& order) {fOrder = order;} 43 | 44 | /// Get the order that events in the input file will be used. 45 | virtual G4String GetOrder() {return fOrder;} 46 | 47 | /// Set the first event to read. 48 | virtual void SetFirstEvent(int f) {fFirstEvent=f;} 49 | 50 | /// Get the first event to read. 51 | virtual int GetFirstEvent() const {return fFirstEvent;} 52 | 53 | virtual void SetNewValue(G4UIcommand* command,G4String newValue); 54 | 55 | private: 56 | /// The root file with the RooTracker tree. 57 | G4String fInputFile; 58 | 59 | /// The path to the tree in the root file. 60 | G4String fTreeName; 61 | 62 | /// The name of the generater that created the rooTracker tree (eg GENIE, 63 | /// NEUT, &c). 64 | G4String fGeneratorName; 65 | 66 | /// The order that events in the input file will be used. 67 | G4String fOrder; 68 | 69 | /// The first event to read in the file. 70 | int fFirstEvent; 71 | 72 | G4UIcmdWithAString* fInputFileCMD; 73 | G4UIcmdWithAString* fTreeNameCMD; 74 | G4UIcmdWithAString* fGeneratorNameCMD; 75 | G4UIcmdWithAString* fOrderCMD; 76 | G4UIcmdWithAnInteger* fFirstEventCMD; 77 | }; 78 | #endif 79 | --------------------------------------------------------------------------------