Adding a reminder for coders
[u/mrichter/AliRoot.git] / TOF / ReadT0FillReference.C
CommitLineData
9b62bd30 1TH1F *
2ReadT0FillReference(Int_t run, Int_t year = 2010)
3{
4
5 AliCDBManager *cdb = AliCDBManager::Instance();
6 cdb->SetDefaultStorage(Form("alien://folder=/alice/data/%d/Reference", year));
7 cdb->SetRun(run);
8 AliCDBEntry *cdbe = cdb->Get("TOF/Calib/T0Fill");
2439c586 9 TH1F *hT0Fill = (TH1F *)cdbe->GetObject();
10
11 /* rebin until maximum bin has required minimum entries */
12 Int_t maxBin = hT0Fill->GetMaximumBin();
13 Float_t maxBinContent = hT0Fill->GetBinContent(maxBin);
14 Float_t binWidth = hT0Fill->GetBinWidth(maxBin);
15 while (maxBinContent < 400 && binWidth < 90.) {
16 hT0Fill->Rebin(2);
17 maxBin = hT0Fill->GetMaximumBin();
18 maxBinContent = hT0Fill->GetBinContent(maxBin);
19 binWidth = hT0Fill->GetBinWidth(maxBin);
20 }
21 Float_t maxBinCenter = hT0Fill->GetBinCenter(maxBin);
22
23 /* rough fit of the edge */
24 TF1 *gaus = (TF1 *)gROOT->GetFunction("landau");
25 gaus->SetParameter(1, maxBinCenter);
26 Float_t fitMin = maxBinCenter - 1000.; /* fit from 1 ns before max */
27 Float_t fitMax = maxBinCenter + 1000.; /* fit until 1 ns above max */
28 hT0Fill->Fit("gaus", "q0", "", fitMin, fitMax);
29 /* better fit of the edge */
30 Float_t mean, sigma;
31 for (Int_t istep = 0; istep < 10; istep++) {
32 mean = gaus->GetParameter(1);
33 sigma = gaus->GetParameter(2);
34 fitMin = mean - 2. * sigma;
35 fitMax = mean + 1. * sigma;
36 hT0Fill->Fit("landau", "q", "", fitMin, fitMax);
37 }
38 /* print params */
39 mean = gaus->GetParameter(1);
40 sigma = gaus->GetParameter(2);
41 Float_t meane = gaus->GetParError(1);
42 Float_t sigmae = gaus->GetParError(2);
43 printf("edge fit: mean = %f +- %f ps\n", mean, meane);
44 printf("edge fit: sigma = %f +- %f ps\n", sigma, sigmae);
45
46 hT0Fill->DrawCopy();
47 gaus->Draw("same");
48
49 return hT0Fill;
9b62bd30 50
51}