Ignore:
Timestamp:
12/09/03 18:25:21 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
8 edited

Legend:

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

    r2603 r2627  
    6969
    7070    // Create a large number of bins, later we will rebin
    71     fBlindPixelChargefirst = 0;
     71    fBlindPixelChargefirst = -1000.;
    7272    fBlindPixelChargelast  = gkStartBlindPixelBinNr;
    73     fBlindPixelChargenbins = gkStartBlindPixelBinNr;
    74 
    75     fHBlindPixelCharge = new TH1I("HBlindPixelCharge","Distribution of Summed FADC Slices",fBlindPixelChargenbins,fBlindPixelChargefirst,fBlindPixelChargelast);
     73    fBlindPixelChargenbins = gkStartBlindPixelBinNr+(int)fBlindPixelChargefirst;
     74
     75    fHBlindPixelCharge = new TH1F("HBlindPixelCharge","Distribution of Summed FADC Slices",
     76                                  fBlindPixelChargenbins,fBlindPixelChargefirst,fBlindPixelChargelast);
    7677    fHBlindPixelCharge->SetXTitle("Sum FADC Slices");
    7778    fHBlindPixelCharge->SetYTitle("Nr. of events");
     
    313314  const Double_t lambda_guess = 0.2;
    314315  const Double_t mu_0_guess = fHBlindPixelCharge->GetBinCenter(fHBlindPixelCharge->GetMaximumBin());
    315   const Double_t si_0_guess = mu_0_guess/10.;
     316  const Double_t si_0_guess = mu_0_guess/5.;
    316317  const Double_t mu_1_guess = mu_0_guess + 50.;
    317318  const Double_t si_1_guess = si_0_guess + si_0_guess;
  • trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.h

    r2603 r2627  
    3232private:
    3333
    34   TH1I* fHBlindPixelCharge;        //-> Histogram with the single Phe spectrum
     34  TH1F* fHBlindPixelCharge;        //-> Histogram with the single Phe spectrum
    3535  TH1F* fHBlindPixelErrCharge;     //-> Variance of summed FADC slices
    3636  TH1I* fHBlindPixelTime;        //-> Variance of summed FADC slices
     
    8383  ~MHCalibrationBlindPixel();
    8484
    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;  }
     85  Bool_t FillBlindPixelCharge(Float_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;  }
    8888  Bool_t FillBlindPixelChargevsN(Stat_t rq, Int_t t) { return fHBlindPixelChargevsN->Fill(t,rq) > -1;  } 
    8989 
     
    123123  void ChangeFitFunc(BlindPixelFitFunc fitfunc, Int_t par=5);
    124124
    125 
    126125  void CutAllEdges();
    127126  void Draw(Option_t *option="");
    128127
    129   ClassDef(MHCalibrationBlindPixel, 0)
     128  ClassDef(MHCalibrationBlindPixel, 1)
    130129};
    131130
  • trunk/MagicSoft/Mars/mhist/MHCalibrationConfig.h

    r2603 r2627  
    77//                                                                         //
    88// Contains all configuration data of the Calibration                      //
    9 //                                                                         //
     9//                       i                                                  //
    1010/////////////////////////////////////////////////////////////////////////////
    1111
  • trunk/MagicSoft/Mars/mhist/MHCalibrationPINDiode.cc

    r2603 r2627  
    6767
    6868    // Create a large number of bins, later we will rebin
    69     fChargeFirst = 0;
    70     fChargeLast  = gkStartPINDiodeBinNr;
    71     fChargeNbins = gkStartPINDiodeBinNr;
     69    fChargeFirstHiGain = -1000.;
     70    fChargeLastHiGain  = gkStartPINDiodeBinNr;
     71    fChargeNbinsHiGain = gkStartPINDiodeBinNr;
    7272
    73     fHPCharge = new TH1I("HPCharge","Distribution of Summed FADC Slices",fChargeNbins,fChargeFirst,fChargeLast);
     73    fHPCharge = new TH1I("HPCharge","Distribution of Summed FADC Slices",
     74                         fChargeNbinsHiGain,fChargeFirstHiGain,fChargeLastHiGain);
    7475    fHPCharge->SetXTitle("Sum FADC Slices");
    7576    fHPCharge->SetYTitle("Nr. of events");
  • trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc

    r2603 r2627  
    6565        fTimeGausFit(NULL),
    6666        fFitLegend(NULL),
    67         fLowerFitRange(0.),
     67        fLowerFitRange(-2000.),
     68        fChargeFirstHiGain(-2000.5),
     69        fChargeLastHiGain(9999.5),
     70        fChargeNbinsHiGain(12000),
     71        fChargeFirstLoGain(-2000.5),
     72        fChargeLastLoGain(9999.5),
     73        fChargeNbinsLoGain(1200),
    6874        fFitOK(kFALSE),
    6975        fChargeChisquare(-1.),
     
    7278        fTimeChisquare(-1.),
    7379        fTimeProb(-1.),
    74         fTimeNdf(-1)
     80        fTimeNdf(-1),
     81        fUseLoGain(kFALSE)
    7582{
    7683
     
    7986
    8087    // Create a large number of bins, later we will rebin
    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);
     88    fHChargeHiGain = new TH1F("HChargeHiGain","Distribution of Summed FADC Hi Gain Slices Pixel ",
     89                              fChargeNbinsHiGain,fChargeFirstHiGain,fChargeLastHiGain);
     90    fHChargeHiGain->SetXTitle("Sum FADC Slices (Hi Gain)");
     91    fHChargeHiGain->SetYTitle("Nr. of events");
     92    fHChargeHiGain->Sumw2();
     93
     94    fHChargeHiGain->SetDirectory(NULL);
     95
     96    fHChargeLoGain = new TH1F("HChargeLoGain","Distribution of Summed FADC Lo Gain Slices Pixel ",
     97                              fChargeNbinsLoGain,fChargeFirstLoGain,fChargeLastLoGain);
     98    fHChargeLoGain->SetXTitle("Sum FADC Slices (Lo Gain)");
     99    fHChargeLoGain->SetYTitle("Nr. of events");
     100    fHChargeLoGain->Sumw2();
     101
     102    fHChargeLoGain->SetDirectory(NULL);
    92103
    93104    Axis_t tfirst = -0.5;
     
    95106    Int_t  ntbins = 16;
    96107
    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);
    104 
    105     TString qvsntitle = "Sum of Charges vs. Event Number Pixel ";
     108    fHTimeHiGain = new TH1I("HTimeHiGain","Distribution of Mean Arrival Hi Gain Times Pixel ",
     109                            ntbins,tfirst,tlast);
     110    fHTimeHiGain->SetXTitle("Mean Arrival Times [Hi Gain FADC slice nr]");
     111    fHTimeHiGain->SetYTitle("Nr. of events");
     112    fHTimeHiGain->Sumw2();
     113
     114    fHTimeHiGain->SetDirectory(NULL);
     115
     116    fHTimeLoGain = new TH1I("HTimeLoGain","Distribution of Mean Arrival Lo Gain Times Pixel ",
     117                            ntbins,tfirst,tlast);
     118    fHTimeLoGain->SetXTitle("Mean Arrival Times [Lo Gain FADC slice nr]");
     119    fHTimeLoGain->SetYTitle("Nr. of events");
     120    fHTimeLoGain->Sumw2();
     121
     122    fHTimeLoGain->SetDirectory(NULL);
    106123
    107124    // We define a reasonable number and later enlarge it if necessary
     
    110127    Axis_t nlast  = (Axis_t)nqbins - 0.5;
    111128
    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);
     129    fHChargevsNHiGain = new TH1I("HChargevsNHiGain","Sum of Hi Gain Charges vs. Event Number Pixel ",
     130                                 nqbins,nfirst,nlast);
     131    fHChargevsNHiGain->SetXTitle("Event Nr.");
     132    fHChargevsNHiGain->SetYTitle("Sum of Hi Gain FADC slices");
     133
     134    fHChargevsNHiGain->SetDirectory(NULL);
     135
     136    fHChargevsNLoGain = new TH1I("HChargevsNLoGain","Sum of Lo Gain Charges vs. Event Number Pixel ",
     137                                 nqbins,nfirst,nlast);
     138    fHChargevsNLoGain->SetXTitle("Event Nr.");
     139    fHChargevsNLoGain->SetYTitle("Sum of Lo Gain FADC slices");
     140
     141    fHChargevsNLoGain->SetDirectory(NULL);
    118142
    119143}
     
    122146{
    123147
    124   delete fHCharge;
    125   delete fHTime;
    126   delete fHChargevsN;
     148  delete fHChargeHiGain;
     149  delete fHTimeHiGain;
     150  delete fHChargevsNHiGain;
     151
     152  delete fHChargeLoGain;
     153  delete fHTimeLoGain;
     154  delete fHChargevsNLoGain;
    127155
    128156  if (fChargeGausFit)
     
    141169  fPixId = id;
    142170 
    143   TString nameQ = TString(fHCharge->GetName());
    144   nameQ += id;
    145   fHCharge->SetName(nameQ.Data());
    146 
    147   TString nameT = TString(fHTime->GetName());
    148   nameT += id;
    149   fHTime->SetName(nameT.Data());
    150 
    151   TString nameQvsN  = TString(fHChargevsN->GetName());
    152   nameQvsN += id;
    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());
     171  TString nameQHiGain = TString(fHChargeHiGain->GetName());
     172  nameQHiGain += id;
     173  fHChargeHiGain->SetName(nameQHiGain.Data());
     174
     175  TString nameTHiGain = TString(fHTimeHiGain->GetName());
     176  nameTHiGain += id;
     177  fHTimeHiGain->SetName(nameTHiGain.Data());
     178
     179  TString nameQvsNHiGain  = TString(fHChargevsNHiGain->GetName());
     180  nameQvsNHiGain += id;
     181  fHChargevsNHiGain->SetName(nameQvsNHiGain.Data());
     182
     183  TString titleQHiGain = TString(fHChargeHiGain->GetTitle());
     184  titleQHiGain += id;
     185  fHChargeHiGain->SetTitle(titleQHiGain.Data());
     186
     187  TString titleTHiGain = TString(fHTimeHiGain->GetTitle());
     188  titleTHiGain += id;
     189  fHTimeHiGain->SetTitle(titleTHiGain.Data());
     190
     191  TString titleQvsNHiGain  = TString(fHChargevsNHiGain->GetTitle());
     192  titleQvsNHiGain += id;
     193  fHChargevsNHiGain->SetTitle(titleQvsNHiGain.Data());
     194
     195
     196  TString nameQLoGain = TString(fHChargeLoGain->GetName());
     197  nameQLoGain += id;
     198  fHChargeLoGain->SetName(nameQLoGain.Data());
     199
     200  TString nameTLoGain = TString(fHTimeLoGain->GetName());
     201  nameTLoGain += id;
     202  fHTimeLoGain->SetName(nameTLoGain.Data());
     203
     204  TString nameQvsNLoGain  = TString(fHChargevsNLoGain->GetName());
     205  nameQvsNLoGain += id;
     206  fHChargevsNLoGain->SetName(nameQvsNLoGain.Data());
     207
     208  TString titleQLoGain = TString(fHChargeLoGain->GetTitle());
     209  titleQLoGain += id;
     210  fHChargeLoGain->SetTitle(titleQLoGain.Data());
     211
     212  TString titleTLoGain = TString(fHTimeLoGain->GetTitle());
     213  titleTLoGain += id;
     214  fHTimeLoGain->SetTitle(titleTLoGain.Data());
     215
     216  TString titleQvsNLoGain  = TString(fHChargevsNLoGain->GetTitle());
     217  titleQvsNLoGain += id;
     218  fHChargevsNLoGain->SetTitle(titleQvsNLoGain.Data());
    166219}
    167220
     
    170223{
    171224 
    172   for (Int_t i = fHCharge->FindBin(fChargeFirst);
    173        i <= fHCharge->FindBin(fChargeLast); i++)
    174     fHCharge->SetBinContent(i, 1.e-20);
     225  for (Int_t i = fHChargeHiGain->FindBin(fChargeFirstHiGain);
     226       i <= fHChargeHiGain->FindBin(fChargeLastHiGain); i++)
     227    fHChargeHiGain->SetBinContent(i, 1.e-20);
    175228
    176229  for (Int_t i = 0; i < 16; i++)
    177       fHTime->SetBinContent(i, 1.e-20);
    178  
    179   fChargeLast     = 9999.5;
    180 
    181   fHCharge->GetXaxis()->SetRangeUser(0.,fChargeLast);
     230      fHTimeHiGain->SetBinContent(i, 1.e-20);
     231 
     232  fChargeLastHiGain     = 9999.5;
     233
     234  fHChargeLoGain->GetXaxis()->SetRangeUser(0.,fChargeLastLoGain);
     235
     236 for (Int_t i = fHChargeLoGain->FindBin(fChargeFirstLoGain);
     237       i <= fHChargeLoGain->FindBin(fChargeLastLoGain); i++)
     238    fHChargeLoGain->SetBinContent(i, 1.e-20);
     239
     240  for (Int_t i = 0; i < 16; i++)
     241      fHTimeLoGain->SetBinContent(i, 1.e-20);
     242 
     243  fChargeLastLoGain     = 9999.5;
     244
     245  fHChargeLoGain->GetXaxis()->SetRangeUser(0.,fChargeLastLoGain);
    182246
    183247  return;
     
    192256{
    193257
    194   fHCharge->Reset();
    195   fHTime->Reset();
     258  fHChargeHiGain->Reset();
     259  fHTimeHiGain->Reset();
     260  fHChargeLoGain->Reset();
     261  fHTimeLoGain->Reset();
    196262
    197263  return kTRUE;
     
    240306  fFitLegend->AddText(line8);
    241307
    242 
    243308  if (fFitOK)
    244309    fFitLegend->AddText("Result of the Fit: OK");
     
    266331    gROOT->SetSelectedPad(NULL);
    267332
    268     c->Divide(2,2);
     333    c->Divide(2,4);
    269334
    270335    c->cd(1);
     
    273338    gPad->SetTicks();
    274339
    275     fHCharge->Draw(opt);
    276    
    277     if (fChargeGausFit)
    278       {
    279         if (fFitOK)
    280           fChargeGausFit->SetLineColor(kGreen);         
    281         else
    282           fChargeGausFit->SetLineColor(kRed);
    283 
    284         fChargeGausFit->Draw("same");
    285         c->Modified();
    286         c->Update();
    287       }
    288 
    289    
    290     c->cd(2);
    291     DrawLegend();
    292     c->Update();
    293 
    294     c->cd(3);
    295     gStyle->SetOptStat(1111111);
    296 
    297     gPad->SetLogy(1);
    298     fHTime->Draw(opt);
    299 
    300     if (fTimeGausFit)
    301       {
    302         if (fTimeChisquare > 1.)
    303           fTimeGausFit->SetLineColor(kRed);
    304         else
    305           fTimeGausFit->SetLineColor(kGreen);
    306 
    307         fTimeGausFit->Draw("same");
    308         c->Modified();
    309         c->Update();
    310       }
    311    
     340    fHChargeHiGain->DrawCopy(opt);
     341
    312342    c->Modified();
    313343    c->Update();
    314344
    315     c->cd(4);
    316     fHChargevsN->Draw(opt);
    317 }
    318 
    319 
    320 
    321 Bool_t MHCalibrationPixel::FitTime(Axis_t rmin, Axis_t rmax, Option_t *option)
     345    if (fUseLoGain)
     346      {
     347        c->cd(2);
     348        gPad->SetLogy(1);
     349        gPad->SetTicks();
     350        fHChargeLoGain->DrawCopy(opt);
     351   
     352        if (fChargeGausFit)
     353          {
     354            if (fFitOK)
     355              fChargeGausFit->SetLineColor(kGreen);         
     356            else
     357              fChargeGausFit->SetLineColor(kRed);
     358           
     359            fChargeGausFit->DrawCopy("same");
     360          }
     361
     362        c->cd(4);
     363        DrawLegend();
     364
     365      }
     366    else
     367      {
     368        if (fChargeGausFit)
     369          {
     370            if (fFitOK)
     371              fChargeGausFit->SetLineColor(kGreen);         
     372            else
     373              fChargeGausFit->SetLineColor(kRed);
     374           
     375            fChargeGausFit->DrawCopy("same");
     376          }
     377        c->cd(2);
     378        gPad->SetLogy(1);
     379        gPad->SetTicks();
     380        fHChargeLoGain->DrawCopy(opt);
     381        c->cd(3);
     382        DrawLegend();
     383      }
     384
     385    c->Modified();
     386    c->Update();
     387   
     388    c->cd(5);
     389    gStyle->SetOptStat(1111111);
     390
     391    gPad->SetLogy(1);
     392    fHTimeHiGain->DrawCopy(opt);
     393    c->Modified();
     394    c->Update();
     395
     396    if (fUseLoGain)
     397      {
     398
     399        c->cd(6);
     400        gPad->SetLogy(1);
     401        fHTimeLoGain->DrawCopy(opt);
     402        c->Modified();
     403        c->Update();
     404       
     405        if (fTimeGausFit)
     406          {
     407            if (fTimeChisquare > 1.)
     408              fTimeGausFit->SetLineColor(kRed);
     409            else
     410              fTimeGausFit->SetLineColor(kGreen);
     411           
     412            fTimeGausFit->DrawCopy("same");
     413          }
     414      }
     415    else
     416      { 
     417        if (fTimeGausFit)
     418          {
     419            if (fTimeChisquare > 1.)
     420              fTimeGausFit->SetLineColor(kRed);
     421            else
     422              fTimeGausFit->SetLineColor(kGreen);
     423           
     424            fTimeGausFit->DrawCopy("same");
     425            c->Modified();
     426            c->Update();
     427          }
     428
     429        c->cd(6);
     430        gPad->SetLogy(1);
     431        fHTimeLoGain->DrawCopy(opt);   
     432      }
     433    c->Modified();
     434    c->Update();
     435   
     436    c->cd(7);
     437    fHChargevsNHiGain->DrawCopy(opt);
     438    c->Modified();
     439    c->Update();
     440
     441    c->cd(8);
     442    fHChargevsNLoGain->DrawCopy(opt);
     443    c->Modified();
     444    c->Update();
     445
     446}
     447
     448
     449
     450Bool_t MHCalibrationPixel::FitTimeHiGain(Axis_t rmin, Axis_t rmax, Option_t *option)
    322451{
    323452
     
    328457  rmax = (rmax != 0.) ? rmax : 9.;
    329458
    330   const Stat_t   entries     = fHTime->GetEntries();
    331   const Double_t mu_guess    = fHTime->GetBinCenter(fHTime->GetMaximumBin());
     459  const Stat_t   entries     = fHTimeHiGain->GetEntries();
     460  const Double_t mu_guess    = fHTimeHiGain->GetBinCenter(fHTimeHiGain->GetMaximumBin());
    332461  const Double_t sigma_guess = (rmax - rmin)/2.;
    333462  const Double_t area_guess  = entries/gkSq2Pi;
     
    350479  fTimeGausFit->SetRange(rmin,rmax);
    351480
    352   fHTime->Fit(fTimeGausFit,option);
     481  fHTimeHiGain->Fit(fTimeGausFit,option);
    353482
    354483  rmin = fTimeGausFit->GetParameter(1) - 3.*fTimeGausFit->GetParameter(2);
     
    356485  fTimeGausFit->SetRange(rmin,rmax); 
    357486
    358   fHTime->Fit(fTimeGausFit,option);
     487  fHTimeHiGain->Fit(fTimeGausFit,option);
    359488
    360489  fTimeChisquare = fTimeGausFit->GetChisquare();
     
    375504}
    376505
    377 Bool_t MHCalibrationPixel::FitCharge(Option_t *option)
     506Bool_t MHCalibrationPixel::FitTimeLoGain(Axis_t rmin, Axis_t rmax, Option_t *option)
     507{
     508
     509  if (fTimeGausFit)
     510    return kFALSE;
     511
     512  rmin = (rmin != 0.) ? rmin : 4.;
     513  rmax = (rmax != 0.) ? rmax : 9.;
     514
     515  const Stat_t   entries     = fHTimeLoGain->GetEntries();
     516  const Double_t mu_guess    = fHTimeLoGain->GetBinCenter(fHTimeLoGain->GetMaximumBin());
     517  const Double_t sigma_guess = (rmax - rmin)/2.;
     518  const Double_t area_guess  = entries/gkSq2Pi;
     519
     520  TString name = TString("GausTime");
     521  name += fPixId;
     522  fTimeGausFit = new TF1(name.Data(),"gaus",rmin,rmax); 
     523
     524  if (!fTimeGausFit)
     525    {
     526    *fLog << err << dbginf << "Could not create fit function for Gauss fit" << endl;
     527    return kFALSE;
     528    }
     529
     530  fTimeGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
     531  fTimeGausFit->SetParNames("Area","#mu","#sigma");
     532  fTimeGausFit->SetParLimits(0,0.,entries);
     533  fTimeGausFit->SetParLimits(1,rmin,rmax);
     534  fTimeGausFit->SetParLimits(2,0.,(rmax-rmin));
     535  fTimeGausFit->SetRange(rmin,rmax);
     536
     537  fHTimeLoGain->Fit(fTimeGausFit,option);
     538
     539  rmin = fTimeGausFit->GetParameter(1) - 3.*fTimeGausFit->GetParameter(2);
     540  rmax = fTimeGausFit->GetParameter(1) + 3.*fTimeGausFit->GetParameter(2);
     541  fTimeGausFit->SetRange(rmin,rmax); 
     542
     543  fHTimeLoGain->Fit(fTimeGausFit,option);
     544
     545  fTimeChisquare = fTimeGausFit->GetChisquare();
     546  fTimeNdf       = fTimeGausFit->GetNDF();
     547  fTimeProb      = fTimeGausFit->GetProb();
     548
     549  fTimeMean      = fTimeGausFit->GetParameter(1);
     550  fTimeSigma     = fTimeGausFit->GetParameter(2);
     551
     552  if (fTimeChisquare > 1.)
     553    {
     554      *fLog << warn << "Fit of the Arrival times failed ! " << endl;
     555      return kFALSE;
     556    }
     557 
     558  return kTRUE;
     559
     560}
     561
     562Bool_t MHCalibrationPixel::FitChargeHiGain(Option_t *option)
    378563{
    379564
     
    384569  // Get the fitting ranges
    385570  //
    386   Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fChargeFirst;
     571  Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fChargeFirstHiGain;
    387572  Axis_t rmax = 0.;
    388573
     
    391576  // otherwise the fit goes gaga because of high number of dimensions ...
    392577  //
    393   const Stat_t   entries    = fHCharge->GetEntries();
     578  const Stat_t   entries    = fHChargeHiGain->GetEntries();
    394579  const Double_t area_guess = entries/gkSq2Pi;
    395   const Double_t mu_guess   = fHCharge->GetBinCenter(fHCharge->GetMaximumBin());
     580  const Double_t mu_guess   = fHChargeHiGain->GetBinCenter(fHChargeHiGain->GetMaximumBin());
    396581  const Double_t sigma_guess = mu_guess/15.;
    397582
     
    399584  name += fPixId;
    400585
    401   fChargeGausFit = new TF1(name.Data(),"gaus",rmin,fChargeLast);
     586  fChargeGausFit = new TF1(name.Data(),"gaus",rmin,fChargeLastHiGain);
    402587
    403588  if (!fChargeGausFit)
     
    410595  fChargeGausFit->SetParNames("Area","#mu","#sigma");
    411596  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);
     597  fChargeGausFit->SetParLimits(1,rmin,fChargeLastHiGain);
     598  fChargeGausFit->SetParLimits(2,0.,fChargeLastHiGain-rmin);
     599  fChargeGausFit->SetRange(rmin,fChargeLastHiGain);
     600
     601  fHChargeHiGain->Fit(fChargeGausFit,option);
    417602 
    418603  Axis_t rtry = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
     
    422607  fChargeGausFit->SetRange(rmin,rmax); 
    423608
    424   fHCharge->Fit(fChargeGausFit,option);
     609  fHChargeHiGain->Fit(fChargeGausFit,option);
    425610
    426611  //  rmin = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
     
    428613  //  fChargeGausFit->SetRange(rmin,rmax); 
    429614
    430   // fHCharge->Fit(fChargeGausFit,option);
     615  // fHChargeHiGain->Fit(fChargeGausFit,option);
    431616
    432617  fChargeChisquare = fChargeGausFit->GetChisquare();
     
    455640}
    456641
     642
     643Bool_t MHCalibrationPixel::FitChargeLoGain(Option_t *option)
     644{
     645
     646  if (fChargeGausFit)
     647    return kFALSE;
     648
     649  //
     650  // Get the fitting ranges
     651  //
     652  Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fChargeFirstLoGain;
     653  Axis_t rmax = 0.;
     654
     655  //
     656  // First guesses for the fit (should be as close to reality as possible,
     657  // otherwise the fit goes gaga because of high number of dimensions ...
     658  //
     659  const Stat_t   entries    = fHChargeLoGain->GetEntries();
     660  const Double_t area_guess = entries/gkSq2Pi;
     661  const Double_t mu_guess   = fHChargeLoGain->GetBinCenter(fHChargeLoGain->GetMaximumBin());
     662  const Double_t sigma_guess = mu_guess/15.;
     663
     664  TString name = TString("ChargeGausFit");
     665  name += fPixId;
     666
     667  fChargeGausFit = new TF1(name.Data(),"gaus",rmin,fChargeLastLoGain);
     668
     669  if (!fChargeGausFit)
     670    {
     671    *fLog << err << dbginf << "Could not create fit function for Gauss fit" << endl;
     672    return kFALSE;
     673    }
     674 
     675  fChargeGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
     676  fChargeGausFit->SetParNames("Area","#mu","#sigma");
     677  fChargeGausFit->SetParLimits(0,0.,entries);
     678  fChargeGausFit->SetParLimits(1,rmin,fChargeLastLoGain);
     679  fChargeGausFit->SetParLimits(2,0.,fChargeLastLoGain-rmin);
     680  fChargeGausFit->SetRange(rmin,fChargeLastLoGain);
     681
     682  fHChargeLoGain->Fit(fChargeGausFit,option);
     683 
     684  Axis_t rtry = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
     685 
     686  rmin = (rtry < rmin ? rmin : rtry);
     687  rmax = fChargeGausFit->GetParameter(1) + 2.5*fChargeGausFit->GetParameter(2);
     688  fChargeGausFit->SetRange(rmin,rmax); 
     689
     690  fHChargeLoGain->Fit(fChargeGausFit,option);
     691
     692  //  rmin = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
     693  //  rmax = fChargeGausFit->GetParameter(1) + 2.5*fChargeGausFit->GetParameter(2);
     694  //  fChargeGausFit->SetRange(rmin,rmax); 
     695
     696  // fHChargeLoGain->Fit(fChargeGausFit,option);
     697
     698  fChargeChisquare = fChargeGausFit->GetChisquare();
     699  fChargeNdf       = fChargeGausFit->GetNDF();
     700  fChargeProb      = fChargeGausFit->GetProb();
     701  fChargeMean      = fChargeGausFit->GetParameter(1);
     702  fChargeMeanErr   = fChargeGausFit->GetParError(1);
     703  fChargeSigma     = fChargeGausFit->GetParameter(2);
     704  fChargeSigmaErr  = fChargeGausFit->GetParError(2);
     705
     706  //
     707  // The fit result is accepted under condition
     708  // The Probability is greater than gkProbLimit (default 0.01 == 99%)
     709  //
     710  if (fChargeProb < gkProbLimit)
     711    {
     712      *fLog << warn << "Prob: " << fChargeProb << " is smaller than the allowed value: " << gkProbLimit << endl;
     713      fFitOK = kFALSE;
     714      return kFALSE;
     715    }
     716 
     717 
     718  fFitOK = kTRUE;
     719   
     720  return kTRUE;
     721}
     722
    457723 
    458724void MHCalibrationPixel::CutAllEdges()
    459725{
    460726
    461   Int_t nbins = 50;
    462 
    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);
     727  Int_t nbins = 30;
     728
     729  CutEdges(fHChargeHiGain,nbins);
     730
     731  fChargeFirstHiGain = fHChargeHiGain->GetBinLowEdge(fHChargeHiGain->GetXaxis()->GetFirst());
     732  fChargeLastHiGain  = fHChargeHiGain->GetBinLowEdge(fHChargeHiGain->GetXaxis()->GetLast())
     733                      +fHChargeHiGain->GetBinWidth(0);
     734  fChargeNbinsHiGain = nbins;
     735
     736  CutEdges(fHChargeLoGain,nbins);
     737
     738  fChargeFirstLoGain = fHChargeLoGain->GetBinLowEdge(fHChargeLoGain->GetXaxis()->GetFirst());
     739  fChargeLastLoGain  = fHChargeLoGain->GetBinLowEdge(fHChargeLoGain->GetXaxis()->GetLast())
     740                      +fHChargeLoGain->GetBinWidth(0);
     741  fChargeNbinsLoGain = nbins;
     742
     743  CutEdges(fHChargevsNHiGain,0);
     744  CutEdges(fHChargevsNLoGain,0);
    470745
    471746}
  • trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.h

    r2603 r2627  
    3131protected:
    3232
    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.
     33  TH1F* fHChargeHiGain;              //-> Summed FADC slices
     34  TH1I* fHTimeHiGain;                //-> Mean arrival time in number of FADC sice
     35  TH1I* fHChargevsNHiGain;           //-> Summed Charge vs. Event Nr.
     36 
     37  TH1F* fHChargeLoGain;              //-> Summed FADC slices
     38  TH1I* fHTimeLoGain;                //-> Mean arrival time in number of FADC sice
     39  TH1I* fHChargevsNLoGain;           //-> Summed Charge vs. Event Nr.
    3640 
    3741  TF1* fChargeGausFit;
     
    4145 
    4246  Axis_t  fLowerFitRange;
    43   Axis_t  fChargeFirst;
    44   Axis_t  fChargeLast;
    45   Int_t   fChargeNbins;
     47  Axis_t  fChargeFirstHiGain;
     48  Axis_t  fChargeLastHiGain;
     49  Int_t   fChargeNbinsHiGain;
     50
     51  Axis_t  fChargeFirstLoGain;
     52  Axis_t  fChargeLastLoGain;
     53  Int_t   fChargeNbinsLoGain;
    4654
    4755  Bool_t fFitOK;
     
    6270  Double_t fTimeMean;
    6371  Double_t fTimeSigma;
     72
     73  Bool_t fUseLoGain;
    6474 
    6575  virtual void DrawLegend();
     
    7585  Bool_t Fill(const MParContainer *, const Stat_t w=1) { return kTRUE; }
    7686
    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; }
     87  Bool_t FillChargeLoGain(Float_t q)             { return fHChargeLoGain->Fill(q)      > -1; }
     88  Bool_t FillTimeLoGain(Int_t t)                 { return fHTimeLoGain->Fill(t)        > -1; }
     89  Bool_t FillChargevsNLoGain(Float_t q, Int_t n) { return fHChargevsNLoGain->Fill(n,q) > -1; }
    8090
    81   const TH1I *GetHCharge()                 { return fHCharge;    }
    82   const TH1I *GetHCharge() const           { return fHCharge;    }
     91  Bool_t FillChargeHiGain(Float_t q)             { return fHChargeHiGain->Fill(q)      > -1; }
     92  Bool_t FillTimeHiGain(Int_t t)                 { return fHTimeHiGain->Fill(t)        > -1; }
     93  Bool_t FillChargevsNHiGain(Float_t q, Int_t n) { return fHChargevsNHiGain->Fill(n,q) > -1; }
     94
     95  void SetUseLoGain()                      { fUseLoGain = kTRUE; }
     96
     97  const TH1F *GetHCharge()                 { return fHChargeHiGain;    }
     98  const TH1F *GetHCharge() const           { return fHChargeHiGain;    }
    8399
    84100  const Double_t GetChargeMean()     const { return fChargeMean;    }
     
    100116  const Int_t    GetTimeNdf()         const { return fTimeNdf;       }   
    101117 
    102   const TH1I *GetHTime()                    { return fHTime; }
    103   const TH1I *GetHTime()              const { return fHTime; }
     118  const TH1I *GetHTime()                    { return fHTimeHiGain; }
     119  const TH1I *GetHTime()              const { return fHTimeHiGain; }
    104120 
    105   const TH1I *GetHChargevsN()               { return fHChargevsN; }
    106   const TH1I *GetHChargevsN()         const { return fHChargevsN; }
     121  const TH1I *GetHChargevsN()               { return fHChargevsNHiGain; }
     122  const TH1I *GetHChargevsN()         const { return fHChargevsNHiGain; }
    107123 
    108   Bool_t FitCharge(Option_t *option="RQ0"); 
    109   Bool_t FitTime(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0");   
     124  Bool_t FitChargeHiGain(Option_t *option="RQ0"); 
     125  Bool_t FitTimeHiGain(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0");   
     126
     127  Bool_t FitChargeLoGain(Option_t *option="RQ0"); 
     128  Bool_t FitTimeLoGain(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0");   
    110129
    111130  virtual void Draw(Option_t *option="");
  • trunk/MagicSoft/Mars/mhist/MHCamera.cc

    r2586 r2627  
    739739// ------------------------------------------------------------------------
    740740//
     741// Call this function to add a MCamEvent on top of the present contents.
     742//
     743void MHCamera::SetCamError(const MCamEvent &evt, Int_t type)
     744{
     745
     746    if (fNcells<=1 || IsFreezed())
     747        return;
     748
     749    // FIXME: Security check missing!
     750    for (Int_t idx=0; idx<fNcells-2; idx++)
     751    {
     752        Double_t val=0;
     753        if (evt.GetPixelContent(val, idx, *fGeomCam, type)/* && !IsUsed(idx)*/)
     754            SetUsed(idx);
     755
     756        SetBinError(idx+1, val); // FIXME: Slow!
     757    }
     758}
     759
     760
     761
     762// ------------------------------------------------------------------------
     763//
    741764// Call this function to add a MHCamera on top of the present contents.
    742765// Type:
  • trunk/MagicSoft/Mars/mhist/MHCamera.h

    r2586 r2627  
    124124    virtual void     SetCamContent(const TArrayD &evt, const TArrayC *used=NULL) { Reset(); AddCamContent(evt, used); }
    125125    virtual void     SetCamContent(const MHCamera &d, Int_t type=0) { Reset(); AddCamContent(d, type); fEntries=d.fEntries; }
     126
     127    virtual void     SetCamError(const MCamEvent &event, Int_t type=0);
     128
    126129    virtual void     CntCamContent(const MCamEvent &evt, Double_t threshold, Int_t type=0);
    127130    virtual void     CntCamContent(const TArrayD &evt, Double_t threshold, Bool_t ispos=kTRUE);
Note: See TracChangeset for help on using the changeset viewer.