Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:29

0001 /******* \class SmartPropagator *******
0002  *
0003  * Description: A propagator which use different algorithm to propagate inside
0004  * or outside tracker
0005  *  
0006  *
0007  * \author : Stefano Lacaprara - INFN Padova <stefano.lacaprara@pd.infn.it>
0008  * \porting author: Chang Liu - Purdue University 
0009  *
0010  * Modification:
0011  *
0012  *********************************/
0013 
0014 /* This Class Header */
0015 #include "TrackingTools/GeomPropagators/interface/SmartPropagator.h"
0016 
0017 /* Collaborating Class Header */
0018 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0019 #include "DataFormats/GeometrySurface/interface/BoundPlane.h"
0020 #include "DataFormats/GeometrySurface/interface/SimpleCylinderBounds.h"
0021 
0022 #include <DataFormats/GeometrySurface/interface/BoundCylinder.h>
0023 
0024 #include "TrackingTools/GeomPropagators/interface/TrackerBounds.h"
0025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0026 
0027 /* Base Class Headers */
0028 
0029 /* C++ Headers */
0030 
0031 /* ====================================================================== */
0032 
0033 /* static member */
0034 
0035 /* Constructor */
0036 SmartPropagator::SmartPropagator(const Propagator* aTkProp,
0037                                  const Propagator* aGenProp,
0038                                  const MagneticField* field,
0039                                  PropagationDirection dir,
0040                                  float epsilon)
0041     : Propagator(dir), theTkProp(aTkProp->clone()), theGenProp(aGenProp->clone()), theField(field) {
0042   initTkVolume(epsilon);
0043 }
0044 
0045 SmartPropagator::SmartPropagator(const Propagator& aTkProp,
0046                                  const Propagator& aGenProp,
0047                                  const MagneticField* field,
0048                                  PropagationDirection dir,
0049                                  float epsilon)
0050     : Propagator(dir), theTkProp(aTkProp.clone()), theGenProp(aGenProp.clone()), theField(field) {
0051   initTkVolume(epsilon);
0052 }
0053 
0054 SmartPropagator::SmartPropagator(const SmartPropagator& aProp)
0055     : Propagator(aProp.propagationDirection()), theTkProp(nullptr), theGenProp(nullptr) {
0056   if (aProp.theTkProp)
0057     theTkProp = aProp.getTkPropagator()->clone();
0058   if (aProp.theGenProp)
0059     theTkProp = aProp.getGenPropagator()->clone();
0060 
0061   //SL since it's a copy constructor, then the TkVolume has been already
0062   //initialized
0063   // initTkVolume(epsilon);
0064 }
0065 
0066 /* Destructor */
0067 SmartPropagator::~SmartPropagator() {
0068   delete theTkProp;
0069   delete theGenProp;
0070 }
0071 
0072 /* Operations */
0073 void SmartPropagator::initTkVolume(float epsilon) {
0074   //
0075   // fill tracker dimensions
0076   //
0077   float radius = TrackerBounds::radius();
0078   float r_out = radius + epsilon / 2;
0079   float r_in = r_out - epsilon;
0080   float z_max = TrackerBounds::halfLength();
0081   float z_min = -z_max;
0082 
0083   Surface::PositionType pos(0, 0, 0);  // centered at the global origin
0084   Surface::RotationType rot;           // unit matrix - barrel cylinder orientation
0085 
0086   theTkVolume = Cylinder::build(radius, pos, rot, new SimpleCylinderBounds(r_in, r_out, z_min, z_max));
0087 }
0088 
0089 std::pair<TrajectoryStateOnSurface, double> SmartPropagator::propagateWithPath(const FreeTrajectoryState& fts,
0090                                                                                const Plane& plane) const {
0091   if (insideTkVol(fts) && insideTkVol(plane)) {
0092     return getTkPropagator()->propagateWithPath(fts, plane);
0093   } else {
0094     return getGenPropagator()->propagateWithPath(fts, plane);
0095   }
0096 }
0097 
0098 std::pair<TrajectoryStateOnSurface, double> SmartPropagator::propagateWithPath(const FreeTrajectoryState& fts,
0099                                                                                const Cylinder& cylinder) const {
0100   if (insideTkVol(fts) && insideTkVol(cylinder)) {
0101     return getTkPropagator()->propagateWithPath(fts, cylinder);
0102   } else {
0103     return getGenPropagator()->propagateWithPath(fts, cylinder);
0104   }
0105 }
0106 
0107 std::pair<TrajectoryStateOnSurface, double> SmartPropagator::propagateWithPath(const TrajectoryStateOnSurface& fts,
0108                                                                                const Plane& plane) const {
0109   if (insideTkVol(*fts.freeState()) && insideTkVol(plane)) {
0110     return getTkPropagator()->propagateWithPath(fts, plane);
0111   } else {
0112     return getGenPropagator()->propagateWithPath(fts, plane);
0113   }
0114 }
0115 
0116 std::pair<TrajectoryStateOnSurface, double> SmartPropagator::propagateWithPath(const TrajectoryStateOnSurface& fts,
0117                                                                                const Cylinder& cylinder) const {
0118   if (insideTkVol(*fts.freeState()) && insideTkVol(cylinder)) {
0119     return getTkPropagator()->propagateWithPath(fts, cylinder);
0120   } else {
0121     return getGenPropagator()->propagateWithPath(fts, cylinder);
0122   }
0123 }
0124 
0125 bool SmartPropagator::insideTkVol(const FreeTrajectoryState& fts) const {
0126   GlobalPoint gp = fts.position();
0127   //  LocalPoint lp = theTkVolume()->toLocal(gp);
0128   //  return theTkVolume()->bounds().inside(lp);
0129 
0130   return ((gp.perp() <= TrackerBounds::radius() + 10.) && (fabs(gp.z()) <= TrackerBounds::halfLength() + 10.));
0131 }
0132 
0133 bool SmartPropagator::insideTkVol(const Surface& surface) const {
0134   const GlobalPoint& gp = surface.position();
0135   // LocalPoint lp = theTkVolume()->toLocal(gp);
0136 
0137   // return theTkVolume()->bounds().inside(lp);
0138   return ((gp.perp() <= TrackerBounds::radius() + 10.) && (fabs(gp.z()) <= TrackerBounds::halfLength() + 10.));
0139 }
0140 
0141 bool SmartPropagator::insideTkVol(const BoundCylinder& cylin) const {
0142   GlobalPoint gp(cylin.radius(), 0., (cylin.bounds().length()) / 2.);
0143   //  LocalPoint lp = theTkVolume()->toLocal(gp);
0144   //  return theTkVolume()->bounds().inside(lp);
0145   return ((gp.perp() <= TrackerBounds::radius() + 10.) && (fabs(gp.z()) <= TrackerBounds::halfLength() + 10.));
0146 }
0147 
0148 bool SmartPropagator::insideTkVol(const Plane& plane) const {
0149   const GlobalPoint& gp = plane.position();
0150   //  LocalPoint lp = theTkVolume()->toLocal(gp);
0151   //  return theTkVolume()->bounds().inside(lp);
0152   return ((gp.perp() <= TrackerBounds::radius() + 10.) && (fabs(gp.z()) <= TrackerBounds::halfLength() + 10.));
0153 }
0154 
0155 const Propagator* SmartPropagator::getTkPropagator() const { return theTkProp; }
0156 
0157 const Propagator* SmartPropagator::getGenPropagator() const { return theGenProp; }