]>
Commit | Line | Data |
---|---|---|
10eb3d17 | 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 | // $Id$ | |
17 | ||
18 | #include "AliMUONTrackerDataHistogrammer.h" | |
19 | ||
20 | #include "AliMUONPainterGroup.h" | |
21 | #include "AliMUONSparseHisto.h" | |
22 | #include "AliMUONVPainter.h" | |
23 | #include "AliMUONVTrackerData.h" | |
24 | #include "AliMpBusPatch.h" | |
25 | #include "AliMpConstants.h" | |
26 | #include "AliMpDDLStore.h" | |
27 | #include "AliMpDEIterator.h" | |
28 | #include "AliMpDetElement.h" | |
29 | #include "AliMpManuUID.h" | |
30 | #include <TH1.h> | |
31 | #include <TObjArray.h> | |
32 | ||
33 | ///\class AliMUONTrackerDataHistogrammer | |
34 | /// | |
35 | /// Class to generate histograms from AliMUONVTrackerData | |
36 | /// (and AliMUONVPainter) objects | |
37 | /// | |
38 | /// \author Laurent Aphecetche, Subatech | |
39 | /// | |
40 | ||
41 | ///\cond CLASSIMP | |
42 | ClassImp(AliMUONTrackerDataHistogrammer) | |
43 | ///\endcond CLASSIMP | |
44 | ||
45 | //_____________________________________________________________________________ | |
46 | AliMUONTrackerDataHistogrammer::AliMUONTrackerDataHistogrammer(const AliMUONVTrackerData& data, | |
47 | Int_t dim) | |
48 | : TObject(), | |
49 | fData(data), | |
50 | fDim(dim) | |
51 | { | |
52 | /// ctor | |
53 | } | |
54 | ||
55 | //_____________________________________________________________________________ | |
56 | AliMUONTrackerDataHistogrammer::~AliMUONTrackerDataHistogrammer() | |
57 | { | |
58 | /// dtor | |
59 | } | |
60 | ||
61 | //_____________________________________________________________________________ | |
62 | void | |
63 | AliMUONTrackerDataHistogrammer::Add(TH1& h, const AliMUONSparseHisto& sh) const | |
64 | { | |
65 | /// Add sparse histo content to histogram. | |
66 | ||
67 | Double_t entries(h.GetEntries()); | |
68 | ||
69 | for ( Int_t i = 0; i < sh.GetNbins(); ++i ) | |
70 | { | |
71 | Int_t count = sh.GetBinContent(i); | |
72 | ||
73 | h.Fill(sh.GetBinCenter(i),count); | |
74 | ||
75 | entries += count; | |
76 | } | |
77 | ||
78 | h.SetEntries(entries); | |
79 | ||
80 | if (sh.HasUnderflow()) h.SetBinContent(0,1); | |
81 | if (sh.HasOverflow()) h.SetBinContent(h.GetNbinsX()+1,1); | |
82 | } | |
83 | ||
84 | //_____________________________________________________________________________ | |
85 | void | |
86 | AliMUONTrackerDataHistogrammer::AddBusPatchHisto(TH1& h, Int_t busPatchId) const | |
87 | { | |
88 | /// Add data from one bus patch to the histogram | |
89 | ||
90 | if ( fData.HasBusPatch(busPatchId ) ) | |
91 | { | |
92 | AliMpBusPatch* busPatch = AliMpDDLStore::Instance()->GetBusPatch(busPatchId); | |
93 | for ( Int_t i = 0; i < busPatch->GetNofManus(); ++i ) | |
94 | { | |
95 | Int_t manuId = busPatch->GetManuId(i); | |
96 | AddManuHisto(h,busPatch->GetDEId(),manuId); | |
97 | } | |
98 | } | |
99 | } | |
100 | //_____________________________________________________________________________ | |
101 | void | |
102 | AliMUONTrackerDataHistogrammer::AddDEHisto(TH1& h, Int_t detElemId) const | |
103 | { | |
104 | /// Add data from one detection element to the histogram | |
105 | ||
106 | if ( fData.HasDetectionElement(detElemId) ) | |
107 | { | |
108 | AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); | |
109 | for ( Int_t i = 0; i < de->GetNofBusPatches(); ++ i ) | |
110 | { | |
111 | Int_t busPatchId = de->GetBusPatchId(i); | |
112 | AddBusPatchHisto(h,busPatchId); | |
113 | } | |
114 | } | |
115 | } | |
116 | ||
117 | //_____________________________________________________________________________ | |
118 | void | |
119 | AliMUONTrackerDataHistogrammer::AddManuHisto(TH1& h, Int_t detElemId, Int_t manuId) const | |
120 | { | |
121 | /// Add data from a given manu to histogram | |
122 | ||
123 | if ( fData.HasManu(detElemId,manuId) ) | |
124 | { | |
125 | for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i ) | |
126 | { | |
127 | if ( fData.HasChannel(detElemId,manuId,i) ) | |
128 | { | |
129 | AliMUONSparseHisto* sh = fData.GetChannelSparseHisto(detElemId,manuId,i); | |
130 | ||
131 | if ( sh ) | |
132 | { | |
133 | Add(h,*sh); | |
134 | } | |
135 | } | |
136 | } | |
137 | } | |
138 | } | |
139 | ||
140 | ||
141 | //_____________________________________________________________________________ | |
142 | TH1* | |
143 | AliMUONTrackerDataHistogrammer::CreateBusPatchHisto(Int_t busPatchId) const | |
144 | { | |
145 | /// Create histogram of a given bus patch. Note that in order | |
146 | /// to keep memory footprint as low as possible, you should delete | |
147 | /// the returned pointer as soon as possible... | |
148 | ||
149 | TH1* h(0x0); | |
150 | ||
151 | if ( fData.HasBusPatch(busPatchId) && fData.IsHistogrammed(fDim)) | |
152 | { | |
153 | h = CreateHisto(Form("BP%04d_%d",busPatchId,fDim)); | |
154 | if ( h ) AddBusPatchHisto(*h,busPatchId); | |
155 | } | |
156 | ||
157 | return h; | |
158 | } | |
159 | ||
160 | ||
161 | //_____________________________________________________________________________ | |
162 | TH1* | |
163 | AliMUONTrackerDataHistogrammer::CreateChamberHisto(Int_t chamberId) const | |
164 | { | |
165 | /// Create histogram of a given chamber. Note that in order | |
166 | /// to keep memory footprint as low as possible, you should delete | |
167 | /// the returned pointer as soon as possible... | |
168 | ||
169 | TH1* h(0x0); | |
170 | ||
171 | if ( fData.HasChamber(chamberId) && fData.IsHistogrammed(fDim)) | |
172 | { | |
173 | h = CreateHisto(Form("CHAMBER%02d_%d",chamberId,fDim)); | |
174 | if ( h ) | |
175 | { | |
176 | AliMpDEIterator it; | |
177 | it.First(chamberId); | |
178 | while ( !it.IsDone() ) | |
179 | { | |
180 | Int_t detElemId = it.CurrentDEId(); | |
181 | AddDEHisto(*h,detElemId); | |
182 | it.Next(); | |
183 | } | |
184 | } | |
185 | } | |
186 | ||
187 | return h; | |
188 | } | |
189 | ||
190 | //_____________________________________________________________________________ | |
191 | TH1* | |
192 | AliMUONTrackerDataHistogrammer::CreateChannelHisto(Int_t detElemId, Int_t manuId, | |
193 | Int_t manuChannel) const | |
194 | { | |
195 | /// Create histogram of a given channel. Note that in order | |
196 | /// to keep memory footprint as low as possible, you should delete | |
197 | /// the returned pointer as soon as possible... | |
198 | ||
199 | if ( fData.HasChannel(detElemId, manuId, manuChannel) && fData.IsHistogrammed(fDim) ) | |
200 | { | |
201 | AliMUONSparseHisto* sh = fData.GetChannelSparseHisto(detElemId,manuId,manuChannel); | |
202 | ||
203 | if ( sh ) | |
204 | { | |
205 | TH1* h = CreateHisto(Form("DE%04dMANU%04dCH%02d_%d",detElemId,manuId,manuChannel,fDim)); | |
206 | if (h ) | |
207 | { | |
208 | Add(*h,*sh); | |
209 | } | |
210 | return h; | |
211 | } | |
212 | } | |
213 | return 0x0; | |
214 | } | |
215 | ||
216 | //_____________________________________________________________________________ | |
217 | TH1* | |
218 | AliMUONTrackerDataHistogrammer::CreateDEHisto(Int_t detElemId) const | |
219 | { | |
220 | /// Create histogram of a given detection element. Note that in order | |
221 | /// to keep memory footprint as low as possible, you should delete | |
222 | /// the returned pointer as soon as possible... | |
223 | ||
224 | TH1* h(0x0); | |
225 | ||
226 | if ( fData.HasDetectionElement(detElemId) && fData.IsHistogrammed(fDim) ) | |
227 | { | |
228 | h = CreateHisto(Form("DE%04d-%d",detElemId,fDim)); | |
229 | if (h) AddDEHisto(*h,detElemId); | |
230 | } | |
231 | ||
232 | return h; | |
233 | } | |
234 | ||
235 | //_____________________________________________________________________________ | |
236 | TH1* | |
237 | AliMUONTrackerDataHistogrammer::CreateHisto(const AliMUONVPainter& painter) | |
238 | { | |
239 | /// Create an histogram, from given dim of given data, | |
240 | /// for all the channels handled by painter | |
241 | ||
242 | AliMUONPainterGroup* group = painter.Master()->PlotterGroup(); | |
243 | ||
244 | if ( !group ) return 0x0; // no data to histogram in this painter | |
245 | ||
246 | AliMUONVTrackerData* data = group->Data(); | |
247 | Int_t dim = data->InternalToExternal(group->DataIndex()); | |
248 | ||
249 | AliMUONTrackerDataHistogrammer tdh(*data,dim); | |
250 | ||
251 | TObjArray manuArray; | |
252 | ||
253 | painter.FillManuList(manuArray); | |
254 | ||
255 | AliMpManuUID* mid; | |
256 | TIter next(&manuArray); | |
257 | ||
258 | TH1* histo = tdh.CreateHisto(Form("%s-%s",painter.PathName().Data(),painter.Attributes().GetName())); | |
259 | ||
260 | while ( ( mid = static_cast<AliMpManuUID*>(next()) ) ) | |
261 | { | |
262 | TH1* h = tdh.CreateManuHisto(mid->DetElemId(),mid->ManuId()); | |
263 | if ( h ) | |
264 | { | |
265 | histo->Add(h); | |
266 | } | |
267 | delete h; | |
268 | } | |
269 | ||
270 | return histo; | |
271 | } | |
272 | ||
273 | //_____________________________________________________________________________ | |
274 | TH1* | |
275 | AliMUONTrackerDataHistogrammer::CreateHisto(const char* name) const | |
276 | { | |
277 | /// Create a single histogram | |
278 | ||
279 | Double_t xmin, xmax; | |
280 | ||
281 | fData.HistogramRange(xmin,xmax); | |
282 | ||
283 | TH1* h(0x0); | |
284 | ||
285 | if ( xmin != xmax ) | |
286 | { | |
287 | h = new TH1I(name,Form("Data=%s Dim=%s", | |
288 | fData.GetName(), | |
289 | fData.ExternalDimensionName(fDim).Data()), | |
290 | (1<<12), | |
291 | xmin-0.5, | |
292 | xmax-0.5); | |
293 | h->SetDirectory(0); | |
294 | } | |
295 | return h; | |
296 | } | |
297 | ||
298 | ||
299 | //_____________________________________________________________________________ | |
300 | TH1* | |
301 | AliMUONTrackerDataHistogrammer::CreateManuHisto(Int_t detElemId, Int_t manuId) const | |
302 | { | |
303 | /// Create histogram of a given manu. Note that in order | |
304 | /// to keep memory footprint as low as possible, you should delete | |
305 | /// the returned pointer as soon as possible... | |
306 | ||
307 | TH1* h(0x0); | |
308 | ||
309 | if ( fData.HasManu(detElemId, manuId) && fData.IsHistogrammed(fDim) ) | |
310 | { | |
311 | h = CreateHisto(Form("DE%04dMANU%04d_%d",detElemId,manuId,fDim)); | |
312 | if ( h ) AddManuHisto(*h,detElemId,manuId); | |
313 | } | |
314 | ||
315 | return h; | |
316 | } | |
317 |