Changeset 5497 for trunk/MagicSoft/Mars
- Timestamp:
- 11/28/04 19:55:21 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/msignal
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSpline.cc
r5496 r5497 271 271 SETBIT(fFlags,typ); 272 272 273 if (IsExtractionType(kAmplitude))274 {275 fNumHiGainSamples = 1.;276 fNumLoGainSamples = fLoGainLast ? 1. : 0.;277 fSqrtHiGainSamples = 1.;278 fSqrtLoGainSamples = 1.;279 }280 281 if (IsExtractionType(kIntegral))282 {283 fNumHiGainSamples = TMath::Floor(fRiseTime + fFallTime);284 fNumLoGainSamples = fLoGainLast ? fNumHiGainSamples + 1. : 0.;285 fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);286 fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);287 }288 273 } 289 274 … … 300 285 Bool_t MExtractTimeAndChargeSpline::ReInit(MParList *pList) 301 286 { 302 303 if (!MExtractTimeAndCharge::ReInit(pList))304 return kFALSE;305 287 306 288 if (fHiGainSignal) … … 334 316 fLoGainSecondDeriv = new Float_t[range]; 335 317 memset(fLoGainSecondDeriv,0,range*sizeof(Float_t)); 318 319 if (IsExtractionType(kAmplitude)) 320 { 321 fNumHiGainSamples = 1.; 322 fNumLoGainSamples = fLoGainLast ? 1. : 0.; 323 fSqrtHiGainSamples = 1.; 324 fSqrtLoGainSamples = 1.; 325 } 326 327 if (IsExtractionType(kIntegral)) 328 { 329 fNumHiGainSamples = fRiseTime + fFallTime; 330 fNumLoGainSamples = fLoGainLast ? fNumHiGainSamples + 1. : 0.; 331 fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples); 332 fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples); 333 } 334 335 if (!MExtractTimeAndCharge::ReInit(pList)) 336 return kFALSE; 336 337 337 338 return kTRUE; … … 441 442 + (-0.375)*fHiGainSecondDeriv[2] 442 443 + (-0.375)*fHiGainSecondDeriv[3]; 444 return; 445 } 446 447 if (IsNoiseCalculation() && IsExtractionType(kIntegral)) 448 { 449 // 450 // Take the spline value at the middle of the third slice (to avoid egde effects) 451 // 452 Int_t first = 2; 453 Int_t last = first + (Int_t)(fRiseTime+fFallTime); 454 CalcIntegralHiGain(sum,first,last); 443 455 return; 444 456 } … … 695 707 // Now integrate the whole thing! 696 708 // 697 Int_t startslice = IsNoiseCalculation() ? 0 : (Int_t)(fAbMaxPos - fRiseTime); 698 Int_t lastslice = IsNoiseCalculation() ? (Int_t)(fRiseTime+fFallTime) : (Int_t)(fAbMaxPos + fFallTime); 699 700 if (startslice < 0) 701 { 702 lastslice -= startslice; 703 startslice = 0; 704 } 705 709 Int_t startslice = (Int_t)(fAbMaxPos - fRiseTime); 710 Int_t lastslice = (Int_t)(fAbMaxPos + fFallTime); 711 706 712 if (lastslice > range) 707 lastslice = range; 708 709 Int_t i = startslice; 710 sum = 0.5*fHiGainSignal[i]; 711 712 // 713 // We sum 1.5 times the second deriv. coefficients because these had been 714 // divided by 6. already. Usually, 0.25*fHiGainSecondDeriv should be added. 715 // 716 for (i=startslice+1; i<lastslice; i++) 717 sum += fHiGainSignal[i] + 1.5*fHiGainSecondDeriv[i]; 718 719 sum += 0.5*fHiGainSignal[lastslice]; 713 { 714 lastslice = range; 715 startslice += (lastslice - range); 716 } 717 718 CalcIntegralHiGain(sum, startslice, lastslice); 720 719 } 721 720 … … 771 770 } 772 771 773 //774 // Allow no saturated slice775 // and776 // Don't start if the maxpos is too close to the left limit.777 //778 if (sat || maxpos < 1)779 {780 time = IsExtractionType(kMaximum)781 ? (Float_t)(fLoGainFirst + maxpos)782 : (Float_t)(fLoGainFirst + maxpos - 1);783 return;784 }785 786 if (maxpos < 2 && IsExtractionType(kHalfMaximum))787 {788 time = (Float_t)(fLoGainFirst + maxpos - 1);789 return;790 }791 792 772 Float_t pp; 793 773 … … 809 789 fLoGainSecondDeriv[k] /= 6.; 810 790 791 if (IsNoiseCalculation() && IsExtractionType(kAmplitude)) 792 { 793 // 794 // Take the spline value at the middle of the third slice (to avoid egde effects) 795 // 796 sum = 0.5*fLoGainSignal[2] 797 + 0.5*fLoGainSignal[3] 798 + (-0.375)*fLoGainSecondDeriv[2] 799 + (-0.375)*fLoGainSecondDeriv[3]; 800 return; 801 } 802 803 if (IsNoiseCalculation() && IsExtractionType(kIntegral)) 804 { 805 // 806 // Take the spline value at the middle of the third slice (to avoid egde effects) 807 // 808 Int_t first = 2; 809 Int_t last = first + (Int_t)(fRiseTime+fFallTime); 810 CalcIntegralLoGain(sum,first,last); 811 return; 812 } 813 814 // 815 // Allow no saturated slice 816 // and 817 // Don't start if the maxpos is too close to the left limit. 818 // 819 if (sat || maxpos < 1) 820 { 821 time = IsExtractionType(kMaximum) 822 ? (Float_t)(fLoGainFirst + maxpos) 823 : (Float_t)(fLoGainFirst + maxpos - 1); 824 return; 825 } 826 827 if (maxpos < 2 && IsExtractionType(kHalfMaximum)) 828 { 829 time = (Float_t)(fLoGainFirst + maxpos - 1); 830 return; 831 } 832 811 833 // 812 834 // Now find the maximum … … 1046 1068 // Now integrate the whole thing! 1047 1069 // 1048 Int_t startslice = IsNoiseCalculation() ? 0 : (Int_t)(fAbMaxPos - fRiseTime); 1049 Int_t lastslice = IsNoiseCalculation() ? (Int_t)(fRiseTime+fFallTime) : (Int_t)(fAbMaxPos + fFallTime + 1); 1050 1051 if (startslice < 0) 1052 { 1053 lastslice -= startslice; 1054 startslice = 0; 1055 } 1056 1057 Int_t i = startslice; 1058 sum = 0.5*fLoGainSignal[i]; 1059 1060 for (i=startslice+1; i<lastslice; i++) 1061 sum += fLoGainSignal[i] + 1.5*fLoGainSecondDeriv[i]; 1062 1063 sum += 0.5*fLoGainSignal[lastslice]; 1064 } 1065 1066 1070 Int_t startslice = (Int_t)(fAbMaxPos - fRiseTime); 1071 Int_t lastslice = (Int_t)(fAbMaxPos + fFallTime + 1); 1072 1073 if (lastslice > range) 1074 { 1075 lastslice = range; 1076 startslice += (lastslice - range); 1077 } 1078 CalcIntegralLoGain(sum, startslice, lastslice); 1079 } 1067 1080 } 1081 1082 void MExtractTimeAndChargeSpline::CalcIntegralHiGain(Float_t &sum, Int_t startslice, Int_t lastslice) 1083 { 1084 1085 if (startslice < 0) 1086 { 1087 lastslice -= startslice; 1088 startslice = 0; 1089 } 1090 1091 Int_t i = startslice; 1092 sum = 0.5*fHiGainSignal[i]; 1093 1094 // 1095 // We sum 1.5 times the second deriv. coefficients because these had been 1096 // divided by 6. already. Usually, 0.25*fHiGainSecondDeriv should be added. 1097 // 1098 for (i=startslice+1; i<lastslice; i++) 1099 sum += fHiGainSignal[i] + 1.5*fHiGainSecondDeriv[i]; 1100 1101 sum += 0.5*fHiGainSignal[lastslice]; 1102 1103 } 1104 1105 void MExtractTimeAndChargeSpline::CalcIntegralLoGain(Float_t &sum, Int_t startslice, Int_t lastslice) 1106 { 1107 1108 if (startslice < 0) 1109 { 1110 lastslice -= startslice; 1111 startslice = 0; 1112 } 1113 1114 Int_t i = startslice; 1115 sum = 0.5*fLoGainSignal[i]; 1116 1117 // 1118 // We sum 1.5 times the second deriv. coefficients because these had been 1119 // divided by 6. already. Usually, 0.25*fLoGainSecondDeriv should be added. 1120 // 1121 for (i=startslice+1; i<lastslice; i++) 1122 sum += fLoGainSignal[i] + 1.5*fLoGainSecondDeriv[i]; 1123 1124 sum += 0.5*fLoGainSignal[lastslice]; 1125 1126 } 1127 1128 1068 1129 1069 1130 // -------------------------------------------------------------------------- … … 1128 1189 1129 1190 } 1191 1192 -
trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSpline.h
r5483 r5497 40 40 41 41 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print); 42 42 43 void CalcIntegralHiGain(Float_t &sum, Int_t startslice, Int_t lastslice); 44 void CalcIntegralLoGain(Float_t &sum, Int_t startslice, Int_t lastslice); 45 43 46 public: 44 47 … … 58 61 Float_t GetFallTime() const { return fFallTime; } 59 62 60 void SetRange ( Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0 );61 void SetResolution (Float_t f=fgResolution ) { fResolution = f; }62 void SetRiseTime (Float_t f=fgRiseTime ) { fRiseTime = f; }63 void SetFallTime (Float_t f=fgFallTime ) { fFallTime = f; }63 void SetRange ( Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0 ); 64 void SetResolution ( const Float_t f=fgResolution ) { fResolution = f; } 65 void SetRiseTime ( const Float_t f=fgRiseTime ) { fRiseTime = f; } 66 void SetFallTime ( const Float_t f=fgFallTime ) { fFallTime = f; } 64 67 65 void SetTimeType (ExtractionType_t typ=kMaximum );66 void SetChargeType (ExtractionType_t typ=kAmplitude);68 void SetTimeType ( const ExtractionType_t typ=kMaximum ); 69 void SetChargeType ( const ExtractionType_t typ=kAmplitude); 67 70 68 71 void FindTimeAndChargeHiGain(Byte_t *first, Byte_t *logain, Float_t &sum, Float_t &dsum,
Note:
See TracChangeset
for help on using the changeset viewer.