Changeset 5843 for trunk


Ignore:
Timestamp:
01/14/05 15:22:39 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r5841 r5843  
    3030     - fixed one warning output which was not a real warning.
    3131
     32   * mcalib/MCalibrationChargeCam.cc
     33     - improved the function to calculate a mean conversion factor over
     34       the whole camera including a fit to the values.
    3235
    3336
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc

    r5840 r5843  
    8484
    8585#include <TOrdCollection.h>
     86#include <TH1D.h>
     87#include <TF1.h>
    8688
    8789#include "MLog.h"
     
    9698#include "MCalibrationQECam.h"
    9799#include "MCalibrationQEPix.h"
     100
     101#include "MHCamera.h"
    98102
    99103ClassImp(MCalibrationChargeCam);
     
    650654  Int_t    nr    = 0;
    651655
     656  MHCamera convcam(geom,"ConvFactors","Conversion Factors;Conv Factor [phot/FADC cnts];channels");
     657
    652658  for (int i=0; i<np; i++)
    653659    {
    654660      if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
     661        continue;
     662
     663      if (bad && (*bad)[i].IsUncalibrated(MBadPixelsPix::kDeviatingNumPhes))
    655664        continue;
    656665
     
    665674     
    666675      const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[i];
    667       const Float_t conv = pix.GetMeanConvFADC2Phe();
    668       const Float_t qe   = qepix.GetQECascadesFFactor();
    669 
    670       mean  += conv/qe;
    671       mean2 += conv*conv/qe/qe;
     676      const Float_t conv = pix.GetMeanConvFADC2Phe()/qepix.GetQECascadesFFactor();
     677
     678      mean  += conv;
     679      mean2 += conv*conv;
    672680      nr    ++;
    673      
    674     }
     681
     682      convcam.Fill(i,conv);
     683      convcam.SetUsed(i);
     684    }
     685
     686  Float_t mn  = nr   ? mean/nr : -1.;
     687  Float_t sg  = nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0.;
     688
     689  const Int_t aidx = (Int_t)ai;
     690
     691  TH1D *h = convcam.ProjectionS(TArrayI(),TArrayI(1,&aidx),"_py",750);
     692  h->SetDirectory(NULL);
     693  h->Fit("gaus","Q");
     694  TF1 *fit = h->GetFunction("gaus");
     695 
     696  Float_t ci2   = fit->GetChisquare();
     697  Float_t sigma = fit->GetParameter(2);
     698 
     699  if (ci2 > 500. || sigma > sg)
     700    {
     701      h->Fit("gaus","QM");
     702      fit = h->GetFunction("gaus");
     703     
     704      ci2   = fit->GetChisquare();
     705      sigma = fit->GetParameter(2);
     706    }
     707 
     708  const Int_t ndf = fit->GetNDF();
     709
     710  if (ci2 < 500. && sigma < sg && ndf > 2)
     711    {
     712      mn  = fit->GetParameter(1);
     713      sg  = sigma;
     714    }
     715 
     716  *fLog << inf << "Conversion Factors to photons area idx: " << aidx << ":" << endl;
     717  *fLog << inf << "Mean: " << Form("%4.3f",mn)
     718        << "+-" << Form("%4.3f",fit->GetParError(1))
     719        << "  Sigma: " << Form("%4.3f",sg) << "+-" << Form("%4.3f",fit->GetParError(2))
     720        << "  Chisquare: " << Form("%4.3f",fit->GetChisquare()) << "  NDF  : " << ndf << endl;         
     721 
     722  delete h;
     723  gROOT->GetListOfFunctions()->Remove(fit);
    675724
    676725  TArrayF arr(2);
    677   arr[0] = nr   ? mean/nr : -1.;
    678   arr[1] = nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0.;
     726  arr[0] = mn;
     727  arr[1] = sg;
    679728
    680729  return arr;
Note: See TracChangeset for help on using the changeset viewer.