Import Geant4 10.4.0 source tree
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
$Id:$
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
|
||||
=========================================================
|
||||
|
||||
physicslists/shared History file
|
||||
--------------------------------
|
||||
This file should be used by the G4 example coordinator to briefly
|
||||
summarize all major modifications introduced in the code and keep
|
||||
track of all tags.
|
||||
|
||||
----------------------------------------------------------
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
26/10/17 I. Hrivnacova (physicslistsShared-V10-03-00)
|
||||
- The first tag
|
||||
|
||||
25/10/17 I. Hrivnacova
|
||||
- First version of example
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: ActionInitialization.hh 68058 2013-03-13 14:47:43Z gcosmo $
|
||||
//
|
||||
/// \file ActionInitialization.hh
|
||||
/// \brief Definition of the ActionInitialization class
|
||||
|
||||
#ifndef ActionInitialization_h
|
||||
#define ActionInitialization_h 1
|
||||
|
||||
#include "G4VUserActionInitialization.hh"
|
||||
#include "G4String.hh"
|
||||
|
||||
/// Action initialization class.
|
||||
///
|
||||
|
||||
class ActionInitialization : public G4VUserActionInitialization
|
||||
{
|
||||
public:
|
||||
ActionInitialization(const G4String& fileName);
|
||||
virtual ~ActionInitialization();
|
||||
|
||||
virtual void BuildForMaster() const;
|
||||
virtual void Build() const;
|
||||
|
||||
private:
|
||||
G4String fFileName;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: Analysis.hh 100946 2016-11-03 11:28:08Z gcosmo $
|
||||
//
|
||||
/// \file Analysis.hh
|
||||
/// \brief Selection of the analysis technology
|
||||
|
||||
#ifndef Analysis_h
|
||||
#define Analysis_h 1
|
||||
|
||||
#include "g4root.hh"
|
||||
//#include "g4cvs.hh"
|
||||
//#include "g4xml.hh"
|
||||
|
||||
#endif
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: DetectorConstruction.hh 75215 2013-10-29 16:07:06Z gcosmo $
|
||||
//
|
||||
/// \file DetectorConstruction.hh
|
||||
/// \brief Definition of the DetectorConstruction class
|
||||
|
||||
#ifndef DetectorConstruction_h
|
||||
#define DetectorConstruction_h 1
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class G4VPhysicalVolume;
|
||||
class G4GlobalMagFieldMessenger;
|
||||
|
||||
/// Detector construction class to define materials and geometry.
|
||||
/// The calorimeter is a box made of a given number of layers. A layer consists
|
||||
/// of an absorber plate and of a detection gap. The layer is replicated.
|
||||
///
|
||||
/// Four parameters define the geometry of the calorimeter :
|
||||
///
|
||||
/// - the thickness of an absorber plate,
|
||||
/// - the thickness of a gap,
|
||||
/// - the number of layers,
|
||||
/// - the transverse size of the calorimeter (the input face is a square).
|
||||
///
|
||||
/// In ConstructSDandField() sensitive detectors of CalorimeterSD type
|
||||
/// are created and associated with the Absorber and Gap volumes.
|
||||
/// In addition a transverse uniform magnetic field is defined
|
||||
/// via G4GlobalMagFieldMessenger class.
|
||||
|
||||
class DetectorConstruction : public G4VUserDetectorConstruction
|
||||
{
|
||||
public:
|
||||
DetectorConstruction();
|
||||
virtual ~DetectorConstruction();
|
||||
|
||||
public:
|
||||
virtual G4VPhysicalVolume* Construct();
|
||||
virtual void ConstructSDandField();
|
||||
|
||||
private:
|
||||
// data members
|
||||
//
|
||||
static G4ThreadLocal G4GlobalMagFieldMessenger* fMagFieldMessenger;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: PrimaryGeneratorAction.hh 94808 2015-12-10 08:22:26Z gcosmo $
|
||||
//
|
||||
/// \file PrimaryGeneratorAction.hh
|
||||
/// \brief Definition of the PrimaryGeneratorAction class
|
||||
|
||||
#ifndef PrimaryGeneratorAction_h
|
||||
#define PrimaryGeneratorAction_h 1
|
||||
|
||||
#include "G4VUserPrimaryGeneratorAction.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class G4ParticleGun;
|
||||
class G4Event;
|
||||
|
||||
/// The primary generator action class with particle gum.
|
||||
///
|
||||
/// It defines a single particle which hits the calorimeter
|
||||
/// perpendicular to the input face. The type of the particle
|
||||
/// can be changed via the G4 build-in commands of G4ParticleGun class
|
||||
/// (see the macros provided with this example).
|
||||
|
||||
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
|
||||
{
|
||||
public:
|
||||
PrimaryGeneratorAction();
|
||||
virtual ~PrimaryGeneratorAction();
|
||||
|
||||
virtual void GeneratePrimaries(G4Event* event);
|
||||
|
||||
// set methods
|
||||
void SetRandomFlag(G4bool value);
|
||||
|
||||
private:
|
||||
G4ParticleGun* fParticleGun; // G4 particle gun
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: RunAction.hh 74265 2013-10-02 14:41:20Z gcosmo $
|
||||
//
|
||||
/// \file RunAction.hh
|
||||
/// \brief Definition of the RunAction class
|
||||
|
||||
#ifndef RunAction_h
|
||||
#define RunAction_h 1
|
||||
|
||||
#include "G4UserRunAction.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class G4Run;
|
||||
|
||||
/// Run action class
|
||||
///
|
||||
/// It accumulates statistic and computes dispersion of the energy deposit
|
||||
/// and track lengths of charged particles with use of analysis tools:
|
||||
/// H1D histograms are created in BeginOfRunAction() for the following
|
||||
/// physics quantities:
|
||||
/// - Edep in absorber
|
||||
/// - Edep in gap
|
||||
/// - Track length in absorber
|
||||
/// - Track length in gap
|
||||
/// The same values are also saved in the ntuple.
|
||||
/// The histograms and ntuple are saved in the output file in a format
|
||||
/// accoring to a selected technology in Analysis.hh.
|
||||
///
|
||||
/// In EndOfRunAction(), the accumulated statistic and computed
|
||||
/// dispersion is printed.
|
||||
///
|
||||
|
||||
class RunAction : public G4UserRunAction
|
||||
{
|
||||
public:
|
||||
RunAction(const G4String& fileName);
|
||||
virtual ~RunAction();
|
||||
|
||||
virtual void BeginOfRunAction(const G4Run*);
|
||||
virtual void EndOfRunAction(const G4Run*);
|
||||
|
||||
private:
|
||||
G4String fFileName;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
/// \file ScreenSD.hh
|
||||
/// \brief Definition of the ScreenSD class
|
||||
//
|
||||
|
||||
#ifndef ScreenSD_h
|
||||
#define ScreenSD_h 1
|
||||
|
||||
#include "G4VSensitiveDetector.hh"
|
||||
|
||||
class G4Step;
|
||||
class G4HCofThisEvent;
|
||||
class G4TouchableHistory;
|
||||
|
||||
class ScreenSD : public G4VSensitiveDetector
|
||||
{
|
||||
public:
|
||||
ScreenSD(const G4String& name);
|
||||
virtual ~ScreenSD();
|
||||
|
||||
virtual void Initialize(G4HCofThisEvent* hce);
|
||||
virtual G4bool ProcessHits(G4Step* step, G4TouchableHistory* history);
|
||||
virtual void EndOfEvent(G4HCofThisEvent* hce);
|
||||
};
|
||||
|
||||
#endif
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Script to remove classes copied from shared directory into include and src
|
||||
# via copy_files.sh
|
||||
#
|
||||
# By I. Hrivnacova, IPN Orsay
|
||||
|
||||
DIRNAME=$1
|
||||
|
||||
for FILE in `ls $DIRNAME/include`; do
|
||||
rm -f include/$FILE
|
||||
done
|
||||
for FILE in `ls $DIRNAME/src`; do
|
||||
rm -f src/$FILE
|
||||
done
|
||||
|
||||
echo "... clean_files.sh from $1 finished"
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Script to copy classes from shared directory into include and src
|
||||
# as it is required by GNUmake build.
|
||||
# Usage: copy_files.sh directoryName
|
||||
#
|
||||
# By I. Hrivnacova, IPN Orsay
|
||||
|
||||
DIRNAME=$1
|
||||
|
||||
cp -rp $DIRNAME/include/* include
|
||||
cp -rp $DIRNAME/src/* src
|
||||
|
||||
echo "... copy_files.sh from $1 finished"
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: ActionInitialization 68058 2013-03-13 14:47:43Z gcosmo $
|
||||
//
|
||||
/// \file ActionInitialization
|
||||
/// \brief Implementation of the ActionInitialization class
|
||||
|
||||
#include "ActionInitialization.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "RunAction.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ActionInitialization::ActionInitialization(const G4String& fileName)
|
||||
: G4VUserActionInitialization(),
|
||||
fFileName(fileName)
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ActionInitialization::~ActionInitialization()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::BuildForMaster() const
|
||||
{
|
||||
SetUserAction(new RunAction(fFileName));
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::Build() const
|
||||
{
|
||||
SetUserAction(new PrimaryGeneratorAction);
|
||||
SetUserAction(new RunAction(fFileName));
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,181 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: DetectorConstruction 101905 2016-12-07 11:34:39Z gunter $
|
||||
//
|
||||
/// \file DetectorConstruction
|
||||
/// \brief Implementation of the DetectorConstruction class
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "ScreenSD.hh"
|
||||
|
||||
#include "G4Material.hh"
|
||||
#include "G4NistManager.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4GlobalMagFieldMessenger.hh"
|
||||
#include "G4SDManager.hh"
|
||||
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4Colour.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4AutoDelete.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4ThreadLocal
|
||||
G4GlobalMagFieldMessenger* DetectorConstruction::fMagFieldMessenger = 0;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::DetectorConstruction()
|
||||
: G4VUserDetectorConstruction()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::~DetectorConstruction()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* DetectorConstruction::Construct()
|
||||
{
|
||||
// Get nist material manager
|
||||
G4NistManager* nistManager = G4NistManager::Instance();
|
||||
|
||||
// Build materials
|
||||
G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
|
||||
G4Material* csi = nistManager->FindOrBuildMaterial("G4_CESIUM_IODIDE");
|
||||
// There is no need to test if materials were built/found
|
||||
// as G4NistManager would issue an error otherwise
|
||||
// Try the code with "XYZ".
|
||||
|
||||
// Print all materials
|
||||
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
|
||||
|
||||
// Option to switch on/off checking of volumes overlaps
|
||||
G4bool checkOverlaps = true;
|
||||
|
||||
//
|
||||
// World
|
||||
//
|
||||
|
||||
// The world dimensions
|
||||
G4double worldHxyz = 2.*m;
|
||||
|
||||
// world volume
|
||||
G4Box* worldS = new G4Box("World", worldHxyz, worldHxyz, worldHxyz);
|
||||
|
||||
G4LogicalVolume* worldLV = new G4LogicalVolume(worldS, air, "World");
|
||||
|
||||
G4VPhysicalVolume* worldPV
|
||||
= new G4PVPlacement(
|
||||
0, G4ThreeVector(), worldLV, "World", 0, false, 0, checkOverlaps);
|
||||
|
||||
//
|
||||
// Box
|
||||
//
|
||||
|
||||
// The box dimensions
|
||||
G4double boxHxy = 1.*m;
|
||||
G4double boxHz = 10.*cm;
|
||||
|
||||
// box volume
|
||||
G4Box* boxS = new G4Box("World", boxHxy, boxHxy, boxHz);
|
||||
|
||||
G4LogicalVolume* boxLV = new G4LogicalVolume(boxS, csi, "Box");
|
||||
|
||||
// The box position
|
||||
G4double posz = 0.*m;
|
||||
|
||||
new G4PVPlacement(
|
||||
0, G4ThreeVector(0, 0, posz),
|
||||
boxLV, "Box", worldLV, false, 0, checkOverlaps);
|
||||
|
||||
//
|
||||
// Scoring screen
|
||||
//
|
||||
// The screen dimensions
|
||||
G4double screenHxy = 1.999*m;
|
||||
G4double screenHz = 1.*mm;
|
||||
|
||||
// Screen volume
|
||||
G4Box* screenS = new G4Box("World", screenHxy, screenHxy, screenHz);
|
||||
|
||||
G4LogicalVolume* screenLV = new G4LogicalVolume(screenS, air, "Screen");
|
||||
|
||||
// The screen position
|
||||
posz += boxHz + screenHz;
|
||||
|
||||
new G4PVPlacement(
|
||||
0, G4ThreeVector(0, 0, posz),
|
||||
screenLV, "Screen", worldLV, false, 0, checkOverlaps);
|
||||
|
||||
//
|
||||
// Visualization attributes
|
||||
//
|
||||
worldLV->SetVisAttributes(G4VisAttributes::GetInvisible());
|
||||
|
||||
auto simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
|
||||
simpleBoxVisAtt->SetVisibility(true);
|
||||
boxLV->SetVisAttributes(simpleBoxVisAtt);
|
||||
screenLV->SetVisAttributes(simpleBoxVisAtt);
|
||||
|
||||
//
|
||||
// Always return the physical World
|
||||
//
|
||||
return worldPV;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::ConstructSDandField()
|
||||
{
|
||||
// G4SDManager::GetSDMpointer()->SetVerboseLevel(1);
|
||||
|
||||
//
|
||||
// Sensitive detectors
|
||||
//
|
||||
auto screenSD = new ScreenSD("ScreenSD");
|
||||
G4SDManager::GetSDMpointer()->AddNewDetector(screenSD);
|
||||
SetSensitiveDetector("Screen", screenSD);
|
||||
|
||||
//
|
||||
// Magnetic field
|
||||
//
|
||||
// Create global magnetic field messenger.
|
||||
// Uniform magnetic field is then created automatically if
|
||||
// the field value is not zero.
|
||||
G4ThreeVector fieldValue;
|
||||
fMagFieldMessenger = new G4GlobalMagFieldMessenger(fieldValue);
|
||||
fMagFieldMessenger->SetVerboseLevel(1);
|
||||
|
||||
// Register the field messenger for deleting
|
||||
G4AutoDelete::Register(fMagFieldMessenger);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: PrimaryGeneratorAction 100946 2016-11-03 11:28:08Z gcosmo $
|
||||
//
|
||||
/// \file PrimaryGeneratorAction
|
||||
/// \brief Implementation of the PrimaryGeneratorAction class
|
||||
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4Proton.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::PrimaryGeneratorAction()
|
||||
: G4VUserPrimaryGeneratorAction(),
|
||||
fParticleGun(nullptr)
|
||||
{
|
||||
G4int nofParticles = 1;
|
||||
fParticleGun = new G4ParticleGun(nofParticles);
|
||||
|
||||
// default particle kinematic
|
||||
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
|
||||
fParticleGun->SetParticleEnergy(1.*GeV);
|
||||
fParticleGun->SetParticleDefinition(G4Proton::Proton());
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::~PrimaryGeneratorAction()
|
||||
{
|
||||
delete fParticleGun;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
// This function is called at the begining of event
|
||||
|
||||
// In order to avoid dependence of PrimaryGeneratorAction
|
||||
// on DetectorConstruction class we get world volume
|
||||
// from G4LogicalVolumeStore
|
||||
//
|
||||
G4double worldZHalfLength = 0.;
|
||||
auto worldLV = G4LogicalVolumeStore::GetInstance()->GetVolume("World");
|
||||
|
||||
// Check that the world volume has box shape
|
||||
G4Box* worldBox = nullptr;
|
||||
if ( worldLV ) {
|
||||
worldBox = dynamic_cast<G4Box*>(worldLV->GetSolid());
|
||||
}
|
||||
|
||||
if ( worldBox ) {
|
||||
worldZHalfLength = worldBox->GetZHalfLength();
|
||||
}
|
||||
else {
|
||||
G4ExceptionDescription msg;
|
||||
msg << "World volume of box shape not found." << G4endl;
|
||||
msg << "Perhaps you have changed geometry." << G4endl;
|
||||
msg << "The gun will be place in the center.";
|
||||
G4Exception("PrimaryGeneratorAction::GeneratePrimaries()",
|
||||
"MyCode0002", JustWarning, msg);
|
||||
}
|
||||
|
||||
// Set gun position
|
||||
fParticleGun
|
||||
->SetParticlePosition(G4ThreeVector(0., 0., -worldZHalfLength));
|
||||
|
||||
fParticleGun->GeneratePrimaryVertex(anEvent);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: RunAction 100946 2016-11-03 11:28:08Z gcosmo $
|
||||
//
|
||||
/// \file RunAction
|
||||
/// \brief Implementation of the RunAction class
|
||||
|
||||
#include "RunAction.hh"
|
||||
#include "Analysis.hh"
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::RunAction(const G4String& fileName)
|
||||
: G4UserRunAction(),
|
||||
fFileName(fileName)
|
||||
{
|
||||
// Create analysis manager
|
||||
// The choice of analysis technology is done via selectin of a namespace
|
||||
// in Analysis.hh
|
||||
auto analysisManager = G4AnalysisManager::Instance();
|
||||
G4cout << "Using " << analysisManager->GetType() << G4endl;
|
||||
analysisManager->SetVerboseLevel(1);
|
||||
analysisManager->SetNtupleMerging(true);
|
||||
// Note: merging ntuples is available only with Root output
|
||||
|
||||
// Set default fileName
|
||||
analysisManager->SetFileName(fFileName);
|
||||
|
||||
// Create ntuple
|
||||
//
|
||||
analysisManager->CreateNtuple("Screen", "Screen hits");
|
||||
analysisManager->CreateNtupleIColumn("ID"); // column id = 0
|
||||
analysisManager->CreateNtupleIColumn("PDG"); // column id = 1
|
||||
analysisManager->CreateNtupleDColumn("Ekin"); // column id = 2
|
||||
analysisManager->CreateNtupleDColumn("Xpos"); // column id = 3
|
||||
analysisManager->CreateNtupleDColumn("Ypos"); // column id = 4
|
||||
analysisManager->CreateNtupleDColumn("time"); // column id = 5
|
||||
analysisManager->FinishNtuple();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::~RunAction()
|
||||
{
|
||||
delete G4AnalysisManager::Instance();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::BeginOfRunAction(const G4Run* /*run*/)
|
||||
{
|
||||
// Get analysis manager
|
||||
auto analysisManager = G4AnalysisManager::Instance();
|
||||
|
||||
// Open an output file
|
||||
analysisManager->OpenFile();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::EndOfRunAction(const G4Run* /*run*/)
|
||||
{
|
||||
// Save ntuple and close file
|
||||
auto analysisManager = G4AnalysisManager::Instance();
|
||||
analysisManager->Write();
|
||||
analysisManager->CloseFile();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,108 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
/// \file ScreenSD.cc
|
||||
/// \brief Implementation of the ScreenSD class
|
||||
//
|
||||
|
||||
#include "ScreenSD.hh"
|
||||
#include "Analysis.hh"
|
||||
|
||||
#include "G4VTouchable.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
#include "G4VProcess.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ScreenSD::ScreenSD(const G4String& name)
|
||||
: G4VSensitiveDetector(name)
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ScreenSD::~ScreenSD()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ScreenSD::Initialize(G4HCofThisEvent* /*hce*/)
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4bool ScreenSD::ProcessHits(G4Step* step, G4TouchableHistory* /*history*/)
|
||||
{
|
||||
// Current track:
|
||||
const G4Track* track = step->GetTrack();
|
||||
|
||||
// Track ID:
|
||||
G4int ID = track->GetTrackID();
|
||||
|
||||
// code PDG:
|
||||
G4int pdgCode = track->GetDefinition()->GetPDGEncoding();
|
||||
|
||||
// Remember preStepPoint:
|
||||
G4StepPoint* preStepPoint = step->GetPreStepPoint();
|
||||
|
||||
// Ekin:
|
||||
G4double Ekin = preStepPoint->GetKineticEnergy();
|
||||
|
||||
// Obtain local coordinates:
|
||||
const G4VTouchable* touchable = preStepPoint->GetTouchable();
|
||||
G4ThreeVector globalPosition = preStepPoint->GetPosition();
|
||||
G4ThreeVector localPosition
|
||||
= touchable->GetHistory()->GetTopTransform().TransformPoint(globalPosition);
|
||||
// // Example for obtaining the local direction:
|
||||
// G4ThreeVector globalDirection = preStepPoint->GetMomentumDirection();
|
||||
// G4ThreeVector localDirection
|
||||
// = touchable->GetHistory()->GetTopTransform().TransformAxis(localDirection);
|
||||
|
||||
// Time
|
||||
G4double time = preStepPoint->GetGlobalTime();
|
||||
|
||||
// Store hit in the ntuple
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
analysisManager->FillNtupleIColumn(0, ID);
|
||||
analysisManager->FillNtupleIColumn(1, pdgCode);
|
||||
analysisManager->FillNtupleDColumn(2, Ekin/MeV);
|
||||
analysisManager->FillNtupleDColumn(3, localPosition.x()/cm);
|
||||
analysisManager->FillNtupleDColumn(4, localPosition.y()/cm);
|
||||
analysisManager->FillNtupleDColumn(5, time/ns);
|
||||
analysisManager->AddNtupleRow();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ScreenSD::EndOfEvent(G4HCofThisEvent* /*hce*/)
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
Reference in New Issue
Block a user