]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSPhysicsAnalyzerPeakFitter.cxx
Effective c++, committed on behalf of �ystein Djuvsland
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSPhysicsAnalyzerPeakFitter.cxx
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   //Constructor
30 }
31
32 AliHLTPHOSPhysicsAnalyzerPeakFitter::~AliHLTPHOSPhysicsAnalyzerPeakFitter()
33 {
34   //Destructor
35 }
36
37 AliHLTPHOSPhysicsAnalyzerPeakFitter::AliHLTPHOSPhysicsAnalyzerPeakFitter(const AliHLTPHOSPhysicsAnalyzerPeakFitter&): fGainLow(80), fGainHigh(5),
38                                                                                                                       fRootHistPtr(0)
39 {
40   //Copy constructor
41 }
42
43
44 Int_t
45 AliHLTPHOSPhysicsAnalyzerPeakFitter::FitGaussian()
46 {
47   //FitGaussian
48
49   Int_t maxBin = fRootHistPtr->GetMaximumBin();
50   Float_t binWidth = fRootHistPtr->GetBinWidth(maxBin);
51   Float_t maxBinValue = (Float_t)(maxBin * binWidth);
52   Float_t lowRange = maxBinValue - 0.03;
53   Float_t highRange = maxBinValue + 0.03;
54
55   TF1* gaussian = new TF1("gaussian", "gaus", 0.1, 0.2);
56     
57   fRootHistPtr->Fit(gaussian->GetName(), "", "",lowRange, highRange);
58   
59   return 0;
60
61 }
62
63 Int_t
64 AliHLTPHOSPhysicsAnalyzerPeakFitter::FitLorentzian()
65 {
66   //FitLorentzian
67   Int_t maxBin = fRootHistPtr->GetMaximumBin();
68   Float_t binWidth = fRootHistPtr->GetBinWidth(maxBin);
69   Float_t maxBinValue = (Float_t)(maxBin * binWidth);
70   Double_t lowRange = maxBinValue - 0.03;
71   Double_t highRange = maxBinValue + 0.03;
72
73   char* name = "lorentzian";
74   
75   TF1* lorentzian = new TF1(name, "([0]*1/TMath::Pi())*[1]/((x[0]-[2])*(x[0]-[2])+[1]*[1])", lowRange, highRange);
76
77   Double_t params[3] = {fRootHistPtr->GetBinContent(maxBin)/20, 0.01, 0.135};
78   lorentzian->SetParameters(params);
79
80   fRootHistPtr->Fit(lorentzian->GetName(), "", "", lowRange, highRange);
81
82   lorentzian->GetParameters(params);
83
84   TFile *outfile = new TFile("/afsuser/odjuvsland","recreate");  
85   fRootHistPtr->Write();
86   outfile->Close();
87
88   return 0;
89 }
90