00001 #include <map> 00002 #include "Simulation/PartToHitTable.h" 00003 #include "Simulation/ParticleList.h" 00004 #include "Simulation/FLSHitList.h" 00005 using namespace sim; 00006 00007 PartToHitTable::PartToHitTable(const ParticleList& plist, 00008 const FLSHitList& hitlist) : 00009 fHitLists(plist.fParticles.size()) 00010 { 00011 unsigned register int i; 00012 // 00013 // The sizes can be large, so try to do this as efficiently as 00014 // possible. The following makes only two passes over the lists 00015 // 00016 // First build a look up table to map trackIds to an index inside 00017 // the particle list 00018 std::map<int,int> trk2indx; 00019 for (i=0; i<plist.fParticles.size(); ++i) { 00020 trk2indx[plist.fParticles[i].fTrackId] = i; 00021 } 00022 00023 // Now, use that map to build the lists 00024 for (i=0; i<hitlist.fHits.size(); ++i) { 00025 int indx = trk2indx[hitlist.fHits[i].fTrackId]; 00026 fHitLists[indx].push_back(&hitlist.fHits[i]); 00027 } 00028 } 00029 00030 //...................................................................... 00031 00039 const PartToHitTable::HitList& 00040 PartToHitTable::operator[](unsigned int i) const 00041 { 00042 assert(i<fHitLists.size()); 00043 return fHitLists[i]; 00044 }
1.3.9.1