EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EicBlackHole.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EicBlackHole.cxx
1 //
2 // AYK (ayk@bnl.gov), 2015/08/06;
3 //
4 // Parent-hierarchy-related class; see the codes below for more details;
5 //
6 
7 #include <TParticle.h>
8 #include <TVirtualMC.h>
9 
10 #include <PndStack.h>
11 
12 #include <EicBlackHole.h>
13 
14 std::set<unsigned> *EicBlackHole::mTracks = new std::set<unsigned>();
15 
16 // ---------------------------------------------------------------------------------------
17 
18 std::pair<int, int> EicBlackHole::GetParentIDs()
19 {
20  // First track in the predecessor chain which entered any of
21  // the "black hole" volumes; undefined per default;
22  int lowestBlackVolumeTrackID = -1;
23 
24  // This call is cheap; do not mind to perform twice (see ProcessHits());
25  int trackID = gMC->GetStack()->GetCurrentTrackNumber();
26 
27  //printf(" investigating track #%5d ...\n", trackID);
28  // Assume can not get stuck in an infinite loop;
29  for( ; ; )
30  {
31  TParticle *particle = ((PndStack*)gMC->GetStack())->GetParticle(trackID);
32 
33  if (EicBlackHole::IsInTrackList(trackID)) lowestBlackVolumeTrackID = trackID;
34 
35  //printf(" %5d (%d); %d\n", trackID, particle->IsPrimary(), EicBlackHole::IsInTrackList(trackID));
36 
37  // Reached a true primary particle in the parent list; return this ID unless
38  // there was a track entering "black hole" volume in the chain;
39  if (particle->IsPrimary()) {
40  //printf(" ret: %5d %5d ... %5d\n", trackID, lowestBlackVolumeTrackID == -1 ?
41  // trackID : lowestBlackVolumeTrackID, lowestBlackVolumeTrackID);
42  return std::pair<int,int>(trackID, lowestBlackVolumeTrackID == -1 ?
43  trackID : lowestBlackVolumeTrackID);
44  } //if
45 
46  trackID = particle->GetFirstMother();
47  particle = ((PndStack*)gMC->GetStack())->GetParticle(trackID);
48  } //for inf
49 } // EicBlackHole::GetParentIDs()
50 
51 // ---------------------------------------------------------------------------------------