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
36 ClassImp(AliMUONPainterGroup)
39 //_____________________________________________________________________________
40 AliMUONPainterGroup::AliMUONPainterGroup()
56 //_____________________________________________________________________________
57 AliMUONPainterGroup::AliMUONPainterGroup(const char* type, Int_t depth)
71 if ( fType == "" || fDepth < 0 )
73 AliFatal("Sorry guy.");
77 //_____________________________________________________________________________
78 AliMUONPainterGroup::~AliMUONPainterGroup()
84 //_____________________________________________________________________________
86 AliMUONPainterGroup::Add(AliMUONVPainter* painter)
88 /// Add a painter to this group (must be of the correct type)
90 if ( fType != painter->Type() )
92 AliError(Form("Cannot add painter of type %s to this = %s",
93 painter->Type(), fType.Data()));
97 if ( fDepth != painter->Depth() )
99 AliError(Form("Cannot add painter of depth %d to this = %d",
100 painter->Depth(), fDepth));
106 fPainters = new TObjArray;
109 painter->SetMotherGroup(this);
111 fPainters->Add(painter);
116 //_____________________________________________________________________________
118 AliMUONPainterGroup::Compare(const TObject* obj) const
120 /// Compare with another group (based on type)
122 const AliMUONPainterGroup* group = static_cast<const AliMUONPainterGroup*>(obj);
123 return fType.CompareTo(group->Type());
126 //_____________________________________________________________________________
128 AliMUONPainterGroup::ComputeDataRange(Double_t& dataMin, Double_t& dataMax)
130 /// Compute the data range spanned by this group
134 if ( !fData || fDataIndex < 0 ) return;
136 TIter next(fPainters);
139 while ( ( p = static_cast<AliMUONVPainter*>(next()) ) )
142 p->ComputeDataRange(*fData,fDataIndex,min,max);
143 dataMin = TMath::Min(min,dataMin);
144 dataMax = TMath::Max(max,dataMax);
148 //_____________________________________________________________________________
150 AliMUONPainterGroup::Draw(Option_t* opt)
152 /// Draw our painters
153 TIter next(fPainters);
155 while ( ( o = next() ) )
161 //_____________________________________________________________________________
163 AliMUONPainterGroup::First() const
165 /// Get the first painter in group
168 return static_cast<AliMUONVPainter*>(fPainters->First());
173 //_____________________________________________________________________________
175 AliMUONPainterGroup::GetLineColor() const
177 /// Get line color of this group's painters
180 return static_cast<AliMUONVPainter*>(fPainters->First())->GetLineColor();
185 //_____________________________________________________________________________
187 AliMUONPainterGroup::GetLineWidth() const
189 /// Get line width of this group's painters
192 return static_cast<AliMUONVPainter*>(fPainters->First())->GetLineWidth();
197 //_____________________________________________________________________________
199 AliMUONPainterGroup::Matches(const char* pattern) const
201 /// Whether our type matches "pattern"
202 TString spattern(pattern);
204 if ( spattern == "*" || fType.Contains(pattern) )
211 //_____________________________________________________________________________
213 AliMUONPainterGroup::Print(Option_t* opt) const
216 cout << "Type " << fType.Data() << " Depth " << fDepth;
217 if ( IsResponder() ) cout << " is responder ";
218 if ( IsVisible() ) cout << " is visible ";
221 cout << Form(" is plotter for data %p %s dimension %d %s plot range = %e, %e",
222 fData,(fData ? fData->Name() : ""),
223 fDataIndex,( (fData && fDataIndex>=0 ) ?
224 fData->DimensionName(fDataIndex).Data() : ""),
225 DataMin(),DataMax());
229 cout << " is outlined";
233 cout << " contains " << fPainters->GetLast()+1 << " painters";
240 if ( sopt == "FULL" )
242 TIter next(fPainters);
243 AliMUONVPainter* painter;
244 while ( ( painter = static_cast<AliMUONVPainter*>(next()) ) )
252 //_____________________________________________________________________________
254 AliMUONPainterGroup::SetData(AliMUONVTrackerData* data, Int_t dataIndex)
256 /// Set the data to be plotted
258 fDataIndex = dataIndex;
263 //_____________________________________________________________________________
265 AliMUONPainterGroup::SetLine(Int_t lineColor, Int_t lineWidth)
267 /// Set our outline attributes
268 TIter next(fPainters);
269 AliMUONVPainter* painter;
270 while ( ( painter = static_cast<AliMUONVPainter*>(next()) ) )
272 painter->SetLineColor(lineColor);
273 painter->SetLineWidth(lineWidth);