CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/TrackPropagation/RungeKutta/src/RKOne4OrderStep.h

Go to the documentation of this file.
00001 #ifndef RKOne4OrderStep_H
00002 #define RKOne4OrderStep_H
00003 
00004 #include "FWCore/Utilities/interface/Visibility.h"
00005 #include "RK4OneStepTempl.h"
00006 
00007 #include <utility>
00008 
00009 template <typename T, int N>
00010 class dso_internal RKOne4OrderStep {
00011 public:
00012 
00013   typedef T                                   Scalar;
00014   typedef RKSmallVector<T,N>                  Vector;
00015 
00016   std::pair< Vector, T> 
00017   operator()( Scalar startPar, const Vector& startState,
00018               const RKDerivative<T,N>& deriv,
00019               const RKDistance<T,N>& dist, Scalar step) {
00020     const Scalar huge = 1.e5;  // ad hoc protection against infinities, must be done better!
00021     const Scalar hugediff = 100.;
00022 
00023     RK4OneStepTempl<T,N> solver;
00024     Vector one(       solver(startPar, startState, deriv, step));
00025     if (std::abs(one[0])>huge || std::abs(one(1)>huge)) return std::pair<Vector, Scalar>(one,hugediff);
00026 
00027     Vector firstHalf( solver(startPar, startState, deriv, step/2));
00028     Vector secondHalf(solver(startPar+step/2, firstHalf, deriv, step/2));
00029     Scalar diff = dist(one, secondHalf, startPar+step);
00030     return std::pair<Vector, Scalar>(secondHalf,diff);
00031   }
00032 };
00033 #endif