CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
Geant4ePropagator Class Reference

#include <Geant4ePropagator.h>

Inheritance diagram for Geant4ePropagator:
Propagator

Public Member Functions

Geant4ePropagatorclone () const override
 
 Geant4ePropagator (const MagneticField *field=nullptr, std::string particleName="mu", PropagationDirection dir=alongMomentum, double plimit=1.0)
 
const MagneticFieldmagneticField () const override
 
std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const FreeTrajectoryState &, const Cylinder &) const override
 
std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const FreeTrajectoryState &, const Plane &) const override
 
std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const TrajectoryStateOnSurface &, const Cylinder &) const override
 
std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const TrajectoryStateOnSurface &, const Plane &) const override
 
 ~Geant4ePropagator () override
 
- Public Member Functions inherited from Propagator
virtual FreeTrajectoryState propagate (const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const final
 
virtual FreeTrajectoryState propagate (const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest1, const GlobalPoint &pDest2) const final
 
virtual FreeTrajectoryState propagate (const FreeTrajectoryState &ftsStart, const reco::BeamSpot &beamSpot) const final
 
template<typename STA , typename SUR >
TrajectoryStateOnSurface propagate (STA const &state, SUR const &surface) const
 
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const FreeTrajectoryState &, const Surface &) const final
 
virtual std::pair< FreeTrajectoryState, double > propagateWithPath (const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const
 
virtual std::pair< FreeTrajectoryState, double > propagateWithPath (const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest1, const GlobalPoint &pDest2) const
 Propagate to PCA to a line (given by 2 points) given a starting point. More...
 
virtual std::pair< FreeTrajectoryState, double > propagateWithPath (const FreeTrajectoryState &ftsStart, const reco::BeamSpot &beamSpot) const
 Propagate to PCA to a line (given by beamSpot position and slope) given a starting point. More...
 
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const TrajectoryStateOnSurface &tsos, const Surface &sur) const final
 
virtual PropagationDirection propagationDirection () const final
 
 Propagator (PropagationDirection dir=alongMomentum)
 
virtual bool setMaxDirectionChange (float phiMax)
 
virtual void setPropagationDirection (PropagationDirection dir)
 
virtual ~Propagator ()
 

Private Types

typedef std::pair< bool, std::shared_ptr< G4ErrorTarget > > ErrorTargetPair
 
typedef std::pair< TrajectoryStateOnSurface, double > TsosPP
 

Private Member Functions

template<>
bool configureAnyPropagation (G4ErrorMode &mode, Cylinder const &pDest, GlobalPoint const &cmsInitPos, GlobalVector const &cmsInitMom) const
 
template<>
bool configureAnyPropagation (G4ErrorMode &mode, Plane const &pDest, GlobalPoint const &cmsInitPos, GlobalVector const &cmsInitMom) const
 
template<class SurfaceType >
bool configureAnyPropagation (G4ErrorMode &mode, SurfaceType const &pDest, GlobalPoint const &cmsInitPos, GlobalVector const &cmsInitMom) const
 
template<class SurfaceType >
bool configurePropagation (G4ErrorMode &mode, SurfaceType const &pDest, GlobalPoint const &cmsInitPos, GlobalVector const &cmsInitMom) const
 
void debugReportPlaneSetup (GlobalPoint const &posPlane, HepGeom::Point3D< double > const &surfPos, GlobalVector const &normalPlane, HepGeom::Normal3D< double > const &surfNorm, const Plane &pDest) const
 
template<class SurfaceType >
void debugReportTrackState (std::string const &currentContext, GlobalPoint const &cmsInitPos, CLHEP::Hep3Vector const &g4InitPos, GlobalVector const &cmsInitMom, CLHEP::Hep3Vector const &g4InitMom, const SurfaceType &pDest) const
 
void ensureGeant4eIsInitilized (bool forceInit) const
 
std::string generateParticleName (int charge) const
 
template<>
std::string getSurfaceType (Cylinder const &c) const
 
template<>
std::string getSurfaceType (Plane const &c) const
 
template<class SurfaceType >
std::string getSurfaceType (SurfaceType const &surface) const
 
template<class SurfaceType >
std::pair< TrajectoryStateOnSurface, double > propagateGeneric (const FreeTrajectoryState &ftsStart, const SurfaceType &pDest) const
 
template<>
Geant4ePropagator::ErrorTargetPair transformToG4SurfaceTarget (const Cylinder &pDest, bool moveTargetToEndOfSurface) const
 
template<>
Geant4ePropagator::ErrorTargetPair transformToG4SurfaceTarget (const Plane &pDest, bool moveTargetToEndOfSurface) const
 
template<class SurfaceType >
ErrorTargetPair transformToG4SurfaceTarget (const SurfaceType &pDest, bool moveTargetToEndOfSurface) const
 

Private Attributes

double plimit_
 
const MagneticFieldtheField
 
G4ErrorPropagatorData * theG4eData
 
G4ErrorPropagatorManager * theG4eManager
 
std::string theParticleName
 

Detailed Description

Propagator based on the Geant4e package. Uses the Propagator class in the TrackingTools/GeomPropagators package to define the interface. See that class for more details.

Definition at line 20 of file Geant4ePropagator.h.

Member Typedef Documentation

◆ ErrorTargetPair

typedef std::pair<bool, std::shared_ptr<G4ErrorTarget> > Geant4ePropagator::ErrorTargetPair
private

Definition at line 84 of file Geant4ePropagator.h.

◆ TsosPP

typedef std::pair<TrajectoryStateOnSurface, double> Geant4ePropagator::TsosPP
private

Definition at line 83 of file Geant4ePropagator.h.

Constructor & Destructor Documentation

◆ Geant4ePropagator()

Geant4ePropagator::Geant4ePropagator ( const MagneticField field = nullptr,
std::string  particleName = "mu",
PropagationDirection  dir = alongMomentum,
double  plimit = 1.0 
)

Constructor. Takes as arguments:

  • The magnetic field
  • The particle name whose properties will be used in the propagation. Without the charge, i.e. "mu", "pi", ...
  • The propagation direction. It may be: alongMomentum, oppositeToMomentum

Constructor.

Definition at line 39 of file Geant4ePropagator.cc.

43  : Propagator(dir),
44  theField(field),
46  theG4eManager(G4ErrorPropagatorManager::GetErrorPropagatorManager()),
47  theG4eData(G4ErrorPropagatorData::GetErrorPropagatorData()),
48  plimit_(plimit) {
49  LogDebug("Geant4e") << "Geant4e Propagator initialized";
50 
51  // has to be called here, doing it later will not load the G4 physics list
52  // properly when using the G4 ES Producer. Reason: unclear
54 }

References ensureGeant4eIsInitilized(), and LogDebug.

Referenced by clone().

◆ ~Geant4ePropagator()

Geant4ePropagator::~Geant4ePropagator ( )
override

Destructor.

Definition at line 58 of file Geant4ePropagator.cc.

58  {
59  LogDebug("Geant4e") << "Geant4ePropagator::~Geant4ePropagator()" << std::endl;
60 
61  // don't close the g4 Geometry here, because the propagator might have been
62  // cloned
63  // but there is only one, globally-shared Geometry
64 }

References LogDebug.

Member Function Documentation

◆ clone()

Geant4ePropagator* Geant4ePropagator::clone ( void  ) const
inlineoverridevirtual

Implements Propagator.

Definition at line 78 of file Geant4ePropagator.h.

78 { return new Geant4ePropagator(*this); }

References Geant4ePropagator().

◆ configureAnyPropagation() [1/3]

template<>
bool Geant4ePropagator::configureAnyPropagation ( G4ErrorMode &  mode,
Cylinder const &  pDest,
GlobalPoint const &  cmsInitPos,
GlobalVector const &  cmsInitMom 
) const
private

Definition at line 183 of file Geant4ePropagator.cc.

186  {
187  if (cmsInitMom.mag() < plimit_)
188  return false;
189  //------------------------------------
190  // For cylinder assume outside is backwards, inside is along
191  // General use for particles from collisions
192  LocalPoint lpos = pDest.toLocal(cmsInitPos);
193  Surface::Side theSide = pDest.side(lpos, 0);
194  if (theSide == SurfaceOrientation::positiveSide) { // outside cylinder
195  mode = G4ErrorMode_PropBackwards;
196  LogDebug("Geant4e") << "G4e - Propagator mode is \'backwards\' indirect "
197  "via the Any direction";
198  } else { // inside cylinder
199  mode = G4ErrorMode_PropForwards;
200  LogDebug("Geant4e") << "G4e - Propagator mode is \'forwards\' indirect "
201  "via the Any direction";
202  }
203 
204  return true;
205 }

References LogDebug, PV3DBase< T, PVType, FrameType >::mag(), ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, plimit_, SurfaceOrientation::positiveSide, Cylinder::side(), and GloballyPositioned< T >::toLocal().

◆ configureAnyPropagation() [2/3]

template<>
bool Geant4ePropagator::configureAnyPropagation ( G4ErrorMode &  mode,
Plane const &  pDest,
GlobalPoint const &  cmsInitPos,
GlobalVector const &  cmsInitMom 
) const
private

Definition at line 161 of file Geant4ePropagator.cc.

164  {
165  if (cmsInitMom.mag() < plimit_)
166  return false;
167  if (pDest.localZ(cmsInitPos) * pDest.localZ(cmsInitMom) < 0) {
168  mode = G4ErrorMode_PropForwards;
169  LogDebug("Geant4e") << "G4e - Propagator mode is \'forwards\' indirect "
170  "via the Any direction"
171  << std::endl;
172  } else {
173  mode = G4ErrorMode_PropBackwards;
174  LogDebug("Geant4e") << "G4e - Propagator mode is \'backwards\' indirect "
175  "via the Any direction"
176  << std::endl;
177  }
178 
179  return true;
180 }

References Plane::localZ(), LogDebug, PV3DBase< T, PVType, FrameType >::mag(), ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, and plimit_.

◆ configureAnyPropagation() [3/3]

template<class SurfaceType >
bool Geant4ePropagator::configureAnyPropagation ( G4ErrorMode &  mode,
SurfaceType const &  pDest,
GlobalPoint const &  cmsInitPos,
GlobalVector const &  cmsInitMom 
) const
private

Referenced by configurePropagation().

◆ configurePropagation()

template<class SurfaceType >
bool Geant4ePropagator::configurePropagation ( G4ErrorMode &  mode,
SurfaceType const &  pDest,
GlobalPoint const &  cmsInitPos,
GlobalVector const &  cmsInitMom 
) const
private

Definition at line 208 of file Geant4ePropagator.cc.

211  {
212  if (cmsInitMom.mag() < plimit_)
213  return false;
215  mode = G4ErrorMode_PropBackwards;
216  LogDebug("Geant4e") << "G4e - Propagator mode is \'backwards\' " << std::endl;
217  } else if (propagationDirection() == alongMomentum) {
218  mode = G4ErrorMode_PropForwards;
219  LogDebug("Geant4e") << "G4e - Propagator mode is \'forwards\'" << std::endl;
220  } else if (propagationDirection() == anyDirection) {
221  if (configureAnyPropagation(mode, pDest, cmsInitPos, cmsInitMom) == false)
222  return false;
223  } else {
224  edm::LogError("Geant4e") << "G4e - Unsupported propagation mode";
225  return false;
226  }
227  return true;
228 }

References alongMomentum, anyDirection, configureAnyPropagation(), LogDebug, PV3DBase< T, PVType, FrameType >::mag(), ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, oppositeToMomentum, plimit_, and Propagator::propagationDirection().

Referenced by propagateGeneric().

◆ debugReportPlaneSetup()

void Geant4ePropagator::debugReportPlaneSetup ( GlobalPoint const &  posPlane,
HepGeom::Point3D< double > const &  surfPos,
GlobalVector const &  normalPlane,
HepGeom::Normal3D< double > const &  surfNorm,
const Plane pDest 
) const
private

Definition at line 449 of file Geant4ePropagator.cc.

453  {
454  LogDebug("Geant4e") << "G4e - Destination CMS plane position:" << posPlane << "cm\n"
455  << "G4e - (Ro, eta, phi): (" << posPlane.perp() << " cm, " << posPlane.eta()
456  << ", " << posPlane.phi().degrees() << " deg)\n"
457  << "G4e - Destination G4 plane position: " << surfPos << " mm, Ro = " << surfPos.perp()
458  << " mm";
459  LogDebug("Geant4e") << "G4e - Destination CMS plane normal : " << normalPlane << "\n"
460  << "G4e - Destination G4 plane normal : " << normalPlane;
461  LogDebug("Geant4e") << "G4e - Distance from plane position to plane: " << pDest.localZ(posPlane) << " cm";
462 }

References Geom::Phi< T1, Range >::degrees(), PV3DBase< T, PVType, FrameType >::eta(), Plane::localZ(), LogDebug, PV3DBase< T, PVType, FrameType >::perp(), and PV3DBase< T, PVType, FrameType >::phi().

◆ debugReportTrackState()

template<class SurfaceType >
void Geant4ePropagator::debugReportTrackState ( std::string const &  currentContext,
GlobalPoint const &  cmsInitPos,
CLHEP::Hep3Vector const &  g4InitPos,
GlobalVector const &  cmsInitMom,
CLHEP::Hep3Vector const &  g4InitMom,
const SurfaceType &  pDest 
) const
private

Definition at line 465 of file Geant4ePropagator.cc.

470  {
471  LogDebug("Geant4e") << "G4e - Current Context: " << currentContext;
472  LogDebug("Geant4e") << "G4e - CMS point position:" << cmsInitPos << "cm\n"
473  << "G4e - (Ro, eta, phi): (" << cmsInitPos.perp() << " cm, " << cmsInitPos.eta()
474  << ", " << cmsInitPos.phi().degrees() << " deg)\n"
475  << "G4e - G4 point position: " << g4InitPos << " mm, Ro = " << g4InitPos.perp() << " mm";
476  LogDebug("Geant4e") << "G4e - CMS momentum :" << cmsInitMom << "GeV\n"
477  << " pt: " << cmsInitMom.perp() << "G4e - G4 momentum : " << g4InitMom << " MeV";
478 }

References Geom::Phi< T1, Range >::degrees(), PV3DBase< T, PVType, FrameType >::eta(), LogDebug, PV3DBase< T, PVType, FrameType >::perp(), and PV3DBase< T, PVType, FrameType >::phi().

Referenced by propagateGeneric().

◆ ensureGeant4eIsInitilized()

void Geant4ePropagator::ensureGeant4eIsInitilized ( bool  forceInit) const
private

Propagate from a free state (e.g. position and momentum in in global cartesian coordinates) to a plane.

Definition at line 74 of file Geant4ePropagator.cc.

74  {
75  LogDebug("Geant4e") << "ensureGeant4eIsInitilized called" << std::endl;
76  if ((G4ErrorPropagatorData::GetErrorPropagatorData()->GetState() == G4ErrorState_PreInit) || forceInit) {
77  LogDebug("Geant4e") << "Initializing G4 propagator" << std::endl;
78 
79  //G4UImanager::GetUIpointer()->ApplyCommand("/exerror/setField -10. kilogauss");
80 
81  theG4eManager->InitGeant4e();
82 
83  const G4Field *field = G4TransportationManager::GetTransportationManager()->GetFieldManager()->GetDetectorField();
84  if (field == nullptr) {
85  edm::LogError("Geant4e") << "No G4 magnetic field defined";
86  }
87  LogDebug("Geant4e") << "G4 propagator initialized" << std::endl;
88  } else {
89  LogDebug("Geant4e") << "G4 not in preinit state: " << G4ErrorPropagatorData::GetErrorPropagatorData()->GetState()
90  << std::endl;
91  }
92  // define 10 mm step limit for propagator
93  G4UImanager::GetUIpointer()->ApplyCommand("/geant4e/limits/stepLength 10.0 mm");
94 }

References LogDebug, and theG4eManager.

Referenced by Geant4ePropagator().

◆ generateParticleName()

std::string Geant4ePropagator::generateParticleName ( int  charge) const
private

Definition at line 145 of file Geant4ePropagator.cc.

145  {
147 
148  if (charge > 0) {
149  particleName += "+";
150  }
151  if (charge < 0) {
152  particleName += "-";
153  }
154 
155  LogDebug("Geant4e") << "G4e - Particle name: " << particleName;
156 
157  return particleName;
158 }

References ALCARECOTkAlJpsiMuMu_cff::charge, LogDebug, HiggsValidation_cfi::particleName, AlCaHLTBitMon_QueryRunRegistry::string, and theParticleName.

Referenced by propagateGeneric().

◆ getSurfaceType() [1/3]

template<>
std::string Geant4ePropagator::getSurfaceType ( Cylinder const &  c) const
private

Definition at line 136 of file Geant4ePropagator.cc.

136  {
137  return "Cylinder";
138 }

◆ getSurfaceType() [2/3]

template<>
std::string Geant4ePropagator::getSurfaceType ( Plane const &  c) const
private

Definition at line 141 of file Geant4ePropagator.cc.

141  {
142  return "Plane";
143 }

◆ getSurfaceType() [3/3]

template<class SurfaceType >
std::string Geant4ePropagator::getSurfaceType ( SurfaceType const &  surface) const
private

◆ magneticField()

const MagneticField* Geant4ePropagator::magneticField ( ) const
inlineoverridevirtual

Implements Propagator.

Definition at line 80 of file Geant4ePropagator.h.

80 { return theField; }

References theField.

◆ propagateGeneric()

template<class SurfaceType >
std::pair< TrajectoryStateOnSurface, double > Geant4ePropagator::propagateGeneric ( const FreeTrajectoryState ftsStart,
const SurfaceType &  pDest 
) const
private

Definition at line 231 of file Geant4ePropagator.cc.

232  {
234  // Construct the target surface
235  //
236  //* Set the target surface
237 
238  ErrorTargetPair g4eTarget_center = transformToG4SurfaceTarget(pDest, false);
239 
240  // * Get the starting point and direction and convert them to
241  // CLHEP::Hep3Vector
242  // for G4. CMS uses cm and GeV while Geant4 uses mm and MeV
243  GlobalPoint cmsInitPos = ftsStart.position();
244  GlobalVector cmsInitMom = ftsStart.momentum();
245  bool flipped = false;
247  // flip the momentum vector as Geant4 will not do this
248  // on it's own in a backward propagation
249  cmsInitMom = -cmsInitMom;
250  flipped = true;
251  }
252 
253  // Set the mode of propagation according to the propagation direction
254  G4ErrorMode mode = G4ErrorMode_PropForwards;
255  if (!configurePropagation(mode, pDest, cmsInitPos, cmsInitMom))
256  return TsosPP(TrajectoryStateOnSurface(), 0.0f);
257 
258  // re-check propagation direction chosen in case of AnyDirection
259  if (mode == G4ErrorMode_PropBackwards && !flipped)
260  cmsInitMom = -cmsInitMom;
261 
262  CLHEP::Hep3Vector g4InitPos = TrackPropagation::globalPointToHep3Vector(cmsInitPos);
263  CLHEP::Hep3Vector g4InitMom = TrackPropagation::globalVectorToHep3Vector(cmsInitMom * GeV);
264 
265  debugReportTrackState("intitial", cmsInitPos, g4InitPos, cmsInitMom, g4InitMom, pDest);
266 
267  // Set the mode of propagation according to the propagation direction
268  // G4ErrorMode mode = G4ErrorMode_PropForwards;
269 
270  // if (!configurePropagation(mode, pDest, cmsInitPos, cmsInitMom))
271  // return TsosPP(TrajectoryStateOnSurface(), 0.0f);
272 
274  // Set the error and trajectories, and finally propagate
275  //
276  G4ErrorTrajErr g4error(5, 1);
277  if (ftsStart.hasError()) {
279  initErr = ftsStart.curvilinearError();
280  g4error = TrackPropagation::algebraicSymMatrix55ToG4ErrorTrajErr(initErr, ftsStart.charge());
281  LogDebug("Geant4e") << "CMS - Error matrix: " << std::endl << initErr.matrix();
282  } else {
283  LogDebug("Geant4e") << "No error matrix available" << std::endl;
284  return TsosPP(TrajectoryStateOnSurface(), 0.0f);
285  }
286 
287  LogDebug("Geant4e") << "G4e - Error matrix: " << std::endl << g4error;
288 
289  // in CMSSW, the state errors are deflated when performing the backward
290  // propagation
291  if (mode == G4ErrorMode_PropForwards) {
292  G4ErrorPropagatorData::GetErrorPropagatorData()->SetStage(G4ErrorStage_Inflation);
293  } else if (mode == G4ErrorMode_PropBackwards) {
294  G4ErrorPropagatorData::GetErrorPropagatorData()->SetStage(G4ErrorStage_Deflation);
295  }
296 
297  G4ErrorFreeTrajState g4eTrajState(generateParticleName(ftsStart.charge()), g4InitPos, g4InitMom, g4error);
298  LogDebug("Geant4e") << "G4e - Traj. State: " << (g4eTrajState);
299 
301  // Propagate
302  int iterations = 0;
303  double finalPathLength = 0;
304 
305  HepGeom::Point3D<double> finalRecoPos;
306 
307  G4ErrorPropagatorData::GetErrorPropagatorData()->SetMode(mode);
308 
309  theG4eData->SetTarget(g4eTarget_center.second.get());
310  LogDebug("Geant4e") << "Running Propagation to the RECO surface" << std::endl;
311 
312  theG4eManager->InitTrackPropagation();
313 
314  bool continuePropagation = true;
315  while (continuePropagation) {
316  iterations++;
317  LogDebug("Geant4e") << std::endl << "step count " << iterations << " step length " << finalPathLength;
318 
319  const int ierr = theG4eManager->PropagateOneStep(&g4eTrajState, mode);
320 
321  if (ierr != 0) {
322  // propagation failed, return invalid track state
323  return TsosPP(TrajectoryStateOnSurface(), 0.0f);
324  }
325 
326  const float thisPathLength = TrackPropagation::g4doubleToCmsDouble(g4eTrajState.GetG4Track()->GetStepLength());
327 
328  LogDebug("Geant4e") << "step Length was " << thisPathLength << " cm, current global position: "
329  << TrackPropagation::hepPoint3DToGlobalPoint(g4eTrajState.GetPosition()) << std::endl;
330 
331  finalPathLength += thisPathLength;
332 
333  // if (std::fabs(finalPathLength) > 10000.0f)
334  if (std::fabs(finalPathLength) > 200.0f) {
335  LogDebug("Geant4e") << "ERROR: Quitting propagation: path length mega large" << std::endl;
336  theG4eManager->GetPropagator()->InvokePostUserTrackingAction(g4eTrajState.GetG4Track());
337  continuePropagation = false;
338  LogDebug("Geant4e") << "WARNING: Quitting propagation: max path length "
339  "exceeded, returning invalid state"
340  << std::endl;
341 
342  // reached maximum path length, bail out
343  return TsosPP(TrajectoryStateOnSurface(), 0.0f);
344  }
345 
346  if (theG4eManager->GetPropagator()->CheckIfLastStep(g4eTrajState.GetG4Track())) {
347  theG4eManager->GetPropagator()->InvokePostUserTrackingAction(g4eTrajState.GetG4Track());
348  continuePropagation = false;
349  }
350  }
351 
352  // CMSSW Tracking convention, backward propagations have negative path length
354  finalPathLength = -finalPathLength;
355 
356  // store the correct location for the hit on the RECO surface
357  LogDebug("Geant4e") << "Position on the RECO surface" << g4eTrajState.GetPosition() << std::endl;
358  finalRecoPos = g4eTrajState.GetPosition();
359 
360  theG4eManager->EventTermination();
361 
362  LogDebug("Geant4e") << "Final position of the Track :" << g4eTrajState.GetPosition() << std::endl;
363 
365  // Retrieve the state in the end from Geant4e, convert them to CMS vectors
366  // and points, and build global trajectory parameters.
367  // CMS uses cm and GeV while Geant4 uses mm and MeV
368  //
369  const HepGeom::Vector3D<double> momEnd = g4eTrajState.GetMomentum();
370 
371  // use the hit on the the RECO plane as the final position to be d'accor with
372  // the RecHit measurements
373  const GlobalPoint posEndGV = TrackPropagation::hepPoint3DToGlobalPoint(finalRecoPos);
375 
376  debugReportTrackState("final", posEndGV, finalRecoPos, momEndGV, momEnd, pDest);
377 
378  // Get the error covariance matrix from Geant4e. It comes in curvilinear
379  // coordinates so use the appropiate CMS class
380  G4ErrorTrajErr g4errorEnd = g4eTrajState.GetError();
381 
382  CurvilinearTrajectoryError curvError(
384 
385  if (mode == G4ErrorMode_PropBackwards) {
387  posEndGV, momEndGV, ftsStart.parameters().charge(), &ftsStart.parameters().magneticField());
388 
389  // flip the momentum direction because it has been flipped before running
390  // G4's backwards prop
391  momEndGV = -momEndGV;
392  }
393 
394  LogDebug("Geant4e") << "G4e - Error matrix after propagation: " << std::endl << g4errorEnd;
395 
396  LogDebug("Geant4e") << "CMS - Error matrix after propagation: " << std::endl << curvError.matrix();
397 
398  GlobalTrajectoryParameters tParsDest(posEndGV, momEndGV, ftsStart.charge(), theField);
399 
401 
404 
405  return TsosPP(TrajectoryStateOnSurface(tParsDest, curvError, pDest, side), finalPathLength);
406 }

References SurfaceSideDefinition::afterSurface, TrackPropagation::algebraicSymMatrix55ToG4ErrorTrajErr(), alongMomentum, SurfaceSideDefinition::beforeSurface, FreeTrajectoryState::charge(), GlobalTrajectoryParameters::charge(), configurePropagation(), FreeTrajectoryState::curvilinearError(), debugReportTrackState(), f, TrackPropagation::g4doubleToCmsDouble(), TrackPropagation::g4ErrorTrajErrToAlgebraicSymMatrix55(), generateParticleName(), GeV, TrackPropagation::globalPointToHep3Vector(), TrackPropagation::globalVectorToHep3Vector(), FreeTrajectoryState::hasError(), TrackPropagation::hep3VectorToGlobalVector(), TrackPropagation::hepPoint3DToGlobalPoint(), LogDebug, GlobalTrajectoryParameters::magneticField(), CurvilinearTrajectoryError::matrix(), ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, FreeTrajectoryState::momentum(), oppositeToMomentum, FreeTrajectoryState::parameters(), FreeTrajectoryState::position(), Propagator::propagationDirection(), theField, theG4eData, theG4eManager, and transformToG4SurfaceTarget().

Referenced by propagateWithPath().

◆ propagateWithPath() [1/4]

std::pair< TrajectoryStateOnSurface, double > Geant4ePropagator::propagateWithPath ( const FreeTrajectoryState ftsStart,
const Cylinder cDest 
) const
overridevirtual

Implements Propagator.

Definition at line 426 of file Geant4ePropagator.cc.

427  {
428  // Finally build the pair<...> that needs to be returned where the second
429  // parameter is the exact path length.
430  return propagateGeneric(ftsStart, cDest);
431 }

References propagateGeneric().

◆ propagateWithPath() [2/4]

std::pair< TrajectoryStateOnSurface, double > Geant4ePropagator::propagateWithPath ( const FreeTrajectoryState ftsStart,
const Plane pDest 
) const
overridevirtual

Propagate from a free state (e.g. position and momentum in in global cartesian coordinates) to a surface. Propagate from a state on surface (e.g. position and momentum in in global cartesian coordinates associated with a layer) to a surface. The methods propagateWithPath() are identical to the corresponding methods propagate() in what concerns the resulting TrajectoryStateOnSurface, but they provide in addition the exact path length along the trajectory. All of these method calls are internally mapped to

The methods propagateWithPath() are identical to the corresponding methods propagate() in what concerns the resulting TrajectoryStateOnSurface, but they provide in addition the exact path length along the trajectory.

Implements Propagator.

Definition at line 418 of file Geant4ePropagator.cc.

419  {
420  // Finally build the pair<...> that needs to be returned where the second
421  // parameter is the exact path length. Currently calculated with a stepping
422  // action that adds up the length of every step
423  return propagateGeneric(ftsStart, pDest);
424 }

References propagateGeneric().

◆ propagateWithPath() [3/4]

std::pair< TrajectoryStateOnSurface, double > Geant4ePropagator::propagateWithPath ( const TrajectoryStateOnSurface tsosStart,
const Cylinder cDest 
) const
overridevirtual

Reimplemented from Propagator.

Definition at line 441 of file Geant4ePropagator.cc.

442  {
443  const FreeTrajectoryState ftsStart = *tsosStart.freeState();
444  // Finally build the pair<...> that needs to be returned where the second
445  // parameter is the exact path length.
446  return propagateGeneric(ftsStart, cDest);
447 }

References TrajectoryStateOnSurface::freeState(), and propagateGeneric().

◆ propagateWithPath() [4/4]

std::pair< TrajectoryStateOnSurface, double > Geant4ePropagator::propagateWithPath ( const TrajectoryStateOnSurface tsosStart,
const Plane pDest 
) const
overridevirtual

Reimplemented from Propagator.

Definition at line 433 of file Geant4ePropagator.cc.

434  {
435  // Finally build the pair<...> that needs to be returned where the second
436  // parameter is the exact path length.
437  const FreeTrajectoryState ftsStart = *tsosStart.freeState();
438  return propagateGeneric(ftsStart, pDest);
439 }

References TrajectoryStateOnSurface::freeState(), and propagateGeneric().

◆ transformToG4SurfaceTarget() [1/3]

template<>
Geant4ePropagator::ErrorTargetPair Geant4ePropagator::transformToG4SurfaceTarget ( const Cylinder pDest,
bool  moveTargetToEndOfSurface 
) const
private

Definition at line 116 of file Geant4ePropagator.cc.

117  {
118  // Get Cylinder parameters.
119  // CMS uses cm and GeV while Geant4 uses mm and MeV.
120  // - Radius
121  G4float radCyl = pDest.radius() * cm;
122  // - Position: PositionType & GlobalPoint are Basic3DPoint<float,GlobalTag>
123  G4ThreeVector posCyl = TrackPropagation::globalPointToHep3Vector(pDest.position());
124  // - Rotation: Type in CMSSW is RotationType == TkRotation<T>, T=float
125  G4RotationMatrix rotCyl = TrackPropagation::tkRotationFToHepRotation(pDest.rotation());
126 
127  // DEBUG
129  LogDebug("Geant4e") << "G4e - TkRotation" << rotation;
130  LogDebug("Geant4e") << "G4e - G4Rotation" << rotCyl << "mm";
131 
132  return ErrorTargetPair(!moveTargetToEndOfSurface, std::make_shared<G4ErrorCylSurfaceTarget>(radCyl, posCyl, rotCyl));
133 }

References TrackPropagation::globalPointToHep3Vector(), LogDebug, GloballyPositioned< T >::position(), Cylinder::radius(), idealTransformation::rotation, GloballyPositioned< T >::rotation(), and TrackPropagation::tkRotationFToHepRotation().

◆ transformToG4SurfaceTarget() [2/3]

template<>
Geant4ePropagator::ErrorTargetPair Geant4ePropagator::transformToG4SurfaceTarget ( const Plane pDest,
bool  moveTargetToEndOfSurface 
) const
private

Definition at line 97 of file Geant4ePropagator.cc.

98  {
99  //* Get position and normal (orientation) of the destination plane
100  GlobalPoint posPlane = pDest.toGlobal(LocalPoint(0, 0, 0));
101  GlobalVector normalPlane = pDest.toGlobal(LocalVector(0, 0, 1.));
102  normalPlane = normalPlane.unit();
103 
104  //* Transform this into HepGeom::Point3D<double> and
105  // HepGeom::Normal3D<double> that define a plane for
106  // Geant4e.
107  // CMS uses cm and GeV while Geant4 uses mm and MeV
108  HepGeom::Point3D<double> surfPos = TrackPropagation::globalPointToHepPoint3D(posPlane);
109  HepGeom::Normal3D<double> surfNorm = TrackPropagation::globalVectorToHepNormal3D(normalPlane);
110 
111  //* Set the target surface
112  return ErrorTargetPair(false, std::make_shared<G4ErrorPlaneSurfaceTarget>(surfNorm, surfPos));
113 }

References TrackPropagation::globalPointToHepPoint3D(), TrackPropagation::globalVectorToHepNormal3D(), Surface::toGlobal(), and Vector3DBase< T, FrameTag >::unit().

◆ transformToG4SurfaceTarget() [3/3]

template<class SurfaceType >
ErrorTargetPair Geant4ePropagator::transformToG4SurfaceTarget ( const SurfaceType &  pDest,
bool  moveTargetToEndOfSurface 
) const
private

Referenced by propagateGeneric().

Member Data Documentation

◆ plimit_

double Geant4ePropagator::plimit_
private

Definition at line 95 of file Geant4ePropagator.h.

Referenced by configureAnyPropagation(), and configurePropagation().

◆ theField

const MagneticField* Geant4ePropagator::theField
private

Definition at line 87 of file Geant4ePropagator.h.

Referenced by magneticField(), and propagateGeneric().

◆ theG4eData

G4ErrorPropagatorData* Geant4ePropagator::theG4eData
private

Definition at line 94 of file Geant4ePropagator.h.

Referenced by propagateGeneric().

◆ theG4eManager

G4ErrorPropagatorManager* Geant4ePropagator::theG4eManager
private

Definition at line 93 of file Geant4ePropagator.h.

Referenced by ensureGeant4eIsInitilized(), and propagateGeneric().

◆ theParticleName

std::string Geant4ePropagator::theParticleName
private

Definition at line 90 of file Geant4ePropagator.h.

Referenced by generateParticleName().

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
TkRotation< float >
FreeTrajectoryState::momentum
GlobalVector momentum() const
Definition: FreeTrajectoryState.h:68
Geant4ePropagator::transformToG4SurfaceTarget
ErrorTargetPair transformToG4SurfaceTarget(const SurfaceType &pDest, bool moveTargetToEndOfSurface) const
TrackPropagation::hep3VectorToGlobalVector
GlobalVector hep3VectorToGlobalVector(const CLHEP::Hep3Vector &p)
Definition: ConvertFromToCLHEP.h:69
anyDirection
Definition: PropagationDirection.h:4
Cylinder::radius
Scalar radius() const
Radius of the cylinder.
Definition: Cylinder.h:64
FreeTrajectoryState::hasError
bool hasError() const
Definition: FreeTrajectoryState.h:77
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
TrackPropagation::hepPoint3DToGlobalPoint
GlobalPoint hepPoint3DToGlobalPoint(const HepGeom::Point3D< double > &r)
Definition: ConvertFromToCLHEP.h:38
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
FreeTrajectoryState::charge
TrackCharge charge() const
Definition: FreeTrajectoryState.h:69
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
GlobalTrajectoryParameters::charge
TrackCharge charge() const
Definition: GlobalTrajectoryParameters.h:72
oppositeToMomentum
Definition: PropagationDirection.h:4
SurfaceSideDefinition::SurfaceSide
SurfaceSide
Definition: SurfaceSideDefinition.h:8
SurfaceSideDefinition::afterSurface
Definition: SurfaceSideDefinition.h:8
TrackPropagation::g4ErrorTrajErrToAlgebraicSymMatrix55
AlgebraicSymMatrix55 g4ErrorTrajErrToAlgebraicSymMatrix55(const G4ErrorTrajErr &e, const int q)
Definition: ConvertFromToCLHEP.h:106
FreeTrajectoryState::position
GlobalPoint position() const
Definition: FreeTrajectoryState.h:67
align::LocalPoint
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
Geant4ePropagator::theParticleName
std::string theParticleName
Definition: Geant4ePropagator.h:90
Geant4ePropagator::theField
const MagneticField * theField
Definition: Geant4ePropagator.h:87
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
Vector3DBase::unit
Vector3DBase unit() const
Definition: Vector3DBase.h:54
TrajectoryStateOnSurface::freeState
FreeTrajectoryState const * freeState(bool withErrors=true) const
Definition: TrajectoryStateOnSurface.h:58
CurvilinearTrajectoryError
Definition: CurvilinearTrajectoryError.h:27
Geant4ePropagator::theG4eManager
G4ErrorPropagatorManager * theG4eManager
Definition: Geant4ePropagator.h:93
Geant4ePropagator::theG4eData
G4ErrorPropagatorData * theG4eData
Definition: Geant4ePropagator.h:94
FreeTrajectoryState::curvilinearError
const CurvilinearTrajectoryError & curvilinearError() const
Definition: FreeTrajectoryState.h:89
SurfaceSideDefinition::beforeSurface
Definition: SurfaceSideDefinition.h:8
TrackPropagation::g4doubleToCmsDouble
double g4doubleToCmsDouble(const G4double &d)
Definition: ConvertFromToCLHEP.h:45
Propagator::propagationDirection
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
TrackPropagation::globalVectorToHepNormal3D
HepGeom::Normal3D< double > globalVectorToHepNormal3D(const GlobalVector &p)
Definition: ConvertFromToCLHEP.h:50
TrackPropagation::globalPointToHepPoint3D
HepGeom::Point3D< double > globalPointToHepPoint3D(const GlobalPoint &r)
Definition: ConvertFromToCLHEP.h:30
HiggsValidation_cfi.particleName
particleName
Definition: HiggsValidation_cfi.py:7
GlobalTrajectoryParameters
Definition: GlobalTrajectoryParameters.h:15
Geant4ePropagator::configureAnyPropagation
bool configureAnyPropagation(G4ErrorMode &mode, SurfaceType const &pDest, GlobalPoint const &cmsInitPos, GlobalVector const &cmsInitMom) const
Point3DBase< float, LocalTag >
Geant4ePropagator::ensureGeant4eIsInitilized
void ensureGeant4eIsInitilized(bool forceInit) const
Definition: Geant4ePropagator.cc:74
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TrackPropagation::globalPointToHep3Vector
CLHEP::Hep3Vector globalPointToHep3Vector(const GlobalPoint &r)
Definition: ConvertFromToCLHEP.h:75
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
GeV
const double GeV
Definition: MathUtil.h:16
Plane::localZ
float localZ(const GlobalPoint &gp) const
Definition: Plane.h:45
LocalVector
Local3DVector LocalVector
Definition: LocalVector.h:12
FreeTrajectoryState::parameters
const GlobalTrajectoryParameters & parameters() const
Definition: FreeTrajectoryState.h:79
TrackPropagation::globalVectorToHep3Vector
CLHEP::Hep3Vector globalVectorToHep3Vector(const GlobalVector &p)
Definition: ConvertFromToCLHEP.h:63
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
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SurfaceOrientation::Side
Side
Definition: Surface.h:18
GloballyPositioned::position
const PositionType & position() const
Definition: GloballyPositioned.h:36
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
TrackPropagation::tkRotationFToHepRotation
CLHEP::HepRotation tkRotationFToHepRotation(const TkRotation< float > &tkr)
Definition: ConvertFromToCLHEP.h:90
TrackPropagation::algebraicSymMatrix55ToG4ErrorTrajErr
G4ErrorTrajErr algebraicSymMatrix55ToG4ErrorTrajErr(const AlgebraicSymMatrix55 &e, const int q)
Definition: ConvertFromToCLHEP.h:126
SurfaceOrientation::positiveSide
Definition: Surface.h:18
GlobalTrajectoryParameters::magneticField
const MagneticField & magneticField() const
Definition: GlobalTrajectoryParameters.h:106
Geant4ePropagator::TsosPP
std::pair< TrajectoryStateOnSurface, double > TsosPP
Definition: Geant4ePropagator.h:83
GloballyPositioned::rotation
const RotationType & rotation() const
Definition: GloballyPositioned.h:38
Geant4ePropagator::propagateGeneric
std::pair< TrajectoryStateOnSurface, double > propagateGeneric(const FreeTrajectoryState &ftsStart, const SurfaceType &pDest) const
Definition: Geant4ePropagator.cc:231
alongMomentum
Definition: PropagationDirection.h:4
CurvilinearTrajectoryError::matrix
const AlgebraicSymMatrix55 & matrix() const
Definition: CurvilinearTrajectoryError.h:61
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
Propagator::Propagator
Propagator(PropagationDirection dir=alongMomentum)
Definition: Propagator.h:46