Changeset 6980 for trunk/MagicSoft/Mars/msignal
- Timestamp:
- 04/27/05 17:23:36 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSpline.cc
r6913 r6980 21 21 ! 22 22 \* ======================================================================== */ 23 23 24 ////////////////////////////////////////////////////////////////////////////// 24 25 // … … 160 161 const Float_t MExtractTimeAndChargeSpline::fgOffsetLoGain = 1.7; // 5 ns 161 162 const Float_t MExtractTimeAndChargeSpline::fgLoGainStartShift = -1.8; 163 162 164 // -------------------------------------------------------------------------- 163 165 // … … 1060 1062 void MExtractTimeAndChargeSpline::CalcIntegralHiGain(Float_t &sum, Float_t start, Float_t last) 1061 1063 { 1062 1063 const Float_t step = 0.2; 1064 1065 if (start < 0) 1066 { 1067 last -= start; 1068 start = 0.; 1069 } 1070 1071 Int_t klo = int(start); 1072 Int_t khi = klo+1; 1073 1074 Float_t lo = TMath::Floor(start); 1075 Float_t up = lo + 1.; 1076 1077 const Int_t m = int((start-klo)/step); 1078 start = step*m + klo; // Correct start for the digitization due to resolution 1079 1080 Float_t x = start; 1081 Float_t a = up-start; 1082 Float_t b = start-lo; 1083 1084 while (1) 1085 { 1086 1087 while (x<up) 1088 { 1089 x += step; 1090 1091 if (x > last) 1092 { 1093 sum *= step; 1094 return; 1095 } 1096 1097 a -= step; 1098 b += step; 1099 1100 sum += a*fHiGainSignal[klo] 1101 + b*fHiGainSignal[khi] 1102 + (a*a*a-a)*fHiGainSecondDeriv[klo] 1064 const Float_t step = 0.2; 1065 1066 if (start < 0) 1067 { 1068 last -= start; 1069 start = 0.; 1070 } 1071 1072 const Int_t n = TMath::Nint((last-start)/step); 1073 1074 sum = 0.; 1075 for (Int_t i=1; i<=n+1; i++) 1076 { 1077 const Float_t x = start+i*step; 1078 const Int_t klo = (Int_t)TMath::Floor(x); 1079 const Int_t khi = klo + 1; 1080 // Note: if x is close to one integer number (= a FADC sample) 1081 // we get the same result by using that sample as klo, and the 1082 // next one as khi, or using the sample as khi and the previous 1083 // one as klo (the spline is of course continuous). So we do not 1084 // expect problems from rounding issues in the argument of 1085 // Floor() above (we have noticed differences in roundings 1086 // depending on the compilation options). 1087 1088 const Float_t a = khi - x; // Distance from x to next FADC sample 1089 const Float_t b = x - klo; // Distance from x to previous FADC sample 1090 1091 sum += a*fHiGainSignal[klo] 1092 + b*fHiGainSignal[khi] 1093 + (a*a*a-a)*fHiGainSecondDeriv[klo] 1103 1094 + (b*b*b-b)*fHiGainSecondDeriv[khi]; 1104 } 1105 1106 up += 1.; 1107 lo += 1.; 1108 klo++; 1109 khi++; 1110 start += 1.; 1111 a = 1.; 1112 b = 0.; 1113 } 1114 1095 1096 // FIXME? Perhaps the integral should be done analitically 1097 // between every two FADC slices, instead of numerically 1098 } 1099 sum *= step; // Transform sum in integral 1115 1100 } 1101 1116 1102 void MExtractTimeAndChargeSpline::CalcIntegralLoGain(Float_t &sum, Float_t start, Float_t last) 1117 1103 { 1118 1119 const Float_t step = 0.1; 1120 1121 if (start < 0) 1122 { 1123 last -= start; 1124 start = 0.; 1125 } 1126 1127 Int_t klo = int(start); 1128 Int_t khi = klo+1; 1129 1130 Float_t lo = TMath::Floor(start); 1131 Float_t up = lo + 1.; 1132 1133 const Int_t m = int((start-klo)/step); 1134 start = step*m + klo; // Correct start for the digitization due to resolution 1135 1136 Float_t x = start; 1137 Float_t a = up-start; 1138 Float_t b = start-lo; 1139 1140 while (1) 1141 { 1142 1143 while (x<up) 1144 { 1145 x += step; 1146 1147 if (x > last) 1148 { 1149 sum *= step; 1150 return; 1151 } 1152 1153 a -= step; 1154 b += step; 1155 1156 sum += a*fLoGainSignal[klo] 1157 + b*fLoGainSignal[khi] 1158 + (a*a*a-a)*fLoGainSecondDeriv[klo] 1104 const Float_t step = 0.2; 1105 1106 if (start < 0) 1107 { 1108 last -= start; 1109 start = 0.; 1110 } 1111 1112 const Int_t n = TMath::Nint((last-start)/step); 1113 1114 sum = 0.; 1115 for (Int_t i=1; i<=n+1; i++) 1116 { 1117 const Float_t x = start+i*step; 1118 const Int_t klo = (Int_t)TMath::Floor(x); 1119 const Int_t khi = klo + 1; 1120 // Note: if x is close to one integer number (= a FADC sample) 1121 // we get the same result by using that sample as klo, and the 1122 // next one as khi, or using the sample as khi and the previous 1123 // one as klo (the spline is of course continuous). So we do not 1124 // expect problems from rounding issues in the argument of 1125 // Floor() above (we have noticed differences in roundings 1126 // depending on the compilation options). 1127 1128 const Float_t a = khi - x; // Distance from x to next FADC sample 1129 const Float_t b = x - klo; // Distance from x to previous FADC sample 1130 1131 sum += a*fLoGainSignal[klo] 1132 + b*fLoGainSignal[khi] 1133 + (a*a*a-a)*fLoGainSecondDeriv[klo] 1159 1134 + (b*b*b-b)*fLoGainSecondDeriv[khi]; 1160 1161 } 1162 1163 up += 1.; 1164 lo += 1.; 1165 klo++; 1166 khi++; 1167 start += 1.; 1168 a = 1.; 1169 b = 0.; 1170 } 1171 1135 1136 // FIXME? Perhaps the integral should be done analitically 1137 // between every two FADC slices, instead of numerically 1138 } 1139 sum *= step; // Transform sum in integral 1172 1140 } 1173 1174 1175 1176 1141 1177 1142 // --------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.