示例#1
0
float SvtxClusterEval::get_energy_contribution(SvtxCluster* cluster, PHG4Hit* g4hit) {

  if (!has_node_pointers()) {++_errors; return NAN;}
  
  if (_strict) {
    assert(cluster);
    assert(g4hit);
  } else if (!cluster||!g4hit) {
    ++_errors;
    return NAN;
  }
  
  if ((_do_cache) &&
      (_cache_get_energy_contribution_g4hit.find(make_pair(cluster,g4hit)) !=
       _cache_get_energy_contribution_g4hit.end())) {
    return _cache_get_energy_contribution_g4hit[make_pair(cluster,g4hit)];
  }

  // this is a fairly simple existance check right now, but might be more
  // complex in the future, so this is here mostly as future-proofing.
  
  float energy = 0.0;
  std::set<PHG4Hit*> g4hits = all_truth_hits(cluster);
  for (std::set<PHG4Hit*>::iterator iter = g4hits.begin();
       iter != g4hits.end();
       ++iter) {
    PHG4Hit* candidate = *iter;
    if (candidate->get_hit_id() != g4hit->get_hit_id()) continue;    
    energy += candidate->get_edep();
  }

  if (_do_cache) _cache_get_energy_contribution_g4hit.insert(make_pair(make_pair(cluster,g4hit),energy));
  
  return energy;
}
示例#2
0
std::set<SvtxCluster*> SvtxClusterEval::all_clusters_from(PHG4Hit* truthhit) {

  if (!has_node_pointers()) {++_errors; return std::set<SvtxCluster*>();}
  
  if (_strict) {assert(truthhit);}
  else if (!truthhit) {++_errors; return std::set<SvtxCluster*>();}
  
  if (_do_cache) {
    std::map<PHG4Hit*,std::set<SvtxCluster*> >::iterator iter =
      _cache_all_clusters_from_g4hit.find(truthhit);
    if (iter != _cache_all_clusters_from_g4hit.end()) {
      return iter->second;
    }
  }
  
  std::set<SvtxCluster*> clusters;

  unsigned int hit_layer = truthhit->get_layer();
  
  // loop over all the clusters
  for (SvtxClusterMap::Iter iter = _clustermap->begin();
       iter != _clustermap->end();
       ++iter) {

    SvtxCluster* cluster = iter->second;

    if (cluster->get_layer() != hit_layer) continue;

    // loop over all truth hits connected to this cluster
    std::set<PHG4Hit*> hits = all_truth_hits(cluster);
    for (std::set<PHG4Hit*>::iterator jter = hits.begin();
	 jter != hits.end();
	 ++jter) {
      PHG4Hit* candidate = *jter;
      if (candidate->get_hit_id() == truthhit->get_hit_id()) {
	clusters.insert(cluster);
      }    
    }
  }

  if (_do_cache) _cache_all_clusters_from_g4hit.insert(make_pair(truthhit,clusters));
  
  return clusters;
}
示例#3
0
std::set<SvtxHit*> SvtxHitEval::all_hits_from(PHG4Hit* g4hit) {

  if (!has_node_pointers()) {++_errors; return std::set<SvtxHit*>();}
  
  if (_strict) {assert(g4hit);}
  else if (!g4hit) {++_errors; return std::set<SvtxHit*>();}
  
  if (_do_cache) {
    std::map<PHG4Hit*,std::set<SvtxHit*> >::iterator iter =
      _cache_all_hits_from_g4hit.find(g4hit);
    if (iter != _cache_all_hits_from_g4hit.end()) {
      return iter->second;
    }
  }
  
  std::set<SvtxHit*> hits;

  unsigned int hit_layer = g4hit->get_layer();
  
  // loop over all the hits
  for (SvtxHitMap::Iter iter = _hitmap->begin();
       iter != _hitmap->end();
       ++iter) {

    SvtxHit* hit = iter->second;

    if (hit->get_layer() != hit_layer) continue;
    
    // loop over all truth hits connected to this hit
    std::set<PHG4Hit*> g4hits = all_truth_hits(hit);
    for (std::set<PHG4Hit*>::iterator jter = g4hits.begin();
	 jter != g4hits.end();
	 ++jter) {
      PHG4Hit* candidate = *jter;
      if (candidate->get_hit_id() == g4hit->get_hit_id()) {
	hits.insert(hit);
      }    
    }
  }

  if (_do_cache) _cache_all_hits_from_g4hit.insert(make_pair(g4hit,hits));
  
  return hits;
}