]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/analysis/AliFMDAnaParameters.cxx
Analysis with correction for double hits (work in progress) and analysis independent...
[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
f58a4769 27#include "AliFMDRing.h"
d7346eed 28#include <AliLog.h>
29#include <Riostream.h>
30#include <sstream>
31#include <TSystem.h>
32#include <TH2D.h>
8dc823cc 33#include <TF1.h>
f58a4769 34#include <TMath.h>
d7346eed 35
36//====================================================================
37ClassImp(AliFMDAnaParameters)
38#if 0
39 ; // This is here to keep Emacs for indenting the next line
40#endif
41
b82e76e0 42const char* AliFMDAnaParameters::fgkBackgroundCorrection = "FMD/Correction/Background";
43const char* AliFMDAnaParameters::fgkEnergyDists = "FMD/Correction/EnergyDistribution";
d7346eed 44//____________________________________________________________________
45AliFMDAnaParameters* AliFMDAnaParameters::fgInstance = 0;
46
47//____________________________________________________________________
48
49AliFMDAnaParameters*
50AliFMDAnaParameters::Instance()
51{
52 // Get static instance
53 if (!fgInstance) fgInstance = new AliFMDAnaParameters;
54 return fgInstance;
55}
56
57//____________________________________________________________________
58AliFMDAnaParameters::AliFMDAnaParameters() :
59 fIsInit(kFALSE),
b82e76e0 60 fBackground(0),
61 fEnergyDistribution(0)
d7346eed 62{
63
64 // Default constructor
65}
66//____________________________________________________________________
67void AliFMDAnaParameters::Init(Bool_t forceReInit, UInt_t what)
68{
69 // Initialize the parameters manager. We need to get stuff from the
70 // CDB here.
71 if (forceReInit) fIsInit = kFALSE;
72 if (fIsInit) return;
73 if (what & kBackgroundCorrection) InitBackground();
74 if (what & kEnergyDistributions) InitEnergyDists();
75
76 fIsInit = kTRUE;
77}
78//____________________________________________________________________
79
80void AliFMDAnaParameters::InitBackground() {
81
82 AliCDBEntry* background = GetEntry(fgkBackgroundCorrection);
83 if (!background) return;
84
b82e76e0 85 fBackground = dynamic_cast<AliFMDAnaCalibBackgroundCorrection*>(background->GetObject());
86 if (!fBackground) AliFatal("Invalid background object from CDB");
d7346eed 87
88}
89//____________________________________________________________________
90
91void AliFMDAnaParameters::InitEnergyDists() {
92
93 AliCDBEntry* edist = GetEntry(fgkEnergyDists);
94 if (!edist) return;
95
b82e76e0 96 fEnergyDistribution = dynamic_cast<AliFMDAnaCalibEnergyDistribution*>(edist->GetObject());
d7346eed 97
b82e76e0 98 if (!fEnergyDistribution) AliFatal("Invalid background object from CDB");
d7346eed 99
100}
101//____________________________________________________________________
102Float_t AliFMDAnaParameters::GetVtxCutZ() {
103
104 if(!fIsInit) {
105 AliWarning("Not initialized yet. Call Init() to remedy");
106 return -1;
107 }
108
b82e76e0 109 return fBackground->GetVtxCutZ();
d7346eed 110}
111
112//____________________________________________________________________
113Int_t AliFMDAnaParameters::GetNvtxBins() {
114
115 if(!fIsInit) {
116 AliWarning("Not initialized yet. Call Init() to remedy");
117 return -1;
118 }
119
b82e76e0 120 return fBackground->GetNvtxBins();
d7346eed 121}
122//____________________________________________________________________
5754671c 123TH1F* AliFMDAnaParameters::GetEnergyDistribution(Int_t det, Char_t ring, Float_t eta) {
d7346eed 124
5754671c 125 return fEnergyDistribution->GetEnergyDistribution(det, ring, eta);
8dc823cc 126}
127//____________________________________________________________________
5754671c 128Float_t AliFMDAnaParameters::GetSigma(Int_t det, Char_t ring, Float_t eta) {
8dc823cc 129
d7346eed 130 if(!fIsInit) {
131 AliWarning("Not initialized yet. Call Init() to remedy");
132 return 0;
133 }
134
5754671c 135 TH1F* hEnergyDist = GetEnergyDistribution(det,ring, eta);
136 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
137 if(!fitFunc) {
138 AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
139 return 1024;
140 }
141 Float_t sigma = fitFunc->GetParameter(2);
8dc823cc 142 return sigma;
143}
144
145
146//____________________________________________________________________
5754671c 147Float_t AliFMDAnaParameters::GetMPV(Int_t det, Char_t ring, Float_t eta) {
8dc823cc 148
149 if(!fIsInit) {
150 AliWarning("Not initialized yet. Call Init() to remedy");
151 return 0;
152 }
153
5754671c 154 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
155 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
156 if(!fitFunc) {
157 AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
158 return 1024;
159 }
160
161 Float_t MPV = fitFunc->GetParameter(1);
8dc823cc 162 return MPV;
d7346eed 163}
164//____________________________________________________________________
5754671c 165Float_t AliFMDAnaParameters::Get2MIPWeight(Int_t det, Char_t ring, Float_t eta) {
166
167 if(!fIsInit) {
168 AliWarning("Not initialized yet. Call Init() to remedy");
169 return 0;
170 }
171
172 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
173 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
174 if(!fitFunc) return 0;
175 Float_t TwoMIPweight = fitFunc->GetParameter(3);
176
177
178
179 if(TwoMIPweight < 1e-05)
180 TwoMIPweight = 0;
181
182 return TwoMIPweight;
183}
184//____________________________________________________________________
185Float_t AliFMDAnaParameters::Get3MIPWeight(Int_t det, Char_t ring, Float_t eta) {
186
187 if(!fIsInit) {
188 AliWarning("Not initialized yet. Call Init() to remedy");
189 return 0;
190 }
191
192 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
193 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
194 if(!fitFunc) return 0;
195 Float_t ThreeMIPweight = fitFunc->GetParameter(4);
196
197 if(ThreeMIPweight < 1e-05)
198 ThreeMIPweight = 0;
199
200 Float_t TwoMIPweight = fitFunc->GetParameter(3);
201
202 if(TwoMIPweight < 1e-05)
203 ThreeMIPweight = 0;
204
205 return ThreeMIPweight;
206}
207//____________________________________________________________________
208Int_t AliFMDAnaParameters::GetNetaBins() {
209 return GetBackgroundCorrection(1,'I',0)->GetNbinsX();
210
211}
212//____________________________________________________________________
213Float_t AliFMDAnaParameters::GetEtaMin() {
8dc823cc 214
5754671c 215 return GetBackgroundCorrection(1,'I',0)->GetXaxis()->GetXmin();
216}
217//____________________________________________________________________
218Float_t AliFMDAnaParameters::GetEtaMax() {
219
220return GetBackgroundCorrection(1,'I',0)->GetXaxis()->GetXmax();
8dc823cc 221
5754671c 222}
223//____________________________________________________________________
8dc823cc 224
d7346eed 225TH2F* AliFMDAnaParameters::GetBackgroundCorrection(Int_t det,
226 Char_t ring,
227 Int_t vtxbin) {
b82e76e0 228
d7346eed 229 if(!fIsInit) {
230 AliWarning("Not initialized yet. Call Init() to remedy");
231 return 0;
232 }
b82e76e0 233
234
235
236 if(vtxbin > fBackground->GetNvtxBins()) {
d7346eed 237 AliWarning(Form("No background object for vertex bin %d", vtxbin));
238 return 0;
239 }
240
b82e76e0 241 return fBackground->GetBgCorrection(det,ring,vtxbin);
d7346eed 242}
f58a4769 243//_____________________________________________________________________
244Float_t AliFMDAnaParameters::GetPhiFromSector(UShort_t det, Char_t ring, UShort_t sec)
245{
246 Int_t nsec = (ring == 'I' ? 20 : 40);
247 Float_t basephi = 0;
248 if(det == 1)
249 basephi = 1.72787594;
250 if(det == 2 && ring == 'I')
251 basephi = 0.15707963;
252 if(det == 2 && ring == 'O')
253 basephi = 0.078539818;
254 if(det == 3 && ring == 'I')
255 basephi = 2.984513044;
256 if(det == 3 && ring == 'O')
257 basephi = 3.06305289;
258
259 Float_t step = 2*TMath::Pi() / nsec;
260 Float_t phi = 0;
261 if(det == 3)
262 phi = basephi - sec*step;
263 else
264 phi = basephi + sec*step;
265
266 if(phi < 0)
267 phi = phi +2*TMath::Pi();
268 if(phi > 2*TMath::Pi() )
269 phi = phi - 2*TMath::Pi();
270
271 return phi;
272}
273//_____________________________________________________________________
274Float_t AliFMDAnaParameters::GetEtaFromStrip(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip, Float_t zvtx)
275{
276 AliFMDRing fmdring(ring);
277 fmdring.Init();
278 Float_t rad = fmdring.GetMaxR()-fmdring.GetMinR();
279 Float_t segment = rad / fmdring.GetNStrips();
280 Float_t r = fmdring.GetMinR() + segment*strip;
281 Float_t z = 0;
282 Int_t hybrid = sec / 2;
283
284 if(det == 1) {
285 if(!(hybrid%2)) z = 320.266; else z = 319.766;
286 }
287 if(det == 2 && ring == 'I' ) {
288 if(!(hybrid%2)) z = 83.666; else z = 83.166;
289 }
290 if(det == 2 && ring == 'O' ) {
291 if(!(hybrid%2)) z = 74.966; else z = 75.466;
292 }
293 if(det == 3 && ring == 'I' ) {
294 if(!(hybrid%2)) z = -63.066; else z = -62.566;
295 }
296 if(det == 3 && ring == 'O' ) {
297 if(!(hybrid%2)) z = -74.966; else z = -75.466;
298 }
299
300 //std::cout<<det<<" "<<ring<<" "<<sec<<" "<<hybrid<<" "<<z<<std::endl;
301
302 // Float_t r = TMath::Sqrt(TMath::Power(x,2)+TMath::Power(y,2));
303 Float_t theta = TMath::ATan2(r,z-zvtx);
304 Float_t eta = -1*TMath::Log(TMath::Tan(0.5*theta));
305
306 return eta;
307}
d7346eed 308//____________________________________________________________________
309AliCDBEntry* AliFMDAnaParameters::GetEntry(const char* path, Bool_t fatal) const
310{
311 // Get an entry from the CDB or via preprocessor
312 AliCDBEntry* entry = 0;
313 AliCDBManager* cdb = AliCDBManager::Instance();
314 entry = cdb->Get(path);
315
316 if (!entry) {
317 TString msg(Form("No %s found in CDB, perhaps you need to "
318 "use AliFMDCalibFaker?", path));
319 if (fatal) { AliFatal(msg.Data()); }
320 else AliLog::Message(AliLog::kWarning, msg.Data(), "FMD",
321 "AliFMDParameters", "GetEntry", __FILE__,
322 __LINE__);
323 return 0;
324 }
325 return entry;
326}
327
328
329//____________________________________________________________________
330//
331// EOF
332//