LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
cheat::RecoCheckAna Class Reference
Inheritance diagram for cheat::RecoCheckAna:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Types

using ModuleType = EDAnalyzer
 

Public Member Functions

 RecoCheckAna (fhicl::ParameterSet const &p)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResults > getTriggerResults (Event const &e) const
 
ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

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.

Member Typedef Documentation

Definition at line 22 of file EDAnalyzer.h.

Constructor & Destructor Documentation

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

Definition at line 162 of file RecoCheckAna_module.cc.

References fCheckClusters, fCheckEvents, fCheckShowers, fCheckTracks, fCheckVertices, fClusterModuleLabel, fEventModuleLabel, fShowerModuleLabel, fTrackModuleLabel, fVertexModuleLabel, and fhicl::ParameterSet::get().

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?
bool fCheckEvents
should we check the reconstruction of events?
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.cc:6
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)
overrideprivatevirtual

Implements art::EDAnalyzer.

Definition at line 178 of file RecoCheckAna_module.cc.

References CheckRecoClusters(), CheckRecoEvents(), CheckRecoShowers(), CheckRecoTracks(), CheckRecoVertices(), art::EventID::event(), art::Handle< T >::failedToGet(), fCheckClusters, fCheckEvents, fCheckShowers, fCheckTracks, fCheckVertices, fClusterModuleLabel, fevent, fEventModuleLabel, fHitModuleLabel, art::fill_ptr_vector(), FillResults(), frun, fShowerModuleLabel, fTrackModuleLabel, fVertexModuleLabel, art::ProductRetriever::getByLabel(), art::Event::id(), art::Event::isRealData(), and art::Event::run().

179 {
180  // check that this is MC, stop if it isn't
181  if (e.isRealData()) {
182  mf::LogWarning("RecoVetter") << "attempting to run MC truth check on "
183  << "real data, bail";
184  return;
185  }
186 
187  // get all hits in the event to figure out how many there are
189  e.getByLabel(fHitModuleLabel, hithdl);
190  std::vector<art::Ptr<recob::Hit>> allhits;
191  art::fill_ptr_vector(allhits, hithdl);
192 
193  // define variables to hold the reconstructed objects
199 
200  if (fCheckClusters) {
201  e.getByLabel(fClusterModuleLabel, clscol);
202  if (!clscol.failedToGet()) this->CheckRecoClusters(e, fClusterModuleLabel, clscol, allhits);
203  }
204  if (fCheckTracks) {
205  e.getByLabel(fTrackModuleLabel, trkcol);
206  if (!trkcol.failedToGet()) this->CheckRecoTracks(e, fTrackModuleLabel, trkcol, allhits);
207  }
208  if (fCheckShowers) {
209  e.getByLabel(fShowerModuleLabel, shwcol);
210  if (!shwcol.failedToGet()) this->CheckRecoShowers(e, fShowerModuleLabel, shwcol, allhits);
211  }
212  if (fCheckVertices) {
213  e.getByLabel(fVertexModuleLabel, vtxcol);
214  if (!vtxcol.failedToGet()) this->CheckRecoVertices(e, fVertexModuleLabel, vtxcol, allhits);
215  }
216  if (fCheckEvents) {
217  e.getByLabel(fEventModuleLabel, evtcol);
218  if (!evtcol.failedToGet()) this->CheckRecoEvents(e, fEventModuleLabel, evtcol, allhits);
219  }
220 
221  frun = e.run();
222  fevent = e.id().event();
223 
224  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e);
225  this->FillResults(clockData, allhits);
226 
227  return;
228 }
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)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
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
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:306
std::string fVertexModuleLabel
label for module making the vertices
Float_t e
Definition: plot.C:35
bool failedToGet() const
Definition: Handle.h:210
std::string fHitModuleLabel
label for module making the hits
void cheat::RecoCheckAna::beginRun ( art::Run const &  r)
overrideprivatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 231 of file RecoCheckAna_module.cc.

References fCheckClusters, fCheckEvents, fCheckShowers, fCheckTracks, fCheckVertices, fclueff, fcluid, fclupur, fClusterEfficiency, fClusterPurity, fClusterPurityEfficiency, fClusterPurityEfficiency2D, fevent, fEventEfficiency, fEventPurity, fEventPurityEfficiency, fhiteff, fnclu, fnshw, fntrk, fpdg, fpmom, frun, fShowerEfficiency, fShowerPurity, fShowerPurityEfficiency, fShowerPurityEfficiency2D, fshweff, fshwid, fshwpur, fTrackEfficiency, ftrackid, fTrackPurity, fTrackPurityEfficiency, fTrackPurityEfficiency2D, fTree, ftrkeff, ftrkid, ftrkpur, fVertexEfficiency, fVertexPurity, and fVertexPurityEfficiency.

232 {
234 
235  if (fCheckEvents) {
236  fEventPurity = tfs->make<TH1D>("eventPurity", ";Purity;Events", 100, 0., 1.1);
237  fEventEfficiency = tfs->make<TH1D>("eventEfficiency", ";Efficiency;Events", 100, 0., 1.1);
239  tfs->make<TH1D>("eventPurityEfficiency", ";purityEfficiency;Events", 110, 0., 1.1);
240  }
241  if (fCheckVertices) {
242  fVertexPurity = tfs->make<TH1D>("vertexPurity", ";Purity;Vertices", 100, 0., 1.1);
243  fVertexEfficiency = tfs->make<TH1D>("vertexEfficiency", ";Efficiency;Vertices", 100, 0., 1.1);
245  tfs->make<TH1D>("vertexPurityEfficiency", ";purityEfficiency;Vertex", 110, 0., 1.1);
246  }
247  if (fCheckTracks) {
248  fTrackPurity = tfs->make<TH1D>("trackPurity", ";Purity;Tracks", 100, 0., 1.1);
249  fTrackEfficiency = tfs->make<TH1D>("trackEfficiency", ";Efficiency;Tracks", 100, 0., 1.1);
251  tfs->make<TH1D>("trackPurityEfficiency", ";purityEfficiency;Tracks", 110, 0., 1.1);
253  tfs->make<TH2D>("trackPurityEfficiency2D", ";purity;efficiency", 110, 0., 1.1, 110, 0., 1.1);
254  }
255  if (fCheckShowers) {
256  fShowerPurity = tfs->make<TH1D>("showerPurity", ";Purity;Showers", 100, 0., 1.1);
257  fShowerEfficiency = tfs->make<TH1D>("showerEfficiency", ";Efficiency;Showers", 100, 0., 1.1);
259  tfs->make<TH1D>("showerPurityEfficiency", ";purityEfficiency;Showers", 110, 0., 1.1);
261  tfs->make<TH2D>("showerPurityEfficiency2D", ";purity;efficiency", 110, 0., 1.1, 110, 0., 1.1);
262  }
263  if (fCheckClusters) {
264  fClusterPurity = tfs->make<TH1D>("clusterPurity", ";Purity;Clusters", 110, 0., 1.1);
265  fClusterEfficiency = tfs->make<TH1D>("clusterEfficiency", ";Efficiency;Clusters", 110, 0., 1.1);
267  tfs->make<TH1D>("clusterPurityEfficiency", ";purityEfficiency;Clusters", 110, 0., 1.1);
268  fClusterPurityEfficiency2D = tfs->make<TH2D>(
269  "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 }
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
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 298 of file RecoCheckAna_module.cc.

References fBT, cheat::BackTrackerService::GetSetOfTrackIds(), cheat::BackTrackerService::HitCollectionEfficiency(), and cheat::BackTrackerService::HitCollectionPurity().

Referenced by CheckRecoClusters(), CheckRecoShowers(), and CheckRecoTracks().

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

References CheckReco(), fG4ClusterIDToPurityEfficiency, and hits().

Referenced by analyze().

343 {
344  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
345  art::FindManyP<recob::Hit> fmh(clscol, evt, label);
346 
347  for (size_t c = 0; c < clscol->size(); ++c) {
348 
349  // get the hits associated with this event
350  std::vector<art::Ptr<recob::Hit>> hits = fmh.at(c);
351 
352  this->CheckReco(clockData, clscol->at(c).ID(), allhits, hits, fG4ClusterIDToPurityEfficiency);
353 
354  } // end loop over clusters
355 
356  return;
357 }
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
void hits()
Definition: readHits.C:15
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 465 of file RecoCheckAna_module.cc.

References d, simb::MCParticle::Daughter(), fBT, fEventEfficiency, fEventPurity, fEventPurityEfficiency, fPI, cheat::BackTrackerService::HitCollectionEfficiency(), cheat::BackTrackerService::HitCollectionPurity(), hits(), geo::k3D, simb::MCParticle::NumberDaughters(), part, and cheat::ParticleInventoryService::ParticleList().

Referenced by analyze().

469 {
470  const sim::ParticleList& plist = fPI->ParticleList();
471 
472  // loop over all primaries in the plist and grab them and their daughters to put into
473  // the set of track ids to pass on to the back tracker
474  std::set<int> ids;
475  for (const auto& PartPair : plist) {
476  auto trackID = PartPair.first;
477  if (!plist.IsPrimary(trackID)) continue;
478  const simb::MCParticle& part = *(PartPair.second);
479  ids.insert(trackID);
480  for (int d = 0; d < part.NumberDaughters(); ++d)
481  ids.insert(part.Daughter(d));
482  } // end loop over primaries
483 
484  art::FindManyP<recob::Hit> fmh(evtcol, evt, label);
485 
486  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
487  for (size_t ev = 0; ev < evtcol->size(); ++ev) {
488 
489  // get the hits associated with this event
490  std::vector<art::Ptr<recob::Hit>> hits = fmh.at(ev);
491 
492  // use the cheat::BackTrackerService to find purity and efficiency for these
493  // hits
494  double purity = fBT->HitCollectionPurity(clockData, ids, hits);
495  double efficiency = fBT->HitCollectionEfficiency(clockData, ids, hits, allhits, geo::k3D);
496 
497  fEventPurity->Fill(purity);
498  fEventEfficiency->Fill(efficiency);
499  fEventPurityEfficiency->Fill(purity * efficiency);
500 
501  } // end loop over events
502 
503  return;
504 }
art::ServiceHandle< cheat::BackTrackerService const > fBT
the back tracker service
double HitCollectionEfficiency(detinfo::DetectorClocksData const &clockData, 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) const
art::ServiceHandle< cheat::ParticleInventoryService const > fPI
the back tracker service
TH1D * fEventPurity
histogram of event purity
TH1D * fEventEfficiency
histogram of event efficiency
int NumberDaughters() const
Definition: MCParticle.h:218
int Daughter(const int i) const
Definition: MCParticle.cxx:118
TH1D * fEventPurityEfficiency
histogram of event efficiency times purity
3-dimensional objects, potentially hits, clusters, prongs, etc.
Definition: geo_types.h:141
TString part[npart]
Definition: Style.C:32
void hits()
Definition: readHits.C:15
double HitCollectionPurity(detinfo::DetectorClocksData const &clockData, std::set< int > const &trackIds, std::vector< art::Ptr< recob::Hit >> const &hits) const
Float_t d
Definition: plot.C:235
const sim::ParticleList & ParticleList() const
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 381 of file RecoCheckAna_module.cc.

References CheckReco(), fG4ShowerIDToPurityEfficiency, and hits().

Referenced by analyze().

385 {
386  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
387  art::FindManyP<recob::Hit> fmh(scol, evt, label);
388 
389  for (size_t p = 0; p < scol->size(); ++p) {
390 
391  // get the hits associated with this event
392  std::vector<art::Ptr<recob::Hit>> hits = fmh.at(p);
393 
394  this->CheckReco(clockData, scol->at(p).ID(), allhits, hits, fG4ShowerIDToPurityEfficiency);
395 
396  } // end loop over events
397 
398  return;
399 }
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 hits()
Definition: readHits.C:15
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 360 of file RecoCheckAna_module.cc.

References CheckReco(), fG4TrackIDToPurityEfficiency, and hits().

Referenced by analyze().

364 {
365  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
366  art::FindManyP<recob::Hit> fmh(tcol, evt, label);
367 
368  for (size_t p = 0; p < tcol->size(); ++p) {
369 
370  // get the hits associated with this event
371  std::vector<art::Ptr<recob::Hit>> hits = fmh.at(p);
372 
373  this->CheckReco(clockData, tcol->at(p).ID(), allhits, hits, fG4TrackIDToPurityEfficiency);
374 
375  } // end loop over tracks
376 
377  return;
378 }
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 hits()
Definition: readHits.C:15
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 404 of file RecoCheckAna_module.cc.

References d, simb::MCParticle::Daughter(), fBT, fPI, fVertexEfficiency, fVertexPurity, fVertexPurityEfficiency, cheat::BackTrackerService::HitCollectionEfficiency(), cheat::BackTrackerService::HitCollectionPurity(), hits(), geo::k3D, simb::MCParticle::NumberDaughters(), part, and cheat::ParticleInventoryService::ParticleList().

Referenced by analyze().

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

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::Analyzer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 25 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

26  {
27  setupQueues(resources);
28  ProcessingFrame const frame{ScheduleID{}};
29  beginJobWithFrame(frame);
30  }
virtual void beginJobWithFrame(ProcessingFrame const &)=0
virtual void setupQueues(SharedResources const &)=0
bool art::detail::Analyzer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 68 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

69  {
70  ProcessingFrame const frame{mc.scheduleID()};
71  beginRunWithFrame(std::as_const(rp).makeRun(mc), frame);
72  return true;
73  }
virtual void beginRunWithFrame(Run const &, ProcessingFrame const &)=0
bool art::detail::Analyzer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 84 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

85  {
86  ProcessingFrame const frame{mc.scheduleID()};
87  beginSubRunWithFrame(std::as_const(srp).makeSubRun(mc), frame);
88  return true;
89  }
virtual void beginSubRunWithFrame(SubRun const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doEndJob ( )
inherited

Definition at line 33 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

34  {
35  ProcessingFrame const frame{ScheduleID{}};
36  endJobWithFrame(frame);
37  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Analyzer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 76 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

77  {
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(std::as_const(rp).makeRun(mc), frame);
80  return true;
81  }
virtual void endRunWithFrame(Run const &, ProcessingFrame const &)=0
bool art::detail::Analyzer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 92 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

93  {
94  ProcessingFrame const frame{mc.scheduleID()};
95  endSubRunWithFrame(std::as_const(srp).makeSubRun(mc), frame);
96  return true;
97  }
virtual void endSubRunWithFrame(SubRun const &, ProcessingFrame const &)=0
bool art::detail::Analyzer::doEvent ( EventPrincipal ep,
ModuleContext const &  mc,
std::atomic< std::size_t > &  counts_run,
std::atomic< std::size_t > &  counts_passed,
std::atomic< std::size_t > &  counts_failed 
)
inherited

Definition at line 100 of file Analyzer.cc.

References e, and art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

105  {
106  auto const e = std::as_const(ep).makeEvent(mc);
107  if (wantEvent(mc.scheduleID(), e)) {
108  ++counts_run;
109  ProcessingFrame const frame{mc.scheduleID()};
110  analyzeWithFrame(e, frame);
111  ++counts_passed;
112  }
113  return true;
114  }
bool wantEvent(ScheduleID id, Event const &e) const
Definition: Observer.cc:63
Float_t e
Definition: plot.C:35
virtual void analyzeWithFrame(Event const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 47 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

48  {
49  ProcessingFrame const frame{ScheduleID{}};
51  }
TFile fb("Li6.root")
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 61 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

62  {
63  ProcessingFrame const frame{ScheduleID{}};
65  }
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Analyzer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 40 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

41  {
42  ProcessingFrame const frame{ScheduleID{}};
44  }
TFile fb("Li6.root")
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 54 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

55  {
56  ProcessingFrame const frame{ScheduleID{}};
58  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void cheat::RecoCheckAna::FillResults ( detinfo::DetectorClocksData const &  clockData,
std::vector< art::Ptr< recob::Hit >> const &  allhits 
)
private

Definition at line 566 of file RecoCheckAna_module.cc.

References util::abs(), DEFINE_ART_MODULE, e, energy, fBT, fCheckClusters, fCheckShowers, fCheckTracks, fclueff, fcluid, fclupur, fClusterEfficiency, fClusterPurity, fClusterPurityEfficiency, fClusterPurityEfficiency2D, fG4ClusterIDToPurityEfficiency, fG4ShowerIDToPurityEfficiency, fG4TrackIDToPurityEfficiency, fhiteff, FlattenMap(), fnclu, fnshw, fntrk, fpdg, fPI, fpmom, fShowerEfficiency, fShowerPurity, fShowerPurityEfficiency, fShowerPurityEfficiency2D, fshweff, fshwid, fshwpur, fTrackEfficiency, ftrackid, fTrackPurity, fTrackPurityEfficiency, fTrackPurityEfficiency2D, fTree, ftrkeff, ftrkid, ftrkpur, cheat::BackTrackerService::GetSetOfTrackIds(), cheat::BackTrackerService::HitToTrackIDEs(), if(), simb::MCParticle::P(), part, simb::MCParticle::PdgCode(), cheat::ParticleInventoryService::TrackIdToParticle_P(), and cheat::BackTrackerService::TrackIdToSimIDEs_Ps().

Referenced by analyze().

568 {
569  // map the g4 track id to energy deposited in a hit
570  std::map<int, double> g4IDToHitEnergy;
571  for (size_t h = 0; h < allhits.size(); ++h) {
572  const std::vector<sim::TrackIDE> hitTrackIDs = fBT->HitToTrackIDEs(clockData, allhits[h]);
573  for (size_t e = 0; e < hitTrackIDs.size(); ++e) {
574  g4IDToHitEnergy[hitTrackIDs[e].trackID] += hitTrackIDs[e].energy;
575  }
576  } // end loop over hits to fill map
577 
578  // flatten the G4RecoBaseIDToPurityEfficiency maps to have just the g4ID as
579  // the key and the rest of the information in vector form
580  std::map<int, std::vector<std::pair<int, std::pair<double, double>>>>
581  g4IDToClusterPurityEfficiency;
582  std::map<int, std::vector<std::pair<int, std::pair<double, double>>>>
583  g4IDToShowerPurityEfficiency;
584  std::map<int, std::vector<std::pair<int, std::pair<double, double>>>> g4IDToTrackPurityEfficiency;
585  std::map<int, std::vector<std::pair<int, std::pair<double, double>>>>::iterator g4peItr;
586 
587  if (fCheckClusters)
589  g4IDToClusterPurityEfficiency,
594  if (fCheckShowers)
596  g4IDToShowerPurityEfficiency,
601  if (fCheckTracks)
603  g4IDToTrackPurityEfficiency,
604  fTrackPurity,
608 
609  // fill the tree vectors
610  // get all the eveIDs from this event
611  std::set<int> trackIDs = fBT->GetSetOfTrackIds();
612  std::set<int>::const_iterator trackItr = trackIDs.begin();
613 
614  // loop over them
615  while (trackItr != trackIDs.end()) {
616 
617  const simb::MCParticle* part = fPI->TrackIdToParticle_P(*trackItr);
618 
619  ftrackid = std::abs(*trackItr);
620  fpdg = part->PdgCode();
621  fpmom = part->P();
622 
623  // figure out how much of the energy deposited from this particle is stored in hits
624  std::vector<const sim::IDE*> ides = fBT->TrackIdToSimIDEs_Ps(*trackItr);
625  double totalDep = 0.;
626  for (size_t i = 0; i < ides.size(); ++i)
627  totalDep += ides[i]->energy;
628 
629  if (totalDep > 0.) fhiteff = g4IDToHitEnergy[*trackItr] / totalDep;
630 
631  std::vector<std::pair<int, std::pair<double, double>>> clVec;
632  std::vector<std::pair<int, std::pair<double, double>>> shVec;
633  std::vector<std::pair<int, std::pair<double, double>>> trVec;
634 
635  if (g4IDToClusterPurityEfficiency.find(*trackItr) != g4IDToClusterPurityEfficiency.end())
636  clVec = g4IDToClusterPurityEfficiency.find(*trackItr)->second;
637 
638  if (g4IDToShowerPurityEfficiency.find(*trackItr) != g4IDToShowerPurityEfficiency.end())
639  shVec = g4IDToShowerPurityEfficiency.find(*trackItr)->second;
640 
641  if (g4IDToTrackPurityEfficiency.find(*trackItr) != g4IDToTrackPurityEfficiency.end())
642  trVec = g4IDToTrackPurityEfficiency.find(*trackItr)->second;
643 
644  fnclu = clVec.size();
645  fnshw = shVec.size();
646  fntrk = trVec.size();
647 
648  for (size_t c = 0; c < clVec.size(); ++c) {
649  fcluid.push_back(clVec[c].first);
650  fclupur.push_back(clVec[c].second.first);
651  fclueff.push_back(clVec[c].second.second);
652  }
653 
654  for (size_t s = 0; s < shVec.size(); ++s) {
655  fshwid.push_back(shVec[s].first);
656  fshwpur.push_back(shVec[s].second.first);
657  fshweff.push_back(shVec[s].second.second);
658  }
659 
660  for (size_t t = 0; t < trVec.size(); ++t) {
661  ftrkid.push_back(trVec[t].first);
662  ftrkpur.push_back(trVec[t].second.first);
663  ftrkeff.push_back(trVec[t].second.second);
664  }
665 
666  fTree->Fill();
667 
668  trackItr++;
669  }
670 
671  // clean up for the next event
672 
673  // clear the maps of G4 track id to efficiency and purity for
674  // various RecoBase objects
678 
679  // clear the vectors hooked up to the tree
680  fclueff.clear();
681  fclupur.clear();
682  fcluid.clear();
683  ftrkeff.clear();
684  ftrkpur.clear();
685  ftrkid.clear();
686  fshweff.clear();
687  fshwpur.clear();
688  fshwid.clear();
689 
690  return;
691 }
art::ServiceHandle< cheat::BackTrackerService const > fBT
the back tracker service
int fpdg
particle pdg code
int fnshw
number of showers for this particle
int PdgCode() const
Definition: MCParticle.h:213
TH1D * fTrackPurityEfficiency
histogram of track efficiency times purity
std::vector< sim::TrackIDE > HitToTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
const simb::MCParticle * TrackIdToParticle_P(int id) const
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
constexpr auto abs(T v)
Returns the absolute value of the argument.
int fntrk
number of tracks for this particle
std::vector< const sim::IDE * > TrackIdToSimIDEs_Ps(int const &id) const
intermediate_table::const_iterator const_iterator
std::map< std::pair< int, int >, std::pair< double, double > > fG4ClusterIDToPurityEfficiency
TH2D * fTrackPurityEfficiency2D
scatter histogram of cluster purity and efficiency
TString part[npart]
Definition: Style.C:32
if(nlines<=0)
std::set< int > GetSetOfTrackIds() const
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:235
std::vector< double > fshwpur
shower purities
TTree * fTree
TTree to save efficiencies.
std::vector< int > fshwid
shower IDs
double energy
Definition: plottest35.C:25
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
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
Float_t e
Definition: plot.C:35
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:82
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 507 of file RecoCheckAna_module.cc.

Referenced by FillResults().

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

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
Handle< TriggerResults > art::Observer::getTriggerResults ( Event const &  e) const
protectedinherited

Definition at line 75 of file Observer.cc.

References art::ProductRetriever::get(), and art::Observer::selectors_.

Referenced by art::OutputModule::doWriteEvent(), and art::Observer::wantAllEvents().

76  {
77  if (selectors_) {
78  return selectors_->getOneTriggerResults(e);
79  }
80 
81  // The following applies for cases where no SelectEvents entries
82  // exist.
83  Handle<TriggerResults> h;
84  if (e.get(empty_process_name, h)) {
85  return h;
86  }
87  return Handle<TriggerResults>{};
88  }
Float_t e
Definition: plot.C:35
std::optional< detail::ProcessAndEventSelectors > selectors_
Definition: Observer.h:79
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
string const & art::Observer::processName ( ) const
protectedinherited

Definition at line 57 of file Observer.cc.

References art::Observer::process_name_.

Referenced by art::FileDumperOutput::printPrincipal().

58  {
59  return process_name_;
60  }
std::string process_name_
Definition: Observer.h:76
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)
bool art::Observer::wantAllEvents ( ) const
inlineprotectednoexceptinherited

Definition at line 31 of file Observer.h.

References e, art::Observer::getTriggerResults(), art::Observer::wantAllEvents_, and art::Observer::wantEvent().

32  {
33  return wantAllEvents_;
34  }
bool wantAllEvents_
Definition: Observer.h:75
bool art::Observer::wantEvent ( ScheduleID  id,
Event const &  e 
) const
protectedinherited

Definition at line 63 of file Observer.cc.

References art::Observer::rejectors_, art::Observer::selectors_, and art::Observer::wantAllEvents_.

Referenced by art::OutputModule::doEvent(), art::OutputModule::doWriteEvent(), and art::Observer::wantAllEvents().

64  {
65  if (wantAllEvents_) {
66  return true;
67  }
68  bool const select_event = selectors_ ? selectors_->matchEvent(id, e) : true;
69  bool const reject_event =
70  rejectors_ ? rejectors_->matchEvent(id, e) : false;
71  return select_event and not reject_event;
72  }
bool wantAllEvents_
Definition: Observer.h:75
std::optional< detail::ProcessAndEventSelectors > rejectors_
Definition: Observer.h:80
Float_t e
Definition: plot.C:35
std::optional< detail::ProcessAndEventSelectors > selectors_
Definition: Observer.h:79

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.

Referenced by CheckReco(), CheckRecoEvents(), CheckRecoVertices(), and FillResults().

bool cheat::RecoCheckAna::fCheckClusters
private

should we check the reconstruction of clusters?

Definition at line 108 of file RecoCheckAna_module.cc.

Referenced by analyze(), beginRun(), FillResults(), and RecoCheckAna().

bool cheat::RecoCheckAna::fCheckEvents
private

should we check the reconstruction of events?

Definition at line 112 of file RecoCheckAna_module.cc.

Referenced by analyze(), beginRun(), and RecoCheckAna().

bool cheat::RecoCheckAna::fCheckShowers
private

should we check the reconstruction of showers?

Definition at line 109 of file RecoCheckAna_module.cc.

Referenced by analyze(), beginRun(), FillResults(), and RecoCheckAna().

bool cheat::RecoCheckAna::fCheckTracks
private

should we check the reconstruction of tracks?

Definition at line 110 of file RecoCheckAna_module.cc.

Referenced by analyze(), beginRun(), FillResults(), and RecoCheckAna().

bool cheat::RecoCheckAna::fCheckVertices
private

should we check the reconstruction of vertices?

Definition at line 111 of file RecoCheckAna_module.cc.

Referenced by analyze(), beginRun(), and RecoCheckAna().

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

cluster efficiencies

Definition at line 148 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

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

cluster IDs

Definition at line 150 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

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

cluster purities

Definition at line 149 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

TH1D* cheat::RecoCheckAna::fClusterEfficiency
private

histogram of cluster efficiency

Definition at line 115 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

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

label for module making the clusters

Definition at line 102 of file RecoCheckAna_module.cc.

Referenced by analyze(), and RecoCheckAna().

TH1D* cheat::RecoCheckAna::fClusterPurity
private

histogram of cluster purity

Definition at line 114 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

TH1D* cheat::RecoCheckAna::fClusterPurityEfficiency
private

histogram of cluster efficiency times purity

Definition at line 116 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

TH2D* cheat::RecoCheckAna::fClusterPurityEfficiency2D
private

scatter histogram of cluster purity and efficiency

Definition at line 117 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

int cheat::RecoCheckAna::fevent
private

event number

Definition at line 142 of file RecoCheckAna_module.cc.

Referenced by analyze(), and beginRun().

TH1D* cheat::RecoCheckAna::fEventEfficiency
private

histogram of event efficiency

Definition at line 130 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and CheckRecoEvents().

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

label for module making the events

Definition at line 106 of file RecoCheckAna_module.cc.

Referenced by analyze(), and RecoCheckAna().

TH1D* cheat::RecoCheckAna::fEventPurity
private

histogram of event purity

Definition at line 129 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and CheckRecoEvents().

TH1D* cheat::RecoCheckAna::fEventPurityEfficiency
private

histogram of event efficiency times purity

Definition at line 131 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and CheckRecoEvents().

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

Definition at line 136 of file RecoCheckAna_module.cc.

Referenced by CheckRecoClusters(), and FillResults().

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

Definition at line 137 of file RecoCheckAna_module.cc.

Referenced by CheckRecoShowers(), and FillResults().

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

Definition at line 138 of file RecoCheckAna_module.cc.

Referenced by CheckRecoTracks(), and FillResults().

double cheat::RecoCheckAna::fhiteff
private

hitfinder efficiency for this particle

Definition at line 146 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

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

label for module making the hits

Definition at line 101 of file RecoCheckAna_module.cc.

Referenced by analyze().

int cheat::RecoCheckAna::fnclu
private

number of clusters for this particle

Definition at line 147 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

int cheat::RecoCheckAna::fnshw
private

number of showers for this particle

Definition at line 151 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

int cheat::RecoCheckAna::fntrk
private

number of tracks for this particle

Definition at line 155 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

int cheat::RecoCheckAna::fpdg
private

particle pdg code

Definition at line 144 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

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

the back tracker service

Definition at line 99 of file RecoCheckAna_module.cc.

Referenced by CheckRecoEvents(), CheckRecoVertices(), and FillResults().

double cheat::RecoCheckAna::fpmom
private

particle momentum

Definition at line 145 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

int cheat::RecoCheckAna::frun
private

run number

Definition at line 141 of file RecoCheckAna_module.cc.

Referenced by analyze(), and beginRun().

TH1D* cheat::RecoCheckAna::fShowerEfficiency
private

histogram of shower efficiency

Definition at line 119 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

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

label for module making the showers

Definition at line 103 of file RecoCheckAna_module.cc.

Referenced by analyze(), and RecoCheckAna().

TH1D* cheat::RecoCheckAna::fShowerPurity
private

histogram of shower purity

Definition at line 118 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

TH1D* cheat::RecoCheckAna::fShowerPurityEfficiency
private

histogram of shower efficiency times purity

Definition at line 120 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

TH2D* cheat::RecoCheckAna::fShowerPurityEfficiency2D
private

scatter histogram of cluster purity and efficiency

Definition at line 121 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

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

shower efficiencies

Definition at line 152 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

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

shower IDs

Definition at line 154 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

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

shower purities

Definition at line 153 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

TH1D* cheat::RecoCheckAna::fTrackEfficiency
private

histogram of track efficiency

Definition at line 123 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

int cheat::RecoCheckAna::ftrackid
private

geant track ID

Definition at line 143 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

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

label for module making the tracks

Definition at line 104 of file RecoCheckAna_module.cc.

Referenced by analyze(), and RecoCheckAna().

TH1D* cheat::RecoCheckAna::fTrackPurity
private

histogram of track purity

Definition at line 122 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

TH1D* cheat::RecoCheckAna::fTrackPurityEfficiency
private

histogram of track efficiency times purity

Definition at line 124 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

TH2D* cheat::RecoCheckAna::fTrackPurityEfficiency2D
private

scatter histogram of cluster purity and efficiency

Definition at line 125 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

TTree* cheat::RecoCheckAna::fTree
private

TTree to save efficiencies.

Definition at line 140 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

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

track efficiencies

Definition at line 156 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

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

track IDs

Definition at line 158 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

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

track purities

Definition at line 157 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and FillResults().

TH1D* cheat::RecoCheckAna::fVertexEfficiency
private

histogram of vertex efficiency

Definition at line 127 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and CheckRecoVertices().

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

label for module making the vertices

Definition at line 105 of file RecoCheckAna_module.cc.

Referenced by analyze(), and RecoCheckAna().

TH1D* cheat::RecoCheckAna::fVertexPurity
private

histogram of vertex purity

Definition at line 126 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and CheckRecoVertices().

TH1D* cheat::RecoCheckAna::fVertexPurityEfficiency
private

histogram of vertex efficiency times purity

Definition at line 128 of file RecoCheckAna_module.cc.

Referenced by beginRun(), and CheckRecoVertices().


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