Skip to content

Reco to true matching

Marco Del Tutto edited this page Oct 13, 2017 · 3 revisions

The matching between reconstructed and simulated objets is done by the module RecoTrueMatcher_module.cc. The matching is done exclusively between reconstructed PFParticles (PFP) and simulated MCParticles (MCP). Once the module finds a match for an MCP, it created an MCGhost and places it into the art::Event. The MCGhost has one association with the MCP, and one with the matched PFP. In analysis, given an PFP (here called pfp), you can then retrieve the matched MCP by doing:

art::Handle<std::vector<ubana::MCGhost>> ghost_h;
e.getByLabel(_mc_ghost_producer,ghost_h);
if(!ghost_h.isValid()){
  throw std::exception();
}
art::FindManyP<ubana::MCGhost>   mcghost_from_pfp   (pfp_h,   e, _mc_ghost_producer);
art::FindManyP<simb::MCParticle> mcpar_from_mcghost (ghost_h, e, _mc_ghost_producer); 

std::vector<art::Ptr<ubana::MCGhost>> mcghosts = mcghost_from_pfp.at(pfp.key());
if (mcghosts.size() > 0) {
  // The match exists, get the mcparticle
  art::Ptr<simb::MCParticle> mcpar = mcpar_from_mcghost.at(mcghosts[0].key()).at(0);
}

You can then check the origin of the MCP (for example to see if it's a GENIE simulated one), by doing:

::art::ServiceHandle<cheat::BackTracker> bt;

const auto mc_truth = bt->TrackIDToMCTruth(mcpar->TrackId()); 
if (mc_truth) {
  if (mc_truth->Origin() == simb::kBeamNeutrino) {
    std::cout << "Neutrino Origin" << std::endl;
  }
}
Clone this wiki locally