Changeset 3025
- Timestamp:
- 02/05/04 16:19:20 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r3024 r3025 4 4 5 5 -*-*- END OF LINE -*-*- 6 2004/02/05: Markus Gaug 7 * mcalib/MHCalibrationPixel.[h,cc] 8 - put an NDF limit for the fit 9 - removed all TStrings and replace them by Form(..) 10 - Check for nan's of all returned fit values 11 12 6 13 2004/02/05: Abelardo Moralejo 7 14 -
trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.cc
r3012 r3025 52 52 const Int_t MHCalibrationPixel::fChargeNbinsHiGain = 2100; 53 53 const Int_t MHCalibrationPixel::fChargeNbinsLoGain = 1010; 54 const Int_t MHCalibrationPixel::fChargevsNbins = 5000; 54 55 const Int_t MHCalibrationPixel::fAbsTimeNbins = 32; 55 const Int_t MHCalibrationPixel::fRelTimeNbins = 480;56 const Int_t MHCalibrationPixel::fChargevsNbins = 5000;57 56 const Axis_t MHCalibrationPixel::fAbsTimeFirst = - 0.25; 58 57 const Axis_t MHCalibrationPixel::fAbsTimeLast = 15.75; 59 const Axis_t MHCalibrationPixel::fRelTimeFirst = -11.; 60 const Axis_t MHCalibrationPixel::fRelTimeLast = 12.; 58 const Int_t MHCalibrationPixel::fRelTimeNbins = 900; 59 const Axis_t MHCalibrationPixel::fRelTimeFirst = -13.; 60 const Axis_t MHCalibrationPixel::fRelTimeLast = 13.; 61 61 const Float_t MHCalibrationPixel::fProbLimit = 0.001; 62 const Int_t MHCalibrationPixel::fNDFLimit = 5; 62 63 63 64 // -------------------------------------------------------------------------- … … 287 288 Bool_t MHCalibrationPixel::FillAbsTimeLoGain(Float_t t) 288 289 { 289 return (fHAbsTimeLoGain->Fill(t) 290 return (fHAbsTimeLoGain->Fill(t)> -1); 290 291 } 291 292 292 293 Bool_t MHCalibrationPixel::FillRelTimeLoGain(Float_t t) 293 294 { 294 return (fHRelTimeLoGain->Fill(t) 295 return (fHRelTimeLoGain->Fill(t) > -1); 295 296 } 296 297 … … 323 324 { 324 325 325 fPixId = id; 326 327 // 328 // Names Hi gain Histograms 329 // 330 fHChargeHiGain->SetName( Form("%s%d",fHChargeHiGain->GetName(), id)); 331 fHAbsTimeHiGain->SetName( Form("%s%d",fHAbsTimeHiGain->GetName(), id)); 332 fHRelTimeHiGain->SetName( Form("%s%d",fHRelTimeHiGain->GetName(), id)); 333 fHChargevsNHiGain->SetName(Form("%s%d",fHChargevsNHiGain->GetName(),id)); 334 335 // 336 // Title Hi gain Histograms 337 // 338 fHChargeHiGain->SetTitle( Form("%s%d",fHChargeHiGain->GetTitle(), id)); 339 fHAbsTimeHiGain->SetTitle( Form("%s%d",fHAbsTimeHiGain->GetTitle(), id)); 340 fHRelTimeHiGain->SetTitle( Form("%s%d",fHRelTimeHiGain->GetTitle(), id)); 341 fHChargevsNHiGain->SetTitle( Form("%s%d",fHChargevsNHiGain->GetTitle(),id)); 342 343 // 344 // Names Low Gain Histograms 345 // 346 fHChargeLoGain->SetName( Form("%s%d",fHChargeLoGain->GetName(),id)); 347 fHAbsTimeLoGain->SetName( Form("%s%d",fHAbsTimeLoGain->GetName(),id)); 348 fHRelTimeLoGain->SetName( Form("%s%d",fHRelTimeLoGain->GetName(),id)); 349 fHChargevsNLoGain->SetName( Form("%s%d",fHChargevsNLoGain->GetName(),id)); 350 351 // 352 // Titles Low Gain Histograms 353 // 354 fHChargeLoGain->SetTitle( Form("%s%d",fHChargeLoGain->GetTitle(),id)); 355 fHAbsTimeLoGain->SetTitle( Form("%s%d",fHAbsTimeLoGain->GetTitle(),id)); 356 fHRelTimeLoGain->SetTitle( Form("%s%d",fHRelTimeLoGain->GetTitle(),id)); 357 fHChargevsNLoGain->SetTitle( Form("%s%d",fHChargevsNLoGain->GetTitle(),id)); 326 // Change only if the names have not yet been changed 327 if (fPixId == -1) 328 { 329 330 // 331 // Names Hi gain Histograms 332 // 333 fHChargeHiGain->SetName( Form("%s%d",fHChargeHiGain->GetName(), id)); 334 fHAbsTimeHiGain->SetName( Form("%s%d",fHAbsTimeHiGain->GetName(), id)); 335 fHRelTimeHiGain->SetName( Form("%s%d",fHRelTimeHiGain->GetName(), id)); 336 fHChargevsNHiGain->SetName(Form("%s%d",fHChargevsNHiGain->GetName(),id)); 337 338 // 339 // Title Hi gain Histograms 340 // 341 fHChargeHiGain->SetTitle( Form("%s%d",fHChargeHiGain->GetTitle(), id)); 342 fHAbsTimeHiGain->SetTitle( Form("%s%d",fHAbsTimeHiGain->GetTitle(), id)); 343 fHRelTimeHiGain->SetTitle( Form("%s%d",fHRelTimeHiGain->GetTitle(), id)); 344 fHChargevsNHiGain->SetTitle( Form("%s%d",fHChargevsNHiGain->GetTitle(),id)); 345 346 // 347 // Names Low Gain Histograms 348 // 349 fHChargeLoGain->SetName( Form("%s%d",fHChargeLoGain->GetName(),id)); 350 fHAbsTimeLoGain->SetName( Form("%s%d",fHAbsTimeLoGain->GetName(),id)); 351 fHRelTimeLoGain->SetName( Form("%s%d",fHRelTimeLoGain->GetName(),id)); 352 fHChargevsNLoGain->SetName( Form("%s%d",fHChargevsNLoGain->GetName(),id)); 353 354 // 355 // Titles Low Gain Histograms 356 // 357 fHChargeLoGain->SetTitle( Form("%s%d",fHChargeLoGain->GetTitle(),id)); 358 fHAbsTimeLoGain->SetTitle( Form("%s%d",fHAbsTimeLoGain->GetTitle(),id)); 359 fHRelTimeLoGain->SetTitle( Form("%s%d",fHRelTimeLoGain->GetTitle(),id)); 360 fHChargevsNLoGain->SetTitle( Form("%s%d",fHChargevsNLoGain->GetTitle(),id)); 361 362 fPixId = id; 363 } 364 358 365 } 359 366 … … 673 680 674 681 fHivsLoGain->Fit("pol1","rq","",fHivsLoGain->GetMean()-2.5*fHivsLoGain->GetRMS(), 675 fHivsLoGain->GetMean()+2. 0*fHivsLoGain->GetRMS());682 fHivsLoGain->GetMean()+2.5*fHivsLoGain->GetRMS()); 676 683 677 684 fOffset = fHivsLoGain->GetFunction("pol1")->GetParameter(0); … … 744 751 if (fRelTimeGausFit->GetProb() < 0.001) 745 752 { 746 rmin = fRelTimeGausFit->GetParameter(1) - 2.*fRelTimeGausFit->GetParameter(2);747 rmax = fRelTimeGausFit->GetParameter(1) + 2.*fRelTimeGausFit->GetParameter(2);753 rmin = fRelTimeGausFit->GetParameter(1) - 1.5*fRelTimeGausFit->GetParameter(2); 754 rmax = fRelTimeGausFit->GetParameter(1) + 1.5*fRelTimeGausFit->GetParameter(2); 748 755 fRelTimeGausFit->SetRange(rmin,rmax); 749 756 hist->Fit(fRelTimeGausFit,option); … … 765 772 } 766 773 767 if (TMath::IsNaN(fRelTimeChisquare) || (fRelTimeProb < gkProbLimit))774 if (TMath::IsNaN(fRelTimeChisquare) || (fRelTimeProb < fProbLimit)) 768 775 { 769 776 CLRBIT(fFlags,kTimeFitOK); … … 788 795 // 789 796 Axis_t rmin = fChargeFirstHiGain; 797 Axis_t rmax = fChargeLastHiGain; 798 TH1F *hist = fHChargeHiGain; 799 790 800 if (TESTBIT(fFlags,kUseLoGain)) 791 rmin = fChargeFirstLoGain; 792 793 Axis_t rmax = fChargeLastHiGain; 794 if (TESTBIT(fFlags,kUseLoGain)) 795 rmax = fChargeLastLoGain; 796 797 TH1F *hist = fHChargeHiGain; 798 if (TESTBIT(fFlags,kUseLoGain)) 799 hist = fHChargeLoGain; 800 801 { 802 rmin = fChargeFirstLoGain; 803 rmax = fChargeLastLoGain; 804 hist = fHChargeLoGain; 805 } 806 801 807 // 802 808 // First guesses for the fit (should be as close to reality as possible, 803 // otherwise the fit goes gaga because of high number of dimensions ... 804 // 805 const Stat_t entries = hist->Integral(); 806 const Double_t area_guess = entries/gkSq2Pi; 809 // 810 const Stat_t entries = hist->Integral("width"); 807 811 const Double_t mu_guess = hist->GetBinCenter(hist->GetMaximumBin()); 808 const Double_t sigma_guess = mu_guess/15.; 809 810 TString name = TString("ChargeGausFit"); 811 name += fPixId; 812 813 fChargeGausFit = new TF1(name.Data(),"gaus",rmin,rmax); 812 const Double_t sigma_guess = (rmax-rmin)/2.; 813 const Double_t area_guess = entries/gkSq2Pi/sigma_guess; 814 815 fChargeGausFit = new TF1(Form("%s%d","ChargeGausFit",fPixId),"gaus",rmin,rmax); 814 816 815 817 if (!fChargeGausFit) … … 831 833 // If we are not able to fit, try once again 832 834 // 833 if (fChargeGausFit->GetProb() < gkProbLimit)834 { 835 836 Axis_t rtry = fChargeGausFit->GetParameter(1) - 3.0*fChargeGausFit->GetParameter(2);835 if (fChargeGausFit->GetProb() < fProbLimit) 836 { 837 838 Axis_t rtry = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2); 837 839 rmin = (rtry < rmin ? rmin : rtry); 838 rmax = fChargeGausFit->GetParameter(1) + 3.0*fChargeGausFit->GetParameter(2); 840 rmax = fChargeGausFit->GetParameter(1) + 2.5*fChargeGausFit->GetParameter(2); 841 839 842 fChargeGausFit->SetRange(rmin,rmax); 840 841 fHChargeHiGain->Fit(fChargeGausFit,option); 843 hist->Fit(fChargeGausFit,option); 842 844 } 843 845 … … 852 854 // 853 855 // The fit result is accepted under condition: 854 // The Results are not nan's 855 // The Probability is greater than gkProbLimit (default 0.001 == 99.9%) 856 // 857 if (TMath::IsNaN(fChargeMean) || TMath::IsNaN(fChargeMeanErr)) 858 { 856 // 1) The results are not nan's 857 // 2) The NDF is not smaller than fNDFLimit (5) 858 // 3) The Probability is greater than fProbLimit (default 0.001 == 99.9%) 859 // 860 // Otherwise take means and RMS of the histograms 861 // 862 if ( TMath::IsNaN(fChargeMean) 863 || TMath::IsNaN(fChargeMeanErr) 864 || TMath::IsNaN(fChargeProb) 865 || TMath::IsNaN(fChargeSigma) 866 || TMath::IsNaN(fChargeSigmaErr) 867 || (fChargeNdf < fNDFLimit) 868 || (fChargeProb < fProbLimit) ) 869 { 870 871 fChargeMean = hist->GetMean(); 872 fChargeMeanErr = hist->GetRMS()/hist->GetEntries(); 873 fChargeSigma = hist->GetRMS(); 874 fChargeSigmaErr = fChargeMeanErr/2.; 875 859 876 CLRBIT(fFlags,kChargeFitOK); 860 877 return kFALSE; 861 878 } 862 879 863 if ((fChargeProb < gkProbLimit) || (TMath::IsNaN(fChargeProb)))864 {865 CLRBIT(fFlags,kChargeFitOK);866 return kFALSE;867 }868 869 880 SETBIT(fFlags,kChargeFitOK); 870 881 return kTRUE; … … 877 888 { 878 889 879 Int_t nbins = 30;890 Int_t nbins = 50; 880 891 881 892 CutEdges(fHChargeHiGain,nbins); … … 891 902 +fHChargeLoGain->GetBinWidth(0); 892 903 893 CutEdges(fHRelTimeHiGain, nbins);904 CutEdges(fHRelTimeHiGain,0); 894 905 895 906 fRelTimeLowerFitRangeHiGain = fHRelTimeHiGain->GetBinLowEdge(fHRelTimeHiGain->GetXaxis()->GetFirst()); … … 897 908 +fHRelTimeHiGain->GetBinWidth(0); 898 909 899 CutEdges(fHRelTimeLoGain, nbins);910 CutEdges(fHRelTimeLoGain,0); 900 911 901 912 fRelTimeLowerFitRangeLoGain = fHRelTimeLoGain->GetBinLowEdge(fHRelTimeLoGain->GetXaxis()->GetFirst()); … … 903 914 +fHRelTimeLoGain->GetBinWidth(0); 904 915 905 CutEdges(fHAbsTimeHiGain, nbins);916 CutEdges(fHAbsTimeHiGain,0); 906 917 907 918 fAbsTimeFirstHiGain = fHAbsTimeHiGain->GetBinLowEdge(fHAbsTimeHiGain->GetXaxis()->GetFirst()); … … 909 920 +fHAbsTimeHiGain->GetBinWidth(0); 910 921 911 CutEdges(fHAbsTimeLoGain, nbins);922 CutEdges(fHAbsTimeLoGain,0); 912 923 913 924 fAbsTimeFirstLoGain = fHAbsTimeLoGain->GetBinLowEdge(fHAbsTimeLoGain->GetXaxis()->GetFirst()); -
trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.h
r3012 r3025 20 20 static const Int_t fChargeNbinsHiGain; 21 21 static const Int_t fChargeNbinsLoGain; 22 static const Int_t fChargevsNbins; 22 23 static const Int_t fAbsTimeNbins; 23 static const Int_t fRelTimeNbins;24 static const Int_t fChargevsNbins;25 24 static const Axis_t fAbsTimeFirst; 26 25 static const Axis_t fAbsTimeLast; 26 static const Int_t fRelTimeNbins; 27 27 static const Axis_t fRelTimeFirst; 28 28 static const Axis_t fRelTimeLast; 29 29 static const Float_t fProbLimit; 30 static const Int_t fNDFLimit; 30 31 31 32 Int_t fPixId; // Pixel Nr
Note:
See TracChangeset
for help on using the changeset viewer.