Issues with Retrieving GlobalStartTime and GlobalEndTime for PixelHit MCParticle

Hello everyone,

I’m trying to retrieve the Number, the GlobalEndTime and the GlobalStartTime of the MCParticles related to each PixelHit using the following code snippet:

for(auto& hit : input_hits){
  std::vector<const allpix::MCParticle*> mc_particles = hit->getMCParticles();
  // Get the number of MCParticles related to this hit
  output_MC_num.push_back(mc_particles.size());
  for (auto& particle : mc_particles) {
      if (particle != nullptr && particle->getTrack() != nullptr) {
          // Get the StartTime and EndTime of the MCParticle
          output_MC_stime.push_back(particle->getTrack()->getGlobalStartTime());
          output_MC_etime.push_back(particle->getTrack()->getGlobalEndTime());
      }
  }
}

I can get the number of MCParticles successfully as the following Figure.

However, as shown in the following Figure, no GlobalEndTime and the GlobalStartTime data has been recorded.

Does anyone know why this might be happening? I’ve attached the full analysis code and data files for reference.
analysis.txt (4.8 KB)
File00000.root (19.4 MB)

Thank you in advance for any help!

Caro

Hi @Caro ,

There were some issues in the script, in getting the track objects and advancing the event in them. I’ve fixed it, see attached.
analysis_fixed.txt (5.6 KB)

Now the times look like this:
image
image

Kind regards,
Håkan

Dear @hwennlof

Thank you very very much for your reply, it is very helpful to me!

Caro