]>
Commit | Line | Data |
---|---|---|
2410262d | 1 | |
2 | /************************************************************************** | |
3 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * * | |
5 | * Authors: Øystein Djuvsland <oysteind@ift.uib.no> * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | ||
17 | ||
18 | #include "AliHLTPHOSPhysicsAnalyzerPeakFitter.h" | |
19 | #include "TMath.h" | |
20 | #include "TF1.h" | |
21 | #include "TFile.h" | |
22 | ||
23 | ||
24 | ClassImp(AliHLTPHOSPhysicsAnalyzerPeakFitter); | |
25 | ||
26 | AliHLTPHOSPhysicsAnalyzerPeakFitter::AliHLTPHOSPhysicsAnalyzerPeakFitter() : fGainLow(80), fGainHigh(5), | |
27 | fRootHistPtr(0) | |
28 | { | |
29 | } | |
30 | ||
31 | AliHLTPHOSPhysicsAnalyzerPeakFitter::~AliHLTPHOSPhysicsAnalyzerPeakFitter() | |
32 | { | |
33 | } | |
34 | ||
35 | Int_t | |
36 | AliHLTPHOSPhysicsAnalyzerPeakFitter::FitGaussian() | |
37 | { | |
38 | Int_t maxBin = fRootHistPtr->GetMaximumBin(); | |
39 | Float_t binWidth = fRootHistPtr->GetBinWidth(maxBin); | |
40 | Float_t maxBinValue = (Float_t)(maxBin * binWidth); | |
41 | Float_t lowRange = maxBinValue - 0.03; | |
42 | Float_t highRange = maxBinValue + 0.03; | |
43 | ||
44 | TF1* gaussian = new TF1("gaussian", "gaus", 0.1, 0.2); | |
45 | Double_t params[3] = {maxBinValue, 0}; | |
46 | ||
47 | ||
48 | fRootHistPtr->Fit(gaussian->GetName(), "", "",lowRange, highRange); | |
49 | ||
50 | return 0; | |
51 | ||
52 | } | |
53 | ||
54 | Int_t | |
55 | AliHLTPHOSPhysicsAnalyzerPeakFitter::FitLorentzian() | |
56 | { | |
57 | ||
58 | ||
59 | Int_t maxBin = fRootHistPtr->GetMaximumBin(); | |
60 | Float_t binWidth = fRootHistPtr->GetBinWidth(maxBin); | |
61 | Float_t maxBinValue = (Float_t)(maxBin * binWidth); | |
62 | Double_t lowRange = maxBinValue - 0.03; | |
63 | Double_t highRange = maxBinValue + 0.03; | |
64 | ||
65 | Int_t npar = 3; | |
66 | ||
67 | char* name = "lorentzian"; | |
68 | ||
69 | TF1* lorentzian = new TF1(name, "([0]*1/TMath::Pi())*[1]/((x[0]-[2])*(x[0]-[2])+[1]*[1])", lowRange, highRange); | |
70 | ||
71 | Double_t params[3] = {fRootHistPtr->GetBinContent(maxBin)/20, 0.01, 0.135}; | |
72 | lorentzian->SetParameters(params); | |
73 | ||
74 | fRootHistPtr->Fit(lorentzian->GetName(), "", "", lowRange, highRange); | |
75 | ||
76 | lorentzian->GetParameters(params); | |
77 | ||
78 | TFile *outfile = new TFile("/home/odjuvsla/pi0HistFit.root","recreate"); | |
79 | fRootHistPtr->Write(); | |
80 | outfile->Close(); | |
81 | ||
82 | return 0; | |
83 | } | |
84 |