1 #ifndef ALILANDAUGAUSFITTER_H
2 #define ALILANDAUGAUSFITTER_H
17 #include <TObjArray.h>
20 #include <TFitResult.h>
192 if (test < low || test > high) {
193 ::Warning(
"",
"Initial value of %s=%f not in [%f,%f]",
194 f->GetParName(iPar), test, low, high);
198 ::Info(
"",
"Set par limits on %-12s=%f: [%f,%f]",
199 f->GetParName(iPar), test, low, high);
200 f->SetParLimits(iPar, low, high);
219 Int_t cutBin = TMath::Max(dist->GetXaxis()->FindBin(
fLowCut),3);
222 dist->GetXaxis()->SetRange(cutBin, maxBin);
226 Int_t peakBin = dist->GetMaximumBin();
227 Double_t peakE = dist->GetBinLowEdge(peakBin);
234 Double_t maxE = dist->GetBinCenter(peakBin+2*fMinusBins);
236 Int_t minEb = dist->GetXaxis()->FindBin(minE);
237 Int_t maxEb = dist->GetXaxis()->FindBin(maxE);
238 Double_t intg = dist->Integral(minEb, maxEb);
240 ::Warning(
"Fit1Particle",
241 "Integral of %s between [%f,%f] [%03d,%03d] = %f < 0",
242 dist->GetName(), minE, maxE, minEb, maxEb, intg);
247 dist->GetXaxis()->SetRange(1, maxBin);
263 ::Info(
"",
"Fitting in the range %f,%f", minE, maxE);
264 TFitResultPtr r = dist->Fit(f, opts,
"", minE, maxE);
266 ::Warning(
"Fit1Particle",
267 "No fit returned when processing %s in the range [%f,%f] "
268 "options %s", dist->GetName(), minE, maxE, opts.Data());
282 TFitResult* r =
static_cast<TFitResult*
>(
fFitResults.At(0));
288 ::Warning(
"FitNLandau",
"No first shot at landau fit");
296 Double_t maxEi = n * (delta1 + xi1 * TMath::Log(n)) + 2 * n * xi1;
299 Int_t minEb = dist->GetXaxis()->FindBin(minE);
300 Int_t maxEb = dist->GetXaxis()->FindBin(maxEi);
302 Double_t intg = dist->Integral(minEb, maxEb);
304 ::Warning(
"FitNParticle",
305 "Integral of %s between [%f,%f] [%03d,%03d] = %f < 0",
306 dist->GetName(), minE, maxEi, minEb, maxEb, intg);
313 a.fArray[i-2] = (n == 2 ? 0.05 : 0.000001);
320 n, a.fArray, minE, maxEi);
324 if (sigman <= 0) f->FixParameter(
kSigmaN, 0);
337 "Fitting in the range %f,%f (%d)", minE, maxEi, n);
338 TFitResultPtr tr = dist->Fit(f, opts,
"", minE, maxEi);
341 fFitResults.AddAtAndExpand(
new TFitResult(*tr), n-1);
351 Int_t cutBin = TMath::Max(dist->GetXaxis()->FindBin(
fLowCut),3);
354 dist->GetXaxis()->SetRange(cutBin, maxBin);
357 Int_t peakBin = dist->GetMaximumBin();
358 Double_t peakE = dist->GetBinLowEdge(peakBin);
364 Double_t maxE = dist->GetBinCenter(peakBin+2*fMinusBins);
367 Int_t minEb = dist->GetXaxis()->FindBin(minE);
368 Int_t maxEb = dist->GetXaxis()->FindBin(maxE);
369 Double_t intg = dist->Integral(minEb, maxEb);
371 ::Warning(
"Fit1Particle",
372 "Integral of %s between [%f,%f] [%03d,%03d] = %f < 0",
373 dist->GetName(), minE, maxE, minEb, maxEb, intg);
378 dist->GetXaxis()->SetRange(1, maxBin);
385 seed->SetParLimits(
kXi, 0.00, 0.1);
386 seed->SetParLimits(
kSigma, 1e-5, 0.1);
387 if (sigman <= 0) seed->FixParameter(
kSigmaN, 0);
392 ::Info(
"",
"Fitting seed in the range %f,%f", minE, maxE);
395 maxE = dist->GetXaxis()->GetXmax();
398 seed->GetParameter(
kDelta),
399 seed->GetParameter(
kDelta)/10,
400 seed->GetParameter(
kDelta)/5,
401 1.20 * seed->GetParameter(
kC),
402 seed->GetParameter(
kXi),
410 comp->SetLineColor(kRed+1);
411 comp->SetLineWidth(3);
416 ::Info(
"FitComposite",
"Fitting composite in the range %f,%f", minE, maxE);
417 dist->Fit(comp, opts,
"", minE, maxE);
421 TF1* part1 =
static_cast<TF1*
>(seed->Clone(
"part1"));
422 part1->SetLineColor(kGreen+1);
423 part1->SetLineWidth(4);
424 part1->SetRange(minE, maxE);
425 part1->SetParameters(comp->GetParameter(0),
426 comp->GetParameter(1),
427 comp->GetParameter(2),
428 comp->GetParameter(3),
430 part1->Save(minE,maxE,0,0,0,0);
431 dist->GetListOfFunctions()->Add(part1);
433 TF1* part2 =
static_cast<TF1*
>(seed->Clone(
"part2"));
434 part2->SetLineColor(kBlue+1);
435 part2->SetLineWidth(4);
436 part2->SetRange(minE, maxE);
437 part2->SetParameters(comp->GetParameter(4),
438 comp->GetParameter(1),
439 comp->GetParameter(5),
440 comp->GetParameter(3),
442 part2->Save(minE,maxE,0,0,0,0);
443 dist->GetListOfFunctions()->Add(part2);
TObjArray & GetFunctions()
void SetParLimits(TF1 *f, Int_t iPar, Double_t test, Double_t low, Double_t high)
static TF1 * MakeFn(Double_t c, Double_t delta, Double_t xi, Double_t sigma, Double_t sigma_n, Int_t n, const Double_t *a, Double_t xmin, Double_t xmax)
Double_t GetMaxRange() const
static TF1 * MakeF1(Double_t c, Double_t delta, Double_t xi, Double_t sigma, Double_t sigma_n, Double_t xmin, Double_t xmax)
const TObjArray & GetFitResults() const
const UShort_t fMinusBins
Double_t GetLowCut() const
Declaration and implementation of Landau-Gauss distributions.
static TF1 * MakeComposite(Double_t c1, Double_t delta, Double_t xi1, Double_t sigma, Double_t c2, Double_t xi2, Double_t xmin, Double_t xmax)
const TObjArray & GetFunctions() const
TObjArray & GetFitResults()
TF1 * FitComposite(TH1 *dist, Double_t sigman)
static const char * GetFitOptions()
TF1 * Fit1Particle(TH1 *dist, Double_t sigman=-1)
AliLandauGausFitter(Double_t lowCut, Double_t maxRange, UShort_t minusBins)
TF1 * FitNParticle(TH1 *dist, UShort_t n, Double_t sigman=-1)
UShort_t GetMinusBins() const
void SetDebug(Bool_t debug=true)
virtual ~AliLandauGausFitter()