Ignore:
Timestamp:
12/05/03 01:08:44 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.cc

    r2599 r2603  
    6969
    7070    // Create a large number of bins, later we will rebin
    71     fBlindPixelQfirst = 0;
    72     fBlindPixelQlast  = gkStartBlindPixelBinNr;
    73     fBlindPixelQnbins = gkStartBlindPixelBinNr;
    74 
    75     fHBlindPixelQ = new TH1I("HBlindPixelQ","Distribution of Summed FADC Slices",fBlindPixelQnbins,fBlindPixelQfirst,fBlindPixelQlast);
    76     fHBlindPixelQ->SetXTitle("Sum FADC Slices");
    77     fHBlindPixelQ->SetYTitle("Nr. of events");
    78     fHBlindPixelQ->Sumw2();
    79 
    80     fErrBlindPixelQfirst = 0.;
    81     fErrBlindPixelQlast  = gkStartBlindPixelBinNr;
    82     fErrBlindPixelQnbins = gkStartBlindPixelBinNr;
    83 
    84     fHBlindPixelErrQ = new TH1F("HBlindPixelErrQ","Distribution of Variances of Summed FADC Slices",
    85                         fErrBlindPixelQnbins,fErrBlindPixelQfirst,fErrBlindPixelQlast);
    86     fHBlindPixelErrQ->SetXTitle("Variance Summed FADC Slices");
    87     fHBlindPixelErrQ->SetYTitle("Nr. of events");
    88     fHBlindPixelErrQ->Sumw2();
     71    fBlindPixelChargefirst = 0;
     72    fBlindPixelChargelast  = gkStartBlindPixelBinNr;
     73    fBlindPixelChargenbins = gkStartBlindPixelBinNr;
     74
     75    fHBlindPixelCharge = new TH1I("HBlindPixelCharge","Distribution of Summed FADC Slices",fBlindPixelChargenbins,fBlindPixelChargefirst,fBlindPixelChargelast);
     76    fHBlindPixelCharge->SetXTitle("Sum FADC Slices");
     77    fHBlindPixelCharge->SetYTitle("Nr. of events");
     78    fHBlindPixelCharge->Sumw2();
     79
     80    fErrBlindPixelChargefirst = 0.;
     81    fErrBlindPixelChargelast  = gkStartBlindPixelBinNr;
     82    fErrBlindPixelChargenbins = gkStartBlindPixelBinNr;
     83
     84    fHBlindPixelErrCharge = new TH1F("HBlindPixelErrCharge","Distribution of Variances of Summed FADC Slices",
     85                        fErrBlindPixelChargenbins,fErrBlindPixelChargefirst,fErrBlindPixelChargelast);
     86    fHBlindPixelErrCharge->SetXTitle("Variance Summed FADC Slices");
     87    fHBlindPixelErrCharge->SetYTitle("Nr. of events");
     88    fHBlindPixelErrCharge->Sumw2();
    8989
    9090    Axis_t tfirst = -0.5;
     
    9292    Int_t nbins   = 16;
    9393
    94     fHBlindPixelT = new TH1I("HBlindPixelT","Distribution of Mean Arrival Times",nbins,tfirst,tlast);
    95     fHBlindPixelT->SetXTitle("Mean Arrival Times [FADC slice nr]");
    96     fHBlindPixelT->SetYTitle("Nr. of events");
    97     fHBlindPixelT->Sumw2();
     94    fHBlindPixelTime = new TH1I("HBlindPixelTime","Distribution of Mean Arrival Times",nbins,tfirst,tlast);
     95    fHBlindPixelTime->SetXTitle("Mean Arrival Times [FADC slice nr]");
     96    fHBlindPixelTime->SetYTitle("Nr. of events");
     97    fHBlindPixelTime->Sumw2();
    9898
    9999    // We define a reasonable number and later enlarge it if necessary
     
    102102    Axis_t nlast  = (Axis_t)nbins - 0.5;
    103103
    104     fHBlindPixelQvsN = new TH1I("HBlindPixelQvsN","Sum of Charges vs. Event Number",nbins,nfirst,nlast);
    105     fHBlindPixelQvsN->SetXTitle("Event Nr.");
    106     fHBlindPixelQvsN->SetYTitle("Sum of FADC slices");
     104    fHBlindPixelChargevsN = new TH1I("HBlindPixelChargevsN","Sum of Charges vs. Event Number",nbins,nfirst,nlast);
     105    fHBlindPixelChargevsN->SetXTitle("Event Nr.");
     106    fHBlindPixelChargevsN->SetYTitle("Sum of FADC slices");
    107107
    108108    fgSinglePheFitFunc = &gfKto8;
     
    113113{
    114114
    115   delete fHBlindPixelQ;
    116   delete fHBlindPixelT;
    117   delete fHBlindPixelErrQ;
     115  delete fHBlindPixelCharge;
     116  delete fHBlindPixelTime;
     117  delete fHBlindPixelErrCharge;
    118118 
    119119  if (fSinglePheFit)
     
    127127void MHCalibrationBlindPixel::ResetBin(Int_t i)
    128128{
    129     fHBlindPixelQ->SetBinContent (i, 1.e-20);
    130     fHBlindPixelErrQ->SetBinContent  (i, 1.e-20);
    131     fHBlindPixelT->SetBinContent(i, 1.e-20);
     129    fHBlindPixelCharge->SetBinContent (i, 1.e-20);
     130    fHBlindPixelErrCharge->SetBinContent  (i, 1.e-20);
     131    fHBlindPixelTime->SetBinContent(i, 1.e-20);
    132132}
    133133
     
    150150  fFitLegend->SetTextSize(0.05);
    151151
    152   char line1[32];
    153   sprintf(line1,"Mean: #lambda = %2.2f #pm %2.2f",GetLambda(),GetLambdaErr());
     152  const TString line1 =
     153  Form("Mean: #lambda = %2.2f #pm %2.2f",GetLambda(),GetLambdaErr());
    154154  fFitLegend->AddText(line1);
    155155
    156   char line2[32];
    157   sprintf(line2,"Pedestal: #mu_{0} = %2.2f #pm %2.2f",GetMu0(),GetMu0Err());
     156  const TString line2 =
     157  Form("Pedestal: #mu_{0} = %2.2f #pm %2.2f",GetMu0(),GetMu0Err());
    158158  fFitLegend->AddText(line2);
    159159
    160   char line3[32];
    161   sprintf(line3,"Width Pedestal: #sigma_{0} = %2.2f #pm %2.2f",GetSigma0(),GetSigma0Err());
     160  const TString line3 =
     161  Form("Width Pedestal: #sigma_{0} = %2.2f #pm %2.2f",GetSigma0(),GetSigma0Err());
    162162  fFitLegend->AddText(line3);
    163163
    164   char line4[32];
    165   sprintf(line4,"1^{st} Phe-peak: #mu_{1} = %2.2f #pm %2.2f",GetMu1(),GetMu1Err());
     164  const TString line4 =
     165  Form("1^{st} Phe-peak: #mu_{1} = %2.2f #pm %2.2f",GetMu1(),GetMu1Err());
    166166  fFitLegend->AddText(line4);
    167167
    168   char line5[32];
    169   sprintf(line5,"Width 1^{st} Phe-peak: #sigma_{1} = %2.2f #pm %2.2f",GetSigma1(),GetSigma1Err());
     168  const TString line5 =
     169  Form("Width 1^{st} Phe-peak: #sigma_{1} = %2.2f #pm %2.2f",GetSigma1(),GetSigma1Err());
    170170  fFitLegend->AddText(line5);
    171171
    172   char line7[32];
    173   sprintf(line7,"#chi^{2} / N_{dof}: %4.2f / %3i",GetChiSquare(),GetNdf());
     172  const TString line7 =
     173  Form("#chi^{2} / N_{dof}: %4.2f / %3i",GetChiSquare(),GetNdf());
    174174  fFitLegend->AddText(line7);
    175175
    176   char line8[32];
    177   sprintf(line8,"Probability: %4.2f ",GetProb());
     176  const TString line8 =
     177  Form("Probability: %4.2f ",GetProb());
    178178  fFitLegend->AddText(line8);
    179179
     
    209209    gPad->SetTicks();
    210210
    211     fHBlindPixelQ->DrawCopy(opt);
     211    fHBlindPixelCharge->DrawCopy(opt);
    212212   
    213213    if (fSinglePheFit)
     
    231231    gPad->SetLogy(1);
    232232    gPad->SetBorderMode(0);
    233     fHBlindPixelT->DrawCopy(opt);
    234 
    235     if (fHBlindPixelT->GetFunction("GausTime"))
     233    fHBlindPixelTime->DrawCopy(opt);
     234
     235    if (fHBlindPixelTime->GetFunction("GausTime"))
    236236      {
    237         TF1 *tfit = fHBlindPixelT->GetFunction("GausTime");
     237        TF1 *tfit = fHBlindPixelTime->GetFunction("GausTime");
    238238        if (tfit->GetProb() < 0.01)
    239239          tfit->SetLineColor(kRed);
     
    248248    c->cd(4);
    249249
    250     fHBlindPixelQvsN->DrawCopy(opt);
     250    fHBlindPixelChargevsN->DrawCopy(opt);
    251251
    252252    c->Modified();
     
    260260  gRandom->SetSeed();
    261261
    262   if (fHBlindPixelQ->GetEntries() != 0)
     262  if (fHBlindPixelCharge->GetEntries() != 0)
    263263    {
    264       *fLog << err << "Histogram " << fHBlindPixelQ->GetTitle() << " is already filled. " << endl;
     264      *fLog << err << "Histogram " << fHBlindPixelCharge->GetTitle() << " is already filled. " << endl;
    265265      *fLog << err << "Create new class MHCalibrationBlindPixel for simulation! " << endl;
    266266      return kFALSE;
     
    268268 
    269269  TF1 *simulateSinglePhe = new TF1("simulateSinglePhe",fgSinglePheFitFunc,
    270                                    fBlindPixelQfirst,fBlindPixelQlast,fgSinglePheFitNPar);
     270                                   fBlindPixelChargefirst,fBlindPixelChargelast,fgSinglePheFitNPar);
    271271 
    272272  simulateSinglePhe->SetParameters(lambda,mu0,mu1,sigma0,sigma1);
    273273  simulateSinglePhe->SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1");
    274   simulateSinglePhe->SetNpx(fBlindPixelQnbins); 
     274  simulateSinglePhe->SetNpx(fBlindPixelChargenbins); 
    275275
    276276  for (Int_t i=0;i<10000; i++)
    277277    {
    278       fHBlindPixelQ->Fill(simulateSinglePhe->GetRandom());
     278      fHBlindPixelCharge->Fill(simulateSinglePhe->GetRandom());
    279279    }
    280280 
     
    303303  // Get the fitting ranges
    304304  //
    305   rmin = (rmin != 0.) ? rmin : fBlindPixelQfirst;
    306   rmax = (rmax != 0.) ? rmax : fBlindPixelQlast;
     305  rmin = (rmin != 0.) ? rmin : fBlindPixelChargefirst;
     306  rmax = (rmax != 0.) ? rmax : fBlindPixelChargelast;
    307307
    308308  //
     
    310310  // otherwise the fit goes gaga because of high number of dimensions ...
    311311  //
    312   const Stat_t   entries      = fHBlindPixelQ->GetSumOfWeights();
     312  const Stat_t   entries      = fHBlindPixelCharge->GetSumOfWeights();
    313313  const Double_t lambda_guess = 0.2;
    314   const Double_t mu_0_guess = fHBlindPixelQ->GetBinCenter(fHBlindPixelQ->GetMaximumBin());
     314  const Double_t mu_0_guess = fHBlindPixelCharge->GetBinCenter(fHBlindPixelCharge->GetMaximumBin());
    315315  const Double_t si_0_guess = mu_0_guess/10.;
    316316  const Double_t mu_1_guess = mu_0_guess + 50.;
     
    333333  // ROOT gives us another nice example of user-unfriendly behavior:
    334334  // Although the normalization of the function fSinglePhe and the
    335   // Histogram fHBlindPixelQ agree (!!), the fit does not normalize correctly INTERNALLY
     335  // Histogram fHBlindPixelCharge agree (!!), the fit does not normalize correctly INTERNALLY
    336336  // in the fitting procedure !!!
    337337  //
     
    343343  //
    344344  //  const Int_t  npx     = fSinglePheFit->GetNpx();
    345   //  const Int_t  bins    = fHBlindPixelQ->GetXaxis()->GetLast()-fHBlindPixelQ->GetXaxis()->GetFirst();
    346   //  fHBlindPixelQ->Scale(gkSq2Pi*(float)bins/npx/entries);
     345  //  const Int_t  bins    = fHBlindPixelCharge->GetXaxis()->GetLast()-fHBlindPixelCharge->GetXaxis()->GetFirst();
     346  //  fHBlindPixelCharge->Scale(gkSq2Pi*(float)bins/npx/entries);
    347347
    348348  //
     
    351351  // mysteries of ROOT which takes you a whole day to find out :-)
    352352  //
    353   //  fSinglePheFit->SetNpx(fQnbins); 
    354 
    355   fHBlindPixelQ->Fit(fSinglePheFit,opt);
     353  //  fSinglePheFit->SetNpx(fChargenbins); 
     354
     355  fHBlindPixelCharge->Fit(fSinglePheFit,opt);
    356356
    357357  fLambda = fSinglePheFit->GetParameter(0);
     
    405405  Int_t nbins = 50;
    406406
    407   *fLog << "New number of bins in HSinQ: " << CutEdges(fHBlindPixelQ,nbins) << endl;
    408 
    409   fBlindPixelQfirst = fHBlindPixelQ->GetBinLowEdge(fHBlindPixelQ->GetXaxis()->GetFirst());
    410   fBlindPixelQlast  = fHBlindPixelQ->GetBinLowEdge(fHBlindPixelQ->GetXaxis()->GetLast())+fHBlindPixelQ->GetBinWidth(0);
    411   fBlindPixelQnbins = nbins;
    412 
    413   *fLog << "New number of bins in HErrQ: " << CutEdges(fHBlindPixelErrQ,30) << endl;
    414   fErrBlindPixelQfirst = fHBlindPixelErrQ->GetBinLowEdge(fHBlindPixelErrQ->GetXaxis()->GetFirst());
    415   fErrBlindPixelQlast  = fHBlindPixelErrQ->GetBinLowEdge(fHBlindPixelErrQ->GetXaxis()->GetLast())+fHBlindPixelErrQ->GetBinWidth(0);
    416   fErrBlindPixelQnbins = nbins;
    417 
    418   CutEdges(fHBlindPixelQvsN,0);
    419 
    420 }
    421 
    422 Bool_t MHCalibrationBlindPixel::FitT(Axis_t rmin, Axis_t rmax, Option_t *opt)
     407  *fLog << "New number of bins in HSinCharge: " << CutEdges(fHBlindPixelCharge,nbins) << endl;
     408
     409  fBlindPixelChargefirst = fHBlindPixelCharge->GetBinLowEdge(fHBlindPixelCharge->GetXaxis()->GetFirst());
     410  fBlindPixelChargelast  = fHBlindPixelCharge->GetBinLowEdge(fHBlindPixelCharge->GetXaxis()->GetLast())+fHBlindPixelCharge->GetBinWidth(0);
     411  fBlindPixelChargenbins = nbins;
     412
     413  *fLog << "New number of bins in HErrCharge: " << CutEdges(fHBlindPixelErrCharge,30) << endl;
     414  fErrBlindPixelChargefirst = fHBlindPixelErrCharge->GetBinLowEdge(fHBlindPixelErrCharge->GetXaxis()->GetFirst());
     415  fErrBlindPixelChargelast  = fHBlindPixelErrCharge->GetBinLowEdge(fHBlindPixelErrCharge->GetXaxis()->GetLast())+fHBlindPixelErrCharge->GetBinWidth(0);
     416  fErrBlindPixelChargenbins = nbins;
     417
     418  CutEdges(fHBlindPixelChargevsN,0);
     419
     420}
     421
     422Bool_t MHCalibrationBlindPixel::FitTime(Axis_t rmin, Axis_t rmax, Option_t *opt)
    423423{
    424424 
     
    429429  rmax = (rmax != 0.) ? rmax : 9.;
    430430
    431   const Stat_t   entries     = fHBlindPixelT->GetEntries();
    432   const Double_t mu_guess    = fHBlindPixelT->GetBinCenter(fHBlindPixelT->GetMaximumBin());
     431  const Stat_t   entries     = fHBlindPixelTime->GetEntries();
     432  const Double_t mu_guess    = fHBlindPixelTime->GetBinCenter(fHBlindPixelTime->GetMaximumBin());
    433433  const Double_t sigma_guess = (rmax - rmin)/2.;
    434434  const Double_t area_guess  = entries/gkSq2Pi;
     
    441441  fTimeGausFit->SetParLimits(2,0.,rmax-rmin);
    442442
    443   fHBlindPixelT->Fit(fTimeGausFit,opt);
     443  fHBlindPixelTime->Fit(fTimeGausFit,opt);
    444444
    445445  rmin = fTimeGausFit->GetParameter(1) - 2.*fTimeGausFit->GetParameter(2);
     
    447447  fTimeGausFit->SetRange(rmin,rmax); 
    448448
    449   fHBlindPixelT->Fit(fTimeGausFit,opt);
    450 
    451 
    452   fMeanT     = fTimeGausFit->GetParameter(2);
    453   fSigmaT    = fTimeGausFit->GetParameter(3);
    454   fMeanTErr  = fTimeGausFit->GetParError(2);
    455   fSigmaTErr = fTimeGausFit->GetParError(3);
     449  fHBlindPixelTime->Fit(fTimeGausFit,opt);
     450
     451
     452  fMeanTime     = fTimeGausFit->GetParameter(2);
     453  fSigmaTime    = fTimeGausFit->GetParameter(3);
     454  fMeanTimeErr  = fTimeGausFit->GetParError(2);
     455  fSigmaTimeErr = fTimeGausFit->GetParError(3);
    456456
    457457  Float_t prob = fTimeGausFit->GetProb();
  • trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.h

    r2599 r2603  
    3232private:
    3333
    34   TH1I* fHBlindPixelQ;        //-> Histogram with the single Phe spectrum
    35   TH1F* fHBlindPixelErrQ;     //-> Variance of summed FADC slices
    36   TH1I* fHBlindPixelT;        //-> Variance of summed FADC slices
    37   TH1I* fHBlindPixelQvsN;     //-> Summed Charge vs. Event Nr.
     34  TH1I* fHBlindPixelCharge;        //-> Histogram with the single Phe spectrum
     35  TH1F* fHBlindPixelErrCharge;     //-> Variance of summed FADC slices
     36  TH1I* fHBlindPixelTime;        //-> Variance of summed FADC slices
     37  TH1I* fHBlindPixelChargevsN;     //-> Summed Charge vs. Event Nr.
    3838 
    3939  TF1 *fSinglePheFit;
    4040  TF1 *fTimeGausFit; 
    4141
    42   Axis_t  fBlindPixelQfirst;
    43   Axis_t  fBlindPixelQlast;
    44   Int_t   fBlindPixelQnbins;
     42  Axis_t  fBlindPixelChargefirst;
     43  Axis_t  fBlindPixelChargelast;
     44  Int_t   fBlindPixelChargenbins;
    4545 
    46   Axis_t fErrBlindPixelQfirst;
    47   Axis_t fErrBlindPixelQlast;
    48   Int_t  fErrBlindPixelQnbins;
     46  Axis_t fErrBlindPixelChargefirst;
     47  Axis_t fErrBlindPixelChargelast;
     48  Int_t  fErrBlindPixelChargenbins;
    4949
    5050  void ResetBin(Int_t i);
     
    7373  Int_t     fNdf;       
    7474
    75   Double_t  fMeanT;
    76   Double_t  fMeanTErr;
    77   Double_t  fSigmaT;
    78   Double_t  fSigmaTErr;
     75  Double_t  fMeanTime;
     76  Double_t  fMeanTimeErr;
     77  Double_t  fSigmaTime;
     78  Double_t  fSigmaTimeErr;
    7979 
    8080public:
     
    8383  ~MHCalibrationBlindPixel();
    8484
    85   Bool_t FillBlindPixelQ(Int_t q)         { return fHBlindPixelQ->Fill(q) > -1;  } 
    86   Bool_t FillErrBlindPixelQ(Float_t errq) { return fHBlindPixelErrQ->Fill(errq) > -1; }
    87   Bool_t FillBlindPixelT(Int_t t)         { return fHBlindPixelT->Fill(t) > -1;  }
    88   Bool_t FillBlindPixelQvsN(Stat_t rq, Int_t t) { return fHBlindPixelQvsN->Fill(t,rq) > -1;  } 
     85  Bool_t FillBlindPixelCharge(Int_t q)         { return fHBlindPixelCharge->Fill(q) > -1;  } 
     86  Bool_t FillErrBlindPixelCharge(Float_t errq) { return fHBlindPixelErrCharge->Fill(errq) > -1; }
     87  Bool_t FillBlindPixelTime(Int_t t)         { return fHBlindPixelTime->Fill(t) > -1;  }
     88  Bool_t FillBlindPixelChargevsN(Stat_t rq, Int_t t) { return fHBlindPixelChargevsN->Fill(t,rq) > -1;  } 
    8989 
    9090  const Double_t GetLambda()   const { return fLambda; }
     
    104104  const Int_t    GetNdf()     const { return fNdf;       }   
    105105
    106   const Double_t GetMeanT()      const { return fMeanT; }
    107   const Double_t GetMeanTErr()    const { return fMeanTErr; }
    108   const Double_t GetSigmaT()      const { return fSigmaT; }
    109   const Double_t GetSigmaTErr()    const { return fSigmaTErr; }
     106  const Double_t GetMeanTime()      const { return fMeanTime; }
     107  const Double_t GetMeanTimeErr()    const { return fMeanTimeErr; }
     108  const Double_t GetSigmaTime()      const { return fSigmaTime; }
     109  const Double_t GetSigmaTimeErr()    const { return fSigmaTimeErr; }
    110110
    111   const TH1F *GetHErrQ() { return fHBlindPixelErrQ; }
    112   const TH1F *GetHErrQ() const { return fHBlindPixelErrQ; }
     111  const TH1F *GetHErrCharge() { return fHBlindPixelErrCharge; }
     112  const TH1F *GetHErrCharge() const { return fHBlindPixelErrCharge; }
    113113 
    114114  Bool_t SimulateSinglePhe(Double_t lambda,
     
    119119 
    120120  Bool_t FitSinglePhe(Axis_t rmin=0, Axis_t rmax=0, Option_t *opt="R0+");
    121   Bool_t FitT(Axis_t rmin=0., Axis_t rmax=0.,Option_t *opt="R0+");
     121  Bool_t FitTime(Axis_t rmin=0., Axis_t rmax=0.,Option_t *opt="R0+");
    122122
    123123  void ChangeFitFunc(BlindPixelFitFunc fitfunc, Int_t par=5);
  • trunk/MagicSoft/Mars/mhist/MHCalibrationConfig.h

    r2599 r2603  
    2020const Int_t gkStartPINDiodeBinNr = 4000;
    2121
    22 // Starting number of bins for the histo: (maximum possible by hardware = 40800)
    23 const Int_t gkStartPixelBinNr = 20000;
    24 
    25 // Starting number for the highest value of the Q-histo:
    26 const Axis_t gkStartQlast      = 10000.;
    27 
    2822// Square root of 2 pi:
    2923const Float_t gkSq2Pi = 2.506628274631;
  • trunk/MagicSoft/Mars/mhist/MHCalibrationPINDiode.cc

    r2525 r2603  
    6767
    6868    // Create a large number of bins, later we will rebin
    69     fQfirst = 0;
    70     fQlast  = gkStartPINDiodeBinNr;
    71     fQnbins = gkStartPINDiodeBinNr;
     69    fChargeFirst = 0;
     70    fChargeLast  = gkStartPINDiodeBinNr;
     71    fChargeNbins = gkStartPINDiodeBinNr;
    7272
    73     fHPQ = new TH1I("HPQ","Distribution of Summed FADC Slices",fQnbins,fQfirst,fQlast);
    74     fHPQ->SetXTitle("Sum FADC Slices");
    75     fHPQ->SetYTitle("Nr. of events");
    76     fHPQ->Sumw2();
     73    fHPCharge = new TH1I("HPCharge","Distribution of Summed FADC Slices",fChargeNbins,fChargeFirst,fChargeLast);
     74    fHPCharge->SetXTitle("Sum FADC Slices");
     75    fHPCharge->SetYTitle("Nr. of events");
     76    fHPCharge->Sumw2();
    7777
    78     fErrQfirst = 0.;
    79     fErrQlast  = gkStartPINDiodeBinNr;
    80     fErrQnbins = gkStartPINDiodeBinNr;
     78    fErrChargeFirst = 0.;
     79    fErrChargeLast  = gkStartPINDiodeBinNr;
     80    fErrChargeNbins = gkStartPINDiodeBinNr;
    8181
    82     fHErrQ = new TH1F("HErrQ","Distribution of Variances of Summed FADC Slices",fErrQnbins,fErrQfirst,fErrQlast);
    83     fHErrQ->SetXTitle("Variance Summed FADC Slices");
    84     fHErrQ->SetYTitle("Nr. of events");
    85     fHErrQ->Sumw2();
     82    fHErrCharge = new TH1F("HErrCharge","Distribution of Variances of Summed FADC Slices",fErrChargeNbins,fErrChargeFirst,fErrChargeLast);
     83    fHErrCharge->SetXTitle("Variance Summed FADC Slices");
     84    fHErrCharge->SetYTitle("Nr. of events");
     85    fHErrCharge->Sumw2();
    8686
    8787    Int_t tfirst = 0;
     
    8989    Int_t nbins   = 32;
    9090
    91     fHPT = new TH1I("HPT","Distribution of Mean Arrival Times",nbins,tfirst,tlast);
    92     fHPT->SetXTitle("Mean Arrival Times [FADC slice nr]");
    93     fHPT->SetYTitle("Nr. of events");
    94     fHPT->Sumw2();
     91    fHPTime = new TH1I("HPTime","Distribution of Mean Arrival Times",nbins,tfirst,tlast);
     92    fHPTime->SetXTitle("Mean Arrival Times [FADC slice nr]");
     93    fHPTime->SetYTitle("Nr. of events");
     94    fHPTime->Sumw2();
    9595
    9696}
     
    9999{
    100100
    101   delete fHPQ;
    102   delete fHErrQ;
     101  delete fHPCharge;
     102  delete fHErrCharge;
    103103 
    104104  if (fVarGausFit)
    105105    delete fVarGausFit;
    106106 
    107   delete fHPT;
     107  delete fHPTime;
    108108
    109109}
  • trunk/MagicSoft/Mars/mhist/MHCalibrationPINDiode.h

    r2525 r2603  
    2626private:
    2727
    28   TH1I* fHPQ;             //-> Histogram containing the summed 32 PINDiode slices
    29   TH1F* fHErrQ;           //-> Variance of summed FADC slices
    30   TH1I* fHPT;             //-> Histogram with time evolution of summed charges
     28  TH1I* fHPCharge;             //-> Histogram containing the summed 32 PINDiode slices
     29  TH1F* fHErrCharge;           //-> Variance of summed FADC slices
     30  TH1I* fHPTime;             //-> Histogram with time evolution of summed charges
    3131 
    3232 
    3333  TF1 *fVarGausFit;
    3434 
    35   Float_t  fErrQfirst;
    36   Float_t  fErrQlast;
    37   UShort_t fErrQnbins;
     35  Float_t  fErrChargeFirst;
     36  Float_t  fErrChargeLast;
     37  UShort_t fErrChargeNbins;
    3838
    3939public:
     
    4242  ~MHCalibrationPINDiode();
    4343
    44   const Double_t GetT()      const { return fVarGausFit->GetParameter(2); }
    45   const Double_t GetErrT()    const { return fVarGausFit->GetParameter(3); }
     44  const Double_t GetTime()      const { return fVarGausFit->GetParameter(2); }
     45  const Double_t GetErrTime()    const { return fVarGausFit->GetParameter(3); }
    4646
    4747  ClassDef(MHCalibrationPINDiode, 0)
  • trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc

    r2599 r2603  
    6262MHCalibrationPixel::MHCalibrationPixel(const char *name, const char *title)
    6363      : fPixId(-1),
    64         fQGausFit(NULL),
    65         fTGausFit(NULL),
     64        fChargeGausFit(NULL),
     65        fTimeGausFit(NULL),
    6666        fFitLegend(NULL),
    6767        fLowerFitRange(0.),
    6868        fFitOK(kFALSE),
    69         fQChisquare(-1.),
    70         fQProb(-1.),
    71         fQNdf(-1),
    72         fTChisquare(-1.),
    73         fTProb(-1.),
    74         fTNdf(-1)
     69        fChargeChisquare(-1.),
     70        fChargeProb(-1.),
     71        fChargeNdf(-1),
     72        fTimeChisquare(-1.),
     73        fTimeProb(-1.),
     74        fTimeNdf(-1)
    7575{
    7676
     
    7878    fTitle = title ? title : "Fill the accumulated charges and times of all events and perform fits";
    7979
    80     TString qtitle = "Distribution of Summed FADC Slices Pixel ";
    81 
    8280    // Create a large number of bins, later we will rebin
    83     fQfirst = -0.5;
    84     fQlast  = gkStartQlast - 0.5;
    85     fQnbins = gkStartPixelBinNr;
    86 
    87     fHQ = new TH1I("HQ",qtitle.Data(),
    88                    fQnbins,fQfirst,fQlast);
    89     fHQ->SetXTitle("Sum FADC Slices");
    90     fHQ->SetYTitle("Nr. of events");
    91     fHQ->Sumw2();
    92 
    93     fHQ->SetDirectory(NULL);
    94 
    95     TString ttitle = "Distribution of Mean Arrival Times Pixel ";
     81    fChargeFirst = -0.5;
     82    fChargeLast  = 10000. - 0.5;
     83    fChargeNbins = 20000;
     84
     85    fHCharge = new TH1I("HCharge","Distribution of Summed FADC Slices Pixel ",
     86                   fChargeNbins,fChargeFirst,fChargeLast);
     87    fHCharge->SetXTitle("Sum FADC Slices");
     88    fHCharge->SetYTitle("Nr. of events");
     89    fHCharge->Sumw2();
     90
     91    fHCharge->SetDirectory(NULL);
    9692
    9793    Axis_t tfirst = -0.5;
    9894    Axis_t tlast  = 15.5;
    99     Int_t nbins  = 16;
    100 
    101     fHT = new TH1I("HT",ttitle.Data(),
    102                   nbins,tfirst,tlast);
    103     fHT->SetXTitle("Mean Arrival Times [FADC slice nr]");
    104     fHT->SetYTitle("Nr. of events");
    105     fHT->Sumw2();
    106 
    107     fHT->SetDirectory(NULL);
     95    Int_t  ntbins = 16;
     96
     97    fHTime = new TH1I("HTime","Distribution of Mean Arrival Times Pixel ",
     98                  ntbins,tfirst,tlast);
     99    fHTime->SetXTitle("Mean Arrival Times [FADC slice nr]");
     100    fHTime->SetYTitle("Nr. of events");
     101    fHTime->Sumw2();
     102
     103    fHTime->SetDirectory(NULL);
    108104
    109105    TString qvsntitle = "Sum of Charges vs. Event Number Pixel ";
    110106
    111107    // We define a reasonable number and later enlarge it if necessary
    112     nbins = 20000;
     108    Int_t  nqbins = 20000;
    113109    Axis_t nfirst = -0.5;
    114     Axis_t nlast  = (Axis_t)nbins - 0.5;
    115 
    116     fHQvsN = new TH1I("HQvsN",qvsntitle.Data(),
    117                      nbins,nfirst,nlast);
    118     fHQvsN->SetXTitle("Event Nr.");
    119     fHQvsN->SetYTitle("Sum of FADC slices");
    120 
    121     fHQvsN->SetDirectory(NULL);
     110    Axis_t nlast  = (Axis_t)nqbins - 0.5;
     111
     112    fHChargevsN = new TH1I("HChargevsN",qvsntitle.Data(),
     113                     nqbins,nfirst,nlast);
     114    fHChargevsN->SetXTitle("Event Nr.");
     115    fHChargevsN->SetYTitle("Sum of FADC slices");
     116
     117    fHChargevsN->SetDirectory(NULL);
    122118
    123119}
     
    126122{
    127123
    128   delete fHQ;
    129   delete fHT;
    130   delete fHQvsN;
    131 
    132   if (fQGausFit)
    133     delete fQGausFit;
    134   if (fTGausFit)
    135     delete fTGausFit;
     124  delete fHCharge;
     125  delete fHTime;
     126  delete fHChargevsN;
     127
     128  if (fChargeGausFit)
     129    delete fChargeGausFit;
     130  if (fTimeGausFit)
     131    delete fTimeGausFit;
    136132  if (fFitLegend)
    137133    delete fFitLegend;
     
    145141  fPixId = id;
    146142 
    147   TString nameQ = TString(fHQ->GetName());
     143  TString nameQ = TString(fHCharge->GetName());
    148144  nameQ += id;
    149   fHQ->SetName(nameQ.Data());
    150 
    151   TString nameT = TString(fHT->GetName());
     145  fHCharge->SetName(nameQ.Data());
     146
     147  TString nameT = TString(fHTime->GetName());
    152148  nameT += id;
    153   fHT->SetName(nameT.Data());
    154 
    155   TString nameQvsN  = TString(fHQvsN->GetName());
     149  fHTime->SetName(nameT.Data());
     150
     151  TString nameQvsN  = TString(fHChargevsN->GetName());
    156152  nameQvsN += id;
    157   fHQvsN->SetName(nameQvsN.Data());
     153  fHChargevsN->SetName(nameQvsN.Data());
     154
     155  TString titleQ = TString(fHCharge->GetTitle());
     156  titleQ += id;
     157  fHCharge->SetTitle(titleQ.Data());
     158
     159  TString titleT = TString(fHTime->GetTitle());
     160  titleT += id;
     161  fHTime->SetTitle(titleT.Data());
     162
     163  TString titleQvsN  = TString(fHChargevsN->GetTitle());
     164  titleQvsN += id;
     165  fHChargevsN->SetTitle(titleQvsN.Data());
    158166}
    159167
     
    162170{
    163171 
    164   for (Int_t i = fHQ->FindBin(fQfirst); i <= fHQ->FindBin(fQlast); i++)
    165       fHQ->SetBinContent(i, 1.e-20);
     172  for (Int_t i = fHCharge->FindBin(fChargeFirst);
     173       i <= fHCharge->FindBin(fChargeLast); i++)
     174    fHCharge->SetBinContent(i, 1.e-20);
    166175
    167176  for (Int_t i = 0; i < 16; i++)
    168       fHT->SetBinContent(i, 1.e-20);
    169  
    170   fQlast     = gkStartQlast;
    171 
    172   fHQ->GetXaxis()->SetRangeUser(0.,fQlast);
     177      fHTime->SetBinContent(i, 1.e-20);
     178 
     179  fChargeLast     = 9999.5;
     180
     181  fHCharge->GetXaxis()->SetRangeUser(0.,fChargeLast);
    173182
    174183  return;
     
    183192{
    184193
    185   fHQ->Reset();
    186   fHT->Reset();
     194  fHCharge->Reset();
     195  fHTime->Reset();
    187196
    188197  return kTRUE;
     
    208217  fFitLegend->SetTextSize(0.05);
    209218
    210   char line1[32];
    211   sprintf(line1,"Mean: Q_{#mu} = %2.2f #pm %2.2f",fQMean,fQMeanErr);
     219  const TString line1 =
     220    Form("Mean: Q_{#mu} = %2.2f #pm %2.2f",fChargeMean,fChargeMeanErr);
     221
    212222  fFitLegend->AddText(line1);
    213223
    214   char line4[32];
    215   sprintf(line4,"Sigma: #sigma_{Q} = %2.2f #pm %2.2f",fQSigma,fQSigmaErr);
     224
     225  const TString line4 =
     226    Form("Sigma: #sigma_{Q} = %2.2f #pm %2.2f",fChargeSigma,fChargeSigmaErr);
     227
    216228  fFitLegend->AddText(line4);
    217229
    218   char line7[32];
    219   sprintf(line7,"#chi^{2} / N_{dof}: %4.2f / %3i",fQChisquare,fQNdf);
     230
     231  const TString line7 =
     232    Form("#chi^{2} / N_{dof}: %4.2f / %3i",fChargeChisquare,fChargeNdf);
     233
    220234  fFitLegend->AddText(line7);
    221235
    222   char line8[32];
    223   sprintf(line8,"Probability: %4.3f ",fQProb);
     236
     237  const TString line8 =
     238    Form("Probability: %4.3f ",fChargeProb);
     239
    224240  fFitLegend->AddText(line8);
     241
    225242
    226243  if (fFitOK)
     
    256273    gPad->SetTicks();
    257274
    258     fHQ->DrawCopy(opt);
     275    fHCharge->Draw(opt);
    259276   
    260     if (fQGausFit)
     277    if (fChargeGausFit)
    261278      {
    262279        if (fFitOK)
    263           fQGausFit->SetLineColor(kGreen);         
     280          fChargeGausFit->SetLineColor(kGreen);         
    264281        else
    265           fQGausFit->SetLineColor(kRed);
    266 
    267         fQGausFit->DrawCopy("same");
     282          fChargeGausFit->SetLineColor(kRed);
     283
     284        fChargeGausFit->Draw("same");
    268285        c->Modified();
    269286        c->Update();
     
    279296
    280297    gPad->SetLogy(1);
    281     fHT->DrawCopy(opt);
    282 
    283     if (fTGausFit)
     298    fHTime->Draw(opt);
     299
     300    if (fTimeGausFit)
    284301      {
    285         if (fTChisquare > 1.)
    286           fTGausFit->SetLineColor(kRed);
     302        if (fTimeChisquare > 1.)
     303          fTimeGausFit->SetLineColor(kRed);
    287304        else
    288           fTGausFit->SetLineColor(kGreen);
    289 
    290         fTGausFit->DrawCopy("same");
     305          fTimeGausFit->SetLineColor(kGreen);
     306
     307        fTimeGausFit->Draw("same");
    291308        c->Modified();
    292309        c->Update();
     
    297314
    298315    c->cd(4);
    299     fHQvsN->DrawCopy(opt);
    300 }
    301 
    302 
    303 
    304 Bool_t MHCalibrationPixel::FitT(Axis_t rmin, Axis_t rmax, Option_t *option)
    305 {
    306 
    307   if (fTGausFit)
     316    fHChargevsN->Draw(opt);
     317}
     318
     319
     320
     321Bool_t MHCalibrationPixel::FitTime(Axis_t rmin, Axis_t rmax, Option_t *option)
     322{
     323
     324  if (fTimeGausFit)
    308325    return kFALSE;
    309326
     
    311328  rmax = (rmax != 0.) ? rmax : 9.;
    312329
    313   const Stat_t   entries     = fHT->GetEntries();
    314   const Double_t mu_guess    = fHT->GetBinCenter(fHT->GetMaximumBin());
     330  const Stat_t   entries     = fHTime->GetEntries();
     331  const Double_t mu_guess    = fHTime->GetBinCenter(fHTime->GetMaximumBin());
    315332  const Double_t sigma_guess = (rmax - rmin)/2.;
    316333  const Double_t area_guess  = entries/gkSq2Pi;
     
    318335  TString name = TString("GausTime");
    319336  name += fPixId;
    320   fTGausFit = new TF1(name.Data(),"gaus",rmin,rmax); 
    321 
    322   if (!fTGausFit)
     337  fTimeGausFit = new TF1(name.Data(),"gaus",rmin,rmax); 
     338
     339  if (!fTimeGausFit)
    323340    {
    324341    *fLog << err << dbginf << "Could not create fit function for Gauss fit" << endl;
     
    326343    }
    327344
    328   fTGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
    329   fTGausFit->SetParNames("Area","#mu","#sigma");
    330   fTGausFit->SetParLimits(0,0.,entries);
    331   fTGausFit->SetParLimits(1,rmin,rmax);
    332   fTGausFit->SetParLimits(2,0.,(rmax-rmin)/2.);
    333   fTGausFit->SetRange(rmin,rmax);
    334 
    335   fHT->Fit(fTGausFit,option);
    336 
    337   rmin = fTGausFit->GetParameter(1) - 3.*fTGausFit->GetParameter(2);
    338   rmax = fTGausFit->GetParameter(1) + 3.*fTGausFit->GetParameter(2);
    339   fTGausFit->SetRange(rmin,rmax); 
    340 
    341   fHT->Fit(fTGausFit,option);
    342 
    343   fTChisquare = fTGausFit->GetChisquare();
    344   fTNdf       = fTGausFit->GetNDF();
    345   fTProb      = fTGausFit->GetProb();
    346   fTMean      = fTGausFit->GetParameter(1);
    347   fTSigma     = fTGausFit->GetParameter(2);
    348 
    349   if (fTChisquare > 1.)
     345  fTimeGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
     346  fTimeGausFit->SetParNames("Area","#mu","#sigma");
     347  fTimeGausFit->SetParLimits(0,0.,entries);
     348  fTimeGausFit->SetParLimits(1,rmin,rmax);
     349  fTimeGausFit->SetParLimits(2,0.,(rmax-rmin));
     350  fTimeGausFit->SetRange(rmin,rmax);
     351
     352  fHTime->Fit(fTimeGausFit,option);
     353
     354  rmin = fTimeGausFit->GetParameter(1) - 3.*fTimeGausFit->GetParameter(2);
     355  rmax = fTimeGausFit->GetParameter(1) + 3.*fTimeGausFit->GetParameter(2);
     356  fTimeGausFit->SetRange(rmin,rmax); 
     357
     358  fHTime->Fit(fTimeGausFit,option);
     359
     360  fTimeChisquare = fTimeGausFit->GetChisquare();
     361  fTimeNdf       = fTimeGausFit->GetNDF();
     362  fTimeProb      = fTimeGausFit->GetProb();
     363
     364  fTimeMean      = fTimeGausFit->GetParameter(1);
     365  fTimeSigma     = fTimeGausFit->GetParameter(2);
     366
     367  if (fTimeChisquare > 1.)
    350368    {
    351369      *fLog << warn << "Fit of the Arrival times failed ! " << endl;
     
    357375}
    358376
    359 Bool_t MHCalibrationPixel::FitQ(Option_t *option)
    360 {
    361 
    362   if (fQGausFit)
     377Bool_t MHCalibrationPixel::FitCharge(Option_t *option)
     378{
     379
     380  if (fChargeGausFit)
    363381    return kFALSE;
    364382
     
    366384  // Get the fitting ranges
    367385  //
    368   Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fQfirst;
     386  Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fChargeFirst;
    369387  Axis_t rmax = 0.;
    370388
     
    373391  // otherwise the fit goes gaga because of high number of dimensions ...
    374392  //
    375   const Stat_t   entries  = fHQ->GetEntries();
    376   const Double_t ar_guess = entries/gkSq2Pi;
    377   const Double_t mu_guess = fHQ->GetBinCenter(fHQ->GetMaximumBin());
    378   const Double_t si_guess = mu_guess/50.;
    379 
    380   TString name = TString("QGausFit");
     393  const Stat_t   entries    = fHCharge->GetEntries();
     394  const Double_t area_guess = entries/gkSq2Pi;
     395  const Double_t mu_guess   = fHCharge->GetBinCenter(fHCharge->GetMaximumBin());
     396  const Double_t sigma_guess = mu_guess/15.;
     397
     398  TString name = TString("ChargeGausFit");
    381399  name += fPixId;
    382400
    383   fQGausFit = new TF1(name.Data(),"gaus",rmin,fQlast);
    384 
    385   if (!fQGausFit)
     401  fChargeGausFit = new TF1(name.Data(),"gaus",rmin,fChargeLast);
     402
     403  if (!fChargeGausFit)
    386404    {
    387405    *fLog << err << dbginf << "Could not create fit function for Gauss fit" << endl;
     
    389407    }
    390408 
    391   fQGausFit->SetParameters(ar_guess,mu_guess,si_guess);
    392   fQGausFit->SetParNames("Area","#mu","#sigma");
    393   fQGausFit->SetParLimits(0,0.,entries);
    394   fQGausFit->SetParLimits(1,rmin,fQlast);
    395   fQGausFit->SetParLimits(2,0.,fQlast-rmin);
    396   fQGausFit->SetRange(rmin,fQlast);
    397   fQGausFit->Update();
    398 
    399   fHQ->Fit(fQGausFit,option);
    400  
    401   rmin = fQGausFit->GetParameter(1) - 3.*fQGausFit->GetParameter(2);
    402   rmax = fQGausFit->GetParameter(1) + 3.*fQGausFit->GetParameter(2);
    403 
    404   fQGausFit->SetRange(rmin,rmax); 
    405   fHQ->Fit(fQGausFit,option);
    406 
    407   rmin = fQGausFit->GetParameter(1) - 3.5*fQGausFit->GetParameter(2);
    408   rmax = fQGausFit->GetParameter(1) + 3.5*fQGausFit->GetParameter(2);
    409 
    410   fQGausFit->SetRange(rmin,rmax); 
    411   fHQ->Fit(fQGausFit,option);
    412 
    413   fQChisquare = fQGausFit->GetChisquare();
    414   fQNdf       = fQGausFit->GetNDF();
    415   fQProb      = fQGausFit->GetProb();
    416   fQMean      = fQGausFit->GetParameter(1);
    417   fQMeanErr   = fQGausFit->GetParError(1);
    418   fQSigma     = fQGausFit->GetParameter(2);
    419   fQSigmaErr  = fQGausFit->GetParError(2);
     409  fChargeGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
     410  fChargeGausFit->SetParNames("Area","#mu","#sigma");
     411  fChargeGausFit->SetParLimits(0,0.,entries);
     412  fChargeGausFit->SetParLimits(1,rmin,fChargeLast);
     413  fChargeGausFit->SetParLimits(2,0.,fChargeLast-rmin);
     414  fChargeGausFit->SetRange(rmin,fChargeLast);
     415
     416  fHCharge->Fit(fChargeGausFit,option);
     417 
     418  Axis_t rtry = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
     419 
     420  rmin = (rtry < rmin ? rmin : rtry);
     421  rmax = fChargeGausFit->GetParameter(1) + 2.5*fChargeGausFit->GetParameter(2);
     422  fChargeGausFit->SetRange(rmin,rmax); 
     423
     424  fHCharge->Fit(fChargeGausFit,option);
     425
     426  //  rmin = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
     427  //  rmax = fChargeGausFit->GetParameter(1) + 2.5*fChargeGausFit->GetParameter(2);
     428  //  fChargeGausFit->SetRange(rmin,rmax); 
     429
     430  // fHCharge->Fit(fChargeGausFit,option);
     431
     432  fChargeChisquare = fChargeGausFit->GetChisquare();
     433  fChargeNdf       = fChargeGausFit->GetNDF();
     434  fChargeProb      = fChargeGausFit->GetProb();
     435  fChargeMean      = fChargeGausFit->GetParameter(1);
     436  fChargeMeanErr   = fChargeGausFit->GetParError(1);
     437  fChargeSigma     = fChargeGausFit->GetParameter(2);
     438  fChargeSigmaErr  = fChargeGausFit->GetParError(2);
    420439
    421440  //
     
    423442  // The Probability is greater than gkProbLimit (default 0.01 == 99%)
    424443  //
    425   if (fQProb < gkProbLimit)
     444  if (fChargeProb < gkProbLimit)
    426445    {
    427       *fLog << warn << "Prob: " << fQProb << " is smaller than the allowed value: " << gkProbLimit << endl;
     446      *fLog << warn << "Prob: " << fChargeProb << " is smaller than the allowed value: " << gkProbLimit << endl;
    428447      fFitOK = kFALSE;
    429448      return kFALSE;
     
    442461  Int_t nbins = 50;
    443462
    444   CutEdges(fHQ,nbins);
    445 
    446   fQfirst = fHQ->GetBinLowEdge(fHQ->GetXaxis()->GetFirst());
    447   fQlast  = fHQ->GetBinLowEdge(fHQ->GetXaxis()->GetLast())+fHQ->GetBinWidth(0);
    448   fQnbins = nbins;
    449 
    450   CutEdges(fHQvsN,0);
    451 
    452 }
    453 
    454 void MHCalibrationPixel::PrintQFitResult()
    455 {
    456  
    457   *fLog << "Results of the Summed Charges Fit: "                 << endl;
    458   *fLog << "Chisquare: "        << fQChisquare                   << endl;
    459   *fLog << "DoF: "              << fQNdf                         << endl;
    460   *fLog << "Probability: "      << fQProb                        << endl;
    461   *fLog                                                          << endl;
    462  
    463 }
    464 
    465 void MHCalibrationPixel::PrintTFitResult()
    466 {
    467 
    468   *fLog << "Results of the Arrival Time Slices Fit: "             << endl;
    469   *fLog << "Chisquare: "   << fTChisquare                         << endl;
    470   *fLog << "Ndf: "         << fTNdf                               << endl;
    471   *fLog << "Probability: " << fTProb                              << endl;
    472   *fLog                                                           << endl;
    473 
    474 }
     463  CutEdges(fHCharge,nbins);
     464
     465  fChargeFirst = fHCharge->GetBinLowEdge(fHCharge->GetXaxis()->GetFirst());
     466  fChargeLast  = fHCharge->GetBinLowEdge(fHCharge->GetXaxis()->GetLast())+fHCharge->GetBinWidth(0);
     467  fChargeNbins = nbins;
     468
     469  CutEdges(fHChargevsN,0);
     470
     471}
     472
     473void MHCalibrationPixel::PrintChargeFitResult()
     474{
     475 
     476  *fLog << "Results of the Summed Charges Fit: "                      << endl;
     477  *fLog << "Chisquare: "        << fChargeChisquare                   << endl;
     478  *fLog << "DoF: "              << fChargeNdf                         << endl;
     479  *fLog << "Probability: "      << fChargeProb                        << endl;
     480  *fLog                                                               << endl;
     481 
     482}
     483
     484void MHCalibrationPixel::PrintTimeFitResult()
     485{
     486
     487  *fLog << "Results of the Time Slices Fit: "                        << endl;
     488  *fLog << "Chisquare: "   << fTimeChisquare                         << endl;
     489  *fLog << "Ndf: "         << fTimeNdf                               << endl;
     490  *fLog << "Probability: " << fTimeProb                              << endl;
     491  *fLog                                                              << endl;
     492
     493}
  • trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.h

    r2599 r2603  
    3131protected:
    3232
    33   TH1I* fHQ;              //-> Summed FADC slices
    34   TH1I* fHT;              //-> Mean arrival time in number of FADC sice
    35 
    36   TH1I* fHQvsN;           //-> Summed Charge vs. Event Nr.
     33  TH1I* fHCharge;              //-> Summed FADC slices
     34  TH1I* fHTime;                //-> Mean arrival time in number of FADC sice
     35  TH1I* fHChargevsN;           //-> Summed Charge vs. Event Nr.
    3736 
    38   TF1* fQGausFit;
    39   TF1* fTGausFit;
     37  TF1* fChargeGausFit;
     38  TF1* fTimeGausFit;
    4039 
    4140  TPaveText *fFitLegend; 
    4241 
    4342  Axis_t  fLowerFitRange;
    44   Axis_t  fQfirst;
    45   Axis_t  fQlast;
    46   Int_t   fQnbins;
     43  Axis_t  fChargeFirst;
     44  Axis_t  fChargeLast;
     45  Int_t   fChargeNbins;
    4746
    4847  Bool_t fFitOK;
    4948
    50   Double_t fQChisquare;
    51   Double_t fQProb;
    52   Int_t    fQNdf;
     49  Double_t fChargeChisquare;
     50  Double_t fChargeProb;
     51  Int_t    fChargeNdf;
    5352
    54   Double_t fQMean;
    55   Double_t fQMeanErr;
    56   Double_t fQSigma;
    57   Double_t fQSigmaErr;
     53  Double_t fChargeMean;
     54  Double_t fChargeMeanErr;
     55  Double_t fChargeSigma;
     56  Double_t fChargeSigmaErr;
    5857 
    59   Double_t fTChisquare;
    60   Double_t fTProb;
    61   Int_t    fTNdf;
     58  Double_t fTimeChisquare;
     59  Double_t fTimeProb;
     60  Int_t    fTimeNdf;
    6261
    63   Double_t fTMean;
    64   Double_t fTSigma;
     62  Double_t fTimeMean;
     63  Double_t fTimeSigma;
    6564 
    6665  virtual void DrawLegend();
     
    7675  Bool_t Fill(const MParContainer *, const Stat_t w=1) { return kTRUE; }
    7776
    78   Bool_t FillQ(Int_t q) {  return fHQ->Fill(q) > -1; }
    79   Bool_t FillT(Int_t t) {  return fHT->Fill(t) > -1; }
    80   Bool_t FillQvsN(Float_t q, Int_t n) { return fHQvsN->Fill(n,q) > -1; }
     77  Bool_t FillCharge(Int_t q)               { return fHCharge->Fill(q)      > -1; }
     78  Bool_t FillTime(Int_t t)                 { return fHTime->Fill(t)        > -1; }
     79  Bool_t FillChargevsN(Float_t q, Int_t n) { return fHChargevsN->Fill(n,q) > -1; }
    8180
    82   const TH1I *GetHQ()       { return fHQ; }
    83   const TH1I *GetHQ() const { return fHQ; }
     81  const TH1I *GetHCharge()                 { return fHCharge;    }
     82  const TH1I *GetHCharge() const           { return fHCharge;    }
    8483
    85   const Double_t GetQMean()    const { return fQMean; }
    86   const Double_t GetQMeanErr()  const { return fQMeanErr; }
    87   const Double_t GetQSigma()   const { return fQSigma; }
    88   const Double_t GetQSigmaErr() const { return fQSigmaErr; }
    89   const Double_t GetArea()    const { return fQGausFit->GetParameter(0); }
    90   const Double_t GetAreaErr()  const { return fQGausFit->GetParError(0); }
     84  const Double_t GetChargeMean()     const { return fChargeMean;    }
     85  const Double_t GetChargeMeanErr()  const { return fChargeMeanErr; }
     86  const Double_t GetChargeSigma()    const { return fChargeSigma;  }
     87  const Double_t GetChargeSigmaErr() const { return fChargeSigmaErr; }
     88  const Double_t GetArea()           const { return fChargeGausFit->GetParameter(0); }
     89  const Double_t GetAreaErr()        const { return fChargeGausFit->GetParError(0); }
    9190
    92   const Double_t GetQChiSquare() const { return fQChisquare; }
    93   const Double_t GetQProb()    const { return fQProb;      } 
    94   const Int_t    GetQNdf()     const { return fQNdf;       }   
     91  const Double_t GetChargeChiSquare() const { return fChargeChisquare; }
     92  const Double_t GetChargeProb()      const { return fChargeProb;      } 
     93  const Int_t    GetChargeNdf()       const { return fChargeNdf;       }   
    9594
    96   const Double_t GetTMean()   const  { return fTMean; }
    97   const Double_t GetTSigma()  const  { return fTSigma; }
     95  const Double_t GetTimeMean()        const { return fTimeMean; }
     96  const Double_t GetTimeSigma()       const { return fTimeSigma; }
    9897
    99   const Double_t GetTChiSquare() const { return fTChisquare; }
    100   const Double_t GetTProb()      const { return fTProb; }
    101   const Int_t    GetTNdf()       const { return fTNdf;       }   
     98  const Double_t GetTimeChiSquare()   const { return fTimeChisquare; }
     99  const Double_t GetTimeProb()        const { return fTimeProb;      }
     100  const Int_t    GetTimeNdf()         const { return fTimeNdf;       }   
    102101 
    103   const TH1I *GetHT()       { return fHT; }
    104   const TH1I *GetHT() const { return fHT; }
     102  const TH1I *GetHTime()                    { return fHTime; }
     103  const TH1I *GetHTime()              const { return fHTime; }
    105104 
    106   const TH1I *GetHQvsN()       { return fHQvsN; }
    107   const TH1I *GetHQvsN() const { return fHQvsN; }
     105  const TH1I *GetHChargevsN()               { return fHChargevsN; }
     106  const TH1I *GetHChargevsN()         const { return fHChargevsN; }
    108107 
    109   Bool_t FitQ(Option_t *option="RQ0"); 
    110   Bool_t FitT(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0");   
     108  Bool_t FitCharge(Option_t *option="RQ0"); 
     109  Bool_t FitTime(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0");   
    111110
    112111  virtual void Draw(Option_t *option="");
     
    116115  void SetLowerFitRange(Axis_t min)  { fLowerFitRange = min; }
    117116
    118   void PrintQFitResult();
    119   void PrintTFitResult(); 
     117  void PrintChargeFitResult();
     118  void PrintTimeFitResult(); 
    120119
    121   Bool_t IsFitted()    { return fFitOK; }
     120  Bool_t IsFitOK()    { return fFitOK; }
    122121 
    123122  ClassDef(MHCalibrationPixel, 1)
Note: See TracChangeset for help on using the changeset viewer.