CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 "G4ErrorPropagatorManager.hh"
12 #include "G4ErrorSurfaceTarget.hh"
13 #include "G4ErrorPropagatorData.hh"
14 
21 
22 public:
28  Geant4ePropagator(const MagneticField* field = 0, std::string particleName =
30 
31  virtual ~Geant4ePropagator() override;
32 
36 /*
37  virtual TrajectoryStateOnSurface
38  propagate(const FreeTrajectoryState& ftsStart, const Plane& pDest) const override;
39 
40  virtual TrajectoryStateOnSurface
41  propagate(const FreeTrajectoryState& ftsStart, const Cylinder& cDest) const override;
42 */
46 /*
47  virtual TrajectoryStateOnSurface
48  propagate(const TrajectoryStateOnSurface& tsos, const Plane& plane) const override;
49 
50  virtual TrajectoryStateOnSurface
51  propagate(const TrajectoryStateOnSurface& tsos, const Cylinder& cyl) const override;
52 */
60  virtual std::pair<TrajectoryStateOnSurface, double>
61  propagateWithPath(const FreeTrajectoryState&, const Plane&) const override;
62 
63  virtual std::pair<TrajectoryStateOnSurface, double>
64  propagateWithPath(const FreeTrajectoryState&, const Cylinder&) const override;
65 
66  virtual std::pair<TrajectoryStateOnSurface, double>
67  propagateWithPath(const TrajectoryStateOnSurface&, const Plane&) const override;
68 
69  virtual std::pair<TrajectoryStateOnSurface, double>
70  propagateWithPath(const TrajectoryStateOnSurface&, const Cylinder&) const override;
71 
72  virtual Geant4ePropagator* clone() const override {
73  return new Geant4ePropagator(*this);
74  }
75 
76  virtual const MagneticField* magneticField() const override {
77  return theField;
78  }
79 
80 private:
81 
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 propagation
96  template <class SurfaceType>
97  ErrorTargetPair transformToG4SurfaceTarget( const SurfaceType& pDest, bool moveTargetToEndOfSurface ) const;
98 
99  // generates the Geant4 name for a particle from the
100  // string stored in theParticleName ( set via constructor )
101  // and the particle charge.
102  // 'mu' as a basis for muon becomes 'mu+' or 'mu-', depening on the charge
103  // This method only supports neutral and +/- 1e charges so far
104  //
105  // returns the generated string
107 
108  // flexible method which performs the actual propagation either for a plane or cylinder
109  // surface type
110  //
111  // returns TSOS after the propagation and the path length
112  template <class SurfaceType>
113  std::pair<TrajectoryStateOnSurface, double>
114  propagateGeneric(const FreeTrajectoryState& ftsStart, const SurfaceType& pDest) const;
115 
116  // saves the Geant4 propagation direction (Forward or Backward) in the provided variable
117  // reference mode and returns true if the propagation direction could be set
118  template <class SurfaceType>
119  bool configurePropagation ( G4ErrorMode & mode, SurfaceType const& pDest,
120  GlobalPoint const& cmsInitPos,GlobalVector const& cmsInitMom ) const;
121 
122  // special case to determine the propagation direction if the CMS propagation direction 'anyDirection'
123  // was set.
124  // This method is called by configurePropagation and provides specific implementations for Plane
125  // and Cylinder classes
126  template <class SurfaceType>
127  bool configureAnyPropagation ( G4ErrorMode & mode, SurfaceType const& pDest,
128  GlobalPoint const& cmsInitPos,
129  GlobalVector const& cmsInitMom ) const;
130 
131  // Ensure Geant4 Error propagation is initialized, if not done so, yet
132  // if the forceInit parameter is set to true, the initialization is performed,
133  // even if already done before.
134  // This can be necessary, when Geant4 needs to read in a new MagneticField object,
135  // which changed during lumi section crossing
136  void ensureGeant4eIsInitilized( bool forceInit ) const;
137 
138  // returns the name of the SurfaceType. Mostly for debug outputs
139  template < class SurfaceType >
140  std::string getSurfaceType ( SurfaceType const& surface) const;
141 
142  void debugReportPlaneSetup ( GlobalPoint const& posPlane, HepGeom::Point3D<double> const& surfPos,
143  GlobalVector const& normalPlane, HepGeom::Normal3D<double> const& surfNorm,
144  const Plane& pDest ) const;
145 
146  template <class SurfaceType>
147  void debugReportTrackState ( std::string const& currentContext, GlobalPoint const& cmsInitPos,
148  CLHEP::Hep3Vector const& g4InitPos,
149  GlobalVector const& cmsInitMom, CLHEP::Hep3Vector const& g4InitMom,
150  const SurfaceType& pDest) const;
151 };
152 
153 #endif
std::pair< TrajectoryStateOnSurface, double > TsosPP
virtual const MagneticField * magneticField() const override
Geant4ePropagator(const MagneticField *field=0, std::string particleName="mu", PropagationDirection dir=alongMomentum)
virtual Geant4ePropagator * clone() const override
void debugReportPlaneSetup(GlobalPoint const &posPlane, HepGeom::Point3D< double > const &surfPos, GlobalVector const &normalPlane, HepGeom::Normal3D< double > const &surfNorm, const Plane &pDest) const
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Plane &) const override
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< TrajectoryStateOnSurface, double > propagateGeneric(const FreeTrajectoryState &ftsStart, const SurfaceType &pDest) const
virtual ~Geant4ePropagator() override
ErrorTargetPair transformToG4SurfaceTarget(const SurfaceType &pDest, bool moveTargetToEndOfSurface) const
std::string getSurfaceType(SurfaceType const &surface) const
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
void ensureGeant4eIsInitilized(bool forceInit) const
std::pair< bool, std::shared_ptr< G4ErrorTarget > > ErrorTargetPair