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 "AliMUONPainterGroup.h"
20 #include "AliMUONVPainter.h"
21 #include "AliMUONVTrackerData.h"
23 #include <Riostream.h>
24 #include <TObjArray.h>
27 ///\class AliMUONPainterGroup
29 /// A group of AliMUONVPainter
31 ///\author Laurent Aphecetche, Subatech
34 ClassImp(AliMUONPainterGroup)
37 //_____________________________________________________________________________
38 AliMUONPainterGroup::AliMUONPainterGroup()
54 //_____________________________________________________________________________
55 AliMUONPainterGroup::AliMUONPainterGroup(const char* type, Int_t depth)
69 if ( fType == "" || fDepth < 0 )
71 AliFatal("Sorry guy.");
75 //_____________________________________________________________________________
76 AliMUONPainterGroup::~AliMUONPainterGroup()
82 //_____________________________________________________________________________
84 AliMUONPainterGroup::Add(AliMUONVPainter* painter)
86 /// Add a painter to this group (must be of the correct type)
88 if ( fType != painter->Type() )
90 AliError(Form("Cannot add painter of type %s to this = %s",
91 painter->Type(), fType.Data()));
95 if ( fDepth != painter->Depth() )
97 AliError(Form("Cannot add painter of depth %d to this = %d",
98 painter->Depth(), fDepth));
104 fPainters = new TObjArray;
107 painter->SetMotherGroup(this);
109 fPainters->Add(painter);
114 //_____________________________________________________________________________
116 AliMUONPainterGroup::Compare(const TObject* obj) const
118 /// Compare with another group (based on type)
120 const AliMUONPainterGroup* group = static_cast<const AliMUONPainterGroup*>(obj);
121 return fType.CompareTo(group->Type());
124 //_____________________________________________________________________________
126 AliMUONPainterGroup::ComputeDataRange(Double_t& dataMin, Double_t& dataMax)
128 /// Compute the data range spanned by this group
132 if ( !fData || fDataIndex < 0 ) return;
134 TIter next(fPainters);
137 while ( ( p = static_cast<AliMUONVPainter*>(next()) ) )
140 p->ComputeDataRange(*fData,fDataIndex,min,max);
141 dataMin = TMath::Min(min,dataMin);
142 dataMax = TMath::Max(max,dataMax);
146 //_____________________________________________________________________________
148 AliMUONPainterGroup::Draw(Option_t* opt)
150 /// Draw our painters
151 TIter next(fPainters);
153 while ( ( o = next() ) )
159 //_____________________________________________________________________________
161 AliMUONPainterGroup::First() const
163 /// Get the first painter in group
166 return static_cast<AliMUONVPainter*>(fPainters->First());
171 //_____________________________________________________________________________
173 AliMUONPainterGroup::GetLineColor() const
175 /// Get line color of this group's painters
178 return static_cast<AliMUONVPainter*>(fPainters->First())->GetLineColor();
183 //_____________________________________________________________________________
185 AliMUONPainterGroup::GetLineWidth() const
187 /// Get line width of this group's painters
190 return static_cast<AliMUONVPainter*>(fPainters->First())->GetLineWidth();
195 //_____________________________________________________________________________
197 AliMUONPainterGroup::Matches(const char* pattern) const
199 /// Whether our type matches "pattern"
200 TString spattern(pattern);
202 if ( spattern == "*" || fType.Contains(pattern) )
209 //_____________________________________________________________________________
211 AliMUONPainterGroup::Print(Option_t* opt) const
214 cout << "Type " << fType.Data() << " Depth " << fDepth;
215 if ( IsResponder() ) cout << " is responder ";
216 if ( IsVisible() ) cout << " is visible ";
219 cout << Form(" is plotter for data %p %s dimension %d %s plot range = %e, %e",
220 fData,(fData ? fData->Name() : ""),
221 fDataIndex,( (fData && fDataIndex>=0 ) ?
222 fData->DimensionName(fDataIndex).Data() : ""),
223 DataMin(),DataMax());
227 cout << " is outlined";
231 cout << " contains " << fPainters->GetLast()+1 << " painters";
238 if ( sopt == "FULL" )
240 TIter next(fPainters);
241 AliMUONVPainter* painter;
242 while ( ( painter = static_cast<AliMUONVPainter*>(next()) ) )
250 //_____________________________________________________________________________
252 AliMUONPainterGroup::SetData(AliMUONVTrackerData* data, Int_t dataIndex)
254 /// Set the data to be plotted
256 fDataIndex = dataIndex;
261 //_____________________________________________________________________________
263 AliMUONPainterGroup::SetLine(Int_t lineColor, Int_t lineWidth)
265 /// Set our outline attributes
266 TIter next(fPainters);
267 AliMUONVPainter* painter;
268 while ( ( painter = static_cast<AliMUONVPainter*>(next()) ) )
270 painter->SetLineColor(lineColor);
271 painter->SetLineWidth(lineWidth);