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

Public Member Functions

 RecoCheckAna (fhicl::ParameterSet const &p)
 

Private Member Functions

void analyze (art::Event const &e) override
 
void beginRun (art::Run const &r) override
 
void CheckReco (detinfo::DetectorClocksData const &clockData, int const &colID, std::vector< art::Ptr< recob::Hit >> const &allhits, std::vector< art::Ptr< recob::Hit >> const &colHits, std::map< std::pair< int, int >, std::pair< double, double >> &g4RecoBaseIDToPurityEfficiency)
 
void CheckRecoClusters (art::Event const &evt, std::string const &label, art::Handle< std::vector< recob::Cluster >> const &clscol, std::vector< art::Ptr< recob::Hit >> const &allhits)
 
void CheckRecoTracks (art::Event const &evt, std::string const &label, art::Handle< std::vector< recob::Track >> const &tcol, std::vector< art::Ptr< recob::Hit >> const &allhits)
 
void CheckRecoShowers (art::Event const &evt, std::string const &label, art::Handle< std::vector< recob::Shower >> const &scol, std::vector< art::Ptr< recob::Hit >> const &allhits)
 
void CheckRecoVertices (art::Event const &evt, std::string const &label, art::Handle< std::vector< recob::Vertex >> const &vtxcol, std::vector< art::Ptr< recob::Hit >> const &allhits)
 
void CheckRecoEvents (art::Event const &evt, std::string const &label, art::Handle< std::vector< recob::Event >> const &evtcol, std::vector< art::Ptr< recob::Hit >> const &allhits)
 
void FillResults (detinfo::DetectorClocksData const &clockData, std::vector< art::Ptr< recob::Hit >> const &allhits)
 
void FlattenMap (std::map< std::pair< int, int >, std::pair< double, double >> const &g4RecoBaseIDToPurityEfficiency, std::map< int, std::vector< std::pair< int, std::pair< double, double >>>> &g4IDToRecoBasePurityEfficiency, TH1D *purity, TH1D *efficiency, TH1D *purityEfficiency, TH2D *purityEfficiency2D)
 

Private Attributes

art::ServiceHandle
< cheat::BackTrackerService
const > 
fBT
 the back tracker service More...
 
art::ServiceHandle
< cheat::ParticleInventoryService
const > 
fPI
 the back tracker service More...
 
std::string fHitModuleLabel
 label for module making the hits More...
 
std::string fClusterModuleLabel
 label for module making the clusters More...
 
std::string fShowerModuleLabel
 label for module making the showers More...
 
std::string fTrackModuleLabel
 label for module making the tracks More...
 
std::string fVertexModuleLabel
 label for module making the vertices More...
 
std::string fEventModuleLabel
 label for module making the events More...
 
bool fCheckClusters
 should we check the reconstruction of clusters? More...
 
bool fCheckShowers
 should we check the reconstruction of showers? More...
 
bool fCheckTracks
 should we check the reconstruction of tracks? More...
 
bool fCheckVertices
 should we check the reconstruction of vertices? More...
 
bool fCheckEvents
 should we check the reconstruction of events? More...
 
TH1D * fClusterPurity
 histogram of cluster purity More...
 
TH1D * fClusterEfficiency
 histogram of cluster efficiency More...
 
TH1D * fClusterPurityEfficiency
 histogram of cluster efficiency times purity More...
 
TH2D * fClusterPurityEfficiency2D
 scatter histogram of cluster purity and efficiency More...
 
TH1D * fShowerPurity
 histogram of shower purity More...
 
TH1D * fShowerEfficiency
 histogram of shower efficiency More...
 
TH1D * fShowerPurityEfficiency
 histogram of shower efficiency times purity More...
 
TH2D * fShowerPurityEfficiency2D
 scatter histogram of cluster purity and efficiency More...
 
TH1D * fTrackPurity
 histogram of track purity More...
 
TH1D * fTrackEfficiency
 histogram of track efficiency More...
 
TH1D * fTrackPurityEfficiency
 histogram of track efficiency times purity More...
 
TH2D * fTrackPurityEfficiency2D
 scatter histogram of cluster purity and efficiency More...
 
TH1D * fVertexPurity
 histogram of vertex purity More...
 
TH1D * fVertexEfficiency
 histogram of vertex efficiency More...
 
TH1D * fVertexPurityEfficiency
 histogram of vertex efficiency times purity More...
 
TH1D * fEventPurity
 histogram of event purity More...
 
TH1D * fEventEfficiency
 histogram of event efficiency More...
 
TH1D * fEventPurityEfficiency
 histogram of event efficiency times purity More...
 
std::map< std::pair< int, int >
, std::pair< double, double > > 
fG4ClusterIDToPurityEfficiency
 
std::map< std::pair< int, int >
, std::pair< double, double > > 
fG4ShowerIDToPurityEfficiency
 
std::map< std::pair< int, int >
, std::pair< double, double > > 
fG4TrackIDToPurityEfficiency
 
TTree * fTree
 TTree to save efficiencies. More...
 
int frun
 run number More...
 
int fevent
 event number More...
 
int ftrackid
 geant track ID More...
 
int fpdg
 particle pdg code More...
 
double fpmom
 particle momentum More...
 
double fhiteff
 hitfinder efficiency for this particle More...
 
int fnclu
 number of clusters for this particle More...
 
std::vector< double > fclueff
 cluster efficiencies More...
 
std::vector< double > fclupur
 cluster purities More...
 
std::vector< int > fcluid
 cluster IDs More...
 
int fnshw
 number of showers for this particle More...
 
std::vector< double > fshweff
 shower efficiencies More...
 
std::vector< double > fshwpur
 shower purities More...
 
std::vector< int > fshwid
 shower IDs More...
 
int fntrk
 number of tracks for this particle More...
 
std::vector< double > ftrkeff
 track efficiencies More...
 
std::vector< double > ftrkpur
 track purities More...
 
std::vector< int > ftrkid
 track IDs More...
 

Detailed Description

Definition at line 50 of file RecoCheckAna_module.cc.

Constructor & Destructor Documentation

cheat::RecoCheckAna::RecoCheckAna ( fhicl::ParameterSet const &  p)
explicit

Definition at line 162 of file RecoCheckAna_module.cc.

163  : EDAnalyzer(p)
164  , fHitModuleLabel{p.get<std::string>("HitModuleLabel")}
165  , fClusterModuleLabel{p.get<std::string>("ClusterModuleLabel")}
166  , fShowerModuleLabel{p.get<std::string>("ShowerModuleLabel")}
167  , fTrackModuleLabel{p.get<std::string>("TrackModuleLabel")}
168  , fVertexModuleLabel{p.get<std::string>("VertexModuleLabel")}
169  , fEventModuleLabel{p.get<std::string>("EventModuleLabel")}
170  , fCheckClusters{p.get<bool>("CheckClusters")}
171  , fCheckShowers{p.get<bool>("CheckShowers")}
172  , fCheckTracks{p.get<bool>("CheckTracks")}
173  , fCheckVertices{p.get<bool>("CheckVertices")}
174  , fCheckEvents{p.get<bool>("CheckEvents")}
175 {}
bool fCheckVertices
should we check the reconstruction of vertices?
pdgs p
Definition: selectors.fcl:22
bool fCheckEvents
should we check the reconstruction of events?
bool fCheckClusters
should we check the reconstruction of clusters?
bool fCheckTracks
should we check the reconstruction of tracks?
std::string fTrackModuleLabel
label for module making the tracks
bool fCheckShowers
should we check the reconstruction of showers?
std::string fClusterModuleLabel
label for module making the clusters
std::string fShowerModuleLabel
label for module making the showers
std::string fEventModuleLabel
label for module making the events
std::string fVertexModuleLabel
label for module making the vertices
std::string fHitModuleLabel
label for module making the hits

Member Function Documentation

void cheat::RecoCheckAna::analyze ( art::Event const &  e)
overrideprivate

Definition at line 179 of file RecoCheckAna_module.cc.

180 {
181  // check that this is MC, stop if it isn't
182  if (e.isRealData()) {
183  mf::LogWarning("RecoVetter") << "attempting to run MC truth check on "
184  << "real data, bail";
185  return;
186  }
187 
188  // get all hits in the event to figure out how many there are
189  art::Handle<std::vector<recob::Hit>> hithdl;
190  e.getByLabel(fHitModuleLabel, hithdl);
191  std::vector<art::Ptr<recob::Hit>> allhits;
192  art::fill_ptr_vector(allhits, hithdl);
193 
194  // define variables to hold the reconstructed objects
195  art::Handle<std::vector<recob::Cluster>> clscol;
196  art::Handle<std::vector<recob::Track>> trkcol;
197  art::Handle<std::vector<recob::Shower>> shwcol;
198  art::Handle<std::vector<recob::Vertex>> vtxcol;
199  art::Handle<std::vector<recob::Event>> evtcol;
200 
201  if (fCheckClusters) {
202  e.getByLabel(fClusterModuleLabel, clscol);
203  if (!clscol.failedToGet()) this->CheckRecoClusters(e, fClusterModuleLabel, clscol, allhits);
204  }
205  if (fCheckTracks) {
206  e.getByLabel(fTrackModuleLabel, trkcol);
207  if (!trkcol.failedToGet()) this->CheckRecoTracks(e, fTrackModuleLabel, trkcol, allhits);
208  }
209  if (fCheckShowers) {
210  e.getByLabel(fShowerModuleLabel, shwcol);
211  if (!shwcol.failedToGet()) this->CheckRecoShowers(e, fShowerModuleLabel, shwcol, allhits);
212  }
213  if (fCheckVertices) {
214  e.getByLabel(fVertexModuleLabel, vtxcol);
215  if (!vtxcol.failedToGet()) this->CheckRecoVertices(e, fVertexModuleLabel, vtxcol, allhits);
216  }
217  if (fCheckEvents) {
218  e.getByLabel(fEventModuleLabel, evtcol);
219  if (!evtcol.failedToGet()) this->CheckRecoEvents(e, fEventModuleLabel, evtcol, allhits);
220  }
221 
222  frun = e.run();
223  fevent = e.id().event();
224 
225  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e);
226  this->FillResults(clockData, allhits);
227 
228  return;
229 }
bool fCheckVertices
should we check the reconstruction of vertices?
void CheckRecoEvents(art::Event const &evt, std::string const &label, art::Handle< std::vector< recob::Event >> const &evtcol, std::vector< art::Ptr< recob::Hit >> const &allhits)
bool fCheckEvents
should we check the reconstruction of events?
void CheckRecoTracks(art::Event const &evt, std::string const &label, art::Handle< std::vector< recob::Track >> const &tcol, std::vector< art::Ptr< recob::Hit >> const &allhits)
bool fCheckClusters
should we check the reconstruction of clusters?
bool fCheckTracks
should we check the reconstruction of tracks?
std::string fTrackModuleLabel
label for module making the tracks
bool fCheckShowers
should we check the reconstruction of showers?
void CheckRecoShowers(art::Event const &evt, std::string const &label, art::Handle< std::vector< recob::Shower >> const &scol, std::vector< art::Ptr< recob::Hit >> const &allhits)
void FillResults(detinfo::DetectorClocksData const &clockData, std::vector< art::Ptr< recob::Hit >> const &allhits)
void CheckRecoVertices(art::Event const &evt, std::string const &label, art::Handle< std::vector< recob::Vertex >> const &vtxcol, std::vector< art::Ptr< recob::Hit >> const &allhits)
do i e
std::string fClusterModuleLabel
label for module making the clusters
void CheckRecoClusters(art::Event const &evt, std::string const &label, art::Handle< std::vector< recob::Cluster >> const &clscol, std::vector< art::Ptr< recob::Hit >> const &allhits)
std::string fShowerModuleLabel
label for module making the showers
std::string fEventModuleLabel
label for module making the events
std::string fVertexModuleLabel
label for module making the vertices
std::string fHitModuleLabel
label for module making the hits
void cheat::RecoCheckAna::beginRun ( art::Run const &  r)
overrideprivate

Definition at line 233 of file RecoCheckAna_module.cc.

234 {
235  art::ServiceHandle<art::TFileService const> tfs;
236 
237  if (fCheckEvents) {
238  fEventPurity = tfs->make<TH1D>("eventPurity", ";Purity;Events", 100, 0., 1.1);
239  fEventEfficiency = tfs->make<TH1D>("eventEfficiency", ";Efficiency;Events", 100, 0., 1.1);
241  tfs->make<TH1D>("eventPurityEfficiency", ";purityEfficiency;Events", 110, 0., 1.1);
242  }
243  if (fCheckVertices) {
244  fVertexPurity = tfs->make<TH1D>("vertexPurity", ";Purity;Vertices", 100, 0., 1.1);
245  fVertexEfficiency = tfs->make<TH1D>("vertexEfficiency", ";Efficiency;Vertices", 100, 0., 1.1);
247  tfs->make<TH1D>("vertexPurityEfficiency", ";purityEfficiency;Vertex", 110, 0., 1.1);
248  }
249  if (fCheckTracks) {
250  fTrackPurity = tfs->make<TH1D>("trackPurity", ";Purity;Tracks", 100, 0., 1.1);
251  fTrackEfficiency = tfs->make<TH1D>("trackEfficiency", ";Efficiency;Tracks", 100, 0., 1.1);
253  tfs->make<TH1D>("trackPurityEfficiency", ";purityEfficiency;Tracks", 110, 0., 1.1);
255  tfs->make<TH2D>("trackPurityEfficiency2D", ";purity;efficiency", 110, 0., 1.1, 110, 0., 1.1);
256  }
257  if (fCheckShowers) {
258  fShowerPurity = tfs->make<TH1D>("showerPurity", ";Purity;Showers", 100, 0., 1.1);
259  fShowerEfficiency = tfs->make<TH1D>("showerEfficiency", ";Efficiency;Showers", 100, 0., 1.1);
261  tfs->make<TH1D>("showerPurityEfficiency", ";purityEfficiency;Showers", 110, 0., 1.1);
263  tfs->make<TH2D>("showerPurityEfficiency2D", ";purity;efficiency", 110, 0., 1.1, 110, 0., 1.1);
264  }
265  if (fCheckClusters) {
266  fClusterPurity = tfs->make<TH1D>("clusterPurity", ";Purity;Clusters", 110, 0., 1.1);
267  fClusterEfficiency = tfs->make<TH1D>("clusterEfficiency", ";Efficiency;Clusters", 110, 0., 1.1);
269  tfs->make<TH1D>("clusterPurityEfficiency", ";purityEfficiency;Clusters", 110, 0., 1.1);
270  fClusterPurityEfficiency2D = tfs->make<TH2D>(
271  "clusterPurityEfficiency2D", ";purity;efficiency", 110, 0., 1.1, 110, 0., 1.1);
272  }
273 
274  fTree = tfs->make<TTree>("cheatertree", "cheater tree");
275  fTree->Branch("run", &frun, "run/I");
276  fTree->Branch("event", &fevent, "event/I");
277  fTree->Branch("trackid", &ftrackid, "trackid/I");
278  fTree->Branch("pdg", &fpdg, "pdg/I");
279  fTree->Branch("pmom", &fpmom, "pmom/D");
280  fTree->Branch("hiteff", &fhiteff, "hiteff/D");
281  fTree->Branch("nclu", &fnclu, "nclu/I");
282  fTree->Branch("clueff", &fclueff);
283  fTree->Branch("clupur", &fclupur);
284  fTree->Branch("cluid", &fcluid);
285  fTree->Branch("nshw", &fnshw, "nshw/I");
286  fTree->Branch("shweff", &fshweff);
287  fTree->Branch("shwpur", &fshwpur);
288  fTree->Branch("shwid", &fshwid);
289  fTree->Branch("ntrk", &fntrk, "ntrk/I");
290  fTree->Branch("trkeff", &ftrkeff);
291  fTree->Branch("trkpur", &ftrkpur);
292  fTree->Branch("trkid", &ftrkid);
293 
294  return;
295 }
int fpdg
particle pdg code
int fnshw
number of showers for this particle
TH1D * fTrackPurityEfficiency
histogram of track efficiency times purity
bool fCheckVertices
should we check the reconstruction of vertices?
double fhiteff
hitfinder efficiency for this particle
TH1D * fClusterPurityEfficiency
histogram of cluster efficiency times purity
int fnclu
number of clusters for this particle
int fntrk
number of tracks for this particle
TH1D * fEventPurity
histogram of event purity
bool fCheckEvents
should we check the reconstruction of events?
TH2D * fTrackPurityEfficiency2D
scatter histogram of cluster purity and efficiency
TH1D * fEventEfficiency
histogram of event efficiency
TH1D * fVertexPurity
histogram of vertex purity
TH1D * fEventPurityEfficiency
histogram of event efficiency times purity
TH1D * fVertexPurityEfficiency
histogram of vertex efficiency times purity
std::vector< double > fclupur
cluster purities
std::vector< double > fshweff
shower efficiencies
bool fCheckClusters
should we check the reconstruction of clusters?
std::vector< double > fshwpur
shower purities
TTree * fTree
TTree to save efficiencies.
std::vector< int > fshwid
shower IDs
TH1D * fVertexEfficiency
histogram of vertex efficiency
std::vector< int > ftrkid
track IDs
std::vector< double > ftrkeff
track efficiencies
bool fCheckTracks
should we check the reconstruction of tracks?
std::vector< double > fclueff
cluster efficiencies
double fpmom
particle momentum
std::vector< int > fcluid
cluster IDs
std::vector< double > ftrkpur
track purities
bool fCheckShowers
should we check the reconstruction of showers?
int ftrackid
geant track ID
TH1D * fShowerPurityEfficiency
histogram of shower efficiency times purity
TH1D * fClusterPurity
histogram of cluster purity
TH1D * fClusterEfficiency
histogram of cluster efficiency
TH1D * fShowerPurity
histogram of shower purity
TH1D * fShowerEfficiency
histogram of shower efficiency
art::ServiceHandle< art::TFileService > tfs
TH1D * fTrackPurity
histogram of track purity
TH2D * fClusterPurityEfficiency2D
scatter histogram of cluster purity and efficiency
TH1D * fTrackEfficiency
histogram of track efficiency
TH2D * fShowerPurityEfficiency2D
scatter histogram of cluster purity and efficiency
void cheat::RecoCheckAna::CheckReco ( detinfo::DetectorClocksData const &  clockData,
int const &  colID,
std::vector< art::Ptr< recob::Hit >> const &  allhits,
std::vector< art::Ptr< recob::Hit >> const &  colHits,
std::map< std::pair< int, int >, std::pair< double, double >> &  g4RecoBaseIDToPurityEfficiency 
)
private

Definition at line 301 of file RecoCheckAna_module.cc.

307 {
308 
309  // grab the set of track IDs for these hits
310  std::set<int> trackIDs = fBT->GetSetOfTrackIds(clockData, colHits);
311 
312  geo::View_t view = colHits[0]->View();
313 
314  std::set<int>::iterator itr = trackIDs.begin();
315  while (itr != trackIDs.end()) {
316 
317  std::set<int> id;
318  id.insert(*itr);
319 
320  // use the cheat::BackTrackerService to find purity and efficiency for these
321  // hits
322  double purity = fBT->HitCollectionPurity(clockData, id, colHits);
323  double efficiency = fBT->HitCollectionEfficiency(clockData, id, colHits, allhits, view);
324 
325  // make the purity and efficiency pair
326  std::pair<double, double> pe(purity, efficiency);
327 
328  // make the pair of the RecoBase object id to the pair of purity/efficiency
329  std::pair<int, int> g4reco(*itr, colID);
330 
331  // insert idpe into the map
332  g4RecoBaseIDToPurityEfficiency[g4reco] = pe;
333 
334  itr++;
335 
336  } // end loop over eveIDs
337 
338  return;
339 }
art::ServiceHandle< cheat::BackTrackerService const > fBT
the back tracker service
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
void cheat::RecoCheckAna::CheckRecoClusters ( art::Event const &  evt,
std::string const &  label,
art::Handle< std::vector< recob::Cluster >> const &  clscol,
std::vector< art::Ptr< recob::Hit >> const &  allhits 
)
private

Definition at line 343 of file RecoCheckAna_module.cc.

347 {
348  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
349  art::FindManyP<recob::Hit> fmh(clscol, evt, label);
350 
351  for (size_t c = 0; c < clscol->size(); ++c) {
352 
353  // get the hits associated with this event
354  std::vector<art::Ptr<recob::Hit>> hits = fmh.at(c);
355 
356  this->CheckReco(clockData, clscol->at(c).ID(), allhits, hits, fG4ClusterIDToPurityEfficiency);
357 
358  } // end loop over clusters
359 
360  return;
361 }
void CheckReco(detinfo::DetectorClocksData const &clockData, int const &colID, std::vector< art::Ptr< recob::Hit >> const &allhits, std::vector< art::Ptr< recob::Hit >> const &colHits, std::map< std::pair< int, int >, std::pair< double, double >> &g4RecoBaseIDToPurityEfficiency)
std::map< std::pair< int, int >, std::pair< double, double > > fG4ClusterIDToPurityEfficiency
TCEvent evt
Definition: DataStructs.cxx:8
void cheat::RecoCheckAna::CheckRecoEvents ( art::Event const &  evt,
std::string const &  label,
art::Handle< std::vector< recob::Event >> const &  evtcol,
std::vector< art::Ptr< recob::Hit >> const &  allhits 
)
private
Todo:
need to divy it up in the case where there is more than 1 true interaction in a spill

Definition at line 473 of file RecoCheckAna_module.cc.

477 {
478  const sim::ParticleList& plist = fPI->ParticleList();
479 
480  // loop over all primaries in the plist and grab them and their daughters to put into
481  // the set of track ids to pass on to the back tracker
482  std::set<int> ids;
483  for (const auto& PartPair : plist) {
484  auto trackID = PartPair.first;
485  if (!plist.IsPrimary(trackID)) continue;
486  const simb::MCParticle& part = *(PartPair.second);
487  ids.insert(trackID);
488  for (int d = 0; d < part.NumberDaughters(); ++d)
489  ids.insert(part.Daughter(d));
490  } // end loop over primaries
491 
492  art::FindManyP<recob::Hit> fmh(evtcol, evt, label);
493 
494  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
495  for (size_t ev = 0; ev < evtcol->size(); ++ev) {
496 
497  // get the hits associated with this event
498  std::vector<art::Ptr<recob::Hit>> hits = fmh.at(ev);
499 
500  // use the cheat::BackTrackerService to find purity and efficiency for these
501  // hits
502  double purity = fBT->HitCollectionPurity(clockData, ids, hits);
503  double efficiency = fBT->HitCollectionEfficiency(clockData, ids, hits, allhits, geo::k3D);
504 
505  fEventPurity->Fill(purity);
506  fEventEfficiency->Fill(efficiency);
507  fEventPurityEfficiency->Fill(purity * efficiency);
508 
509  } // end loop over events
510 
511  return;
512 }
art::ServiceHandle< cheat::BackTrackerService const > fBT
the back tracker service
art::ServiceHandle< cheat::ParticleInventoryService const > fPI
the back tracker service
TH1D * fEventPurity
histogram of event purity
TH1D * fEventEfficiency
histogram of event efficiency
TH1D * fEventPurityEfficiency
histogram of event efficiency times purity
3-dimensional objects, potentially hits, clusters, prongs, etc.
Definition: geo_types.h:135
TCEvent evt
Definition: DataStructs.cxx:8
void cheat::RecoCheckAna::CheckRecoShowers ( art::Event const &  evt,
std::string const &  label,
art::Handle< std::vector< recob::Shower >> const &  scol,
std::vector< art::Ptr< recob::Hit >> const &  allhits 
)
private

Definition at line 387 of file RecoCheckAna_module.cc.

391 {
392  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
393  art::FindManyP<recob::Hit> fmh(scol, evt, label);
394 
395  for (size_t p = 0; p < scol->size(); ++p) {
396 
397  // get the hits associated with this event
398  std::vector<art::Ptr<recob::Hit>> hits = fmh.at(p);
399 
400  this->CheckReco(clockData, scol->at(p).ID(), allhits, hits, fG4ShowerIDToPurityEfficiency);
401 
402  } // end loop over events
403 
404  return;
405 }
pdgs p
Definition: selectors.fcl:22
void CheckReco(detinfo::DetectorClocksData const &clockData, int const &colID, std::vector< art::Ptr< recob::Hit >> const &allhits, std::vector< art::Ptr< recob::Hit >> const &colHits, std::map< std::pair< int, int >, std::pair< double, double >> &g4RecoBaseIDToPurityEfficiency)
std::map< std::pair< int, int >, std::pair< double, double > > fG4ShowerIDToPurityEfficiency
TCEvent evt
Definition: DataStructs.cxx:8
void cheat::RecoCheckAna::CheckRecoTracks ( art::Event const &  evt,
std::string const &  label,
art::Handle< std::vector< recob::Track >> const &  tcol,
std::vector< art::Ptr< recob::Hit >> const &  allhits 
)
private

Definition at line 365 of file RecoCheckAna_module.cc.

369 {
370  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
371  art::FindManyP<recob::Hit> fmh(tcol, evt, label);
372 
373  for (size_t p = 0; p < tcol->size(); ++p) {
374 
375  // get the hits associated with this event
376  std::vector<art::Ptr<recob::Hit>> hits = fmh.at(p);
377 
378  this->CheckReco(clockData, tcol->at(p).ID(), allhits, hits, fG4TrackIDToPurityEfficiency);
379 
380  } // end loop over tracks
381 
382  return;
383 }
pdgs p
Definition: selectors.fcl:22
void CheckReco(detinfo::DetectorClocksData const &clockData, int const &colID, std::vector< art::Ptr< recob::Hit >> const &allhits, std::vector< art::Ptr< recob::Hit >> const &colHits, std::map< std::pair< int, int >, std::pair< double, double >> &g4RecoBaseIDToPurityEfficiency)
std::map< std::pair< int, int >, std::pair< double, double > > fG4TrackIDToPurityEfficiency
TCEvent evt
Definition: DataStructs.cxx:8
void cheat::RecoCheckAna::CheckRecoVertices ( art::Event const &  evt,
std::string const &  label,
art::Handle< std::vector< recob::Vertex >> const &  vtxcol,
std::vector< art::Ptr< recob::Hit >> const &  allhits 
)
private

Definition at line 411 of file RecoCheckAna_module.cc.

415 {
416  const sim::ParticleList& plist = fPI->ParticleList();
417 
418  std::vector<std::set<int>> ids(1);
419  // loop over all primary particles and put their ids into the first set of the
420  // vector. add another set for each primary particle that also has daughters
421  // and put those daughters into the new set
422  // PartPair is a (track ID, particle pointer) pair
423  for (const auto& PartPair : plist) {
424  auto trackID = PartPair.first;
425  if (!plist.IsPrimary(trackID)) continue;
426  const simb::MCParticle& part = *(PartPair.second);
427  ids[0].insert(trackID);
428  if (part.NumberDaughters() > 0) {
429  std::set<int> dv;
430  for (int d = 0; d < part.NumberDaughters(); ++d)
431  dv.insert(part.Daughter(d));
432  ids.push_back(std::move(dv));
433  } // end if this primary particle has daughters
434  } // end loop over primaries
435 
436  art::FindManyP<recob::Hit> fmh(vtxcol, evt, label);
437 
438  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
439 
440  for (size_t v = 0; v < vtxcol->size(); ++v) {
441 
442  // get the hits associated with this event
443  std::vector<art::Ptr<recob::Hit>> hits = fmh.at(v);
444 
445  double maxPurity = -1.;
446  double maxEfficiency = -1.;
447 
448  for (size_t tv = 0; tv < ids.size(); ++tv) {
449 
450  // use the cheat::BackTrackerService to find purity and efficiency for
451  // these hits
452  double purity = fBT->HitCollectionPurity(clockData, ids[tv], hits);
453  double efficiency = fBT->HitCollectionEfficiency(clockData, ids[tv], hits, allhits, geo::k3D);
454 
455  if (purity > maxPurity) maxPurity = purity;
456  if (efficiency > maxEfficiency) maxEfficiency = efficiency;
457  }
458 
459  fVertexPurity->Fill(maxPurity);
460  fVertexEfficiency->Fill(maxEfficiency);
461  fVertexPurityEfficiency->Fill(maxPurity * maxEfficiency);
462 
463  } // end loop over vertices
464 
465  return;
466 }
art::ServiceHandle< cheat::BackTrackerService const > fBT
the back tracker service
art::ServiceHandle< cheat::ParticleInventoryService const > fPI
the back tracker service
TH1D * fVertexPurity
histogram of vertex purity
3-dimensional objects, potentially hits, clusters, prongs, etc.
Definition: geo_types.h:135
TH1D * fVertexPurityEfficiency
histogram of vertex efficiency times purity
TH1D * fVertexEfficiency
histogram of vertex efficiency
TCEvent evt
Definition: DataStructs.cxx:8
void cheat::RecoCheckAna::FillResults ( detinfo::DetectorClocksData const &  clockData,
std::vector< art::Ptr< recob::Hit >> const &  allhits 
)
private

Definition at line 576 of file RecoCheckAna_module.cc.

578 {
579  // map the g4 track id to energy deposited in a hit
580  std::map<int, double> g4IDToHitEnergy;
581  for (size_t h = 0; h < allhits.size(); ++h) {
582  const std::vector<sim::TrackIDE> hitTrackIDs = fBT->HitToTrackIDEs(clockData, allhits[h]);
583  for (size_t e = 0; e < hitTrackIDs.size(); ++e) {
584  g4IDToHitEnergy[hitTrackIDs[e].trackID] += hitTrackIDs[e].energy;
585  }
586  } // end loop over hits to fill map
587 
588  // flatten the G4RecoBaseIDToPurityEfficiency maps to have just the g4ID as
589  // the key and the rest of the information in vector form
590  std::map<int, std::vector<std::pair<int, std::pair<double, double>>>>
591  g4IDToClusterPurityEfficiency;
592  std::map<int, std::vector<std::pair<int, std::pair<double, double>>>>
593  g4IDToShowerPurityEfficiency;
594  std::map<int, std::vector<std::pair<int, std::pair<double, double>>>> g4IDToTrackPurityEfficiency;
595  std::map<int, std::vector<std::pair<int, std::pair<double, double>>>>::iterator g4peItr;
596 
597  if (fCheckClusters)
599  g4IDToClusterPurityEfficiency,
604  if (fCheckShowers)
606  g4IDToShowerPurityEfficiency,
611  if (fCheckTracks)
613  g4IDToTrackPurityEfficiency,
614  fTrackPurity,
618 
619  // fill the tree vectors
620  // get all the eveIDs from this event
621  std::set<int> trackIDs = fBT->GetSetOfTrackIds();
622  std::set<int>::const_iterator trackItr = trackIDs.begin();
623 
624  // loop over them
625  while (trackItr != trackIDs.end()) {
626 
627  const simb::MCParticle* part = fPI->TrackIdToParticle_P(*trackItr);
628 
629  ftrackid = std::abs(*trackItr);
630  fpdg = part->PdgCode();
631  fpmom = part->P();
632 
633  // figure out how much of the energy deposited from this particle is stored in hits
634  std::vector<const sim::IDE*> ides = fBT->TrackIdToSimIDEs_Ps(*trackItr);
635  double totalDep = 0.;
636  for (size_t i = 0; i < ides.size(); ++i)
637  totalDep += ides[i]->energy;
638 
639  if (totalDep > 0.) fhiteff = g4IDToHitEnergy[*trackItr] / totalDep;
640 
641  std::vector<std::pair<int, std::pair<double, double>>> clVec;
642  std::vector<std::pair<int, std::pair<double, double>>> shVec;
643  std::vector<std::pair<int, std::pair<double, double>>> trVec;
644 
645  if (g4IDToClusterPurityEfficiency.find(*trackItr) != g4IDToClusterPurityEfficiency.end())
646  clVec = g4IDToClusterPurityEfficiency.find(*trackItr)->second;
647 
648  if (g4IDToShowerPurityEfficiency.find(*trackItr) != g4IDToShowerPurityEfficiency.end())
649  shVec = g4IDToShowerPurityEfficiency.find(*trackItr)->second;
650 
651  if (g4IDToTrackPurityEfficiency.find(*trackItr) != g4IDToTrackPurityEfficiency.end())
652  trVec = g4IDToTrackPurityEfficiency.find(*trackItr)->second;
653 
654  fnclu = clVec.size();
655  fnshw = shVec.size();
656  fntrk = trVec.size();
657 
658  for (size_t c = 0; c < clVec.size(); ++c) {
659  fcluid.push_back(clVec[c].first);
660  fclupur.push_back(clVec[c].second.first);
661  fclueff.push_back(clVec[c].second.second);
662  }
663 
664  for (size_t s = 0; s < shVec.size(); ++s) {
665  fshwid.push_back(shVec[s].first);
666  fshwpur.push_back(shVec[s].second.first);
667  fshweff.push_back(shVec[s].second.second);
668  }
669 
670  for (size_t t = 0; t < trVec.size(); ++t) {
671  ftrkid.push_back(trVec[t].first);
672  ftrkpur.push_back(trVec[t].second.first);
673  ftrkeff.push_back(trVec[t].second.second);
674  }
675 
676  fTree->Fill();
677 
678  trackItr++;
679  }
680 
681  // clean up for the next event
682 
683  // clear the maps of G4 track id to efficiency and purity for
684  // various RecoBase objects
688 
689  // clear the vectors hooked up to the tree
690  fclueff.clear();
691  fclupur.clear();
692  fcluid.clear();
693  ftrkeff.clear();
694  ftrkpur.clear();
695  ftrkid.clear();
696  fshweff.clear();
697  fshwpur.clear();
698  fshwid.clear();
699 
700  return;
701 }
art::ServiceHandle< cheat::BackTrackerService const > fBT
the back tracker service
int fpdg
particle pdg code
int fnshw
number of showers for this particle
then if[["$THISISATEST"==1]]
Definition: neoSmazza.sh:95
TH1D * fTrackPurityEfficiency
histogram of track efficiency times purity
double fhiteff
hitfinder efficiency for this particle
TH1D * fClusterPurityEfficiency
histogram of cluster efficiency times purity
int fnclu
number of clusters for this particle
art::ServiceHandle< cheat::ParticleInventoryService const > fPI
the back tracker service
int fntrk
number of tracks for this particle
std::map< std::pair< int, int >, std::pair< double, double > > fG4ClusterIDToPurityEfficiency
TH2D * fTrackPurityEfficiency2D
scatter histogram of cluster purity and efficiency
while getopts h
T abs(T value)
std::vector< double > fclupur
cluster purities
std::vector< double > fshweff
shower efficiencies
bool fCheckClusters
should we check the reconstruction of clusters?
std::vector< double > fshwpur
shower purities
TTree * fTree
TTree to save efficiencies.
std::vector< int > fshwid
shower IDs
std::vector< int > ftrkid
track IDs
std::vector< double > ftrkeff
track efficiencies
bool fCheckTracks
should we check the reconstruction of tracks?
std::vector< double > fclueff
cluster efficiencies
double fpmom
particle momentum
void FlattenMap(std::map< std::pair< int, int >, std::pair< double, double >> const &g4RecoBaseIDToPurityEfficiency, std::map< int, std::vector< std::pair< int, std::pair< double, double >>>> &g4IDToRecoBasePurityEfficiency, TH1D *purity, TH1D *efficiency, TH1D *purityEfficiency, TH2D *purityEfficiency2D)
std::vector< int > fcluid
cluster IDs
std::vector< double > ftrkpur
track purities
bool fCheckShowers
should we check the reconstruction of showers?
std::map< std::pair< int, int >, std::pair< double, double > > fG4TrackIDToPurityEfficiency
int ftrackid
geant track ID
TH1D * fShowerPurityEfficiency
histogram of shower efficiency times purity
TH1D * fClusterPurity
histogram of cluster purity
std::map< std::pair< int, int >, std::pair< double, double > > fG4ShowerIDToPurityEfficiency
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
do i e
TH1D * fClusterEfficiency
histogram of cluster efficiency
TH1D * fShowerPurity
histogram of shower purity
TH1D * fShowerEfficiency
histogram of shower efficiency
TH1D * fTrackPurity
histogram of track purity
TH2D * fClusterPurityEfficiency2D
scatter histogram of cluster purity and efficiency
TH1D * fTrackEfficiency
histogram of track efficiency
TH2D * fShowerPurityEfficiency2D
scatter histogram of cluster purity and efficiency
void cheat::RecoCheckAna::FlattenMap ( std::map< std::pair< int, int >, std::pair< double, double >> const &  g4RecoBaseIDToPurityEfficiency,
std::map< int, std::vector< std::pair< int, std::pair< double, double >>>> &  g4IDToRecoBasePurityEfficiency,
TH1D *  purity,
TH1D *  efficiency,
TH1D *  purityEfficiency,
TH2D *  purityEfficiency2D 
)
private

Definition at line 516 of file RecoCheckAna_module.cc.

524 {
525 
526  std::map<std::pair<int, int>, std::pair<double, double>>::const_iterator rbItr =
527  g4RecoBaseIDToPurityEfficiency.begin();
528 
529  // map of key cluster ID to pair of purity, efficiency
530  std::map<int, std::pair<double, double>> recoBIDToPurityEfficiency;
531  std::map<int, std::pair<double, double>>::iterator rbpeItr;
532 
533  while (rbItr != g4RecoBaseIDToPurityEfficiency.end()) {
534 
535  // trackID, cluster ID
536  std::pair<int, int> g4cl = rbItr->first;
537  // purity, efficiency
538  std::pair<double, double> pe = rbItr->second;
539 
540  // add the efficiency and purity values for clusters corresponding
541  // to the current g4 id to the map
542  // pair of cluster id, pair of purity, efficiency
543  std::pair<int, std::pair<double, double>> clpe(g4cl.second, pe);
544  // g4IDToRecoBasePurityEfficiency is a map with key of trackID of a vector of clusterIDs of pairs of purity and efficiency
545  g4IDToRecoBasePurityEfficiency[g4cl.first].push_back(clpe);
546 
547  // now find the maximum purity to determine the purity and efficiency
548  // for this RecoBase object
549  rbpeItr = recoBIDToPurityEfficiency.find(g4cl.second);
550  if (rbpeItr != recoBIDToPurityEfficiency.end()) {
551  std::pair<double, double> curpe = rbpeItr->second;
552  if (pe.first > curpe.first) recoBIDToPurityEfficiency[g4cl.second] = pe;
553  }
554  else
555  recoBIDToPurityEfficiency[g4cl.second] = pe;
556 
557  rbItr++;
558  }
559 
560  rbpeItr = recoBIDToPurityEfficiency.begin();
561 
562  // now fill the histograms,
563  while (rbpeItr != recoBIDToPurityEfficiency.end()) {
564  purity->Fill(rbpeItr->second.first);
565  efficiency->Fill(rbpeItr->second.second);
566  purityEfficiency->Fill(rbpeItr->second.first * rbpeItr->second.second);
567  purityEfficiency2D->Fill(rbpeItr->second.first, rbpeItr->second.second);
568  rbpeItr++;
569  }
570 
571  return;
572 }

Member Data Documentation

art::ServiceHandle<cheat::BackTrackerService const> cheat::RecoCheckAna::fBT
private

the back tracker service

Definition at line 98 of file RecoCheckAna_module.cc.

bool cheat::RecoCheckAna::fCheckClusters
private

should we check the reconstruction of clusters?

Definition at line 108 of file RecoCheckAna_module.cc.

bool cheat::RecoCheckAna::fCheckEvents
private

should we check the reconstruction of events?

Definition at line 112 of file RecoCheckAna_module.cc.

bool cheat::RecoCheckAna::fCheckShowers
private

should we check the reconstruction of showers?

Definition at line 109 of file RecoCheckAna_module.cc.

bool cheat::RecoCheckAna::fCheckTracks
private

should we check the reconstruction of tracks?

Definition at line 110 of file RecoCheckAna_module.cc.

bool cheat::RecoCheckAna::fCheckVertices
private

should we check the reconstruction of vertices?

Definition at line 111 of file RecoCheckAna_module.cc.

std::vector<double> cheat::RecoCheckAna::fclueff
private

cluster efficiencies

Definition at line 148 of file RecoCheckAna_module.cc.

std::vector<int> cheat::RecoCheckAna::fcluid
private

cluster IDs

Definition at line 150 of file RecoCheckAna_module.cc.

std::vector<double> cheat::RecoCheckAna::fclupur
private

cluster purities

Definition at line 149 of file RecoCheckAna_module.cc.

TH1D* cheat::RecoCheckAna::fClusterEfficiency
private

histogram of cluster efficiency

Definition at line 115 of file RecoCheckAna_module.cc.

std::string cheat::RecoCheckAna::fClusterModuleLabel
private

label for module making the clusters

Definition at line 102 of file RecoCheckAna_module.cc.

TH1D* cheat::RecoCheckAna::fClusterPurity
private

histogram of cluster purity

Definition at line 114 of file RecoCheckAna_module.cc.

TH1D* cheat::RecoCheckAna::fClusterPurityEfficiency
private

histogram of cluster efficiency times purity

Definition at line 116 of file RecoCheckAna_module.cc.

TH2D* cheat::RecoCheckAna::fClusterPurityEfficiency2D
private

scatter histogram of cluster purity and efficiency

Definition at line 117 of file RecoCheckAna_module.cc.

int cheat::RecoCheckAna::fevent
private

event number

Definition at line 142 of file RecoCheckAna_module.cc.

TH1D* cheat::RecoCheckAna::fEventEfficiency
private

histogram of event efficiency

Definition at line 130 of file RecoCheckAna_module.cc.

std::string cheat::RecoCheckAna::fEventModuleLabel
private

label for module making the events

Definition at line 106 of file RecoCheckAna_module.cc.

TH1D* cheat::RecoCheckAna::fEventPurity
private

histogram of event purity

Definition at line 129 of file RecoCheckAna_module.cc.

TH1D* cheat::RecoCheckAna::fEventPurityEfficiency
private

histogram of event efficiency times purity

Definition at line 131 of file RecoCheckAna_module.cc.

std::map<std::pair<int, int>, std::pair<double, double> > cheat::RecoCheckAna::fG4ClusterIDToPurityEfficiency
private

Definition at line 136 of file RecoCheckAna_module.cc.

std::map<std::pair<int, int>, std::pair<double, double> > cheat::RecoCheckAna::fG4ShowerIDToPurityEfficiency
private

Definition at line 137 of file RecoCheckAna_module.cc.

std::map<std::pair<int, int>, std::pair<double, double> > cheat::RecoCheckAna::fG4TrackIDToPurityEfficiency
private

Definition at line 138 of file RecoCheckAna_module.cc.

double cheat::RecoCheckAna::fhiteff
private

hitfinder efficiency for this particle

Definition at line 146 of file RecoCheckAna_module.cc.

std::string cheat::RecoCheckAna::fHitModuleLabel
private

label for module making the hits

Definition at line 101 of file RecoCheckAna_module.cc.

int cheat::RecoCheckAna::fnclu
private

number of clusters for this particle

Definition at line 147 of file RecoCheckAna_module.cc.

int cheat::RecoCheckAna::fnshw
private

number of showers for this particle

Definition at line 151 of file RecoCheckAna_module.cc.

int cheat::RecoCheckAna::fntrk
private

number of tracks for this particle

Definition at line 155 of file RecoCheckAna_module.cc.

int cheat::RecoCheckAna::fpdg
private

particle pdg code

Definition at line 144 of file RecoCheckAna_module.cc.

art::ServiceHandle<cheat::ParticleInventoryService const> cheat::RecoCheckAna::fPI
private

the back tracker service

Definition at line 99 of file RecoCheckAna_module.cc.

double cheat::RecoCheckAna::fpmom
private

particle momentum

Definition at line 145 of file RecoCheckAna_module.cc.

int cheat::RecoCheckAna::frun
private

run number

Definition at line 141 of file RecoCheckAna_module.cc.

TH1D* cheat::RecoCheckAna::fShowerEfficiency
private

histogram of shower efficiency

Definition at line 119 of file RecoCheckAna_module.cc.

std::string cheat::RecoCheckAna::fShowerModuleLabel
private

label for module making the showers

Definition at line 103 of file RecoCheckAna_module.cc.

TH1D* cheat::RecoCheckAna::fShowerPurity
private

histogram of shower purity

Definition at line 118 of file RecoCheckAna_module.cc.

TH1D* cheat::RecoCheckAna::fShowerPurityEfficiency
private

histogram of shower efficiency times purity

Definition at line 120 of file RecoCheckAna_module.cc.

TH2D* cheat::RecoCheckAna::fShowerPurityEfficiency2D
private

scatter histogram of cluster purity and efficiency

Definition at line 121 of file RecoCheckAna_module.cc.

std::vector<double> cheat::RecoCheckAna::fshweff
private

shower efficiencies

Definition at line 152 of file RecoCheckAna_module.cc.

std::vector<int> cheat::RecoCheckAna::fshwid
private

shower IDs

Definition at line 154 of file RecoCheckAna_module.cc.

std::vector<double> cheat::RecoCheckAna::fshwpur
private

shower purities

Definition at line 153 of file RecoCheckAna_module.cc.

TH1D* cheat::RecoCheckAna::fTrackEfficiency
private

histogram of track efficiency

Definition at line 123 of file RecoCheckAna_module.cc.

int cheat::RecoCheckAna::ftrackid
private

geant track ID

Definition at line 143 of file RecoCheckAna_module.cc.

std::string cheat::RecoCheckAna::fTrackModuleLabel
private

label for module making the tracks

Definition at line 104 of file RecoCheckAna_module.cc.

TH1D* cheat::RecoCheckAna::fTrackPurity
private

histogram of track purity

Definition at line 122 of file RecoCheckAna_module.cc.

TH1D* cheat::RecoCheckAna::fTrackPurityEfficiency
private

histogram of track efficiency times purity

Definition at line 124 of file RecoCheckAna_module.cc.

TH2D* cheat::RecoCheckAna::fTrackPurityEfficiency2D
private

scatter histogram of cluster purity and efficiency

Definition at line 125 of file RecoCheckAna_module.cc.

TTree* cheat::RecoCheckAna::fTree
private

TTree to save efficiencies.

Definition at line 140 of file RecoCheckAna_module.cc.

std::vector<double> cheat::RecoCheckAna::ftrkeff
private

track efficiencies

Definition at line 156 of file RecoCheckAna_module.cc.

std::vector<int> cheat::RecoCheckAna::ftrkid
private

track IDs

Definition at line 158 of file RecoCheckAna_module.cc.

std::vector<double> cheat::RecoCheckAna::ftrkpur
private

track purities

Definition at line 157 of file RecoCheckAna_module.cc.

TH1D* cheat::RecoCheckAna::fVertexEfficiency
private

histogram of vertex efficiency

Definition at line 127 of file RecoCheckAna_module.cc.

std::string cheat::RecoCheckAna::fVertexModuleLabel
private

label for module making the vertices

Definition at line 105 of file RecoCheckAna_module.cc.

TH1D* cheat::RecoCheckAna::fVertexPurity
private

histogram of vertex purity

Definition at line 126 of file RecoCheckAna_module.cc.

TH1D* cheat::RecoCheckAna::fVertexPurityEfficiency
private

histogram of vertex efficiency times purity

Definition at line 128 of file RecoCheckAna_module.cc.


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