G4SDParticleFilter TrackLength Scorer for specific ion

Hello,

I want to create a PrimitveScorer that scores the Track Length of a given ion, like C12, N14, Al27, etc.

When i create a PrimitiveScorer for protons in DetectorConstruction, it looks like this

// Declare filters on Particles and Scorer
G4String fltName,particleName;

// Proton filter
G4SDParticleFilter* protonFilter =
new G4SDParticleFilter(fltName="protonFilter", particleName="proton");

//Track Length Scorer
G4VPrimitiveScorer* PS_TrackLength = new G4PSTrackLength("TrackLength");

//apply filter to scorer
PS_TrackLength ->SetFilter(protonFilter);

However if i change the ‘particleName’ to something like “C11” , “N14” or “Al27” i get an error;

“*** G4Exception : DetPS0101 issued by : G4SDParticleFilter::G4SDParticleFilter
Particle N14 not found.”

What works is the line

G4SDParticleFilter* nitrogenFilter =
new G4SDParticleFilter(fltName="nitrogenFilter", particleName="GenericIon");

but this will give the Track Lengths of all Ions…

What’s the naming scheme of G4SDParticleFilter for specific ions?

Best Regards
Max

Looking at $G4INCLUDE/G4SDParticleFilter.hh (as always, the .hh file is the correct and complete documentation for individual classes) I see
G4SDParticleFilter::addIon(Z,A). Implement your code as:

  G4SDParticleFilter* nitrogenFilter = new G4SDParticleFilter("nitrogenFilter");
  nitrogenFilter->addIon(7,14);

and similarly for your other nuclides.

1 Like

Thank you for your fast and direct reply!
It works and is excactly what i was looking for!

I was reading the Documentation, old Forum Posts and the G4SDParticleFilter.cc file …

Best Regards
Max

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.