diff --git a/include/MedtechAnalysis.hh b/include/MedtechAnalysis.hh index 8abd926..b6a8e06 100644 --- a/include/MedtechAnalysis.hh +++ b/include/MedtechAnalysis.hh @@ -9,6 +9,7 @@ #define MedtechAnalysis_hh #include +#include #include "G4Threading.hh" #include "G4AutoLock.hh" #include "TTree.h" @@ -28,9 +29,12 @@ private: /* Static access method. */ MedtechAnalysis(); + double x, y, e; public: ~MedtechAnalysis(); + MedtechAnalysis(const MedtechAnalysis&) = delete; + MedtechAnalysis& operator=(const MedtechAnalysis&) = delete; void Fill(double, double, double); void Close(); diff --git a/include/MedtechSteppingAction.hh b/include/MedtechSteppingAction.hh index 14fb65a..3ddeb0a 100644 --- a/include/MedtechSteppingAction.hh +++ b/include/MedtechSteppingAction.hh @@ -12,6 +12,7 @@ #include "G4UserSteppingAction.hh" #include "MedtechEventAction.hh" #include "G4Gamma.hh" +#include "MedtechAnalysis.hh" class MedtechSteppingAction : public G4UserSteppingAction { diff --git a/medtech.cc b/medtech.cc index b42e111..c6b2ba2 100644 --- a/medtech.cc +++ b/medtech.cc @@ -19,7 +19,6 @@ #include "MedtechActionInitialization.hh" #include "Parameters.hh" #include "G4SteppingManager.hh" -#include "MedtechAnalysis.hh" int main(int argc,char** argv) { diff --git a/src/MedtechAnalysis.cc b/src/MedtechAnalysis.cc index e7e58f6..a8c927d 100644 --- a/src/MedtechAnalysis.cc +++ b/src/MedtechAnalysis.cc @@ -13,6 +13,10 @@ MedtechAnalysis::MedtechAnalysis() file = new TFile("data.root","RECREATE"); instance = this; MedtechAnalysisMutex = G4MUTEX_INITIALIZER; + + tree -> Branch("x", &x, "x/D"); + tree -> Branch("y", &y, "y/D"); + tree -> Branch("e", &e, "e/D"); } MedtechAnalysis::~MedtechAnalysis() @@ -24,18 +28,20 @@ MedtechAnalysis* MedtechAnalysis::getInstance() { if (instance == 0) { + std::cout << "Created instance" << std::endl; instance = new MedtechAnalysis(); } return instance; } -void MedtechAnalysis::Fill(double x, double y, double e) +void MedtechAnalysis::Fill(double x1, double y1, double e1) { G4AutoLock lock(&MedtechAnalysisMutex); - tree -> Branch("x", &x, "x/D"); - tree -> Branch("y", &y, "y/D"); - tree -> Branch("e", &e, "e/D"); + + x = x1; + y = y1; + e = e1; tree -> Fill(); diff --git a/src/MedtechPrimaryGeneratorAction.cc b/src/MedtechPrimaryGeneratorAction.cc index 085c647..894c833 100644 --- a/src/MedtechPrimaryGeneratorAction.cc +++ b/src/MedtechPrimaryGeneratorAction.cc @@ -11,7 +11,7 @@ MedtechPrimaryGeneratorAction::MedtechPrimaryGeneratorAction() { Parameters *param = Parameters::getInstance(); - G4int numberOfParticles = 100; + G4int numberOfParticles = 1000; particleGun = new G4ParticleGun(numberOfParticles); G4ParticleTable *particleTable = G4ParticleTable::GetParticleTable(); G4ParticleDefinition *particle = particleTable -> FindParticle("e-"); diff --git a/src/MedtechSteppingAction.cc b/src/MedtechSteppingAction.cc index 971f324..b8f2617 100644 --- a/src/MedtechSteppingAction.cc +++ b/src/MedtechSteppingAction.cc @@ -64,7 +64,7 @@ void MedtechSteppingAction::UserSteppingAction(const G4Step* step) { fTrack -> SetTrackStatus(fStopAndKill); } - G4cout << "X: " << postX << " Y: " << postY << " KinE: " << postkinE << " Particle: " << fTrack -> GetDefinition() << G4endl; + //G4cout << "X: " << postX << " Y: " << postY << " KinE: " << postkinE << " Particle: " << fTrack -> GetDefinition() << G4endl; MedtechAnalysis *man = MedtechAnalysis::getInstance(); man -> Fill(postX, postY, postkinE); }