Import Geant4 11.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2025-12-05 08:54:02 +01:00
parent a499fb82e9
commit b4a16de652
6484 changed files with 232674 additions and 221097 deletions
@@ -23,47 +23,86 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// CaTS (Calorimetry and Tracking Simulation)
//
// Authors: Hans Wenzel and Soon Yung Jun
// (Fermi National Accelerator Laboratory)
//
// History: October 18th, 2021 : first implementation
//
// ********************************************************************
// ********************************************************************
//
// CaTS (Calorimetry and Tracking Simulation)
//
// Authors : Hans Wenzel
// Soon Yung Jun
// (Fermi National Accelerator Laboratory)
//
// History
// October 18th, 2021 : first implementation
//
// ********************************************************************
//
/// \file DetectorConstruction.hh
/// \brief Definition of the CaTS::DetectorConstruction class
#pragma once
#include "G4String.hh"
#include "G4VSensitiveDetector.hh"
#include "G4VUserDetectorConstruction.hh"
#include <G4String.hh>
class G4VPhysicalVolume;
#include "TrackerSD.hh"
#include "MscSD.hh"
#include "lArTPCSD.hh"
#include "CalorimeterSD.hh"
#include "DRCalorimeterSD.hh"
#include "RadiatorSD.hh"
#include "PhotonSD.hh"
#include "InteractionSD.hh"
#include <memory>
#include <string>
#include <unordered_map>
class ColorReader;
class G4GDMLParser;
class G4VPhysicalVolume;
class DetectorConstruction final : public G4VUserDetectorConstruction
{
public:
DetectorConstruction(G4String fname);
~DetectorConstruction() final;
explicit DetectorConstruction(G4String fname);
~DetectorConstruction() final {};
DetectorConstruction& operator=(const DetectorConstruction& right) = delete;
DetectorConstruction(const DetectorConstruction&) = delete;
void ReadGDML();
DetectorConstruction(const DetectorConstruction&) = delete;
G4VPhysicalVolume* Construct() final;
void ConstructSDandField() final;
void UpdateGeometry();
private:
void ReadGDML();
void UpdateGeometry();
// The map of sensitive detectors
using SDMap = std::unordered_map<std::string,
std::function<std::unique_ptr<G4VSensitiveDetector>(const G4String&)>>;
inline const SDMap& GetSDMap()
{
static const SDMap sdMap = {
{"PhotonDetector", [](const G4String& name)
{ return std::make_unique<PhotonSD>(name); }},
{"Target", [](const G4String& name)
{ return std::make_unique<InteractionSD>(name); }},
{"Tracker", [](const G4String& name)
{ return std::make_unique<TrackerSD>(name); }},
{"Msc", [](const G4String& name)
{ return std::make_unique<MscSD>(name); }},
{"lArTPC", [](const G4String& name)
{ return std::make_unique<lArTPCSD>(name); }},
{"Radiator", [](const G4String& name)
{ return std::make_unique<RadiatorSD>(name); }},
{"Calorimeter", [](const G4String& name)
{ return std::make_unique<CalorimeterSD>(name); }},
{"DRCalorimeter", [](const G4String& name)
{ return std::make_unique<DRCalorimeterSD>(name); }}
};
return sdMap;
}
private:
G4bool verbose{ false };
G4String gdmlFile;
G4GDMLParser* parser{ nullptr };
ColorReader* fReader{ nullptr };
G4bool verbose{ false };
};
+6 -19
View File
@@ -23,18 +23,12 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// CaTS (Calorimetry and Tracking Simulation)
//
// ********************************************************************
// Authors: Hans Wenzel and Soon Yung Jun
// (Fermi National Accelerator Laboratory)
//
// CaTS (Calorimetry and Tracking Simulation)
//
// Authors : Hans Wenzel
// Soon Yung Jun
// (Fermi National Accelerator Laboratory)
//
// History
// October 18th, 2021 : first implementation
// History: October 18th, 2021 : first implementation
//
// ********************************************************************
//
@@ -43,21 +37,14 @@
#pragma once
#include <string>
#include <vector>
#include "G4UserEventAction.hh"
class G4Event;
class EventAction : public G4UserEventAction
{
public:
EventAction();
EventAction() {}
~EventAction() = default;
void BeginOfEventAction(const G4Event* anEvent) final;
void EndOfEventAction(const G4Event* anEvent) final;
private:
std::vector<std::string>& split(const std::string& s, char delim,
std::vector<std::string>& elems);
std::vector<std::string> split(const std::string& s, char delim);
};
+55 -30
View File
@@ -23,18 +23,12 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// CaTS (Calorimetry and Tracking Simulation)
//
// ********************************************************************
// Authors: Hans Wenzel and Soon Yung Jun
// (Fermi National Accelerator Laboratory)
//
// CaTS (Calorimetry and Tracking Simulation)
//
// Authors : Hans Wenzel
// Soon Yung Jun
// (Fermi National Accelerator Laboratory)
//
// History
// October 18th, 2021 : first implementation
// History: October 18th, 2021 : first implementation
//
// ********************************************************************
//
@@ -44,33 +38,64 @@
#ifdef WITH_ROOT
#pragma once
#include "RtypesCore.h"
#include <G4Types.hh>
#include <G4String.hh>
#include "G4ThreadLocalSingleton.hh"
#include "G4VHit.hh"
#include "G4VHitsCollection.hh"
#include "Event.hh"
class G4Event;
class TBranch;
class TFile;
class TTree;
class TBranch;
class Event;
class RootIO {
friend class G4ThreadLocalSingleton< RootIO >;
public:
virtual ~RootIO()= default;
static RootIO* GetInstance();
void Write(Event*);
void Close();
void Merge();
protected:
RootIO();
class RootIO
{
friend class G4ThreadLocalSingleton<RootIO>;
public:
static RootIO* GetInstance();
~RootIO() = default;
void Write(const G4Event* event);
void Merge();
void Close();
private:
// Private constructor used only for the static instance
RootIO();
// Split a string using the delimiter character
std::vector<G4String> Split(const G4String& s, char delim);
// Add hits from sensitive detectors into the CaTS event data
template<typename T>
void AddHits(G4VHitsCollection* hc, Event* event_data);
private:
TFile* fFile{ nullptr };
G4int fNevents{ 0 };
TTree* ftree{ nullptr };
TBranch* fevtbranch{ nullptr };
Long64_t fnb{ 0 };
G4bool fevtinitialized{ false };
static G4ThreadLocal RootIO* fgInstance;
G4String fFileName;
TBranch* fEvtBranch{ nullptr };
TFile* fFile{ nullptr };
TTree* fTree{ nullptr };
};
template<typename T>
void RootIO::AddHits(G4VHitsCollection* hc, Event* event_data)
{
std::map<G4String, std::vector< G4VHit*>> *hcmap = event_data->GetHCMap();
std::vector<G4VHit*> hitsVector;
G4int NbHits = hc->GetSize();
G4String hcname = hc->GetName();
for (G4int ii = 0; ii < NbHits; ++ii)
{
G4VHit* hit = hc->GetHit(ii);
T* tpcHit = dynamic_cast<T*> (hit);
hitsVector.push_back(tpcHit);
}
hcmap->insert(std::make_pair(hcname, hitsVector));
}
#endif /* WITH_ROOT */
+4 -10
View File
@@ -23,18 +23,12 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// CaTS (Calorimetry and Tracking Simulation)
//
// ********************************************************************
// Authors: Hans Wenzel and Soon Yung Jun
// (Fermi National Accelerator Laboratory)
//
// CaTS (Calorimetry and Tracking Simulation)
//
// Authors : Hans Wenzel
// Soon Yung Jun
// (Fermi National Accelerator Laboratory)
//
// History
// October 18th, 2021 : first implementation
// History: October 18th, 2021 : first implementation
//
// ********************************************************************
//