2 circular targets

Thank you @anna. Then if I undestand,

  1. Currently in the ROOT file I’m storing each step in which there is an interaction between the target (1 or 2)
  2. I store these interactions (7 interactions because, currently I’ve a beam just constitued by only 5 e+) and I store
    a. the ID of interacting particle
    b. the kinetic energy of interacting particle
    c. The momentum (x,y,z) of interacting particles
    d. The released energy in the targets in each step by particles.

Right?

Now, to end the program, I should:

  1. Set the beam dimension, so that I can study the differences of relased energy in the targets in function of the beam dimension
  2. Store in the ROOT file the information about secondary particles after the second target; I mean
    a. The PDG ID of secondary particles outgoing from the second target
    b. The kinetic energy of the secondary particles outgoing the secondary particles

Can you help me for this too, please?

To modify the beam you can read in the user guide on the general particle source.
To check for particles exiting the volume, you need to introduce another check into the stepping action, I believe it is touched in another thread on the forum.

Thank you @anna, but before to speak about the beam size and the outgoing particle…I just notice a problem!
Moving the

analysisManager->FillNtupleDColumn(0,5, fEdep);
analysisManager->FillNtupleDColumn(1,5, fEdep2Tar);

from the B1EventAction to the B1SteppingAction to get just 7 events as I read by the tracking verbosity, I have a problem in the released energy, i.e. I get a 0GeV released energy in the two targets!
I just noticed it


So, what should I do to have 7 events, but no zero energy?

Does anyone know how to fix it please?
I’m sorry to update my help request, but this is my first Gean4 simulation and I need it to be admitted to next PhD year…so if someone can help me to finish it, please do it. Currently I just need

  1. to fix this problem of 0 GeV released energy;
  2. to get information about outgoing particles
  3. to set the beam size
    and the program will be finished.

For the answer to 2) and 3) please see my previous post.
Regarding 1), I cannot reproduce your problem. Attaching header files does not help much with the code, it’s the source files that you edit (the ones ending with .cc)
However, let me show explicitly how it can be done. Energy accumulated in the target should not be filled within step, but rather after all the particles are simulated (it’s a sum of energy of all particles within an event). Therefore, they should be filled from event action. To do so you need to create a separate (third) ntuple, as I wrote in many previous messages:

  analysisManager->CreateNtuple("B1Event", "Event");
  analysisManager->CreateNtupleDColumn("OutputEnergy");
  analysisManager->CreateNtupleDColumn("OutputEnergy2");
  analysisManager->FinishNtuple();

(removing “OutputEnergy” and “OutputEnergy2” from other ntuples)
And fill it in in ::EndOfEventAction(...):

   auto analysisManager = G4AnalysisManager::Instance();
  analysisManager->FillNtupleDColumn(2,0, fEdep);
  analysisManager->FillNtupleDColumn(2,1, fEdep2Tar);
  analysisManager->AddNtupleRow(2);

Of course you need to keep accumulating the energy in the stepping action:

  G4double edepStep = step->GetTotalEnergyDeposit();
  if (volume == fScoringVolume) {
    fEventAction->AddEdep(edepStep);
  } else if (volume == fScoringVolume2) {
    fEventAction->AddEdep2(edepStep);
  }

That way you have an ntuple that should have as many entries as events that you run (5).

Thank you @anna ,I know you replied me about the outgoing particles and the beam size, but I first want to solve the 0 energy problem.

I created the third ntupla to store just the released energy in the two targets (I showed you it). But, as you wrote, in this way I just store the released energy by primary particles. Instead, as I wrote previous, my supervisor wants to store the released energy not just by primary particles, but also by secondary particle…this is my problem and this is the reason because you wrote me to see what happen in the verbosity tracker and to move the storing energy from the event action to the stepping action.
So, do you know how can I store both primary and secondary particles released energy?

Ps. Here there is all the code https://we.tl/t-iYl3DPpNFg

Have you looked at any of the basic examples? I am fairly sure that accumulating results for a full event (not just one step), as well as accumulating totals across many events in a run, are part of those examples.

Hi @mkelsey , thanks. I’m modifying the B1 example and @anna was helping me to do it.

My supervisror wants that the program

  1. Store the released energy in my two targets both by primary and secondary particles.
  2. Store the PDG particle ID of the particle releasing energy
  3. Store the kinetic energy of the particle releasing energy
  4. Store the directions of the particle releasing energy
  5. Store PDG particle ID of the particle outgoing the second target
  6. Store kinetic energy of the particle outgoing the second target

Let’s go step by step and let’s think first about what happens inside the two targets for now.

I think that in the B1 example the accumulating energy is for the event, because in the B1SteppingAction.cc I have the code:

  1. For the first target:
    if (volume == fScoringVolume) { G4double edepStep = step->GetTotalEnergyDeposit(); fEventAction->AddEdep(edepStep); }

  2. For the second target:

     else if (volume == fScoringVolume2) {
       G4double edepStep2 = step->GetTotalEnergyDeposit();
       fEventAction->AddEdep2(edepStep2);
     	}
    

then I think that I’m accumulating energy in the full event. Am I wrong?

Given that I need both the released energy by primary and secondary particles in the target, @anna said me to create a first Ntupla to store in the first one the released energy in the first target and in the second one the released energy in the second target.

Here the plots about the PDG, the kinetic energy, momentum and the released energy in the 2 targets:

TARGET 1
Particle ID


Kinetic Energy

Momentum x

Momentum y

Momentum z

Released Energy

TARGET 2

Particle ID


Kinetic Energy

Momentum x

Momentum y

Momentum z

Released energy

Then in the ROOT plots I read that I have 12 particles (i.e 6 e+, 5 photons and 1 e-) in each target. But it looks like to me that it doesn’t fit with the verbosity tracker

verbosity.txt (60.6 KB)

Or not? @anna and @mkelsey what do you think? Are the result fitting with the verbosity tracker or should I fix something?

@anna, last week, wrote me

but
if I move the lines
analysisManager->FillNtupleDColumn(0,5, fEdep);
analysisManager->FillNtupleDColumn(1,5, fEdep2Tar);
In the stepping action, I get 0 GeV released energy!

She also wrote me

but in this way I just store the released energy by prirmary particles (not the released enrergy by primary and secondary)…or not? @anna did I understand wrotng your message?

What I mean is:
If my beam is constituted by five 45GeV e+ and hitting the first target, one of them produce a couple e+e-, I must accumulate both the released energy by the 5 primary e+, and the secondary e+ and e-. Does my code is doing it correctly?