Changeset 2790


Ignore:
Timestamp:
01/13/04 17:29:27 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r2789 r2790  
    99     - make Stat Window in option 'proj' bigger
    1010     - add comment line at beginning of Draw()
     11
     12   * mcalib/MHCalibrationBlindPixel.[h.cc]
     13     - add Function DrawClone()
     14     - fix bug in calculation of integral (GetIntegral("width"))
     15     - fit now with fixed normalization
     16     - restrict parameters tighter
     17     - declare fit as not valid, if less than 100 events
     18       in single photo-electron peak
    1119
    1220
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.cc

    r2734 r2790  
    2727//  MHCalibrationBlindPixel                                                 //
    2828//                                                                          //
    29 //  Performs all the necessary fits to extract the mean number of photons   //
    30 //              out of the derived light flux                               //
     29//  Performs all the Single Photo-Electron Fit to extract                   //
     30//  the mean number of photons and to derive the light flux                 //
     31//                                                                          //
     32// The fit result is accepted under condition that:                         //
     33// 1) the Probability is greater than gkProbLimit (default 0.001 == 99.7%)  //
     34// 2) at least 100 events are in the single Photo-electron peak             //
    3135//                                                                          //
    3236//////////////////////////////////////////////////////////////////////////////
     
    8387    fHBlindPixelCharge->SetYTitle("Nr. of events");
    8488    fHBlindPixelCharge->Sumw2();
     89    fHBlindPixelCharge->SetDirectory(NULL);
    8590
    8691    Axis_t tfirst = -0.5;
     
    9297    fHBlindPixelTime->SetYTitle("Nr. of events");
    9398    fHBlindPixelTime->Sumw2();
     99    fHBlindPixelTime->SetDirectory(NULL);
    94100
    95101    // We define a reasonable number and later enlarge it if necessary
     
    101107    fHBlindPixelChargevsN->SetXTitle("Event Nr.");
    102108    fHBlindPixelChargevsN->SetYTitle("Sum of FADC slices");
    103 
    104     fgSinglePheFitFunc = &gfKto8;
     109    fHBlindPixelChargevsN->SetDirectory(NULL);
     110
     111    fgSinglePheFitFunc = &gfKto4;
    105112    fgSinglePheFitNPar = 5;
    106113}
     
    187194
    188195}
     196
     197
     198TObject *MHCalibrationBlindPixel::DrawClone(Option_t *opt) const
     199{
     200
     201   //TVirtualPad *pad = gROOT->GetSelectedPad();
     202   TVirtualPad *padsav = gPad;
     203   //if (pad) pad->cd();
     204
     205   TObject *newobj = Clone();
     206
     207   if (!newobj)
     208       return 0;
     209
     210   newobj->Draw(opt);
     211
     212   if (padsav)
     213       padsav->cd();
     214
     215   return newobj;
     216}
     217 
    189218
    190219
     
    317346  // otherwise the fit goes gaga because of high number of dimensions ...
    318347  //
    319   const Stat_t   entries      = fHBlindPixelCharge->Integral();
     348  const Stat_t   entries      = fHBlindPixelCharge->Integral("width");
    320349  const Double_t lambda_guess = 0.5;
    321350  const Double_t mu_0_guess = fHBlindPixelCharge->GetBinCenter(fHBlindPixelCharge->GetMaximumBin());
    322351  const Double_t si_0_guess = 20.;
    323   const Double_t mu_1_guess = mu_0_guess + 100.;
     352  const Double_t mu_1_guess = mu_0_guess + 50.;
    324353  const Double_t si_1_guess = si_0_guess + si_0_guess;
    325354
    326355  fSinglePheFit = new TF1("SinglePheFit",fgSinglePheFitFunc,rmin,rmax,fgSinglePheFitNPar+1);
     356  //  fSinglePheFit = new TF1("SinglePheFit",fgSinglePheFitFunc,rmin,rmax,fgSinglePheFitNPar+1);
     357  //  fSinglePheFit->SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess);
    327358  fSinglePheFit->SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess,entries);
     359  //  fSinglePheFit->SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1");
    328360  fSinglePheFit->SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1","area");
    329   fSinglePheFit->SetParLimits(0,0.,3.);
    330   fSinglePheFit->SetParLimits(1,rmin,rmax);
    331   fSinglePheFit->SetParLimits(2,rmin,rmax);
    332   fSinglePheFit->SetParLimits(3,1.0,rmax-rmin);
    333   fSinglePheFit->SetParLimits(4,1.7,rmax-rmin);
    334   fSinglePheFit->SetParLimits(5,0.,1.5*entries);
     361  fSinglePheFit->SetParLimits(0,0.,1.);
     362  fSinglePheFit->SetParLimits(1,rmin,(rmax-rmin)/1.5);
     363  fSinglePheFit->SetParLimits(2,(rmax-rmin)/2.,(rmax-0.05*(rmax-rmin)));
     364  fSinglePheFit->SetParLimits(3,1.0,(rmax-rmin)/2.0);
     365  fSinglePheFit->SetParLimits(4,1.0,(rmax-rmin)/2.5);
     366  //  fSinglePheFit->SetParLimits(5,entries/gkSq2Pi,entries/gkSq2Pi);
     367  //  fSinglePheFit->SetParLimits(5,0.,1.5*entries);
    335368  //
    336369  // Normalize the histogram to facilitate faster fitting of the area
    337   // For speed reasons, FKto8 is normalized to Sqrt(2 pi).
     370  // For speed reasons, gfKto4 is normalized to Sqrt(2 pi).
    338371  // Therefore also normalize the histogram to that value
    339372  //
    340   // ROOT gives us another nice example of user-unfriendly behavior:
    341   // Although the normalization of the function fSinglePhe and the
    342   // Histogram fHBlindPixelCharge agree (!!), the fit does not normalize correctly INTERNALLY
    343   // in the fitting procedure !!!
    344   //
    345   // This has to do with the fact that the internal function histogramming
    346   // uses 100 bins and does not adapt to the binning of the fitted histogram, unlike PAW does
    347   // (very important if you use Sumw2, see e.g. ROOTTALK: Mon May 26 1997 - 09:56:03 MEST)
    348   //
    349   // So, WE have to adapt to that internal flaw of ROOT:
    350   //
    351   //  const Int_t  npx     = fSinglePheFit->GetNpx();
    352   //  const Int_t  bins    = fHBlindPixelCharge->GetXaxis()->GetLast()-fHBlindPixelCharge->GetXaxis()->GetFirst();
    353373  //  fHBlindPixelCharge->Scale(gkSq2Pi*(float)bins/npx/entries);
    354 
    355   //
    356   // we need this, otherwise, ROOT does not calculate the area correctly
    357   // don't ask me why it does not behave correctly, it's one of the nasty
    358   // mysteries of ROOT which takes you a whole day to find out :-)
    359   //
    360   //  fSinglePheFit->SetNpx(fChargenbins); 
    361 
    362   fHBlindPixelCharge->Fit(fSinglePheFit,opt);
     374  // fHBlindPixelCharge->Scale(gkSq2Pi/entries);
     375  Float_t  norm   = entries/gkSq2Pi;
     376  //           norm  *= (Float_t)fSinglePheFit->GetNpx()/(Float_t)fBlindPixelChargenbins;
     377  fSinglePheFit->SetParLimits(5,norm-0.1,norm+0.1);
     378
    363379  fHBlindPixelCharge->Fit(fSinglePheFit,opt);
    364380
     
    384400
    385401  Double_t pedarea = fSinglePhePedFit->GetParameter(0)*gkSq2Pi*fSinglePhePedFit->GetParameter(2);
    386   cout << "Parameter0: " << fSinglePhePedFit->GetParameter(0) << endl;
    387   cout << "Parameter2: " << fSinglePhePedFit->GetParameter(2) << endl;
    388   cout << "Pedarea: " << pedarea << endl;
    389   cout << "entries: " << entries << endl;
    390   fLambdaCheck     = TMath::Log((double)entries/pedarea);
     402  fLambdaCheck     = TMath::Log(entries/pedarea);
    391403  fLambdaCheckErr  = fSinglePhePedFit->GetParError(0)/fSinglePhePedFit->GetParameter(0)
    392404                     + fSinglePhePedFit->GetParError(2)/fSinglePhePedFit->GetParameter(2);
     
    396408  *fLog << "DoF: " << fNdf << endl;
    397409  *fLog << "Probability: " << fProb << endl;
    398   *fLog << "Integral: " << fSinglePheFit->Integral(rmin,rmax);
    399 
    400   //
    401   // The fit result is accepted under condition
    402   // The fit result is accepted under condition
    403   // The Probability is greater than gkProbLimit (default 0.001 == 99.7%)
     410
     411  //
     412  // The fit result is accepted under condition that:
     413  // 1) the Probability is greater than gkProbLimit (default 0.001 == 99.7%)
     414  // 2) at least 100 events are in the single Photo-electron peak
    404415  //
    405416  if (fProb < gkProbLimit)
    406417    {
    407       *fLog << warn << "Prob: " << fProb << " is smaller than the allowed value: " << gkProbLimit << endl;
     418      *fLog << err << "Prob: " << fProb << " is smaller than the allowed value: " << gkProbLimit << endl;
    408419      fFitOK = kFALSE;
    409420      return kFALSE;
    410421    }
    411  
     422
     423  Float_t contSinglePhe = TMath::Exp(-1.0*fLambda)*fLambda*entries;
     424 
     425  if (contSinglePhe < 100.)
     426    {
     427      *fLog << err << "Statistics is too low: Only " << contSinglePhe
     428            << " in the first electron peak " << endl;
     429      fFitOK = kFALSE;
     430      return kFALSE;
     431    }
     432  else
     433    *fLog << GetDescriptor() << ": " << contSinglePhe
     434          << " in first electron peak " << endl;
    412435 
    413436  fFitOK = kTRUE;
     
    420443{
    421444
    422   Int_t nbins = 50;
     445  Int_t nbins = 30;
    423446
    424447  CutEdges(fHBlindPixelCharge,nbins);
  • trunk/MagicSoft/Mars/mhist/MHCamera.cc

    r2781 r2790  
    375375//   'content'     Display the relative content aligned to GetMaximum() and
    376376//                 GeMinimum() ((val-min)/(max-min))
     377//   'proj'        Display the y-projection of the histogram
    377378//
    378379void MHCamera::Draw(Option_t *option)
     
    620621      CreateProjection();
    621622      opt.ReplaceAll("proj", "");
     623      Float_t he = gStyle->GetStatH();
     624      Float_t wi = gStyle->GetStatH();
     625      gStyle->SetStatH(0.4);
     626      gStyle->SetStatW(0.25);
    622627      fYProj->Paint(opt);
     628      gStyle->SetStatH(he);     
     629      gStyle->SetStatW(wi);     
    623630      return;
    624631    }
Note: See TracChangeset for help on using the changeset viewer.