Ignore:
Timestamp:
02/05/04 16:19:20 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r3012 r3025  
    5252const Int_t   MHCalibrationPixel::fChargeNbinsHiGain = 2100;
    5353const Int_t   MHCalibrationPixel::fChargeNbinsLoGain = 1010;
     54const Int_t   MHCalibrationPixel::fChargevsNbins     = 5000;
    5455const Int_t   MHCalibrationPixel::fAbsTimeNbins      = 32;
    55 const Int_t   MHCalibrationPixel::fRelTimeNbins      = 480;
    56 const Int_t   MHCalibrationPixel::fChargevsNbins     = 5000;
    5756const Axis_t  MHCalibrationPixel::fAbsTimeFirst      = - 0.25;
    5857const Axis_t  MHCalibrationPixel::fAbsTimeLast       =  15.75;
    59 const Axis_t  MHCalibrationPixel::fRelTimeFirst      = -11.;
    60 const Axis_t  MHCalibrationPixel::fRelTimeLast       =  12.;
     58const Int_t   MHCalibrationPixel::fRelTimeNbins      = 900;
     59const Axis_t  MHCalibrationPixel::fRelTimeFirst      = -13.;
     60const Axis_t  MHCalibrationPixel::fRelTimeLast       =  13.;
    6161const Float_t MHCalibrationPixel::fProbLimit         = 0.001;
     62const Int_t   MHCalibrationPixel::fNDFLimit          = 5;
    6263
    6364// --------------------------------------------------------------------------
     
    287288Bool_t MHCalibrationPixel::FillAbsTimeLoGain(Float_t t)
    288289{
    289     return (fHAbsTimeLoGain->Fill(t)   > -1);
     290    return (fHAbsTimeLoGain->Fill(t)> -1);
    290291}
    291292
    292293Bool_t MHCalibrationPixel::FillRelTimeLoGain(Float_t t)
    293294{
    294     return (fHRelTimeLoGain->Fill(t)   > -1);
     295    return (fHRelTimeLoGain->Fill(t) > -1);
    295296}
    296297
     
    323324{
    324325
    325   fPixId = id;
    326 
    327   //
    328   // Names Hi gain Histograms
    329   //
    330   fHChargeHiGain->SetName(   Form("%s%d",fHChargeHiGain->GetName(),   id));
    331   fHAbsTimeHiGain->SetName(  Form("%s%d",fHAbsTimeHiGain->GetName(),  id));
    332   fHRelTimeHiGain->SetName(  Form("%s%d",fHRelTimeHiGain->GetName(),  id));
    333   fHChargevsNHiGain->SetName(Form("%s%d",fHChargevsNHiGain->GetName(),id));
    334 
    335   //
    336   // Title Hi gain Histograms
    337   //
    338   fHChargeHiGain->SetTitle(    Form("%s%d",fHChargeHiGain->GetTitle(),   id));
    339   fHAbsTimeHiGain->SetTitle(   Form("%s%d",fHAbsTimeHiGain->GetTitle(),  id));
    340   fHRelTimeHiGain->SetTitle(   Form("%s%d",fHRelTimeHiGain->GetTitle(),  id));
    341   fHChargevsNHiGain->SetTitle( Form("%s%d",fHChargevsNHiGain->GetTitle(),id));
    342 
    343   //
    344   // Names Low Gain Histograms
    345   //
    346   fHChargeLoGain->SetName( Form("%s%d",fHChargeLoGain->GetName(),id));
    347   fHAbsTimeLoGain->SetName( Form("%s%d",fHAbsTimeLoGain->GetName(),id));
    348   fHRelTimeLoGain->SetName( Form("%s%d",fHRelTimeLoGain->GetName(),id));
    349   fHChargevsNLoGain->SetName( Form("%s%d",fHChargevsNLoGain->GetName(),id));
    350 
    351   //
    352   // Titles Low Gain Histograms
    353   //
    354   fHChargeLoGain->SetTitle( Form("%s%d",fHChargeLoGain->GetTitle(),id));
    355   fHAbsTimeLoGain->SetTitle( Form("%s%d",fHAbsTimeLoGain->GetTitle(),id));
    356   fHRelTimeLoGain->SetTitle( Form("%s%d",fHRelTimeLoGain->GetTitle(),id));
    357   fHChargevsNLoGain->SetTitle( Form("%s%d",fHChargevsNLoGain->GetTitle(),id));
     326  // Change only if the names have not yet been changed
     327  if (fPixId == -1)
     328    {
     329     
     330      //
     331      // Names Hi gain Histograms
     332      //
     333      fHChargeHiGain->SetName(   Form("%s%d",fHChargeHiGain->GetName(),   id));
     334      fHAbsTimeHiGain->SetName(  Form("%s%d",fHAbsTimeHiGain->GetName(),  id));
     335      fHRelTimeHiGain->SetName(  Form("%s%d",fHRelTimeHiGain->GetName(),  id));
     336      fHChargevsNHiGain->SetName(Form("%s%d",fHChargevsNHiGain->GetName(),id));
     337     
     338      //
     339      // Title Hi gain Histograms
     340      //
     341      fHChargeHiGain->SetTitle(    Form("%s%d",fHChargeHiGain->GetTitle(),   id));
     342      fHAbsTimeHiGain->SetTitle(   Form("%s%d",fHAbsTimeHiGain->GetTitle(),  id));
     343      fHRelTimeHiGain->SetTitle(   Form("%s%d",fHRelTimeHiGain->GetTitle(),  id));
     344      fHChargevsNHiGain->SetTitle( Form("%s%d",fHChargevsNHiGain->GetTitle(),id));
     345 
     346      //
     347      // Names Low Gain Histograms
     348      //
     349      fHChargeLoGain->SetName( Form("%s%d",fHChargeLoGain->GetName(),id));
     350      fHAbsTimeLoGain->SetName( Form("%s%d",fHAbsTimeLoGain->GetName(),id));
     351      fHRelTimeLoGain->SetName( Form("%s%d",fHRelTimeLoGain->GetName(),id));
     352      fHChargevsNLoGain->SetName( Form("%s%d",fHChargevsNLoGain->GetName(),id));
     353
     354      //
     355      // Titles Low Gain Histograms
     356      //
     357      fHChargeLoGain->SetTitle( Form("%s%d",fHChargeLoGain->GetTitle(),id));
     358      fHAbsTimeLoGain->SetTitle( Form("%s%d",fHAbsTimeLoGain->GetTitle(),id));
     359      fHRelTimeLoGain->SetTitle( Form("%s%d",fHRelTimeLoGain->GetTitle(),id));
     360      fHChargevsNLoGain->SetTitle( Form("%s%d",fHChargevsNLoGain->GetTitle(),id));
     361     
     362      fPixId = id;
     363    }
     364 
    358365}
    359366
     
    673680 
    674681  fHivsLoGain->Fit("pol1","rq","",fHivsLoGain->GetMean()-2.5*fHivsLoGain->GetRMS(),
    675                                   fHivsLoGain->GetMean()+2.0*fHivsLoGain->GetRMS());
     682                                  fHivsLoGain->GetMean()+2.5*fHivsLoGain->GetRMS());
    676683 
    677684  fOffset = fHivsLoGain->GetFunction("pol1")->GetParameter(0);
     
    744751  if (fRelTimeGausFit->GetProb() < 0.001)
    745752    {
    746       rmin = fRelTimeGausFit->GetParameter(1) - 2.*fRelTimeGausFit->GetParameter(2);
    747       rmax = fRelTimeGausFit->GetParameter(1) + 2.*fRelTimeGausFit->GetParameter(2);
     753      rmin = fRelTimeGausFit->GetParameter(1) - 1.5*fRelTimeGausFit->GetParameter(2);
     754      rmax = fRelTimeGausFit->GetParameter(1) + 1.5*fRelTimeGausFit->GetParameter(2);
    748755      fRelTimeGausFit->SetRange(rmin,rmax); 
    749756      hist->Fit(fRelTimeGausFit,option);
     
    765772    }
    766773 
    767   if (TMath::IsNaN(fRelTimeChisquare) || (fRelTimeProb < gkProbLimit))
     774  if (TMath::IsNaN(fRelTimeChisquare) || (fRelTimeProb < fProbLimit))
    768775    {
    769776      CLRBIT(fFlags,kTimeFitOK);
     
    788795  //
    789796  Axis_t rmin = fChargeFirstHiGain;
     797  Axis_t rmax = fChargeLastHiGain;
     798  TH1F *hist = fHChargeHiGain;
     799
    790800  if (TESTBIT(fFlags,kUseLoGain))
    791     rmin = fChargeFirstLoGain;
    792 
    793   Axis_t rmax = fChargeLastHiGain;
    794   if (TESTBIT(fFlags,kUseLoGain))
    795     rmax = fChargeLastLoGain;
    796 
    797   TH1F *hist = fHChargeHiGain;
    798   if (TESTBIT(fFlags,kUseLoGain))
    799     hist = fHChargeLoGain;
    800 
     801    {
     802      rmin = fChargeFirstLoGain;
     803      rmax = fChargeLastLoGain;
     804      hist = fHChargeLoGain;
     805    }
     806 
    801807  //
    802808  // First guesses for the fit (should be as close to reality as possible,
    803   // otherwise the fit goes gaga because of high number of dimensions ...
    804   //
    805   const Stat_t   entries     = hist->Integral();
    806   const Double_t area_guess  = entries/gkSq2Pi;
     809  //
     810  const Stat_t   entries     = hist->Integral("width");
    807811  const Double_t mu_guess    = hist->GetBinCenter(hist->GetMaximumBin());
    808   const Double_t sigma_guess = mu_guess/15.;
    809 
    810   TString name = TString("ChargeGausFit");
    811   name += fPixId;
    812 
    813   fChargeGausFit = new TF1(name.Data(),"gaus",rmin,rmax);
     812  const Double_t sigma_guess = (rmax-rmin)/2.;
     813  const Double_t area_guess  = entries/gkSq2Pi/sigma_guess;
     814
     815  fChargeGausFit = new TF1(Form("%s%d","ChargeGausFit",fPixId),"gaus",rmin,rmax);
    814816
    815817  if (!fChargeGausFit)
     
    831833  // If we are not able to fit, try once again
    832834  //
    833   if (fChargeGausFit->GetProb() < gkProbLimit)
    834     {
    835 
    836       Axis_t rtry = fChargeGausFit->GetParameter(1) - 3.0*fChargeGausFit->GetParameter(2);
     835  if (fChargeGausFit->GetProb() < fProbLimit)
     836    {
     837
     838      Axis_t rtry = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
    837839      rmin        = (rtry < rmin ? rmin : rtry);
    838       rmax        = fChargeGausFit->GetParameter(1) + 3.0*fChargeGausFit->GetParameter(2);
     840      rmax        = fChargeGausFit->GetParameter(1) + 2.5*fChargeGausFit->GetParameter(2);
     841
    839842      fChargeGausFit->SetRange(rmin,rmax); 
    840 
    841       fHChargeHiGain->Fit(fChargeGausFit,option);
     843      hist->Fit(fChargeGausFit,option);
    842844    }
    843845 
     
    852854  //
    853855  // The fit result is accepted under condition:
    854   // The Results are not nan's
    855   // The Probability is greater than gkProbLimit (default 0.001 == 99.9%)
    856   //
    857   if (TMath::IsNaN(fChargeMean) || TMath::IsNaN(fChargeMeanErr))
    858     {
     856  // 1) The results are not nan's
     857  // 2) The NDF is not smaller than fNDFLimit (5)
     858  // 3) The Probability is greater than fProbLimit (default 0.001 == 99.9%)
     859  //
     860  // Otherwise take means and RMS of the histograms
     861  //
     862  if (    TMath::IsNaN(fChargeMean)
     863      || TMath::IsNaN(fChargeMeanErr)
     864      || TMath::IsNaN(fChargeProb)   
     865      || TMath::IsNaN(fChargeSigma)
     866      || TMath::IsNaN(fChargeSigmaErr)
     867      || (fChargeNdf < fNDFLimit)
     868      || (fChargeProb < fProbLimit) )
     869    {
     870
     871      fChargeMean      = hist->GetMean();
     872      fChargeMeanErr   = hist->GetRMS()/hist->GetEntries();
     873      fChargeSigma     = hist->GetRMS();
     874      fChargeSigmaErr  = fChargeMeanErr/2.;
     875     
    859876      CLRBIT(fFlags,kChargeFitOK);
    860877      return kFALSE;
    861878    }
    862879 
    863   if ((fChargeProb < gkProbLimit) || (TMath::IsNaN(fChargeProb)))
    864     {
    865       CLRBIT(fFlags,kChargeFitOK);
    866       return kFALSE;
    867     }
    868  
    869880  SETBIT(fFlags,kChargeFitOK);
    870881  return kTRUE;
     
    877888{
    878889
    879   Int_t nbins = 30;
     890  Int_t nbins = 50;
    880891
    881892  CutEdges(fHChargeHiGain,nbins);
     
    891902                      +fHChargeLoGain->GetBinWidth(0);
    892903
    893   CutEdges(fHRelTimeHiGain,nbins);
     904  CutEdges(fHRelTimeHiGain,0);
    894905
    895906  fRelTimeLowerFitRangeHiGain = fHRelTimeHiGain->GetBinLowEdge(fHRelTimeHiGain->GetXaxis()->GetFirst());
     
    897908                               +fHRelTimeHiGain->GetBinWidth(0);
    898909
    899   CutEdges(fHRelTimeLoGain,nbins);
     910  CutEdges(fHRelTimeLoGain,0);
    900911
    901912  fRelTimeLowerFitRangeLoGain = fHRelTimeLoGain->GetBinLowEdge(fHRelTimeLoGain->GetXaxis()->GetFirst());
     
    903914                               +fHRelTimeLoGain->GetBinWidth(0);
    904915
    905   CutEdges(fHAbsTimeHiGain,nbins);
     916  CutEdges(fHAbsTimeHiGain,0);
    906917
    907918  fAbsTimeFirstHiGain = fHAbsTimeHiGain->GetBinLowEdge(fHAbsTimeHiGain->GetXaxis()->GetFirst());
     
    909920                       +fHAbsTimeHiGain->GetBinWidth(0);
    910921
    911   CutEdges(fHAbsTimeLoGain,nbins);
     922  CutEdges(fHAbsTimeLoGain,0);
    912923
    913924  fAbsTimeFirstLoGain = fHAbsTimeLoGain->GetBinLowEdge(fHAbsTimeLoGain->GetXaxis()->GetFirst());
Note: See TracChangeset for help on using the changeset viewer.