Fixing warnings (Gines)
[u/mrichter/AliRoot.git] / PWG3 / base / AliQuarkoniaAcceptance.cxx
CommitLineData
d587d4f0 1/* $Id$ */
2
3// Root
4#include "TAxis.h"
5#include "TFile.h"
6#include "TH2.h"
7#include "TString.h"
8
9// AliRoot includes
10#include "AliQuarkoniaAcceptance.h"
11#include "AliLog.h"
12
13
14
15//_______________________________________________________________________
16AliQuarkoniaAcceptance::AliQuarkoniaAcceptance(Int_t quarkoniaResonance, Int_t decayChannel):
17 fAcceptanceFileName("$ALICE_ROOT/PWG3/QuarkoniaAcceptance.root"),
18 fQuarkoniaResonance(quarkoniaResonance),
19 fDecayChannel(decayChannel),
20 fAcceptance(0x0)
21{
22
23
24}
25//_______________________________________________________________________
26AliQuarkoniaAcceptance::~AliQuarkoniaAcceptance()
27{
28 delete fAcceptance;
29}
30
31//_______________________________________________________________________
32void AliQuarkoniaAcceptance::Init()
33{
34 switch (fQuarkoniaResonance) {
35 case kJpsi:
36 SetTitle("Jpsi");
37 break;
38 case kPsiP:
39 SetTitle("PsiP");
40 break;
41 case kUpsilon:
42 SetTitle("Upsilon");
43 break;
44 case kUpsilonP:
45 SetTitle("UpsilonP");
46 break;
47 case kUpsilonPP:
48 SetTitle("UpsilonPP");
49 break;
50 case kOmega:
51 SetTitle("Omega");
52 break;
53 case kPhi:
54 SetTitle("Phi");
55 break;
56 }
57
58 switch ( fDecayChannel) {
59 case kDimuon:
60 SetName("Dimuon");
61 break;
62 case kDielectron:
63 SetName("Dielectron");
64 break;
65 }
66
67 if(!fAcceptance) delete fAcceptance;
68
69 TFile acceptanceFile(fAcceptanceFileName);
70 if ( acceptanceFile.IsOpen() ) {
71 char histoname[30];
72 sprintf(histoname,"h%s%sAccep",GetTitle(),GetName());
73 fAcceptance = (TH2F*) acceptanceFile.Get(histoname);
74 if ( !fAcceptance ) {
75 AliError(Form("Acceptance data for quarkonia %s and channel %s not found", GetTitle(), GetName() ));
76 }
77 else {
78 fAcceptance->SetDirectory(0);
79 }
80 acceptanceFile.Close();
81 }
82 else {
83 AliError(Form("File %s not found",fAcceptanceFileName.Data()));
84 }
85}
86//_______________________________________________________________________
87TH2F* AliQuarkoniaAcceptance::GetAcceptanceHisto() const
88{
89 if (fAcceptance) return fAcceptance;
90 else {
91 AliError(Form("Acceptance data for quarkonia %s and channel %s not found",GetTitle(),GetName()));
92 return 0x0;
93 }
94}
95//_______________________________________________________________________
96void AliQuarkoniaAcceptance::GetAcceptance(Float_t rap, Float_t pT, Double_t &accep, Double_t &error)
97{
98 Int_t binx=0;
99 Int_t biny=0;
100
101 if (!fAcceptance) {
102 AliError(Form("Acceptance data for quarkonia %s and channel %s not found",GetTitle(),GetName()));
103 }
104 else {
105 if ( rap < (fAcceptance->GetXaxis())->GetXmin() ||
106 rap > (fAcceptance->GetXaxis())->GetXmax() ||
107 pT < (fAcceptance->GetYaxis())->GetXmin() ||
108 pT > (fAcceptance->GetYaxis())->GetXmax() ) {
109 AliInfo("Values out of range");
110 accep = 0.;
111 error = 0.;
112 }
113 else {
114 binx = fAcceptance->GetXaxis()->FindBin(rap);
115 biny = fAcceptance->GetYaxis()->FindBin(pT);
116 accep = fAcceptance->GetBinContent(binx,biny);
117 error = fAcceptance->GetBinError(binx,biny);
118 }
119 }
120}