Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:25:00

0001 #include "SimG4Core/Notification/interface/TrackInformationExtractor.h"
0002 
0003 #include "G4Track.hh"
0004 
0005 const TrackInformation &TrackInformationExtractor::operator()(const G4Track &gtk) 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   return *tkInfo;
0014 }
0015 
0016 TrackInformation &TrackInformationExtractor::operator()(G4Track &gtk) const {
0017   G4VUserTrackInformation *gui = gtk.GetUserInformation();
0018   TrackInformation *tkInfo = dynamic_cast<TrackInformation *>(gui);
0019   if (gui == nullptr) {
0020     missing(gtk);
0021   } else if (tkInfo == nullptr) {
0022     wrongType();
0023   }
0024   return *tkInfo;
0025 }
0026 
0027 void TrackInformationExtractor::missing(const G4Track &) const {
0028   G4Exception(
0029       "SimG4Core/Notification", "mc001", FatalException, "TrackInformationExtractor: G4Track has no TrackInformation");
0030 }
0031 
0032 void TrackInformationExtractor::wrongType() const {
0033   G4Exception(
0034       "SimG4Core/Notification", "mc001", FatalException, "User information in G4Track is not of TrackInformation type");
0035 }