File indexing completed on 2024-04-06 12:23:31
0001 #include "PhysicsTools/IsolationAlgos/interface/PropagateToCal.h"
0002
0003 PropagateToCal::PropagateToCal(double radius, double minZ, double maxZ, bool theIgnoreMaterial) {
0004 radius_ = radius;
0005 maxZ_ = maxZ;
0006 minZ_ = minZ;
0007 theIgnoreMaterial_ = theIgnoreMaterial;
0008 if (maxZ_ < minZ_ || radius < 0.0)
0009 throw cms::Exception("BadConfig") << "PropagateToCal: CalMaxZ (" << maxZ_ << ") smaller than CalMinZ (" << minZ_
0010 << ") or invalid radius (" << radius_ << ").";
0011 }
0012
0013 PropagateToCal::~PropagateToCal() {}
0014
0015 bool PropagateToCal::propagate(const GlobalPoint& vertex,
0016 GlobalVector& Cand,
0017 int charge,
0018 const MagneticField* field) const {
0019
0020 bool result = true;
0021 typedef std::pair<TrajectoryStateOnSurface, double> TsosPath;
0022
0023 SteppingHelixPropagator propagator(field);
0024 propagator.setMaterialMode(theIgnoreMaterial_);
0025 propagator.setNoErrorPropagation(true);
0026
0027 const FreeTrajectoryState fts(GlobalTrajectoryParameters(vertex, Cand, charge, field));
0028 const Surface::RotationType dummyRot;
0029
0030
0031 Cylinder::ConstCylinderPointer theTargetCylinder =
0032 Cylinder::build(radius_, Surface::PositionType(0., 0., 0.), dummyRot);
0033
0034
0035 Plane::ConstPlanePointer theTargetPlaneMin = Plane::build(Surface::PositionType(0., 0., minZ_), dummyRot);
0036
0037
0038 Plane::ConstPlanePointer theTargetPlaneMax = Plane::build(Surface::PositionType(0., 0., maxZ_), dummyRot);
0039
0040 TsosPath aTsosPath(propagator.propagateWithPath(fts, *theTargetCylinder));
0041 if (!aTsosPath.first.isValid()) {
0042 result = false;
0043 } else if (aTsosPath.first.globalPosition().z() < theTargetPlaneMin->position().z()) {
0044
0045
0046
0047 aTsosPath = propagator.propagateWithPath(fts, *theTargetPlaneMin);
0048 if (!aTsosPath.first.isValid() || aTsosPath.first.globalPosition().perp() > theTargetCylinder->radius()) {
0049 result = false;
0050 }
0051 } else if (aTsosPath.first.globalPosition().z() > theTargetPlaneMax->position().z()) {
0052
0053 aTsosPath = propagator.propagateWithPath(fts, *theTargetPlaneMax);
0054 if (!aTsosPath.first.isValid() || aTsosPath.first.globalPosition().perp() > theTargetCylinder->radius()) {
0055 result = false;
0056 }
0057 }
0058
0059
0060 if (result) {
0061 Cand = GlobalVector(aTsosPath.first.globalPosition().x(),
0062 aTsosPath.first.globalPosition().y(),
0063 aTsosPath.first.globalPosition().z());
0064 }
0065 return result;
0066 }