Changeset 8545
- Timestamp:
- 06/11/07 16:49:41 (18 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r8543 r8545 19 19 -*-*- END OF LINE -*-*- 20 20 21 2007/06/06 Markus Meyer 22 23 * Cosy/tpoint/: 24 - added tpoint files from Jan. 2007 to June 2007 21 2007/06/11 Thomas Bretz 22 23 * sponde.cc: 24 - added check for validity of resource file 25 26 * mbase/MMath.cc: 27 - small speed improvement to calclation of three solutions 28 for the third order pol. 29 - for a second order pol. set x1 and x2 if it has only one 30 solution 31 32 * mbase/MMath.h: 33 - speed improvement using ::cbrt instead of pow(x, 1/3) 34 35 * mcalib/MCalibrationChargeCalc.cc: 36 - improved output 37 38 * mextralgo/MExtralgoSpline.cc: 39 - speed improvement by using a look up table for often used 40 and identical coefficients 41 - use MMath::SolvePol2 to get the null-points of the first 42 derivative (EvalDerivEq0) 43 - removed a lot of old an obsolete comments 25 44 26 45 -
trunk/MagicSoft/Mars/mextralgo/MExtralgoSpline.cc
r8500 r8545 18 18 ! Author(s): Markus Gaug 09/2004 <mailto:markus@ifae.es> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2002-200 620 ! Copyright: MAGIC Software Development, 2002-2007 21 21 ! 22 22 ! … … 53 53 54 54 #include "../mbase/MMath.h" 55 #include "../mbase/MArrayF.h" 55 56 56 57 using namespace std; … … 72 73 return; 73 74 75 // Look up table for coefficients 76 static MArrayF lut; 77 78 // If the lut is not et large enough resize and reclaculate 79 if (fNum>(Int_t)lut.GetSize()) 80 { 81 lut.Set(fNum); 82 83 lut[0] = 0.; 84 for (Int_t i=1; i<fNum-1; i++) 85 lut[i] = -1.0/(lut[i-1] + 4); 86 } 87 88 // Calculate the coefficients used to get reproduce the first and 89 // second derivative. 74 90 fDer1[0] = 0.; 75 fDer2[0] = 0.;76 77 91 for (Int_t i=1; i<fNum-1; i++) 78 92 { 79 const Float_t pp = fDer2[i-1] + 4.;80 81 fDer2[i] = -1.0/pp;82 83 93 const Float_t d1 = fVal[i+1] - 2*fVal[i] + fVal[i-1]; 84 fDer1[i] = ( 6.0*d1-fDer1[i-1])/pp;94 fDer1[i] = (fDer1[i-1]-d1)*lut[i]; 85 95 } 86 96 87 97 fDer2[fNum-1] = 0.; 88 89 98 for (Int_t k=fNum-2; k>=0; k--) 90 fDer2[k] = fDer2[k]*fDer2[k+1] + fDer1[k]; 91 92 for (Int_t k=fNum-2; k>=0; k--) 93 fDer2[k] /= 6.; 99 fDer2[k] = lut[k]*fDer2[k+1] + fDer1[k]; 100 } 101 102 // -------------------------------------------------------------------------- 103 // 104 // Return the two results x1 and x2 of f'(x)=0 for the third order 105 // polynomial (spline) in the interval i. Return the number of results. 106 // (0 if the fist derivative does not have a null-point) 107 // 108 Int_t MExtralgoSpline::EvalDerivEq0(const Int_t i, Double_t &x1, Double_t &x2) const 109 { 110 const Double_t difder = fDer2[i+1]-fDer2[i]; 111 const Double_t difval = fVal[i+1] -fVal[i]; 112 113 return MMath::SolvePol2(3*difder, 6*fDer2[i], difval-2*fDer2[i]-fDer2[i+1], x1, x2); 94 114 } 95 115 … … 114 134 const Double_t c = fVal[i+1]-fVal[i] -2*fDer2[i]-fDer2[i+1]; 115 135 const Double_t d = fVal[i] - y; 136 137 // If the first derivative is nowhere==0 and it is increasing 138 // in one point, and the value we search is outside of the 139 // y-interval... it cannot be there 140 // if (c>0 && (d>0 || fVal[i+1]<y) && b*b<3*c*a) 141 // return -2; 116 142 117 143 Double_t x1, x2, x3; -
trunk/MagicSoft/Mars/mextralgo/MExtralgoSpline.h
r8524 r8545 30 30 31 31 Float_t fHeightTm; 32 33 // Float_t fResolution;34 32 35 33 // Result … … 117 115 */ 118 116 117 Int_t EvalDerivEq0(const Int_t i, Double_t &x1, Double_t &x2) const; 118 /* 119 119 inline void EvalDerivEq0(const Int_t i, Float_t &rc1, Float_t &rc2) const 120 120 { 121 / *--- ORIGINAL CODE ---121 // --- ORIGINAL CODE --- 122 122 Double_t sumder = fDer2[i]+fDer2[i+1]; 123 123 Double_t difder = fDer2[i]-fDer2[i+1]; … … 128 128 Double_t denom = -3*(fDer2[i+1]-fDer2[i]); 129 129 130 rc1 = -(3*fDer2[i] + sqt3)/denom;131 rc2 = -(3*fDer2[i] - sqt3)/denom;132 */ 133 130 rc1 = (3*fDer2[i] + sqt3)/denom; 131 rc2 = (3*fDer2[i] - sqt3)/denom; 132 133 // --- NEW CODE --- 134 134 Double_t sumder = fDer2[i]+fDer2[i+1]; 135 135 Double_t difder = fDer2[i]-fDer2[i+1]; … … 139 139 Double_t sqt3 = sqt1+sqt2<0 ? 0 : sqrt((sqt1 + sqt2)/3); 140 140 141 rc1 = -(fDer2[i] + sqt3)/difder;142 rc2 = -(fDer2[i] - sqt3)/difder;143 } 141 rc1 = (fDer2[i] + sqt3)/difder; 142 rc2 = (fDer2[i] - sqt3)/difder; 143 }*/ 144 144 145 145 // Calculate the "Stammfunktion" of the Eval-function … … 355 355 // Find analytical maximum in the bin i in the interval [min,max[ 356 356 357 Float_t x1, x2; 358 EvalDerivEq0(i, x1, x2); 357 Double_t x1, x2; 358 if (!EvalDerivEq0(i, x1, x2)) 359 return kFALSE; 360 359 361 // const Float_t x1 = EvalDerivEq0S1(i); 360 362 // const Float_t x2 = EvalDerivEq0S2(i); … … 479 481 void SetExtractionType(ExtractionType_t typ) { fExtractionType = typ; } 480 482 void SetHeightTm(Float_t h) { fHeightTm = h; } 481 // void SetResolution(Float_t res) { fResolution=res; }482 483 483 484 Float_t GetTime() const { return fTime; }
Note:
See TracChangeset
for help on using the changeset viewer.