Ignore:
Timestamp:
06/22/04 11:35:06 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r4283 r4320  
    186186#include <TSystem.h>
    187187#include <TH1.h>
     188#include <TF1.h>
    188189
    189190#include "MLog.h"
     
    197198#include "MGeomCam.h"
    198199#include "MGeomPix.h"
     200#include "MHCamera.h"
    199201
    200202#include "MPedestalCam.h"
     
    229231const Float_t MCalibrationChargeCalc::fgLambdaCheckLimit       = 0.5;
    230232const Float_t MCalibrationChargeCalc::fgPheErrLimit            = 3.5;
    231 const Float_t MCalibrationChargeCalc::fgFFactorErrLimit        = 3.5;
     233const Float_t MCalibrationChargeCalc::fgFFactorErrLimit        = 4.5;
    232234// --------------------------------------------------------------------------
    233235//
     
    701703  PrintUncalibrated(MBadPixelsPix::kDeviatingNumPhes,   
    702704                    "Pixels with deviating number of phes:             ");
     705  PrintUncalibrated(MBadPixelsPix::kDeviatingFFactor,   
     706                    "Pixels with deviating F-Factor:                   ");
    703707
    704708  *fLog << inf << endl;
     
    923927  //             The loop is only to recognize later pixels with very deviating numbers
    924928  //
     929  MHCamera camphes(*fGeom,"Camphes","Phes in Camera");
     930
    925931  for (UInt_t i=0; i<npixels; i++)
    926932    {
     
    944950      const Float_t nvar  = pix.GetPheFFactorMethod()*pix.GetPheFFactorMethod();
    945951      const Int_t   aidx  = (*fGeom)[i].GetAidx();
     952
     953      camphes.Fill(i,nphe);
     954      camphes.SetUsed(i);
    946955
    947956      areaphes    [aidx] += nphe;
     
    973982      lowlim  [i] = areaphes[i] - fPheErrLimit*TMath::Sqrt(areavars[i]);
    974983      upplim  [i] = areaphes[i] + fPheErrLimit*TMath::Sqrt(areavars[i]);
     984
     985      TArrayI area(1);
     986      area[0] = i;
     987
     988      TH1D *hist = camphes.ProjectionS(TArrayI(),area);
     989      hist->Fit("gaus","Q");
     990      const Float_t mean  = hist->GetFunction("gaus")->GetParameter(1);
     991      const Float_t sigma = hist->GetFunction("gaus")->GetParameter(2);
     992      const Int_t   ndf   = hist->GetFunction("gaus")->GetNDF();
     993
     994      if (ndf < 2)
     995        {
     996          *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons "
     997                << "in the camera with area index: " << i << endl;
     998          *fLog << warn << GetDescriptor() << ": Number of dof.: " << ndf << " is smaller than 2 " << endl;
     999          *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl;
     1000          delete hist;
     1001          continue;
     1002        }
     1003     
     1004      const Double_t prob = hist->GetFunction("gaus")->GetProb();
     1005
     1006      if (prob < 0.001)
     1007        {
     1008          *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons "
     1009                << "in the camera with area index: " << i << endl;
     1010          *fLog << warn << GetDescriptor() << ": Fit probability " << prob
     1011                << " is smaller than 0.001 " << endl;
     1012          *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl;
     1013          delete hist;
     1014          continue;
     1015        }
     1016     
     1017      *fLog << inf << endl;
     1018      *fLog << inf << GetDescriptor() << ": Mean Number of photo-electrons "
     1019            << "in the camera with area index: " << i << ": "
     1020            << Form("%4.2f%s%4.2f",mean,"+-",sigma) << endl;
     1021      *fLog << inf << endl;
     1022
     1023      lowlim  [i] = mean  - fPheErrLimit*sigma;
     1024      upplim  [i] = mean  + fPheErrLimit*sigma;
     1025
     1026      delete hist;
    9751027    }
    9761028
     
    12891341  const UInt_t npixels  = fGeom->GetNumPixels();
    12901342
     1343  MHCamera camffactor(*fGeom,"Camffactor","F-Factor in Camera");
     1344
    12911345  for (UInt_t i=0; i<npixels; i++)
    12921346    {
     
    13061360          (*fBadPixels)[i].SetUncalibrated( MBadPixelsPix::kDeviatingNumPhes );
    13071361          continue;
    1308          
    13091362        }
    13101363
     
    13201373
    13211374      const Int_t aidx = (*fGeom)[i].GetAidx();
    1322 
    1323       avffactorphotons[aidx] += pix.GetMeanFFactorFADC2Phot();
     1375      const Float_t ffactor = pix.GetMeanFFactorFADC2Phot();
     1376
     1377      camffactor.Fill(i,ffactor);
     1378      camffactor.SetUsed(i);
     1379
     1380      avffactorphotons[aidx] += ffactor;
    13241381      avffactorphotvar[aidx] += pix.GetMeanFFactorFADC2PhotVar();
    13251382      numffactor[aidx]++;
     
    13301387      avffactorphotons[i] /= numffactor[i];
    13311388      avffactorphotvar[i] /= numffactor[i];
    1332       lowlim  [i] = 1.1;
     1389
     1390      lowlim  [i] = 1.1;   // Lowest known F-Factor of a PMT
    13331391      upplim  [i] = avffactorphotons[i] + fFFactorErrLimit*TMath::Sqrt(avffactorphotvar[i]);
     1392
     1393      TArrayI area(1);
     1394      area[0] = i;
     1395
     1396      TH1D *hist = camffactor.ProjectionS(TArrayI(),area);
     1397      hist->Fit("gaus","Q");
     1398      const Float_t mean  = hist->GetFunction("gaus")->GetParameter(1);
     1399      const Float_t sigma = hist->GetFunction("gaus")->GetParameter(2);
     1400      const Int_t   ndf   = hist->GetFunction("gaus")->GetNDF();
     1401
     1402      if (ndf < 2)
     1403        {
     1404          *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor "
     1405                << "in the camera with area index: " << i << endl;
     1406          *fLog << warn << GetDescriptor() << ": Number of dof.: " << ndf << " is smaller than 2 " << endl;
     1407          *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl;
     1408          delete hist;
     1409          continue;
     1410        }
     1411     
     1412      const Double_t prob = hist->GetFunction("gaus")->GetProb();
     1413
     1414      if (prob < 0.001)
     1415        {
     1416          *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor "
     1417                << "in the camera with area index: " << i << endl;
     1418          *fLog << warn << GetDescriptor() << ": Fit probability " << prob
     1419                << " is smaller than 0.001 " << endl;
     1420          *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl;
     1421          delete hist;
     1422          continue;
     1423        }
     1424
     1425      *fLog << inf << endl;
     1426      *fLog << inf << GetDescriptor() << ": Mean F-Factor "
     1427            << "in the camera with area index: " << i << ": "
     1428            << Form("%4.2f%s%4.2f",mean,"+-",sigma) << endl;
     1429      *fLog << inf << endl;
     1430
     1431      lowlim  [i] = mean  - fFFactorErrLimit*sigma;
     1432      upplim  [i] = mean  + fFFactorErrLimit*sigma;
     1433
     1434      delete hist;
    13341435    }
    13351436 
Note: See TracChangeset for help on using the changeset viewer.