Changeset 8478 for trunk/MagicSoft/Mars/mcalib
- Timestamp:
- 05/09/07 13:15:53 (18 years ago)
- Location:
- trunk/MagicSoft/Mars/mcalib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc
r8452 r8478 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCalc.cc,v 1.17 7 2007-04-27 10:04:46tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCalc.cc,v 1.178 2007-05-09 12:15:52 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 19 19 ! 20 20 ! Author(s): Markus Gaug 02/2004 <mailto:markus@ifae.es> 21 ! Author(s): Thomas Bretz <mailto:tbretz@astro.uni-wuerzburg.de> 21 22 ! 22 ! Copyright: MAGIC Software Development, 2000-200 423 ! Copyright: MAGIC Software Development, 2000-2007 23 24 ! 24 25 ! … … 213 214 #include "MLogManip.h" 214 215 216 #include "MMath.h" 217 215 218 #include "MParList.h" 216 219 … … 255 258 const Float_t MCalibrationChargeCalc::fgPheErrUpperLimit = 5.5; 256 259 const Float_t MCalibrationChargeCalc::fgFFactorErrLimit = 4.5; 257 const Float_t MCalibrationChargeCalc::fgArrTimeRmsLimit = 3.5;260 const Float_t MCalibrationChargeCalc::fgArrTimeRmsLimit = 5.0; 258 261 const Float_t MCalibrationChargeCalc::fgUnsuitablesLimit = 0.1; 259 262 const Float_t MCalibrationChargeCalc::fgUnreliablesLimit = 0.3; … … 672 675 } 673 676 677 // ---------------------------------------------------------------------------------------------------- 678 // 679 // Check for outliers. They are marked with 680 // MBadPixelsPix::kFluctuatingArrivalTimes 681 // 682 // see also MCalibrationRelTimeCalc::FinalizeRelTimes 683 // 684 void MCalibrationChargeCalc::FinalizeAbsTimes() 685 { 686 const Int_t npixels = fGeom->GetNumPixels(); 687 const Int_t nareas = fGeom->GetNumAreas(); 688 689 // Create an array capable of holding all pixels 690 TArrayF arr(npixels); 691 692 for (Int_t aidx=0; aidx<nareas; aidx++) 693 { 694 Int_t n = 0; 695 for (Int_t i=0; i<npixels; i++) 696 { 697 // Check for this aidx only 698 if ((*fGeom)[i].GetAidx()!=aidx) 699 continue; 700 701 // check if pixel may not contain a valid value 702 if ((*fBadPixels)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun)) 703 continue; 704 705 // check if it was excluded for some reason 706 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i]; 707 if (pix.IsExcluded()) 708 continue; 709 710 // if TimePrecision is valid fill it into array 711 if (pix.GetAbsTimeRms()>0) 712 arr[n++] = pix.GetAbsTimeRms(); 713 } 714 715 // Check the ratio of valid entries to the ratio of pixels 716 const Float_t ratio = 100*n/fGeom->GetNumPixWithAidx(aidx); 717 if (3*ratio<2) 718 *fLog << warn << "Area " << setw(4) << aidx << ": Only " << ratio << "% pixels with valid time resolution found." << endl; 719 720 // Calculate median and median deviation 721 Double_t med; 722 const Double_t dev = MMath::MedianDev(n, arr.GetArray(), med); 723 724 // Calculate upper and lower limit 725 const Float_t lolim = TMath::Max(med-fArrTimeRmsLimit*dev, 0.); 726 const Float_t hilim = TMath::Max(med+fArrTimeRmsLimit*dev, 0.); 727 728 // Now find the outliers 729 for (Int_t i=0; i<npixels; i++) 730 { 731 // Search only within this aidx 732 if ((*fGeom)[i].GetAidx()!=aidx) 733 continue; 734 735 // skip pixels already known to be unsuitable 736 if ((*fBadPixels)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun)) 737 continue; 738 739 // check if a pixel has been excluded. This 740 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i]; 741 742 // Check if time precision is valid (might be invalid 743 // for example in cae of empty histograms) 744 const Float_t res = pix.GetAbsTimeRms(); 745 if (res<0) //FIXME!!! How does this happen? 746 { 747 *fLog << warn << "Pixel " << setw(4) << i << ": Abs-time resolution could not be calculated." << endl; 748 (*fBadPixels)[i].SetUncalibrated(MBadPixelsPix::kDeviatingTimeResolution); 749 continue; 750 } 751 752 // Now compare to a lower and upper limit 753 if (res<=lolim || res>=hilim) 754 { 755 *fLog << warn << "Pixel " << setw(4) << i << ": Deviating abs-time resolution: " 756 << Form("%5.2f", res) << " out of range " 757 << Form("[%4.2f,%4.2f]", lolim, hilim) << endl; 758 759 (*fBadPixels)[i].SetUncalibrated(MBadPixelsPix::kFluctuatingArrivalTimes); 760 } 761 } 762 } 763 } 764 674 765 // ----------------------------------------------------------------------- 675 766 // … … 723 814 // First loop over pixels, call FinalizePedestals and FinalizeCharges 724 815 // 725 Int_t nvalid = 0; 726 816 Int_t nvalid = 0; 727 817 for (Int_t pixid=0; pixid<fPedestals->GetSize(); pixid++) 728 { 729 730 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[pixid]; 818 { 731 819 // 732 820 // Check if the pixel has been excluded from the fits 733 821 // 822 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[pixid]; 734 823 if (pix.IsExcluded()) 735 continue; 736 737 MPedestalPix &ped = (*fPedestals)[pixid]; 738 MBadPixelsPix &bad = (*fBadPixels)[pixid]; 739 740 const Int_t aidx = (*fGeom)[pixid].GetAidx(); 741 742 FinalizePedestals(ped,pix,aidx); 743 744 if (FinalizeCharges(pix,bad,"pixel ")) 745 nvalid++; 746 747 FinalizeArrivalTimes(pix,bad,"pixel "); 748 } 824 continue; 825 826 FinalizePedestals((*fPedestals)[pixid], pix, (*fGeom)[pixid].GetAidx()); 827 828 if (FinalizeCharges(pix, (*fBadPixels)[pixid], "Pixel ")) 829 nvalid++; 830 } 831 832 FinalizeAbsTimes(); 749 833 750 834 *fLog << endl; … … 779 863 // (already done for calibration sigma in MHCalibrationCam::CalcAverageSigma() 780 864 // 781 pix.SetPedRMS(pix.GetPedRms()*TMath::Sqrt((Float_t)arr[aidx]), 782 pix.GetPedRmsErr()*TMath::Sqrt((Float_t)arr[aidx])); 865 const Double_t sqrtnum = TMath::Sqrt((Double_t)arr[aidx]); 866 867 pix.SetPedRMS(pix.GetPedRms()*sqrtnum, pix.GetPedRmsErr()*sqrtnum); 783 868 pix.SetSigma (pix.GetSigma()/pix.GetFFactorFADC2Phe()); 784 869 785 870 FinalizeCharges(pix, fCam->GetAverageBadArea(aidx),"area id"); 786 FinalizeArrivalTimes(pix, fCam->GetAverageBadArea(aidx), "area id");787 871 } 788 872 … … 850 934 PrintUncalibrated(MBadPixelsPix::kLoGainSaturation, 851 935 "Low Gain Saturation: "); 852 PrintUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin, 853 Form("%s%2.1f%s","Mean Abs. Arr. Time in First ",1.," Bin(s): "));854 PrintUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins, 855 Form("%s%2.1f%s","Mean Abs. Arr. Time in Last ",2.," Bin(s): "));936 // PrintUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin, 937 // Form("%s%2.1f%s","Mean Abs. Arr. Time in First ",1.," Bin(s): ")); 938 // PrintUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins, 939 // Form("%s%2.1f%s","Mean Abs. Arr. Time in Last ",2.," Bin(s): ")); 856 940 PrintUncalibrated(MBadPixelsPix::kHiGainOverFlow, 857 941 "Pixels with High Gain Overflow: "); … … 974 1058 const TString desc = Form("%7s%4d: ", what, cal.GetPixId()); 975 1059 1060 if (cal.GetMean()<0) 1061 { 1062 *fLog << warn << desc << "Charge not fitted." << endl; 1063 bad.SetUncalibrated( MBadPixelsPix::kChargeIsPedestal); 1064 return kFALSE; 1065 } 1066 1067 if (cal.GetSigma()<0) 1068 { 1069 *fLog << warn << desc << "Charge Sigma invalid." << endl; 1070 bad.SetUncalibrated( MBadPixelsPix::kChargeIsPedestal); 1071 return kFALSE; 1072 } 1073 976 1074 if (cal.GetMean() < fChargeLimit*cal.GetPedRms()) 977 1075 { … … 1084 1182 1085 1183 return kTRUE; 1086 }1087 1088 // -----------------------------------------------------------------------------------1089 //1090 // Test the arrival Times RMS of the pixel and set the bit1091 // - MBadPixelsPix::kFluctuatingArrivalTimes1092 //1093 void MCalibrationChargeCalc::FinalizeArrivalTimes(MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what)1094 {1095 if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))1096 return;1097 1098 const TString desc = Form("%7s%4d: ", what, cal.GetPixId());1099 1100 if (cal.GetAbsTimeRms() > fArrTimeRmsLimit)1101 {1102 *fLog << warn;1103 *fLog << desc << "RMS of pulse arrival times: " << Form("%2.1f", cal.GetAbsTimeRms());1104 *fLog << " FADC sl. < " << Form("%2.1f", fArrTimeRmsLimit) << endl;1105 bad.SetUncalibrated( MBadPixelsPix::kFluctuatingArrivalTimes);1106 }1107 1184 } 1108 1185 … … 1134 1211 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun ); 1135 1212 } 1136 1213 /* 1137 1214 if (IsCheckExtractionWindow()) 1138 1215 { … … 1143 1220 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun ); 1144 1221 } 1145 1222 */ 1146 1223 if (IsCheckDeviatingBehavior()) 1147 1224 { … … 1275 1352 continue; 1276 1353 } 1277 1354 1355 // FIXME: WHAT IS THIS FOR? It is overwritten! 1278 1356 lowlim[i] = areaphes[i] - fPheErrLowerLimit*TMath::Sqrt(areavars[i]); 1279 1357 upplim[i] = areaphes[i] + fPheErrUpperLimit*TMath::Sqrt(areavars[i]); -
trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h
r8452 r8478 83 83 84 84 // Pointers 85 // MBadPixelsIntensityCam *fIntensBad; //! Bad Pixels86 85 MBadPixelsCam *fBadPixels; //! Bad Pixels 87 86 MCalibrationChargeCam *fCam; //! Calibrated Charges results of all pixels … … 128 127 129 128 // functions 130 void FinalizeArrivalTimes ( MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what);131 129 void FinalizeBadPixels (); 132 130 Bool_t FinalizeBlindCam (); … … 141 139 Bool_t FinalizeUnsuitablePixels(); 142 140 141 void FinalizeAbsTimes(); 142 143 143 const char* GetOutputFile(); 144 144 -
trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.cc
r8458 r8478 17 17 ! 18 18 ! Author(s): Markus Gaug 04/2004 <mailto:markus@ifae.es> 19 ! 20 ! Copyright: MAGIC Software Development, 2000-2004 19 ! Author(s): Thomas Bretz <mailto:tbretz@astro.uni-wuerzburg.de> 20 ! 21 ! Copyright: MAGIC Software Development, 2000-2007 21 22 ! 22 23 ! … … 242 243 // MBadPixelsPix::kDeviatingTimeResolution 243 244 // 245 // see also MCalibrationChargeCalc::FinalizeAbsTimes 246 // 244 247 void MCalibrationRelTimeCalc::FinalizeRelTimes() 245 248 { … … 260 263 261 264 // check if pixel may not contain a valid value 262 if ((*fBadPixels)[i].IsUnsuitable( ))265 if ((*fBadPixels)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun)) 263 266 continue; 264 267 … … 281 284 Double_t med; 282 285 const Double_t dev = MMath::MedianDev(n, arr.GetArray(), med); 286 287 // Calculate upper and lower limit 288 const Float_t lolim = TMath::Max(med-fRelTimeResolutionLimit*dev, 0.); 289 const Float_t hilim = TMath::Max(med+fRelTimeResolutionLimit*dev, 0.); 283 290 284 291 // Now find the outliers … … 290 297 291 298 // skip pixels already known to be unsuitable 292 if ((*fBadPixels)[i].IsUnsuitable( ))299 if ((*fBadPixels)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun)) 293 300 continue; 294 301 … … 301 308 if (res<0) //FIXME!!! How does this happen? 302 309 { 303 *fLog << warn << "Pixel " << setw(4) << i << ": Time resolution could not be calculated." << endl;310 *fLog << warn << "Pixel " << setw(4) << i << ": Rel-time resolution could not be calculated." << endl; 304 311 (*fBadPixels)[i].SetUncalibrated(MBadPixelsPix::kDeviatingTimeResolution); 305 312 continue; … … 307 314 308 315 // Now compare to a lower and upper limit 309 const Float_t lolim = TMath::Max(med-fRelTimeResolutionLimit*dev, 0.);310 const Float_t hilim = TMath::Max(med+fRelTimeResolutionLimit*dev, 0.);311 312 316 if (res<=lolim || res>=hilim) 313 317 { 314 *fLog << warn << "Pixel " << setw(4) << i << ": Deviating time resolution: "315 << Form("% 4.2f", res) << " out of range "318 *fLog << warn << "Pixel " << setw(4) << i << ": Deviating rel-time resolution: " 319 << Form("%5.2f", res) << " out of range " 316 320 << Form("[%4.2f,%4.2f]", lolim, hilim) << endl; 317 321
Note:
See TracChangeset
for help on using the changeset viewer.