| Message: Finding "mother particle" | Not Logged In (login) |
|
Hello!
I am currently simulating an experimental setup with a Sr90 source. To do this, I use G4RadioactiveDecay, and a general particle source. However, as 90Sr has a beta-decay to 90Y which again has another beta-decay (and then there are some gamma's etc), I get two betas per event. As I am using a G4PSEnergyDeposit to generate hits, this means that the energy in one single "real" hit could be over-estimated if both electrons hit the same SD in the same event, or the triggering (done in an external program by requiring that the energy deposit in a scintilator has to be larger than a set value) could be wrong if i get one electron in the trigger, and one in the "device under test". Thus I have started to implement a G4VSDFilter (*very* much not finished!), shown below:
#ifndef FilterMotherIon_hh #define FilterMotherIon_hh
#include "G4VSDFilter.hh" #include "globals.hh"
/* * Filter for a simple detector, in order to filter * hits depending on the originally decaying ion. * * */
class FilterMotherIon : public G4VSDFilter {
public:
FilterMotherIon(G4String name, G4int z, G4int a) :
G4VSDFilter(name), Z(z), A(a) {};
G4bool Accept(const G4Step* origStep) const;
private: G4int Z; G4int A; }; #endif
#include "FilterMotherIon.hh" #include "G4Track.hh" #include "G4ParticleDefinition.hh"
G4bool FilterMotherIon::Accept(const G4Step* origStep) const {
/*
* Run down the particle tree until either condition is met:
* - Correct particle is found (accept)
* - Primary particle is found (not found - reject)
*
* Remark: As the correct particle may be the primary particle,
* check (1) before (2)!
*/
while (true) {
G4ParticleDefinition* thisDef = origStep->GetTrack()->GetDefinition();
if (thisDef->GetAtomicNumber() == Z && thisDef->GetAtomicMass() == A) {
//Gold!
//G4cout << "GOLD!" << G4endl;
return true;
}
else {
//Dig deeper?
G4int parentID = origStep->GetTrack()->GetParentID();
G4cout << parentID << G4endl;
}
}
}
However, while I can get the ID of the parent track, I do not know how to translate this into a G4ParticleDefinition of the parent track, which I need to do recursively... --- Kyrre Ness Sjøbæk (Geant4 novice)
|
| Inline Depth: | Outline Depth: | Add message: |
|
to: |