Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4VTrajectory.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 // G4VTrajectory
0027 //
0028 // Class description:
0029 //
0030 // This class is the abstract base class representing a trajectory of
0031 // a particle being tracked.
0032 // Its concrete class includes information of:
0033 //     1) List of trajectory points composing the trajectory;
0034 //     2) Static information of the particle which generated the trajectory;
0035 //     3) Track ID and parent particle ID of the trajectory.
0036 
0037 // Contact:
0038 //   Questions and comments to this code should be sent to
0039 //     Katsuya Amako  (e-mail: Katsuya.Amako@kek.jp)
0040 //     Makoto  Asai   (e-mail: asai@slac.stanford.edu)
0041 //     Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
0042 // --------------------------------------------------------------------
0043 #ifndef G4VTrajectory_hh
0044 #define G4VTrajectory_hh 1
0045 
0046 #include "G4ThreeVector.hh"
0047 #include "globals.hh"
0048 
0049 #include <map>
0050 #include <vector>
0051 #include <memory>
0052 
0053 class G4Step;
0054 class G4VTrajectoryPoint;
0055 class G4AttDef;
0056 class G4AttValue;
0057 
0058 class G4VTrajectory
0059 {
0060  public:
0061   // Constructor/Destrcutor
0062   G4VTrajectory() = default;
0063   virtual ~G4VTrajectory() = default;
0064 
0065   // Equality operator
0066   G4bool operator==(const G4VTrajectory& right) const;
0067 
0068   // Cloning with the master thread allocator
0069   // Each concrete class should implement its own method.
0070   // This method is used only in the sub-event parallel mode.
0071   virtual G4VTrajectory* CloneForMaster() const;
0072 
0073   // Accessors
0074   virtual G4int GetTrackID() const = 0;
0075   virtual G4int GetParentID() const = 0;
0076   virtual G4String GetParticleName() const = 0;
0077 
0078   // Charge is that of G4DynamicParticle
0079   virtual G4double GetCharge() const = 0;
0080 
0081   // Zero will be returned if the particle does not have PDG code.
0082   virtual G4int GetPDGEncoding() const = 0;
0083 
0084   // Momentum at the origin of the track in global coordinate system
0085   virtual G4ThreeVector GetInitialMomentum() const = 0;
0086 
0087   // Returns the number of trajectory points
0088   virtual G4int GetPointEntries() const = 0;
0089 
0090   // Returns i-th trajectory point
0091   virtual G4VTrajectoryPoint* GetPoint(G4int i) const = 0;
0092 
0093   // Converts attributes in trajectory (and trajectory point if
0094   // needed) to ostream. A default implementation in this base class
0095   // may be used or may be overridden in the concrete class. Note:
0096   // the user needs to follow with new-line or end-of-string,
0097   // depending on the nature of os
0098   virtual void ShowTrajectory(std::ostream& os = G4cout) const;
0099 
0100   // Draw the trajectory. A default implementation in this base
0101   // class may be used or may be overridden in the concrete class
0102   virtual void DrawTrajectory() const;
0103 
0104   // If implemented by a derived class, returns a pointer to a map of
0105   // attribute definitions for the attribute values below. The user
0106   // must test the validity of this pointer. See G4Trajectory for an
0107   // example of a concrete implementation of this method
0108   virtual const std::map<G4String, G4AttDef>* GetAttDefs() const { return nullptr; }
0109 
0110   // If implemented by a derived class, returns a pointer to a list
0111   // of attribute values suitable, e.g., for picking. Each must
0112   // refer to an attribute definition in the above map; its name is
0113   // the key. The user must test the validity of this pointer (it
0114   // must be non-zero and conform to the G4AttDefs, which may be
0115   // checked with G4AttCheck) and delete the list after use. See
0116   // G4Trajectory for an example of a concrete implementation of this
0117   // method and G4VTrajectory::ShowTrajectory for an example of its use.
0118   // The caller is expected to take ownership of the returned pointer
0119   // and delete it appropriately.
0120   virtual std::vector<G4AttValue>* CreateAttValues() const { return nullptr; }
0121   
0122   // Smart access function - creates on request and stores for future
0123   // access. An invalid shared pointer means "not available". Usage:
0124   //   const auto trajectoryAttValues = aTrajectory.GetAttValues();
0125   //   if (trajectoryAttValues) { ...
0126   // then use as a normal pointer, but do not delete - simply allow
0127   // to go out of scope.
0128   std::shared_ptr<std::vector<G4AttValue>> GetAttValues() const;
0129 
0130   // Methods invoked exclusively by G4TrackingManager
0131   virtual void AppendStep(const G4Step* aStep) = 0;
0132   virtual void MergeTrajectory(G4VTrajectory* secondTrajectory) = 0;
0133 
0134 protected:
0135   G4VTrajectory(const G4VTrajectory& right) = default;
0136   G4VTrajectory& operator=(const G4VTrajectory& right) = default;
0137   G4VTrajectory(G4VTrajectory&&) = default;
0138   G4VTrajectory& operator=(G4VTrajectory&&) = default;
0139 
0140 private:
0141   // Cached att values
0142   mutable std::shared_ptr<std::vector<G4AttValue>> fpAttValues;
0143 };
0144 
0145 #endif