Changeset 9212 for trunk/MagicSoft/Mars/mextralgo
- Timestamp:
- 01/06/09 13:07:00 (16 years ago)
- Location:
- trunk/MagicSoft/Mars/mextralgo
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mextralgo/MExtralgoSpline.cc
r8795 r9212 18 18 ! Author(s): Markus Gaug 09/2004 <mailto:markus@ifae.es> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2002-200 720 ! Copyright: MAGIC Software Development, 2002-2008 21 21 ! 22 22 ! … … 47 47 // (Note that the variables fDer are not real first derivative coefficients.) 48 48 // 49 // Note, this spline is not optimized to be evaluated many many times, but 50 // it is optimized to be initialized very fast with new values again and 51 // again. 52 // 49 53 ////////////////////////////////////////////////////////////////////////////// 50 54 #include "MExtralgoSpline.h" … … 179 183 // at x, until x==0. If y is not found -2 is returned. 180 184 // 181 Double_t MExtralgoSpline::SearchY (Float_t x, Float_t y) const185 Double_t MExtralgoSpline::SearchYdn(Float_t x, Float_t y) const 182 186 { 183 187 if (x>=fNum-1) … … 185 189 186 190 Int_t i = TMath::FloorNint(x); 191 if (i<0) 192 return -2; 193 187 194 Double_t rc = FindY(i, kTRUE, y, 0, x-i); 188 195 while (--i>=0 && rc<0) … … 198 205 199 206 Int_t i = TMath::FloorNint(x); 207 if (i>fNum-2) 208 return -2; 209 200 210 Double_t rc = FindY(i, kFALSE, y, x-i, 1.); 201 while ( i++<fNum-1 && rc<0)211 while (++i<fNum-1 && rc<0) 202 212 rc = FindY(i, kFALSE, y); 203 213 … … 287 297 // Search downwards for fHeight/2 288 298 // By doing also a search upwards we could extract the pulse width 289 fTime = SearchY (maxpos, h);299 fTime = SearchYdn(maxpos, h); 290 300 fTimeDev = 0; 291 301 if (width) -
trunk/MagicSoft/Mars/mextralgo/MExtralgoSpline.h
r8928 r9212 58 58 59 59 // Evaluate first derivative of spline in the interval i with x=[0;1[ 60 inline Double_t EvalDeriv1(const Float_t x, const Int_t i) const60 inline Double_t EvalDeriv1(const Int_t i, const Float_t x) const 61 61 { 62 62 // x := [0; 1[ … … 64 64 const Double_t difder = fDer2[i+1]-fDer2[i]; 65 65 66 return 3*difder*x*x + 6*fDer2[i]*x - 2*fDer2[i] - fDer2[i+1] + difval; 66 //return 3*difder*x*x + 6*fDer2[i]*x - 2*fDer2[i] - fDer2[i+1] + difval; 67 return 3*difder*x*x + (6*x - 2)*fDer2[i] - fDer2[i+1] + difval; 67 68 } 68 69 69 70 // Evaluate second derivative of spline in the interval i with x=[0;1[ 70 inline Double_t EvalDeriv2(const Float_t x, const Int_t i) const71 inline Double_t EvalDeriv2(const Int_t i, const Float_t x) const 71 72 { 72 73 // x := [0; 1[ … … 75 76 76 77 Double_t FindY(Int_t i, Bool_t downwards, Double_t y=0, Double_t min=0, Double_t max=1) const; 77 Double_t SearchY(Float_t maxpos, Float_t y) const;78 Double_t SearchYup(Float_t maxpos, Float_t y) const;79 78 80 79 Int_t EvalDerivEq0(const Int_t i, Double_t &x1, Double_t &x2) const; … … 141 140 142 141 // Calculate the intgeral of the Eval-function in 143 // bin i from a=[0;1[ to b=[0;1[142 // bin i from 0 <= a < b < 1 144 143 inline Double_t EvalInteg(Int_t i, Float_t a, Float_t b) const 145 144 { … … 268 267 return kFALSE; 269 268 270 const Bool_t ismax1 = x1>=min && x1<max && EvalDeriv2( x1, i)<0;271 const Bool_t ismax2 = x2>=min && x2<max && EvalDeriv2( x2, i)<0;269 const Bool_t ismax1 = x1>=min && x1<max && EvalDeriv2(i, x1)<0; 270 const Bool_t ismax2 = x2>=min && x2<max && EvalDeriv2(i, x2)<0; 272 271 273 272 if (!ismax1 && !ismax2) … … 323 322 324 323 Float_t EvalAt(const Float_t x) const; 324 Float_t Deriv1(const Float_t x) const; 325 326 Double_t SearchYdn(Float_t maxpos, Float_t y) const; 327 Double_t SearchYup(Float_t maxpos, Float_t y) const; 328 329 Double_t SearchYdn(Float_t y) const { return SearchYdn(fNum, y); } 330 Double_t SearchYup(Float_t y) const { return SearchYup(0, y); } 325 331 }; 326 332 … … 335 341 } 336 342 343 inline Float_t MExtralgoSpline::Deriv1(const Float_t x) const 344 { 345 Int_t i = TMath::FloorNint(x); 346 Float_t f = x-i; 347 348 Align(i, f); 349 350 return EvalDeriv1(i, f); 351 } 352 337 353 #endif
Note:
See TracChangeset
for help on using the changeset viewer.