CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/TrackingTools/GsfTracking/src/GsfPropagatorWithMaterial.cc

Go to the documentation of this file.
00001 #include "TrackingTools/GsfTracking/interface/GsfPropagatorWithMaterial.h"
00002 
00003 #include "TrackingTools/GsfTools/interface/MultiTrajectoryStateAssembler.h"
00004 #include "TrackingTools/GeomPropagators/interface/AnalyticalPropagator.h"
00005 #include "TrackingTools/GeomPropagators/interface/PropagationDirectionFromPath.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 #include "FWCore/Utilities/interface/Exception.h"
00008 
00009 GsfPropagatorWithMaterial::GsfPropagatorWithMaterial (const Propagator& aPropagator,
00010                                                       const GsfMaterialEffectsUpdator& aMEUpdator) :
00011   Propagator(aPropagator.propagationDirection()),
00012   theGeometricalPropagator(new GsfPropagatorAdapter(aPropagator)),
00013   theConvolutor(new FullConvolutionWithMaterial(aMEUpdator)),
00014   theMaterialLocation(atDestination)
00015 {  
00016   //   if ( propWithPathTimer1==0 )  defineTimer();
00017 }
00018 
00019 GsfPropagatorWithMaterial::GsfPropagatorWithMaterial (const GsfPropagatorAdapter& aGsfPropagator,
00020                                                       const FullConvolutionWithMaterial& aConvolutor) :
00021   Propagator(aGsfPropagator.propagationDirection()),
00022   theGeometricalPropagator(aGsfPropagator.clone()),
00023   theConvolutor(aConvolutor.clone()),
00024   theMaterialLocation(atDestination) 
00025 {  
00026   //   if ( propWithPathTimer1==0 )  defineTimer();
00027 }
00028 
00029 // void
00030 // GsfPropagatorWithMaterial::defineTimer()
00031 // {
00032 //   if ( propWithPathTimer1==0 ) {
00033 //     propWithPathTimer1 = 
00034 //       &(*TimingReport::current())[string("GsfPropagatorWithMaterial:toPlane")];
00035 //     propWithPathTimer2 = 
00036 //       &(*TimingReport::current())[string("GsfPropagatorWithMaterial:toCylinder")];
00037 //     static SimpleConfigurable<bool> timeConf(false,"GsfPropagatorWithMaterial:activateTiming");
00038 //     if ( timeConf.value() ) {
00039 //       propWithPathTimer1->switchCPU(false);
00040 //       propWithPathTimer2->switchCPU(false);
00041 //     }
00042 //     else {
00043 //       propWithPathTimer1->switchOn(false);
00044 //       propWithPathTimer2->switchOn(false);
00045 //     }
00046 //   }
00047 // }
00048 
00049 std::pair<TrajectoryStateOnSurface,double> 
00050 GsfPropagatorWithMaterial::propagateWithPath (const TrajectoryStateOnSurface& tsos, 
00051                                               const Plane& plane) const {
00052   //   TimeMe t1(*propWithPathTimer1,false);
00053   //
00054   // add material before propagation?
00055   //
00056   TrajectoryStateOnSurface stateAtSource;
00057   if ( materialAtSource() )
00058     stateAtSource = convoluteStateWithMaterial(tsos,propagationDirection());
00059   else
00060     stateAtSource = tsos;
00061   if ( !stateAtSource.isValid() )  return TsosWP(stateAtSource,0.);
00062   //
00063   // geometrical propagation
00064   //
00065   TsosWP propStateWP(theGeometricalPropagator->propagateWithPath(stateAtSource,plane));
00066   if ( !(propStateWP.first).isValid() )  return propStateWP;
00067   //
00068   // return convoluted state
00069   //
00070   return convoluteWithMaterial(propStateWP);
00071 }
00072 
00073 std::pair<TrajectoryStateOnSurface,double> 
00074 GsfPropagatorWithMaterial::propagateWithPath (const TrajectoryStateOnSurface& tsos, 
00075                                               const Cylinder& cylinder) const {
00076   //   TimeMe t2(*propWithPathTimer2,false);
00077   //
00078   // add material before propagation?
00079   //
00080   TrajectoryStateOnSurface stateAtSource;
00081   if ( materialAtSource() )
00082     stateAtSource = convoluteStateWithMaterial(tsos,propagationDirection());
00083   else
00084     stateAtSource = tsos;
00085   if ( !stateAtSource.isValid() )  return TsosWP(stateAtSource,0.);
00086   //
00087   // geometrical propagation
00088   //
00089   TsosWP propStateWP(theGeometricalPropagator->propagateWithPath(stateAtSource,cylinder));
00090   if ( !(propStateWP.first).isValid() )  return propStateWP;
00091   //
00092   // return convoluted state
00093   //
00094   return convoluteWithMaterial(propStateWP);
00095 }
00096 
00097 std::pair<TrajectoryStateOnSurface,double> 
00098 GsfPropagatorWithMaterial::propagateWithPath (const FreeTrajectoryState& fts, 
00099                                               const Plane& plane) const {
00100   static int nWarn(0);
00101   if ( nWarn++<5 )
00102     edm::LogInfo("GsfPropagatorWithMaterial") 
00103       << "GsfPropagatorWithMaterial used from FTS: input state might have been collapsed!";
00104   TsosWP propStateWP = theGeometricalPropagator->propagateWithPath(fts,plane);
00105   if ( !(propStateWP.first).isValid() || materialAtSource() )  return propStateWP;
00106   //
00107   // return convoluted state
00108   //
00109   return convoluteWithMaterial(propStateWP);
00110 }
00111 
00112 std::pair<TrajectoryStateOnSurface,double> 
00113 GsfPropagatorWithMaterial::propagateWithPath (const FreeTrajectoryState& fts, 
00114                                               const Cylinder& cylinder) const {
00115   static int nWarn(0);
00116   if ( nWarn++<5 )
00117     edm::LogInfo("GsfPropagatorWithMaterial") 
00118       << "GsfPropagatorWithMaterial used from FTS: input state might have been collapsed!";
00119   TsosWP propStateWP = theGeometricalPropagator->propagateWithPath(fts,cylinder);
00120   if ( !(propStateWP.first).isValid() || materialAtSource() )  return propStateWP;
00121   //
00122   // return convoluted state
00123   //
00124   return convoluteWithMaterial(propStateWP);
00125 }
00126 
00127 
00128 void GsfPropagatorWithMaterial::setPropagationDirection (PropagationDirection dir) const {
00129   theGeometricalPropagator->setPropagationDirection(dir);
00130   Propagator::setPropagationDirection(dir);
00131 }
00132 
00133 std::pair<TrajectoryStateOnSurface,double>
00134 GsfPropagatorWithMaterial::convoluteWithMaterial (const TsosWP& aStateWithPath) const
00135 {
00136   //
00137   // convolute with material
00138   //
00139   PropagationDirection propDir = PropagationDirectionFromPath()(aStateWithPath.second,
00140                                                                 propagationDirection());
00141   return TsosWP((*theConvolutor)(aStateWithPath.first,propDir),
00142                 aStateWithPath.second);
00143 }
00144 
00145 TrajectoryStateOnSurface
00146 GsfPropagatorWithMaterial::convoluteStateWithMaterial (const TrajectoryStateOnSurface tsos,
00147                                                        const PropagationDirection propDir) const
00148 {
00149   //
00150   // convolute with material
00151   //
00152   return (*theConvolutor)(tsos,propDir);
00153 }
00154 
00155 bool
00156 GsfPropagatorWithMaterial::materialAtSource() const {
00157   if ( propagationDirection()==anyDirection ) {
00158     if ( theMaterialLocation!=atDestination ) { 
00159       throw cms::Exception("LogicError")
00160         << "PropagatorWithMaterial: propagation direction = anyDirection is "
00161         << "incompatible with adding of material at source";
00162     }
00163   }
00164   return theMaterialLocation==atSource || (theMaterialLocation==fromDirection&&
00165                                            propagationDirection()==alongMomentum);
00166 }
00167 
00168 // TimingReport::Item* GsfPropagatorWithMaterial::propWithPathTimer1(0);
00169 // TimingReport::Item* GsfPropagatorWithMaterial::propWithPathTimer2(0);