Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-31 22:26:11

0001 #ifndef SimG4Core_G4SimTrack_H
0002 #define SimG4Core_G4SimTrack_H
0003 
0004 #include "DataFormats/Math/interface/Vector3D.h"
0005 #include "DataFormats/Math/interface/LorentzVector.h"
0006 #include "FWCore/Utilities/interface/Exception.h"
0007 #include "SimG4Core/Notification/interface/TrackWithHistory.h"
0008 #include <cmath>
0009 
0010 class G4SimTrack {
0011 public:
0012   G4SimTrack() {}
0013 
0014   G4SimTrack(int iid, int ipart, const math::XYZVectorD& ip, double ie)
0015       : id_(iid),
0016         ipart_(ipart),
0017         ip_(ip),
0018         ie_(ie),
0019         ivert_(-1),
0020         igenpart_(-1),
0021         parentID_(-1),
0022         parentMomentum_(math::XYZVectorD(0., 0., 0.)),
0023         tkSurfacePosition_(math::XYZVectorD(0., 0., 0.)),
0024         tkSurfaceMomentum_(math::XYZTLorentzVectorD(0., 0., 0., 0.)),
0025         crossedBoundary_(false) {}
0026 
0027   G4SimTrack(int iid, int ipart, const math::XYZVectorD& ip, double ie, int iv, int ig, const math::XYZVectorD& ipmom)
0028       : id_(iid),
0029         ipart_(ipart),
0030         ip_(ip),
0031         ie_(ie),
0032         ivert_(iv),
0033         igenpart_(ig),
0034         parentMomentum_(ipmom),
0035         tkSurfacePosition_(math::XYZVectorD(0., 0., 0.)),
0036         tkSurfaceMomentum_(math::XYZTLorentzVectorD(0., 0., 0., 0.)),
0037         crossedBoundary_(false) {}
0038 
0039   G4SimTrack(int iid,
0040              int ipart,
0041              const math::XYZVectorD& ip,
0042              double ie,
0043              int iv,
0044              int ig,
0045              const math::XYZVectorD& ipmom,
0046              const math::XYZVectorD& tkpos,
0047              const math::XYZTLorentzVectorD& tkmom)
0048       : id_(iid),
0049         ipart_(ipart),
0050         ip_(ip),
0051         ie_(ie),
0052         ivert_(iv),
0053         igenpart_(ig),
0054         parentMomentum_(ipmom),
0055         tkSurfacePosition_(tkpos),
0056         tkSurfaceMomentum_(tkmom),
0057         crossedBoundary_(false) {}
0058 
0059   ~G4SimTrack() = default;
0060 
0061   int id() const { return id_; }
0062   int part() const { return ipart_; }
0063   const math::XYZVectorD& momentum() const { return ip_; }
0064   double energy() const { return ie_; }
0065   int ivert() const { return ivert_; }
0066   int igenpart() const { return igenpart_; }
0067   // parent momentum at interaction
0068   const math::XYZVectorD& parentMomentum() const { return parentMomentum_; }
0069   // Information at level of tracker surface
0070   const math::XYZVectorD& trackerSurfacePosition() const { return tkSurfacePosition_; }
0071   const math::XYZTLorentzVectorD& trackerSurfaceMomentum() const { return tkSurfaceMomentum_; }
0072   // parent track ID (only stored if parent momentum at interaction
0073   // is stored, else = -1)
0074   int parentID() const { return parentID_; }
0075 
0076   void copyCrossedBoundaryVars(const TrackWithHistory* track) {
0077     if (track->crossedBoundary()) {
0078       crossedBoundary_ = track->crossedBoundary();
0079       idAtBoundary_ = track->getIDAtBoundary();
0080       positionAtBoundary_ = track->getPositionAtBoundary();
0081       momentumAtBoundary_ = track->getMomentumAtBoundary();
0082     }
0083   }
0084   bool crossedBoundary() const { return crossedBoundary_; }
0085   const math::XYZTLorentzVectorF& getPositionAtBoundary() const { return positionAtBoundary_; }
0086   const math::XYZTLorentzVectorF& getMomentumAtBoundary() const { return momentumAtBoundary_; }
0087   int getIDAtBoundary() const { return idAtBoundary_; }
0088 
0089 private:
0090   int id_;
0091   int ipart_;
0092   math::XYZVectorD ip_;
0093   double ie_;
0094   int ivert_;
0095   int igenpart_;
0096   int parentID_;
0097   math::XYZVectorD parentMomentum_;
0098   math::XYZVectorD tkSurfacePosition_;
0099   math::XYZTLorentzVectorD tkSurfaceMomentum_;
0100   bool crossedBoundary_;
0101   int idAtBoundary_;
0102   math::XYZTLorentzVectorF positionAtBoundary_;
0103   math::XYZTLorentzVectorF momentumAtBoundary_;
0104 };
0105 
0106 #endif