#ifndef TG4HitSegment_hxx_seen #define TG4HitSegment_hxx_seen #include #include "IG4VHit.hxx" #include "IG4Trajectory.hxx" #include "IHandle.hxx" #include namespace COMET { class IG4HitSegment; class ITrackIDMap; } /// DO NOT USE THIS CLASS IN ANALYSIS CODE. /// /// This is a base class used to save G4Hit objects into a root output file. /// It contains the global position of the starting point and stopping point /// of the track segment that created the hit, plus the fields provided by /// IG4VHit. The SIMG4 expects the electronics response to be simulated /// off-line, and to assign the sensor identifiers to each hit. /// /// In the SIMG4, this class is multiply inherited with COMETHitSegment to /// implement a G4VHit derived class that can be used in a G4HitCollection. /// The behavior is designed so that IG4HitSegment contains all of the payload /// for the hit, and COMETHitSegment contains all of the interface related to /// the G4 infrastructure. class COMET::IG4HitSegment: public IG4VHit { public: IG4HitSegment(); IG4HitSegment(const IG4HitSegment& rhs); virtual ~IG4HitSegment(); /// Impose a new mapping from old primary track id to new primary track id /// Technically a setter function... virtual void MapTrackIDs(ITrackIDMap* aMap); /// Return a list of track identifiers that contributed to this hit. /// These track ids can be used as indicies to find trajectories in the /// IG4TrajectoryContainer object associated with an MC event. const std::vector& GetContributors(void) const { return fContributors; } /// The average X position of the hit segment double GetPosX(void) const {return (fStartX + fStopX)/2.;} /// The average Y position of the hit segment double GetPosY(void) const {return (fStartY + fStopY)/2.;} /// The average Z position of the hit segment double GetPosZ(void) const {return (fStartZ + fStopZ)/2.;} /// The average time of the hit segment double GetPosT(void) const {return (fStartT + fStopT)/2.;} /// Get the tota energy deposited in this hit. double GetEnergyDeposit(void) const {return (double) fEnergyDeposit;} /// Get the total charged track length in this hit. This includes all of /// the contributions from secondary particles that got lumped into this /// hit (e.g. the contributions from delta-rays). double GetTrackLength(void) const {return (double) fTrackLength;} /// The X position of the hit starting point. Note that a hit by /// definition is in a single volume. If the hit is spread over two /// volumes, it's a result of round-off error (and is almost a bug). The /// GeoNodeId should be defined by the average position of the hit. double GetStartX(void) const {return fStartX;} /// The Y position of the hit starting point. Note that a hit by /// definition is in a single volume. If the hit is spread over two /// volumes, it's a result of round-off error (and is almost a bug). The /// GeoNodeId should be defined by the average position of the hit. double GetStartY(void) const {return fStartY;} /// The Z position of the hit starting point. Note that a hit by /// definition is in a single volume. If the hit is spread over two /// volumes, it's a result of round-off error (and is almost a bug). The /// GeoNodeId should be defined by the average position of the hit. double GetStartZ(void) const {return fStartZ;} /// The time of the hit starting point. Note that a hit by /// definition is in a single volume. If the hit is spread over two /// volumes, it's a result of round-off error (and is almost a bug). The /// GeoNodeId should be defined by the average position of the hit. double GetStartT(void) const {return fStartT;} /// The X position of the hit stopping point. Note that a hit by /// definition is in a single volume. If the hit is spread over two /// volumes, it's a result of round-off error (and is almost a bug). The /// GeoNodeId should be defined by the average position of the hit. double GetStopX(void) const {return fStopX;} /// The Y position of the hit stopping point. Note that a hit by /// definition is in a single volume. If the hit is spread over two /// volumes, it's a result of round-off error (and is almost a bug). The /// GeoNodeId should be defined by the average position of the hit. double GetStopY(void) const {return fStopY;} /// The Z position of the hit stopping point. Note that a hit by /// definition is in a single volume. If the hit is spread over two /// volumes, it's a result of round-off error (and is almost a bug). The /// GeoNodeId should be defined by the average position of the hit. double GetStopZ(void) const {return fStopZ;} /// The time of the hit stopping point. Note that a hit by /// definition is in a single volume. If the hit is spread over two /// volumes, it's a result of round-off error (and is almost a bug). The /// GeoNodeId should be defined by the average position of the hit. double GetStopT(void) const {return fStopT;} /// The id of track which mainly contributes this HitSegment int GetTrackId(void) const {return fTrackId;} /// The X component of the momentum vector of the track /// at the hit starting point double GetMomentumX(void) const {return fMomentumX;} /// The Y component of the momentum vector of the track /// at the hit starting point double GetMomentumY(void) const {return fMomentumY;} /// The Z component of the momentum vector of the track /// at the hit starting point double GetMomentumZ(void) const {return fMomentumZ;} /// The magnitude of the momentum double GetMomentumMag(void) const {return TVector3(fMomentumX, fMomentumY, fMomentumZ).Mag();} /// The pre and post step points of each G4Step that was /// merged into this hit in SimG4. const std::vector& GetHitSteps(void) const {return fStep;}; /// Return a trajectory that contributed to this hit /// /// The contributor argument can be used to select which trajectory in the /// list of contributors (fContributors) is returned, so: /// contributor < fContributors.size() /// If contributor == -1, the primary trajectory (with track ID = /// GetPrimaryId()) will be returned. /// /// The returned handle should be checked for NULL in case the trajectory /// wasn't written out for this event. const COMET::IHandle GetTrajectory(int contributor)const; /// Function that returns the first trajectory on the list of contributors. /// This function overloads the base IG4VHit::GetTrajectory(void) function /// to return the previous default option for /// IG4HitSegment::GetTrajectory(int) function. Previously, this default /// was defined as: /// /// IG4HitSegment::GetTrajectory(int contributors=0) /// /// whereas the IG4VHit::GetTrajectory(void) returns: /// /// IG4HitSegement::GetTrajectory(fPrimaryId) /// /// Since IG4VHit::GetTrajectory(void) was added after the /// IG4HitSegement::GetTrajectory(int) function, this is somewhat messy. const COMET::IHandle GetTrajectory()const {return GetTrajectory(0);} /// The PDG code of particle int GetPDGEncoding(void) const {return fPDGEncoding;} /// Print the hit information. virtual void ls(Option_t * = "") const; protected: /// The function to add each G4step into fStep in this hit. inline void AddG4Step(double x, double y, double z) { fStep.push_back(TVector3(x,y,z)); } protected: /// The TrackID for each trajectory that contributed to this hit. This /// could contain the TrackID of the primary particle, but not /// necessarily. std::vector fContributors; /// The total energy deposit in this hit. Float_t fEnergyDeposit; /// The total charged track length in this hit. This includes the /// contribution from all of the secondary particles (e.g. delta-rays) /// that are included in this hit. Float_t fTrackLength; /// The X position of the hit starting point. Float_t fStartX; /// The Y position of the hit starting point. Float_t fStartY; /// The Z position of the hit starting point. Float_t fStartZ; /// The time of the hit starting point. Float_t fStartT; /// The X position of the hit stopping point. Float_t fStopX; /// The Y position of the hit stopping point. Float_t fStopY; /// The Z position of the hit stopping point. Float_t fStopZ; /// The time of the hit stopping point. Float_t fStopT; /// The track id of this particle. Int_t fTrackId; /// The X momentum of the hit starting point. Float_t fMomentumX; /// The Y momentum of the hit starting point. Float_t fMomentumY; /// The Z momentum of the hit starting point. Float_t fMomentumZ; /// The end points of the steps that make up this hit. std::vector fStep; /// The PDG id of this particle. Int_t fPDGEncoding; ClassDef(IG4HitSegment,7); }; #endif