CMS 3D CMS Logo

TrackInformationExtractor.cc
Go to the documentation of this file.
2 
3 #include "G4Track.hh"
4 
5 const TrackInformation &TrackInformationExtractor::operator()(const G4Track &gtk) const {
6  G4VUserTrackInformation *gui = gtk.GetUserInformation();
7  const TrackInformation *tkInfo = dynamic_cast<const TrackInformation *>(gui);
8  if (gui == nullptr) {
9  missing(gtk);
10  } else if (tkInfo == nullptr) {
11  wrongType();
12  }
13  return *tkInfo;
14 }
15 
17  G4VUserTrackInformation *gui = gtk.GetUserInformation();
18  TrackInformation *tkInfo = dynamic_cast<TrackInformation *>(gui);
19  if (gui == nullptr) {
20  missing(gtk);
21  } else if (tkInfo == nullptr) {
22  wrongType();
23  }
24  return *tkInfo;
25 }
26 
27 void TrackInformationExtractor::missing(const G4Track &) const {
28  G4Exception(
29  "SimG4Core/Notification", "mc001", FatalException, "TrackInformationExtractor: G4Track has no TrackInformation");
30 }
31 
33  G4Exception(
34  "SimG4Core/Notification", "mc001", FatalException, "User information in G4Track is not of TrackInformation type");
35 }
void missing(const G4Track &gtk) const
const TrackInformation & operator()(const G4Track &gtk) const