Hi @anna thank you. By particle ID I mean the t number related to the particle (i.e. number=particle)! I must store it after the first and the second target.
Currently the simulation is able to describe the released energy in the two targets. But I nee these information too
- ParticleID: Which particle relased that energy? A primary positron? a secondary muon? A secondary electron?
- Particle Kinetic energy: How much is the kinetic energy of the particle that released the energy?
- Particle Direction: What is the direction of particle that released the energy?
** PARTICLE ID**
Following your message I did:
- In B1SteppingAction.cc
a. I added
#include "g4analysis.hh"
b.I added
auto analysisManager = G4AnalysisManager::Instance();
c. added
if (volume == fScoringVolume) {
int pdg = step->GetTrack()->GetParticleDefinition()->GetPDGEncoding();
analysisManager->FillNtupleDColumn(2, pdg);
}
if (volume == fScoringVolume2) {
int pdg2 = step->GetTrack()->GetParticleDefinition()->GetPDGEncoding();
analysisManager->FillNtupleDColumn(3, pdg2);
}
B1SteppingAction.cc (5.3 KB)
- In B1RunAction.cc
a. I wrote
analysisManager->CreateNtupleDColumn(“ParticleID”);
analysisManager->CreateNtupleDColumn(“ParticleID2”);
The I compiled and runned without errors
logB1.txt (98.1 KB)
and I got a B1.root file
So I opened the root file
and I get two graphs
the first one for the target 1
and the second one for the target 2
but the 2 plots are identical…thereare two partice having ID=-11 ( I think they are positrons) and one particle having ID=11 (I think it’s an electron).
Then…I’m not sure if the graph are identical because I really have the same particles after each target or because I made mistakes.…
PARTICLE KINETIC ENERGY
-
In B1SteppingAction.cc
a. I added
#include "G4Track.hh"
b. I added
if (volume == fScoringVolume) {
double kinEnergy = step->GetTrack()->GetDynamicParticle()->GetKineticEnergy();
analysisManager->FillNtupleDColumn(2, kinEnergy);
}
if (volume == fScoringVolume2) {
double kinEnergy2 = step->GetTrack()->GetDynamicParticle()->GetKineticEnergy();
analysisManager->FillNtupleDColumn(3, kinEnergy2);
}
B1PrimaryGeneratorAction.cc (4.3 KB)
- In B1RunAction.cc
a. I added
analysisManager->CreateNtupleDColumn(“kinEnergy”);[B1RunAction.cc|attachment]
analysisManager->CreateNtupleDColumn(“kinEnergy2”);
(upload://uGBGEMCRdDK7eaX13LxInnaZYPV.cc) (7.9 KB)
Then I compiled and runned without errors
logB1-2.txt (97.9 KB)
I got a B1.root file, so I opened it and here the 2 graphs
again the twro graphs are identical, then I’m not sure if really secondary particles have the same kinetic energy or I’m plotting the just particles after one of the two targets…
Moreover I notice that:
1. I simulated 45GeV positrons
2. By the particleID plots I see there are 4 positrons (particle id =-11) and one electron both after first and second target.
**3. By the kinetic energy plots I see there are 4 particles having 45GeV kinetic and one having a very low enegy. **
Given that I simulate 45GeV positrons hitting the targets, it looks like that 4 positrons didn’t interact in the targets and just one interacted…but, how is it possible that I get 5 particles? If just one positron interacted, I should have a couple electron/positron and the 4 primary positrons…not the 4 primary positrons and just one electron!
PARTICLE DIRECTIONS
I used the MomentumDirection functions…so
- In B1SteppingAction:
a. I added
#include “G4ParticleMomentum.hh”
b.I added
if (volume == fScoringVolume) {
double MomDirx = step->GetTrack()->GetMomentumDirection().x();
analysisManager->FillNtupleDColumn(4, MomDirx);
double MomDiry = step->GetTrack()->GetMomentumDirection().y();
analysisManager->FillNtupleDColumn(5, MomDiry);
double MomDirz = step->GetTrack()->GetMomentumDirection().z();
analysisManager->FillNtupleDColumn(6, MomDirz);
}
if (volume == fScoringVolume2) {
double MomDirx2 = step->GetTrack()->GetMomentumDirection().x();
analysisManager->FillNtupleDColumn(7, MomDirx2);
double MomDiry2 = step->GetTrack()->GetMomentumDirection().y();
analysisManager->FillNtupleDColumn(8, MomDiry2);
double MomDirz2 = step->GetTrack()->GetMomentumDirection().z();
analysisManager->FillNtupleDColumn(9, MomDirz2);
}
B1SteppingAction.cc (6.5 KB)
- In B1RunAction
a.I added
analysisManager->CreateNtupleDColumn(“MomentumDirection.x”);
analysisManager->CreateNtupleDColumn(“MomentumDirection.y”);
analysisManager->CreateNtupleDColumn(“MomentumDirection.z”);
analysisManager->CreateNtupleDColumn(“MomentumDirection.x2”);
analysisManager->CreateNtupleDColumn(“MomentumDirection.y2”);
analysisManager->CreateNtupleDColumn(“MomentumDirection.z2”);
B1RunAction.cc (8.3 KB)
Then I compiled and runned without errors, I opened the Root file, so I get the three momentum directions after the first target
And after the second one
In this case it looks like that the momentum directions after the two targets are different…
Do you think that I did mistakes or not?