I am developing some code for the DD4hep software, I am using Geant4 version 10.7 and I am generating MC events with Pythia8.3 Angantyr model.
I am trying to access particle definition objects of excited ions from the pdgID in this way,
int id = particle->pdgID; // is 10 L ZZZ AAA I
int L, A, Z, lvl;
id -= 1000000000;
L = id / 10000000; id %= 10000000;
Z = id / 10000; id %= 10000;
A = id / 10; id %= 10;
lvl = id;
G4double E = 0.0;
G4IonTable* tab_ion = G4IonTable::GetIonTable();
G4ParticleDefinition* def_ion = tab_ion->FindIon(Z, A, lvl);
The FindIon method returns a null pointer for some of these states. For example, for pdg ID equal to 1000691759 and 1000711809. What is the reason for this?
Does this state have a defined excitation energy?
What does it mean the warning message: “Isomer level 9 may be ambiguous”?
I would like to specify that not all the ions with isomer level equal to 9 are null pointers.
Here an example of some printouts to get pdgID, pointer and excitation energy (using the method ((const G4Ions*)(def_ion))->GetExcitationEnergy();).
It works for this case:
Creating ion 1000230499
Found ion 0x15fd1140
GetIsomerLevel, 9, excitation energy E=0.152928
please try out
First of all if the example is working for you. Second: C++ interface is equivalent to UI command shown in this example.
There is some limitation in this interface: parameters to ions should exactly coincide with the real level of an isomer - this excitation energy should exist in the list of excitation energies for given isomer.
There is another limitation: Geant4 must be initialized before this call.
I have suggested simplest radioactive decay example first of all in order to show that ion interface is working. Secondly, you may add your lines of code into example user class and see if you have G4Exception or not. Reproducing the problem inside G4 examples allowing easy formulate question (or bug report) to Geant4 developers.
I suspect that inside example ion interface will be fine and the problem is in your application.
-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : UIMAN0123
issued by : G4UImanager::ApplyCommand
Ion with Z = 71, A = 118, I = 9 is not defined
Error code : 1
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------
So, how do I tell Geant4 about this ion (and all the other ions people might come up with)?