Ejemplo n.º 1
0
std::set<PHG4VtxPoint*> SvtxVertexEval::all_truth_points(SvtxVertex* vertex) {

 if ((_do_cache) && (_cache_all_truth_points.find(vertex) !=
		     _cache_all_truth_points.end())) {
    return _cache_all_truth_points[vertex];
  }
  
  PHG4TruthInfoContainer* truthinfo = findNode::getClass<PHG4TruthInfoContainer>(_topNode,"G4TruthInfo");
  if (!truthinfo) {
    cerr << PHWHERE << " ERROR: Can't find G4TruthInfo" << endl;
    exit(-1);
  }

  std::set<PHG4VtxPoint*> points;
  
  std::set<PHG4Particle*> particles = all_truth_particles(vertex);
  for (std::set<PHG4Particle*>::iterator iter = particles.begin();
       iter != particles.end();
       ++iter) {
    PHG4Particle* particle = *iter;

    // only consider primary particles
    PHG4TruthInfoContainer::Map primarymap = truthinfo->GetPrimaryMap();
    if (primarymap.find(particle->get_track_id()) == primarymap.end()) continue;
        
    points.insert(truthinfo->GetPrimaryVtx(particle->get_vtx_id()));
  }

  if (_do_cache) _cache_all_truth_points.insert(make_pair(vertex,points));
  
  return points;
}
Ejemplo n.º 2
0
bool SvtxTruthEval::is_primary(PHG4Particle* particle) {

  PHG4TruthInfoContainer* truthinfo = findNode::getClass<PHG4TruthInfoContainer>(_topNode,"G4TruthInfo");
  if (!truthinfo) {
    cerr << PHWHERE << " ERROR: Can't find G4TruthInfo" << endl;
    exit(-1);
  }

  bool is_primary = false;  
  PHG4TruthInfoContainer::Map primary_map = truthinfo->GetPrimaryMap();
  for (PHG4TruthInfoContainer::ConstIterator iter = primary_map.begin(); 
       iter != primary_map.end(); 
       ++iter) {
    if (iter->second->get_track_id() == particle->get_track_id() ) {
      is_primary = true;
    }
  }
  
  return is_primary;
}
Ejemplo n.º 3
0
// overlap calculations
unsigned int SvtxVertexEval::get_ntracks_contribution(SvtxVertex* vertex, PHG4VtxPoint* truthpoint) {

  if ((_do_cache) && (_cache_get_ntracks_contribution.find(make_pair(vertex,truthpoint)) !=
		      _cache_get_ntracks_contribution.end())) {
    return _cache_get_ntracks_contribution[make_pair(vertex,truthpoint)];
  }
  
  SvtxTrackMap* trackmap = findNode::getClass<SvtxTrackMap>(_topNode,"SvtxTrackMap");
  if (!trackmap) {
    cerr << PHWHERE << " ERROR: Can't find SvtxTrackMap" << endl;
    exit(-1);
  }

  PHG4TruthInfoContainer* truthinfo = findNode::getClass<PHG4TruthInfoContainer>(_topNode,"G4TruthInfo");
  if (!truthinfo) {
    cerr << PHWHERE << " ERROR: Can't find G4TruthInfo" << endl;
    exit(-1);
  }
  
  unsigned int ntracks = 0;

  for (SvtxVertex::TrackIter iter = vertex->begin_tracks();
       iter != vertex->end_tracks();
       ++iter) {
    
    SvtxTrack* track = trackmap->get(*iter);
    PHG4Particle* particle = _trackeval.max_truth_particle_by_nclusters(track);

    // only consider primary particles
    PHG4TruthInfoContainer::Map primarymap = truthinfo->GetPrimaryMap();
    if (primarymap.find(particle->get_track_id()) == primarymap.end()) continue;

    PHG4VtxPoint* candidate = truthinfo->GetPrimaryVtx(particle->get_vtx_id());
    if (candidate->get_id() == truthpoint->get_id()) ++ntracks;
  }
  
  if (_do_cache) _cache_get_ntracks_contribution.insert(make_pair(make_pair(vertex,truthpoint),ntracks));
  
  return ntracks;
}