10 #include <calobase/RawCluster.h>
11 #include <calobase/RawClusterContainer.h>
12 #include <calobase/RawTower.h>
13 #include <calobase/RawTowerContainer.h>
38 const std::string& recojetname,
39 const std::string& truthjetname)
40 : _jettrutheval(topNode, truthjetname)
41 , _recojetname(recojetname)
42 , _truthjetname(truthjetname)
46 , _cemctowers(nullptr)
47 , _cemcclusters(nullptr)
48 , _hcalintowers(nullptr)
49 , _hcalinclusters(nullptr)
50 , _hcalouttowers(nullptr)
51 , _hcaloutclusters(nullptr)
52 , _femctowers(nullptr)
53 , _femcclusters(nullptr)
54 , _fhcaltowers(nullptr)
55 , _fhcalclusters(nullptr)
56 , _eemctowers(nullptr)
57 , _eemcclusters(nullptr)
62 , _cache_all_truth_showers()
63 , _cache_all_truth_particles()
64 , _cache_all_truth_jets()
65 , _cache_max_truth_jet_by_energy()
66 , _cache_all_jets_from()
67 , _cache_best_jet_from()
68 , _cache_get_energy_contribution()
69 , _cache_get_energy_contribution_src()
70 , _cache_all_truth_hits()
81 cout <<
"JetRecoEval::~JetRecoEval() - Error Count: " <<
_errors << endl;
118 return std::set<PHG4Shower*>();
123 std::map<Jet*, std::set<PHG4Shower*> >::iterator iter =
131 std::set<PHG4Shower*> truth_showers;
141 unsigned int index = iter->second;
143 std::set<PHG4Shower*> new_showers;
149 cout <<
PHWHERE <<
"ERROR: can't find SvtxTrackMap" << endl;
165 cout <<
PHWHERE <<
"ERROR: can't find TOWER_CEMC" << endl;
187 cout <<
PHWHERE <<
"ERROR: can't find CLUSTER_CEMC" << endl;
209 cout <<
PHWHERE <<
"ERROR: can't find TOWER_EEMC" << endl;
231 cout <<
PHWHERE <<
"ERROR: can't find CLUSTER_EEMC" << endl;
253 cout <<
PHWHERE <<
"ERROR: can't find TOWER_HCALIN" << endl;
275 cout <<
PHWHERE <<
"ERROR: can't find CLUSTER_HCALIN" << endl;
297 cout <<
PHWHERE <<
"ERROR: can't find TOWER_HCALOUT" << endl;
319 cout <<
PHWHERE <<
"ERROR: can't find CLUSTER_HCALOUT" << endl;
341 cout <<
PHWHERE <<
"ERROR: can't find TOWER_FEMC" << endl;
363 cout <<
PHWHERE <<
"ERROR: can't find CLUSTER_FEMC" << endl;
385 cout <<
PHWHERE <<
"ERROR: can't find TOWER_FHCAL" << endl;
407 cout <<
PHWHERE <<
"ERROR: can't find CLUSTER_FHCAL" << endl;
426 for (std::set<PHG4Shower*>::iterator jter = new_showers.begin();
427 jter != new_showers.end();
430 truth_showers.insert(*jter);
436 return truth_showers;
448 return std::set<PHG4Particle*>();
453 std::map<Jet*, std::set<PHG4Particle*> >::iterator iter =
461 std::set<PHG4Particle*> truth_particles;
471 unsigned int index = iter->second;
473 std::set<PHG4Particle*> new_particles;
479 cout <<
PHWHERE <<
"ERROR: can't find TrackMap" << endl;
501 cout <<
PHWHERE <<
"ERROR: can't find TOWER_CEMC" << endl;
523 cout <<
PHWHERE <<
"ERROR: can't find CLUSTER_CEMC" << endl;
545 cout <<
PHWHERE <<
"ERROR: can't find TOWER_EEMC" << endl;
567 cout <<
PHWHERE <<
"ERROR: can't find CLUSTER_EEMC" << endl;
589 cout <<
PHWHERE <<
"ERROR: can't find TOWER_HCALIN" << endl;
611 cout <<
PHWHERE <<
"ERROR: can't find CLUSTER_HCALIN" << endl;
633 cout <<
PHWHERE <<
"ERROR: can't find TOWER_HCALOUT" << endl;
655 cout <<
PHWHERE <<
"ERROR: can't find CLUSTER_HCALOUT" << endl;
677 cout <<
PHWHERE <<
"ERROR: can't find TOWER_FEMC" << endl;
699 cout <<
PHWHERE <<
"ERROR: can't find CLUSTER_FEMC" << endl;
721 cout <<
PHWHERE <<
"ERROR: can't find TOWER_FHCAL" << endl;
743 cout <<
PHWHERE <<
"ERROR: can't find CLUSTER_FHCAL" << endl;
762 for (std::set<PHG4Particle*>::iterator jter = new_particles.begin();
763 jter != new_particles.end();
766 truth_particles.insert(*jter);
772 return truth_particles;
784 return std::set<Jet*>();
789 std::map<Jet*, std::set<Jet*> >::iterator iter =
797 std::set<Jet*> truth_jets;
803 for (std::set<PHG4Particle*>::iterator iter = particles.begin();
804 iter != particles.end();
820 if (!truth_jet)
continue;
822 truth_jets.insert(truth_jet);
844 std::map<Jet*, Jet*>::iterator iter =
852 Jet* truthjet =
nullptr;
853 float max_energy =
FLT_MAX * -1.0;
856 for (std::set<Jet*>::iterator iter = truthjets.begin();
857 iter != truthjets.end();
860 Jet* candidate = *iter;
873 if (energy > max_energy)
875 truthjet = candidate;
894 return std::set<Jet*>();
899 std::map<Jet*, std::set<Jet*> >::iterator iter =
907 std::set<Jet*> recojets;
914 Jet* recojet = iter->second;
918 for (std::set<Jet*>::iterator jter = truthcandidates.begin();
919 jter != truthcandidates.end();
922 Jet* truthcandidate = *jter;
926 assert(truthcandidate);
928 else if (!truthcandidate)
936 recojets.insert(recojet);
960 std::map<Jet*, Jet*>::iterator iter =
968 Jet* bestrecojet =
nullptr;
969 float max_energy =
FLT_MAX * -1.0;
972 for (std::set<Jet*>::iterator iter = recojets.begin();
973 iter != recojets.end();
976 Jet* recojet = *iter;
989 if (energy > max_energy)
991 bestrecojet = recojet;
1063 else if (!recojet || !truthjet)
1071 std::map<std::pair<Jet*, Jet*>,
float>::iterator iter =
1075 return iter->second;
1079 float energy_contribution = 0.0;
1083 for (std::set<PHG4Particle*>::iterator iter = truthjetcomp.begin();
1084 iter != truthjetcomp.end();
1091 assert(truthparticle);
1093 else if (!truthparticle)
1105 unsigned int index = jter->second;
1125 if (maxtruthparticle ==
nullptr)
1132 energy = track->
get_p();
1328 energy_contribution +=
energy;
1334 return energy_contribution;
1352 std::map<std::pair<Jet*, Jet::SRC>,
float>::iterator iter =
1356 return iter->second;
1368 assert(source == src);
1369 unsigned int index = jter->second;
1374 energy += track->
get_p();
1585 return std::set<PHG4Hit*>();
1590 std::map<Jet*, std::set<PHG4Hit*> >::iterator iter =
1594 return iter->second;
1598 std::set<PHG4Hit*> truth_hits;
1608 unsigned int index = iter->second;
1610 std::set<PHG4Hit*> new_hits;
1616 cout <<
PHWHERE <<
"ERROR: can't find SvtxTrackMap" << endl;
1638 cout <<
PHWHERE <<
"ERROR: can't find TOWER_CEMC" << endl;
1660 cout <<
PHWHERE <<
"ERROR: can't find CLUSTER_CEMC" << endl;
1682 cout <<
PHWHERE <<
"ERROR: can't find TOWER_EEMC" << endl;
1704 cout <<
PHWHERE <<
"ERROR: can't find CLUSTER_EEMC" << endl;
1726 cout <<
PHWHERE <<
"ERROR: can't find TOWER_HCALIN" << endl;
1748 cout <<
PHWHERE <<
"ERROR: can't find CLUSTER_HCALIN" << endl;
1770 cout <<
PHWHERE <<
"ERROR: can't find TOWER_HCALOUT" << endl;
1792 cout <<
PHWHERE <<
"ERROR: can't find CLUSTER_HCALOUT" << endl;
1814 cout <<
PHWHERE <<
"ERROR: can't find TOWER_FEMC" << endl;
1836 cout <<
PHWHERE <<
"ERROR: can't find CLUSTER_FEMC" << endl;
1858 cout <<
PHWHERE <<
"ERROR: can't find TOWER_FHCAL" << endl;
1880 cout <<
PHWHERE <<
"ERROR: can't find CLUSTER_FHCAL" << endl;
1899 for (std::set<PHG4Hit*>::iterator jter = new_hits.begin();
1900 jter != new_hits.end();
1903 truth_hits.insert(*jter);
1932 _trackmap = findNode::getClass<SvtxTrackMap>(topNode,
"TrackMap");
1934 _cemctowers = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_CEMC");
1935 _hcalintowers = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_HCALIN");
1936 _hcalouttowers = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_HCALOUT");
1937 _femctowers = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_FEMC");
1938 _fhcaltowers = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_FHCAL");
1939 _eemctowers = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_EEMC");
1940 _cemcclusters = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_CEMC");
1941 _hcalinclusters = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_HCALIN");
1942 _hcaloutclusters = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_HCALOUT");
1943 _femcclusters = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_FEMC");
1944 _fhcalclusters = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_FHCAL");
1945 _eemcclusters = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_EEMC");