59 std::map<std::pair<int, int>, std::pair<double, double> >& g4RecoBaseIDToPurityEfficiency);
61 std::string
const&
label,
62 art::Handle< std::vector<recob::Cluster> >
const& clscol,
65 std::string
const& label,
66 art::Handle< std::vector<recob::Track> >
const& tcol,
69 std::string
const& label,
70 art::Handle< std::vector<recob::Shower> >
const& scol,
73 std::string
const& label,
74 art::Handle< std::vector<recob::Vertex> >
const& vtxcol,
77 std::string
const& label,
78 art::Handle< std::vector<recob::Event> >
const& evtcol,
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,
88 TH1D* purityEfficiency,
89 TH2D* purityEfficiency2D);
173 mf::LogWarning(
"RecoVetter") <<
"attempting to run MC truth check on " 174 <<
"real data, bail";
181 std::vector< art::Ptr<recob::Hit> > allhits;
244 fEventPurity = tfs->
make<TH1D>(
"eventPurity",
";Purity;Events", 100, 0., 1.1);
249 fVertexPurity = tfs->
make<TH1D>(
"vertexPurity",
";Purity;Vertices", 100, 0., 1.1);
254 fTrackPurity = tfs->
make<TH1D>(
"trackPurity",
";Purity;Tracks", 100, 0., 1.1);
260 fShowerPurity = tfs->
make<TH1D>(
"showerPurity",
";Purity;Showers", 100, 0., 1.1);
272 fTree = tfs->
make<TTree>(
"cheatertree",
"cheater tree");
301 std::map<std::pair<int, int>, std::pair<double, double> >& g4RecoBaseIDToPurityEfficiency)
310 while( itr != trackIDs.end() ){
322 std::pair<double, double> pe(purity, efficiency);
325 std::pair<int, int> g4reco(*itr, colID);
328 g4RecoBaseIDToPurityEfficiency[g4reco] = pe;
339 std::string
const&
label,
340 art::Handle< std::vector<recob::Cluster> >
const& clscol,
346 for(
size_t c = 0; c < clscol->size(); ++c){
349 std::vector< art::Ptr< recob::Hit > >
hits = fmh.at(c);
360 std::string
const&
label,
361 art::Handle< std::vector<recob::Track> >
const& tcol,
367 for(
size_t p = 0; p < tcol->size(); ++p){
370 std::vector< art::Ptr< recob::Hit > >
hits = fmh.at(p);
381 std::string
const&
label,
382 art::Handle< std::vector<recob::Shower> >
const& scol,
388 for(
size_t p = 0; p < scol->size(); ++p){
391 std::vector< art::Ptr< recob::Hit > >
hits = fmh.at(p);
404 std::string
const&
label,
405 art::Handle< std::vector<recob::Vertex> >
const& vtxcol,
410 std::vector< std::set<int> > ids(1);
415 for (
const auto& PartPair: plist) {
416 auto trackID = PartPair.first;
417 if (!plist.IsPrimary(trackID))
continue;
419 ids[0].insert(trackID);
424 ids.push_back(std::move(dv));
430 for(
size_t v = 0; v < vtxcol->size(); ++v){
433 std::vector< art::Ptr< recob::Hit > >
hits = fmh.at(v);
435 double maxPurity = -1.;
436 double maxEfficiency = -1.;
438 for(
size_t tv = 0; tv < ids.size(); ++tv){
444 if(purity > maxPurity ) maxPurity = purity;
445 if(efficiency > maxEfficiency) maxEfficiency = efficiency;
462 std::string
const&
label,
463 art::Handle< std::vector<recob::Event> >
const& evtcol,
471 for (
const auto& PartPair: plist) {
472 auto trackID = PartPair.first;
473 if (!plist.IsPrimary(trackID))
continue;
484 for(
size_t ev = 0; ev < evtcol->size(); ++ev){
487 std::vector< art::Ptr< recob::Hit > >
hits = fmh.at(ev);
504 std::map<
int,
std::vector<std::pair<
int, std::pair<double, double> > > >& g4IDToRecoBasePurityEfficiency,
507 TH1D* purityEfficiency,
508 TH2D* purityEfficiency2D)
511 std::map<std::pair<int, int>, std::pair<double, double> >
::const_iterator rbItr = g4RecoBaseIDToPurityEfficiency.begin();
514 std::map<int, std::pair<double, double> > recoBIDToPurityEfficiency;
515 std::map<int, std::pair<double, double> >
::iterator rbpeItr;
517 while( rbItr != g4RecoBaseIDToPurityEfficiency.end() ){
521 std::pair<int, int> g4cl = rbItr->first;
523 std::pair<double, double> pe = rbItr->second;
528 std::pair<int, std::pair<double, double> > clpe(g4cl.second, pe);
530 g4IDToRecoBasePurityEfficiency[g4cl.first].push_back(clpe);
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;
540 recoBIDToPurityEfficiency[g4cl.second] = pe;
545 rbpeItr = recoBIDToPurityEfficiency.begin();
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);
563 std::map<int, double> g4IDToHitEnergy;
564 for(
size_t h = 0; h < allhits.size(); ++h){
566 for(
size_t e = 0;
e < hitTrackIDs.size(); ++
e){
567 g4IDToHitEnergy[hitTrackIDs[
e].trackID] += hitTrackIDs[
e].energy;
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;
588 while( trackItr != trackIDs.end() ){
598 double totalDep = 0.;
599 for(
size_t i = 0; i < ides.size(); ++i) totalDep += ides[i]->
energy;
602 fhiteff = g4IDToHitEnergy[*trackItr]/totalDep;
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;
609 if( g4IDToClusterPurityEfficiency.find(*trackItr) != g4IDToClusterPurityEfficiency.end() )
610 clVec = g4IDToClusterPurityEfficiency.find(*trackItr)->second;
612 if( g4IDToShowerPurityEfficiency.find(*trackItr) != g4IDToShowerPurityEfficiency.end() )
613 shVec = g4IDToShowerPurityEfficiency.find(*trackItr)->second;
615 if( g4IDToTrackPurityEfficiency.find(*trackItr) != g4IDToTrackPurityEfficiency.end() )
616 trVec = g4IDToTrackPurityEfficiency.find(*trackItr)->second;
618 fnclu = clVec.size();
619 fnshw = shVec.size();
620 fntrk = trVec.size();
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);
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);
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);
int fpdg
particle pdg code
const simb::MCParticle * TrackIdToParticle_P(int const &id)
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?
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)
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?
TH2D * fTrackPurityEfficiency2D
scatter histogram of cluster purity and efficiency
TH1D * fEventEfficiency
histogram of event efficiency
int NumberDaughters() const
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)
TH1D * fVertexPurity
histogram of vertex purity
virtual void beginRun(art::Run const &r)
int Daughter(const int i) const
TH1D * fEventPurityEfficiency
histogram of event efficiency times purity
3-dimensional objects, potentially hits, clusters, prongs, etc.
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.
virtual void reconfigure(fhicl::ParameterSet const &p)
std::map< std::pair< int, int >, std::pair< double, double > > fG4TrackIDToPurityEfficiency
#define DEFINE_ART_MODULE(klass)
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
T get(std::string const &key) const
std::vector< double > fshwpur
shower purities
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
TH1D * fVertexEfficiency
histogram of vertex efficiency
std::vector< int > ftrkid
track IDs
std::vector< double > ftrkeff
track efficiencies
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)
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)
Provides recob::Track data product.
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
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
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
const sim::ParticleList & ParticleList()
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
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)
std::string fVertexModuleLabel
label for module making the vertices
Particle list in DetSim contains Monte Carlo particle information.
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
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