36 const int maxnOscillStep = 5 ;
37 const int maxnDivergingStep = 5 ;
45 double delta(0), prevdelta(0) ;
47 int nDivergingStep(0) ;
48 bool finished =
false ;
51 for (istep=0; istep <
_maxTry && !finished; ++istep) {
52 double prevflt1 =
flt1();
53 double prevflt2 =
flt2() ;
54 double prevprevdelta = prevdelta ;
64 delta = (newPos1 - newPos2).mag();
65 double step1 =
flt1() - prevflt1;
66 double step2 =
flt2() - prevflt2;
67 int pathDir1 = (step1 > 0.) ? 1 : -1;
68 int pathDir2 = (step2 > 0.) ? 1 : -1;
76 (fabs(step1) < distToErr1 && fabs(step2) < distToErr2 ) ||
77 (
status().success() == 3) ;
80 if( !finished && istep>2 &&
delta > prevdelta) {
81 if( prevdelta > prevprevdelta) {
83 if(++nDivergingStep>maxnDivergingStep) {
90 if(++nOscillStep>maxnOscillStep) {
101 _flt1 = prevflt1 + 0.5*step1 ;
102 _flt2 = prevflt2 + 0.5*step2 ;
105 delta = (newPos1 - newPos2).mag() ;
129 double fltLast = 0., fltBeforeLast = 0.;
130 for (
int i = 0; i <
_maxTry; i++) {
133 if (
status().failure())
return;
134 double step =
flt1() - fltLast;
135 pathDir = (step > 0.) ? 1 : -1;
138 bool mustStep = (fabs(step) > distToErr && step != 0.);
145 if (fabs(step) >= fabs(fltBeforeLast-fltLast) &&
146 fabs(fltBeforeLast-
flt1()) <= fabs(step)) {
148 double halfway = (fltBeforeLast + fltLast) / 2.;
154 if (nTinyStep > 3) mustStep =
false;
157#ifdef MDCPATREC_WARNING
158 std::cout<<
" ErrMsg(warning) "<<
"Alleged oscillation detected. "
159 << step <<
" " << fltLast-fltBeforeLast
160 <<
" " << i <<
" " << std::endl;
163 if (!mustStep)
return;
164 fltBeforeLast = fltLast;
181 static Hep3Vector dir1, dir2;
182 static Hep3Vector delDir1, delDir2;
187 Hep3Vector
delta = ((CLHEP::Hep3Vector)pos1) - ((CLHEP::Hep3Vector)pos2);
188 double ua = -
delta.dot(dir1);
189 double ub =
delta.dot(dir2);
190 double caa = dir1.mag2() +
delta.dot(delDir1);
191 double cbb = dir2.mag2() -
delta.dot(delDir2);
192 double cab = -dir1.dot(dir2);
193 double det = caa * cbb - cab * cab;
199 det = caa * cbb - cab * cab;
208 double df1 = (ua * cbb - ub * cab)/det;
209 int pathDir1 = (df1 > 0) ? 1 : -1;
210 double df2 = (ub * caa - ua * cab)/det;
211 int pathDir2 = (df2 > 0) ? 1 : -1;
222 const double smudge = 1.01 ;
223 if( fabs(df1) > smudge*distToErr1 ) {
225 df1 = smudge*distToErr1 * pathDir1 ;
227 df2 = (ub - df1*cab)/cbb ;
230 if( fabs(df2) > smudge*distToErr2 ) {
232 df2 = smudge*distToErr2 * pathDir2 ;
234 df1 = (ua - df2*cab)/cbb ;
236 if( fabs(df1) > smudge*distToErr1 ) {
237 df1 = smudge*distToErr1 * pathDir1 ;