ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4TrackUserInfoV1.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4TrackUserInfoV1.cc
1 #include "PHG4TrackUserInfoV1.h"
2 
3 #include <Geant4/G4Track.hh>
4 #include <Geant4/G4VUserTrackInformation.hh> // for G4VUserTrackInformation
5 
6 #include <boost/lexical_cast.hpp>
7 
8 #include <iostream> // for operator<<, basic_ostream, endl, cout
9 #include <string> // for string, operator<<
10 
11 namespace PHG4TrackUserInfo
12 {
13  void SetUserTrackId(G4Track* track, const int usertrackid)
14  {
16  {
17  // User info exists, test it for something valid
18  if (PHG4TrackUserInfoV1* pp = dynamic_cast<PHG4TrackUserInfoV1*>(p))
19  {
20  pp->SetUserTrackId(usertrackid);
21  }
22  else
23  {
24  std::cout << "Unknown UserTrackInformation stored in track number "
25  << boost::lexical_cast<std::string>(track->GetTrackID())
26  << std::endl;
27  }
28  }
29  else
30  {
31  // User info does not exist, add it.
33  pp->SetUserTrackId(usertrackid);
34  track->SetUserInformation(pp);
35  }
36  }
37 
38  void SetUserParentId(G4Track* track, const int userparentid)
39  {
41  {
42  // User info exists, test it for something valid
43  if (PHG4TrackUserInfoV1* pp = dynamic_cast<PHG4TrackUserInfoV1*>(p))
44  {
45  pp->SetUserParentId(userparentid);
46  }
47  else
48  {
49  std::cout << "Unknown UserTrackInformation stored in track number "
50  << boost::lexical_cast<std::string>(track->GetTrackID())
51  << std::endl;
52  }
53  }
54  else
55  {
56  // User info does not exist, add it.
58  pp->SetUserParentId(userparentid);
59  track->SetUserInformation(pp);
60  }
61  }
62 
63  void SetUserPrimaryId(G4Track* track, const int userprimaryid)
64  {
66  {
67  // User info exists, test it for something valid
68  if (PHG4TrackUserInfoV1* pp = dynamic_cast<PHG4TrackUserInfoV1*>(p))
69  {
70  pp->SetUserPrimaryId(userprimaryid);
71  }
72  else
73  {
74  std::cout << "Unknown UserTrackInformation stored in track number "
75  << boost::lexical_cast<std::string>(track->GetTrackID())
76  << std::endl;
77  }
78  }
79  else
80  {
81  // User info does not exist, add it.
83  pp->SetUserPrimaryId(userprimaryid);
84  track->SetUserInformation(pp);
85  }
86  }
87 
88  void SetWanted(G4Track* track, const int trkid)
89  {
91  {
92  // User info exists, test it for something valid
93  if (PHG4TrackUserInfoV1* pp = dynamic_cast<PHG4TrackUserInfoV1*>(p))
94  {
95  pp->SetWanted(trkid);
96  }
97  else
98  {
99  std::cout << "Unknown UserTrackInformation stored in track number "
100  << boost::lexical_cast<std::string>(track->GetTrackID())
101  << std::endl;
102  }
103  }
104  else
105  {
106  // User info does not exist, add it.
108  pp->SetWanted(trkid);
109  track->SetUserInformation(pp);
110  }
111  }
112 
113  void SetKeep(G4Track* track, const int trkid)
114  {
116  {
117  // User info exists, test it for something valid
118  if (PHG4TrackUserInfoV1* pp = dynamic_cast<PHG4TrackUserInfoV1*>(p))
119  {
120  pp->SetKeep(trkid);
121  }
122  else
123  {
124  std::cout << "Unknown UserTrackInformation stored in track number "
125  << boost::lexical_cast<std::string>(track->GetTrackID())
126  << std::endl;
127  }
128  }
129  else
130  {
131  // User info does not exist, add it.
133  pp->SetKeep(trkid);
134  track->SetUserInformation(pp);
135  }
136  }
137 
139  {
141  {
142  // User info exists, test it for something valid
143  if (PHG4TrackUserInfoV1* pp = dynamic_cast<PHG4TrackUserInfoV1*>(p))
144  {
145  pp->SetShower(shower);
146  }
147  else
148  {
149  std::cout << "Unknown UserTrackInformation stored in track number "
150  << boost::lexical_cast<std::string>(track->GetTrackID())
151  << std::endl;
152  }
153  }
154  else
155  {
156  // User info does not exist, add it.
158  pp->SetShower(shower);
159  track->SetUserInformation(pp);
160  }
161  }
162 
163 } // namespace PHG4TrackUserInfo