LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
RecoCheckAna_module.cc
Go to the documentation of this file.
1 #ifndef RecoCheckAna_h
2 #define RecoCheckAna_h
3 // Class: RecoCheckAna
5 // Module Type: analyzer
6 // File: RecoCheckAna.h
7 //
8 // Generated at Fri Jul 15 09:54:26 2011 by Brian Rebel using artmod
9 // from art v0_07_04.
11 
12 #include <utility> // std::move()
13 
14 #include "TH1.h"
15 #include "TH2.h"
16 #include "TTree.h"
17 
22 
34 
35 namespace cheat {
36  class RecoCheckAna;
37 }
38 
39 class TH1D;
40 class TTree;
41 
43 public:
44  explicit RecoCheckAna(fhicl::ParameterSet const &p);
45  virtual ~RecoCheckAna();
46 
47  virtual void analyze(art::Event const &e);
48 
49  virtual void reconfigure(fhicl::ParameterSet const & p);
50  virtual void beginRun(art::Run const &r);
51 
52 
53 
54 private:
55 
56  void CheckReco (int const& colID,
57  std::vector< art::Ptr<recob::Hit> > const& allhits,
58  std::vector< art::Ptr<recob::Hit> > const& colHits,
59  std::map<std::pair<int, int>, std::pair<double, double> >& g4RecoBaseIDToPurityEfficiency);
60  void CheckRecoClusters(art::Event const& evt,
61  std::string const& label,
62  art::Handle< std::vector<recob::Cluster> > const& clscol,
63  std::vector< art::Ptr<recob::Hit> > const& allhits);
64  void CheckRecoTracks (art::Event const& evt,
65  std::string const& label,
66  art::Handle< std::vector<recob::Track> > const& tcol,
67  std::vector< art::Ptr<recob::Hit> > const& allhits);
68  void CheckRecoShowers (art::Event const& evt,
69  std::string const& label,
70  art::Handle< std::vector<recob::Shower> > const& scol,
71  std::vector< art::Ptr<recob::Hit> > const& allhits);
72  void CheckRecoVertices(art::Event const& evt,
73  std::string const& label,
74  art::Handle< std::vector<recob::Vertex> > const& vtxcol,
75  std::vector< art::Ptr<recob::Hit> > const& allhits);
76  void CheckRecoEvents (art::Event const& evt,
77  std::string const& label,
78  art::Handle< std::vector<recob::Event> > const& evtcol,
79  std::vector< art::Ptr<recob::Hit> > const& allhits);
80  // method to fill the histograms and TTree
81  void FillResults(std::vector< art::Ptr<recob::Hit> > const& allhits);
82 
83  // helper method to the above for clusters, showers and tracks
84  void FlattenMap(std::map<std::pair<int, int>, std::pair<double, double> > const& g4RecoBaseIDToPurityEfficiency,
85  std::map<int, std::vector<std::pair<int, std::pair<double, double> > > >& g4IDToRecoBasePurityEfficiency,
86  TH1D* purity,
87  TH1D* efficiency,
88  TH1D* purityEfficiency,
89  TH2D* purityEfficiency2D);
90 
93 
94  std::string fHitModuleLabel;
95  std::string fClusterModuleLabel;
96  std::string fShowerModuleLabel;
97  std::string fTrackModuleLabel;
98  std::string fVertexModuleLabel;
99  std::string fEventModuleLabel;
100 
106 
115  TH1D* fTrackPurity;
122  TH1D* fEventPurity;
125 
126  // The following maps have a pair of the G4 track id and RecoBase object
127  // id as the key and then the purity and efficiency (in that order) of the RecoBase object
128  // as the value
129  std::map< std::pair<int, int>, std::pair<double, double> > fG4ClusterIDToPurityEfficiency;
130  std::map< std::pair<int, int>, std::pair<double, double> > fG4ShowerIDToPurityEfficiency;
131  std::map< std::pair<int, int>, std::pair<double, double> > fG4TrackIDToPurityEfficiency;
132 
133  TTree* fTree;
134  int frun;
135  int fevent;
136  int ftrackid;
137  int fpdg;
138  double fpmom;
139  double fhiteff;
140  int fnclu;
141  std::vector<double> fclueff;
142  std::vector<double> fclupur;
143  std::vector<int> fcluid;
144  int fnshw;
145  std::vector<double> fshweff;
146  std::vector<double> fshwpur;
147  std::vector<int> fshwid;
148  int fntrk;
149  std::vector<double> ftrkeff;
150  std::vector<double> ftrkpur;
151  std::vector<int> ftrkid;
152 
153 };
154 
155 //-------------------------------------------------------------------
157  : EDAnalyzer(p)
158 {
159  this->reconfigure(p);
160 }
161 
162 //-------------------------------------------------------------------
164 {
165  // Clean up dynamic memory and other resources here.
166 }
167 
168 //-------------------------------------------------------------------
170 {
171  // check that this is MC, stop if it isn't
172  if(e.isRealData()){
173  mf::LogWarning("RecoVetter") << "attempting to run MC truth check on "
174  << "real data, bail";
175  return;
176  }
177 
178  // get all hits in the event to figure out how many there are
180  e.getByLabel(fHitModuleLabel, hithdl);
181  std::vector< art::Ptr<recob::Hit> > allhits;
182  art::fill_ptr_vector(allhits, hithdl);
183 
184  // define variables to hold the reconstructed objects
190 
191  if(fCheckClusters){
192  e.getByLabel(fClusterModuleLabel, clscol);
193  if( !clscol.failedToGet() ) this->CheckRecoClusters(e, fClusterModuleLabel, clscol, allhits);
194  }
195  if(fCheckTracks){
196  e.getByLabel(fTrackModuleLabel, trkcol);
197  if( !trkcol.failedToGet() ) this->CheckRecoTracks(e, fTrackModuleLabel, trkcol, allhits);
198  }
199  if(fCheckShowers){
200  e.getByLabel(fShowerModuleLabel, shwcol);
201  if( !shwcol.failedToGet() ) this->CheckRecoShowers(e, fShowerModuleLabel, shwcol, allhits);
202  }
203  if(fCheckVertices){
204  e.getByLabel(fVertexModuleLabel, vtxcol);
205  if( !vtxcol.failedToGet() ) this->CheckRecoVertices(e, fVertexModuleLabel, vtxcol, allhits);
206  }
207  if(fCheckEvents){
208  e.getByLabel(fEventModuleLabel, evtcol);
209  if( !evtcol.failedToGet() ) this->CheckRecoEvents(e, fEventModuleLabel, evtcol, allhits);
210  }
211 
212  frun = e.run();
213  fevent = e.id().event();
214 
215  this->FillResults(allhits);
216 
217  return;
218 
219 }
220 
221 //-------------------------------------------------------------------
223 {
224  fHitModuleLabel = p.get< std::string >("HitModuleLabel");
225  fClusterModuleLabel = p.get< std::string >("ClusterModuleLabel");
226  fShowerModuleLabel = p.get< std::string >("ShowerModuleLabel" );
227  fTrackModuleLabel = p.get< std::string >("TrackModuleLabel" );
228  fVertexModuleLabel = p.get< std::string >("VertexModuleLabel" );
229  fEventModuleLabel = p.get< std::string >("EventModuleLabel" );
230 
231  fCheckClusters = p.get< bool >("CheckClusters");
232  fCheckShowers = p.get< bool >("CheckShowers" );
233  fCheckTracks = p.get< bool >("CheckTracks" );
234  fCheckVertices = p.get< bool >("CheckVertices");
235  fCheckEvents = p.get< bool >("CheckEvents" );
236 }
237 
238 //-------------------------------------------------------------------
240 {
242 
243  if(fCheckEvents){
244  fEventPurity = tfs->make<TH1D>("eventPurity", ";Purity;Events", 100, 0., 1.1);
245  fEventEfficiency = tfs->make<TH1D>("eventEfficiency", ";Efficiency;Events", 100, 0., 1.1);
246  fEventPurityEfficiency = tfs->make<TH1D>("eventPurityEfficiency", ";purityEfficiency;Events", 110, 0., 1.1);
247  }
248  if(fCheckVertices){
249  fVertexPurity = tfs->make<TH1D>("vertexPurity", ";Purity;Vertices", 100, 0., 1.1);
250  fVertexEfficiency = tfs->make<TH1D>("vertexEfficiency", ";Efficiency;Vertices", 100, 0., 1.1);
251  fVertexPurityEfficiency = tfs->make<TH1D>("vertexPurityEfficiency", ";purityEfficiency;Vertex", 110, 0., 1.1);
252  }
253  if(fCheckTracks){
254  fTrackPurity = tfs->make<TH1D>("trackPurity", ";Purity;Tracks", 100, 0., 1.1);
255  fTrackEfficiency = tfs->make<TH1D>("trackEfficiency", ";Efficiency;Tracks", 100, 0., 1.1);
256  fTrackPurityEfficiency = tfs->make<TH1D>("trackPurityEfficiency", ";purityEfficiency;Tracks", 110, 0., 1.1);
257  fTrackPurityEfficiency2D = tfs->make<TH2D>("trackPurityEfficiency2D", ";purity;efficiency", 110, 0., 1.1, 110, 0., 1.1);
258  }
259  if(fCheckShowers){
260  fShowerPurity = tfs->make<TH1D>("showerPurity", ";Purity;Showers", 100, 0., 1.1);
261  fShowerEfficiency = tfs->make<TH1D>("showerEfficiency", ";Efficiency;Showers", 100, 0., 1.1);
262  fShowerPurityEfficiency = tfs->make<TH1D>("showerPurityEfficiency", ";purityEfficiency;Showers", 110, 0., 1.1);
263  fShowerPurityEfficiency2D= 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);
268  fClusterPurityEfficiency = tfs->make<TH1D>("clusterPurityEfficiency", ";purityEfficiency;Clusters", 110, 0., 1.1);
269  fClusterPurityEfficiency2D = tfs->make<TH2D>("clusterPurityEfficiency2D", ";purity;efficiency", 110, 0., 1.1, 110, 0., 1.1);
270  }
271 
272  fTree = tfs->make<TTree>("cheatertree","cheater tree");
273  fTree->Branch("run", &frun, "run/I" );
274  fTree->Branch("event", &fevent, "event/I" );
275  fTree->Branch("trackid", &ftrackid, "trackid/I");
276  fTree->Branch("pdg", &fpdg, "pdg/I" );
277  fTree->Branch("pmom", &fpmom, "pmom/D" );
278  fTree->Branch("hiteff", &fhiteff, "hiteff/D" );
279  fTree->Branch("nclu", &fnclu, "nclu/I" );
280  fTree->Branch("clueff", &fclueff );
281  fTree->Branch("clupur", &fclupur );
282  fTree->Branch("cluid", &fcluid );
283  fTree->Branch("nshw", &fnshw, "nshw/I" );
284  fTree->Branch("shweff", &fshweff );
285  fTree->Branch("shwpur", &fshwpur );
286  fTree->Branch("shwid", &fshwid );
287  fTree->Branch("ntrk", &fntrk, "ntrk/I" );
288  fTree->Branch("trkeff", &ftrkeff );
289  fTree->Branch("trkpur", &ftrkpur );
290  fTree->Branch("trkid", &ftrkid );
291 
292  return;
293 }
294 
295 //-------------------------------------------------------------------
296 // colID is the ID of the RecoBase object and colHits are the recob::Hits
297 // associated with it
298 void cheat::RecoCheckAna::CheckReco(int const& colID,
299  std::vector< art::Ptr<recob::Hit> > const& allhits,
300  std::vector< art::Ptr<recob::Hit> > const& colHits,
301  std::map<std::pair<int, int>, std::pair<double, double> >& g4RecoBaseIDToPurityEfficiency)
302 {
303 
304  // grab the set of track IDs for these hits
305  std::set<int> trackIDs = fBT->GetSetOfTrackIds(colHits);
306 
307  geo::View_t view = colHits[0]->View();
308 
309  std::set<int>::iterator itr = trackIDs.begin();
310  while( itr != trackIDs.end() ){
311 
312  //std::cout << "*itr: " << *itr << std::endl;
313 
314  std::set<int> id;
315  id.insert(*itr);
316 
317  // use the cheat::BackTrackerService to find purity and efficiency for these hits
318  double purity = fBT->HitCollectionPurity(id, colHits);
319  double efficiency = fBT->HitCollectionEfficiency(id, colHits, allhits, view);
320 
321  // make the purity and efficiency pair
322  std::pair<double, double> pe(purity, efficiency);
323 
324  // make the pair of the RecoBase object id to the pair of purity/efficiency
325  std::pair<int, int> g4reco(*itr, colID);
326 
327  // insert idpe into the map
328  g4RecoBaseIDToPurityEfficiency[g4reco] = pe;
329 
330  itr++;
331 
332  } // end loop over eveIDs
333 
334  return;
335 }
336 
337 //-------------------------------------------------------------------
339  std::string const& label,
340  art::Handle< std::vector<recob::Cluster> > const& clscol,
341  std::vector< art::Ptr<recob::Hit> > const& allhits)
342 {
343 
344  art::FindManyP<recob::Hit> fmh(clscol, evt, label);
345 
346  for(size_t c = 0; c < clscol->size(); ++c){
347 
348  // get the hits associated with this event
349  std::vector< art::Ptr< recob::Hit > > hits = fmh.at(c);
350 
351  this->CheckReco(clscol->at(c).ID(), allhits, hits, fG4ClusterIDToPurityEfficiency);
352 
353  }// end loop over clusters
354 
355  return;
356 }
357 
358 //-------------------------------------------------------------------
360  std::string const& label,
361  art::Handle< std::vector<recob::Track> > const& tcol,
362  std::vector< art::Ptr<recob::Hit> > const& allhits)
363 {
364 
365  art::FindManyP<recob::Hit> fmh(tcol, evt, label);
366 
367  for(size_t p = 0; p < tcol->size(); ++p){
368 
369  // get the hits associated with this event
370  std::vector< art::Ptr< recob::Hit > > hits = fmh.at(p);
371 
372  this->CheckReco(tcol->at(p).ID(), allhits, hits, fG4TrackIDToPurityEfficiency);
373 
374  }// end loop over tracks
375 
376  return;
377 }
378 
379 //-------------------------------------------------------------------
381  std::string const& label,
382  art::Handle< std::vector<recob::Shower> > const& scol,
383  std::vector< art::Ptr<recob::Hit> > const& allhits)
384 {
385 
386  art::FindManyP<recob::Hit> fmh(scol, evt, label);
387 
388  for(size_t p = 0; p < scol->size(); ++p){
389 
390  // get the hits associated with this event
391  std::vector< art::Ptr< recob::Hit > > hits = fmh.at(p);
392 
393  this->CheckReco(scol->at(p).ID(), allhits, hits, fG4ShowerIDToPurityEfficiency);
394 
395  }// end loop over events
396 
397  return;
398 }
399 
400 //-------------------------------------------------------------------
401 //a true vertex will either consist of primary particles originating from
402 //the interaction vertex, or a primary particle decaying to make daughters
404  std::string const& label,
405  art::Handle< std::vector<recob::Vertex> > const& vtxcol,
406  std::vector< art::Ptr<recob::Hit> > const& allhits)
407 {
408  const sim::ParticleList& plist = fPI->ParticleList();
409 
410  std::vector< std::set<int> > ids(1);
411  // loop over all primary particles and put their ids into the first set of the
412  // vector. add another set for each primary particle that also has daughters
413  // and put those daughters into the new set
414  // PartPair is a (track ID, particle pointer) pair
415  for (const auto& PartPair: plist) {
416  auto trackID = PartPair.first;
417  if (!plist.IsPrimary(trackID)) continue;
418  const simb::MCParticle& part = *(PartPair.second);
419  ids[0].insert(trackID);
420  if(part.NumberDaughters() > 0){
421  std::set<int> dv;
422  for(int d = 0; d < part.NumberDaughters(); ++d)
423  dv.insert(part.Daughter(d));
424  ids.push_back(std::move(dv));
425  }//end if this primary particle has daughters
426  }// end loop over primaries
427 
428  art::FindManyP<recob::Hit> fmh(vtxcol, evt, label);
429 
430  for(size_t v = 0; v < vtxcol->size(); ++v){
431 
432  // get the hits associated with this event
433  std::vector< art::Ptr< recob::Hit > > hits = fmh.at(v);
434 
435  double maxPurity = -1.;
436  double maxEfficiency = -1.;
437 
438  for(size_t tv = 0; tv < ids.size(); ++tv){
439 
440  // use the cheat::BackTrackerService to find purity and efficiency for these hits
441  double purity = fBT->HitCollectionPurity(ids[tv], hits);
442  double efficiency = fBT->HitCollectionEfficiency(ids[tv], hits, allhits, geo::k3D);
443 
444  if(purity > maxPurity ) maxPurity = purity;
445  if(efficiency > maxEfficiency) maxEfficiency = efficiency;
446  }
447 
448  fVertexPurity ->Fill(maxPurity);
449  fVertexEfficiency->Fill(maxEfficiency);
450  fVertexPurityEfficiency->Fill(maxPurity*maxEfficiency);
451 
452  }// end loop over vertices
453 
454  return;
455 }
456 
457 //-------------------------------------------------------------------
458 // in this method one should loop over the primary particles from a given
459 // MCTruth collection
462  std::string const& label,
463  art::Handle< std::vector<recob::Event> > const& evtcol,
464  std::vector< art::Ptr<recob::Hit> > const& allhits)
465 {
466  const sim::ParticleList& plist = fPI->ParticleList();
467 
468  // loop over all primaries in the plist and grab them and their daughters to put into
469  // the set of track ids to pass on to the back tracker
470  std::set<int> ids;
471  for (const auto& PartPair: plist) {
472  auto trackID = PartPair.first;
473  if (!plist.IsPrimary(trackID)) continue;
474  const simb::MCParticle& part = *(PartPair.second);
475  ids.insert(trackID);
476  for(int d = 0; d < part.NumberDaughters(); ++d)
477  ids.insert(part.Daughter(d));
478  }// end loop over primaries
479 
480 
481 
482  art::FindManyP<recob::Hit> fmh(evtcol, evt, label);
483 
484  for(size_t ev = 0; ev < evtcol->size(); ++ev){
485 
486  // get the hits associated with this event
487  std::vector< art::Ptr< recob::Hit > > hits = fmh.at(ev);
488 
489  // use the cheat::BackTrackerService to find purity and efficiency for these hits
490  double purity = fBT->HitCollectionPurity(ids, hits);
491  double efficiency = fBT->HitCollectionEfficiency(ids, hits, allhits, geo::k3D);
492 
493  fEventPurity ->Fill(purity);
494  fEventEfficiency->Fill(efficiency);
495  fEventPurityEfficiency->Fill(purity*efficiency);
496 
497  }// end loop over events
498 
499  return;
500 }
501 
502 //-------------------------------------------------------------------
503 void cheat::RecoCheckAna::FlattenMap(std::map<std::pair<int, int>, std::pair<double, double> > const& g4RecoBaseIDToPurityEfficiency,
504  std::map<int, std::vector<std::pair<int, std::pair<double, double> > > >& g4IDToRecoBasePurityEfficiency,
505  TH1D* purity,
506  TH1D* efficiency,
507  TH1D* purityEfficiency,
508  TH2D* purityEfficiency2D)
509 {
510 
511  std::map<std::pair<int, int>, std::pair<double, double> >::const_iterator rbItr = g4RecoBaseIDToPurityEfficiency.begin();
512 
513  // map of key cluster ID to pair of purity, efficiency
514  std::map<int, std::pair<double, double> > recoBIDToPurityEfficiency;
515  std::map<int, std::pair<double, double> >::iterator rbpeItr;
516 
517  while( rbItr != g4RecoBaseIDToPurityEfficiency.end() ){
518 
519 
520  // trackID, cluster ID
521  std::pair<int, int> g4cl = rbItr->first;
522  // purity, efficiency
523  std::pair<double, double> pe = rbItr->second;
524 
525  // add the efficiency and purity values for clusters corresponding
526  // to the current g4 id to the map
527  // pair of cluster id, pair of purity, efficiency
528  std::pair<int, std::pair<double, double> > clpe(g4cl.second, pe);
529  // g4IDToRecoBasePurityEfficiency is a map with key of trackID of a vector of clusterIDs of pairs of purity and efficiency
530  g4IDToRecoBasePurityEfficiency[g4cl.first].push_back(clpe);
531 
532  // now find the maximum purity to determine the purity and efficiency
533  // for this RecoBase object
534  rbpeItr = recoBIDToPurityEfficiency.find(g4cl.second);
535  if( rbpeItr != recoBIDToPurityEfficiency.end() ){
536  std::pair<double, double> curpe = rbpeItr->second;
537  if(pe.first > curpe.first) recoBIDToPurityEfficiency[g4cl.second] = pe;
538  }
539  else
540  recoBIDToPurityEfficiency[g4cl.second] = pe;
541 
542  rbItr++;
543  }
544 
545  rbpeItr = recoBIDToPurityEfficiency.begin();
546 
547  // now fill the histograms,
548  while(rbpeItr != recoBIDToPurityEfficiency.end() ){
549  purity ->Fill(rbpeItr->second.first);
550  efficiency->Fill(rbpeItr->second.second);
551  purityEfficiency->Fill(rbpeItr->second.first*rbpeItr->second.second);
552  purityEfficiency2D->Fill(rbpeItr->second.first,rbpeItr->second.second);
553  rbpeItr++;
554  }
555 
556  return;
557 }
558 
559 //-------------------------------------------------------------------
561 {
562  // map the g4 track id to energy deposited in a hit
563  std::map<int, double> g4IDToHitEnergy;
564  for(size_t h = 0; h < allhits.size(); ++h){
565  const std::vector<sim::TrackIDE> hitTrackIDs = fBT->HitToTrackIDEs(allhits[h]);
566  for(size_t e = 0; e < hitTrackIDs.size(); ++e){
567  g4IDToHitEnergy[hitTrackIDs[e].trackID] += hitTrackIDs[e].energy;
568  }
569  } // end loop over hits to fill map
570 
571  // flatten the G4RecoBaseIDToPurityEfficiency maps to have just the g4ID as the key and the
572  // rest of the information in vector form
573  std::map<int, std::vector< std::pair<int, std::pair<double, double> > > > g4IDToClusterPurityEfficiency;
574  std::map<int, std::vector< std::pair<int, std::pair<double, double> > > > g4IDToShowerPurityEfficiency;
575  std::map<int, std::vector< std::pair<int, std::pair<double, double> > > > g4IDToTrackPurityEfficiency;
576  std::map<int, std::vector< std::pair<int, std::pair<double, double> > > >::iterator g4peItr;
577 
581 
582  // fill the tree vectors
583  // get all the eveIDs from this event
584  std::set<int> trackIDs = fBT->GetSetOfTrackIds();
585  std::set<int>::const_iterator trackItr = trackIDs.begin();
586 
587  // loop over them
588  while( trackItr != trackIDs.end() ){
589 
590  const simb::MCParticle* part = fPI->TrackIdToParticle_P(*trackItr);
591 
592  ftrackid = std::abs(*trackItr);
593  fpdg = part->PdgCode();
594  fpmom = part->P();
595 
596  // figure out how much of the energy deposited from this particle is stored in hits
597  std::vector<const sim::IDE*> ides = fBT->TrackIdToSimIDEs_Ps(*trackItr);
598  double totalDep = 0.;
599  for(size_t i = 0; i < ides.size(); ++i) totalDep += ides[i]->energy;
600 
601  if(totalDep > 0.)
602  fhiteff = g4IDToHitEnergy[*trackItr]/totalDep;
603 
604  std::vector< std::pair<int, std::pair<double, double> > > clVec;
605  std::vector< std::pair<int, std::pair<double, double> > > shVec;
606  std::vector< std::pair<int, std::pair<double, double> > > trVec;
607 
608 
609  if( g4IDToClusterPurityEfficiency.find(*trackItr) != g4IDToClusterPurityEfficiency.end() )
610  clVec = g4IDToClusterPurityEfficiency.find(*trackItr)->second;
611 
612  if( g4IDToShowerPurityEfficiency.find(*trackItr) != g4IDToShowerPurityEfficiency.end() )
613  shVec = g4IDToShowerPurityEfficiency.find(*trackItr)->second;
614 
615  if( g4IDToTrackPurityEfficiency.find(*trackItr) != g4IDToTrackPurityEfficiency.end() )
616  trVec = g4IDToTrackPurityEfficiency.find(*trackItr)->second;
617 
618  fnclu = clVec.size();
619  fnshw = shVec.size();
620  fntrk = trVec.size();
621 
622  for(size_t c = 0; c < clVec.size(); ++c){
623  fcluid .push_back(clVec[c].first);
624  fclupur.push_back(clVec[c].second.first);
625  fclueff.push_back(clVec[c].second.second);
626  }
627 
628  for(size_t s = 0; s < shVec.size(); ++s){
629  fshwid .push_back(shVec[s].first);
630  fshwpur.push_back(shVec[s].second.first);
631  fshweff.push_back(shVec[s].second.second);
632  }
633 
634  for(size_t t = 0; t < trVec.size(); ++t){
635  ftrkid .push_back(trVec[t].first);
636  ftrkpur.push_back(trVec[t].second.first);
637  ftrkeff.push_back(trVec[t].second.second);
638  }
639 
640  fTree->Fill();
641 
642  trackItr++;
643  }
644 
645  // clean up for the next event
646 
647  // clear the maps of G4 track id to efficiency and purity for
648  // various RecoBase objects
652 
653  // clear the vectors hooked up to the tree
654  fclueff.clear();
655  fclupur.clear();
656  fcluid .clear();
657  ftrkeff.clear();
658  ftrkpur.clear();
659  ftrkid .clear();
660  fshweff.clear();
661  fshwpur.clear();
662  fshwid .clear();
663 
664  return;
665 }
666 
667 
669 
670 #endif /* RecoCheckAna_h */
int fpdg
particle pdg code
Float_t s
Definition: plot.C:23
const simb::MCParticle * TrackIdToParticle_P(int const &id)
int fnshw
number of showers for this particle
int PdgCode() const
Definition: MCParticle.h:216
TH1D * fTrackPurityEfficiency
histogram of track efficiency times purity
bool fCheckVertices
should we check the reconstruction of vertices?
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(std::vector< art::Ptr< recob::Hit > > const &allhits)
intermediate_table::iterator iterator
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit)
std::map< std::pair< int, int >, std::pair< double, double > > fG4ShowerIDToPurityEfficiency
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
double fhiteff
hitfinder efficiency for this particle
TH1D * fClusterPurityEfficiency
histogram of cluster efficiency times purity
Declaration of signal hit object.
int fnclu
number of clusters for this particle
int fntrk
number of tracks for this particle
RecoCheckAna(fhicl::ParameterSet const &p)
TH1D * fEventPurity
histogram of event purity
bool fCheckEvents
should we check the reconstruction of events?
bool isRealData() const
Definition: Event.h:83
TH2D * fTrackPurityEfficiency2D
scatter histogram of cluster purity and efficiency
Particle class.
TH1D * fEventEfficiency
histogram of event efficiency
int NumberDaughters() const
Definition: MCParticle.h:221
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)
Definition: Run.h:30
TH1D * fVertexPurity
histogram of vertex purity
virtual void beginRun(art::Run const &r)
int Daughter(const int i) const
Definition: MCParticle.cxx:112
TH1D * fEventPurityEfficiency
histogram of event efficiency times purity
3-dimensional objects, potentially hits, clusters, prongs, etc.
Definition: geo_types.h:82
TH1D * fVertexPurityEfficiency
histogram of vertex efficiency times purity
const std::set< int > GetSetOfTrackIds()
const std::vector< const sim::IDE * > TrackIdToSimIDEs_Ps(int const &id)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
virtual void reconfigure(fhicl::ParameterSet const &p)
std::map< std::pair< int, int >, std::pair< double, double > > fG4TrackIDToPurityEfficiency
void hits()
Definition: readHits.C:15
intermediate_table::const_iterator const_iterator
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
Provides recob::Track data product.
std::vector< double > fclupur
cluster purities
std::vector< double > fshweff
shower efficiencies
bool fCheckClusters
should we check the reconstruction of clusters?
double P(const int i=0) const
Definition: MCParticle.h:238
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::vector< double > fshwpur
shower purities
TString part[npart]
Definition: Style.C:32
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)
TTree * fTree
TTree to save efficiencies.
std::vector< int > fshwid
shower IDs
double energy
Definition: plottest35.C:25
TH1D * fVertexEfficiency
histogram of vertex efficiency
std::vector< int > ftrkid
track IDs
std::vector< double > ftrkeff
track efficiencies
Float_t d
Definition: plot.C:237
virtual void analyze(art::Event const &e)
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 fCheckTracks
should we check the reconstruction of tracks?
std::vector< double > fclueff
cluster efficiencies
std::string fTrackModuleLabel
label for module making the tracks
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
double fpmom
particle momentum
std::vector< int > fcluid
cluster IDs
Declaration of cluster object.
const double HitCollectionEfficiency(std::set< int > const &trackIds, std::vector< art::Ptr< recob::Hit > > const &hits, std::vector< art::Ptr< recob::Hit > > const &allhits, geo::View_t const &view)
std::vector< double > ftrkpur
track purities
bool fCheckShowers
should we check the reconstruction of showers?
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)
T * make(ARGS...args) const
code to link reconstructed objects back to the MC truth information
Definition: BackTracker.cc:26
Utility object to perform functions of association.
int ftrackid
geant track ID
const double HitCollectionPurity(std::set< int > const &trackIds, std::vector< art::Ptr< recob::Hit > > const &hits)
TH1D * fShowerPurityEfficiency
histogram of shower efficiency times purity
TH1D * fClusterPurity
histogram of cluster purity
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::map< std::pair< int, int >, std::pair< double, double > > fG4ClusterIDToPurityEfficiency
std::string fClusterModuleLabel
label for module making the clusters
EventNumber_t event() const
Definition: EventID.h:117
TH1D * fClusterEfficiency
histogram of cluster efficiency
TH1D * fShowerPurity
histogram of shower purity
std::string fShowerModuleLabel
label for module making the showers
TH1D * fShowerEfficiency
histogram of shower efficiency
std::string fEventModuleLabel
label for module making the events
art::ServiceHandle< cheat::BackTrackerService > fBT
the back tracker service
TCEvent evt
Definition: DataStructs.cxx:5
TH1D * fTrackPurity
histogram of track purity
TH2D * fClusterPurityEfficiency2D
scatter histogram of cluster purity and efficiency
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
std::string fVertexModuleLabel
label for module making the vertices
Particle list in DetSim contains Monte Carlo particle information.
Float_t e
Definition: plot.C:34
RunNumber_t run() const
Definition: Event.h:77
void CheckReco(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 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)
TH1D * fTrackEfficiency
histogram of track efficiency
EventID id() const
Definition: Event.h:56
bool failedToGet() const
Definition: Handle.h:197
TH2D * fShowerPurityEfficiency2D
scatter histogram of cluster purity and efficiency
std::string fHitModuleLabel
label for module making the hits
art::ServiceHandle< cheat::ParticleInventoryService > fPI
the back tracker service