Heavy Ions energy scoring

Dear Geant4 users
Hi,
In example RE02 in Detector Construction one can determine the particles spectra scoring using:

G4SDParticleWithEnergyFilter* pkinEFilter =
new G4SDParticleWithEnergyFilter(fltName=",kmin,kmax);
pkinEFilter->add(“particle name”);

The question is that for heavy ion tracking such as secondary carbon ions I don’t know what Particle Name to use.
I defined the ion by;
G4SDparticleFilter*IonFilter= new G4SDparticleFilter;
IonFilter-> addIons(6 12);

But in scoring the ion energy spectra it ask to add particle name in this line: G4SDParticleWithEnergyFilter(fltName=",kmin,kmax);
pkinEFilter->add(“particle name”);

Please let me know how using RE02 for tracking the heavy ions energy spectra.
Thanks

You found the first half of the solution – the underlying ParticleFilter has exactly the (Z,A) interface you need (heavy ions are not instantiated until the run begins, so you can’t reference them directly before that)

The ParticleWithEnergyFilter does not include a call through to the addIon() function. Nor does it include accessors to address the two internal filters directly. I’d call this a bug (or a “missing feature”).

Would you be willing to create a Bugzilla report requesting this be added? It won’t help you right now, unless you patch the code yourself, but it will make things better down the road.

Thanks for the reply Michael.
Yes, it is a missing feature. However, I tried the example Hadr06 which gives an ion spectra in root format. It gave me a small help in my project.
Anyway, I appreciate for your time.

It occurs to me that if you’re doing your setup using C++ code, rather than macro commands, you could make your own Filter class as a subclass of G4VSDFilter, and register it into your SD. Then you’d have control over the interface, and could implement the missing addIon(Z,A) function. You could make the filter as custom as you like in that case.

Is there any hint in the examples? Would you please make it more clear as I am not very professional in writing but I will give a try.

There’s one example for writing your own filter class:

$ cd /Applications/GEANT4/geant4.10.07.p03/examples/
$ find . -name '*.hh'|xargs grep SDFilter
./advanced/ChargeExchangeMC/include/CexmcTrackPointsFilter.hh:#include <G4VSDFilter.hh>
./advanced/ChargeExchangeMC/include/CexmcTrackPointsFilter.hh:class  CexmcTrackPointsFilter : public G4VSDFilter
1 Like

Many many thanks.
It looks exactly what I needed.
Best

How about this:
Adding some lines for scoring the flux between two energy limits of Emin & Emax.

But it is beyound my skill.

1 Like