Changeset 4198


Ignore:
Timestamp:
05/26/04 18:24:22 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r4197 r4198  
    2929     - set MCalibrationChargeBlindPix and MCalibrationChargePINDiode as
    3030       data members and store them in the output of WriteResult()
     31
     32   * mcalib/MCalibrationQEPix.cc
     33     - several small bugs fixed concerning calibration with the blind pixel
     34       or the PIN Diode
    3135
    3236   * mjobs/MGCamDisplays.[h,cc]
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc

    r4166 r4198  
    227227const Float_t MCalibrationChargeCalc::fgChargeRelErrLimit      = 1.;
    228228const Float_t MCalibrationChargeCalc::fgLambdaErrLimit         = 0.2;
    229 const Float_t MCalibrationChargeCalc::fgLambdaCheckLimit       = 0.2;
     229const Float_t MCalibrationChargeCalc::fgLambdaCheckLimit       = 0.5;
    230230const Float_t MCalibrationChargeCalc::fgPheErrLimit            = 3.5;
    231231const Float_t MCalibrationChargeCalc::fgFFactorErrLimit        = 3.;
     
    600600      *fLog << err << GetDescriptor() << ": Or, maybe, you have used a pedestal run "
    601601            << "instead of a calibration run " << endl;
    602     return kFALSE;
     602      return kFALSE;
    603603  }
    604604
     
    11171117  const Float_t lambdacheck = fBlindPixel->GetLambdaCheck();
    11181118
    1119   if (2.*(lambdacheck-lambda)/(lambdacheck+lambda) < fLambdaCheckLimit)
    1120     {
    1121       *fLog << warn << GetDescriptor() << ": Lambda and Lambda-Check differ by more than "
    1122             << fLambdaCheckLimit << " in the Blind Pixel " << endl;
    1123       return kFALSE;
    1124     }
    1125  
    1126   if (lambdaerr < fLambdaErrLimit)
    1127     {
    1128       *fLog << warn << GetDescriptor() << ": Error of Fitted Lambda is greater than "
    1129             << fLambdaErrLimit << " in Blind Pixel " << endl;
     1119  if (2.*(lambdacheck-lambda)/(lambdacheck+lambda) > fLambdaCheckLimit)
     1120    {
     1121      *fLog << warn << GetDescriptor()
     1122            << Form("%s%4.2f%s%4.2f%s%4.2f%s",": Lambda: ",lambda," and Lambda-Check: ",
     1123                    lambdacheck," differ by more than ",fLambdaCheckLimit," in the Blind Pixel ")
     1124            << endl;
     1125      return kFALSE;
     1126    }
     1127 
     1128  if (lambdaerr > fLambdaErrLimit)
     1129    {
     1130      *fLog << warn << GetDescriptor()
     1131            << Form("%s%4.2f%s%4.2f%s",": Error of Fitted Lambda: ",lambdaerr," is greater than ",
     1132                    fLambdaErrLimit," in Blind Pixel ") << endl;
    11301133      return kFALSE;
    11311134    }
     
    13761379          continue;
    13771380        }
    1378      
     1381
    13791382      if (!fBlindPixel->IsFluxInsidePlexiglassAvailable())
    13801383        {
     
    13851388      MBadPixelsPix       &bad   =                   (*fBadPixels)[i];
    13861389
    1387       if (!bad.IsUnsuitable (MBadPixelsPix::kUnsuitableRun))
     1390      if (bad.IsUnsuitable (MBadPixelsPix::kUnsuitableRun))
    13881391        {
    13891392          qepix.SetBlindPixelMethodValid(kFALSE, fPulserColor);
     
    13971400                             / fBlindPixel->GetFluxInsidePlexiglass()
    13981401                             / geo.GetA()
    1399                             * fQECam->GetPlexiglassQE();
     1402                             * fQECam->GetPlexiglassQE();
    14001403
    14011404      const Float_t qerelvar = fBlindPixel->GetFluxInsidePlexiglassRelVar()
     
    14051408      qepix.SetQEBlindPixel    ( qe            , fPulserColor );
    14061409      qepix.SetQEBlindPixelVar ( qerelvar*qe*qe, fPulserColor );     
    1407       qepix.UpdateBlindPixelMethod();
     1410      qepix.SetBlindPixelMethodValid(  kTRUE   , fPulserColor );
     1411
     1412      if (!qepix.UpdateBlindPixelMethod())
     1413        *fLog << warn << GetDescriptor()
     1414              << ": Cannot update Quantum efficiencies with the Blind Pixel Method" << endl;
    14081415    }
    14091416}
     
    14711478      qepix.SetQEPINDiode    ( qe            , fPulserColor );
    14721479      qepix.SetQEPINDiodeVar ( qerelvar*qe*qe, fPulserColor );     
    1473       qepix.UpdateBlindPixelMethod();
     1480      qepix.SetPINDiodeMethodValid(  kTRUE   , fPulserColor );
     1481
     1482      if (!qepix.UpdatePINDiodeMethod())
     1483        *fLog << warn << GetDescriptor()
     1484              << ": Cannot update Quantum efficiencies with the PIN Diode Method" << endl;
    14741485    }
    14751486}
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeBlindPix.cc

    r3963 r4198  
    9696const Double_t MHCalibrationChargeBlindPix::gkElectronicAmpErr   = 0.002;
    9797
    98 const Int_t    MHCalibrationChargeBlindPix::fgChargeNbins        =  300;
    99 const Axis_t   MHCalibrationChargeBlindPix::fgChargeFirst        = -100.5;
    100 const Axis_t   MHCalibrationChargeBlindPix::fgChargeLast         = 5199.5;
    101 const Float_t  MHCalibrationChargeBlindPix::fgSinglePheCut       = 200.;
     98const Int_t    MHCalibrationChargeBlindPix::fgChargeNbins        = 1000;
     99const Axis_t   MHCalibrationChargeBlindPix::fgChargeFirst        = -0.5;
     100const Axis_t   MHCalibrationChargeBlindPix::fgChargeLast         = 5999.5;
     101const Float_t  MHCalibrationChargeBlindPix::fgSinglePheCut       = 600.;
    102102const Float_t  MHCalibrationChargeBlindPix::fgNumSinglePheLimit  =  50.;
    103103// --------------------------------------------------------------------------
     
    146146    SetNumSinglePheLimit();
    147147
    148     SetBinsAfterStripping(30);
     148    SetBinsAfterStripping(50);
    149149
    150150    fHGausHist.SetName("HCalibrationChargeBlindPix");
     
    216216  fLambdaCheckErr = -999.;
    217217 
    218   fFitFunc = kEPoisson5;
     218  fFitFunc = kEMichele;
     219  //  fFitFunc = kEPoisson4;
    219220
    220221  fNumSinglePhes    = 0;
     
    387388  //
    388389  const Float_t signal = (Float_t)fSignal->GetExtractedSignal();
    389   if (signal > -1)
     390  if (signal > -0.5)
    390391    FillHistAndArray(signal);
     392  else
     393    return kTRUE;
    391394
    392395  //
     
    448451    fBlindPix->SetSinglePheFitOK();
    449452  else
    450     fBlindPix->SetValid(kFALSE);
    451 
    452   fBlindPix->SetLambda      (    fLambda               );
    453   fBlindPix->SetLambdaVar   (    fLambdaErr*fLambdaErr );
     453    fBlindPix->SetValid(IsPedestalFitOK());
     454
     455  fBlindPix->SetLambda      (    fLambdaCheck          );
     456  fBlindPix->SetLambdaVar   (    fLambdaCheckErr*fLambdaCheckErr );
    454457  fBlindPix->SetMu0         (    fMu0                  );
    455458  fBlindPix->SetMu0Err      (    fMu0Err               );
     
    462465  fBlindPix->SetProb        (    fProb                 );
    463466
    464   fBlindPix->SetLambdaCheck    ( fLambdaCheck          );
    465   fBlindPix->SetLambdaCheckErr ( fLambdaCheckErr       );
     467  fBlindPix->SetLambdaCheck    ( fLambda               );
     468  fBlindPix->SetLambdaCheckErr ( fLambdaErr            );
    466469
    467470  return kTRUE;
     
    598601      break;
    599602    case kEMichele:
    600       break;
    601 
     603      fSinglePheFit = new TF1("SinglePheFit",&fFitFuncMichele,rmin,rmax,10);
     604      break;
    602605    default:
    603606      *fLog << warn << "WARNING: Could not find Fit Function for Blind Pixel " << endl;
     
    614617  const Double_t mu_0_guess = maximum_bin;
    615618  const Double_t si_0_guess = 40.;
    616   const Double_t mu_1_guess = mu_0_guess + 100.;
     619  const Double_t mu_1_guess = mu_0_guess + 4000.;
    617620  const Double_t si_1_guess = si_0_guess + si_0_guess;
    618621  // Michele
    619 //  const Double_t lambda_1cat_guess = 0.5;
    620   // const Double_t lambda_1dyn_guess = 0.5;
    621   // const Double_t mu_1cat_guess = mu_0_guess + 50.;
    622   // const Double_t mu_1dyn_guess = mu_0_guess + 20.;
    623   // const Double_t si_1cat_guess = si_0_guess + si_0_guess;
    624   // const Double_t si_1dyn_guess = si_0_guess;
     622  const Double_t lambda_1cat_guess = 0.005;
     623  const Double_t lambda_1dyn_guess = 0.002;
     624  //  const Double_t mu_1cat_guess = mu_0_guess + 4500.;
     625  //  const Double_t mu_1dyn_guess = mu_0_guess + 2500.;
     626  const Double_t mu_1cat_guess = mu_0_guess + 1000.;
     627  const Double_t mu_1dyn_guess = mu_0_guess + 2500.;
     628  const Double_t si_1cat_guess = 500.;
     629  const Double_t si_1dyn_guess = 1000.;
     630  const Double_t offset_guess  = 0.5;
    625631  // Polya
    626632  const Double_t excessPoisson_guess = 0.5;
     
    689695      break;
    690696    case kEMichele:
     697      fSinglePheFit->SetParameters(lambda_1cat_guess, lambda_1dyn_guess,
     698                                   mu_0_guess, mu_1cat_guess,mu_1dyn_guess,
     699                                   si_0_guess, si_1cat_guess,si_1dyn_guess,
     700                                   norm, offset_guess);
     701      fSinglePheFit->SetParNames("#lambda_{cat}","#lambda_{dyn}",
     702                                 "#mu_{0}","#mu_{1cat}","#mu_{1dyn}",
     703                                 "#sigma_{0}","#sigma_{1cat}","#sigma_{1dyn}",
     704                                 "Area","offset");
     705      fSinglePheFit->SetParLimits(0,0.,0.2);
     706      fSinglePheFit->SetParLimits(1,0.,0.05);
     707      fSinglePheFit->SetParLimits(2,0.,fSinglePheCut);   
     708      //      fSinglePheFit->SetParLimits(3,4000.,5500.);   
     709      //      fSinglePheFit->SetParLimits(4,2500.,5000.);   
     710      fSinglePheFit->SetParLimits(3,fSinglePheCut,3000.);   
     711      fSinglePheFit->SetParLimits(4,fSinglePheCut,3500.);   
     712      fSinglePheFit->SetParLimits(5,0.,fSinglePheCut);   
     713      fSinglePheFit->SetParLimits(6,500.,1000.);   
     714      fSinglePheFit->SetParLimits(7,300.,1500.);   
     715      //      fSinglePheFit->SetParLimits(6,300.,2000.);   
     716      //      fSinglePheFit->SetParLimits(7,100.,2500.);   
     717      fSinglePheFit->SetParLimits(8,norm/1.1,norm*1.1);
     718      fSinglePheFit->SetParLimits(9,0.,1.);
    691719      break;
    692720
     
    745773      fSigma0Err = fSinglePheFit->GetParError(5);
    746774      fSigma1Err = 0.;
     775    case kEMichele:
     776      fLambda =  fSinglePheFit->GetParameter(0);
     777      fMu0    =  fSinglePheFit->GetParameter(2);
     778      fMu1    =  fSinglePheFit->GetParameter(3);
     779      fSigma0 =  fSinglePheFit->GetParameter(5);
     780      fSigma1 =  fSinglePheFit->GetParameter(6);
     781
     782      fLambdaErr = fSinglePheFit->GetParError(0);
     783      fMu0Err    = fSinglePheFit->GetParError(2);
     784      fMu1Err    = fSinglePheFit->GetParError(3);
     785      fSigma0Err = fSinglePheFit->GetParError(5);
     786      fSigma1Err = fSinglePheFit->GetParError(6);
     787      break;
    747788    default:
    748789      break;
     
    832873  // Perform the cross-check fitting only the pedestal:
    833874  const Axis_t rmin    = 0.;
    834   const Axis_t rmax    = fHGausHist.GetBinCenter(fHGausHist.GetMaximumBin());
     875  //  const Axis_t rmax    = fHGausHist.GetBinCenter(fHGausHist.GetMaximumBin());
     876  const Axis_t rmax = fSinglePheCut;
    835877
    836878  FitGaus(opt, rmin, rmax);
    837879
    838880  const Stat_t   entries = fHGausHist.Integral("width");
    839   const Double_t fitarea = fFGausFit->GetParameter(0);
    840   const Double_t pedarea = fitarea * TMath::Sqrt(TMath::TwoPi()) * fFGausFit->GetParameter(2);
    841 
     881  const Double_t pedarea = fFGausFit->Integral(0.,fSinglePheCut);
     882   
    842883  fLambdaCheck     = TMath::Log(entries/pedarea);
    843   fLambdaCheckErr  =   fFGausFit->GetParError(0)/fFGausFit->GetParameter(0)
    844                      + fFGausFit->GetParError(2)/fFGausFit->GetParameter(2);
    845 
    846  
    847   SetPedestalFitOK();
     884  // estimate the error by the error of the obtained area from the Gauss-function:
     885  fLambdaCheckErr  = fFGausFit->GetParError(0)/fFGausFit->GetParameter(0);
     886 
     887  SetPedestalFitOK(IsGausFitOK());
    848888  return;
    849889}
     
    861901      fFitLegend = new TPaveText(0.05,0.05,0.95,0.95);
    862902      fFitLegend->SetLabel(Form("%s%s", "Results of the single PhE Fit (",
    863                                 (fFitFunc =  kEPoisson4) ? "Poisson(k=4))" :
    864                                 (fFitFunc =  kEPoisson5) ? "Poisson(k=5))" :
    865                                 (fFitFunc =  kEPoisson6) ? "Poisson(k=4))" :
    866                                 (fFitFunc =  kEPolya   ) ? "Polya(k=4))"   :
    867                                 (fFitFunc =  kEMichele ) ?  "Michele)"     : " none )" ));
     903                                (fFitFunc ==  kEPoisson4) ? "Poisson(k=4))" :
     904                                (fFitFunc ==  kEPoisson5) ? "Poisson(k=5))" :
     905                                (fFitFunc ==  kEPoisson6) ? "Poisson(k=6))" :
     906                                (fFitFunc ==  kEPolya   ) ? "Polya(k=4))"   :
     907                                (fFitFunc ==  kEMichele ) ?  "Michele)"     : " none )" ));
    868908      fFitLegend->SetTextSize(0.05);
    869909  }
     
    9791019      fFGausFit->SetLineColor(kBlue);
    9801020      fFGausFit->Draw("same");
     1021      TLine *line = new TLine(fSinglePheCut, 0., fSinglePheCut, 10.);
     1022      line->SetBit(kCanDelete);
     1023      line->SetLineColor(kBlue);
     1024      line->SetLineWidth(3);
     1025      line->DrawLine(fSinglePheCut, 0., fSinglePheCut, 2.);
    9811026  }
    9821027  if (fSinglePheFit)
     
    9851030      fSinglePheFit->Draw("same");
    9861031  }
     1032
    9871033
    9881034  pad->cd(2);
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeBlindPix.h

    r3952 r4198  
    146146  // Fits
    147147public:
    148   enum FitFunc_t  { kEPoisson4, kEPoisson5, kEPoisson6, kEPoisson7, kEPolya, kEMichele }; // The possible fit functions
     148  enum FitFunc_t { kEPoisson4, kEPoisson5, kEPoisson6, kEPoisson7, kEPolya, kEMichele }; // The possible fit functions
    149149
    150150private:
     
    175175      Double_t sigma1cat  = par[6];
    176176      Double_t sigma1dyn  = par[7];
    177        
     177      Double_t offset     = par[9];
     178     
    178179      Double_t sumcat = 0.;
    179180      Double_t sumdyn = 0.;
     
    240241      sumdyn = TMath::Exp(-1.*lambda1dyn)*sumdyn;
    241242     
    242       return par[8]*(sumcat+sumdyn)/2.;
     243      return par[8]*(sumcat+sumdyn)/2. + offset;
    243244
    244245    }
  • trunk/MagicSoft/Mars/mcalib/MHGausEvents.cc

    r3989 r4198  
    662662  StripZeros(&fHGausHist,fBinsAfterStripping);
    663663 
     664  TAxis *axe = fHGausHist.GetXaxis();
    664665  //
    665666  // Get the fitting ranges
    666667  //
    667   Axis_t rmin = (xmin==0.) && (xmax==0.) ? fHGausHist.GetBinCenter(fHGausHist.GetXaxis()->GetFirst()) : xmin;
    668   Axis_t rmax = (xmin==0.) && (xmax==0.) ? fHGausHist.GetBinCenter(fHGausHist.GetXaxis()->GetLast())  : xmax;
     668  Axis_t rmin = ((xmin==0.) && (xmax==0.)) ? fHGausHist.GetBinCenter(axe->GetFirst()) : xmin;
     669  Axis_t rmax = ((xmin==0.) && (xmax==0.)) ? fHGausHist.GetBinCenter(axe->GetLast())  : xmax;
    669670
    670671  //
    671672  // First guesses for the fit (should be as close to reality as possible,
    672673  //
    673   const Stat_t   entries     = fHGausHist.Integral("width");
     674  const Stat_t   entries     = fHGausHist.Integral(axe->FindBin(rmin),axe->FindBin(rmax),"width");
    674675  const Double_t mu_guess    = fHGausHist.GetBinCenter(fHGausHist.GetMaximumBin());
    675676  const Double_t sigma_guess = fHGausHist.GetRMS();
     
    687688  fFGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
    688689  fFGausFit->SetParNames("Area","#mu","#sigma");
    689   fFGausFit->SetParLimits(0,0.,area_guess*1.5);
     690  fFGausFit->SetParLimits(0,0.,area_guess*25.);
    690691  fFGausFit->SetParLimits(1,rmin,rmax);
    691692  fFGausFit->SetParLimits(2,0.,rmax-rmin);
Note: See TracChangeset for help on using the changeset viewer.