]>
Commit | Line | Data |
---|---|---|
0bd4b00f | 1 | #include "AliFMDCorrMergingEfficiency.h" |
2 | #include <TBrowser.h> | |
3 | #include <TH1D.h> | |
4 | #include <AliLog.h> | |
5 | #include <iostream> | |
6 | ||
7 | //____________________________________________________________________ | |
8 | AliFMDCorrMergingEfficiency::AliFMDCorrMergingEfficiency() | |
9 | : fRingArray(), | |
10 | fVertexAxis(0,0,0) | |
11 | { | |
12 | fRingArray.SetOwner(kTRUE); | |
13 | fRingArray.SetName("rings"); | |
14 | fVertexAxis.SetName("vtxAxis"); | |
15 | fVertexAxis.SetTitle("v_{z} [cm]"); | |
16 | ||
17 | } | |
18 | //____________________________________________________________________ | |
19 | AliFMDCorrMergingEfficiency::AliFMDCorrMergingEfficiency(const | |
20 | AliFMDCorrMergingEfficiency& o) | |
21 | : TObject(o), | |
22 | fRingArray(o.fRingArray), | |
23 | fVertexAxis(o.fVertexAxis.GetNbins(), o.fVertexAxis.GetXmin(), | |
24 | o.fVertexAxis.GetXmax()) | |
25 | { | |
26 | fVertexAxis.SetName("vtxAxis"); | |
27 | fVertexAxis.SetTitle("v_{z} [cm]"); | |
28 | } | |
29 | //____________________________________________________________________ | |
30 | AliFMDCorrMergingEfficiency::~AliFMDCorrMergingEfficiency() | |
31 | { | |
32 | fRingArray.Clear(); | |
33 | } | |
34 | //____________________________________________________________________ | |
35 | AliFMDCorrMergingEfficiency& | |
36 | AliFMDCorrMergingEfficiency::operator=(const AliFMDCorrMergingEfficiency& o) | |
37 | { | |
38 | fRingArray = o.fRingArray; | |
39 | SetVertexAxis(o.fVertexAxis); | |
40 | ||
41 | return *this; | |
42 | } | |
43 | //____________________________________________________________________ | |
44 | TH1D* | |
45 | AliFMDCorrMergingEfficiency::GetCorrection(UShort_t d, Char_t r, Double_t v) const | |
46 | { | |
47 | Int_t b = FindVertexBin(v); | |
48 | if (b <= 0) return 0; | |
49 | return GetCorrection(d, r, UShort_t(b)); | |
50 | } | |
51 | //____________________________________________________________________ | |
52 | TH1D* | |
53 | AliFMDCorrMergingEfficiency::GetCorrection(UShort_t d, Char_t r, UShort_t b) const | |
54 | { | |
55 | TObjArray* ringArray = GetRingArray(d, r); | |
56 | if (!ringArray) return 0; | |
57 | ||
58 | if (b <= 0 || b > ringArray->GetEntriesFast()) { | |
59 | AliWarning(Form("vertex bin %d out of range [1,%d]", | |
60 | b, ringArray->GetEntriesFast())); | |
61 | return 0; | |
62 | } | |
63 | ||
64 | TObject* o = ringArray->At(b-1); | |
65 | if (!o) { | |
66 | AliWarning(Form("No secondary map found for FMD%d%c in vertex bin %d", | |
67 | d,r,b)); | |
68 | return 0; | |
69 | } | |
70 | return static_cast<TH1D*>(o); | |
71 | } | |
72 | ||
73 | //____________________________________________________________________ | |
74 | Int_t | |
75 | AliFMDCorrMergingEfficiency::FindVertexBin(Double_t v) const | |
76 | { | |
77 | if (fVertexAxis.GetNbins() <= 0) { | |
78 | AliWarning("No vertex array defined"); | |
79 | return 0; | |
80 | } | |
81 | Int_t bin = const_cast<TAxis&>(fVertexAxis).FindBin(v); | |
82 | if (bin <= 0 || bin > fVertexAxis.GetNbins()) { | |
83 | AliWarning(Form("vertex %+8.4f out of range [%+8.4f,%+8.4f]", | |
84 | v, fVertexAxis.GetXmin(), fVertexAxis.GetXmax())); | |
85 | return 0; | |
86 | } | |
87 | return bin; | |
88 | } | |
89 | //____________________________________________________________________ | |
90 | Int_t | |
91 | AliFMDCorrMergingEfficiency::GetRingIndex(UShort_t d, Char_t r) const | |
92 | { | |
93 | switch (d) { | |
94 | case 1: return 0; | |
95 | case 2: return (r == 'I' || r == 'i' ? 1 : 2); break; | |
96 | case 3: return (r == 'I' || r == 'i' ? 3 : 4); break; | |
97 | } | |
98 | AliWarning(Form("Index for FMD%d%c not found", d, r)); | |
99 | return -1; | |
100 | } | |
101 | //____________________________________________________________________ | |
102 | TObjArray* | |
103 | AliFMDCorrMergingEfficiency::GetRingArray(UShort_t d, Char_t r) const | |
104 | { | |
105 | Int_t idx = GetRingIndex(d,r); | |
106 | if (idx < 0) return 0; | |
107 | ||
108 | TObject* o = fRingArray.At(idx); | |
109 | if (!o) { | |
110 | AliWarning(Form("No array found for FMD%d%c", d, r)); | |
111 | return 0; | |
112 | } | |
113 | ||
114 | return static_cast<TObjArray*>(o); | |
115 | } | |
116 | //____________________________________________________________________ | |
117 | TObjArray* | |
118 | AliFMDCorrMergingEfficiency::GetOrMakeRingArray(UShort_t d, Char_t r) | |
119 | { | |
120 | Int_t idx = GetRingIndex(d,r); | |
121 | if (idx < 0) return 0; | |
122 | ||
123 | TObject* o = fRingArray.At(idx); | |
124 | if (!o) { | |
125 | TObjArray* a = new TObjArray(fVertexAxis.GetNbins()); | |
126 | a->SetName(Form("FMD%d%c", d, r)); | |
127 | a->SetOwner(kTRUE); | |
128 | fRingArray.AddAtAndExpand(a, idx); | |
129 | return a; | |
130 | } | |
131 | ||
132 | return static_cast<TObjArray*>(fRingArray.At(idx)); | |
133 | } | |
134 | ||
135 | //____________________________________________________________________ | |
136 | Bool_t | |
137 | AliFMDCorrMergingEfficiency::SetCorrection(UShort_t d, Char_t r, | |
138 | UShort_t b, TH1D* h) | |
139 | { | |
140 | TObjArray* ringArray = GetOrMakeRingArray(d, r); | |
141 | if (!ringArray) return false; | |
142 | ||
143 | if (b <= 0 || b > fVertexAxis.GetNbins()) { | |
144 | AliWarning(Form("Vertex bin %3d out of range [1,%3d]", | |
145 | b, fVertexAxis.GetNbins())); | |
146 | return false; | |
147 | } | |
148 | h->SetName(Form("FMD%d%c_vtxbin%03d", d, r, b)); | |
149 | h->SetTitle(Form("Secondary map correction for FMD%d%c " | |
150 | "in vertex bin %d [%+8.4f,%+8.4f]", | |
151 | d, r, b, fVertexAxis.GetBinLowEdge(b), | |
152 | fVertexAxis.GetBinUpEdge(b))); | |
153 | h->SetXTitle("#eta"); | |
154 | h->SetYTitle("dN_{ch}/d#eta / sum_i N_{ch,i}"); | |
155 | h->SetFillStyle(3001); | |
156 | h->SetDirectory(0); | |
157 | h->SetStats(0); | |
158 | ringArray->AddAtAndExpand(h, b-1); | |
159 | return kTRUE; | |
160 | } | |
161 | //____________________________________________________________________ | |
162 | Bool_t | |
163 | AliFMDCorrMergingEfficiency::SetCorrection(UShort_t d, Char_t r, | |
164 | Double_t v, TH1D* h) | |
165 | { | |
166 | Int_t b = FindVertexBin(v); | |
167 | if (b <= 0 || b > fVertexAxis.GetNbins()) { | |
168 | AliWarning(Form("Vertex %+8.4f out of range [%+8.4f,%+8.4f]", | |
169 | v, fVertexAxis.GetXmin(), fVertexAxis.GetXmax())); | |
170 | return false; | |
171 | } | |
172 | return SetCorrection(d, r, UShort_t(b), h); | |
173 | } | |
174 | //____________________________________________________________________ | |
175 | void | |
176 | AliFMDCorrMergingEfficiency::Browse(TBrowser* b) | |
177 | { | |
178 | b->Add(&fRingArray); | |
179 | b->Add(&fVertexAxis); | |
180 | } | |
181 | //____________________________________________________________________ | |
182 | void | |
183 | AliFMDCorrMergingEfficiency::Print(Option_t* option) const | |
184 | { | |
185 | std::cout << "Merging efficiency correction" << std::endl; | |
186 | fRingArray.Print(option); | |
187 | fVertexAxis.Print(option); | |
188 | } | |
189 | ||
190 | //____________________________________________________________________ | |
191 | // | |
192 | // EOF | |
193 | // |