Ignore:
Timestamp:
02/02/04 22:52:53 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r2980 r3007  
    5050using namespace std;
    5151
     52const Int_t   MHCalibrationPixel::fChargeNbinsHiGain = 2100;
     53const Int_t   MHCalibrationPixel::fChargeNbinsLoGain = 1010;
     54const Int_t   MHCalibrationPixel::fAbsTimeNbins      = 32;
     55const Int_t   MHCalibrationPixel::fRelTimeNbins      = 240;
     56const Int_t   MHCalibrationPixel::fChargevsNbins     = 5000;
     57const Axis_t  MHCalibrationPixel::fAbsTimeFirst      = - 0.25;
     58const Axis_t  MHCalibrationPixel::fAbsTimeLast       =  15.75;
     59const Axis_t  MHCalibrationPixel::fRelTimeFirst      = -11.;
     60const Axis_t  MHCalibrationPixel::fRelTimeLast       =  12.;
     61
    5262// --------------------------------------------------------------------------
    5363//
     
    5666MHCalibrationPixel::MHCalibrationPixel(const char *name, const char *title)
    5767      : fPixId(-1),
    58         fChargeNbinsHiGain(2100),
    59         fChargeNbinsLoGain(1010),
    60         fTimeNbins(32),
    61         fChargevsNbins(5000),
    62         fTimeFirst(-0.25),
    63         fTimeLast(15.75),
    6468        fHivsLoGain(NULL),
    6569        fHPSD(NULL),
    6670        fChargeGausFit(NULL),
    67         fTimeGausFit(NULL),
     71        fRelTimeGausFit(NULL),
    6872        fFitLegend(NULL)
    6973{
     
    9296    fHChargeLoGain->Sumw2();
    9397
    94     fHTimeHiGain = new TH1F("HTimeHiGain","Distribution of Mean Arrival Hi Gain Times Pixel ",
    95                             fTimeNbins,fTimeFirst,fTimeLast);
    96     fHTimeLoGain = new TH1F("HTimeLoGain","Distribution of Mean Arrival Lo Gain Times Pixel ",
    97                             fTimeNbins,fTimeFirst,fTimeLast);
    98 
    99     fHTimeHiGain->SetXTitle("Mean Arrival Times [Hi Gain FADC slice nr]");
    100     fHTimeLoGain->SetXTitle("Mean Arrival Times [Lo Gain FADC slice nr]");
    101 
    102     fHTimeHiGain->SetYTitle("Nr. of events");
    103     fHTimeLoGain->SetYTitle("Nr. of events");
     98    // Absolute Times
     99    fHAbsTimeHiGain = new TH1F("HAbsTimeHiGain","Distribution of Absolute Arrival Hi Gain Times Pixel ",
     100                               fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
     101    fHAbsTimeLoGain = new TH1F("HAbsTimeLoGain","Distribution of Absolute Arrival Lo Gain Times Pixel ",
     102                               fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
     103
     104    fHAbsTimeHiGain->SetXTitle("Absolute Arrival Time [Hi Gain FADC slice nr]");
     105    fHAbsTimeLoGain->SetXTitle("Absolute Arrival Time [Lo Gain FADC slice nr]");
     106
     107    fHAbsTimeHiGain->SetYTitle("Nr. of events");
     108    fHAbsTimeLoGain->SetYTitle("Nr. of events");
     109
     110    // Relative Times
     111    fHRelTimeHiGain = new TH1F("HRelTimeHiGain","Distribution of Relative Arrival Times High Gain Pixel ",
     112                               fRelTimeNbins,fRelTimeFirst,fRelTimeLast);
     113    fHRelTimeLoGain = new TH1F("HRelTimeLoGain","Distribution of Relative Arrival Time Low Gain Pixel ",
     114                               fRelTimeNbins,fRelTimeFirst,fRelTimeLast);
     115
     116    fHRelTimeHiGain->SetXTitle("Relative Arrival Times [Hi Gain FADC slice nr]");
     117    fHRelTimeLoGain->SetXTitle("Relative Arrival Times [Lo Gain FADC slice nr]");
     118
     119    fHRelTimeHiGain->SetYTitle("Nr. of events");
     120    fHRelTimeLoGain->SetYTitle("Nr. of events");
    104121
    105122    // We define a reasonable number and later enlarge it if necessary
     
    117134    fHChargeHiGain->SetDirectory(NULL);
    118135    fHChargeLoGain->SetDirectory(NULL);
    119     fHTimeHiGain->SetDirectory(NULL);
    120     fHTimeLoGain->SetDirectory(NULL);
     136    fHAbsTimeHiGain->SetDirectory(NULL);
     137    fHAbsTimeLoGain->SetDirectory(NULL);
     138    fHRelTimeHiGain->SetDirectory(NULL);
     139    fHRelTimeLoGain->SetDirectory(NULL);
    121140    fHChargevsNHiGain->SetDirectory(NULL);
    122141    fHChargevsNLoGain->SetDirectory(NULL);
     
    133152
    134153  delete fHChargeHiGain;
    135   delete fHTimeHiGain;
     154  delete fHAbsTimeHiGain;
     155  delete fHRelTimeHiGain;
    136156  delete fHChargevsNHiGain;
    137157
    138158  delete fHChargeLoGain;
    139   delete fHTimeLoGain;
     159  delete fHAbsTimeLoGain;
     160  delete fHRelTimeLoGain;
    140161  delete fHChargevsNLoGain;
    141162
     
    145166  if (fChargeGausFit)
    146167    delete fChargeGausFit;
    147   if (fTimeGausFit)
    148     delete fTimeGausFit;
     168  if (fRelTimeGausFit)
     169    delete fRelTimeGausFit;
    149170  if (fFitLegend)
    150171    delete fFitLegend;
     
    168189  fChargeNdf               = -1;
    169190
    170   fTimeChisquare           = -1.;
    171   fTimeProb                = -1.;
    172   fTimeNdf                 = -1;
    173   fTimeMean                = -1.;
    174   fTimeSigma               = -1.;
    175 
    176   fTimeLowerFitRangeHiGain = 0;
    177   fTimeUpperFitRangeHiGain = 0;
    178   fTimeLowerFitRangeLoGain = 0;
    179   fTimeUpperFitRangeLoGain = 0;
     191  fRelTimeChisquare        = -1.;
     192  fRelTimeProb             = -1.;
     193  fRelTimeNdf              = -1;
     194  fRelTimeMean             = -1.;
     195  fRelTimeSigma            = -1.;
     196
     197  fRelTimeLowerFitRangeHiGain = -99.;
     198  fRelTimeUpperFitRangeHiGain = -99.;
     199  fRelTimeLowerFitRangeLoGain = -99.;
     200  fRelTimeUpperFitRangeLoGain = -99.;
     201
     202  fAbsTimeFirstHiGain     = -1.;
     203  fAbsTimeFirstLoGain     = -1.;
     204  fAbsTimeLastHiGain      = -1.;
     205  fAbsTimeLastLoGain      = -1.;
     206 
    180207
    181208  fOffset = 0.;
     
    184211  if (fChargeGausFit)
    185212    delete fChargeGausFit;
    186   if (fTimeGausFit)
    187     delete fTimeGausFit;
     213  if (fRelTimeGausFit)
     214    delete fRelTimeGausFit;
    188215  if (fFitLegend)
    189216    delete fFitLegend;
     
    193220    delete fHPSD;
    194221
     222  CLRBIT(fFlags,kUseLoGain);
     223  CLRBIT(fFlags,kChargeFitOK);
     224  CLRBIT(fFlags,kTimeFitOK);
     225
    195226  return;
    196227}
     
    204235  fHChargeHiGain->Reset();
    205236  fHChargeLoGain->Reset();
    206   fHTimeHiGain->Reset();
    207   fHTimeLoGain->Reset();
     237  fHAbsTimeHiGain->Reset();
     238  fHAbsTimeLoGain->Reset();
     239  fHRelTimeHiGain->Reset();
     240  fHRelTimeLoGain->Reset();
    208241  fHChargevsNHiGain->Reset();
    209242  fHChargevsNLoGain->Reset();
     
    214247}
    215248
     249void MHCalibrationPixel::SetUseLoGain(Bool_t b)
     250{
     251  if (b)
     252    SETBIT(fFlags, kUseLoGain) ;
     253  else
     254    CLRBIT(fFlags, kUseLoGain);
     255}
    216256
    217257
     
    226266}
    227267
    228 Bool_t MHCalibrationPixel::IsFitOK() const
    229 {
    230     return TESTBIT(fFlags,kFitOK);
     268Bool_t MHCalibrationPixel::IsChargeFitOK() const
     269{
     270    return TESTBIT(fFlags,kChargeFitOK);
     271}
     272
     273Bool_t MHCalibrationPixel::IsTimeFitOK() const
     274{
     275    return TESTBIT(fFlags,kTimeFitOK);
    231276}
    232277
     
    236281}
    237282
    238 Bool_t MHCalibrationPixel::FillTimeLoGain(Float_t t)
    239 {
    240     return (fHTimeLoGain->Fill(t)   > -1);
     283Bool_t MHCalibrationPixel::FillAbsTimeLoGain(Float_t t)
     284{
     285    return (fHAbsTimeLoGain->Fill(t)   > -1);
     286}
     287
     288Bool_t MHCalibrationPixel::FillRelTimeLoGain(Float_t t)
     289{
     290    return (fHRelTimeLoGain->Fill(t)   > -1);
    241291}
    242292
     
    251301}
    252302
    253 Bool_t MHCalibrationPixel::FillTimeHiGain(Float_t t)
    254 {
    255     return (fHTimeHiGain->Fill(t) > -1);
     303Bool_t MHCalibrationPixel::FillAbsTimeHiGain(Float_t t)
     304{
     305    return (fHAbsTimeHiGain->Fill(t) > -1);
     306}
     307
     308Bool_t MHCalibrationPixel::FillRelTimeHiGain(Float_t t)
     309{
     310    return (fHRelTimeHiGain->Fill(t) > -1);
    256311}
    257312
     
    273328  fHChargeHiGain->SetName(nameQHiGain.Data());
    274329
    275   TString nameTHiGain = TString(fHTimeHiGain->GetName());
    276   nameTHiGain += id;
    277   fHTimeHiGain->SetName(nameTHiGain.Data());
     330  TString nameTAHiGain = TString(fHAbsTimeHiGain->GetName());
     331  nameTAHiGain += id;
     332  fHAbsTimeHiGain->SetName(nameTAHiGain.Data());
     333
     334  TString nameTRHiGain = TString(fHRelTimeHiGain->GetName());
     335  nameTRHiGain += id;
     336  fHRelTimeHiGain->SetName(nameTRHiGain.Data());
    278337
    279338  TString nameQvsNHiGain  = TString(fHChargevsNHiGain->GetName());
     
    288347  fHChargeHiGain->SetTitle(titleQHiGain.Data());
    289348
    290   TString titleTHiGain = TString(fHTimeHiGain->GetTitle());
    291   titleTHiGain += id;
    292   fHTimeHiGain->SetTitle(titleTHiGain.Data());
     349  TString titleTAHiGain = TString(fHAbsTimeHiGain->GetTitle());
     350  titleTAHiGain += id;
     351  fHAbsTimeHiGain->SetTitle(titleTAHiGain.Data());
     352
     353  TString titleTRHiGain = TString(fHRelTimeHiGain->GetTitle());
     354  titleTRHiGain += id;
     355  fHRelTimeHiGain->SetTitle(titleTRHiGain.Data());
    293356
    294357  TString titleQvsNHiGain  = TString(fHChargevsNHiGain->GetTitle());
     
    303366  fHChargeLoGain->SetName(nameQLoGain.Data());
    304367
    305   TString nameTLoGain = TString(fHTimeLoGain->GetName());
    306   nameTLoGain += id;
    307   fHTimeLoGain->SetName(nameTLoGain.Data());
     368  TString nameTALoGain = TString(fHAbsTimeLoGain->GetName());
     369  nameTALoGain += id;
     370  fHAbsTimeLoGain->SetName(nameTALoGain.Data());
     371
     372  TString nameTRLoGain = TString(fHRelTimeLoGain->GetName());
     373  nameTRLoGain += id;
     374  fHRelTimeLoGain->SetName(nameTRLoGain.Data());
    308375
    309376  TString nameQvsNLoGain  = TString(fHChargevsNLoGain->GetName());
     
    318385  fHChargeLoGain->SetTitle(titleQLoGain.Data());
    319386
    320   TString titleTLoGain = TString(fHTimeLoGain->GetTitle());
    321   titleTLoGain += id;
    322   fHTimeLoGain->SetTitle(titleTLoGain.Data());
     387  TString titleTALoGain = TString(fHAbsTimeLoGain->GetTitle());
     388  titleTALoGain += id;
     389  fHAbsTimeLoGain->SetTitle(titleTALoGain.Data());
     390
     391  TString titleTRLoGain = TString(fHRelTimeLoGain->GetTitle());
     392  titleTRLoGain += id;
     393  fHRelTimeLoGain->SetTitle(titleTRLoGain.Data());
    323394
    324395  TString titleQvsNLoGain  = TString(fHChargevsNLoGain->GetTitle());
     
    375446  fFitLegend = new TPaveText(0.05,0.05,0.95,0.95);
    376447
    377   if (IsFitOK())
     448  if (IsChargeFitOK())
    378449      fFitLegend->SetFillColor(80);
    379450  else
     
    403474  t4->SetBit(kCanDelete);
    404475
    405   if (IsFitOK())
     476  if (IsChargeFitOK())
    406477    {
    407478      TText *t5 = fFitLegend->AddText("Result of the Fit: OK");
     
    459530  TCanvas *c = MakeDefCanvas(this,600,900);
    460531 
    461   c->Divide(2,4);
     532  c->Divide(2,5);
    462533 
    463534  c->cd(1);
     
    490561      if (fChargeGausFit)
    491562        {
    492           if (IsFitOK())
     563          if (IsChargeFitOK())
    493564            fChargeGausFit->SetLineColor(kGreen);         
    494565          else
     
    516587      if (fChargeGausFit)
    517588        {
    518           if (IsFitOK())
     589          if (IsChargeFitOK())
    519590            fChargeGausFit->SetLineColor(kGreen);         
    520591          else
     
    557628  gPad->SetTicks(); 
    558629  gPad->SetLogy(0);
    559   fHTimeHiGain->Draw(opt);
     630  fHRelTimeHiGain->Draw(opt);
    560631  c->Modified();
    561632  c->Update();
     
    567638        gPad->SetTicks();
    568639        gPad->SetLogy(0);
    569         fHTimeLoGain->Draw(opt);
     640        fHRelTimeLoGain->Draw(opt);
    570641        c->Modified();
    571642        c->Update();
    572643       
    573         if (fTimeGausFit)
     644        if (fRelTimeGausFit)
    574645          {
    575             if (fTimeChisquare > 20.)
    576               fTimeGausFit->SetLineColor(kRed);
     646            if (fRelTimeChisquare > 20.)
     647              fRelTimeGausFit->SetLineColor(kRed);
    577648            else
    578               fTimeGausFit->SetLineColor(kGreen);
     649              fRelTimeGausFit->SetLineColor(kGreen);
    579650           
    580             fTimeGausFit->Draw("same");
     651            fRelTimeGausFit->Draw("same");
    581652            c->Modified();
    582653            c->Update();
     
    585656    else
    586657      { 
    587         if (fTimeGausFit)
     658        if (fRelTimeGausFit)
    588659          {
    589             if (fTimeChisquare > 20.)
    590               fTimeGausFit->SetLineColor(kRed);
     660            if (fRelTimeChisquare > 20.)
     661              fRelTimeGausFit->SetLineColor(kRed);
    591662            else
    592               fTimeGausFit->SetLineColor(kGreen);
     663              fRelTimeGausFit->SetLineColor(kGreen);
    593664           
    594             fTimeGausFit->Draw("same");
     665            fRelTimeGausFit->Draw("same");
    595666            c->Modified();
    596667            c->Update();
     
    600671        gPad->SetTicks();
    601672        gPad->SetLogy(0);
    602         fHTimeLoGain->Draw(opt);       
     673        fHRelTimeLoGain->Draw(opt);     
    603674        c->Modified();
    604675        c->Update();
     
    610681    c->cd(7);
    611682    gPad->SetTicks();
     683    fHAbsTimeHiGain->Draw(opt);
     684    c->Modified();
     685    c->Update();
     686
     687    c->cd(8);
     688    gPad->SetTicks();
     689    fHAbsTimeLoGain->Draw(opt);
     690    c->Modified();
     691    c->Update();
     692
     693
     694    c->cd(9);
     695    gPad->SetTicks();
    612696    fHChargevsNHiGain->Draw(opt);
    613697    c->Modified();
    614698    c->Update();
    615699
    616     c->cd(8);
     700    c->cd(10);
    617701    gPad->SetTicks();
    618702    fHChargevsNLoGain->Draw(opt);
     
    656740
    657741
    658 Bool_t MHCalibrationPixel::FitTimeHiGain(Axis_t rmin, Axis_t rmax, Option_t *option)
    659 {
    660 
    661   if (fTimeGausFit)
     742Bool_t MHCalibrationPixel::FitTime(Option_t *option)
     743{
     744
     745  if (fRelTimeGausFit)
    662746    return kFALSE;
    663747
    664   rmin = (rmin != 0.) ? rmin : (Axis_t)fTimeLowerFitRangeHiGain;
    665   rmax = (rmax != 0.) ? rmax : (Axis_t)fTimeUpperFitRangeHiGain;
    666 
    667   const Stat_t entries       = fHTimeHiGain->Integral();
    668   const Double_t mu_guess    = fHTimeHiGain->GetBinCenter(fHTimeHiGain->GetMaximumBin());
     748  //
     749  // Get the fitting ranges
     750  //
     751  Axis_t rmin = fRelTimeLowerFitRangeHiGain;
     752  if (TESTBIT(fFlags,kUseLoGain))
     753    rmin = fRelTimeLowerFitRangeLoGain;
     754
     755  Axis_t rmax = fRelTimeUpperFitRangeHiGain;
     756  if (TESTBIT(fFlags,kUseLoGain))
     757    rmin = fRelTimeUpperFitRangeLoGain;
     758
     759  TH1F *hist = fHRelTimeHiGain;
     760  if (TESTBIT(fFlags,kUseLoGain))
     761    hist = fHRelTimeLoGain;
     762
     763  const Stat_t   entries     = hist->Integral("width");
     764  const Double_t mu_guess    = hist->GetBinCenter(hist->GetMaximumBin());
    669765  const Double_t sigma_guess = (rmax - rmin)/2.;
    670   const Double_t area_guess  = entries/gkSq2Pi;
    671 
    672   TString name = TString("GausTime");
     766  const Double_t area_guess  = 2.*entries/gkSq2Pi/sigma_guess;
     767
     768  TString name = TString("GausRelTime");
    673769  name += fPixId;
    674   fTimeGausFit = new TF1(name.Data(),"gaus",rmin,rmax); 
    675 
    676   if (!fTimeGausFit)
    677     {
    678     *fLog << warn << dbginf << "WARNING: Could not create fit function for Time fit" << endl;
     770  fRelTimeGausFit = new TF1(name.Data(),"gaus",rmin,rmax); 
     771
     772  if (!fRelTimeGausFit)
     773    {
     774    *fLog << warn << dbginf << "WARNING: Could not create fit function for RelTime fit" << endl;
    679775    return kFALSE;
    680776    }
    681777
    682   fTimeGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
    683   fTimeGausFit->SetParNames("Area","#mu","#sigma");
    684   fTimeGausFit->SetParLimits(0,0.,entries);
    685   fTimeGausFit->SetParLimits(1,rmin,rmax);
    686   fTimeGausFit->SetParLimits(2,0.,(rmax-rmin));
    687   fTimeGausFit->SetRange(rmin,rmax);
    688 
    689   fHTimeHiGain->Fit(fTimeGausFit,option);
    690 
    691   rmin = fTimeGausFit->GetParameter(1) - 3.*fTimeGausFit->GetParameter(2);
    692   rmax = fTimeGausFit->GetParameter(1) + 3.*fTimeGausFit->GetParameter(2);
    693   fTimeGausFit->SetRange(rmin,rmax); 
    694 
    695   fHTimeHiGain->Fit(fTimeGausFit,option);
    696 
    697   fTimeChisquare = fTimeGausFit->GetChisquare();
    698   fTimeNdf       = fTimeGausFit->GetNDF();
    699   fTimeProb      = fTimeGausFit->GetProb();
    700 
    701   fTimeMean      = fTimeGausFit->GetParameter(1);
    702   fTimeSigma     = fTimeGausFit->GetParameter(2);
    703 
    704   if (TMath::IsNaN(fTimeMean) || TMath::IsNaN(fTimeSigma))
    705     return kFALSE;
    706 
    707   if (TMath::IsNaN(fTimeChisquare) || fTimeChisquare > 20.)  // Cannot use Probability because Ndf is sometimes < 1
    708     return kFALSE;
     778  fRelTimeGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
     779  fRelTimeGausFit->SetParNames("Area","#mu","#sigma");
     780  fRelTimeGausFit->SetParLimits(0,0.,5.*area_guess);
     781  fRelTimeGausFit->SetParLimits(1,rmin,rmax);
     782  fRelTimeGausFit->SetParLimits(2,0.,(rmax-rmin));
     783  fRelTimeGausFit->SetRange(rmin,rmax);
     784
     785  hist->Fit(fRelTimeGausFit,option);
     786
     787  //
     788  // If the fit does not converge, try another one with smaller bounderies
     789  //
     790  if (fRelTimeGausFit->GetProb() < 0.001)
     791    {
     792      rmin = fRelTimeGausFit->GetParameter(1) - 2.*fRelTimeGausFit->GetParameter(2);
     793      rmax = fRelTimeGausFit->GetParameter(1) + 2.*fRelTimeGausFit->GetParameter(2);
     794      fRelTimeGausFit->SetRange(rmin,rmax); 
     795      hist->Fit(fRelTimeGausFit,option);
     796    }
     797 
     798  fRelTimeChisquare = fRelTimeGausFit->GetChisquare();
     799  fRelTimeNdf       = fRelTimeGausFit->GetNDF();
     800  fRelTimeProb      = fRelTimeGausFit->GetProb();
     801
     802  fRelTimeMean      = fRelTimeGausFit->GetParameter(1);
     803  fRelTimeSigma     = fRelTimeGausFit->GetParameter(2);
     804
     805  fRelTimeMeanErr   = fRelTimeGausFit->GetParError(1);
     806
     807  if (TMath::IsNaN(fRelTimeMean) || TMath::IsNaN(fRelTimeSigma))
     808    {
     809      CLRBIT(fFlags,kTimeFitOK);
     810      return kFALSE;
     811    }
     812 
     813  if (TMath::IsNaN(fRelTimeChisquare) || (fRelTimeProb < gkProbLimit))
     814    {
     815      CLRBIT(fFlags,kTimeFitOK);
     816      return kFALSE;
     817    }
     818 
     819  SETBIT(fFlags,kTimeFitOK);
    709820
    710821  return kTRUE;
     
    712823}
    713824
    714 Bool_t MHCalibrationPixel::FitTimeLoGain(Axis_t rmin, Axis_t rmax, Option_t *option)
    715 {
    716 
    717   if (fTimeGausFit)
    718     return kFALSE;
    719 
    720   rmin = (rmin != 0.) ? rmin : (Axis_t)fTimeLowerFitRangeLoGain;
    721   rmax = (rmax != 0.) ? rmax : (Axis_t)fTimeUpperFitRangeLoGain;
    722 
    723   const Stat_t   entries     = fHTimeLoGain->Integral();
    724   const Double_t mu_guess    = fHTimeLoGain->GetBinCenter(fHTimeLoGain->GetMaximumBin());
    725   const Double_t sigma_guess = (rmax - rmin)/2.;
    726   const Double_t area_guess  = entries/gkSq2Pi;
    727 
    728   TString name = TString("GausTime");
    729   name += fPixId;
    730   fTimeGausFit = new TF1(name.Data(),"gaus",rmin,rmax); 
    731 
    732   if (!fTimeGausFit)
    733     {
    734     *fLog << warn << dbginf << "WARNING: Could not create fit function for Time fit" << endl;
    735     return kFALSE;
    736     }
    737 
    738   fTimeGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
    739   fTimeGausFit->SetParNames("Area","#mu","#sigma");
    740   fTimeGausFit->SetParLimits(0,0.,entries);
    741   fTimeGausFit->SetParLimits(1,rmin,rmax);
    742   fTimeGausFit->SetParLimits(2,0.,(rmax-rmin));
    743   fTimeGausFit->SetRange(rmin,rmax);
    744 
    745   fHTimeLoGain->Fit(fTimeGausFit,option);
    746 
    747   rmin = fTimeGausFit->GetParameter(1) - 3.*fTimeGausFit->GetParameter(2);
    748   rmax = fTimeGausFit->GetParameter(1) + 3.*fTimeGausFit->GetParameter(2);
    749   fTimeGausFit->SetRange(rmin,rmax); 
    750 
    751   fHTimeLoGain->Fit(fTimeGausFit,option);
    752 
    753   fTimeChisquare = fTimeGausFit->GetChisquare();
    754   fTimeNdf       = fTimeGausFit->GetNDF();
    755   fTimeProb      = fTimeGausFit->GetProb();
    756 
    757   fTimeMean      = fTimeGausFit->GetParameter(1);
    758   fTimeSigma     = fTimeGausFit->GetParameter(2);
    759 
    760   if (fTimeChisquare > 20.)  // Cannot use Probability because Ndf is sometimes < 1
    761     {
    762       *fLog << warn << "WARNING: Fit of the Arrival times failed ! " << endl;
    763       return kFALSE;
    764     }
    765  
    766   return kTRUE;
    767 
    768 }
    769825
    770826Bool_t MHCalibrationPixel::FitCharge(Option_t *option)
     
    783839  Axis_t rmax = fChargeLastHiGain;
    784840  if (TESTBIT(fFlags,kUseLoGain))
    785     rmin = fChargeFirstLoGain;
     841    rmax = fChargeLastLoGain;
    786842
    787843  TH1F *hist = fHChargeHiGain;
     
    847903  if (TMath::IsNaN(fChargeMean) || TMath::IsNaN(fChargeMeanErr))
    848904    {
    849       CLRBIT(fFlags,kFitOK);
     905      CLRBIT(fFlags,kChargeFitOK);
    850906      return kFALSE;
    851907    }
     
    853909  if ((fChargeProb < gkProbLimit) || (TMath::IsNaN(fChargeProb)))
    854910    {
    855       CLRBIT(fFlags,kFitOK);
     911      CLRBIT(fFlags,kChargeFitOK);
    856912      return kFALSE;
    857913    }
    858914 
    859   SETBIT(fFlags,kFitOK);
     915  SETBIT(fFlags,kChargeFitOK);
    860916  return kTRUE;
    861917}
     
    880936  fChargeLastLoGain  = fHChargeLoGain->GetBinLowEdge(fHChargeLoGain->GetXaxis()->GetLast())
    881937                      +fHChargeLoGain->GetBinWidth(0);
     938
     939  CutEdges(fHRelTimeHiGain,nbins);
     940
     941  fRelTimeLowerFitRangeHiGain = fHRelTimeHiGain->GetBinLowEdge(fHRelTimeHiGain->GetXaxis()->GetFirst());
     942  fRelTimeUpperFitRangeHiGain = fHRelTimeHiGain->GetBinLowEdge(fHRelTimeHiGain->GetXaxis()->GetLast())
     943                               +fHRelTimeHiGain->GetBinWidth(0);
     944
     945  CutEdges(fHRelTimeLoGain,nbins);
     946
     947  fRelTimeLowerFitRangeLoGain = fHRelTimeLoGain->GetBinLowEdge(fHRelTimeLoGain->GetXaxis()->GetFirst());
     948  fRelTimeUpperFitRangeLoGain = fHRelTimeLoGain->GetBinLowEdge(fHRelTimeLoGain->GetXaxis()->GetLast())
     949                               +fHRelTimeLoGain->GetBinWidth(0);
     950
     951  CutEdges(fHAbsTimeHiGain,nbins);
     952
     953  fAbsTimeFirstHiGain = fHAbsTimeHiGain->GetBinLowEdge(fHAbsTimeHiGain->GetXaxis()->GetFirst());
     954  fAbsTimeLastHiGain  = fHAbsTimeHiGain->GetBinLowEdge(fHAbsTimeHiGain->GetXaxis()->GetLast())
     955                       +fHAbsTimeHiGain->GetBinWidth(0);
     956
     957  CutEdges(fHAbsTimeLoGain,nbins);
     958
     959  fAbsTimeFirstLoGain = fHAbsTimeLoGain->GetBinLowEdge(fHAbsTimeLoGain->GetXaxis()->GetFirst());
     960  fAbsTimeLastLoGain  = fHAbsTimeLoGain->GetBinLowEdge(fHAbsTimeLoGain->GetXaxis()->GetLast())
     961                       +fHAbsTimeLoGain->GetBinWidth(0);
    882962
    883963  CutEdges(fHChargevsNHiGain,0);
     
    901981
    902982  *fLog << all << "Results of the Time Slices Fit: "                        << endl;
    903   *fLog << all << "Chisquare: "   << fTimeChisquare                         << endl;
    904   *fLog << all << "Ndf: "         << fTimeNdf                               << endl;
    905   *fLog << all << "Probability: " << fTimeProb                              << endl;
     983  *fLog << all << "Chisquare: "   << fRelTimeChisquare                      << endl;
     984  *fLog << all << "Ndf: "         << fRelTimeNdf                            << endl;
     985  *fLog << all << "Probability: " << fRelTimeProb                           << endl;
    906986  *fLog << all                                                              << endl;
    907987
Note: See TracChangeset for help on using the changeset viewer.