CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/PhysicsTools/IsolationAlgos/src/PropagateToCal.cc

Go to the documentation of this file.
00001 #include "PhysicsTools/IsolationAlgos/interface/PropagateToCal.h"
00002 
00003 PropagateToCal::PropagateToCal(double radius, double minZ, double maxZ, bool theIgnoreMaterial)
00004 { 
00005   radius_ = radius; 
00006   maxZ_ = maxZ; 
00007   minZ_ = minZ; 
00008   theIgnoreMaterial_ = theIgnoreMaterial;
00009   if (maxZ_ < minZ_ || radius < 0.0) 
00010     throw cms::Exception("BadConfig") << "PropagateToCal: CalMaxZ (" 
00011                                       << maxZ_
00012                                       << ") smaller than CalMinZ (" 
00013                                       << minZ_ << ") or invalid radius ("
00014                                       << radius_ << ").";
00015 }
00016 
00017 
00018 PropagateToCal::~PropagateToCal()
00019 {
00020 }
00021 
00022 
00023 bool PropagateToCal::propagate(const GlobalPoint& vertex, 
00024                      GlobalVector& Cand, int charge, const MagneticField * field) const
00025 {
00027   bool result = true;
00028   typedef std::pair<TrajectoryStateOnSurface, double> TsosPath;
00029 
00030   SteppingHelixPropagator propagator(field); // should we somehow take it from ESetup???
00031   propagator.setMaterialMode(theIgnoreMaterial_); // no material effects if set to true
00032   propagator.setNoErrorPropagation(true);
00033 
00034   const FreeTrajectoryState fts(GlobalTrajectoryParameters(vertex, Cand, charge, field));
00035   const Surface::RotationType dummyRot;
00036 
00038   Cylinder::ConstCylinderPointer theTargetCylinder = 
00039     Cylinder::build(Surface::PositionType(0.,0.,0.), dummyRot, radius_);
00040 
00042   Plane::ConstPlanePointer theTargetPlaneMin = 
00043     Plane::build(Surface::PositionType(0.,0.,minZ_), dummyRot);
00044 
00046   Plane::ConstPlanePointer theTargetPlaneMax = 
00047     Plane::build(Surface::PositionType(0.,0.,maxZ_), dummyRot);
00048 
00049   TsosPath aTsosPath(propagator.propagateWithPath(fts, *theTargetCylinder));
00050   if (!aTsosPath.first.isValid()) {
00051     result = false;
00052   } else if (aTsosPath.first.globalPosition().z() < theTargetPlaneMin->position().z()) {
00053     // If on cylinder, but outside minimum z, try minimum z-plane:
00054     // (Would it be possible to miss rdius on plane, but reach cylinder afterwards in z-range?
00055     //  No, at least not in B-field parallel to z-axis which is cylinder axis.)
00056     aTsosPath = propagator.propagateWithPath(fts, *theTargetPlaneMin);
00057     if (!aTsosPath.first.isValid()
00058         || aTsosPath.first.globalPosition().perp() > theTargetCylinder->radius()) {
00059       result = false;
00060     }
00061   } else if (aTsosPath.first.globalPosition().z() > theTargetPlaneMax->position().z()) {
00062     // Analog for outside maximum z:
00063     aTsosPath = propagator.propagateWithPath(fts, *theTargetPlaneMax);
00064     if (!aTsosPath.first.isValid()
00065         || aTsosPath.first.globalPosition().perp() > theTargetCylinder->radius()) {
00066       result = false;
00067     }
00068   }
00071   if (result) {
00072     Cand = GlobalVector(aTsosPath.first.globalPosition().x(),
00073                         aTsosPath.first.globalPosition().y(),
00074                         aTsosPath.first.globalPosition().z() );
00075   }
00076   return result;
00077 }