Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

PartToHitTable.cxx

Go to the documentation of this file.
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 }

Generated on Mon Dec 1 02:35:18 2008 for NOvA Offline by  doxygen 1.3.9.1