Back to home page

Project CMSSW displayed by LXR

 
 

    


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   ///the code is inspired by Gero's CosmicGenFilterHelix class:
0020   bool result = true;
0021   typedef std::pair<TrajectoryStateOnSurface, double> TsosPath;
0022 
0023   SteppingHelixPropagator propagator(field);       // should we somehow take it from ESetup???
0024   propagator.setMaterialMode(theIgnoreMaterial_);  // no material effects if set to true
0025   propagator.setNoErrorPropagation(true);
0026 
0027   const FreeTrajectoryState fts(GlobalTrajectoryParameters(vertex, Cand, charge, field));
0028   const Surface::RotationType dummyRot;
0029 
0030   /// target cylinder, around z-axis
0031   Cylinder::ConstCylinderPointer theTargetCylinder =
0032       Cylinder::build(radius_, Surface::PositionType(0., 0., 0.), dummyRot);
0033 
0034   /// plane closing cylinder at 'negative' side
0035   Plane::ConstPlanePointer theTargetPlaneMin = Plane::build(Surface::PositionType(0., 0., minZ_), dummyRot);
0036 
0037   /// plane closing cylinder at 'positive' side
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     // If on cylinder, but outside minimum z, try minimum z-plane:
0045     // (Would it be possible to miss rdius on plane, but reach cylinder afterwards in z-range?
0046     //  No, at least not in B-field parallel to z-axis which is cylinder axis.)
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     // Analog for outside maximum z:
0053     aTsosPath = propagator.propagateWithPath(fts, *theTargetPlaneMax);
0054     if (!aTsosPath.first.isValid() || aTsosPath.first.globalPosition().perp() > theTargetCylinder->radius()) {
0055       result = false;
0056     }
0057   }
0058   ///The result is the vector connecting the extrapolation endPoint on the Calorimeter surface and
0059   ///the origin of the coordinate system, point (0,0,0).
0060   if (result) {
0061     Cand = GlobalVector(aTsosPath.first.globalPosition().x(),
0062                         aTsosPath.first.globalPosition().y(),
0063                         aTsosPath.first.globalPosition().z());
0064   }
0065   return result;  ///Successfully propagated to the calorimeter or not
0066 }