Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:15:37

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4RichTrajectory
0027 //
0028 // Class description:
0029 //
0030 // This class extends G4Trajectory, which includes the following:
0031 //   1) List of trajectory points which compose the trajectory,
0032 //   2) static information of particle which generated the
0033 //      trajectory,
0034 //   3) trackID and parent particle ID of the trajectory.
0035 // The extended information, only publicly accessible through AttValues,
0036 // includes:
0037 //   4) physical volume and next physical volume;
0038 //   5) creator process;
0039 // ...and much more.
0040 
0041 // Contact:
0042 //   Questions and comments on G4Trajectory should be sent to
0043 //     Katsuya Amako  (e-mail: Katsuya.Amako@kek.jp)
0044 //     Makoto  Asai   (e-mail: asai@slac.stanford.edu)
0045 //     Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
0046 //   and on the extended code to:
0047 //     John Allison   (e-mail: John.Allison@manchester.ac.uk)
0048 //     Joseph Perl    (e-mail: perl@slac.stanford.edu)
0049 // --------------------------------------------------------------------
0050 #ifndef G4RICHTRAJECTORY_HH
0051 #define G4RICHTRAJECTORY_HH
0052 
0053 #include "G4TouchableHandle.hh"
0054 #include "G4VTrajectory.hh"
0055 #include "G4ParticleDefinition.hh"  // Include from 'particle+matter'
0056 #include "G4Step.hh"
0057 #include "G4Track.hh"
0058 #include "G4RichTrajectoryPoint.hh"  // Include from 'tracking'
0059 #include "G4ios.hh"  // Include from 'system'
0060 #include "globals.hh"  // Include from 'global'
0061 
0062 #include "trkgdefs.hh"
0063 #include <stdlib.h>  // Include from 'system'
0064 
0065 #include <vector>
0066 
0067 class G4Polyline;
0068 class G4ClonedRichTrajectory;
0069 
0070 class G4RichTrajectory : public G4VTrajectory
0071 {
0072   using G4TrajectoryPointContainer = std::vector<G4VTrajectoryPoint*>;
0073 
0074   friend class G4ClonedRichTrajectory;
0075 
0076  public:
0077   // Constructors/destructor
0078   //
0079   G4RichTrajectory() = default;
0080   G4RichTrajectory(const G4Track* aTrack);
0081   ~G4RichTrajectory() override;
0082   G4RichTrajectory(G4RichTrajectory&);
0083   G4RichTrajectory& operator=(const G4RichTrajectory&) = delete;
0084 
0085   // Operators
0086   //
0087   G4bool operator==(const G4RichTrajectory& r) const { return (this == &r); }
0088 
0089   inline void* operator new(size_t);
0090   inline void operator delete(void*);
0091 
0092   // cloning with the master thread allocator
0093   G4VTrajectory* CloneForMaster() const override;
0094 
0095   // Get/Set functions
0096 
0097   inline G4int GetTrackID() const override { return fTrackID; }
0098   inline G4int GetParentID() const override { return fParentID; }
0099   inline G4String GetParticleName() const override { return ParticleName; }
0100   inline G4double GetCharge() const override { return PDGCharge; }
0101   inline G4int GetPDGEncoding() const override { return PDGEncoding; }
0102   inline G4double GetInitialKineticEnergy() const { return initialKineticEnergy; }
0103   inline G4ThreeVector GetInitialMomentum() const override { return initialMomentum; }
0104 
0105   // Other (virtual) member functions
0106   //
0107   void ShowTrajectory(std::ostream& os = G4cout) const override;
0108   void DrawTrajectory() const override;
0109   void AppendStep(const G4Step* aStep) override;
0110   void MergeTrajectory(G4VTrajectory* secondTrajectory) override;
0111   inline G4int GetPointEntries() const override;
0112   inline G4VTrajectoryPoint* GetPoint(G4int i) const override;
0113 
0114   G4ParticleDefinition* GetParticleDefinition();
0115 
0116   // Get methods for HepRep style attributes
0117   //
0118   const std::map<G4String, G4AttDef>* GetAttDefs() const override;
0119   std::vector<G4AttValue>* CreateAttValues() const override;
0120 
0121  private:
0122   G4TrajectoryPointContainer* positionRecord = nullptr;
0123   G4int fTrackID = 0;
0124   G4int fParentID = 0;
0125   G4int PDGEncoding = 0;
0126   G4double PDGCharge = 0.0;
0127   G4String ParticleName = "dummy";
0128   G4double initialKineticEnergy = 0.0;
0129   G4ThreeVector initialMomentum;
0130 
0131   // Extended information (only publicly accessible through AttValues)...
0132   //
0133   G4TrajectoryPointContainer* fpRichPointContainer = nullptr;
0134   G4TouchableHandle fpInitialVolume;
0135   G4TouchableHandle fpInitialNextVolume;
0136   const G4VProcess* fpCreatorProcess = nullptr;
0137   G4int fCreatorModelID = 0;
0138   G4TouchableHandle fpFinalVolume;
0139   G4TouchableHandle fpFinalNextVolume;
0140   const G4VProcess* fpEndingProcess = nullptr;
0141   G4double fFinalKineticEnergy = 0.0;
0142 };
0143 
0144 extern G4TRACKING_DLL G4Allocator<G4RichTrajectory>*& aRichTrajectoryAllocator();
0145 
0146 inline void* G4RichTrajectory::operator new(size_t)
0147 {
0148   if (aRichTrajectoryAllocator() == nullptr) {
0149     aRichTrajectoryAllocator() = new G4Allocator<G4RichTrajectory>;
0150   }
0151   return (void*)aRichTrajectoryAllocator()->MallocSingle();
0152 }
0153 
0154 inline void G4RichTrajectory::operator delete(void* aRichTrajectory)
0155 {
0156   aRichTrajectoryAllocator()->FreeSingle((G4RichTrajectory*)aRichTrajectory);
0157 }
0158 
0159 inline G4int G4RichTrajectory::GetPointEntries() const
0160 {
0161   return G4int(fpRichPointContainer->size());
0162 }
0163 
0164 inline G4VTrajectoryPoint* G4RichTrajectory::GetPoint(G4int i) const
0165 {
0166   return (*fpRichPointContainer)[i];
0167 }
0168 
0169 #endif