CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/TrackingTools/GeomPropagators/src/SmartPropagator.cc

Go to the documentation of this file.
00001 /******* \class SmartPropagator *******
00002  *
00003  * Description: A propagator which use different algorithm to propagate inside
00004  * or outside tracker
00005  *  
00006  *
00007  * \author : Stefano Lacaprara - INFN Padova <stefano.lacaprara@pd.infn.it>
00008  * \porting author: Chang Liu - Purdue University 
00009  * $Date: 2009/07/05 19:56:54 $
00010  * $Revision: 1.7 $
00011  *
00012  * Modification:
00013  *
00014  *********************************/
00015 
00016 /* This Class Header */
00017 #include "TrackingTools/GeomPropagators/interface/SmartPropagator.h"
00018 
00019 /* Collaborating Class Header */
00020 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00021 #include "DataFormats/GeometrySurface/interface/BoundPlane.h"
00022 #include "DataFormats/GeometrySurface/interface/SimpleCylinderBounds.h"
00023 
00024 #include <DataFormats/GeometrySurface/interface/BoundCylinder.h>
00025 
00026 #include "TrackingTools/GeomPropagators/interface/TrackerBounds.h"
00027 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00028 
00029 /* Base Class Headers */
00030 
00031 /* C++ Headers */
00032 
00033 /* ====================================================================== */
00034 
00035 /* static member */
00036 ReferenceCountingPointer<BoundCylinder> & SmartPropagator::theTkVolume() {
00037   static ReferenceCountingPointer<BoundCylinder> local=0;
00038   return local;
00039 }
00040 
00041 
00042 
00043 /* Constructor */ 
00044 SmartPropagator::SmartPropagator(Propagator* aTkProp, Propagator* aGenProp, const MagneticField* field,
00045                                  PropagationDirection dir, float epsilon) :
00046   Propagator(dir), theTkProp(aTkProp->clone()), theGenProp(aGenProp->clone()), theField(field) { 
00047 
00048   if (theTkVolume()==0) initTkVolume(epsilon);
00049 
00050 }
00051 
00052 
00053 SmartPropagator::SmartPropagator(const Propagator& aTkProp, const Propagator& aGenProp,const MagneticField* field,
00054                                  PropagationDirection dir, float epsilon) :
00055   Propagator(dir), theTkProp(aTkProp.clone()), theGenProp(aGenProp.clone()), theField(field) {
00056 
00057   if (theTkVolume()==0) initTkVolume(epsilon);
00058 
00059 }
00060 
00061 
00062 SmartPropagator::SmartPropagator(const SmartPropagator& aProp) :
00063   Propagator(aProp.propagationDirection()), theTkProp(0), theGenProp(0) { 
00064     if (aProp.theTkProp)
00065       theTkProp=aProp.getTkPropagator()->clone();
00066     if (aProp.theGenProp)
00067       theTkProp=aProp.getGenPropagator()->clone();
00068 
00069     //SL since it's a copy constructor, then the TkVolume has been already
00070     //initialized
00071     //if (theTkVolume==0) initTkVolume(epsilon);
00072 
00073   }
00074 
00075 /* Destructor */ 
00076 SmartPropagator::~SmartPropagator() {
00077 
00078   delete theTkProp;
00079   delete theGenProp;
00080 
00081 }
00082 
00083 
00084 /* Operations */ 
00085 void SmartPropagator::initTkVolume(float epsilon) {
00086 
00087   //
00088   // fill tracker dimensions
00089   //
00090   float radius = TrackerBounds::radius();
00091   float r_out  = radius + epsilon/2;
00092   float r_in   = r_out - epsilon;
00093   float z_max  = TrackerBounds::halfLength();
00094   float z_min  = - z_max;
00095 
00096   Surface::PositionType pos(0,0,0); // centered at the global origin
00097   Surface::RotationType rot; // unit matrix - barrel cylinder orientation
00098 
00099   theTkVolume() = BoundCylinder::build(pos, rot, radius, SimpleCylinderBounds(r_in, r_out, z_min, z_max));
00100 
00101 }
00102 
00103 
00104 TrajectoryStateOnSurface SmartPropagator::propagate(const FreeTrajectoryState& fts, 
00105                                                     const Surface& surface) const {
00106   return Propagator::propagate( fts, surface);
00107 }
00108 
00109 
00110 TrajectoryStateOnSurface SmartPropagator::propagate(const FreeTrajectoryState& fts, 
00111                                                     const Plane& plane) const {
00112 
00113   if (insideTkVol(fts) && insideTkVol(plane)) {
00114     return getTkPropagator()->propagate(fts, plane);
00115   } else {
00116     return getGenPropagator()->propagate(fts, plane);
00117   }
00118 
00119 }
00120 
00121 
00122 TrajectoryStateOnSurface SmartPropagator::propagate(const FreeTrajectoryState& fts, 
00123                                                     const Cylinder& cylinder) const {
00124   if (insideTkVol(fts) && insideTkVol(cylinder)) {
00125     return getTkPropagator()->propagate(fts, cylinder);
00126   } else {
00127     return getGenPropagator()->propagate(fts, cylinder);
00128   }
00129 
00130 }
00131 
00132 std::pair<TrajectoryStateOnSurface,double> 
00133 SmartPropagator::propagateWithPath(const FreeTrajectoryState& fts, 
00134                                    const Plane& plane) const 
00135 {
00136   if (insideTkVol(fts) && insideTkVol(plane)) {
00137     return getTkPropagator()->propagateWithPath(fts, plane);
00138   } else {
00139     return getGenPropagator()->propagateWithPath(fts, plane);
00140   }
00141 }
00142 
00143 std::pair<TrajectoryStateOnSurface,double> 
00144 SmartPropagator::propagateWithPath(const FreeTrajectoryState& fts, 
00145                                    const Cylinder& cylinder) const
00146 {
00147   if (insideTkVol(fts) && insideTkVol(cylinder)) {
00148     return getTkPropagator()->propagateWithPath(fts, cylinder);
00149   } else {
00150     return getGenPropagator()->propagateWithPath(fts, cylinder);
00151   }
00152 }
00153 
00154 bool SmartPropagator::insideTkVol(const FreeTrajectoryState& fts) const {
00155 
00156   GlobalPoint gp = fts.position();
00157 //  LocalPoint lp = theTkVolume()->toLocal(gp);
00158 //  return theTkVolume()->bounds().inside(lp);
00159 
00160   return ( (gp.perp()<= TrackerBounds::radius()+10.) && (fabs(gp.z())<= TrackerBounds::halfLength()+10.) );
00161 }
00162 
00163 
00164 bool SmartPropagator::insideTkVol(const Surface& surface) const {
00165 
00166   GlobalPoint gp = surface.position();
00167  // LocalPoint lp = theTkVolume()->toLocal(gp);
00168 
00169  // return theTkVolume()->bounds().inside(lp);
00170   return ( (gp.perp()<= TrackerBounds::radius()+10.) && (fabs(gp.z())<= TrackerBounds::halfLength()+10.) );
00171 
00172 
00173 }
00174 
00175 
00176 bool SmartPropagator::insideTkVol( const BoundCylinder& cylin)  const {
00177 
00178   GlobalPoint gp(cylin.radius(),0.,(cylin.bounds().length())/2.);
00179 //  LocalPoint lp = theTkVolume()->toLocal(gp);
00180 //  return theTkVolume()->bounds().inside(lp);
00181   return ( (gp.perp()<= TrackerBounds::radius()+10.) && (fabs(gp.z())<= TrackerBounds::halfLength()+10.) );
00182 
00183 
00184 }
00185 
00186 
00187 bool SmartPropagator::insideTkVol( const Plane& plane)  const {
00188 
00189   GlobalPoint gp = plane.position();
00190 //  LocalPoint lp = theTkVolume()->toLocal(gp);
00191 //  return theTkVolume()->bounds().inside(lp);
00192   return ( (gp.perp()<= TrackerBounds::radius()+10.) && (fabs(gp.z())<= TrackerBounds::halfLength()+10.) );
00193 
00194 
00195 }
00196 
00197 
00198 Propagator* SmartPropagator::getTkPropagator() const {
00199 
00200   return theTkProp;
00201 
00202 }
00203 
00204 
00205 Propagator* SmartPropagator::getGenPropagator() const {
00206 
00207   return theGenProp;
00208 
00209 }
00210 
00211