Ignore:
Timestamp:
12/04/03 12:17:22 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
5 edited

Legend:

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

    r2525 r2599  
    6969
    7070    // Create a large number of bins, later we will rebin
    71     fBPQfirst = 0;
    72     fBPQlast  = gkStartBlindPixelBinNr;
    73     fBPQnbins = gkStartBlindPixelBinNr;
    74 
    75     fHBPQ = new TH1I("HBPQ","Distribution of Summed FADC Slices",fBPQnbins,fBPQfirst,fBPQlast);
    76     fHBPQ->SetXTitle("Sum FADC Slices");
    77     fHBPQ->SetYTitle("Nr. of events");
    78     fHBPQ->Sumw2();
    79 
    80     fErrBPQfirst = 0.;
    81     fErrBPQlast  = gkStartBlindPixelBinNr;
    82     fErrBPQnbins = gkStartBlindPixelBinNr;
    83 
    84     fHBPErrQ = new TH1F("HBPErrQ","Distribution of Variances of Summed FADC Slices",
    85                         fErrBPQnbins,fErrBPQfirst,fErrBPQlast);
    86     fHBPErrQ->SetXTitle("Variance Summed FADC Slices");
    87     fHBPErrQ->SetYTitle("Nr. of events");
    88     fHBPErrQ->Sumw2();
     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();
    8989
    9090    Axis_t tfirst = -0.5;
     
    9292    Int_t nbins   = 16;
    9393
    94     fHBPT = new TH1I("HBPT","Distribution of Mean Arrival Times",nbins,tfirst,tlast);
    95     fHBPT->SetXTitle("Mean Arrival Times [FADC slice nr]");
    96     fHBPT->SetYTitle("Nr. of events");
    97     fHBPT->Sumw2();
     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();
    9898
    9999    // We define a reasonable number and later enlarge it if necessary
     
    102102    Axis_t nlast  = (Axis_t)nbins - 0.5;
    103103
    104     fHBPQvsN = new TH1I("HBPQvsN","Sum of Charges vs. Event Number",nbins,nfirst,nlast);
    105     fHBPQvsN->SetXTitle("Event Nr.");
    106     fHBPQvsN->SetYTitle("Sum of FADC slices");
     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");
    107107
    108108    fgSinglePheFitFunc = &gfKto8;
     
    113113{
    114114
    115   delete fHBPQ;
    116   delete fHBPT;
    117   delete fHBPErrQ;
     115  delete fHBlindPixelQ;
     116  delete fHBlindPixelT;
     117  delete fHBlindPixelErrQ;
    118118 
    119119  if (fSinglePheFit)
     
    127127void MHCalibrationBlindPixel::ResetBin(Int_t i)
    128128{
    129     fHBPQ->SetBinContent (i, 1.e-20);
    130     fHBPErrQ->SetBinContent  (i, 1.e-20);
    131     fHBPT->SetBinContent(i, 1.e-20);
     129    fHBlindPixelQ->SetBinContent (i, 1.e-20);
     130    fHBlindPixelErrQ->SetBinContent  (i, 1.e-20);
     131    fHBlindPixelT->SetBinContent(i, 1.e-20);
    132132}
    133133
     
    209209    gPad->SetTicks();
    210210
    211     fHBPQ->DrawCopy(opt);
     211    fHBlindPixelQ->DrawCopy(opt);
    212212   
    213213    if (fSinglePheFit)
     
    231231    gPad->SetLogy(1);
    232232    gPad->SetBorderMode(0);
    233     fHBPT->DrawCopy(opt);
    234 
    235     if (fHBPT->GetFunction("GausTime"))
     233    fHBlindPixelT->DrawCopy(opt);
     234
     235    if (fHBlindPixelT->GetFunction("GausTime"))
    236236      {
    237         TF1 *tfit = fHBPT->GetFunction("GausTime");
     237        TF1 *tfit = fHBlindPixelT->GetFunction("GausTime");
    238238        if (tfit->GetProb() < 0.01)
    239239          tfit->SetLineColor(kRed);
     
    248248    c->cd(4);
    249249
    250     fHBPQvsN->DrawCopy(opt);
     250    fHBlindPixelQvsN->DrawCopy(opt);
    251251
    252252    c->Modified();
     
    260260  gRandom->SetSeed();
    261261
    262   if (fHBPQ->GetEntries() != 0)
     262  if (fHBlindPixelQ->GetEntries() != 0)
    263263    {
    264       *fLog << err << "Histogram " << fHBPQ->GetTitle() << " is already filled. " << endl;
     264      *fLog << err << "Histogram " << fHBlindPixelQ->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                                    fBPQfirst,fBPQlast,fgSinglePheFitNPar);
     270                                   fBlindPixelQfirst,fBlindPixelQlast,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(fBPQnbins); 
     274  simulateSinglePhe->SetNpx(fBlindPixelQnbins); 
    275275
    276276  for (Int_t i=0;i<10000; i++)
    277277    {
    278       fHBPQ->Fill(simulateSinglePhe->GetRandom());
     278      fHBlindPixelQ->Fill(simulateSinglePhe->GetRandom());
    279279    }
    280280 
     
    283283
    284284
    285 void MHCalibrationBlindPixel::ChangeFitFunc(BPFitFunc fitfunc, Int_t par)
     285void MHCalibrationBlindPixel::ChangeFitFunc(BlindPixelFitFunc fitfunc, Int_t par)
    286286{
    287287 
     
    303303  // Get the fitting ranges
    304304  //
    305   rmin = (rmin != 0.) ? rmin : fBPQfirst;
    306   rmax = (rmax != 0.) ? rmax : fBPQlast;
     305  rmin = (rmin != 0.) ? rmin : fBlindPixelQfirst;
     306  rmax = (rmax != 0.) ? rmax : fBlindPixelQlast;
    307307
    308308  //
     
    310310  // otherwise the fit goes gaga because of high number of dimensions ...
    311311  //
    312   const Stat_t   entries      = fHBPQ->GetSumOfWeights();
     312  const Stat_t   entries      = fHBlindPixelQ->GetSumOfWeights();
    313313  const Double_t lambda_guess = 0.2;
    314   const Double_t mu_0_guess = fHBPQ->GetBinCenter(fHBPQ->GetMaximumBin());
    315   const Double_t si_0_guess = mu_0_guess/500.;
    316   const Double_t mu_1_guess = mu_0_guess + 2.;
     314  const Double_t mu_0_guess = fHBlindPixelQ->GetBinCenter(fHBlindPixelQ->GetMaximumBin());
     315  const Double_t si_0_guess = mu_0_guess/10.;
     316  const Double_t mu_1_guess = mu_0_guess + 50.;
    317317  const Double_t si_1_guess = si_0_guess + si_0_guess;
    318318
     
    325325  fSinglePheFit->SetParLimits(3,1.0,rmax-rmin);
    326326  fSinglePheFit->SetParLimits(4,1.7,rmax-rmin);
    327   fSinglePheFit->SetParLimits(5,0.,2.*entries);
     327  fSinglePheFit->SetParLimits(5,0.,2.5*entries);
    328328  //
    329329  // Normalize the histogram to facilitate faster fitting of the area
     
    333333  // ROOT gives us another nice example of user-unfriendly behavior:
    334334  // Although the normalization of the function fSinglePhe and the
    335   // Histogram fHBPQ agree (!!), the fit does not normalize correctly INTERNALLY
     335  // Histogram fHBlindPixelQ agree (!!), the fit does not normalize correctly INTERNALLY
    336336  // in the fitting procedure !!!
    337337  //
     
    342342  // So, WE have to adapt to that internal flaw of ROOT:
    343343  //
    344   const Int_t  npx     = fSinglePheFit->GetNpx();
    345   const Int_t  bins    = fHBPQ->GetXaxis()->GetLast()-fHBPQ->GetXaxis()->GetFirst();
    346   //  fHBPQ->Scale(gkSq2Pi*(float)bins/npx/entries);
     344  //  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);
    347347
    348348  //
     
    353353  //  fSinglePheFit->SetNpx(fQnbins); 
    354354
    355   fHBPQ->Fit("SinglePheFit",opt);
     355  fHBlindPixelQ->Fit(fSinglePheFit,opt);
    356356
    357357  fLambda = fSinglePheFit->GetParameter(0);
     
    403403  // If you find another solution which WORKS!!, please tell me!!
    404404  //
    405   Int_t nbins = 100;
    406 
    407   *fLog << "New number of bins in HSinQ: " << CutEdges(fHBPQ,nbins) << endl;
    408 
    409   fBPQfirst = fHBPQ->GetBinLowEdge(fHBPQ->GetXaxis()->GetFirst());
    410   fBPQlast  = fHBPQ->GetBinLowEdge(fHBPQ->GetXaxis()->GetLast())+fHBPQ->GetBinWidth(0);
    411   fBPQnbins = nbins;
    412 
    413   *fLog << "New number of bins in HErrQ: " << CutEdges(fHBPErrQ,30) << endl;
    414   fErrBPQfirst = fHBPErrQ->GetBinLowEdge(fHBPErrQ->GetXaxis()->GetFirst());
    415   fErrBPQlast  = fHBPErrQ->GetBinLowEdge(fHBPErrQ->GetXaxis()->GetLast())+fHBPErrQ->GetBinWidth(0);
    416   fErrBPQnbins = nbins;
    417 
    418   CutEdges(fHBPQvsN,0);
     405  Int_t nbins = 50;
     406
     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);
    419419
    420420}
     
    426426    return kFALSE;
    427427
    428   rmin = (rmin != 0.) ? rmin : 0.;
    429   rmax = (rmax != 0.) ? rmax : 16.;
    430 
    431   const Stat_t   entries     = fHBPT->GetEntries();
    432   const Double_t mu_guess    = fHBPT->GetBinCenter(fHBPT->GetMaximumBin());
     428  rmin = (rmin != 0.) ? rmin : 4.;
     429  rmax = (rmax != 0.) ? rmax : 9.;
     430
     431  const Stat_t   entries     = fHBlindPixelT->GetEntries();
     432  const Double_t mu_guess    = fHBlindPixelT->GetBinCenter(fHBlindPixelT->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   fHBPT->Fit("GausTime",opt);
     443  fHBlindPixelT->Fit(fTimeGausFit,opt);
     444
     445  rmin = fTimeGausFit->GetParameter(1) - 2.*fTimeGausFit->GetParameter(2);
     446  rmax = fTimeGausFit->GetParameter(1) + 2.*fTimeGausFit->GetParameter(2);
     447  fTimeGausFit->SetRange(rmin,rmax); 
     448
     449  fHBlindPixelT->Fit(fTimeGausFit,opt);
     450
    444451
    445452  fMeanT     = fTimeGausFit->GetParameter(2);
  • trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.h

    r2525 r2599  
    3232private:
    3333
    34   TH1I* fHBPQ;        //-> Histogram with the single Phe spectrum
    35   TH1F* fHBPErrQ;     //-> Variance of summed FADC slices
    36   TH1I* fHBPT;        //-> Variance of summed FADC slices
    37   TH1I* fHBPQvsN;     //-> Summed Charge vs. Event Nr.
     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.
    3838 
    3939  TF1 *fSinglePheFit;
    4040  TF1 *fTimeGausFit; 
    4141
    42   Axis_t  fBPQfirst;
    43   Axis_t  fBPQlast;
    44   Int_t   fBPQnbins;
     42  Axis_t  fBlindPixelQfirst;
     43  Axis_t  fBlindPixelQlast;
     44  Int_t   fBlindPixelQnbins;
    4545 
    46   Axis_t fErrBPQfirst;
    47   Axis_t fErrBPQlast;
    48   Int_t  fErrBPQnbins;
     46  Axis_t fErrBlindPixelQfirst;
     47  Axis_t fErrBlindPixelQlast;
     48  Int_t  fErrBlindPixelQnbins;
    4949
    5050  void ResetBin(Int_t i);
     
    5454  Bool_t fFitOK; 
    5555 
    56   BPFitFunc fgSinglePheFitFunc;     // In the beginning,
     56  BlindPixelFitFunc fgSinglePheFitFunc;     // In the beginning,
    5757  Int_t     fgSinglePheFitNPar;     // we want to be flexible using different functions
    5858
     
    8383  ~MHCalibrationBlindPixel();
    8484
    85   Bool_t FillBPQ(Int_t q)         { return fHBPQ->Fill(q) > -1;  } 
    86   Bool_t FillErrBPQ(Float_t errq) { return fHBPErrQ->Fill(errq) > -1; }
    87   Bool_t FillBPT(Int_t t)         { return fHBPT->Fill(t) > -1;  }
    88   Bool_t FillBPQvsN(Stat_t rq, Int_t t) { return fHBPQvsN->Fill(t,rq) > -1;  } 
     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;  } 
    8989 
    9090  const Double_t GetLambda()   const { return fLambda; }
     
    109109  const Double_t GetSigmaTErr()    const { return fSigmaTErr; }
    110110
    111   const TH1F *GetHErrQ() { return fHBPErrQ; }
    112   const TH1F *GetHErrQ() const { return fHBPErrQ; }
     111  const TH1F *GetHErrQ() { return fHBlindPixelErrQ; }
     112  const TH1F *GetHErrQ() const { return fHBlindPixelErrQ; }
    113113 
    114114  Bool_t SimulateSinglePhe(Double_t lambda,
     
    121121  Bool_t FitT(Axis_t rmin=0., Axis_t rmax=0.,Option_t *opt="R0+");
    122122
    123   void ChangeFitFunc(BPFitFunc fitfunc, Int_t par=5);
     123  void ChangeFitFunc(BlindPixelFitFunc fitfunc, Int_t par=5);
    124124
    125125
  • trunk/MagicSoft/Mars/mhist/MHCalibrationConfig.h

    r2533 r2599  
    1212
    1313// Global rejection criteria for the acceptance of a fit: Prob=0.01 == 99% Probability
    14 const Float_t gkProbLimit = 0.01;
     14const Float_t gkProbLimit = 0.001;
    1515
    1616// Starting number of bins for the histo:
     
    3030
    3131// typedef to the fitting functions for the blind pixel
    32 typedef Double_t (*BPFitFunc)(Double_t *, Double_t *);
     32typedef Double_t (*BlindPixelFitFunc)(Double_t *, Double_t *);
    3333
    3434#endif /* MARS_MHCalibrationBlindPixelConfig */
  • trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc

    r2581 r2599  
    6060// Default Constructor.
    6161//
    62 MHCalibrationPixel::MHCalibrationPixel(Int_t pix, const char *name, const char *title)
    63       : fPixId(pix),
     62MHCalibrationPixel::MHCalibrationPixel(const char *name, const char *title)
     63      : fPixId(-1),
    6464        fQGausFit(NULL),
    6565        fTGausFit(NULL),
    6666        fFitLegend(NULL),
    6767        fLowerFitRange(0.),
    68         fFitOK(kFALSE)
     68        fFitOK(kFALSE),
     69        fQChisquare(-1.),
     70        fQProb(-1.),
     71        fQNdf(-1),
     72        fTChisquare(-1.),
     73        fTProb(-1.),
     74        fTNdf(-1)
    6975{
    7076
     
    7278    fTitle = title ? title : "Fill the accumulated charges and times of all events and perform fits";
    7379
    74     TString qname  = "HQ";
    7580    TString qtitle = "Distribution of Summed FADC Slices Pixel ";
    76     qname  += pix;
    77     qtitle += pix;
    7881
    7982    // Create a large number of bins, later we will rebin
     
    8285    fQnbins = gkStartPixelBinNr;
    8386
    84     fHQ = new TH1I( qname.Data(),qtitle.Data(),
     87    fHQ = new TH1I("HQ",qtitle.Data(),
    8588                   fQnbins,fQfirst,fQlast);
    8689    fHQ->SetXTitle("Sum FADC Slices");
     
    8891    fHQ->Sumw2();
    8992
    90     TString tname  = "HT";
     93    fHQ->SetDirectory(NULL);
     94
    9195    TString ttitle = "Distribution of Mean Arrival Times Pixel ";
    92     tname  += pix;
    93     ttitle += pix;
    9496
    9597    Axis_t tfirst = -0.5;
     
    9799    Int_t nbins   = 16;
    98100
    99     fHT = new TH1I(tname.Data(),ttitle.Data(),
     101    fHT = new TH1I("HT",ttitle.Data(),
    100102                  nbins,tfirst,tlast);
    101103    fHT->SetXTitle("Mean Arrival Times [FADC slice nr]");
     
    103105    fHT->Sumw2();
    104106
    105     TString qvsnname  = "HQvsN";
     107    fHT->SetDirectory(NULL);
     108
    106109    TString qvsntitle = "Sum of Charges vs. Event Number Pixel ";
    107     qvsnname  += pix;
    108     qvsntitle += pix;
    109110
    110111    // We define a reasonable number and later enlarge it if necessary
     
    113114    Axis_t nlast  = (Axis_t)nbins - 0.5;
    114115
    115     fHQvsN = new TH1I(qvsnname.Data(),qvsntitle.Data(),
     116    fHQvsN = new TH1I("HQvsN",qvsntitle.Data(),
    116117                     nbins,nfirst,nlast);
    117118    fHQvsN->SetXTitle("Event Nr.");
    118119    fHQvsN->SetYTitle("Sum of FADC slices");
    119120
    120     fQChisquare = -1.;
    121     fQProb      = -1.;
    122     fQNdf       = -1;
    123    
    124     fTChisquare = -1.;
    125     fTProb      = -1.;
    126     fTNdf       = -1;
     121    fHQvsN->SetDirectory(NULL);
    127122
    128123}
     
    144139}
    145140
     141
     142void MHCalibrationPixel::ChangeHistId(Int_t id)
     143{
     144
     145  fPixId = id;
     146 
     147  TString nameQ = TString(fHQ->GetName());
     148  nameQ += id;
     149  fHQ->SetName(nameQ.Data());
     150
     151  TString nameT = TString(fHT->GetName());
     152  nameT += id;
     153  fHT->SetName(nameT.Data());
     154
     155  TString nameQvsN  = TString(fHQvsN->GetName());
     156  nameQvsN += id;
     157  fHQvsN->SetName(nameQvsN.Data());
     158}
     159
     160
    146161void MHCalibrationPixel::Reset()
    147162{
     
    206221
    207222  char line8[32];
    208   sprintf(line8,"Probability: %4.2f ",fQProb);
     223  sprintf(line8,"Probability: %4.3f ",fQProb);
    209224  fFitLegend->AddText(line8);
    210225
     
    266281    fHT->DrawCopy(opt);
    267282
    268     if (fHT->GetFunction("GausTime"))
     283    if (fTGausFit)
    269284      {
    270         TF1 *tfit = fHT->GetFunction("GausTime");
    271         if (tfit->GetProb() < 0.01)
    272           tfit->SetLineColor(kRed);
     285        if (fTChisquare > 1.)
     286          fTGausFit->SetLineColor(kRed);
    273287        else
    274           tfit->SetLineColor(kGreen);
    275 
    276         tfit->DrawCopy("same");
     288          fTGausFit->SetLineColor(kGreen);
     289
     290        fTGausFit->DrawCopy("same");
    277291        c->Modified();
    278292        c->Update();
     
    290304Bool_t MHCalibrationPixel::FitT(Axis_t rmin, Axis_t rmax, Option_t *option)
    291305{
    292  
     306
    293307  if (fTGausFit)
    294308    return kFALSE;
    295309
    296   rmin = (rmin != 0.) ? rmin : -0.5;
    297   rmax = (rmax != 0.) ? rmax : 15.5;
     310  rmin = (rmin != 0.) ? rmin : 4.;
     311  rmax = (rmax != 0.) ? rmax : 9.;
    298312
    299313  const Stat_t   entries     = fHT->GetEntries();
     
    302316  const Double_t area_guess  = entries/gkSq2Pi;
    303317
    304   fTGausFit = new TF1("GausTime","gaus",rmin,rmax); 
     318  TString name = TString("GausTime");
     319  name += fPixId;
     320  fTGausFit = new TF1(name.Data(),"gaus",rmin,rmax); 
    305321
    306322  if (!fTGausFit)
     
    314330  fTGausFit->SetParLimits(0,0.,entries);
    315331  fTGausFit->SetParLimits(1,rmin,rmax);
    316   fTGausFit->SetParLimits(2,0.,rmax-rmin);
    317 
    318   fHT->Fit("GausTime",option);
     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);
    319342
    320343  fTChisquare = fTGausFit->GetChisquare();
     
    324347  fTSigma     = fTGausFit->GetParameter(2);
    325348
    326   if (fTProb < gkProbLimit)
     349  if (fTChisquare > 1.)
    327350    {
    328351      *fLog << warn << "Fit of the Arrival times failed ! " << endl;
     
    344367  //
    345368  Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fQfirst;
     369  Axis_t rmax = 0.;
    346370
    347371  //
     
    352376  const Double_t ar_guess = entries/gkSq2Pi;
    353377  const Double_t mu_guess = fHQ->GetBinCenter(fHQ->GetMaximumBin());
    354   const Double_t si_guess = mu_guess/500.;
    355 
    356   fQGausFit = new TF1("QGausFit","gaus",rmin,fQlast);
     378  const Double_t si_guess = mu_guess/50.;
     379
     380  TString name = TString("QGausFit");
     381  name += fPixId;
     382
     383  fQGausFit = new TF1(name.Data(),"gaus",rmin,fQlast);
    357384
    358385  if (!fQGausFit)
     
    367394  fQGausFit->SetParLimits(1,rmin,fQlast);
    368395  fQGausFit->SetParLimits(2,0.,fQlast-rmin);
    369 
    370   fHQ->Fit("QGausFit",option);
     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);
    371412
    372413  fQChisquare = fQGausFit->GetChisquare();
     
    399440{
    400441
    401   //
    402   // The number 100 is necessary because it is the internal binning
    403   // of ROOT functions. A call to SetNpx() does NOT help
    404   // If you find another solution which WORKS!!, please tell me!!
    405   //
    406   Int_t nbins = 100;
     442  Int_t nbins = 50;
    407443
    408444  CutEdges(fHQ,nbins);
  • trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.h

    r2581 r2599  
    6868public:
    6969
    70   MHCalibrationPixel(Int_t pix=-1, const char *name=NULL, const char *title=NULL);
     70  MHCalibrationPixel(const char *name=NULL, const char *title=NULL);
    7171  ~MHCalibrationPixel();
     72
     73  void ChangeHistId(Int_t i);
    7274 
    7375  Bool_t SetupFill(const MParList *pList);
     
    105107  const TH1I *GetHQvsN() const { return fHQvsN; }
    106108 
    107   Bool_t FitQ(Option_t *option="RQ0+"); 
    108   Bool_t FitT(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0+");   
     109  Bool_t FitQ(Option_t *option="RQ0"); 
     110  Bool_t FitT(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0");   
    109111
    110112  virtual void Draw(Option_t *option="");
Note: See TracChangeset for help on using the changeset viewer.