Changeset 7055 for trunk/MagicSoft/Mars/msignal
- Timestamp:
- 05/18/05 17:54:27 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/msignal
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSpline.cc
r7043 r7055 432 432 } 433 433 } 434 434 435 435 fAbMax = fHiGainSignal[maxpos]; 436 437 Float_t pp;438 436 439 437 fHiGainSecondDeriv[0] = 0.; … … 442 440 for (Int_t i=1;i<range-1;i++) 443 441 { 444 pp = fHiGainSecondDeriv[i-1] + 4.;442 const Float_t pp = fHiGainSecondDeriv[i-1] + 4.; 445 443 fHiGainSecondDeriv[i] = -1.0/pp; 446 fHiGainFirstDeriv [i] = fHiGainSignal[i+1] - fHiGainSignal[i] - fHiGainSignal[i] + fHiGainSignal[i-1];444 fHiGainFirstDeriv [i] = 2*(fHiGainSignal[i+1] - fHiGainSignal[i]); 447 445 fHiGainFirstDeriv [i] = (6.0*fHiGainFirstDeriv[i]-fHiGainFirstDeriv[i-1])/pp; 448 446 } … … 474 472 } 475 473 else 476 { 477 Float_t start = 2. + nsx; 478 Float_t last = start + fRiseTimeHiGain + fFallTimeHiGain; 479 480 if (int(last) > range) 481 { 482 const Int_t diff = range - int(last); 483 last -= diff; 484 start -= diff; 485 } 486 487 CalcIntegralHiGain(sum, start, last); 488 } 474 sum = CalcIntegralHiGain(2. + nsx, range); 475 489 476 fRandomIter++; 490 477 return; … … 492 479 493 480 // 494 // Allow no saturated slice 495 // and 481 // Allow no saturated slice and 496 482 // Don't start if the maxpos is too close to the limits. 497 483 // 498 if (sat || maxpos < TMath::Ceil(fRiseTimeHiGain) || maxpos > range-2) 499 { 500 484 const Bool_t limlo = maxpos < TMath::Ceil(fRiseTimeHiGain); 485 const Bool_t limup = maxpos > range-TMath::Ceil(fFallTimeHiGain)-1; 486 if (sat || limlo || limup) 487 { 501 488 dtime = 1.0; 502 489 if (fExtractionType == kAmplitude) … … 506 493 return; 507 494 } 508 509 if (maxpos > range - 2) 510 CalcIntegralHiGain(sum, (Float_t)range - fRiseTimeHiGain - fFallTimeHiGain, (Float_t)range - 0.001); 511 else 512 CalcIntegralHiGain(sum, 0.001, fRiseTimeHiGain + fFallTimeHiGain); 513 514 time = (Float_t)(fHiGainFirst + maxpos - 1); 495 496 sum = CalcIntegralHiGain(limlo ? 0 : range, range); 497 time = (Float_t)(fHiGainFirst + maxpos - 1); 515 498 return; 516 499 } … … 561 544 if (fAbMaxPos > upper-0.1) 562 545 { 563 564 546 upper = 1. + maxpos; 565 547 lower = (Float_t)maxpos; … … 678 660 while (klo > 0) 679 661 { 680 klo--; 681 if (fHiGainSignal[klo] < fHalfMax) 662 if (fHiGainSignal[--klo] < fHalfMax) 682 663 break; 683 664 } … … 719 700 + (b*b*b-b)*fHiGainSecondDeriv[khi]; 720 701 721 if (y > fHalfMax) 722 back = kTRUE; 723 else 724 back = kFALSE; 702 back = y > fHalfMax; 725 703 726 704 if (++cnt > maxcnt) … … 730 708 } 731 709 732 time = (Float_t)fHiGainFirst + x;733 710 // 734 711 // Now integrate the whole thing! 735 712 // 736 737 Float_t start = fAbMaxPos - fRiseTimeHiGain; 738 Float_t last = fAbMaxPos + fFallTimeHiGain; 739 740 const Int_t diff = int(last) - range; 741 742 if (diff > 0) 743 { 744 last -= diff; 745 start -= diff; 746 } 747 748 CalcIntegralHiGain(sum, start, last); 713 time = (Float_t)fHiGainFirst + x; 714 sum = CalcIntegralHiGain(fAbMaxPos - fRiseTimeHiGain, range); 749 715 } 750 716 … … 795 761 fAbMax = fLoGainSignal[maxpos]; 796 762 797 Float_t pp;798 799 763 fLoGainSecondDeriv[0] = 0.; 800 764 fLoGainFirstDeriv[0] = 0.; … … 802 766 for (Int_t i=1;i<range-1;i++) 803 767 { 804 pp = fLoGainSecondDeriv[i-1] + 4.;768 const Float_t pp = fLoGainSecondDeriv[i-1] + 4.; 805 769 fLoGainSecondDeriv[i] = -1.0/pp; 806 fLoGainFirstDeriv [i] = fLoGainSignal[i+1] - fLoGainSignal[i] - fLoGainSignal[i] + fLoGainSignal[i-1];770 fLoGainFirstDeriv [i] = 2*(fLoGainSignal[i+1] - fLoGainSignal[i]); 807 771 fLoGainFirstDeriv [i] = (6.0*fLoGainFirstDeriv[i]-fLoGainFirstDeriv[i-1])/pp; 808 772 } … … 833 797 } 834 798 else 835 { 836 Float_t start = 2. + nsx; 837 Float_t last = start + fRiseTimeLoGain + fFallTimeLoGain; 838 839 if (int(last) > range) 840 { 841 const Int_t diff = range - int(last); 842 last -= diff; 843 start -= diff; 844 } 845 846 CalcIntegralLoGain(sum, start, last); 847 } 799 sum = CalcIntegralLoGain(2. + nsx, range); 800 848 801 fRandomIter++; 849 802 return; 850 803 } 851 804 // 852 // Allow no saturated slice 853 // and 805 // Allow no saturated slice and 854 806 // Don't start if the maxpos is too close to the limits. 855 807 // 856 if (sat || maxpos < TMath::Ceil(fRiseTimeLoGain) || maxpos > range-2) 857 { 858 808 const Bool_t limlo = maxpos < TMath::Ceil(fRiseTimeLoGain); 809 const Bool_t limup = maxpos > range-TMath::Ceil(fFallTimeLoGain)-1; 810 if (sat || limlo || limup) 811 { 859 812 dtime = 1.0; 860 813 if (fExtractionType == kAmplitude) … … 864 817 return; 865 818 } 866 867 if (maxpos > range-2) 868 CalcIntegralLoGain(sum, (Float_t)range - fRiseTimeLoGain - fFallTimeLoGain -1., (Float_t)range - 0.001); 869 else 870 CalcIntegralLoGain(sum, 0.001, fRiseTimeLoGain + fFallTimeLoGain + 1.); 871 819 820 sum = CalcIntegralLoGain(limlo ? 0 : range, range); 872 821 time = (Float_t)(fLoGainFirst + maxpos - 1); 873 822 return; … … 1080 1029 + (b*b*b-b)*fLoGainSecondDeriv[khi]; 1081 1030 1082 if (y > fHalfMax) 1083 back = kTRUE; 1084 else 1085 back = kFALSE; 1031 back = y > fHalfMax; 1086 1032 1087 1033 if (++cnt > maxcnt) … … 1091 1037 } 1092 1038 1093 time = x + (Int_t)fLoGainFirst;1094 1095 1039 // 1096 1040 // Now integrate the whole thing! 1097 1041 // 1098 Float_t start = fAbMaxPos - fRiseTimeLoGain; 1099 Float_t last = fAbMaxPos + fFallTimeLoGain; 1100 1101 const Int_t diff = int(last) - range; 1102 1103 if (diff > 0) 1104 { 1105 last -= diff; 1106 start -= diff; 1107 } 1108 CalcIntegralLoGain(sum, start, last); 1042 time = x + (Int_t)fLoGainFirst; 1043 sum = CalcIntegralLoGain(fAbMaxPos - fRiseTimeLoGain, range); 1109 1044 } 1110 1045 1111 void MExtractTimeAndChargeSpline::CalcIntegralHiGain(Float_t &sum, Float_t start, Float_t last) 1046 Float_t MExtractTimeAndChargeSpline::CalcIntegralHiGain(Float_t start, Float_t range) const 1112 1047 { 1113 const Float_t step = 0.2; 1114 1048 // The number of steps is calculated directly from the integration 1049 // window. This is the only way to ensure we are not dealing with 1050 // numerical rounding uncertanties, because we always get the same 1051 // value under the same conditions -- it might still be different on 1052 // other machines! 1053 const Float_t step = 0.2; 1054 const Float_t width = fRiseTimeHiGain+fFallTimeHiGain; 1055 const Float_t max = range-1 - (width+step); 1056 const Int_t num = TMath::Nint(width/step); 1057 1058 // The order is important. In some cases (limlo-/limup-check) it can 1059 // happen than max<0. In this case we start at 0 1060 if (start > max) 1061 start = max; 1115 1062 if (start < 0) 1116 { 1117 last -= start; 1118 start = 0.; 1119 } 1120 1121 const Int_t n = TMath::Nint((last-start)/step); 1063 start = 0; 1122 1064 1123 1065 start += step/2; 1124 1066 1125 sum = 0.;1126 for (Int_t i=0; i<n ; i++)1067 Double_t sum = 0.; 1068 for (Int_t i=0; i<num; i++) 1127 1069 { 1128 1070 const Float_t x = start+i*step; … … 1149 1091 } 1150 1092 sum *= step; // Transform sum in integral 1093 return sum; 1151 1094 } 1152 1095 1153 void MExtractTimeAndChargeSpline::CalcIntegralLoGain(Float_t &sum, Float_t start, Float_t last) 1096 Float_t MExtractTimeAndChargeSpline::CalcIntegralLoGain(Float_t start, Float_t range) const 1154 1097 { 1155 const Float_t step = 0.2; 1156 1098 // The number of steps is calculated directly from the integration 1099 // window. This is the only way to ensure we are not dealing with 1100 // numerical rounding uncertanties, because we always get the same 1101 // value under the same conditions -- it might still be different on 1102 // other machines! 1103 const Int_t cnt = 5; 1104 const Float_t width = fRiseTimeLoGain+fFallTimeLoGain; 1105 const Float_t max = range-1 - (width+step); 1106 const Int_t num = TMath::Nint(width/step); 1107 1108 // The order is important. In some cases (limlo-/limup-check) it can 1109 // happen than max<0. In this case we start at 0 1110 if (start > max) 1111 start = max; 1157 1112 if (start < 0) 1158 { 1159 last -= start; 1160 start = 0.; 1161 } 1162 1163 const Int_t n = TMath::Nint((last-start)/step); 1113 start = 0; 1164 1114 1165 1115 start += step/2; 1166 1116 1167 sum = 0.;1168 for (Int_t i=0; i<n ; i++)1117 Double_t sum = 0.; 1118 for (Int_t i=0; i<num; i++) 1169 1119 { 1170 1120 const Float_t x = start+i*step; … … 1191 1141 } 1192 1142 sum *= step; // Transform sum in integral 1143 return sum; 1193 1144 } 1194 1145 -
trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSpline.h
r6840 r7055 6 6 #endif 7 7 8 #ifndef MARS_MArrayF9 #include " MArrayF.h"8 #ifndef ROOT_TArrayF 9 #include "TArrayF.h" 10 10 #endif 11 11 … … 27 27 static const Float_t fgLoGainStartShift; //! Default for fLoGainStartShift (now set to -1.6) 28 28 29 MArrayF fHiGainSignal; //! Need fast access to the signals in a float way30 MArrayF fLoGainSignal; //! Store them in separate arrays31 MArrayF fHiGainFirstDeriv; //! High-gain discretized first derivatives32 MArrayF fLoGainFirstDeriv; //! Low-gain discretized first derivatives33 MArrayF fHiGainSecondDeriv; //! High-gain discretized second derivatives34 MArrayF fLoGainSecondDeriv; //! Low-gain discretized second derivatives29 TArrayF fHiGainSignal; //! Need fast access to the signals in a float way 30 TArrayF fLoGainSignal; //! Store them in separate arrays 31 TArrayF fHiGainFirstDeriv; //! High-gain discretized first derivatives 32 TArrayF fLoGainFirstDeriv; //! Low-gain discretized first derivatives 33 TArrayF fHiGainSecondDeriv; //! High-gain discretized second derivatives 34 TArrayF fLoGainSecondDeriv; //! Low-gain discretized second derivatives 35 35 36 36 Float_t fAbMax; //! Current maximum of the spline … … 53 53 Bool_t InitArrays(); 54 54 55 void CalcIntegralHiGain(Float_t &sum, Float_t start, Float_t last);56 void CalcIntegralLoGain(Float_t &sum, Float_t start, Float_t last);55 Float_t CalcIntegralHiGain(Float_t start, Float_t range) const; 56 Float_t CalcIntegralLoGain(Float_t start, Float_t range) const; 57 57 58 58 public:
Note:
See TracChangeset
for help on using the changeset viewer.