CMS 3D CMS Logo

Geant4ePropagator.h
Go to the documentation of this file.
1 #ifndef TrackPropagation_Geant4ePropagator_h
2 #define TrackPropagation_Geant4ePropagator_h
3 
4 #include <memory>
5 
6 // CMS includes
7 // - Propagator
9 
10 // - Geant4e
11 #include "G4ErrorPropagatorData.hh"
12 #include "G4ErrorPropagatorManager.hh"
13 #include "G4ErrorSurfaceTarget.hh"
14 
20 class Geant4ePropagator : public Propagator {
21 public:
28  Geant4ePropagator(const MagneticField *field = nullptr,
31 
32  ~Geant4ePropagator() override;
33 
37  /*
38  virtual TrajectoryStateOnSurface
39  propagate(const FreeTrajectoryState& ftsStart, const Plane& pDest)
40  const override;
41 
42  virtual TrajectoryStateOnSurface
43  propagate(const FreeTrajectoryState& ftsStart, const Cylinder& cDest)
44  const override;
45  */
49  /*
50  virtual TrajectoryStateOnSurface
51  propagate(const TrajectoryStateOnSurface& tsos, const Plane& plane)
52  const override;
53 
54  virtual TrajectoryStateOnSurface
55  propagate(const TrajectoryStateOnSurface& tsos, const Cylinder& cyl)
56  const override;
57  */
65  std::pair<TrajectoryStateOnSurface, double> propagateWithPath(const FreeTrajectoryState &,
66  const Plane &) const override;
67 
68  std::pair<TrajectoryStateOnSurface, double> propagateWithPath(const FreeTrajectoryState &,
69  const Cylinder &) const override;
70 
71  std::pair<TrajectoryStateOnSurface, double> propagateWithPath(const TrajectoryStateOnSurface &,
72  const Plane &) const override;
73 
74  std::pair<TrajectoryStateOnSurface, double> propagateWithPath(const TrajectoryStateOnSurface &,
75  const Cylinder &) const override;
76 
77  Geant4ePropagator *clone() const override { return new Geant4ePropagator(*this); }
78 
79  const MagneticField *magneticField() const override { return theField; }
80 
81 private:
82  typedef std::pair<TrajectoryStateOnSurface, double> TsosPP;
83  typedef std::pair<bool, std::shared_ptr<G4ErrorTarget>> ErrorTargetPair;
84 
85  // Magnetic field
87 
88  // Name of the particle whose properties will be used in the propagation
90 
91  // The Geant4e manager. Does the real propagation
92  G4ErrorPropagatorManager *theG4eManager;
93  G4ErrorPropagatorData *theG4eData;
94 
95  // Transform a CMS Reco detector surface into a Geant4 Target for the error
96  // propagation
97  template <class SurfaceType>
98  ErrorTargetPair transformToG4SurfaceTarget(const SurfaceType &pDest, bool moveTargetToEndOfSurface) const;
99 
100  // generates the Geant4 name for a particle from the
101  // string stored in theParticleName ( set via constructor )
102  // and the particle charge.
103  // 'mu' as a basis for muon becomes 'mu+' or 'mu-', depening on the charge
104  // This method only supports neutral and +/- 1e charges so far
105  //
106  // returns the generated string
108 
109  // flexible method which performs the actual propagation either for a plane or
110  // cylinder surface type
111  //
112  // returns TSOS after the propagation and the path length
113  template <class SurfaceType>
114  std::pair<TrajectoryStateOnSurface, double> propagateGeneric(const FreeTrajectoryState &ftsStart,
115  const SurfaceType &pDest) const;
116 
117  // saves the Geant4 propagation direction (Forward or Backward) in the
118  // provided variable reference mode and returns true if the propagation
119  // direction could be set
120  template <class SurfaceType>
121  bool configurePropagation(G4ErrorMode &mode,
122  SurfaceType const &pDest,
123  GlobalPoint const &cmsInitPos,
124  GlobalVector const &cmsInitMom) const;
125 
126  // special case to determine the propagation direction if the CMS propagation
127  // direction 'anyDirection' was set. This method is called by
128  // configurePropagation and provides specific implementations for Plane and
129  // Cylinder classes
130  template <class SurfaceType>
131  bool configureAnyPropagation(G4ErrorMode &mode,
132  SurfaceType const &pDest,
133  GlobalPoint const &cmsInitPos,
134  GlobalVector const &cmsInitMom) const;
135 
136  // Ensure Geant4 Error propagation is initialized, if not done so, yet
137  // if the forceInit parameter is set to true, the initialization is performed,
138  // even if already done before.
139  // This can be necessary, when Geant4 needs to read in a new MagneticField
140  // object, which changed during lumi section crossing
141  void ensureGeant4eIsInitilized(bool forceInit) const;
142 
143  // returns the name of the SurfaceType. Mostly for debug outputs
144  template <class SurfaceType>
145  std::string getSurfaceType(SurfaceType const &surface) const;
146 
147  void debugReportPlaneSetup(GlobalPoint const &posPlane,
148  HepGeom::Point3D<double> const &surfPos,
149  GlobalVector const &normalPlane,
150  HepGeom::Normal3D<double> const &surfNorm,
151  const Plane &pDest) const;
152 
153  template <class SurfaceType>
154  void debugReportTrackState(std::string const &currentContext,
155  GlobalPoint const &cmsInitPos,
156  CLHEP::Hep3Vector const &g4InitPos,
157  GlobalVector const &cmsInitMom,
158  CLHEP::Hep3Vector const &g4InitMom,
159  const SurfaceType &pDest) const;
160 };
161 
162 #endif
std::pair< TrajectoryStateOnSurface, double > TsosPP
Geant4ePropagator(const MagneticField *field=0, std::string particleName="mu", PropagationDirection dir=alongMomentum)
void debugReportPlaneSetup(GlobalPoint const &posPlane, HepGeom::Point3D< double > const &surfPos, GlobalVector const &normalPlane, HepGeom::Normal3D< double > const &surfNorm, const Plane &pDest) const
std::string theParticleName
bool configurePropagation(G4ErrorMode &mode, SurfaceType const &pDest, GlobalPoint const &cmsInitPos, GlobalVector const &cmsInitMom) const
PropagationDirection
const MagneticField * theField
Definition: Plane.h:17
G4ErrorPropagatorManager * theG4eManager
G4ErrorPropagatorData * theG4eData
void debugReportTrackState(std::string const &currentContext, GlobalPoint const &cmsInitPos, CLHEP::Hep3Vector const &g4InitPos, GlobalVector const &cmsInitMom, CLHEP::Hep3Vector const &g4InitMom, const SurfaceType &pDest) const
std::pair< bool, std::shared_ptr< G4ErrorTarget > > ErrorTargetPair
std::pair< TrajectoryStateOnSurface, double > propagateGeneric(const FreeTrajectoryState &ftsStart, const SurfaceType &pDest) const
~Geant4ePropagator() override
ErrorTargetPair transformToG4SurfaceTarget(const SurfaceType &pDest, bool moveTargetToEndOfSurface) const
std::string getSurfaceType(SurfaceType const &surface) const
Geant4ePropagator * clone() const override
bool configureAnyPropagation(G4ErrorMode &mode, SurfaceType const &pDest, GlobalPoint const &cmsInitPos, GlobalVector const &cmsInitMom) const
std::string generateParticleName(int charge) const
dbl *** dir
Definition: mlp_gen.cc:35
std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Plane &) const override
void ensureGeant4eIsInitilized(bool forceInit) const
const MagneticField * magneticField() const override