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