snapshot with output
This commit is contained in:
@@ -1,7 +1,34 @@
|
||||
|
||||
#ifndef CONSTRUCTIONWRAPPER_HH
|
||||
#define CONSTRUCTIONWRAPPER_HH
|
||||
|
||||
#include "G4ThreeVector.hh"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
//#include "G4VPhysicalVolume.hh"
|
||||
class G4VPhysicalVolume;
|
||||
|
||||
|
||||
class Sensor{
|
||||
public:
|
||||
Sensor(){};
|
||||
~Sensor(){};
|
||||
|
||||
const G4double getEnergy()const{
|
||||
return energy;
|
||||
}
|
||||
G4ThreeVector getPos()const{
|
||||
return position;
|
||||
}
|
||||
G4ThreeVector getSize()const{
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
G4ThreeVector position;
|
||||
G4ThreeVector size;
|
||||
mutable G4double energy;
|
||||
};
|
||||
|
||||
class Layer{
|
||||
|
||||
@@ -25,6 +52,8 @@ public:
|
||||
bool isActive;
|
||||
G4VPhysicalVolume* physicalVolume;
|
||||
std::string name;
|
||||
|
||||
std::vector<Sensor> sensors;
|
||||
};
|
||||
|
||||
|
||||
@@ -34,7 +63,7 @@ public:
|
||||
ConstructionWrapper(double xy_width=50);
|
||||
~ConstructionWrapper() {};
|
||||
|
||||
void addLayer(double thickness_cm, std::string material, bool isActive=true, int nx=1, int ny=1);
|
||||
void addLayer(double thickness_cm, std::string material, bool isActive=true, int nx=1, int ny=-1);
|
||||
|
||||
std::vector<Layer>& getLayers() ;
|
||||
const std::vector<Layer>& getLayers() const;
|
||||
@@ -42,7 +71,29 @@ public:
|
||||
double getXYWidth() const{
|
||||
return xywidth;
|
||||
}
|
||||
void resetSensorEnergies()const;//energies are mutable
|
||||
int getNSensors()const{
|
||||
int n_sensors = 0;
|
||||
for(const auto& layer: layers){
|
||||
n_sensors += layer.sensors.size();
|
||||
}
|
||||
return n_sensors;
|
||||
}
|
||||
|
||||
Layer* getLayerByVolume(G4VPhysicalVolume* volume);
|
||||
|
||||
const Layer* getLayerByVolume(G4VPhysicalVolume* volume)const;
|
||||
|
||||
Sensor* getSensorByVolume(G4VPhysicalVolume* volume);
|
||||
|
||||
const Sensor* getSensorByVolume(G4VPhysicalVolume* volume)const;
|
||||
|
||||
void printSensorEnergies()const;
|
||||
|
||||
|
||||
private:
|
||||
double xywidth;
|
||||
std::vector<Layer> layers;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -32,10 +32,10 @@
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
#include "globals.hh"
|
||||
#include "ConstructionWrapper.hh"
|
||||
|
||||
class G4VPhysicalVolume;
|
||||
class G4GlobalMagFieldMessenger;
|
||||
class ConstructionWrapper;
|
||||
|
||||
namespace B4
|
||||
{
|
||||
@@ -59,19 +59,20 @@ namespace B4
|
||||
class DetectorConstruction : public G4VUserDetectorConstruction
|
||||
{
|
||||
public:
|
||||
DetectorConstruction(const ConstructionWrapper& cw){
|
||||
this->cw = cw;
|
||||
}
|
||||
DetectorConstruction( ConstructionWrapper* Cw): G4VUserDetectorConstruction(), cw(Cw){}
|
||||
~DetectorConstruction() override = default;
|
||||
|
||||
public:
|
||||
G4VPhysicalVolume* Construct() override;
|
||||
void ConstructSDandField() override;
|
||||
|
||||
// get methods
|
||||
//
|
||||
const G4VPhysicalVolume* GetAbsorberPV() const;
|
||||
const G4VPhysicalVolume* GetGapPV() const;
|
||||
|
||||
ConstructionWrapper* getConstructionWrapper(){
|
||||
return cw;
|
||||
}
|
||||
const ConstructionWrapper* getConstructionWrapper()const{
|
||||
return cw;
|
||||
}
|
||||
|
||||
private:
|
||||
// methods
|
||||
@@ -84,23 +85,11 @@ class DetectorConstruction : public G4VUserDetectorConstruction
|
||||
static G4ThreadLocal G4GlobalMagFieldMessenger* fMagFieldMessenger;
|
||||
// magnetic field messenger
|
||||
|
||||
G4VPhysicalVolume* fAbsorberPV = nullptr; // the absorber physical volume
|
||||
G4VPhysicalVolume* fGapPV = nullptr; // the gap physical volume
|
||||
|
||||
G4bool fCheckOverlaps = true; // option to activate checking of volumes overlaps
|
||||
|
||||
ConstructionWrapper cw;
|
||||
ConstructionWrapper* cw=nullptr;
|
||||
};
|
||||
|
||||
// inline functions
|
||||
|
||||
inline const G4VPhysicalVolume* DetectorConstruction::GetAbsorberPV() const {
|
||||
return fAbsorberPV;
|
||||
}
|
||||
|
||||
inline const G4VPhysicalVolume* DetectorConstruction::GetGapPV() const {
|
||||
return fGapPV;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+16
-17
@@ -31,7 +31,10 @@
|
||||
#define B4aEventAction_h 1
|
||||
|
||||
#include "G4UserEventAction.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "globals.hh"
|
||||
class ConstructionWrapper;
|
||||
|
||||
namespace B4a
|
||||
{
|
||||
@@ -51,30 +54,26 @@ class EventAction : public G4UserEventAction
|
||||
~EventAction() override = default;
|
||||
|
||||
void BeginOfEventAction(const G4Event* event) override;
|
||||
void EndOfEventAction(const G4Event* event) override;
|
||||
void EndOfEventAction(const G4Event* event) override;
|
||||
|
||||
void AddAbs(G4double de, G4double dl);
|
||||
void AddGap(G4double de, G4double dl);
|
||||
void setConstructionWrapper(const ConstructionWrapper * Cw){
|
||||
this->cw = Cw;
|
||||
}
|
||||
void setPrimaryGeneratorAction(const B4::PrimaryGeneratorAction * Gen){
|
||||
this->gen = Gen;
|
||||
}
|
||||
void setRunAction(const B4::RunAction * Run){
|
||||
this->run = Run;
|
||||
}
|
||||
|
||||
private:
|
||||
G4double fEnergyAbs = 0.;
|
||||
G4double fEnergyGap = 0.;
|
||||
G4double fTrackLAbs = 0.;
|
||||
G4double fTrackLGap = 0.;
|
||||
const ConstructionWrapper * cw=nullptr;
|
||||
const B4::PrimaryGeneratorAction * gen=nullptr;
|
||||
const B4::RunAction * run=nullptr;
|
||||
};
|
||||
|
||||
// inline functions
|
||||
|
||||
inline void EventAction::AddAbs(G4double de, G4double dl) {
|
||||
fEnergyAbs += de;
|
||||
fTrackLAbs += dl;
|
||||
}
|
||||
|
||||
inline void EventAction::AddGap(G4double de, G4double dl) {
|
||||
fEnergyGap += de;
|
||||
fTrackLGap += dl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -56,9 +56,17 @@ public:
|
||||
|
||||
// set methods
|
||||
void SetRandomFlag(G4bool value);
|
||||
|
||||
G4double getPartEnergy() const{return partEnergy;}
|
||||
void setMinPartEnergy(G4double value){minPartEnergy = value;}
|
||||
void setMaxPartEnergy(G4double value){maxPartEnergy = value;}
|
||||
void setPartSpecies(G4String value){partSpecies = value;}
|
||||
private:
|
||||
G4ParticleGun* fParticleGun = nullptr; // G4 particle gun
|
||||
G4double partEnergy;
|
||||
G4double minPartEnergy; //MeV
|
||||
G4double maxPartEnergy;
|
||||
G4String partSpecies;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -64,6 +64,20 @@ class RunAction : public G4UserRunAction
|
||||
|
||||
void BeginOfRunAction(const G4Run*) override;
|
||||
void EndOfRunAction(const G4Run*) override;
|
||||
|
||||
//now this is dumb but the way this is setup it has to be done like this
|
||||
|
||||
//yeah mutable fine whatever
|
||||
mutable std::vector<double> hitEnergy;
|
||||
mutable std::vector<double> hitX;
|
||||
mutable std::vector<double> hitY;
|
||||
mutable std::vector<double> hitZ;
|
||||
mutable std::vector<double> hitDX;
|
||||
mutable std::vector<double> hitDY;
|
||||
mutable std::vector<double> hitDZ;
|
||||
mutable std::vector<int> hitLayer;
|
||||
mutable std::vector<int> hitCopyNumber;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#define B4aSteppingAction_h 1
|
||||
|
||||
#include "G4UserSteppingAction.hh"
|
||||
#include "ConstructionWrapper.hh"
|
||||
|
||||
namespace B4
|
||||
{
|
||||
@@ -57,6 +58,7 @@ public:
|
||||
|
||||
void UserSteppingAction(const G4Step* step) override;
|
||||
|
||||
|
||||
private:
|
||||
const B4::DetectorConstruction* fDetConstruction = nullptr;
|
||||
EventAction* fEventAction = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user