All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
CAFRecoUtils Namespace Reference

Functions

std::vector< std::pair< int,
float > > 
AllTrueParticleIDEnergyMatches (const detinfo::DetectorClocksData &clockData, const std::vector< art::Ptr< recob::Hit > > &hits, bool rollup_unsaved_ids=1)
 
float TotalHitEnergy (const detinfo::DetectorClocksData &clockData, const std::vector< art::Ptr< recob::Hit > > &hits)
 
float TrackPurity (const detinfo::DetectorClocksData &clockData, int mcparticle_id, const std::vector< art::Ptr< recob::Hit >> &reco_track_hits)
 
float TrackCompletion (const detinfo::DetectorClocksData &clockData, int mcparticle_id, const std::vector< art::Ptr< recob::Hit >> &reco_track_hits)
 
int GetShowerPrimary (const int g4ID)
 

Function Documentation

std::vector< std::pair< int, float > > CAFRecoUtils::AllTrueParticleIDEnergyMatches ( const detinfo::DetectorClocksData clockData,
const std::vector< art::Ptr< recob::Hit > > &  hits,
bool  rollup_unsaved_ids = 1 
)

Definition at line 3 of file sbncode/sbncode/CAFMaker/RecoUtils/RecoUtils.cc.

3  {
4  art::ServiceHandle<cheat::BackTrackerService> bt_serv;
5  std::map<int, float> trackIDToEDepMap;
6  for (std::vector<art::Ptr<recob::Hit> >::const_iterator hitIt = hits.begin(); hitIt != hits.end(); ++hitIt) {
7  art::Ptr<recob::Hit> hit = *hitIt;
8  std::vector<sim::TrackIDE> trackIDs = bt_serv->HitToTrackIDEs(clockData, hit);
9  for (unsigned int idIt = 0; idIt < trackIDs.size(); ++idIt) {
10  int id = trackIDs[idIt].trackID;
11  if (rollup_unsaved_ids) id = std::abs(id);
12  id = GetShowerPrimary(id);
13  trackIDToEDepMap[id] += trackIDs[idIt].energy;
14  }
15  }
16 
17  std::vector<std::pair<int, float>> ret;
18  for (auto const &pair: trackIDToEDepMap) {
19  ret.push_back(pair);
20  }
21  return ret;
22 }
process_name hit
Definition: cheaterreco.fcl:51
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
T abs(T value)
int CAFRecoUtils::GetShowerPrimary ( const int  g4ID)

Definition at line 91 of file sbncode/sbncode/CAFMaker/RecoUtils/RecoUtils.cc.

92 {
93  art::ServiceHandle<cheat::ParticleInventoryService> particleInventory;
94  const sim::ParticleList& particles = particleInventory->ParticleList();
95  const sim::ParticleList::const_iterator part_iter = particles.find(g4ID);
96  if(part_iter == particles.end()) return g4ID;
97 
98  auto temp_iter = part_iter;
99  int primary_id = part_iter->second->TrackId();
100 
101  while (std::abs(temp_iter->second->PdgCode()) == 11 || temp_iter->second->PdgCode() == 22)
102  {
103  primary_id = temp_iter->second->TrackId();
104  temp_iter = particles.find(temp_iter->second->Mother());
105  if(temp_iter == particles.end()) break;
106  }
107 
108  return primary_id;
109 }
T abs(T value)
float CAFRecoUtils::TotalHitEnergy ( const detinfo::DetectorClocksData clockData,
const std::vector< art::Ptr< recob::Hit > > &  hits 
)

Definition at line 47 of file sbncode/sbncode/CAFMaker/RecoUtils/RecoUtils.cc.

47  {
48  art::ServiceHandle<cheat::BackTrackerService> bt_serv;
49 
50  float ret = 0.;
51 
52  for (std::vector<art::Ptr<recob::Hit> >::const_iterator hitIt = hits.begin(); hitIt != hits.end(); ++hitIt) {
53  art::Ptr<recob::Hit> hit = *hitIt;
54  std::vector<sim::TrackIDE> trackIDs = bt_serv->HitToTrackIDEs(clockData, hit);
55  for (unsigned int idIt = 0; idIt < trackIDs.size(); ++idIt) {
56  ret += trackIDs[idIt].energy;
57  }
58  }
59  return ret;
60 }
process_name hit
Definition: cheaterreco.fcl:51
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
float CAFRecoUtils::TrackCompletion ( const detinfo::DetectorClocksData clockData,
int  mcparticle_id,
const std::vector< art::Ptr< recob::Hit >> &  reco_track_hits 
)

Definition at line 62 of file sbncode/sbncode/CAFMaker/RecoUtils/RecoUtils.cc.

62  {
63  // get handle to back tracker
64  art::ServiceHandle<cheat::BackTrackerService> bt;
65 
66  // get all the IDE's of the truth track
67  const std::vector<const sim::IDE*> mcparticle_ides = bt->TrackIdToSimIDEs_Ps(mcparticle_id);
68  // sum it up
69  float mcparticle_energy = 0.;
70  for (auto const &ide: mcparticle_ides) {
71  mcparticle_energy += ide->energy;
72  }
73 
74  // get all the hits of the reco track that match the truth track
75  const std::vector<art::Ptr<recob::Hit>> matched_reco_track_hits = bt->TrackIdToHits_Ps(clockData, mcparticle_id, reco_track_hits);
76 
77  // for each of the hits get the energy coming from the track
78  float matched_reco_energy = 0.;
79  for (auto const &matched_reco_track_hit: matched_reco_track_hits) {
80  std::vector<sim::IDE> this_hit_IDEs = bt->HitToAvgSimIDEs(clockData, *matched_reco_track_hit);
81  for (auto const &ide: this_hit_IDEs) {
82  if (ide.trackID == mcparticle_id) {
83  matched_reco_energy += ide.energy;
84  }
85  }
86  }
87 
88  return matched_reco_energy / mcparticle_energy;
89 }
float CAFRecoUtils::TrackPurity ( const detinfo::DetectorClocksData clockData,
int  mcparticle_id,
const std::vector< art::Ptr< recob::Hit >> &  reco_track_hits 
)

Definition at line 24 of file sbncode/sbncode/CAFMaker/RecoUtils/RecoUtils.cc.

24  {
25  // get handle to back tracker
26  art::ServiceHandle<cheat::BackTrackerService> bt;
27 
28  // get all the hits of the reco track that match the truth track
29  const std::vector<art::Ptr<recob::Hit>> matched_reco_track_hits = bt->TrackIdToHits_Ps(clockData, mcparticle_id, reco_track_hits);
30 
31  // for each of the hits get the energy coming from the track
32  float matched_reco_energy = 0.;
33  float reco_energy = 0.;
34  for (auto const &matched_reco_track_hit: matched_reco_track_hits) {
35  std::vector<sim::IDE> this_hit_IDEs = bt->HitToAvgSimIDEs(clockData, *matched_reco_track_hit);
36  for (auto const &ide: this_hit_IDEs) {
37  reco_energy += ide.energy;
38  if (ide.trackID == mcparticle_id) {
39  matched_reco_energy += ide.energy;
40  }
41  }
42  }
43 
44  return (reco_energy > 1e-6) ? matched_reco_energy / reco_energy : 1.;
45 }
do i e