File indexing completed on 2024-12-20 03:14:15
0001 #ifndef SimG4Core_TrackInformation_H
0002 #define SimG4Core_TrackInformation_H
0003
0004 #include "G4VUserTrackInformation.hh"
0005 #include "G4Allocator.hh"
0006 #include "G4Track.hh"
0007 #include "DataFormats/Math/interface/Vector3D.h"
0008 #include "DataFormats/Math/interface/LorentzVector.h"
0009
0010 class TrackInformation : public G4VUserTrackInformation {
0011 public:
0012 TrackInformation() {}
0013 ~TrackInformation() override = default;
0014 inline void *operator new(std::size_t);
0015 inline void operator delete(void *TrackInformation);
0016
0017 bool storeTrack() const { return storeTrack_; }
0018
0019 void setStoreTrack() {
0020 storeTrack_ = true;
0021 isInHistory_ = true;
0022 }
0023
0024 bool isPrimary() const { return isPrimary_; }
0025 void setPrimary(bool v) { isPrimary_ = v; }
0026
0027 bool hasHits() const { return hasHits_; }
0028 void setHasHits(bool v) { hasHits_ = v; }
0029
0030 bool isGeneratedSecondary() const { return isGeneratedSecondary_; }
0031 void setGeneratedSecondary(bool v) { isGeneratedSecondary_ = v; }
0032
0033 bool isInHistory() const { return isInHistory_; }
0034 void putInHistory() { isInHistory_ = true; }
0035
0036 bool isAncestor() const { return flagAncestor_; }
0037 void setAncestor() { flagAncestor_ = true; }
0038
0039 int mcTruthID() const { return mcTruthID_; }
0040 void setMCTruthID(int id) { mcTruthID_ = id; }
0041
0042 int idLastStoredAncestor() const { return idLastStoredAncestor_; }
0043 void setIdLastStoredAncestor(int id) { idLastStoredAncestor_ = id; }
0044
0045
0046 int getIDonCaloSurface() const { return idOnCaloSurface_; }
0047 void setIDonCaloSurface(int id, int ical, int last, int pdgID, double p) {
0048 idOnCaloSurface_ = id;
0049 idCaloVolume_ = ical;
0050 idLastVolume_ = last;
0051 caloSurfaceParticlePID_ = pdgID;
0052 caloSurfaceParticleP_ = p;
0053 }
0054 int getIDCaloVolume() const { return idCaloVolume_; }
0055 int getIDLastVolume() const { return idLastVolume_; }
0056 bool caloIDChecked() const { return caloIDChecked_; }
0057 void setCaloIDChecked(bool f) { caloIDChecked_ = f; }
0058 int caloSurfaceParticlePID() const { return caloSurfaceParticlePID_; }
0059 void setCaloSurfaceParticlePID(int id) { caloSurfaceParticlePID_ = id; }
0060 double caloSurfaceParticleP() const { return caloSurfaceParticleP_; }
0061 void setCaloSurfaceParticleP(double p) { caloSurfaceParticleP_ = p; }
0062
0063
0064 void setCrossedBoundary(const G4Track *track);
0065 bool crossedBoundary() const { return crossedBoundary_; }
0066 const math::XYZTLorentzVectorF &getPositionAtBoundary() const { return positionAtBoundary_; }
0067 const math::XYZTLorentzVectorF &getMomentumAtBoundary() const { return momentumAtBoundary_; }
0068 bool startedInFineVolume() const { return startedInFineVolume_; }
0069 void setStartedInFineVolume(bool flag = true) {
0070 startedInFineVolume_ = flag;
0071 startedInFineVolumeIsSet_ = true;
0072 }
0073 bool startedInFineVolumeIsSet() { return startedInFineVolumeIsSet_; }
0074
0075
0076 int genParticlePID() const { return genParticlePID_; }
0077 void setGenParticlePID(int id) { genParticlePID_ = id; }
0078 double genParticleP() const { return genParticleP_; }
0079 void setGenParticleP(double p) { genParticleP_ = p; }
0080
0081
0082
0083 bool hasCastorHit() const { return hasCastorHit_; }
0084 void setCastorHitPID(const int pid) {
0085 hasCastorHit_ = true;
0086 castorHitPID_ = pid;
0087 }
0088 int getCastorHitPID() const { return castorHitPID_; }
0089
0090
0091
0092 void setFromTtoBTL() { mtdStatus_ |= 1 << 0; }
0093 bool isFromTtoBTL() const { return (mtdStatus_ >> 0) & 1; }
0094 void setFromBTLtoT() { mtdStatus_ |= 1 << 1; }
0095 bool isFromBTLtoT() const { return (mtdStatus_ >> 1) & 1; }
0096 void setBTLlooper() { mtdStatus_ |= 1 << 2; }
0097 bool isBTLlooper() const { return (mtdStatus_ >> 2) & 1; }
0098 void setInTrkFromBackscattering() { mtdStatus_ |= 1 << 3; }
0099 bool isInTrkFromBackscattering() const { return (mtdStatus_ >> 3) & 1; }
0100 void setExtSecondary() { mtdStatus_ |= 1 << 4; }
0101 bool isExtSecondary() const { return (mtdStatus_ >> 4) & 1; }
0102 void setETLfromFront() { mtdStatus_ |= 1 << 5; }
0103 bool isETLfromFront() const { return (mtdStatus_ >> 5) & 1; }
0104 void setETLfromBack() { mtdStatus_ |= 1 << 6; }
0105 bool isETLfromBack() const { return (mtdStatus_ >> 6) & 1; }
0106 uint8_t mtdStatus() const { return mtdStatus_; }
0107
0108 void Print() const override;
0109
0110 private:
0111 bool storeTrack_{false};
0112 bool isPrimary_{false};
0113 bool hasHits_{false};
0114 bool isGeneratedSecondary_{false};
0115 bool isInHistory_{false};
0116 bool flagAncestor_{false};
0117 bool caloIDChecked_{false};
0118 bool crossedBoundary_{false};
0119 bool startedInFineVolume_{false};
0120 bool startedInFineVolumeIsSet_{false};
0121 bool hasCastorHit_{false};
0122 int idLastStoredAncestor_{0};
0123 int idOnCaloSurface_{0};
0124 int idCaloVolume_{-1};
0125 int idLastVolume_{-1};
0126 int genParticlePID_{-1};
0127 int mcTruthID_{-1};
0128 int caloSurfaceParticlePID_{0};
0129 int castorHitPID_{0};
0130 uint8_t mtdStatus_{0};
0131 double genParticleP_{0.};
0132 double caloSurfaceParticleP_{0.};
0133 math::XYZTLorentzVectorF positionAtBoundary_;
0134 math::XYZTLorentzVectorF momentumAtBoundary_;
0135 };
0136
0137 extern G4ThreadLocal G4Allocator<TrackInformation> *fpTrackInformationAllocator;
0138
0139 inline void *TrackInformation::operator new(std::size_t) {
0140 if (!fpTrackInformationAllocator)
0141 fpTrackInformationAllocator = new G4Allocator<TrackInformation>;
0142 return (void *)fpTrackInformationAllocator->MallocSingle();
0143 }
0144
0145 inline void TrackInformation::operator delete(void *trkInfo) {
0146 fpTrackInformationAllocator->FreeSingle((TrackInformation *)trkInfo);
0147 }
0148
0149 #endif