File indexing completed on 2024-10-04 22:55:05
0001 #include "SimG4Core/Notification/interface/TrackInformationExtractor.h"
0002
0003 #include "G4Track.hh"
0004
0005 const TrackInformation &TrackInformationExtractor::operator()(const G4Track >k) const {
0006 G4VUserTrackInformation *gui = gtk.GetUserInformation();
0007 const TrackInformation *tkInfo = dynamic_cast<const TrackInformation *>(gui);
0008 if (gui == nullptr) {
0009 missing(gtk);
0010 } else if (tkInfo == nullptr) {
0011 wrongType();
0012 }
0013
0014 [[clang::suppress]] return *tkInfo;
0015 }
0016
0017 TrackInformation &TrackInformationExtractor::operator()(G4Track >k) const {
0018 G4VUserTrackInformation *gui = gtk.GetUserInformation();
0019 TrackInformation *tkInfo = dynamic_cast<TrackInformation *>(gui);
0020 if (gui == nullptr) {
0021 missing(gtk);
0022 } else if (tkInfo == nullptr) {
0023 wrongType();
0024 }
0025
0026 [[clang::suppress]] return *tkInfo;
0027 }
0028
0029 void TrackInformationExtractor::missing(const G4Track &) const {
0030 G4Exception(
0031 "SimG4Core/Notification", "mc001", FatalException, "TrackInformationExtractor: G4Track has no TrackInformation");
0032 }
0033
0034 void TrackInformationExtractor::wrongType() const {
0035 G4Exception(
0036 "SimG4Core/Notification", "mc001", FatalException, "User information in G4Track is not of TrackInformation type");
0037 }