Saving Cerenkov photons and Scintillation photons in different ntuples

Geant4 Version: 11.3
Operating System:
Compiler/Version:
CMake Version:


I defined a SenstiveDetector that scores hits from optical photons. Then I want to handle separately cerenkov and scintillation photons, for example I want to save the global time of the hit in separate ntuples of they are cerenkov or optical photons.

In my EndOfEventAction() I put this:

for (int j = 0; j < totalHitsCH1; ++j) {
  SiPMHit\* Hit = (\*SiPM_CH1_HitCollection)\[j\];


  if (Hit->GetCreatorProcess() == “Scintillation”) {

  ++tot_phot_scint_CH1;

  analysisManager->FillNtupleFColumn(21, Hit->GetEnergy());

  analysisManager->FillNtupleFColumn(17, Hit->GetTime());

  analysisManager->FillNtupleFColumn(25, Hit->GetPos().x());

  analysisManager->FillNtupleFColumn(26, Hit->GetPos().y());

  analysisManager->FillNtupleFColumn(27, Hit->GetPos().z());

  analysisManager->AddNtupleRow();

  }
  else if (Hit->GetCreatorProcess() == “Cerenkov”) {

  ++tot_phot_cer_CH1;

  analysisManager->FillNtupleFColumn(22, Hit->GetEnergy());

  analysisManager->FillNtupleFColumn(18, Hit->GetTime());

  analysisManager->FillNtupleFColumn(28, Hit->GetPos().x());

  analysisManager->FillNtupleFColumn(29, Hit->GetPos().y());

  analysisManager->FillNtupleFColumn(30, Hit->GetPos().z());

  analysisManager->AddNtupleRow();

  }

}

Then I if a look a the branches in output file, for example the branch containing the time of cerenkov photons I get a lot of zeros

It seems to me that the columns of cerenkov photons get filled with zeros when I fill columns for scintillation photons, is there a way to avoid this issue?

Hello,

I suggest you to create two n-tuples: one for Scintillation and one for Cerenkov photons and to define columns only for the data that you need to fill.

Then you will call FillNtupleFColumn and AddNtupleRow with the ntupleId additional parameter as follows:

for (int j = 0; j < totalHitsCH1; ++j) {
  SiPMHit\* Hit = (\*SiPM_CH1_HitCollection)\[j\];


  if (Hit->GetCreatorProcess() == “Scintillation”) {

  ++tot_phot_scint_CH1;

  analysisManager->FillNtupleFColumn(0, 0, Hit->GetEnergy());
  analysisManager->FillNtupleFColumn(0, 1, Hit->GetTime());
  analysisManager->FillNtupleFColumn(0, 2, Hit->GetPos().x());
  analysisManager->FillNtupleFColumn(0, 3, Hit->GetPos().y());
  analysisManager->FillNtupleFColumn(0, 4, Hit->GetPos().z());
  analysisManager->AddNtupleRow(0);

  }

else if (Hit->GetCreatorProcess() == “Cerenkov”) {

  ++tot_phot_cer_CH1;

  analysisManager->FillNtupleFColumn(1, 0, Hit->GetEnergy());
  analysisManager->FillNtupleFColumn(1, 1, Hit->GetTime());
  analysisManager->FillNtupleFColumn(1, 2, Hit->GetPos().x());
  analysisManager->FillNtupleFColumn(1, 3, Hit->GetPos().y());
  analysisManager->FillNtupleFColumn(1, 4, Hit->GetPos().z());
  analysisManager->AddNtupleRow(1);

  }

}

Best regards,