Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:22:01

0001 #include "PHG4TrackUserInfoV1.h"
0002 
0003 #include <Geant4/G4Track.hh>
0004 #include <Geant4/G4VUserTrackInformation.hh>  // for G4VUserTrackInformation
0005 
0006 #include <iostream>  // for operator<<, basic_ostream, endl, cout
0007 #include <string>    // for string, operator<<
0008 
0009 namespace PHG4TrackUserInfo
0010 {
0011   void SetUserTrackId(G4Track* track, const int usertrackid)
0012   {
0013     if (G4VUserTrackInformation* p = track->GetUserInformation())
0014     {
0015       // User info exists, test it for something valid
0016       if (PHG4TrackUserInfoV1* pp = dynamic_cast<PHG4TrackUserInfoV1*>(p))
0017       {
0018         pp->SetUserTrackId(usertrackid);
0019       }
0020       else
0021       {
0022         std::cout << "Unknown UserTrackInformation stored in track number "
0023                   << track->GetTrackID()
0024                   << std::endl;
0025       }
0026     }
0027     else
0028     {
0029       // User info does not exist, add it.
0030       PHG4TrackUserInfoV1* pp = new PHG4TrackUserInfoV1();
0031       pp->SetUserTrackId(usertrackid);
0032       track->SetUserInformation(pp);
0033     }
0034   }
0035 
0036   void SetUserParentId(G4Track* track, const int userparentid)
0037   {
0038     if (G4VUserTrackInformation* p = track->GetUserInformation())
0039     {
0040       // User info exists, test it for something valid
0041       if (PHG4TrackUserInfoV1* pp = dynamic_cast<PHG4TrackUserInfoV1*>(p))
0042       {
0043         pp->SetUserParentId(userparentid);
0044       }
0045       else
0046       {
0047         std::cout << "Unknown UserTrackInformation stored in track number "
0048                   << track->GetTrackID()
0049                   << std::endl;
0050       }
0051     }
0052     else
0053     {
0054       // User info does not exist, add it.
0055       PHG4TrackUserInfoV1* pp = new PHG4TrackUserInfoV1();
0056       pp->SetUserParentId(userparentid);
0057       track->SetUserInformation(pp);
0058     }
0059   }
0060 
0061   void SetUserPrimaryId(G4Track* track, const int userprimaryid)
0062   {
0063     if (G4VUserTrackInformation* p = track->GetUserInformation())
0064     {
0065       // User info exists, test it for something valid
0066       if (PHG4TrackUserInfoV1* pp = dynamic_cast<PHG4TrackUserInfoV1*>(p))
0067       {
0068         pp->SetUserPrimaryId(userprimaryid);
0069       }
0070       else
0071       {
0072         std::cout << "Unknown UserTrackInformation stored in track number "
0073                   << track->GetTrackID()
0074                   << std::endl;
0075       }
0076     }
0077     else
0078     {
0079       // User info does not exist, add it.
0080       PHG4TrackUserInfoV1* pp = new PHG4TrackUserInfoV1();
0081       pp->SetUserPrimaryId(userprimaryid);
0082       track->SetUserInformation(pp);
0083     }
0084   }
0085 
0086   void SetWanted(G4Track* track, const int trkid)
0087   {
0088     if (G4VUserTrackInformation* p = track->GetUserInformation())
0089     {
0090       // User info exists, test it for something valid
0091       if (PHG4TrackUserInfoV1* pp = dynamic_cast<PHG4TrackUserInfoV1*>(p))
0092       {
0093         pp->SetWanted(trkid);
0094       }
0095       else
0096       {
0097         std::cout << "Unknown UserTrackInformation stored in track number "
0098                   << track->GetTrackID()
0099                   << std::endl;
0100       }
0101     }
0102     else
0103     {
0104       // User info does not exist, add it.
0105       PHG4TrackUserInfoV1* pp = new PHG4TrackUserInfoV1();
0106       pp->SetWanted(trkid);
0107       track->SetUserInformation(pp);
0108     }
0109   }
0110 
0111   void SetKeep(G4Track* track, const int trkid)
0112   {
0113     if (G4VUserTrackInformation* p = track->GetUserInformation())
0114     {
0115       // User info exists, test it for something valid
0116       if (PHG4TrackUserInfoV1* pp = dynamic_cast<PHG4TrackUserInfoV1*>(p))
0117       {
0118         pp->SetKeep(trkid);
0119       }
0120       else
0121       {
0122         std::cout << "Unknown UserTrackInformation stored in track number "
0123                   << track->GetTrackID()
0124                   << std::endl;
0125       }
0126     }
0127     else
0128     {
0129       // User info does not exist, add it.
0130       PHG4TrackUserInfoV1* pp = new PHG4TrackUserInfoV1();
0131       pp->SetKeep(trkid);
0132       track->SetUserInformation(pp);
0133     }
0134   }
0135 
0136   void SetShower(G4Track* track, PHG4Shower* shower)
0137   {
0138     if (G4VUserTrackInformation* p = track->GetUserInformation())
0139     {
0140       // User info exists, test it for something valid
0141       if (PHG4TrackUserInfoV1* pp = dynamic_cast<PHG4TrackUserInfoV1*>(p))
0142       {
0143         pp->SetShower(shower);
0144       }
0145       else
0146       {
0147         std::cout << "Unknown UserTrackInformation stored in track number "
0148                   << track->GetTrackID()
0149                   << std::endl;
0150       }
0151     }
0152     else
0153     {
0154       // User info does not exist, add it.
0155       PHG4TrackUserInfoV1* pp = new PHG4TrackUserInfoV1();
0156       pp->SetShower(shower);
0157       track->SetUserInformation(pp);
0158     }
0159   }
0160 
0161 }  // namespace PHG4TrackUserInfo