StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
buildRecHitTrackMap.cc
1 //
2 //
3 //
4 #include <map>
5 #include "StContainers.h"
6 #include "StTrackNode.h"
7 #include "StTrack.h"
8 #include "StTrackDetectorInfo.h"
9 #include "StHit.h"
10 
11 size_t buildRecHitTrackMap(const StSPtrVecTrackNode& nodes,map<StHit*,StTrack*>& htMap){
12  size_t failedInserts = 0;
13  for (size_t it = 0; it<nodes.size(); ++it) {
14  StTrack* track = nodes[it]->track(global);
15  if (! track) continue;
16  if (track->flag() <= 0) continue;
17  if (! track->detectorInfo()) continue;
18  StPtrVecHit hits = track->detectorInfo()->hits(kTpcId);
19  for (StPtrVecHitIterator hIterTrk = hits.begin(); hIterTrk != hits.end(); ++hIterTrk) {
20  StHit* hit = *hIterTrk;
21  pair<map<StHit*,StTrack*>::iterator,bool> insRes = htMap.insert(map<StHit*,StTrack*>::value_type(hit,track));
22  if (insRes.second==false) ++failedInserts;
23  }//hits in track loop
24  }// track loop
25  return failedInserts;
26 }
Definition: StHit.h:125