All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
cheat::CheckBackTracking Class Reference
Inheritance diagram for cheat::CheckBackTracking:

Public Member Functions

 CheckBackTracking (fhicl::ParameterSet const &pset)
 
void analyze (art::Event const &evt)
 

Private Attributes

std::string fHitModuleLabel
 label for module creating recob::Hit objects More...
 
std::string fG4ModuleLabel
 label for module running G4 and making particles, etc More...
 

Detailed Description

Definition at line 33 of file CheckBackTracking_module.cc.

Constructor & Destructor Documentation

cheat::CheckBackTracking::CheckBackTracking ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 48 of file CheckBackTracking_module.cc.

49  : EDAnalyzer(pset)
50  , fHitModuleLabel{pset.get<std::string>("HitModuleLabel", "ffthit")}
51  , fG4ModuleLabel{pset.get<std::string>("G4ModuleLabel", "largeant")}
52  {}
std::string fHitModuleLabel
label for module creating recob::Hit objects
std::string fG4ModuleLabel
label for module running G4 and making particles, etc

Member Function Documentation

void cheat::CheckBackTracking::analyze ( art::Event const &  evt)

Definition at line 56 of file CheckBackTracking_module.cc.

57  {
58 
59  // grab the hits that have been reconstructed
60  art::Handle<std::vector<recob::Hit>> hitcol;
61  evt.getByLabel(fHitModuleLabel, hitcol);
62 
63  // make a vector of them - we aren't writing anything out to a file
64  // so no need for a art::PtrVector here
65  std::vector<art::Ptr<recob::Hit>> hits;
66  art::fill_ptr_vector(hits, hitcol);
67 
68  // loop over the hits and figure out which particle contributed to each one
69  std::vector<art::Ptr<recob::Hit>>::iterator itr = hits.begin();
70 
71  art::ServiceHandle<cheat::BackTrackerService const> bt_serv;
72  art::ServiceHandle<cheat::ParticleInventoryService const> pi_serv;
73 
74  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
75 
76  // make a collection of the distinct eve ID values
77  std::set<int> eveIDs;
78 
79  while (itr != hits.end()) {
80 
81  // print the truth information for this hit
82  mf::LogInfo("CheckBackTracking") << *((*itr).get()) << "\n channel is: " << (*itr)->Channel();
83 
84  std::vector<sim::TrackIDE> trackides = bt_serv->HitToTrackIDEs(clockData, *itr);
85  std::vector<sim::TrackIDE> eveides = bt_serv->HitToEveTrackIDEs(clockData, *itr);
86  std::vector<double> xyz = bt_serv->HitToXYZ(clockData, *itr);
87 
88  mf::LogInfo("CheckBackTracking")
89  << "hit weighted mean position is (" << xyz[0] << "," << xyz[1] << "," << xyz[2] << ")";
90 
91  for (size_t t = 0; t < trackides.size(); ++t) {
92 
93  // find the Eve particle for the current trackID
94  int eveID = pi_serv->ParticleList().EveId(trackides[t].trackID);
95 
96  mf::LogInfo("CheckBackTracking")
97  << "track id: " << trackides[t].trackID << " contributed " << trackides[t].energy << "/"
98  << trackides[t].energyFrac << " to the current hit and has eveID: " << eveID;
99  }
100 
101  for (size_t e = 0; e < eveides.size(); ++e) {
102  mf::LogInfo("CheckBackTracking")
103  << "eve id: " << eveides[e].trackID << " contributed " << eveides[e].energy << "/"
104  << eveides[e].energyFrac << " to the current hit";
105 
106  if (eveIDs.find(eveides[e].trackID) == eveIDs.end()) eveIDs.insert(eveides[e].trackID);
107  }
108 
109  itr++;
110  } // end loop over hits
111 
112  // loop over the eveID values and calculate the purity and efficiency for
113  // each
114  std::set<int>::iterator setitr = eveIDs.begin();
115  while (setitr != eveIDs.end()) {
116 
117  std::set<int> id;
118  id.insert(*setitr);
119  mf::LogInfo("CheckBackTracking")
120  << "eve ID: " << *setitr << " purity: " << bt_serv->HitCollectionPurity(clockData, id, hits)
121  << " efficiency: " << bt_serv->HitCollectionEfficiency(clockData, id, hits, hits, geo::k3D);
122 
123  setitr++;
124  }
125 
126  return;
127 
128  } // end analyze
std::string fHitModuleLabel
label for module creating recob::Hit objects
3-dimensional objects, potentially hits, clusters, prongs, etc.
Definition: geo_types.h:135
do i e
TCEvent evt
Definition: DataStructs.cxx:8

Member Data Documentation

std::string cheat::CheckBackTracking::fG4ModuleLabel
private

label for module running G4 and making particles, etc

Definition at line 41 of file CheckBackTracking_module.cc.

std::string cheat::CheckBackTracking::fHitModuleLabel
private

label for module creating recob::Hit objects

Definition at line 40 of file CheckBackTracking_module.cc.


The documentation for this class was generated from the following file: