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