24 #include "art_root_io/TFileService.h" 63 std::map<std::pair<int, int>, std::pair<double, double>>& g4RecoBaseIDToPurityEfficiency);
65 std::string
const& label,
66 art::Handle<std::vector<recob::Cluster>>
const& clscol,
69 std::string
const& label,
73 std::string
const& label,
74 art::Handle<std::vector<recob::Shower>>
const& scol,
77 std::string
const& label,
78 art::Handle<std::vector<recob::Vertex>>
const& vtxcol,
81 std::string
const& label,
82 art::Handle<std::vector<recob::Event>>
const& evtcol,
90 std::map<std::pair<int, int>, std::pair<double, double>>
const& g4RecoBaseIDToPurityEfficiency,
91 std::map<
int,
std::vector<std::pair<
int, std::pair<double, double>>>>&
92 g4IDToRecoBasePurityEfficiency,
95 TH1D* purityEfficiency,
96 TH2D* purityEfficiency2D);
182 mf::LogWarning(
"RecoVetter") <<
"attempting to run MC truth check on " 183 <<
"real data, bail";
190 std::vector<art::Ptr<recob::Hit>> allhits;
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);
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);
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);
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);
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);
269 "clusterPurityEfficiency2D",
";purity;efficiency", 110, 0., 1.1, 110, 0., 1.1);
272 fTree = tfs->make<TTree>(
"cheatertree",
"cheater tree");
303 std::map<std::pair<int, int>, std::pair<double, double>>& g4RecoBaseIDToPurityEfficiency)
312 while (itr != trackIDs.end()) {
323 std::pair<double, double> pe(purity, efficiency);
326 std::pair<int, int> g4reco(*itr, colID);
329 g4RecoBaseIDToPurityEfficiency[g4reco] = pe;
340 std::string
const& label,
341 art::Handle<std::vector<recob::Cluster>>
const& clscol,
347 for (
size_t c = 0; c < clscol->size(); ++c) {
350 std::vector<art::Ptr<recob::Hit>>
hits = fmh.at(c);
361 std::string
const& label,
362 art::Handle<std::vector<recob::Track>>
const& tcol,
368 for (
size_t p = 0; p < tcol->size(); ++p) {
371 std::vector<art::Ptr<recob::Hit>>
hits = fmh.at(p);
382 std::string
const& label,
383 art::Handle<std::vector<recob::Shower>>
const& scol,
389 for (
size_t p = 0; p < scol->size(); ++p) {
392 std::vector<art::Ptr<recob::Hit>>
hits = fmh.at(p);
405 std::string
const& label,
406 art::Handle<std::vector<recob::Vertex>>
const& vtxcol,
411 std::vector<std::set<int>> ids(1);
416 for (
const auto& PartPair : plist) {
417 auto trackID = PartPair.first;
418 if (!plist.IsPrimary(trackID))
continue;
420 ids[0].insert(trackID);
425 ids.push_back(std::move(dv));
433 for (
size_t v = 0; v < vtxcol->size(); ++v) {
436 std::vector<art::Ptr<recob::Hit>>
hits = fmh.at(v);
438 double maxPurity = -1.;
439 double maxEfficiency = -1.;
441 for (
size_t tv = 0; tv < ids.size(); ++tv) {
448 if (purity > maxPurity) maxPurity = purity;
449 if (efficiency > maxEfficiency) maxEfficiency = efficiency;
466 std::string
const& label,
467 art::Handle<std::vector<recob::Event>>
const& evtcol,
475 for (
const auto& PartPair : plist) {
476 auto trackID = PartPair.first;
477 if (!plist.IsPrimary(trackID))
continue;
487 for (
size_t ev = 0; ev < evtcol->size(); ++ev) {
490 std::vector<art::Ptr<recob::Hit>>
hits = fmh.at(ev);
508 std::map<std::pair<int, int>, std::pair<double, double>>
const& g4RecoBaseIDToPurityEfficiency,
509 std::map<
int,
std::vector<std::pair<
int, std::pair<double, double>>>>&
510 g4IDToRecoBasePurityEfficiency,
513 TH1D* purityEfficiency,
514 TH2D* purityEfficiency2D)
517 std::map<std::pair<int, int>, std::pair<double, double>>
::const_iterator rbItr =
518 g4RecoBaseIDToPurityEfficiency.begin();
521 std::map<int, std::pair<double, double>> recoBIDToPurityEfficiency;
522 std::map<int, std::pair<double, double>>
::iterator rbpeItr;
524 while (rbItr != g4RecoBaseIDToPurityEfficiency.end()) {
527 std::pair<int, int> g4cl = rbItr->first;
529 std::pair<double, double> pe = rbItr->second;
534 std::pair<int, std::pair<double, double>> clpe(g4cl.second, pe);
536 g4IDToRecoBasePurityEfficiency[g4cl.first].push_back(clpe);
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;
546 recoBIDToPurityEfficiency[g4cl.second] = pe;
551 rbpeItr = recoBIDToPurityEfficiency.begin();
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);
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;
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;
589 g4IDToClusterPurityEfficiency,
596 g4IDToShowerPurityEfficiency,
603 g4IDToTrackPurityEfficiency,
615 while (trackItr != trackIDs.end()) {
625 double totalDep = 0.;
626 for (
size_t i = 0; i < ides.size(); ++i)
627 totalDep += ides[i]->
energy;
629 if (totalDep > 0.)
fhiteff = g4IDToHitEnergy[*trackItr] / totalDep;
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;
635 if (g4IDToClusterPurityEfficiency.find(*trackItr) != g4IDToClusterPurityEfficiency.end())
636 clVec = g4IDToClusterPurityEfficiency.find(*trackItr)->second;
638 if (g4IDToShowerPurityEfficiency.find(*trackItr) != g4IDToShowerPurityEfficiency.end())
639 shVec = g4IDToShowerPurityEfficiency.find(*trackItr)->second;
641 if (g4IDToTrackPurityEfficiency.find(*trackItr) != g4IDToTrackPurityEfficiency.end())
642 trVec = g4IDToTrackPurityEfficiency.find(*trackItr)->second;
644 fnclu = clVec.size();
645 fnshw = shVec.size();
646 fntrk = trVec.size();
648 for (
size_t c = 0; c < clVec.size(); ++c) {
649 fcluid.push_back(clVec[c].first);
654 for (
size_t s = 0; s < shVec.size(); ++s) {
655 fshwid.push_back(shVec[s].first);
660 for (
size_t t = 0; t < trVec.size(); ++t) {
661 ftrkid.push_back(trVec[t].first);
art::ServiceHandle< cheat::BackTrackerService const > fBT
the back tracker service
int fpdg
particle pdg code
int fnshw
number of showers for this particle
void analyze(art::Event const &e) override
TH1D * fTrackPurityEfficiency
histogram of track efficiency times purity
bool fCheckVertices
should we check the reconstruction of vertices?
std::vector< sim::TrackIDE > HitToTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
const simb::MCParticle * TrackIdToParticle_P(int id) const
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
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
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 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)
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
RecoCheckAna(fhicl::ParameterSet const &p)
TH1D * fEventPurity
histogram of event purity
bool fCheckEvents
should we check the reconstruction of events?
std::map< std::pair< int, int >, std::pair< double, double > > fG4ClusterIDToPurityEfficiency
TH2D * fTrackPurityEfficiency2D
scatter histogram of cluster purity and efficiency
void beginRun(art::Run const &r) override
EDAnalyzer(fhicl::ParameterSet const &pset)
TH1D * fEventEfficiency
histogram of event efficiency
int NumberDaughters() const
TH1D * fVertexPurity
histogram of vertex purity
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
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
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)
#define DEFINE_ART_MODULE(klass)
std::set< int > GetSetOfTrackIds() const
std::vector< double > fclupur
cluster purities
std::vector< double > fshweff
shower efficiencies
double HitCollectionPurity(detinfo::DetectorClocksData const &clockData, std::set< int > const &trackIds, std::vector< art::Ptr< recob::Hit >> const &hits) const
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
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
Provides recob::Track data product.
bool fCheckTracks
should we check the reconstruction of tracks?
std::vector< double > fclueff
cluster efficiencies
std::string fTrackModuleLabel
label for module making the tracks
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
Declaration of cluster object.
std::vector< double > ftrkpur
track purities
Definition of data types for geometry description.
bool fCheckShowers
should we check the reconstruction of showers?
const sim::ParticleList & ParticleList() const
std::map< std::pair< int, int >, std::pair< double, double > > fG4TrackIDToPurityEfficiency
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)
code to link reconstructed objects back to the MC truth information
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
int ftrackid
geant track ID
Contains all timing reference information for the detector.
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
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
object containing MC truth information necessary for making RawDigits and doing back tracking ...
std::string fClusterModuleLabel
label for module making the clusters
EventNumber_t event() const
TH1D * fClusterEfficiency
histogram of cluster efficiency
TH1D * fShowerPurity
histogram of shower purity
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
TH1D * fShowerEfficiency
histogram of shower efficiency
std::string fEventModuleLabel
label for module making the events
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.
second_as<> second
Type of time stored in seconds, in double precision.
TH1D * fTrackEfficiency
histogram of track efficiency
TH2D * fShowerPurityEfficiency2D
scatter histogram of cluster purity and efficiency
std::string fHitModuleLabel
label for module making the hits