Import Geant4 10.7.0 source tree

This commit is contained in:
Gabriele Cosmo
2020-12-04 12:30:43 +01:00
parent 67ba86d073
commit dab42d2018
3770 changed files with 226369 additions and 286486 deletions
@@ -0,0 +1,48 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#ifndef ACTIONINITIALIZATION_HH
#define ACTIONINITIALIZATION_HH
#include "G4VUserActionInitialization.hh"
/**
* @brief Initialization of user actions.
*
* Initialises the primary generator, and user actions (event, run) to store
* output.
*
*/
class ActionInitialization : public G4VUserActionInitialization {
public:
ActionInitialization();
virtual ~ActionInitialization();
virtual void BuildForMaster() const;
virtual void Build() const;
};
#endif /* ACTIONINITIALIZATION_HH */
@@ -0,0 +1,51 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#ifndef CMSEMSTANDARDPHYSICSHCAL_HH
#define CMSEMSTANDARDPHYSICSHCAL_HH
#include "G4VPhysicsConstructor.hh"
/**
* @brief EM physics
*
* Used in FTFPCMS_BERT_EMM physics list. Copy from test46.
*
*/
class CMSEmStandardPhysicsHcal : public G4VPhysicsConstructor {
public:
explicit CMSEmStandardPhysicsHcal(G4int ver);
virtual ~CMSEmStandardPhysicsHcal();
virtual void ConstructParticle();
virtual void ConstructProcess();
private:
G4int fVerbose = 0;
};
#endif /* CMSEMSTANDARDPHYSICSHCAL_HH */
@@ -0,0 +1,88 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#ifndef DETECTORCONSTRUCTION_HH
#define DETECTORCONSTRUCTION_HH
#include "G4VUserDetectorConstruction.hh"
#include "G4Types.hh"
#include <utility>
#include <vector>
class G4VPhysicalVolume;
class G4LogicalVolume;
class G4GenericMessenger;
class HGCalTBMaterials;
/**
* @brief Detector construction.
*
* Creates a detector with a configuration set by UI commands. By default a test
* module is build (few elements including a silicon sensor).
* Sensitive detectors are attached to silicon sensors.
*
*/
class DetectorConstruction : public G4VUserDetectorConstruction {
public:
DetectorConstruction();
virtual ~DetectorConstruction();
virtual G4VPhysicalVolume *Construct();
virtual void ConstructSDandField();
private:
/// Define UI commands: configuration of detector (geometry setup), and
/// maximal step size in silicon
void DefineCommands();
/// Set detector setup configuration based on ID
/// @param[in] aValue ID of detector configuration
void SelectConfiguration(G4int aValue);
/// Set maximal size of step within silicon sensor
/// Can be changed by the UI command /HGCalTestbeam/setup/stepSilicon
/// @param[in] aValue Max step size
void SetStepSizeSilicon(G4double aValue);
/// Helper method placing the logical volumes from map of elements
void ConstructHGCal();
/// Pointer to the logical volume of the world
G4LogicalVolume *fLogicWorld = nullptr;
/// Pointer to the messenger for UI commands
G4GenericMessenger *fMessenger = nullptr;
/// Pointer to the class that defines materials and logical volumes of all
/// possible elements, to be placed according to the configuration setup
HGCalTBMaterials *fMaterials = nullptr;
/// Map of elements to be placed along z axis: name and distance to the
/// previous element is specified
std::vector<std::pair<G4String, G4double>> fElementsMap;
/// Viewpoint for the visualisation
G4double fVisViewpoint = 0;
/// Configuration of the detector setup
/// Can be changed by the UI command /HGCalTestbeam/setup/configuration
G4int fConfiguration = 0;
};
#endif /* DETECTORCONSTRUCTION_HH */
@@ -0,0 +1,67 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#ifndef DETECTORCONSTRUCTION0_HH
#define DETECTORCONSTRUCTION0_HH
#include "G4String.hh"
#include "G4Types.hh"
#include <vector>
#include <utility>
/// Add module of silicon sensor with absorbers, readout, and support, for the
/// electromagnetic calorimeter (EE).
/// @param[in] aEEid ID of module in the setup (not all modules are identical)
/// @param[out] aDzMap List of element names and air gap to be placed in front
/// of the element
/// @param[in] aAirBefore How much air should be added before the current module
/// (before the first iron)
/// @param[in] aAirMid How much air should be added in the middle (before the
/// first PCB)
void add_EE(G4int aEEid, std::vector<std::pair<G4String, G4double>> &aDzMap,
G4double aAirBefore, G4double aAirMid);
/// Add module of scintillator sensor with absorbers, readout, and support, for
/// the hadronic calorimeter (FH).
/// @param[in] aFHid ID of module in the setup (not all modules are identical)
/// @param[out] aDzMap List of element names and air gap to be placed in front
/// of the element
/// @param[in] aAirBefore How much air should be added before the current module
/// (before the first iron)
/// @param[in] aAirMid How much air should be added in the middle (before the
/// first PCB)
void add_FH(G4int aFHid, std::vector<std::pair<G4String, G4double>> &aDzMap,
G4double aAirBefore, G4double aAirMid);
/// Define detector setup for test beam run in October 2018
/// @param[out] aDzMap List of element names and air gap to be placed in front
/// of the element
/// @param[out] aViewpoint Targer point to be set in the visualisation
void DetectorConstruction0(
std::vector<std::pair<G4String, G4double>> &aDzMap,
G4double &aViewpoint);
#endif /* DETECTORCONSTRUCTION0_HH */
@@ -0,0 +1,45 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#ifndef DETECTORCONSTRUCTION1_HH
#define DETECTORCONSTRUCTION1_HH
#include "G4String.hh"
#include "G4Types.hh"
#include <vector>
#include <utility>
/// Define detector setup for test beam run in October 2018
/// Include the beamline elements in the simulation.
/// @param[out] aDzMap List of element names and air gap to be placed in front
/// of the element
/// @param[out] aViewpoint Targer point to be set in the visualisation
void DetectorConstruction1(
std::vector<std::pair<G4String, G4double>> &aDzMap,
G4double &aViewpoint);
#endif /* DETECTORCONSTRUCTION1_HH */
@@ -0,0 +1,42 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#ifndef DETECTORCONSTRUCTION2_HH
#define DETECTORCONSTRUCTION2_HH
#include "G4Types.hh"
#include "G4String.hh"
#include <utility>
#include <vector>
/// Define test setup
/// @param[out] aDzMap List of element names and air gap to be placed in front
/// of the element
/// @param[out] aViewpoint Targer point to be set in the visualisation
void DetectorConstruction2(std::vector<std::pair<G4String, G4double>> &aDzMap,
G4double &aViewpoint);
#endif /* DETECTORCONSTRUCTION2_HH */
@@ -0,0 +1,129 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#ifndef EVENTACTION_HH
#define EVENTACTION_HH
#include "G4UserEventAction.hh"
#include "G4Types.hh"
#include <vector>
class G4GenericMessenger;
/**
* @brief Event action class
*
* Fills ntuples with information about hits in sensitive detectors.
*
*/
class EventAction : public G4UserEventAction {
public:
EventAction();
virtual ~EventAction();
virtual void BeginOfEventAction(const G4Event *event);
virtual void EndOfEventAction(const G4Event *event);
/// Vector of primary particles in an event: PDG type
std::vector<G4int> fPrimariesPDG;
/// Vector of primary particles in an event: particle energy (in GeV)
std::vector<G4double> fPrimariesEnergy;
/// Vector of primary particles in an event: vertex position x (in cm)
std::vector<G4double> fPrimariesX;
/// Vector of primary particles in an event: vertex position y (in cm)
std::vector<G4double> fPrimariesY;
/// Vector of primary particles in an event: vertex position z (in cm)
std::vector<G4double> fPrimariesZ;
/// Vector of hits in silicon sensors: hit ID
std::vector<G4int> fSiHitsID;
/// Vector of hits in silicon sensors: hit position x (in cm)
std::vector<G4double> fSiHitsX;
/// Vector of hits in silicon sensors: hit position y (in cm)
std::vector<G4double> fSiHitsY;
/// Vector of hits in silicon sensors: hit position z (in cm)
std::vector<G4double> fSiHitsZ;
/// Vector of hits in silicon sensors: hit energy (in keV)
std::vector<G4double> fSiHitsEdep;
/// Vector of hits in silicon sensors: hit non-ionizing energy (in keV)
std::vector<G4double> fSiHitsEdepNonIonising;
/// Vector of hits in silicon sensors: hit time of arrival (in ns)
/// calculated as global time of energy deposit which added to hit energy
/// exceeds the toa threshold (by default threshold is 0, so it is the first
/// deposit)
std::vector<G4double> fSiHitsTOA;
/// Vector of hits in silicon sensors: hit time of last arrival (in ns)
/// calculated as global time of energy deposit which is the last deposit
/// that fits within the digitisation time window (by default window is
/// undefined, so it is the last deposit)
std::vector<G4double> fSiHitsTOAlast;
/// Vector of hits in silicon sensors: hit type
/// Simulation defines only hits of type 0 (hexagonal cells, no calibration or
/// edge cell is constructed)
std::vector<G4int> fSiHitsType;
/// Vector of hits in SiPM: hit ID
std::vector<G4int> fSiPMhitsID;
/// Vector of hits in SiPM: hit position x (in cm)
std::vector<G4double> fSiPMhitsX;
/// Vector of hits in SiPM: hit position y (in cm)
std::vector<G4double> fSiPMhitsY;
/// Vector of hits in SiPM: hit position z (in cm)
std::vector<G4double> fSiPMhitsZ;
/// Vector of hits in SiPM: hit energy (in keV)
std::vector<G4double> fSiPMhitsEdep;
/// Vector of hits in SiPM: hit non-ionizing energy (in keV)
std::vector<G4double> fSiPMhitsEdepNonIonising;
/// Vector of hits in SiPM: hit time of last arrival (in ns)
/// calculated as global time of energy deposit which is the last deposit
/// that fits within the digitisation time window (by default window is
/// undefined, so it is the last deposit)
std::vector<G4double> fSiPMhitsTOA;
/// Vector of hits in silicon sensors: hit type
/// Simulation defines only hits of type 1
std::vector<G4int> fSiPMhitsType;
private:
/// Define UI commands: digitisation of hits with the time cut on deposits
/// (time window), and the energy threshold for the first deposit counted as
/// the time of arrival
void DefineCommands();
/// Pointer to the messenger for UI commands
G4GenericMessenger *fMessenger = nullptr;
/// Time window for hit digitisation (in ns)
/// By default undefined window indicates the last created deposit will set up
/// the time
/// Can be changed by the UI command /HGCalTestbeam/hits/timeCut
G4double fHitTimeCut = -1;
/// Time of arrival threshold (in keV)
/// Default value of 0 indicates the first created deposit will set up the
/// time, independent on the amount of deposited energy
/// Can be changed by the UI command /HGCalTestbeam/hits/toaThreshold
G4double fToaThreshold = 0;
};
#endif /* EVENTACTION_HH */
@@ -0,0 +1,47 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#ifndef FTFPCMS_BERT_EMM_HH
#define FTFPCMS_BERT_EMM_HH
#include "G4VModularPhysicsList.hh"
/**
* @brief FTFPCMS_BERT_EMM physics list
*
* FTFPCMS_BERT_EMM physics list. Copy from test46.
*
*/
class FTFPCMS_BERT_EMM : public G4VModularPhysicsList {
public:
explicit FTFPCMS_BERT_EMM(G4int ver = 1);
virtual ~FTFPCMS_BERT_EMM();
virtual void SetCuts();
};
#endif /* FTFPCMS_BERT_EMM_HH */
@@ -0,0 +1,210 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#ifndef HGCALTBMATERIALS_HH
#define HGCALTBMATERIALS_HH
#include "G4Types.hh"
#include "G4String.hh"
#include "CLHEP/Units/SystemOfUnits.h"
#include <map>
class G4Box;
class G4LogicalVolume;
class G4Material;
class G4SubtractionSolid;
/// Construction of a hexagon solid
/// @param[in] name Name of the solid
/// @param[in] cellThickness Thickness of the hexagon
/// @param[in] cellSideLength Length of a side of the haxagon
/// @return Solid
G4SubtractionSolid *HexagonSolid(G4String name, G4double cellThickness,
G4double cellSideLength);
/// Construction of a logical volume
/// @param[in] name Name of the solid
/// @param[in] cellThickness Thickness of the hexagon
/// @param[in] cellSideLength Length of a side of the haxagon
/// @param[in] material Material
/// @return Logical volume
G4LogicalVolume *HexagonLogical(G4String name, G4double cellThickness,
G4double cellSideLength, G4Material *material);
/**
* @brief HGCal material and elements definitions
*
* Defines materials used for HGCal test-beam.
* Creates logical volumes for every element that may be constructed and placed
* in the test beam.
*
*/
class HGCalTBMaterials {
public:
/// Create HGCal materials
HGCalTBMaterials();
/// Set visualisation attributes
void SetEventDisplayColorScheme();
/// Get length of the beam line (world)
inline G4double GetBeamLineLength() const { return fBeamLineLength; }
/// Get transverse size of the beam line (world)
inline G4double GetBeamLineXY() const { return fBeamLineXY; }
/// Get pointer to the air material
G4Material *GetAir() { return fMatAIR; }
/// Place logical volume
/// @param[in] aName Name of the logical volume
/// @param[in,out] aZ0 Position in front of the logical volume, incremented by
/// half the thickness for placement, and by another half thickness to return
/// the position just behind the placed volume
/// @param[in] aLogicMother Pointer to mother volume for placement
void PlaceItemInLogicalVolume(std::string aName, G4double &aZ0,
G4LogicalVolume *aLogicMother);
/// Get logical volume of silicon pixel (cell)
G4LogicalVolume *GetSiPixelLogical() { return this->fSiPixelLogical; }
/// Get logical volume of SiPM
G4LogicalVolume *GetAHCALSiPMlogical() { return this->fAHCALSiPMlogical; }
/// Get any logical volume by name
inline const G4LogicalVolume *GetLogicalVolume(G4String aName) {
return fLogicalVolumeMap[aName];
};
/// Get thickness of logical volume by name
inline G4double GetThickness(std::string aName) {
return fThicknessMap[aName];
};
private:
/// Define materisals used in HGCal test-beam
void DefineMaterials();
/// Define silicon wafer logical volume from silicon cells/pixels
void DefineSiWaferAndCells();
/// Define logical volumes for HGCal baseplates (CuW, Cu, PCB, Kapton layers)
void DefineHGCalBaseplates();
/// Define logical volumes for HGCal cases (Al, Steel)
void DefineHGCalCases();
/// Define logical volumes for HGCal electromagnetic part absorbers (Pb, Cu,
/// W)
void DefineHGCalEEAbsorbers();
/// Define logical volumes for HGCal hadronic part absorbers (Cu, Fe)
void DefineHGCalFHAbsorbers();
/// Define logical volumes for AHCAL SiPM
void DefineAHCALSiPM();
/// Define logical volumes for AHCAL absorbers
void DefineAHCALAbsorbers();
/// Define logical volumes for beamline elements (MCP, scintillators, DWC)
void DefineBeamLineElements();
/// Length of the beam line
G4double fBeamLineLength = 90 * CLHEP::m;
/// Transverse dimension of the beam line
G4double fBeamLineXY = 4 * CLHEP::m;
/// Rotation angle of silicon hexagon
G4double fAlpha;
/// Side length of silicon cell hexagon
G4double fSiPixelSideLength;
/// Thickness of silicon wafer hexagon
G4double fSiWaferThickness;
/// Side length of silicon wafer haxagon
G4double fSiWaferSideLength;
/// Transverse size of AHCAL SiPM
G4double fAHCALSiPMxy;
/// Box representing AHCAL SiPM
G4Box *fAHCALSiPMsolid;
/// Map of volume name to its thickness
std::map<G4String, G4double> fThicknessMap;
/// Map of volume name to its logical volume
std::map<G4String, G4LogicalVolume *> fLogicalVolumeMap;
/// Map of volume name to counter of placed copies
std::map<G4String, int> fCopyCounterMap;
/// Materials
G4Material *fMatVacuum;
G4Material *fMatAIR;
G4Material *fMatAr;
G4Material *fMatAl;
G4Material *fMatFe;
G4Material *fMatGlass;
G4Material *fMatSteel;
G4Material *fMatPb;
G4Material *fMatCu;
G4Material *fMatW;
G4Material *fMatSi;
G4Material *fMatKAPTON;
G4Material *fMatAu;
G4Material *fMatPCB;
G4Material *fMatQuartz;
G4Material *fMatPolystyrene;
G4Material *fMatCuW;
G4Material *fMatC;
G4Material *fMatH;
G4Material *fMatO;
G4Material *fMatMn;
G4Material *fMatCr;
G4Material *fMatNi;
G4Material *fMatPolyethylene;
G4Material *fMatFreon;
G4Material *fMatScintillator;
G4Material *fMatArCO2;
G4Material *fMatCl;
G4Material *fMatF;
/// Logical volumes
G4LogicalVolume *fSiPixelLogical;
G4LogicalVolume *fSiWaferLogical;
G4LogicalVolume *fCuWbaseplateLogical;
G4LogicalVolume *fCuWbaseplate550umLogical;
G4LogicalVolume *fCuWbaseplate610umLogical;
G4LogicalVolume *fCuWbaseplate710umLogical;
G4LogicalVolume *fCuBaseplateLogical;
G4LogicalVolume *fCuBaseplate25umLogical;
G4LogicalVolume *fCuBaseplate175umLogical;
G4LogicalVolume *fPCBbaseplateLogical;
G4LogicalVolume *fPCBbaseplateThinLogical;
G4LogicalVolume *fKaptonLayerLogical;
G4LogicalVolume *fAlCaseLogical;
G4LogicalVolume *fAlCaseThickLogical;
G4LogicalVolume *fAlChipLogical;
G4LogicalVolume *fSteelCaseLogical;
G4LogicalVolume *fSteelCaseThickLogical;
G4LogicalVolume *fPbAbsorberEElogical;
G4LogicalVolume *fFeAbsorberEElogical;
G4LogicalVolume *fCuAbsorberEElogical;
G4LogicalVolume *fWabsorberEElogical;
G4LogicalVolume *fW2mmAbsorberEEDESY2018Logical;
G4LogicalVolume *fW4mmAbsorberEEDESY2018Logical;
G4LogicalVolume *fCuAbsorberFHlogical;
G4LogicalVolume *fFeAbsorberFHlogical;
G4LogicalVolume *fAHCALSiPMlogical;
G4LogicalVolume *fAHCALSiPM2x2HUBlogical;
G4LogicalVolume *fAlAbsorberAHCALlogical;
G4LogicalVolume *fPCBAHCALlogical;
G4LogicalVolume *fFeAbsorberAHCALlogical;
G4LogicalVolume *fScintillatorLogical;
G4LogicalVolume *fScintillatorThinLogical;
G4LogicalVolume *fMCPlogical;
G4LogicalVolume *fDWClogical;
G4LogicalVolume *fDWCgasLogical;
G4LogicalVolume *fCK3logical;
};
#endif /* HGCALTBMATERIALS_HH */
@@ -0,0 +1,224 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#ifndef PRIMARYGENERATORACTION_HH
#define PRIMARYGENERATORACTION_HH
#include "G4String.hh"
#include "G4VUserPrimaryGeneratorAction.hh"
#include "CLHEP/Units/SystemOfUnits.h"
class G4ParticleGun;
class G4Event;
class G4Box;
class PrimaryGeneratorMessenger;
#ifdef WITHROOT
#include <RtypesCore.h>
class TFile;
class TTreeReader;
template <typename T> class TTreeReaderValue;
#endif
/**
* @brief Primary generator
*
* Primary generator action.
*
* By default particle gun is used. It can be controlled with standard UI
* commands (/gun/) and with additional ones introduced by the messenger.
* "/HGCalTestbeam/generator/momentumSpread <VALUE>" to change constant
* particle energy to Gaussian distribution with sigma expressed in units of the
* initial energy (e.g. value 0.05 means sigma of 0.05 * E).
* By default it equals to 0 and constant energy value is used.
* "/HGCalTestbeam/generator/beamSpread <none/Gaussian/flat>" to define type of
* beam position spread. By default none is used.
* "/HGCalTestbeam/generator/beamSpreadX <SIZE>" to define size of beam spread
* along x axis. It is sigma of a Gaussian distribution, or half-width of a
* flat distribution.
* "/HGCalTestbeam/generator/beamSpreadY <SIZE>" to define size of beam spread
* along y axis. It is sigma of a Gaussian distribution, or half-width of a
* flat distribution.
* "/HGCalTestbeam/generator/fBeamZ0 <POSITION>" to define beam position along z
* axis. By default edge of the world volume is used.
*
* If installation was done with ROOT package (CMake was able to locate it),
* an additional option of input read from the ROOT file is enabled.
* It can be activated with "/HGCalTestbeam/generator/fReadInputFile true".
* "/HGCalTestbeam/generator/fPathInputFile <FILE>" sets the path to the input
* file.
* "/HGCalTestbeam/generator/startFromEvent <N>" allows to start simulation from
* Nth event.
* Please note that in current implementation input from file needs to be
* executed in a non-multithreaded mode (or with 1 thread).
*
*/
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction {
public:
PrimaryGeneratorAction();
virtual ~PrimaryGeneratorAction();
virtual void GeneratePrimaries(G4Event *);
const G4ParticleGun *GetParticleGun() const { return fParticleGun; }
#ifdef WITHROOT
/// Open input file with list of particles
void OpenInput();
/// Set flag indicating that particles should be read from file
inline void SetIfUseInputFiles(G4bool aUseInputFiles) {
fReadInputFile = aUseInputFiles;
};
/// Set the flag indicating that particles should be read from file
inline G4bool GetIfUseInputFiles() { return fReadInputFile; }
/// Set the path to the input file
inline void SetInputFiles(G4String aInputFiles) {
fPathInputFile = aInputFiles;
};
/// Get the path to the input file
inline G4String GetInputFiles() const { return fPathInputFile; }
/// Set ID of the first event to be read for the simulation
inline void SetStartFromEvent(G4int aStartFromEvent) {
fStartFromEvent = aStartFromEvent;
};
/// Get ID of the first event to be read for the simulation
inline G4int GetStartFromEvent() const { return fStartFromEvent; }
#endif
/// Set sigma of the Gaussian distribution for the momentum spread
/// @param[in] aMomentumSpread sigma of Gaussian distribution expressed in
/// units of initial energy (e.g. 0.05 means sigma = 0.05 * E)
inline void SetMomentumSpread(G4double aMomentumSpread) {
fMomentumGaussianSpread = aMomentumSpread;
};
/// Get sigma of the Gaussian distribution for the momentum spread
inline G4double GetMomentumSpread() const { return fMomentumGaussianSpread; }
/// Set type of beam position spread
/// @param[in] aType Type of beam position spread: "none", "Gaussian" or
/// "flat". By default "none" is used.
inline void SetBeamSpreadType(G4String aType) {
if (aType == "none")
fBeamType = eNone;
if (aType == "Gaussian")
fBeamType = eGaussian;
if (aType == "flat")
fBeamType = eFlat;
}
/// Get type of beam position spread
inline G4String GetBeamSpreadType() const {
switch (fBeamType) {
case eNone:
return "none";
break;
case eGaussian:
return "Gaussian";
break;
case eFlat:
return "flat";
break;
}
return "";
}
/// Set size of beam position spread along X axis
/// @param[in] aBeamSpreadX Size of beam position spread. Sigma for Gaussian
/// distribution or half-width of flat distribution.
inline void SetBeamSpreadX(G4double aBeamSpreadX) {
fSigmaBeamX = aBeamSpreadX;
}
/// Get size of beam position spread along X axis
inline G4double GetBeamSpreadX() const { return fSigmaBeamX; }
/// Set size of beam position spread along Y axis
/// @param[in] aBeamSpreadY Size of beam position spread. Sigma for Gaussian
/// distribution or half-width of flat distribution.
inline void SetBeamSpreadY(G4double aBeamSpreadY) {
fSigmaBeamY = aBeamSpreadY;
}
/// Get size of beam position spread along Y axis
inline G4double GetBeamSpreadY() const { return fSigmaBeamY; }
/// Set initial beam position along Z axis
/// By default edge of world volume is used
inline void SetBeamZ0(G4double aBeamZ0) { fBeamZ0 = aBeamZ0; }
/// Get initial beam position along Z axis
inline G4double GetBeamZ0() const { return fBeamZ0; }
private:
/// Pointer to the particle gun
G4ParticleGun *fParticleGun;
/// Pointer to the world volume for initial beam position
G4Box *fEnvelopeBox;
/// Pointer to the messenger with custom UI commands
PrimaryGeneratorMessenger *fMessenger;
/// enum describing the beam position spread in transverse plane
enum eBeamType { eNone, eGaussian, eFlat };
/// Type of beam position spread in transverse dimension
eBeamType fBeamType = eBeamType::eNone;
/// Size of beam position spread along X axis
/// Sigma for Gaussian, and half-width for flat distribution
G4double fSigmaBeamX = 0;
/// Size of beam position spread along Y axis
/// Sigma for Gaussian, and half-width for flat distribution
G4double fSigmaBeamY = 0;
/// Initial beam position along Z axis
G4double fBeamZ0 = -999 * CLHEP::m;
/// Sigma of Gaussian momentum spread
G4double fMomentumGaussianSpread = 0;
#ifdef WITHROOT
/// Flag indicating if primaries should be read from file instead of using
/// the particle gun
G4bool fReadInputFile = false;
/// Path to the input file
G4String fPathInputFile = "";
/// ID of the first event in the file to be used in this simulation
G4int fStartFromEvent = 0;
/// Counter of event
G4int fEventCounter = -1;
/// Pointer to the input file
TFile *fInputFile = nullptr;
/// Pointer to the tree containing particles
TTreeReader *fHgcalReader = nullptr;
/// Reader of event ID
TTreeReaderValue<Float_t> *fHgcalEventId;
/// Reader of particle PDG
TTreeReaderValue<Float_t> *fHgcalPdgId;
/// Reader of particle X position (in mm)
TTreeReaderValue<Float_t> *fHgcalPosX;
/// Reader of particle Y position (in mm)
TTreeReaderValue<Float_t> *fHgcalPosY;
/// Reader of particle Z position (in mm)
TTreeReaderValue<Float_t> *fHgcalPosZ;
/// Reader of particle X momentum (in MeV)
TTreeReaderValue<Float_t> *fHgcalMomX;
/// Reader of particle Y momentum (in MeV)
TTreeReaderValue<Float_t> *fHgcalMomY;
/// Reader of particle Z momentum (in MeV)
TTreeReaderValue<Float_t> *fHgcalMomZ;
#endif
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
@@ -0,0 +1,110 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#ifndef PRIMARYGENERATORMMESSENGER_HH
#define PRIMARYGENERATORMMESSENGER_HH
#include "G4UImessenger.hh"
class G4UIdirectory;
class G4UIcmdWithABool;
class G4UIcmdWithAnInteger;
class G4UIcmdWithAString;
class G4UIcmdWithADouble;
class G4UIcmdWithADoubleAndUnit;
class PrimaryGeneratorAction;
/**
* @brief Primary generator messenger
*
* Defines UI commands to set up the primary generator.
*
* By default particle gun is used as the primary generator. It can be
* controlled with standard UI commands (/gun/).
*
* "/HGCalTestbeam/generator/momentumSpread <VALUE>" to change constant
* particle energy to Gaussian distribution with sigma expressed in units of the
* initial energy (e.g. value 0.05 means sigma of 0.05 * E).
* By default it equals to 0 and constant energy value is used.
* "/HGCalTestbeam/generator/beamSpread <none/Gaussian/flat>" to define type of
* beam position spread. By default none is used.
* "/HGCalTestbeam/generator/beamSpreadX <SIZE>" to define size of beam spread
* along x axis. It is sigma of a Gaussian distribution, or half-width of a
* flat distribution.
* "/HGCalTestbeam/generator/beamSpreadY <SIZE>" to define size of beam spread
* along y axis. It is sigma of a Gaussian distribution, or half-width of a
* flat distribution.
* "/HGCalTestbeam/generator/beamZ0 <POSITION>" to define beam position along z
* axis. By default edge of the world volume is used.
*
* If installation was done with ROOT package (CMake was able to locate it),
* an additional option of input read from the ROOT file is enabled.
* It can be activated with "/HGCalTestbeam/generator/readInputFile true".
* "/HGCalTestbeam/generator/pathInputFile <FILE>" sets the path to the input
* file.
* "/HGCalTestbeam/generator/startFromEvent <N>" allows to start simulation from
* Nth event.
* Please note that in current implementation input from file needs to be
* executed in a non-multithreaded mode (or with 1 thread).
*
*/
class PrimaryGeneratorMessenger : public G4UImessenger {
public:
explicit PrimaryGeneratorMessenger(PrimaryGeneratorAction *aPrimaryGeneratorAction);
~PrimaryGeneratorMessenger();
public:
void SetNewValue(G4UIcommand *command, G4String newValues);
G4String GetCurrentValue(G4UIcommand *command);
private:
/// Pointer to the primmary generator
PrimaryGeneratorAction *fPrimaryGenerator;
private:
/// Directory for UI commands
G4UIdirectory *fDirectory;
#ifdef WITHROOT
/// Command specyfing if primary event should be read from file
G4UIcmdWithABool *fReadInputCmd;
/// Command to set the path to the input file
G4UIcmdWithAString *fPathInputCmd;
/// Command to set ID of the first event to be read from the file
G4UIcmdWithAnInteger *fStartFromEventCmd;
#endif
/// Command to set the sigma of the Gaussian momentum spread
G4UIcmdWithADouble *fMomentumSpreadCmd;
/// Command to set the type of transverse beam position spread
G4UIcmdWithAString *fBeamSpreadTypeCmd;
/// Command to set the size of beam position spread along X axis
G4UIcmdWithADoubleAndUnit *fBeamSpreadXCmd;
/// Command to set the size of beam position spread along Y axis
G4UIcmdWithADoubleAndUnit *fBeamSpreadYCmd;
/// Command to set the initial beam position size along Z axis
G4UIcmdWithADoubleAndUnit *fBeamZ0Cmd;
};
#endif /*PRIMARYGENERATORMMESSENGER_HH */
@@ -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. *
// ********************************************************************
//
#ifndef RUNACTION_HH
#define RUNACTION_HH
#include "G4UserRunAction.hh"
#include "G4String.hh"
class G4Run;
class EventAction;
class G4GenericMessenger;
/**
* @brief Run action
*
* Creates the output file with ntuple.
* Output name can be changed with UI command "/HGCalTestbeam/output/file
* <NAME>"
*
*/
class RunAction : public G4UserRunAction {
public:
explicit RunAction(EventAction *);
virtual ~RunAction();
virtual void BeginOfRunAction(const G4Run *);
virtual void EndOfRunAction(const G4Run *);
private:
/// Pointer to the event action to retrieve vectors
EventAction *fEventAction;
/// Name of the output file
G4String fOutputFileDir;
/// Pointer to the command messenger
G4GenericMessenger *fMessenger;
};
#endif /* RUNACTION_HH */
@@ -0,0 +1,137 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#ifndef SIPMHIT_HHinline
#define SIPMHIT_HHinline
#include "G4THitsCollection.hh"
#include "G4VHit.hh"
#include "G4Types.hh"
#include "G4String.hh"
#include <vector>
/**
* @brief SiPM hit
*
* Stores information of energy deposited in the SiPM.
*
* Hits can be digitised, to take into account the time window for the deposits
* as well as to set the time information based on the energy threshold.
* By default no time window is used (all energy deposits are counted), as well
* as no energy threshold is used (time of the first energy deposit, however
* small, is counted as hit time).
*
*/
class SiPMHit : public G4VHit {
public:
/// Constructor
/// @param[in] aName Name of the pixel volume
/// @param[in] aCopyNoSensor ID of the sensor
/// @param[in] aCopyNoCell ID of the cell
SiPMHit(G4String aName, G4int aCopyNoSensor, G4int aCopyNoCell);
~SiPMHit(){};
/// Get hit ID calculated as 1000 * sensorID + cellID
G4int ID() { return 1000 * fCopyNumSensor + fCopyNumCell; }
/// Add non-zero energy deposit to vector of deposits
/// @param[in] aEnergy Deposited energy
/// @param[in] aTime Time of deposit
inline void AddEdep(const G4double aEnergy, const G4double aTime) {
if (aEnergy > 0)
fEdep.push_back(std::make_pair(aEnergy, aTime));
}
/// Add non-zero non-ionizing energy deposit to vector of deposits
/// @param[in] aEnergy Deposited energy
/// @param[in] aTime Time of deposit
inline void AddEdepNonIonizing(const G4double aEnergy, const G4double aTime) {
if (aEnergy > 0)
fEdepNonIonizing.push_back(std::make_pair(aEnergy, aTime));
}
/// Digitise hit
/// Calculate time of hit as global time of energy deposit which added
/// to hit energy exceeds the energy threshold. Take into account only
/// deposits with global time within the timeWindow.
/// @param[in] timeWindow Maximal global time for deposit, caounted from
/// the time of the first deposit
/// @param[in] toaThreshold Energy threshold, first deposit that adds to
/// the hit energy and exceeds the threshold is counted as time of
/// arrival.
void Digitise(const G4double timeWindow, const G4double toaThreshold);
/// Set hit position
/// @param[in] x X position
/// @param[in] y Y position
/// @param[in] z Z position
inline void SetPosition(G4double x, G4double y, G4double z) {
fPosX = x;
fPosY = y;
fPosZ = z;
}
/// Get hit X position
inline G4double GetX() const { return fPosX; }
/// Get hit Y position
inline G4double GetY() const { return fPosY; }
/// Get hit Z position
inline G4double GetZ() const { return fPosZ; }
/// Check if hit is valid
inline G4bool isValidHit() const { return fIsValidHit; }
/// Get hit energy
inline G4double GetEdep() const { return fEdepDigi; }
/// Get hit non-ionizing energy
inline G4double GetEdepNonIonizing() const { return fEdepNonIonizingDigi; }
/// Get time of arrival
inline G4double GetTOA() const { return fTimeOfArrival; }
private:
/// Name of the logical volume
G4String fVolumeName = "";
/// ID of the sensor
G4int fCopyNumCell = -1;
/// ID of the cell
G4int fCopyNumSensor = -1;
/// Position along x axis
G4double fPosX = -1;
/// Position along y axis
G4double fPosY = -1;
/// Position along z axis
G4double fPosZ = -1;
/// Vector of energy deposits (and their global time)
std::vector<std::pair<G4double, G4double>> fEdep;
/// Vector of non-ionizing energy deposits (and their global time)
std::vector<std::pair<G4double, G4double>> fEdepNonIonizing;
/// Flag indicating if hit is valid (digitised and with non-zero energy)
G4bool fIsValidHit = false;
/// Energy of the digitised hit
G4double fEdepDigi = -1;
/// Non-ionizing energy of the digitised hit
G4double fEdepNonIonizingDigi = -1;
/// Time of arrival of the digitised hit
G4double fTimeOfArrival = -1;
};
typedef G4THitsCollection<SiPMHit> SiPMHitCollection;
#endif /* SIPMHIT_HH */
@@ -0,0 +1,68 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#ifndef SIPMSD_HH
#define SIPMSD_HH
#include "SiPMHit.hh"
#include "G4VSensitiveDetector.hh"
#include "G4Types.hh"
#include <map>
/**
* @brief Sensitive detector for SiPMs
*
* Processes step information and stores it in SiPM hits.
* Information is stored in units of:
* - keV for energy
* - cm for position
*
*/
class SiPMSD : public G4VSensitiveDetector {
public:
explicit SiPMSD(G4String name);
~SiPMSD();
/// Hits are processed and added to the temporary map of hit ID to hit
/// pointer. Energy is stored in units of keV, and position in cm.
G4bool ProcessHits(G4Step *step, G4TouchableHistory *ROhist);
void Initialize(G4HCofThisEvent *HCE);
/// Temporary map of hits is stored in hit collection, to be retrieved
/// for analysis by the event action
void EndOfEvent(G4HCofThisEvent *HCE);
private:
/// Hit collection stored in the event, filled in at the end of event based
/// on temporary hits
SiPMHitCollection *fHitCollection = nullptr;
/// ID of hit collection
G4int fHCID = -1;
/// Temporary map of hits (ID: hit) collected within one event
std::map<G4int, SiPMHit *> fTmpHits;
};
#endif /* SIPMSD_HH */
@@ -0,0 +1,142 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#ifndef SILICONPIXELHIT_HH
#define SILICONPIXELHIT_HH
#include "G4THitsCollection.hh"
#include "G4VHit.hh"
#include "G4Types.hh"
#include <vector>
/**
* @brief Silicon pixel hit
*
* Stores information of energy deposited in the silicon pixel.
*
* Hits can be digitised, to take into account the time window for the deposits
* as well as to set the time information based on the energy threshold.
* By default no time window is used (all energy deposits are counted), as well
* as no energy threshold is used (time of the first energy deposit, however
* small, is counted as hit time).
*
*/
class SiliconPixelHit : public G4VHit {
public:
/// Constructor
/// @param[in] aName Name of the pixel volume
/// @param[in] aCopyNumSensor ID of the sensor
/// @param[in] aCopyNumCell ID of the cell
SiliconPixelHit(G4String aName, G4int aCopyNumSensor, G4int aCopyNumCell);
~SiliconPixelHit(){};
/// Draw pixels
void Draw();
/// Get hit ID calculated as 1000 * sensorID + cellID
G4int ID() { return 1000 * fCopyNumSensor + fCopyNumCell; }
/// Add non-zero energy deposit to vector of deposits
/// @param[in] aEnergy Deposited energy
/// @param[in] aTime Time of deposit
inline void AddEdep(const G4double aEnergy, const G4double aTime) {
if (aEnergy > 0)
fEdep.push_back(std::make_pair(aEnergy, aTime));
}
/// Add non-zero non-ionizing energy deposit to vector of deposits
/// @param[in] aEnergy Deposited energy
/// @param[in] aTime Time of deposit
inline void AddEdepNonIonizing(const G4double aEnergy, const G4double aTime) {
if (aEnergy > 0)
fEdepNonIonizing.push_back(std::make_pair(aEnergy, aTime));
}
/// Digitise hit
/// Calculate time of hit as global time of energy deposit which added
/// to hit energy exceeds the energy threshold. Take into account only
/// deposits with global time within the time window.
/// @param[in] aTimeWindow Maximal global time for deposit, caounted from
/// the time of the first deposit
/// @param[in] aToaThreshold Energy threshold, first deposit that adds to
/// the hit energy and exceeds the threshold is counted as time of
/// arrival.
void Digitise(const G4double aTimeWindow, const G4double aToaThreshold);
/// Set hit position
/// @param[in] x X position
/// @param[in] y Y position
/// @param[in] z Z position
inline void SetPosition(G4double x, G4double y, G4double z) {
fPosX = x;
fPosY = y;
fPosZ = z;
}
/// Get hit X position
inline G4double GetX() const { return fPosX; }
/// Get hit Y position
inline G4double GetY() const { return fPosY; }
/// Get hit Z position
inline G4double GetZ() const { return fPosZ; }
/// Check if hit is valid
inline G4bool isValidHit() const { return fIsValidHit; }
/// Get hit energy
inline G4double GetEdep() const { return fEdepDigi; }
/// Get hit non-ionizing energy
inline G4double GetEdepNonIonizing() const { return fEdepNonIonizingDigi; }
/// Get time of arrival
inline G4double GetTOA() const { return fTimeOfArrival; }
/// Get time of arrival from the last energy deposit
inline G4double GetLastTOA() const { return fTimeOfArrivalLast; }
private:
/// Name of the logical volume
G4String fVolumeName = "";
/// ID of the sensor
G4int fCopyNumCell = -1;
/// ID of the cell
G4int fCopyNumSensor = -1;
/// Position along x axis
G4double fPosX = -1;
/// Position along y axis
G4double fPosY = -1;
/// Position along z axis
G4double fPosZ = -1;
/// Vector of energy deposits (and their global time)
std::vector<std::pair<G4double, G4double>> fEdep;
/// Vector of non-ionizing energy deposits (and their global time)
std::vector<std::pair<G4double, G4double>> fEdepNonIonizing;
/// Flag indicating if hit is valid (digitised and with non-zero energy)
G4bool fIsValidHit = false;
/// Energy of the digitised hit
G4double fEdepDigi = -1;
/// Non-ionizing energy of the digitised hit
G4double fEdepNonIonizingDigi = -1;
/// Time of arrival of the digitised hit
G4double fTimeOfArrival = -1;
/// Last time of arrival of the digitised hit
G4double fTimeOfArrivalLast = -1;
};
typedef G4THitsCollection<SiliconPixelHit> SiliconPixelHitCollection;
#endif /* SILICONPIXELHIT_HH */
@@ -0,0 +1,67 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#ifndef SILICONPIXELSD_HH
#define SILICONPIXELSD_HH
#include "G4VSensitiveDetector.hh"
#include "SiliconPixelHit.hh"
#include "G4Types.hh"
#include <map>
/**
* @brief Sensitive detector for silicon pixels
*
* Processes step information and stores it in silicon hits.
* Information is stored in units of:
* - keV for energy
* - cm for position
*
*/
class SiliconPixelSD : public G4VSensitiveDetector {
public:
explicit SiliconPixelSD(G4String name);
~SiliconPixelSD();
/// Hits are processed and added to the temporary map of hit ID to hit
/// pointer. Energy is stored in units of keV, and position in cm.
G4bool ProcessHits(G4Step *step, G4TouchableHistory *ROhist);
void Initialize(G4HCofThisEvent *HCE);
/// Temporary map of hits is stored in hit collection, to be retrieved
/// for analysis by the event action
void EndOfEvent(G4HCofThisEvent *HCE);
private:
/// Hit collection stored in the event, filled in at the end of event based
/// on temporary hits
SiliconPixelHitCollection *fHitCollection = nullptr;
/// ID of hit collection
G4int fHCID = -1;
/// Temporary map of hits (ID: hit) collected within one event
std::map<G4int, SiliconPixelHit *> fTmpHits;
};
#endif /* SILICONPIXELSD_HH */