I want to perform a simulation of x-rays. I’m still at the beginning of my project where I’m using code snippets of other projects. So far, it’s working well, I guess but I’m a bit stuck now where I expect the x-rays to go through the detectors and not being stopped there. This is the code of the detector:
fAlive : Continue the tracking
fStopButAlive : Invoke active rest physics processes and kill the current track afterward
fStopAndKill : Kill the current track
fKillTrackAndSecondaries : Kill the current track and also associated secondaries. Suspend the current track.
fSuspend : Suspend the current track
fPostponeToNextEvent : Postpones the tracking of the current track to the next event
What are you trying to do? If you want the xray to travel through your detector, just comment out that line. You don’t have to replace it with anything
Good point, actually, I want to measure the deposited energy at the detectors but x-rays are possible to go through matter, right? So I would expect that a part of the x-rays go through even if there’s a detector?
You don’t have to do anything. That’s what Geant4 does. It will track a particle, with all of its interactions and energy losses, until the particle either reaches zero energy, or leaves the world volume.
Why do you want to chage the track status? Your question was about measuring quantities (i.e., using a sensitive detector, a scorer, or a stepping action). If you want to let Geant4 do it’s normal thing, you shouldn’t interfere with that by changing the track status.
You can remove any line. There are very few required commands in GEANT4, namely specify your user action classes, and creating a minimal geometry, particle source, etc.
If you don’t have that line, Geant4 will handle the process and only record what you ask it to
What does happen when I comment out this line (either be it track->SetTrackStatus(fStopAndKill); or track->SetTrackStatus(fAlive); ) ?
I noticed slight changes in the energy deposition but what is actually happening then?
when commenting out the line track->SetTrackStatus(fStopAndKill);, you don’t kill the particle in the current step, and thus the particle proceeds to be tracked through the geometry and can deposit additional energy or leave the detector volume etc…
when commenting out the line track->SetTrackStatus(fAlive);, in principle nothing should change. Without having looked very much into this: you could see differences in energy deposition due to different reasons: first, the random numbers generator is in a different state (if you seed e.g. with the current time at the start of the run / launch of application / …). Second, maybe the order in which the tracks are processed could change when you touch the TrackStatus (the order of random numbers stays the same, but different “decisions” are made for the particular step)? After all, it is a monte carlo simulation…
In any case: I would not touch stuff if not needed. Manually setting the trackStatus to alive is probably unneccessary…
Am I safe when I simply uncomment the track->SetTrackStatus() in general? Is there any default which will be set then?
Btw, I can’t find any official information about these options…?
a general statement is difficult in this case. Your code snippet from the opening post suggests that you intend to detect the position where a particle enters the detector. In order to avoid counting the same particle as it travels through the detector in each step, the particle is killed at the first step within the SD.
If you don’t kill the particle, there will be at least 1 additional step inside the SD (namely, when it leaves the volume) and an additional N-tuple row will be added.
I would add
if (aStep->GetPreStepPoint()->GetStepStatus() == fGeomBoundary ) {
...
}
around the stuff that is supposed to sense the entrance position, and not mess with the TrackStatus.
I don’t belive there is a default that will be set anywhere, because it is simply not necessary to change this --except maybe some (physical)process happens that changes the status, but this is then part of Geant4 doing it’s normal thing
You have posted documentation about the different options yourself:
You are safe doing just about anything… you can always revert if you see unintended changes. You can do almost nothing in stepping action and Geant4 will create the particle, track it through all physics processes that occur, and stop tracking when the particle is destroyed. You don’t have to specify any changes to the track status unless you explicitly want to. For instance, as weller mentioned, if you only care about the location that the particle enters your detector, you could kill the particle after it has entered the detector. But if you also care about total energy deposited, then you will have to check to make sure the particle has just entered the detector (for the first time) and isn’t just interacting inside of the detector.
Sorry in case I’m repeating myself over and over. My attempt is rather simple: I only want to measure the energy particles (only photons) deposit within my detectors. This, on the other hand, as realistic as possible.
Means, from my side, the photons shouldn’t be killed within the detector because they could go through it and enter another detector(?).
That’s why I’m so concerned about this track status because I’m not really understanding it (w.r.t. to the simulation). But according to the deposited energies it seems there is (almost) no difference whether I use the track status or not (in case it is set to fStopAndKill).
From my guts I would set it to fAlive because “continuing the track” sounds reasonable to me. But whyever, this takes ages meaning it takes so long it is not usable…? But maybe I would need to change something for this (like Pre- or PostStep…?).
I’m also fine to ignore/uncomment this command in total. I just don’t understand it in either case