Fixes of warnings and upgrade of analysis to include Pb+Pb analysis. Background corre...
[u/mrichter/AliRoot.git] / FMD / analysis / AliFMDAnaParameters.cxx
CommitLineData
d7346eed 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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//The design of this class is based on the AliFMDParameters class. Its purpose
17//is to hold parameters for the analysis such as background correction and
18//fit functions.
19//
20//Author: Hans Hjersing Dalsgaard, NBI, hans.dalsgaard@cern.ch
21//
22
23#include "AliFMDDebug.h" // ALILOG_H
24#include "AliFMDAnaParameters.h" // ALIFMDPARAMETERS_H
25#include <AliCDBManager.h> // ALICDBMANAGER_H
26#include <AliCDBEntry.h> // ALICDBMANAGER_H
27#include <AliLog.h>
28#include <Riostream.h>
29#include <sstream>
30#include <TSystem.h>
31#include <TH2D.h>
8dc823cc 32#include <TF1.h>
d7346eed 33
34//====================================================================
35ClassImp(AliFMDAnaParameters)
36#if 0
37 ; // This is here to keep Emacs for indenting the next line
38#endif
39
b82e76e0 40const char* AliFMDAnaParameters::fgkBackgroundCorrection = "FMD/Correction/Background";
41const char* AliFMDAnaParameters::fgkEnergyDists = "FMD/Correction/EnergyDistribution";
d7346eed 42//____________________________________________________________________
43AliFMDAnaParameters* AliFMDAnaParameters::fgInstance = 0;
44
45//____________________________________________________________________
46
47AliFMDAnaParameters*
48AliFMDAnaParameters::Instance()
49{
50 // Get static instance
51 if (!fgInstance) fgInstance = new AliFMDAnaParameters;
52 return fgInstance;
53}
54
55//____________________________________________________________________
56AliFMDAnaParameters::AliFMDAnaParameters() :
57 fIsInit(kFALSE),
b82e76e0 58 fBackground(0),
59 fEnergyDistribution(0)
d7346eed 60{
61
62 // Default constructor
63}
64//____________________________________________________________________
65void AliFMDAnaParameters::Init(Bool_t forceReInit, UInt_t what)
66{
67 // Initialize the parameters manager. We need to get stuff from the
68 // CDB here.
69 if (forceReInit) fIsInit = kFALSE;
70 if (fIsInit) return;
71 if (what & kBackgroundCorrection) InitBackground();
72 if (what & kEnergyDistributions) InitEnergyDists();
73
74 fIsInit = kTRUE;
75}
76//____________________________________________________________________
77
78void AliFMDAnaParameters::InitBackground() {
79
80 AliCDBEntry* background = GetEntry(fgkBackgroundCorrection);
81 if (!background) return;
82
b82e76e0 83 fBackground = dynamic_cast<AliFMDAnaCalibBackgroundCorrection*>(background->GetObject());
84 if (!fBackground) AliFatal("Invalid background object from CDB");
d7346eed 85
86}
87//____________________________________________________________________
88
89void AliFMDAnaParameters::InitEnergyDists() {
90
91 AliCDBEntry* edist = GetEntry(fgkEnergyDists);
92 if (!edist) return;
93
b82e76e0 94 fEnergyDistribution = dynamic_cast<AliFMDAnaCalibEnergyDistribution*>(edist->GetObject());
d7346eed 95
b82e76e0 96 if (!fEnergyDistribution) AliFatal("Invalid background object from CDB");
d7346eed 97
98}
99//____________________________________________________________________
100Float_t AliFMDAnaParameters::GetVtxCutZ() {
101
102 if(!fIsInit) {
103 AliWarning("Not initialized yet. Call Init() to remedy");
104 return -1;
105 }
106
b82e76e0 107 return fBackground->GetVtxCutZ();
d7346eed 108}
109
110//____________________________________________________________________
111Int_t AliFMDAnaParameters::GetNvtxBins() {
112
113 if(!fIsInit) {
114 AliWarning("Not initialized yet. Call Init() to remedy");
115 return -1;
116 }
117
b82e76e0 118 return fBackground->GetNvtxBins();
d7346eed 119}
120//____________________________________________________________________
121TH1F* AliFMDAnaParameters::GetEnergyDistribution(Int_t det, Char_t ring) {
122
b82e76e0 123 return fEnergyDistribution->GetEnergyDistribution(det, ring);
8dc823cc 124}
125//____________________________________________________________________
126Float_t AliFMDAnaParameters::GetSigma(Int_t det, Char_t ring) {
127
d7346eed 128 if(!fIsInit) {
129 AliWarning("Not initialized yet. Call Init() to remedy");
130 return 0;
131 }
132
b82e76e0 133 TH1F* hEnergyDist = GetEnergyDistribution(det,ring);
134 TF1* landau = hEnergyDist->GetFunction("landau");
8dc823cc 135 Float_t sigma = landau->GetParameter(2);
136 return sigma;
137}
138
139
140//____________________________________________________________________
141Float_t AliFMDAnaParameters::GetMPV(Int_t det, Char_t ring) {
142
143 if(!fIsInit) {
144 AliWarning("Not initialized yet. Call Init() to remedy");
145 return 0;
146 }
147
148 TH1F* hEnergyDist = GetEnergyDistribution(det,ring);
149 TF1* landau = hEnergyDist->GetFunction("landau");
150 Float_t MPV = landau->GetParameter(1);
151 return MPV;
d7346eed 152}
153//____________________________________________________________________
8dc823cc 154
155
156
d7346eed 157TH2F* AliFMDAnaParameters::GetBackgroundCorrection(Int_t det,
158 Char_t ring,
159 Int_t vtxbin) {
b82e76e0 160
d7346eed 161 if(!fIsInit) {
162 AliWarning("Not initialized yet. Call Init() to remedy");
163 return 0;
164 }
b82e76e0 165
166
167
168 if(vtxbin > fBackground->GetNvtxBins()) {
d7346eed 169 AliWarning(Form("No background object for vertex bin %d", vtxbin));
170 return 0;
171 }
172
b82e76e0 173 return fBackground->GetBgCorrection(det,ring,vtxbin);
d7346eed 174}
d7346eed 175
176//____________________________________________________________________
177AliCDBEntry* AliFMDAnaParameters::GetEntry(const char* path, Bool_t fatal) const
178{
179 // Get an entry from the CDB or via preprocessor
180 AliCDBEntry* entry = 0;
181 AliCDBManager* cdb = AliCDBManager::Instance();
182 entry = cdb->Get(path);
183
184 if (!entry) {
185 TString msg(Form("No %s found in CDB, perhaps you need to "
186 "use AliFMDCalibFaker?", path));
187 if (fatal) { AliFatal(msg.Data()); }
188 else AliLog::Message(AliLog::kWarning, msg.Data(), "FMD",
189 "AliFMDParameters", "GetEntry", __FILE__,
190 __LINE__);
191 return 0;
192 }
193 return entry;
194}
195
196
197//____________________________________________________________________
198//
199// EOF
200//