Merge branch 'main' of gitlab.etp.kit.edu:jkiesele/minicalosim

This commit is contained in:
lars
2023-10-07 15:31:02 +02:00
15 changed files with 110 additions and 1059 deletions
+6 -6
View File
@@ -35,7 +35,7 @@
class G4VPhysicalVolume;
class G4GlobalMagFieldMessenger;
class ConstructionWrapper;
class GeometryDescriptor;
namespace B4
{
@@ -67,7 +67,7 @@ class DetectorConstruction : public G4VUserDetectorConstruction
return _global_detector_construction;
}
DetectorConstruction( ConstructionWrapper* Cw): G4VUserDetectorConstruction(), cw(Cw){
DetectorConstruction( GeometryDescriptor* Cw): G4VUserDetectorConstruction(), cw(Cw){
_global_detector_construction=this;
}
~DetectorConstruction() override = default;
@@ -76,14 +76,14 @@ class DetectorConstruction : public G4VUserDetectorConstruction
G4VPhysicalVolume* Construct() override;
void ConstructSDandField() override;
void setConstructionWrapper(ConstructionWrapper* Cw){
void setGeometryDescriptor(GeometryDescriptor* Cw){
this->cw = Cw;
}
ConstructionWrapper* getConstructionWrapper(){
GeometryDescriptor* getGeometryDescriptor(){
return cw;
}
const ConstructionWrapper* getConstructionWrapper()const{
const GeometryDescriptor* getGeometryDescriptor()const{
return cw;
}
@@ -100,7 +100,7 @@ class DetectorConstruction : public G4VUserDetectorConstruction
G4bool fCheckOverlaps = true; // option to activate checking of volumes overlaps
ConstructionWrapper* cw=nullptr;
GeometryDescriptor* cw=nullptr;
};
+1 -1
View File
@@ -34,7 +34,7 @@
#include "RunAction.hh"
#include "PrimaryGeneratorAction.hh"
#include "globals.hh"
class ConstructionWrapper;
class GeometryDescriptor;
namespace B4a
{
+14 -4
View File
@@ -2,7 +2,7 @@
#ifndef G4SYSTEM_HH
#define G4SYSTEM_HH
#include "ConstructionWrapper.hh"
#include "GeometryDescriptor.hh"
#include <stdexcept>
#include "G4RunManagerFactory.hh"
#include "DetectorConstruction.hh"
@@ -28,10 +28,11 @@ G4System(bool Gui=false):gui(Gui){};
delete runManager;
delete ui;
}
};
void init(ConstructionWrapper &cw);
void init(GeometryDescriptor &cw);
//will use dawn for visualization, also wrap more in python
void run_visualize(const std::string& partSpecies, double minEnergy_GeV, double maxEnergy_GeV);
//runs the whole gui if available
@@ -47,9 +48,18 @@ void displayEvent()const{}; //just a placeholder, this will be implemented in py
void printMaterial(const std::string& name)const;
GeometryDescriptor& getGeometryDescriptor(){
check();
if ( assigned_cw == nullptr ){
throw std::runtime_error("GeometryDescriptor not assigned");
}
return *assigned_cw;
}
private:
void check()const;
GeometryDescriptor * assigned_cw=nullptr;
bool gui;
@@ -67,7 +77,7 @@ G4UIExecutive * ui=nullptr;
/*
void run(ConstructionWrapper CW, int nEvents, std::string partSpecies, double minEnergy, double maxEnergy, bool gui=false){
void run(GeometryDescriptor CW, int nEvents, std::string partSpecies, double minEnergy, double maxEnergy, bool gui=false){
char* argv[]={(char*)"dummy"};
@@ -77,7 +87,7 @@ void run(ConstructionWrapper CW, int nEvents, std::string partSpecies, double mi
G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
runManager->SetNumberOfThreads(1);
ConstructionWrapper * cw = &CW;
GeometryDescriptor * cw = &CW;
G4String session;
G4UIExecutive* ui = nullptr;
if ( gui ) {
@@ -1,6 +1,6 @@
#ifndef CONSTRUCTIONWRAPPER_HH
#define CONSTRUCTIONWRAPPER_HH
#ifndef GeometryDescriptor_HH
#define GeometryDescriptor_HH
#include "G4ThreeVector.hh"
#include <vector>
@@ -66,6 +66,11 @@ public:
void setIsActive(bool isActive);
void assignPhysicalVolume(G4VPhysicalVolume* physicalVolume);
void unAssign(){
physicalVolume = nullptr;
sensors.clear();
}
double thickness;
double sens_xwidth;
double sens_ywidth;
@@ -81,11 +86,11 @@ public:
};
class ConstructionWrapper{
class GeometryDescriptor{
public:
ConstructionWrapper(double xy_width=50);
~ConstructionWrapper() {};
GeometryDescriptor(double xy_width=50);
~GeometryDescriptor() {};
void addLayer(double thickness_cm, std::string material, bool isActive=true, int nx=1, int ny=-1);
@@ -123,6 +128,12 @@ public:
}
}
void unAssign(){
for(auto& layer: layers){
layer.unAssign();
}
}
private:
double xywidth;
+1 -1
View File
@@ -31,7 +31,7 @@
#define B4aSteppingAction_h 1
#include "G4UserSteppingAction.hh"
#include "ConstructionWrapper.hh"
#include "GeometryDescriptor.hh"
#include "DetectorConstruction.hh"