I’ve been running 87000 events and was trying to figure out how to determine the amount of particles that are hitting in the simulation
Hi @Aatuser
for every particle that interacts with the detector, one MCParticle
is generated. Assuming you have stored those using the ROOTObjectWriter, this ROOT macro should do the job:
// Open tree
TTree* mcp_tree = static_cast<TTree*>(file->Get("MCParticle"));
// Get branch of the detector of interest
TBranch* mcp_branch = mcp_tree->FindBranch("my_detector");
// Bind the information to a predefined vector
std::vector<allpix::MCParticle*> mcparticles;
mcp_branch->SetObject(&mcparticles);
size_t total_particles = 0;
// Loop over tree, event-by-event:
for(int i = 0; i < mcp_tree->GetEntries(); ++i) {
mcp_tree->GetEntry(i);
total_particles += mcparticles.size();
}
std::cout << "Total particles: " << total_particles << std::endl;
Best regards,
Simon