Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:31:38

0001 #include "TrackingTools/GsfTracking/interface/GsfPropagatorWithMaterial.h"
0002 
0003 #include "TrackingTools/GsfTools/interface/MultiTrajectoryStateAssembler.h"
0004 #include "TrackingTools/GeomPropagators/interface/AnalyticalPropagator.h"
0005 #include "TrackingTools/GeomPropagators/interface/PropagationDirectionFromPath.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "FWCore/Utilities/interface/Exception.h"
0008 
0009 #include <atomic>
0010 
0011 GsfPropagatorWithMaterial::GsfPropagatorWithMaterial(const Propagator& aPropagator,
0012                                                      const GsfMaterialEffectsUpdator& aMEUpdator)
0013     : Propagator(aPropagator.propagationDirection()),
0014       theGeometricalPropagator(new GsfPropagatorAdapter(aPropagator)),
0015       theConvolutor(new FullConvolutionWithMaterial(aMEUpdator)),
0016       theMaterialLocation(atDestination) {}
0017 
0018 GsfPropagatorWithMaterial::GsfPropagatorWithMaterial(const GsfPropagatorAdapter& aGsfPropagator,
0019                                                      const FullConvolutionWithMaterial& aConvolutor)
0020     : Propagator(aGsfPropagator.propagationDirection()),
0021       theGeometricalPropagator(aGsfPropagator.clone()),
0022       theConvolutor(aConvolutor.clone()),
0023       theMaterialLocation(atDestination) {}
0024 
0025 std::pair<TrajectoryStateOnSurface, double> GsfPropagatorWithMaterial::propagateWithPath(
0026     const TrajectoryStateOnSurface& tsos, const Plane& plane) const {
0027   // add material before propagation?
0028   //
0029   TrajectoryStateOnSurface stateAtSource;
0030   if (materialAtSource())
0031     stateAtSource = convoluteStateWithMaterial(tsos, propagationDirection());
0032   else
0033     stateAtSource = tsos;
0034   if (!stateAtSource.isValid())
0035     return TsosWP(stateAtSource, 0.);
0036   //
0037   // geometrical propagation
0038   //
0039   TsosWP propStateWP(theGeometricalPropagator->propagateWithPath(stateAtSource, plane));
0040   if (!(propStateWP.first).isValid())
0041     return propStateWP;
0042   //
0043   // return convoluted state
0044   //
0045   return convoluteWithMaterial(propStateWP);
0046 }
0047 
0048 std::pair<TrajectoryStateOnSurface, double> GsfPropagatorWithMaterial::propagateWithPath(
0049     const TrajectoryStateOnSurface& tsos, const Cylinder& cylinder) const {
0050   // add material before propagation?
0051   //
0052   TrajectoryStateOnSurface stateAtSource;
0053   if (materialAtSource())
0054     stateAtSource = convoluteStateWithMaterial(tsos, propagationDirection());
0055   else
0056     stateAtSource = tsos;
0057   if (!stateAtSource.isValid())
0058     return TsosWP(stateAtSource, 0.);
0059   //
0060   // geometrical propagation
0061   //
0062   TsosWP propStateWP(theGeometricalPropagator->propagateWithPath(stateAtSource, cylinder));
0063   if (!(propStateWP.first).isValid())
0064     return propStateWP;
0065   //
0066   // return convoluted state
0067   //
0068   return convoluteWithMaterial(propStateWP);
0069 }
0070 
0071 std::pair<TrajectoryStateOnSurface, double> GsfPropagatorWithMaterial::propagateWithPath(const FreeTrajectoryState& fts,
0072                                                                                          const Plane& plane) const {
0073   static std::atomic<int> nWarn(0);
0074   if (nWarn++ < 5)
0075     edm::LogInfo("GsfPropagatorWithMaterial")
0076         << "GsfPropagatorWithMaterial used from FTS: input state might have been collapsed!";
0077   TsosWP propStateWP = theGeometricalPropagator->propagateWithPath(fts, plane);
0078   if (!(propStateWP.first).isValid() || materialAtSource())
0079     return propStateWP;
0080   //
0081   // return convoluted state
0082   //
0083   return convoluteWithMaterial(propStateWP);
0084 }
0085 
0086 std::pair<TrajectoryStateOnSurface, double> GsfPropagatorWithMaterial::propagateWithPath(
0087     const FreeTrajectoryState& fts, const Cylinder& cylinder) const {
0088   static std::atomic<int> nWarn(0);
0089   if (nWarn++ < 5)
0090     edm::LogInfo("GsfPropagatorWithMaterial")
0091         << "GsfPropagatorWithMaterial used from FTS: input state might have been collapsed!";
0092   TsosWP propStateWP = theGeometricalPropagator->propagateWithPath(fts, cylinder);
0093   if (!(propStateWP.first).isValid() || materialAtSource())
0094     return propStateWP;
0095   //
0096   // return convoluted state
0097   //
0098   return convoluteWithMaterial(propStateWP);
0099 }
0100 
0101 void GsfPropagatorWithMaterial::setPropagationDirection(PropagationDirection dir) {
0102   theGeometricalPropagator->setPropagationDirection(dir);
0103   Propagator::setPropagationDirection(dir);
0104 }
0105 
0106 std::pair<TrajectoryStateOnSurface, double> GsfPropagatorWithMaterial::convoluteWithMaterial(
0107     const TsosWP& aStateWithPath) const {
0108   //
0109   // convolute with material
0110   //
0111   PropagationDirection propDir = PropagationDirectionFromPath()(aStateWithPath.second, propagationDirection());
0112   return TsosWP((*theConvolutor)(aStateWithPath.first, propDir), aStateWithPath.second);
0113 }
0114 
0115 TrajectoryStateOnSurface GsfPropagatorWithMaterial::convoluteStateWithMaterial(
0116     const TrajectoryStateOnSurface tsos, const PropagationDirection propDir) const {
0117   //
0118   // convolute with material
0119   //
0120   return (*theConvolutor)(tsos, propDir);
0121 }
0122 
0123 bool GsfPropagatorWithMaterial::materialAtSource() const {
0124   if (propagationDirection() == anyDirection) {
0125     if (theMaterialLocation != atDestination) {
0126       throw cms::Exception("LogicError") << "PropagatorWithMaterial: propagation direction = anyDirection is "
0127                                          << "incompatible with adding of material at source";
0128     }
0129   }
0130   return theMaterialLocation == atSource ||
0131          (theMaterialLocation == fromDirection && propagationDirection() == alongMomentum);
0132 }