Ignore:
Timestamp:
01/26/04 20:26:36 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mcalib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mcalib/MCalibrationPINDiode.cc

    r2839 r2922  
    8181Bool_t MCalibrationPINDiode::FitCharge()
    8282{
    83   if(!fHist->FitChargeHiGain())
     83  if(!fHist->FitCharge())
    8484    return kFALSE;
    8585
  • trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc

    r2904 r2922  
    356356  //    possible remaining cosmics to spoil the fit.
    357357  //
    358   if (fPed && fPedRms)
    359     fHist->SetLowerFitRange(1.5*fPedRms);
     358  //  if (fPed && fPedRms)
     359  //    fHist->SetLowerFitRange(1.5*fPedRms);
     360  //  else
     361  //    *fLog << warn << "WARNING: Cannot set lower fit range: Pedestals not available" << endl;
     362
     363  //
     364  // 3) Decide if the LoGain Histogram is fitted or the HiGain Histogram
     365  //
     366  if (fHist->UseLoGain())
     367    SetHiGainSaturation();
     368     
     369  //
     370  // 4) Fit the Lo Gain histograms with a Gaussian
     371  //
     372  if(fHist->FitCharge())
     373    {
     374      SETBIT(fFlags,kFitted);
     375    }
    360376  else
    361     *fLog << warn << "WARNING: Cannot set lower fit range: Pedestals not available" << endl;
    362 
    363   //
    364   // 3) Decide if the LoGain Histogram is fitted or the HiGain Histogram
    365   //
    366   if (fHist->UseLoGain())
    367     {
    368 
    369       SetHiGainSaturation();
    370      
    371       //
    372       // 4) Fit the Lo Gain histograms with a Gaussian
    373       //
    374       if(!fHist->FitChargeLoGain())
    375         {
    376           *fLog << warn << "WARNING: Could not fit Lo Gain charges of pixel " << fPixId << endl;
    377           //         
    378           // 5) In case of failure print out the fit results
    379           //
    380           //      fHist->PrintChargeFitResult();
    381           CLRBIT(fFlags,kFitted);
    382         }
    383       else
    384         SETBIT(fFlags,kFitted);
    385     }
    386   else
    387     {
    388       //
    389       // 4) Fit the Hi Gain histograms with a Gaussian
    390       //
    391       if(!fHist->FitChargeHiGain())
    392         {
    393           *fLog << warn << "WARNING: Could not fit Hi Gain charges of pixel " << fPixId << endl;
    394           //         
    395           // 5) In case of failure print out the fit results
    396           //
    397           //      fHist->PrintChargeFitResult();
    398           CLRBIT(fFlags,kFitted);
    399         }
    400       else
    401         SETBIT(fFlags,kFitted);
    402     }
    403  
     377    {
     378      *fLog << warn << "WARNING: Could not fit charges of pixel " << fPixId << endl;
     379      //         
     380      // 5) In case of failure print out the fit results
     381      //
     382      //          fHist->PrintChargeFitResult();
     383      CLRBIT(fFlags,kFitted);
     384    }
    404385
    405386  //
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.cc

    r2920 r2922  
    541541  // The fit result is accepted under condition that:
    542542  // 1) the Probability is greater than gkProbLimit (default 0.001 == 99.7%)
    543   // 2) at least 100 events are in the single Photo-electron peak
     543  // 2) at least 50 events are in the single Photo-electron peak
    544544  //
    545545  if (fProb < gkProbLimit)
     
    551551    }
    552552
    553   if (fProb < 0.01)
    554     *fLog << warn << "WARNING: Fit Probability " << fProb << " is smaller than 1% " << endl;
    555 
    556553  Float_t contSinglePhe = TMath::Exp(-1.0*fLambda)*fLambda*entries;
    557554 
    558   if (contSinglePhe < 100.)
     555  if (contSinglePhe < 50.)
    559556    {
    560557      *fLog << err << "ERROR: Statistics is too low: Only " << contSinglePhe
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.cc

    r2904 r2922  
    6767        fHivsLoGain(NULL),
    6868        fFitLegend(NULL),
    69         fLowerFitRange(-100.),
    7069        fChargeFirstHiGain(-100.5),
    7170        fChargeLastHiGain(1999.5),
     
    112111    Axis_t tfirst = -0.5;
    113112    Axis_t tlast  = 15.5;
    114     Int_t  ntbins = 16;
     113    Int_t  ntbins = 32;
    115114
    116115    fHTimeHiGain = new TH1F("HTimeHiGain","Distribution of Mean Arrival Hi Gain Times Pixel ",
     
    695694  fTimeSigma     = fTimeGausFit->GetParameter(2);
    696695
    697   if (fTimeChisquare > 20.)  // Cannot use Probability because Ndf is sometimes < 1
     696  if (TMath::IsNaN(fTimeMean) || TMath::IsNaN(fTimeSigma))
     697    return kFALSE;
     698
     699  if (TMath::IsNaN(fTimeChisquare) || fTimeChisquare > 20.)  // Cannot use Probability because Ndf is sometimes < 1
    698700    return kFALSE;
    699701
     
    758760}
    759761
    760 Bool_t MHCalibrationPixel::FitChargeHiGain(Option_t *option)
     762Bool_t MHCalibrationPixel::FitCharge(Option_t *option)
    761763{
    762764
     
    767769  // Get the fitting ranges
    768770  //
    769   Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fChargeFirstHiGain;
    770   Axis_t rmax = 0.;
     771  Axis_t rmin = fChargeFirstHiGain;
     772  if (TESTBIT(fFlags,kUseLoGain))
     773    rmin = fChargeFirstLoGain;
     774
     775  Axis_t rmax = fChargeLastHiGain;
     776  if (TESTBIT(fFlags,kUseLoGain))
     777    rmin = fChargeFirstLoGain;
     778
     779  TH1F *hist = fHChargeHiGain;
     780  if (TESTBIT(fFlags,kUseLoGain))
     781    hist = fHChargeLoGain;
    771782
    772783  //
     
    774785  // otherwise the fit goes gaga because of high number of dimensions ...
    775786  //
    776   const Stat_t   entries    = fHChargeHiGain->Integral();
    777   const Double_t area_guess = entries/gkSq2Pi;
    778   const Double_t mu_guess   = fHChargeHiGain->GetBinCenter(fHChargeHiGain->GetMaximumBin());
     787  const Stat_t   entries     = hist->Integral();
     788  const Double_t area_guess  = entries/gkSq2Pi;
     789  const Double_t mu_guess    = hist->GetBinCenter(hist->GetMaximumBin());
    779790  const Double_t sigma_guess = mu_guess/15.;
    780791
     
    782793  name += fPixId;
    783794
    784   fChargeGausFit = new TF1(name.Data(),"gaus",rmin,fChargeLastHiGain);
     795  fChargeGausFit = new TF1(name.Data(),"gaus",rmin,rmax);
    785796
    786797  if (!fChargeGausFit)
     
    793804  fChargeGausFit->SetParNames("Area","#mu","#sigma");
    794805  fChargeGausFit->SetParLimits(0,0.,entries);
    795   fChargeGausFit->SetParLimits(1,rmin,fChargeLastHiGain);
    796   fChargeGausFit->SetParLimits(2,0.,fChargeLastHiGain-rmin);
    797   fChargeGausFit->SetRange(rmin,fChargeLastHiGain);
    798 
    799   fHChargeHiGain->Fit(fChargeGausFit,option);
    800  
    801   Axis_t rtry = fChargeGausFit->GetParameter(1) - 2.0*fChargeGausFit->GetParameter(2);
    802  
    803   rmin = (rtry < rmin ? rmin : rtry);
    804   rmax = fChargeGausFit->GetParameter(1) + 3.5*fChargeGausFit->GetParameter(2);
    805   fChargeGausFit->SetRange(rmin,rmax); 
    806 
    807   fHChargeHiGain->Fit(fChargeGausFit,option);
    808 
     806  fChargeGausFit->SetParLimits(1,rmin,rmax);
     807  fChargeGausFit->SetParLimits(2,0.,rmax-rmin);
     808  fChargeGausFit->SetRange(rmin,rmax);
     809
     810  hist->Fit(fChargeGausFit,option);
     811 
     812  //
     813  // If we are not able to fit, try once again
     814  //
     815  if (fChargeGausFit->GetProb() < gkProbLimit)
     816    {
     817
     818      Axis_t rtry = fChargeGausFit->GetParameter(1) - 3.0*fChargeGausFit->GetParameter(2);
     819      rmin        = (rtry < rmin ? rmin : rtry);
     820      rmax        = fChargeGausFit->GetParameter(1) + 3.0*fChargeGausFit->GetParameter(2);
     821      fChargeGausFit->SetRange(rmin,rmax); 
     822
     823      fHChargeHiGain->Fit(fChargeGausFit,option);
     824    }
     825 
    809826  fChargeChisquare = fChargeGausFit->GetChisquare();
    810827  fChargeNdf       = fChargeGausFit->GetNDF();
     
    816833
    817834  //
    818   // The fit result is accepted under condition
     835  // The fit result is accepted under condition:
     836  // The Results are not nan's
    819837  // The Probability is greater than gkProbLimit (default 0.001 == 99.9%)
    820838  //
    821   if (fChargeProb < gkProbLimit)
    822     {
    823       //      *fLog << warn << "WARNING: Fit Probability " << fChargeProb
    824       //            << " is smaller than the allowed value: " << gkProbLimit << endl;
     839  if (TMath::IsNaN(fChargeMean) || TMath::IsNaN(fChargeMeanErr))
     840    {
    825841      CLRBIT(fFlags,kFitOK);
    826842      return kFALSE;
    827843    }
    828844 
     845  if ((fChargeProb < gkProbLimit) || (TMath::IsNaN(fChargeProb)))
     846    {
     847      CLRBIT(fFlags,kFitOK);
     848      return kFALSE;
     849    }
     850 
    829851  SETBIT(fFlags,kFitOK);
    830852  return kTRUE;
     
    832854
    833855
    834 Bool_t MHCalibrationPixel::FitChargeLoGain(Option_t *option)
    835 {
    836 
    837   if (fChargeGausFit)
    838     return kFALSE;
    839 
    840   //
    841   // Get the fitting ranges
    842   //
    843   Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fChargeFirstLoGain;
    844   Axis_t rmax = 0.;
    845 
    846   //
    847   // First guesses for the fit (should be as close to reality as possible,
    848   // otherwise the fit goes gaga because of high number of dimensions ...
    849   //
    850   const Stat_t   entries    = fHChargeLoGain->Integral();
    851   const Double_t area_guess = entries/gkSq2Pi;
    852   const Double_t mu_guess   = fHChargeLoGain->GetBinCenter(fHChargeLoGain->GetMaximumBin());
    853   const Double_t sigma_guess = mu_guess/15.;
    854 
    855   TString name = TString("ChargeGausFit");
    856   name += fPixId;
    857 
    858   fChargeGausFit = new TF1(name.Data(),"gaus",rmin,fChargeLastLoGain);
    859 
    860   if (!fChargeGausFit)
    861     {
    862     *fLog << warn << dbginf << "WARNING: Could not create fit function for Charges fit" << endl;
    863     return kFALSE;
    864     }
    865  
    866   fChargeGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
    867   fChargeGausFit->SetParNames("Area","#mu","#sigma");
    868   fChargeGausFit->SetParLimits(0,0.,entries);
    869   fChargeGausFit->SetParLimits(1,rmin,fChargeLastLoGain);
    870   fChargeGausFit->SetParLimits(2,0.,fChargeLastLoGain-rmin);
    871   fChargeGausFit->SetRange(rmin,fChargeLastLoGain);
    872 
    873   fHChargeLoGain->Fit(fChargeGausFit,option);
    874  
    875   Axis_t rtry = fChargeGausFit->GetParameter(1) - 2.*fChargeGausFit->GetParameter(2);
    876  
    877   rmin = (rtry < rmin ? rmin : rtry);
    878   rmax = fChargeGausFit->GetParameter(1) + 3.5*fChargeGausFit->GetParameter(2);
    879   fChargeGausFit->SetRange(rmin,rmax); 
    880 
    881   fHChargeLoGain->Fit(fChargeGausFit,option);
    882 
    883   //  rmin = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
    884   //  rmax = fChargeGausFit->GetParameter(1) + 2.5*fChargeGausFit->GetParameter(2);
    885   //  fChargeGausFit->SetRange(rmin,rmax); 
    886 
    887   // fHChargeLoGain->Fit(fChargeGausFit,option);
    888 
    889   fChargeChisquare = fChargeGausFit->GetChisquare();
    890   fChargeNdf       = fChargeGausFit->GetNDF();
    891   fChargeProb      = fChargeGausFit->GetProb();
    892   fChargeMean      = fChargeGausFit->GetParameter(1);
    893   fChargeMeanErr   = fChargeGausFit->GetParError(1);
    894   fChargeSigma     = fChargeGausFit->GetParameter(2);
    895   fChargeSigmaErr  = fChargeGausFit->GetParError(2);
    896 
    897   //
    898   // The fit result is accepted under condition
    899   // The Probability is greater than gkProbLimit (default 0.01 == 99%)
    900   //
    901   if (fChargeProb < gkProbLimit)
    902     {
    903       //      *fLog << warn << "WARNING: Fit Probability " << fChargeProb
    904       //            << " is smaller than the allowed value: " << gkProbLimit << endl;
    905       CLRBIT(fFlags,kFitOK);
    906       return kFALSE;
    907     }
    908  
    909   SETBIT(fFlags,kFitOK);
    910    
    911   return kTRUE;
    912 }
    913856
    914857 
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.h

    r2904 r2922  
    4141  TPaveText *fFitLegend; 
    4242 
    43   Axis_t  fLowerFitRange;
    4443  Axis_t  fChargeFirstHiGain;
    4544  Axis_t  fChargeLastHiGain;
     
    9594  void SetTimeFitRangesLoGain(Byte_t low, Byte_t up) { fTimeLowerFitRangeLoGain = low,
    9695                                               fTimeUpperFitRangeLoGain = up ;  }
    97 
    98   void SetLowerFitRange(Axis_t min)                {  fLowerFitRange = min; }
    9996
    10097  // Getters
     
    152149 
    153150  // Fits
    154   Bool_t FitChargeHiGain(Option_t *option="RQ0"); 
     151  Bool_t FitCharge(Option_t *option="RQ0"); 
     152
    155153  Bool_t FitTimeHiGain(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0");   
    156 
    157   Bool_t FitChargeLoGain(Option_t *option="RQ0"); 
    158154  Bool_t FitTimeLoGain(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0");   
    159155
Note: See TracChangeset for help on using the changeset viewer.