AliRoot Core  v5-06-30 (35d6c57)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONTrackerDataHistogrammer.cxx
Go to the documentation of this file.
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 
19 
20 #include "AliLog.h"
21 #include "AliMUONPainterGroup.h"
22 #include "AliMUONSparseHisto.h"
23 #include "AliMUONVPainter.h"
24 #include "AliMUONVTrackerData.h"
25 #include "AliMpBusPatch.h"
26 #include "AliMpConstants.h"
27 #include "AliMpDDLStore.h"
28 #include "AliMpDEIterator.h"
29 #include "AliMpDetElement.h"
30 #include "AliMpManuUID.h"
31 #include <TClass.h>
32 #include <TH1.h>
33 #include <TObjArray.h>
34 #include <TROOT.h>
35 #include <TMath.h>
36 
44 
48 
49 //_____________________________________________________________________________
51  Int_t externalDim,
52  Int_t internalDim)
53 : TObject(),
54 fkData(data),
55 fExternalDim(externalDim),
56 fInternalDim(internalDim)
57 {
59 }
60 
61 //_____________________________________________________________________________
63 {
65 }
66 
67 //_____________________________________________________________________________
68 void
70 {
72 
73  Double_t entries(h.GetEntries());
74 
75  for ( Int_t i = 0; i < sh.GetNbins(); ++i )
76  {
77  Int_t count = sh.GetBinContent(i);
78 
79  h.Fill(sh.GetBinCenter(i),count);
80 
81  entries += count;
82  }
83 
84  h.SetEntries(entries);
85 
86  if (sh.HasUnderflow()) h.SetBinContent(0,1);
87  if (sh.HasOverflow()) h.SetBinContent(h.GetNbinsX()+1,1);
88 }
89 
90 //_____________________________________________________________________________
91 void
92 AliMUONTrackerDataHistogrammer::AddBusPatchHisto(TH1& h, Int_t busPatchId) const
93 {
95 
96  if ( fkData.HasBusPatch(busPatchId ) )
97  {
98  AliMpBusPatch* busPatch = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
99  for ( Int_t i = 0; i < busPatch->GetNofManus(); ++i )
100  {
101  Int_t manuId = busPatch->GetManuId(i);
102  AddManuHisto(h,busPatch->GetDEId(),manuId);
103  }
104  }
105 }
106 //_____________________________________________________________________________
107 void
108 AliMUONTrackerDataHistogrammer::AddDEHisto(TH1& h, Int_t detElemId) const
109 {
111 
112  if ( fkData.HasDetectionElement(detElemId) )
113  {
115  for ( Int_t i = 0; i < de->GetNofBusPatches(); ++ i )
116  {
117  Int_t busPatchId = de->GetBusPatchId(i);
118  AddBusPatchHisto(h,busPatchId);
119  }
120  }
121 }
122 
123 //_____________________________________________________________________________
124 void
125 AliMUONTrackerDataHistogrammer::AddManuHisto(TH1& h, Int_t detElemId, Int_t manuId) const
126 {
128 
129  if ( fkData.HasManu(detElemId,manuId) )
130  {
132  {
133  for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
134  {
135  if ( fkData.HasChannel(detElemId,manuId,i) )
136  {
137  if ( IsInternalMode() )
138  {
139  h.Fill(fkData.Channel(detElemId,manuId,i,fInternalDim));
140  }
141  else
142  {
144 
145  if ( sh )
146  {
147  Add(h,*sh);
148  }
149  }
150  }
151  }
152  }
153  else
154  {
155  if ( IsInternalMode() )
156  {
157  h.Fill(fkData.Manu(detElemId,manuId,fInternalDim));
158  }
159  else
160  {
162  if (sh)
163  {
164  Add(h,*sh);
165  }
166  }
167  }
168  }
169 }
170 
171 //_____________________________________________________________________________
172 TH1*
174  Int_t manuId,
175  Int_t manuChannel) const
176 {
180 
181  if ( fkData.HasChannel(detElemId, manuId, manuChannel) && fkData.IsHistogrammed(fExternalDim) )
182  {
183  AliMUONSparseHisto* sh = fkData.GetChannelSparseHisto(detElemId,manuId,manuChannel);
184 
185  if ( sh )
186  {
187  Int_t nbins((1<<sh->Nbits()));
188  Double_t xmin,xmax;
189  fkData.HistogramRange(xmin,xmax);
190 
191  TH1* h = CreateHisto(Form("DE%04dMANU%04dCH%02d",detElemId,manuId,manuChannel),
192  nbins,xmin,xmax);
193  if (h )
194  {
195  Add(*h,*sh);
196  }
197  return h;
198  }
199  }
200  return 0x0;
201 }
202 
203 //_____________________________________________________________________________
204 TH1*
206  Int_t nbins,
207  Double_t xmin,
208  Double_t xmax) const
209 {
211 
212  TH1* h(0);
213 
214  if ( xmin < xmax )
215  {
216  h = new TH1F(name,name,nbins,xmin,xmax);
217  h->SetDirectory(gROOT);
218  }
219  else
220  {
221  AliError(Form("Cannot create histo for name=%s nbins=%d xmin=%e xmax=%e",name,nbins,xmin,xmax));
222  }
223  return h;
224 }
225 
226 //_____________________________________________________________________________
227 TH1*
229  Int_t externalDim,
230  Int_t internalDim)
231 {
234 
235  AliMUONPainterGroup* group = painter.Master()->PlotterGroup();
236 
237  if ( !group ) return 0x0; // no data to histogram in this painter
238 
239  AliMUONVTrackerData* data = group->Data();
240 
241  if ( externalDim >= data->ExternalDimension() )
242  {
243  AliErrorClass(Form("externalDim %d is out of bounds",externalDim));
244  return 0x0;
245  }
246 
247  if ( internalDim >= data->NumberOfDimensions() )
248  {
249  AliErrorClass(Form("internalDim %d is out of bounds",internalDim));
250  return 0x0;
251  }
252 
253  if ( internalDim < 0 && externalDim < 0 )
254  {
255  AliErrorClass("Both internal and external dim are < 0 !!!");
256  return 0x0;
257  }
258 
259  AliMUONTrackerDataHistogrammer tdh(*data,externalDim,internalDim);
260 
261  TObjArray manuArray;
262 
263  painter.FillManuList(manuArray);
264 
265  AliMpManuUID* mid;
266  TIter next(&manuArray);
267 
268  TString basename(Form("%s-%s",painter.PathName().Data(),painter.Attributes().GetName()));
269  TString ext;
270  Int_t nbins((1<<12));
271  Double_t xmin(0.0);
272  Double_t xmax(0.0);
273 
274  if ( !tdh.IsInternalMode() )
275  {
276  data->HistogramRange(xmin,xmax);
277 
278  xmin -= 0.5;
279  xmax -= 0.5;
280 
281  ext = data->ExternalDimensionName(externalDim).Data();
282  }
283  else
284  {
285  tdh.GetDataRange(manuArray,xmin,xmax);
286  ext = data->DimensionName(internalDim).Data();
287  nbins = 100;
288  }
289 
290  TString name(Form("%s-%s",basename.Data(),ext.Data()));
291 
292  TH1* histo = tdh.CreateHisto(name.Data(),nbins,xmin,xmax);
293 
294  if ( histo )
295  {
296  while ( ( mid = static_cast<AliMpManuUID*>(next()) ) )
297  {
298  TH1* h = tdh.CreateManuHisto(mid->DetElemId(),mid->ManuId(),nbins,xmin,xmax);
299  if ( h )
300  {
301  histo->Add(h);
302  }
303  delete h;
304  }
305  }
306  else
307  {
308  AliErrorClass(Form("Could not create histo for painter %s (%p) data %s (%p) external dim %d internal dim %d",
309  painter.PathName().Data(),&painter,
310  data->GetName(),data,externalDim,internalDim));
311  }
312 
313  if (histo) histo->SetDirectory(gROOT);
314 
315  return histo;
316 }
317 
318 //_____________________________________________________________________________
319 TH1*
321  Int_t nbins,
322  Double_t xmin,
323  Double_t xmax) const
324 {
328 
329  TH1* h(0x0);
330 
331  if ( !fkData.HasManu(detElemId,manuId) ) return 0x0;
332 
333  if ( ( fExternalDim >= 0 && fkData.IsHistogrammed(fExternalDim) ) ||
335  {
336  h = CreateHisto(Form("DE%04dMANU%04d",detElemId,manuId),
337  nbins,xmin,xmax);
338  if ( h ) AddManuHisto(*h,detElemId,manuId);
339  }
340 
341  return h;
342 }
343 
344 //_____________________________________________________________________________
345 void
347  Double_t& xmin, Double_t& xmax) const
348 {
351 
352  xmin = FLT_MAX;
353  xmax = -FLT_MAX;
354 
355  if (!IsInternalMode())
356  {
357  AliError("Cannot use this method for external mode !");
358  }
359 
360  AliMpManuUID* mid;
361  TIter next(&manuArray);
362 
363  while ( ( mid = static_cast<AliMpManuUID*>(next()) ) )
364  {
365  Int_t detElemId = mid->DetElemId();
366  Int_t manuId = mid->ManuId();
367 
368  for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
369  {
370  if ( fkData.HasChannel(detElemId,manuId,i) )
371  {
372  Double_t value = fkData.Channel(detElemId,manuId,i,fInternalDim);
373 
374  if ( ! TMath::Finite(value) )
375  {
376  AliError(Form("Got a NaN for DE %d manu %d ch %d",detElemId,manuId,i));
377  }
378  else
379  {
380  xmin = TMath::Min(xmin,value);
381  xmax = TMath::Max(xmax,value);
382  }
383  }
384  }
385  }
386 
387 }
388 
Int_t GetNofManus() const
Bool_t HasOverflow() const
Int_t fExternalDim
(external) dimension we'll histogram
#define TObjArray
Int_t GetNbins() const
Return number of bins we hold.
Int_t DetElemId() const
Get detection element.
Definition: AliMpManuUID.h:27
Make histograms from VTrackerData and VPainter objects.
virtual Bool_t HasManu(Int_t detElemId, Int_t manuId) const =0
Whether we have data for a given manu.
static TH1 * CreateHisto(const AliMUONVPainter &painter, Int_t externalDim, Int_t internalDim)
TROOT * gROOT
virtual Bool_t HasChannel(Int_t detElemId, Int_t manuId, Int_t manuChannel) const
Whether we have a given channel or not.
virtual Double_t Channel(Int_t detElemId, Int_t manuId, Int_t manuChannel, Int_t dim=0) const =0
Get the value for a given channel and given dimension.
void AddManuHisto(TH1 &h, Int_t detElemId, Int_t manuId) const
Int_t GetDEId() const
Return the Detection element Id.
Definition: AliMpBusPatch.h:93
virtual TString PathName() const
Get our path name (aka fullname)
Double_t GetBinCenter(Int_t bin) const
AliMpDetElement * GetDetElement(Int_t detElemId, Bool_t warn=true) const
Int_t GetManuId(Int_t index) const
The class defines the electronics properties of detection element.
Bool_t HasUnderflow() const
virtual TString DimensionName(Int_t dim) const =0
Get the name of a given (internal) dimension.
Unique ID for manus.
Definition: AliMpManuUID.h:19
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Int_t GetBinContent(Int_t bin) const
AliMUONVTrackerData * Data() const
Return the data we are plotting.
static AliMpDDLStore * Instance(Bool_t warn=true)
void GetDataRange(const TObjArray &manuList, Double_t &xmin, Double_t &xmax) const
const AliMUONAttPainter & Attributes() const
Get our attributes.
static Int_t ManuNofChannels()
Max number of channels per manu.
Base class for a graphical object representing some part of the MUON tracking system.
virtual Double_t Manu(Int_t detElemId, Int_t manuId, Int_t dim=0) const =0
Get the value for a given manu and given dimension.
TH1 * CreateManuHisto(Int_t detElemId, Int_t manuId, Int_t nbins, Double_t xmin, Double_t xmax) const
virtual void HistogramRange(Double_t &xmin, Double_t &xmax) const
Get histogram range.
virtual AliMUONSparseHisto * GetManuSparseHisto(Int_t detElemId, Int_t manuId, Int_t dim=0) const =0
Get sparse histogram for a given manu (valid only if IsChannelLevelEnabled()==kFALSE and IsManuLevelE...
virtual const char * GetName() const
Return our name.
virtual Bool_t HasDetectionElement(Int_t detElemId) const =0
Whether we have data for a given detection element.
AliMUONVPainter * Master() const
AliMpBusPatch * GetBusPatch(Int_t busPatchId, Bool_t warn=true) const
A very memory compact histogram to hold some tracker distributions.
virtual AliMUONSparseHisto * GetChannelSparseHisto(Int_t detElemId, Int_t manuId, Int_t manuChannel, Int_t dim=0) const =0
Get sparse histogram for a given channel.
virtual Bool_t IsHistogrammed(Int_t) const
Whether we have histograms for a given dimension, or not.
void AddDEHisto(TH1 &h, Int_t detElemId) const
Int_t fInternalDim
(internal) dimension we'll make histogram for
TH1 * CreateChannelHisto(Int_t detElemId, Int_t manuId, Int_t manuChannel) const
Int_t ManuId() const
Get manu identifier.
Definition: AliMpManuUID.h:30
Int_t GetNofBusPatches() const
The class defines the properties of BusPatch.
Definition: AliMpBusPatch.h:21
void Add(TH1 &h, const AliMUONSparseHisto &sh) const
virtual Bool_t IsChannelLevelEnabled() const =0
Whether we store values at the channel level.
virtual void FillManuList(TObjArray &manuList) const
Append (i.e. don't have the right to clear the array !) our list of manus to manuList.
Int_t Nbits() const
Number of bits used to code the x-value of the histogram.
Int_t GetBusPatchId(Int_t index) const
void AddBusPatchHisto(TH1 &h, Int_t busPatchId) const
virtual TString ExternalDimensionName(Int_t dim) const =0
Get the name of a given (external) dimension.
virtual Int_t NumberOfDimensions() const =0
The number of dimensions we are handling.
Bool_t IsInternalMode() const
Whether we are working with internal dimensions or external ones.
A group of AliMUONVPainter.
AliMUONPainterGroup * PlotterGroup() const
Return the plotter group.
Base class for MUON data that can be presented at different levels in the hierarchy of the MUON syste...
virtual Bool_t HasBusPatch(Int_t busPatchId) const =0
Whether we have data for a given buspath.
const AliMUONVTrackerData & fkData
data we'll histogram
virtual Int_t ExternalDimension() const =0
The number of dimensions we are inputting.