From eccdc3142388aaad5ace97c55b22397b97c650cf Mon Sep 17 00:00:00 2001 From: Gitea Date: Thu, 12 Apr 2018 14:43:05 +0200 Subject: [PATCH] Latest changes. 1B electrons --- include/MedtechAnalysis.hh | 5 ++- include/MedtechDetectorConstruction.hh | 2 + include/MedtechSteppingAction.hh | 1 + include/Parameters.hh | 9 +++++ medtech.cc | 14 ++++++- src/MedtechAnalysis.cc | 20 +++++++++- src/MedtechDetectorConstruction.cc | 51 +++++++++++++++++++++----- src/MedtechPrimaryGeneratorAction.cc | 4 +- src/MedtechSteppingAction.cc | 14 ++++++- src/Parameters.cc | 22 ++++++++++- 10 files changed, 122 insertions(+), 20 deletions(-) diff --git a/include/MedtechAnalysis.hh b/include/MedtechAnalysis.hh index c8b426d..9d10ef5 100644 --- a/include/MedtechAnalysis.hh +++ b/include/MedtechAnalysis.hh @@ -24,20 +24,21 @@ private: /* Private constructor to prevent instancing. */ TTree *tree; + TTree *electrontree; TFile *file; G4Mutex MedtechAnalysisMutex; /* Static access method. */ MedtechAnalysis(); - double x, y, e; + double x, y, z, e; public: ~MedtechAnalysis(); MedtechAnalysis(const MedtechAnalysis&) = delete; MedtechAnalysis& operator=(const MedtechAnalysis&) = delete; - void Fill(double, double, double); + void Fill(int, double, double, double, double); void Close(); static MedtechAnalysis* getInstance(); diff --git a/include/MedtechDetectorConstruction.hh b/include/MedtechDetectorConstruction.hh index dae4f98..daf145a 100644 --- a/include/MedtechDetectorConstruction.hh +++ b/include/MedtechDetectorConstruction.hh @@ -27,6 +27,8 @@ #include "G4VPVParameterisation.hh" #include "G4RotationMatrix.hh" #include "G4PVReplica.hh" +#include "G4Orb.hh" +#include "G4Sphere.hh" class MedtechDetectorConstruction : public G4VUserDetectorConstruction { diff --git a/include/MedtechSteppingAction.hh b/include/MedtechSteppingAction.hh index 3ddeb0a..f0d4643 100644 --- a/include/MedtechSteppingAction.hh +++ b/include/MedtechSteppingAction.hh @@ -13,6 +13,7 @@ #include "MedtechEventAction.hh" #include "G4Gamma.hh" #include "MedtechAnalysis.hh" +#include "G4Electron.hh" class MedtechSteppingAction : public G4UserSteppingAction { diff --git a/include/Parameters.hh b/include/Parameters.hh index c31686b..47f5bf8 100644 --- a/include/Parameters.hh +++ b/include/Parameters.hh @@ -29,6 +29,9 @@ private: double cone_size; double radius; + double globe_size; + double globe_placement; + public: /* Static access method. */ static Parameters* getInstance(); @@ -55,6 +58,12 @@ public: void SetTubeSize(double); double GetTubeSize(); + + void SetGlobeSize(double); + double GetGlobeSize(); + + void SetGlonePlacement(double); + double GetGlobePlacement(); }; #endif /* Parameters_hh */ diff --git a/medtech.cc b/medtech.cc index 99df09d..b8b87e4 100644 --- a/medtech.cc +++ b/medtech.cc @@ -23,7 +23,7 @@ int main(int argc,char** argv) { Parameters *param = Parameters::getInstance(); - bool visualization = false; + bool visualization = true; int NoE=1; for(int i=1; i < argc-1; i++) @@ -67,12 +67,22 @@ int main(int argc,char** argv) { param -> SetConeSize(atof(argv[i+1])); } + + else if(!strcmp("-g", argv[i])) //Globe size + { + param -> SetGlobeSize(atof(argv[i+1])); + } + + else if(!strcmp("-gp", argv[i])) //Globe placement + { + param -> SetGlonePlacement(atof(argv[i+1])); + } } //parameters from command line #ifdef G4MULTITHREADED G4MTRunManager* runManager = new G4MTRunManager; - unsigned nthreads = sysconf(_SC_NPROCESSORS_ONLN); //Use all available cores + unsigned int nthreads = (int)sysconf(_SC_NPROCESSORS_ONLN); //Use all available cores std::cout << "Using all cores (" << nthreads << ")\n"; runManager->SetNumberOfThreads(nthreads); #else diff --git a/src/MedtechAnalysis.cc b/src/MedtechAnalysis.cc index 57abefd..fb6e235 100644 --- a/src/MedtechAnalysis.cc +++ b/src/MedtechAnalysis.cc @@ -13,13 +13,20 @@ MedtechAnalysis::MedtechAnalysis() Parameters *parameter = Parameters::getInstance(); snprintf(filename, 30, "data_c%dt%d.root", (int)parameter -> GetConeSize(), (int)parameter -> GetTubeSize()); tree = new TTree("tree", "tree"); + electrontree = new TTree("electrontree","electrontree"); file = new TFile(filename,"RECREATE"); instance = this; MedtechAnalysisMutex = G4MUTEX_INITIALIZER; tree -> Branch("x", &x, "x/D"); tree -> Branch("y", &y, "y/D"); + tree -> Branch("z", &z, "z/D"); tree -> Branch("e", &e, "e/D"); + + electrontree -> Branch("x", &x, "x/D"); + electrontree -> Branch("y", &y, "y/D"); + electrontree -> Branch("e", &e, "e/D"); + electrontree -> Branch("z", &z, "z/D"); } MedtechAnalysis::~MedtechAnalysis() @@ -38,15 +45,23 @@ MedtechAnalysis* MedtechAnalysis::getInstance() return instance; } -void MedtechAnalysis::Fill(double x1, double y1, double e1) +void MedtechAnalysis::Fill(int num, double x1, double y1, double z1, double e1) { G4AutoLock lock(&MedtechAnalysisMutex); x = x1; y = y1; + z = z1; e = e1; - tree -> Fill(); + if(num == 1) + { + tree -> Fill(); + } + if(num == 2) + { + electrontree -> Fill(); + } lock.unlock(); } @@ -54,6 +69,7 @@ void MedtechAnalysis::Fill(double x1, double y1, double e1) void MedtechAnalysis::Close() { tree -> Write(); + electrontree -> Write(); file -> Close(); } diff --git a/src/MedtechDetectorConstruction.cc b/src/MedtechDetectorConstruction.cc index 6b59acd..a0b5d8e 100644 --- a/src/MedtechDetectorConstruction.cc +++ b/src/MedtechDetectorConstruction.cc @@ -27,7 +27,7 @@ G4VPhysicalVolume* MedtechDetectorConstruction::Construct() G4Material *targetMaterial = manager -> FindOrBuildMaterial("G4_Pb"); G4Material *boxMaterial = manager -> FindOrBuildMaterial("G4_W"); G4Material *coneMaterial = manager -> FindOrBuildMaterial("G4_Fe"); - G4Material *waterMaterial = manager -> FindOrBuildMaterial("G4_WATER"); + G4Material *globeMaterial = manager -> FindOrBuildMaterial("G4_W"); //End of Material Section //Physical world @@ -114,12 +114,12 @@ G4VPhysicalVolume* MedtechDetectorConstruction::Construct() { cone_placement = abs(cone_size); - solidCone = new G4Cons("cone", 0, radius*cm, 0, 0, cone_size*cm, 0, 2*CLHEP::pi); //name, inside R -Z, outside, R -Z, inside R Z, outside R Z, half length in z, vmi, vmi + solidCone = new G4Cons("cone", 0, radius*cm, 0, 0, cone_size*mm, 0, 2*CLHEP::pi); //name, inside R -Z, outside, R -Z, inside R Z, outside R Z, half length in z, vmi, vmi //move_in_z_to_zero = cone_size; //put the cone to zero cone_placement = cone_size + 2*tube_size; //use tube size + threshold logicCone = new G4LogicalVolume(solidCone, coneMaterial, "Cone", 0, 0, 0); physicalCone = new G4PVPlacement(0, - G4ThreeVector(0, 0, cone_placement*cm), + G4ThreeVector(0, 0, cone_placement*mm), logicCone, "Cone", logicWorld, @@ -129,17 +129,18 @@ G4VPhysicalVolume* MedtechDetectorConstruction::Construct() else if(cone_size < 0) //cone_size < 0 { - cone_placement = abs(cone_size) + 2*tube_size; + G4double abs_cone_size = abs(cone_size); + cone_placement = abs_cone_size + 2*tube_size; G4RotationMatrix *rot = new G4RotationMatrix(); rot -> rotateX(180 * deg); - solidCone = new G4Cons("cone", 0, radius*cm, 0, 0, -cone_size*cm, 0, 2*CLHEP::pi); //name, inside R -Z, outside, R -Z, inside R Z, outside R Z, half length in z, vmi, vmi - solidTube = new G4Tubs("tube", 0, radius*cm, -cone_size*cm, 0, 2*CLHEP::pi); //name, inner R, outter R, Half length in Z, starting angle, angle of the segment in rad + solidCone = new G4Cons("cone", 0, radius*cm, 0, 0, -cone_size*mm, 0, 2*CLHEP::pi); //name, inside R -Z, outside, R -Z, inside R Z, outside R Z, half length in z, vmi, vmi + solidTube = new G4Tubs("tube", 0, radius*cm, -cone_size*mm, 0, 2*CLHEP::pi); //name, inner R, outter R, Half length in Z, starting angle, angle of the segment in rad G4SubtractionSolid *Cone = new G4SubtractionSolid("Cone", solidTube, solidCone, rot, G4ThreeVector(0, 0, move_in_z_to_zero*cm)); logicCone = new G4LogicalVolume(Cone, coneMaterial, "Cone", 0, 0, 0); physicalCone = new G4PVPlacement(0, - G4ThreeVector(0, 0, cone_placement*cm), + G4ThreeVector(0, 0, cone_placement*mm), logicCone, "Cone", logicWorld, @@ -155,10 +156,10 @@ G4VPhysicalVolume* MedtechDetectorConstruction::Construct() if(tube_size > 0) { - G4Tubs *fixsolidTube = new G4Tubs("tube", 0, radius*cm, tube_size*cm, 0, 2*CLHEP::pi); //name, inner R, outter R, Half length in Z, starting angle, angle of the segment in rad + G4Tubs *fixsolidTube = new G4Tubs("tube", 0, radius*cm, tube_size*mm, 0, 2*CLHEP::pi); //name, inner R, outter R, Half length in Z, starting angle, angle of the segment in rad G4LogicalVolume *fixlogicalTube = new G4LogicalVolume(fixsolidTube, coneMaterial, "fixTube", 0, 0, 0); fixTube = new G4PVPlacement(0, - G4ThreeVector(0, 0, cone_placement*cm), + G4ThreeVector(0, 0, cone_placement*mm), fixlogicalTube, "Cone", logicWorld, @@ -166,6 +167,38 @@ G4VPhysicalVolume* MedtechDetectorConstruction::Construct() 0); } + //Globe + G4PVPlacement *Globe = 0; + G4double globe_size = parameter -> GetGlobeSize() / 2; + G4double globe_placement = globe_size + cone_placement + 100; + if(globe_size > 0) + { + G4Orb *solidGlobe = new G4Orb("Globe", globe_size*mm); + G4LogicalVolume *logicalGlobe = new G4LogicalVolume(solidGlobe, globeMaterial, "Globe", 0, 0, 0); + Globe = new G4PVPlacement(0, + G4ThreeVector(0, 0, 0.5*m), + logicalGlobe, + "Globe", + logicWorld, + false, + 0); + } + //End of globe + + //köpeny a másik köré + G4PVPlacement *sphere = 0; + G4double sphere_outter_size = 200 / 2; + G4double sphere_inner_size = 190 / 2; + G4Sphere *solidSphere = new G4Sphere("sphere", sphere_inner_size, sphere_outter_size, 0, 360*deg, 0, 360*deg); //name, inner R, outter R, starting phi angle, Delta phi angle, starting theta angle, delta theta angle + G4LogicalVolume * logicalSphere = new G4LogicalVolume(solidSphere, air, "sphere", 0, 0, 0); + sphere = new G4PVPlacement(0, + G4ThreeVector(0, 0, 0.5*m), + logicalSphere, + "sphere", + logicWorld, + false, + 0); + return physicalWorld; } diff --git a/src/MedtechPrimaryGeneratorAction.cc b/src/MedtechPrimaryGeneratorAction.cc index 894c833..a38f7b7 100644 --- a/src/MedtechPrimaryGeneratorAction.cc +++ b/src/MedtechPrimaryGeneratorAction.cc @@ -11,7 +11,7 @@ MedtechPrimaryGeneratorAction::MedtechPrimaryGeneratorAction() { Parameters *param = Parameters::getInstance(); - G4int numberOfParticles = 1000; + G4int numberOfParticles = 1000000000; particleGun = new G4ParticleGun(numberOfParticles); G4ParticleTable *particleTable = G4ParticleTable::GetParticleTable(); G4ParticleDefinition *particle = particleTable -> FindParticle("e-"); @@ -28,6 +28,6 @@ MedtechPrimaryGeneratorAction::~MedtechPrimaryGeneratorAction() void MedtechPrimaryGeneratorAction::GeneratePrimaries(G4Event *anEvent) { - particleGun -> SetParticlePosition(G4ThreeVector(0, 0, 0)); + particleGun -> SetParticlePosition(G4ThreeVector(0, 0, -20*cm)); particleGun -> GeneratePrimaryVertex(anEvent); } diff --git a/src/MedtechSteppingAction.cc b/src/MedtechSteppingAction.cc index 5fa66a5..01b1e57 100644 --- a/src/MedtechSteppingAction.cc +++ b/src/MedtechSteppingAction.cc @@ -66,7 +66,7 @@ void MedtechSteppingAction::UserSteppingAction(const G4Step* step) if(postkinE < 1*MeV) { fTrack -> SetTrackStatus(fStopAndKill); - std::cout << "Low energy killed" < SetTrackStatus(fStopAndKill); MedtechAnalysis *man = MedtechAnalysis::getInstance(); - man -> Fill(postX, postY, postkinE); + //std::cout << "Target" < Fill(1, postX, postY, postZ, postkinE); } } } + if(particle == G4Electron::ElectronDefinition()) + { + if(preName == "sphere") + { + MedtechAnalysis *man = MedtechAnalysis::getInstance(); + std::cout << "Globe to sphere" < Fill(2, postX, postY, postZ, postkinE); + } + } //G4cout << "X: " << postX << " Y: " << postY << " KinE: " << postkinE << " Particle: " << fTrack -> GetDefinition() << G4endl; diff --git a/src/Parameters.cc b/src/Parameters.cc index 84b4e5e..ac1fd49 100644 --- a/src/Parameters.cc +++ b/src/Parameters.cc @@ -17,7 +17,7 @@ Parameters* Parameters::getInstance() return instance; } -Parameters::Parameters() : ParticleEnergy(6), hdegree(0), vdegree(0), box_size(10), tube_size(2), cone_size(2), radius(5) +Parameters::Parameters() : ParticleEnergy(6), hdegree(0), vdegree(0), box_size(10), tube_size(2), cone_size(2), radius(5), globe_size(1), globe_placement(0) { } @@ -104,3 +104,23 @@ double Parameters::GetTubeSize() { return tube_size; } + +void Parameters::SetGlobeSize(double s) +{ + globe_size = s; +} + +double Parameters::GetGlobeSize() +{ + return globe_size; +} + +void Parameters::SetGlonePlacement(double p) +{ + globe_placement = p; +} + +double Parameters::GetGlobePlacement() +{ + return globe_placement; +}