Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 07:50:29

0001 #pragma once
0002 /**
0003 Deprecated_U4PhotonInfo.h
0004 =============================
0005 
0006 Carries spho.h photon label, which comprises 4 int indices. 
0007 
0008 This is replaced by the templated U4TrackInfo which 
0009 maintains more separation between Geant4 TrackInfo 
0010 mechanics and the details of the info carried in the label. 
0011 
0012 
0013 **/
0014 
0015 #include <string>
0016 #include "spho.h"
0017 #include "G4Track.hh"
0018 #include "G4VUserTrackInformation.hh"
0019 
0020 struct Deprecated_U4PhotonInfo : public G4VUserTrackInformation
0021 {
0022     spho pho ; 
0023 
0024     Deprecated_U4PhotonInfo(const spho& _pho); 
0025     std::string desc() const ; 
0026 
0027     static bool Exists(const G4Track* track); 
0028     static spho  Get(   const G4Track* track);   // by value 
0029     static spho* GetRef(const G4Track* track);   // by reference, allowing inplace changes
0030 
0031     static int GetIndex(const  G4Track* track);
0032     static void Set(G4Track* track, const spho& pho_ ); 
0033 };
0034 
0035 inline Deprecated_U4PhotonInfo::Deprecated_U4PhotonInfo(const spho& _pho )
0036     :   
0037     G4VUserTrackInformation("Deprecated_U4PhotonInfo"),
0038     pho(_pho)
0039 {
0040 }
0041  
0042 inline std::string Deprecated_U4PhotonInfo::desc() const 
0043 {
0044     std::stringstream ss ; 
0045     ss << *pType << " " << pho.desc() ; 
0046     std::string s = ss.str(); 
0047     return s ; 
0048 }
0049 
0050 inline bool Deprecated_U4PhotonInfo::Exists(const G4Track* track)
0051 {
0052     G4VUserTrackInformation* ui = track->GetUserInformation() ;
0053     Deprecated_U4PhotonInfo* pin = ui ? dynamic_cast<Deprecated_U4PhotonInfo*>(ui) : nullptr ;
0054     return pin != nullptr ; 
0055 }
0056 
0057 inline spho Deprecated_U4PhotonInfo::Get(const G4Track* track) // by value 
0058 {
0059     G4VUserTrackInformation* ui = track->GetUserInformation() ;
0060     Deprecated_U4PhotonInfo* pin = ui ? dynamic_cast<Deprecated_U4PhotonInfo*>(ui) : nullptr ;
0061     return pin ? pin->pho : spho::Placeholder() ; 
0062 }
0063 
0064 inline spho* Deprecated_U4PhotonInfo::GetRef(const G4Track* track) // by value 
0065 {
0066     G4VUserTrackInformation* ui = track->GetUserInformation() ;
0067     Deprecated_U4PhotonInfo* pin = ui ? dynamic_cast<Deprecated_U4PhotonInfo*>(ui) : nullptr ;
0068     return pin ? &(pin->pho) : nullptr ; 
0069 }
0070 
0071 inline int Deprecated_U4PhotonInfo::GetIndex(const G4Track* track)
0072 {
0073     spho label = Get(track); 
0074     return label.id ;  
0075 }
0076 
0077 inline void Deprecated_U4PhotonInfo::Set(G4Track* track, const spho& pho_ )
0078 {
0079     track->SetUserInformation(new Deprecated_U4PhotonInfo(pho_)); 
0080     // hmm: seems expensive if already has the label 
0081 }
0082