EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FwdMcTrackMapper.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FwdMcTrackMapper.cxx
1 //
2 // AYK (ayk@bnl.gov)
3 //
4 // Code helping to remap MC tracks into RC ones;
5 //
6 //
7 
8 #include <FwdMcTrackMapper.h>
9 
10 // ---------------------------------------------------------------------------------------
11 
13 {
14  if (!mcTrackArray || !rcTrackArray) return -1;
15 
16  mMcToRcMap.clear();
17 
18  for(unsigned rc=0; rc<rcTrackArray->GetEntriesFast(); rc++) {
19  FwdMatchCandidate *rctrack = (FwdMatchCandidate *)rcTrackArray->At(rc);
20 
21  // FIXME: used in rc2mc.C as well -> make a routine;
22  int mcTrackId = rctrack->GetMcTrackId();
23 
24  assert(mcTrackId >= 0 && mcTrackId < mcTrackArray->GetEntriesFast());
25  // Select only correctly rc->mc identified tracks;
26  if (mcTrackId < 0 || mcTrackId >= mcTrackArray->GetEntriesFast()) continue;
27 
28  // Find MC track associated with this reconstructed track;
29  PndMCTrack *mctrack = (PndMCTrack *)mcTrackArray->At(mcTrackId);
30 
31  mMcToRcMap.insert(std::pair<PndMCTrack*, FwdMatchCandidate*>(mctrack, rctrack));
32  } //for rc
33 
34  return 0;
35 } // FwdMcTrackMapper::Rebuild()
36 
37 // ---------------------------------------------------------------------------------------
38 
40 {
41  // Get range of matching entries;
42  std::pair <std::multimap<PndMCTrack*, FwdMatchCandidate*>::iterator,
43  std::multimap<PndMCTrack*, FwdMatchCandidate*>::iterator> ret = mMcToRcMap.equal_range(mctrack);
44 
45  // And count them now;
46  unsigned counter = 0;
47 
48  for(std::multimap<PndMCTrack*, FwdMatchCandidate*>::iterator it=ret.first; it != ret.second; it++)
49  counter++;
50 
51  return counter;
52 } // FwdMcTrackMapper::GetRcTrackCount()
53 
54 // ---------------------------------------------------------------------------------------
55 
57 {
58  // Get range of matching entries;
59  std::pair <std::multimap<PndMCTrack*, FwdMatchCandidate*>::iterator,
60  std::multimap<PndMCTrack*, FwdMatchCandidate*>::iterator> range = mMcToRcMap.equal_range(mctrack);
61 
62  // And loop through them now;
63  unsigned counter = 0;
64 
65  for(std::multimap<PndMCTrack*, FwdMatchCandidate*>::iterator it=range.first; it != range.second; it++)
66  if (counter++ == id) return it->second;
67 
68  // 'id' was too big (no this N-th entry in the multimap);
69  return 0;
70 } // FwdMcTrackMapper::GetRcTrack()
71 
72 // ---------------------------------------------------------------------------------------
73