Changeset 7189 for trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc
- Timestamp:
- 07/14/05 16:03:32 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc
r7126 r7189 184 184 // + Float_t fPheErrUpperLimit; // Upper limit acceptance nr. phe's w.r.t. area idx mean (in sigmas) 185 185 // 186 // 186 187 // ClassVersion 3: 187 188 // + Bool_t fUseExtractorRes; // Include extractor resolution in F-Factor method 189 // 190 // ClassVersion 3: 191 // + Float_t fUnsuitablesLimit; // Limit for relative number of unsuitable pixels 192 // + Float_t fUnreliablesLimit; // Limit for relative number of unreliable pixels 193 // + Float_t fExternalNumPhes; // External mean number of photo-electrons set from outside 194 // + Float_t fExternalNumPhesRelVar; // External rel. var. number of photo-electrons set from outside 188 195 // 189 196 ////////////////////////////////////////////////////////////////////////////// … … 198 205 199 206 #include "MParList.h" 200 201 #include "MStatusDisplay.h"202 207 203 208 #include "MCalibrationPattern.h" … … 247 252 const Float_t MCalibrationChargeCalc::fgFFactorErrLimit = 4.5; 248 253 const Float_t MCalibrationChargeCalc::fgArrTimeRmsLimit = 3.5; 254 const Float_t MCalibrationChargeCalc::fgUnsuitablesLimit = 0.1; 255 const Float_t MCalibrationChargeCalc::fgUnreliablesLimit = 0.3; 249 256 const TString MCalibrationChargeCalc::fgNamePedestalCam = "MPedestalCam"; 250 257 … … 263 270 // 264 271 // Initializes: 265 // - fArrTimeRmsLimit to fgArrTimeRmsLimit 266 // - fChargeLimit to fgChargeLimit 267 // - fChargeErrLimit to fgChargeErrLimit 268 // - fChargeRelErrLimit to fgChargeRelErrLimit 269 // - fFFactorErrLimit to fgFFactorErrLimit 270 // - fLambdaCheckLimit to fgLambdaCheckLimit 271 // - fLambdaErrLimit to fgLambdaErrLimit 272 // - fNamePedestalCam to fgNamePedestalCam 273 // - fPheErrLowerLimit to fgPheErrLowerLimit 274 // - fPheErrUpperLimit to fgPheErrUpperLimit 275 // - fPulserColor to MCalibrationCam::kCT1 276 // - fOutputPath to "." 277 // - fOutputFile to "ChargeCalibStat.txt" 278 // - flag debug to kFALSE 272 // - fArrTimeRmsLimit to fgArrTimeRmsLimit 273 // - fChargeLimit to fgChargeLimit 274 // - fChargeErrLimit to fgChargeErrLimit 275 // - fChargeRelErrLimit to fgChargeRelErrLimit 276 // - fFFactorErrLimit to fgFFactorErrLimit 277 // - fLambdaCheckLimit to fgLambdaCheckLimit 278 // - fLambdaErrLimit to fgLambdaErrLimit 279 // - fNamePedestalCam to fgNamePedestalCam 280 // - fPheErrLowerLimit to fgPheErrLowerLimit 281 // - fPheErrUpperLimit to fgPheErrUpperLimit 282 // - fPulserColor to MCalibrationCam::kCT1 283 // - fOutputPath to "." 284 // - fOutputFile to "ChargeCalibStat.txt" 285 // - flag debug to kFALSE 286 // - IsUseExtractorRes to kFALSE 287 // - IsUseExternalNumPhes to kFALSE 288 // - fExternalNumPhes to 0. 289 // - fExternalNumPhesRelVar to 0. 279 290 // 280 291 // Sets all checks … … 284 295 // 285 296 MCalibrationChargeCalc::MCalibrationChargeCalc(const char *name, const char *title) 286 : fUseExtractorRes(kFALSE), 287 fGeom(NULL), fSignal(NULL), fCalibPattern(NULL), fExtractor(NULL) 297 : fGeom(NULL), fSignal(NULL), fCalibPattern(NULL), fExtractor(NULL) 288 298 { 289 299 … … 309 319 SetPheErrLowerLimit (); 310 320 SetPheErrUpperLimit (); 321 SetUnsuitablesLimit (); 322 SetUnreliablesLimit (); 323 SetUseExtractorRes (); 324 SetUseUnreliables (); 325 SetUseExternalNumPhes(kFALSE); 326 327 SetExternalNumPhes (); 328 SetExternalNumPhesRelVar(); 311 329 312 330 SetCheckArrivalTimes (); … … 560 578 } 561 579 580 fResultFlags.Set(fGeom->GetNumAreas()); 581 562 582 return kTRUE; 563 583 } … … 777 797 { 778 798 779 const MPedestalPix 799 const MPedestalPix &ped = fPedestals->GetAverageArea(aidx); 780 800 MCalibrationChargePix &pix = (MCalibrationChargePix&)chargecam->GetAverageArea(aidx); 801 const MArrayI &arr = fHCam->GetAverageAreaNum(); 781 802 782 803 FinalizePedestals(ped,pix,aidx); 804 805 // 806 // Correct for sqrt(number of valid pixels) in the pedestal RMS 807 // (already done for calibration sigma in MHCalibrationCam::CalcAverageSigma() 808 // 809 pix.SetPedRMS(pix.GetPedRms()*TMath::Sqrt((Float_t)arr[aidx]), 810 pix.GetPedRmsErr()*TMath::Sqrt((Float_t)arr[aidx])); 811 pix.SetSigma (pix.GetSigma()/pix.GetFFactorFADC2Phe()); 812 783 813 FinalizeCharges(pix, chargecam->GetAverageBadArea(aidx),"area id"); 784 814 FinalizeArrivalTimes(pix, chargecam->GetAverageBadArea(aidx), "area id"); … … 847 877 } 848 878 849 //850 // Finalize calibration statistics851 //852 FinalizeUnsuitablePixels();853 854 chargecam->SetReadyToSave();855 qecam ->SetReadyToSave();856 badcam ->SetReadyToSave();857 858 if (blindcam)859 blindcam->SetReadyToSave();860 if (fPINDiode)861 fPINDiode->SetReadyToSave();862 863 879 *fLog << inf << endl; 864 880 *fLog << GetDescriptor() << ": Fatal errors statistics:" << endl; … … 884 900 PrintUncalibrated(MBadPixelsPix::kDeviatingNumPhes, 885 901 "Deviating number of phes: "); 902 PrintUncalibrated(MBadPixelsPix::kLoGainBlackout, 903 "Too many blackout events in low gain: "); 886 904 PrintUncalibrated(MBadPixelsPix::kPreviouslyExcluded, 887 905 "Previously excluded: "); … … 906 924 SetLogStream(oldlog); 907 925 908 return kTRUE; 926 chargecam->SetReadyToSave(); 927 qecam ->SetReadyToSave(); 928 badcam ->SetReadyToSave(); 929 930 if (blindcam) 931 blindcam->SetReadyToSave(); 932 if (fPINDiode) 933 fPINDiode->SetReadyToSave(); 934 935 // 936 // Finalize calibration statistics 937 // 938 return FinalizeUnsuitablePixels(); 909 939 } 910 940 … … 1042 1072 } 1043 1073 1044 if (! fUseExtractorRes)1074 if (!IsUseExtractorRes()) 1045 1075 return kTRUE; 1046 1076 … … 1059 1089 : resinphes/cal.GetMeanConvFADC2Phe(); 1060 1090 1061 if (resinfadc > 1.5*cal.GetPedRms() ) 1062 { 1063 *fLog << warn << " Extractor Resolution: " << resinfadc << " bigger than Pedestal RMS " << cal.GetPedRms() << endl; 1064 resinfadc = cal.GetPedRms(); 1091 if (resinfadc > 3.0*cal.GetPedRms() ) 1092 { 1093 *fLog << warn << " Extractor Resolution: " << resinfadc << " bigger than 3 Pedestal RMS " 1094 << cal.GetPedRms() << endl; 1095 resinfadc = 3.0*cal.GetPedRms(); 1065 1096 } 1066 1097 … … 1152 1183 if (bad.IsUncalibrated( MBadPixelsPix::kChargeIsPedestal)) 1153 1184 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun ); 1154 1155 if (bad.IsUncalibrated( MBadPixelsPix::kChargeErrNotValid ))1156 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );1157 1158 if (bad.IsUncalibrated( MBadPixelsPix::kChargeRelErrNotValid ))1159 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );1160 1185 } 1161 1186 … … 1268 1293 if (bad.IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid)) 1269 1294 continue; 1270 1295 1296 if (!IsUseUnreliables()) 1297 if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun)) 1298 continue; 1299 1271 1300 const Float_t nphe = pix.GetPheFFactorMethod(); 1272 1301 const Int_t aidx = (*fGeom)[i].GetAidx(); … … 1322 1351 if (ndf < 5) 1323 1352 { 1324 *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons " 1325 << "in the camera with area index: " << i << endl; 1326 *fLog << warn << GetDescriptor() << ": Number of dof.: " << ndf << " is smaller than 5 " << endl; 1327 *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl; 1328 delete hist; 1329 continue; 1353 *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons " << endl; 1354 *fLog << " in the camera with area index: " << i << endl; 1355 *fLog << " Number of dof.: " << ndf << " is smaller than 5 " << endl; 1356 *fLog << " Will use the simple mean and rms " << endl; 1357 delete hist; 1358 SetPheFitOK(i,kFALSE); 1359 continue; 1330 1360 } 1331 1361 … … 1334 1364 if (prob < 0.001) 1335 1365 { 1336 *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons "1337 << "in the camera with area index: " << i << endl;1338 *fLog << warn << GetDescriptor() << ": Fit probability " << prob1339 << " is smaller than 0.001" << endl;1340 *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl;1341 delete hist;1342 continue;1366 *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons " << endl; 1367 *fLog << " in the camera with area index: " << i << endl; 1368 *fLog << " Fit probability " << prob << " is smaller than 0.001 " << endl; 1369 *fLog << " Will use the simple mean and rms " << endl; 1370 delete hist; 1371 SetPheFitOK(i,kFALSE); 1372 continue; 1343 1373 } 1344 1374 1345 1375 if (mean < 0.) 1346 1376 { 1347 *fLog << inf << GetDescriptor() << ": Fitted mean number of photo-electrons " 1348 << "with area idx " << i << ": " << mean << " is smaller than 0. " << endl; 1349 *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl; 1350 delete hist; 1351 continue; 1377 *fLog << inf << GetDescriptor() << ": Fitted mean number of photo-electrons " << endl; 1378 *fLog << " with area idx " << i << ": " << mean << " is smaller than 0. " << endl; 1379 *fLog << warn << " Will use the simple mean and rms " << endl; 1380 SetPheFitOK(i,kFALSE); 1381 delete hist; 1382 continue; 1352 1383 } 1353 1384 … … 1359 1390 1360 1391 delete hist; 1392 1393 SetPheFitOK(i,kTRUE); 1361 1394 } 1362 1395 … … 1383 1416 if (bad.IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid)) 1384 1417 continue; 1418 1419 if (!IsUseUnreliables()) 1420 if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun)) 1421 continue; 1385 1422 1386 1423 const Float_t nvar = pix.GetPheFFactorMethodVar(); … … 1730 1767 MCalibrationQEPix &qepix = (MCalibrationQEPix&) qecam->GetAverageArea(0); 1731 1768 1732 const Float_t avphotons = avpix.GetPheFFactorMethod() 1769 if (IsDebug()) 1770 *fLog << dbginf << "External Phes: " << fExternalNumPhes 1771 << " Internal Phes: " << avpix.GetPheFFactorMethod() << endl; 1772 1773 const Float_t avphotons = ( IsUseExternalNumPhes() 1774 ? fExternalNumPhes 1775 : avpix.GetPheFFactorMethod() ) 1733 1776 / qepix.GetDefaultQE(fPulserColor) 1734 1777 / qepix.GetPMTCollectionEff() … … 1736 1779 / qecam->GetPlexiglassQE(); 1737 1780 1738 const Float_t avphotrelvar = avpix.GetPheFFactorMethodRelVar() 1781 const Float_t avphotrelvar = ( IsUseExternalNumPhes() 1782 ? fExternalNumPhesRelVar 1783 : avpix.GetPheFFactorMethodRelVar() ) 1739 1784 + qepix.GetDefaultQERelVar(fPulserColor) / fNumInnerFFactorMethodUsed 1740 1785 + qepix.GetPMTCollectionEffRelVar() … … 1846 1891 if (ndf < 2) 1847 1892 { 1848 *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor " 1849 << "in the camera with area index: " << i << endl;1850 *fLog << " Number of dof.: " << ndf << " is smaller than 2 " << endl;1851 *fLog << " Will use the simple mean and rms." << endl;1893 *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor " << endl; 1894 *fLog << " in the camera with area index: " << i << endl; 1895 *fLog << " Number of dof.: " << ndf << " is smaller than 2 " << endl; 1896 *fLog << " Will use the simple mean and rms." << endl; 1852 1897 delete hist; 1898 SetFFactorFitOK(i,kFALSE); 1853 1899 continue; 1854 1900 } … … 1858 1904 if (prob < 0.001) 1859 1905 { 1860 *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor " 1861 << "in the camera with area index: " << i << endl; 1862 *fLog << "Fit probability " << prob 1863 << " is smaller than 0.001 " << endl; 1864 *fLog << "Will use the simple mean and rms." << endl; 1906 *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor " << endl; 1907 *fLog << " in the camera with area index: " << i << endl; 1908 *fLog << " Fit probability " << prob << " is smaller than 0.001 " << endl; 1909 *fLog << " Will use the simple mean and rms." << endl; 1865 1910 delete hist; 1866 continue; 1911 SetFFactorFitOK(i,kFALSE); 1912 continue; 1867 1913 } 1868 1914 1869 1915 *fLog << inf << GetDescriptor() << ": Mean F-Factor " 1870 << "with area index #" << i << ": " 1871 << Form("%4.2f+-%4.2f",mean,sigma) << endl; 1916 << "with area index #" << i << ": " << Form("%4.2f+-%4.2f",mean,sigma) << endl; 1872 1917 1873 1918 lowlim [i] = 1.; … … 1875 1920 1876 1921 delete hist; 1922 1923 SetFFactorFitOK(i,kTRUE); 1877 1924 } 1878 1925 … … 2134 2181 // - store numbers of bad pixels of each type in fCam or fIntensCam 2135 2182 // 2136 voidMCalibrationChargeCalc::FinalizeUnsuitablePixels()2183 Bool_t MCalibrationChargeCalc::FinalizeUnsuitablePixels() 2137 2184 { 2138 2185 … … 2143 2190 const Int_t nareas = fGeom->GetNumAreas(); 2144 2191 2192 TArrayI suit(nareas); 2193 TArrayI unsuit(nareas); 2194 TArrayI unrel(nareas); 2195 2196 const MBadPixelsCam *badcam = fIntensBad ? (MBadPixelsCam*)fIntensBad->GetCam() : fBadPixels; 2197 MCalibrationChargeCam *chargecam = fIntensCam ? (MCalibrationChargeCam*)fIntensCam->GetCam() : fCam; 2198 2199 Int_t unsuitcnt=0; 2200 Int_t unrelcnt =0; 2201 2202 // Count number of succesfully calibrated pixels 2203 for (Int_t aidx=0; aidx<nareas; aidx++) 2204 { 2205 suit[aidx] = badcam->GetNumSuitable(MBadPixelsPix::kUnsuitableRun, fGeom, aidx); 2206 unsuit[aidx] = badcam->GetNumUnsuitable(MBadPixelsPix::kUnsuitableRun, fGeom, aidx); 2207 unrel[aidx] = badcam->GetNumUnsuitable(MBadPixelsPix::kUnreliableRun, fGeom, aidx); 2208 2209 unsuitcnt += unsuit[aidx]; 2210 unrelcnt += unrel[aidx]; 2211 2212 chargecam->SetNumUnsuitable(unsuit[aidx], aidx); 2213 chargecam->SetNumUnreliable(unrel[aidx], aidx); 2214 } 2215 2145 2216 TArrayI counts(nareas); 2146 2147 MBadPixelsCam *badcam = fIntensBad 2148 ? (MBadPixelsCam*)fIntensBad->GetCam() : fBadPixels; 2149 MCalibrationChargeCam *chargecam = fIntensCam 2150 ? (MCalibrationChargeCam*)fIntensCam->GetCam() : fCam; 2151 2152 for (Int_t i=0; i<badcam->GetSize(); i++) 2153 { 2154 MBadPixelsPix &bad = (*badcam)[i]; 2155 if (!bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun)) 2156 { 2217 for (Int_t i=0; i<chargecam->GetSize(); i++) 2218 { 2219 MCalibrationPix &pix = (*chargecam)[i]; 2220 if (pix.IsHiGainSaturation()) 2221 { 2157 2222 const Int_t aidx = (*fGeom)[i].GetAidx(); 2158 2223 counts[aidx]++; 2159 2160 2224 } 2225 } 2161 2226 2162 2227 if (fGeom->InheritsFrom("MGeomCamMagic")) 2163 *fLog << " " << setw(7) << "Successfully calibrated Pixels: " 2164 << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl; 2165 2166 counts.Reset(); 2167 2168 for (Int_t i=0; i<badcam->GetSize(); i++) 2169 { 2170 MBadPixelsPix &bad = (*badcam)[i]; 2171 2172 if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun)) 2173 { 2174 const Int_t aidx = (*fGeom)[i].GetAidx(); 2175 counts[aidx]++; 2176 } 2177 } 2178 2179 for (Int_t aidx=0; aidx<nareas; aidx++) 2180 chargecam->SetNumUnsuitable(counts[aidx], aidx); 2181 2182 if (fGeom->InheritsFrom("MGeomCamMagic")) 2183 *fLog << " " << setw(7) << "Uncalibrated Pixels: " 2184 << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl; 2185 2186 counts.Reset(); 2187 2188 for (Int_t i=0; i<badcam->GetSize(); i++) 2189 { 2190 2191 MBadPixelsPix &bad = (*badcam)[i]; 2192 2193 if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun)) 2194 { 2195 const Int_t aidx = (*fGeom)[i].GetAidx(); 2196 counts[aidx]++; 2197 } 2198 } 2199 2200 for (Int_t aidx=0; aidx<nareas; aidx++) 2201 chargecam->SetNumUnreliable(counts[aidx], aidx); 2202 2203 *fLog << " " << setw(7) << "Unreliable Pixels: " 2204 << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl; 2205 2228 { 2229 *fLog << " Successfully calibrated Pixels: Inner: " 2230 << Form("%3i",suit[0]) << " Outer: " << Form("%3i",suit[1]) << endl; 2231 *fLog << " Uncalibrated Pixels: Inner: " 2232 << Form("%3i",unsuit[0]) << " Outer: " << Form("%3i",unsuit[1]) << endl; 2233 *fLog << " Unreliable Pixels: Inner: " 2234 << Form("%3i",unrel[0]) << " Outer: " << Form("%3i",unrel[1]) << endl; 2235 *fLog << " High-gain saturated Pixels: Inner: " 2236 << Form("%3i",counts[0]) << " Outer: " << Form("%3i",counts[1]) << endl; 2237 *fLog << endl; 2238 } 2239 2240 return kTRUE; 2241 2242 if (unsuitcnt > fUnsuitablesLimit*fGeom->GetNumPixels()) 2243 { 2244 *fLog << err << "Number of unsuitable pixels: " << 100.*unsuitcnt/fGeom->GetNumPixels() 2245 << "% exceeds limit of " << fUnsuitablesLimit*100 << "%" << endl; 2246 return kFALSE; 2247 } 2248 2249 if (unrelcnt > fUnreliablesLimit*fGeom->GetNumPixels()) 2250 { 2251 *fLog << err << "Relative number of unreliable pixels: " << 100.*unrelcnt/fGeom->GetNumPixels() 2252 << "% exceeds limit of " << fUnreliablesLimit*100 << "%" << endl; 2253 return kFALSE; 2254 } 2255 return kTRUE; 2206 2256 } 2207 2257 … … 2232 2282 } 2233 2283 2234 *fLog << " " << setw(7) << text 2235 << Form("%s%3i%s%3i","Inner: ",countinner," Outer: ",countouter) << endl;2284 *fLog << " " << setw(7) << text << "Inner: " << Form("%3i",countinner) 2285 << " Outer: " << Form("%3i", countouter) << endl; 2236 2286 } 2237 2287 … … 2361 2411 rc = kTRUE; 2362 2412 } 2363 if (IsEnvDefined(env, prefix, "UseExtractorRes", print))2364 {2365 SetUseExtractorRes(GetEnvValue(env, prefix, "UseExtractorRes", fUseExtractorRes));2413 if (IsEnvDefined(env, prefix, "UseExtractorRes", print)) 2414 { 2415 SetUseExtractorRes(GetEnvValue(env, prefix, "UseExtractorRes", IsUseExtractorRes())); 2366 2416 rc = kTRUE; 2367 2417 } 2418 if (IsEnvDefined(env, prefix, "UseUnreliables", print)) 2419 { 2420 SetUseUnreliables(GetEnvValue(env, prefix, "UseUnreliables", IsUseUnreliables())); 2421 rc = kTRUE; 2422 } 2423 2424 if (IsEnvDefined(env, prefix, "UseExternalNumPhes", print)) 2425 { 2426 SetUseExternalNumPhes(GetEnvValue(env, prefix, "UseExternalNumPhes", IsUseExternalNumPhes())); 2427 rc = kTRUE; 2428 } 2429 2430 if (IsEnvDefined(env, prefix, "UnsuitablesLimit", print)) 2431 { 2432 SetUnsuitablesLimit(GetEnvValue(env, prefix, "UnsuitablesLimit", fUnsuitablesLimit)); 2433 rc = kTRUE; 2434 } 2435 2436 if (IsEnvDefined(env, prefix, "UnreliablesLimit", print)) 2437 { 2438 SetUnreliablesLimit(GetEnvValue(env, prefix, "UnreliablesLimit", fUnreliablesLimit)); 2439 rc = kTRUE; 2440 } 2441 2368 2442 2369 2443 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.