1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONTrackerDataHistogrammer.h"
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"
31 #include <TObjArray.h>
33 ///\class AliMUONTrackerDataHistogrammer
35 /// Class to generate histograms from AliMUONVTrackerData
36 /// (and AliMUONVPainter) objects
38 /// \author Laurent Aphecetche, Subatech
42 ClassImp(AliMUONTrackerDataHistogrammer)
45 //_____________________________________________________________________________
46 AliMUONTrackerDataHistogrammer::AliMUONTrackerDataHistogrammer(const AliMUONVTrackerData& data,
55 //_____________________________________________________________________________
56 AliMUONTrackerDataHistogrammer::~AliMUONTrackerDataHistogrammer()
61 //_____________________________________________________________________________
63 AliMUONTrackerDataHistogrammer::Add(TH1& h, const AliMUONSparseHisto& sh) const
65 /// Add sparse histo content to histogram.
67 Double_t entries(h.GetEntries());
69 for ( Int_t i = 0; i < sh.GetNbins(); ++i )
71 Int_t count = sh.GetBinContent(i);
73 h.Fill(sh.GetBinCenter(i),count);
78 h.SetEntries(entries);
80 if (sh.HasUnderflow()) h.SetBinContent(0,1);
81 if (sh.HasOverflow()) h.SetBinContent(h.GetNbinsX()+1,1);
84 //_____________________________________________________________________________
86 AliMUONTrackerDataHistogrammer::AddBusPatchHisto(TH1& h, Int_t busPatchId) const
88 /// Add data from one bus patch to the histogram
90 if ( fData.HasBusPatch(busPatchId ) )
92 AliMpBusPatch* busPatch = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
93 for ( Int_t i = 0; i < busPatch->GetNofManus(); ++i )
95 Int_t manuId = busPatch->GetManuId(i);
96 AddManuHisto(h,busPatch->GetDEId(),manuId);
100 //_____________________________________________________________________________
102 AliMUONTrackerDataHistogrammer::AddDEHisto(TH1& h, Int_t detElemId) const
104 /// Add data from one detection element to the histogram
106 if ( fData.HasDetectionElement(detElemId) )
108 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
109 for ( Int_t i = 0; i < de->GetNofBusPatches(); ++ i )
111 Int_t busPatchId = de->GetBusPatchId(i);
112 AddBusPatchHisto(h,busPatchId);
117 //_____________________________________________________________________________
119 AliMUONTrackerDataHistogrammer::AddManuHisto(TH1& h, Int_t detElemId, Int_t manuId) const
121 /// Add data from a given manu to histogram
123 if ( fData.HasManu(detElemId,manuId) )
125 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
127 if ( fData.HasChannel(detElemId,manuId,i) )
129 AliMUONSparseHisto* sh = fData.GetChannelSparseHisto(detElemId,manuId,i);
141 //_____________________________________________________________________________
143 AliMUONTrackerDataHistogrammer::CreateBusPatchHisto(Int_t busPatchId) const
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...
151 if ( fData.HasBusPatch(busPatchId) && fData.IsHistogrammed(fDim))
153 h = CreateHisto(Form("BP%04d_%d",busPatchId,fDim));
154 if ( h ) AddBusPatchHisto(*h,busPatchId);
161 //_____________________________________________________________________________
163 AliMUONTrackerDataHistogrammer::CreateChamberHisto(Int_t chamberId) const
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...
171 if ( fData.HasChamber(chamberId) && fData.IsHistogrammed(fDim))
173 h = CreateHisto(Form("CHAMBER%02d_%d",chamberId,fDim));
178 while ( !it.IsDone() )
180 Int_t detElemId = it.CurrentDEId();
181 AddDEHisto(*h,detElemId);
190 //_____________________________________________________________________________
192 AliMUONTrackerDataHistogrammer::CreateChannelHisto(Int_t detElemId, Int_t manuId,
193 Int_t manuChannel) const
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...
199 if ( fData.HasChannel(detElemId, manuId, manuChannel) && fData.IsHistogrammed(fDim) )
201 AliMUONSparseHisto* sh = fData.GetChannelSparseHisto(detElemId,manuId,manuChannel);
205 TH1* h = CreateHisto(Form("DE%04dMANU%04dCH%02d_%d",detElemId,manuId,manuChannel,fDim));
216 //_____________________________________________________________________________
218 AliMUONTrackerDataHistogrammer::CreateDEHisto(Int_t detElemId) const
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...
226 if ( fData.HasDetectionElement(detElemId) && fData.IsHistogrammed(fDim) )
228 h = CreateHisto(Form("DE%04d-%d",detElemId,fDim));
229 if (h) AddDEHisto(*h,detElemId);
235 //_____________________________________________________________________________
237 AliMUONTrackerDataHistogrammer::CreateHisto(const AliMUONVPainter& painter)
239 /// Create an histogram, from given dim of given data,
240 /// for all the channels handled by painter
242 AliMUONPainterGroup* group = painter.Master()->PlotterGroup();
244 if ( !group ) return 0x0; // no data to histogram in this painter
246 AliMUONVTrackerData* data = group->Data();
247 Int_t dim = data->InternalToExternal(group->DataIndex());
249 AliMUONTrackerDataHistogrammer tdh(*data,dim);
253 painter.FillManuList(manuArray);
256 TIter next(&manuArray);
258 TH1* histo = tdh.CreateHisto(Form("%s-%s",painter.PathName().Data(),painter.Attributes().GetName()));
260 while ( ( mid = static_cast<AliMpManuUID*>(next()) ) )
262 TH1* h = tdh.CreateManuHisto(mid->DetElemId(),mid->ManuId());
273 //_____________________________________________________________________________
275 AliMUONTrackerDataHistogrammer::CreateHisto(const char* name) const
277 /// Create a single histogram
281 fData.HistogramRange(xmin,xmax);
287 h = new TH1I(name,Form("Data=%s Dim=%s",
289 fData.ExternalDimensionName(fDim).Data()),
299 //_____________________________________________________________________________
301 AliMUONTrackerDataHistogrammer::CreateManuHisto(Int_t detElemId, Int_t manuId) const
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...
309 if ( fData.HasManu(detElemId, manuId) && fData.IsHistogrammed(fDim) )
311 h = CreateHisto(Form("DE%04dMANU%04d_%d",detElemId,manuId,fDim));
312 if ( h ) AddManuHisto(*h,detElemId,manuId);