]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONPainterGroup.cxx
Increase size in char array to avoid overflow
[u/mrichter/AliRoot.git] / MUON / AliMUONPainterGroup.cxx
CommitLineData
0145e89a 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 "AliMUONPainterGroup.h"
19
20#include "AliMUONVPainter.h"
21#include "AliMUONVTrackerData.h"
22#include "AliLog.h"
23#include <Riostream.h>
24#include <TObjArray.h>
25#include <float.h>
26
27///\class AliMUONPainterGroup
28///
29/// A group of AliMUONVPainter
30///
31///\author Laurent Aphecetche, Subatech
32
33///\cond CLASSIMP
34ClassImp(AliMUONPainterGroup)
35///\endcond
36
37//_____________________________________________________________________________
38AliMUONPainterGroup::AliMUONPainterGroup()
39: TObject(),
40fType(""),
41fIsResponder(kFALSE),
42fIsVisible(kTRUE),
43fData(0x0),
44fDataIndex(-1),
45fDataMin(FLT_MAX),
46fDataMax(-FLT_MAX),
47fPainters(0x0),
48fDepth(-1),
49fIsOutlined(kTRUE)
50{
51 /// ctor
52}
53
54//_____________________________________________________________________________
55AliMUONPainterGroup::AliMUONPainterGroup(const char* type, Int_t depth)
56: TObject(),
57 fType(type),
58 fIsResponder(kFALSE),
59 fIsVisible(kTRUE),
60 fData(0x0),
61 fDataIndex(-1),
62 fDataMin(FLT_MAX),
63 fDataMax(-FLT_MAX),
64 fPainters(0x0),
65 fDepth(depth),
66 fIsOutlined(kTRUE)
67{
68 /// ctor
69 if ( fType == "" || fDepth < 0 )
70 {
fc2293be 71 AliFatal("Sorry guy.");
0145e89a 72 }
73}
74
75//_____________________________________________________________________________
76AliMUONPainterGroup::~AliMUONPainterGroup()
77{
78 /// dtor
79 delete fPainters;
80}
81
82//_____________________________________________________________________________
83Bool_t
84AliMUONPainterGroup::Add(AliMUONVPainter* painter)
85{
86 /// Add a painter to this group (must be of the correct type)
87
88 if ( fType != painter->Type() )
89 {
90 AliError(Form("Cannot add painter of type %s to this = %s",
91 painter->Type(), fType.Data()));
92 return kFALSE;
93 }
94
95 if ( fDepth != painter->Depth() )
96 {
97 AliError(Form("Cannot add painter of depth %d to this = %d",
98 painter->Depth(), fDepth));
99 return kFALSE;
100 }
101
102 if (!fPainters)
103 {
104 fPainters = new TObjArray;
105 }
106
107 painter->SetMotherGroup(this);
108
109 fPainters->Add(painter);
110
111 return kTRUE;
112}
113
114//_____________________________________________________________________________
115Int_t
116AliMUONPainterGroup::Compare(const TObject* obj) const
117{
118 /// Compare with another group (based on type)
119
120 const AliMUONPainterGroup* group = static_cast<const AliMUONPainterGroup*>(obj);
121 return fType.CompareTo(group->Type());
122}
123
124//_____________________________________________________________________________
125void
126AliMUONPainterGroup::ComputeDataRange(Double_t& dataMin, Double_t& dataMax)
127{
128 /// Compute the data range spanned by this group
129 dataMin = FLT_MAX;
130 dataMax = -FLT_MAX;
131
132 if ( !fData || fDataIndex < 0 ) return;
133
134 TIter next(fPainters);
135 AliMUONVPainter* p;
136
137 while ( ( p = static_cast<AliMUONVPainter*>(next()) ) )
138 {
139 Double_t min, max;
140 p->ComputeDataRange(*fData,fDataIndex,min,max);
141 dataMin = TMath::Min(min,dataMin);
142 dataMax = TMath::Max(max,dataMax);
143 }
144}
145
146//_____________________________________________________________________________
147void
148AliMUONPainterGroup::Draw(Option_t* opt)
149{
150 /// Draw our painters
151 TIter next(fPainters);
152 TObject* o;
153 while ( ( o = next() ) )
154 {
155 o->Draw(opt);
156 }
157}
158
159//_____________________________________________________________________________
160AliMUONVPainter*
161AliMUONPainterGroup::First() const
162{
163 /// Get the first painter in group
164 if ( fPainters )
165 {
166 return static_cast<AliMUONVPainter*>(fPainters->First());
167 }
168 return 0x0;
169}
170
171//_____________________________________________________________________________
172Int_t
173AliMUONPainterGroup::GetLineColor() const
174{
175 /// Get line color of this group's painters
176 if ( fPainters )
177 {
178 return static_cast<AliMUONVPainter*>(fPainters->First())->GetLineColor();
179 }
180 return 1;
181}
182
183//_____________________________________________________________________________
184Int_t
185AliMUONPainterGroup::GetLineWidth() const
186{
187 /// Get line width of this group's painters
188 if ( fPainters )
189 {
190 return static_cast<AliMUONVPainter*>(fPainters->First())->GetLineWidth();
191 }
192 return 1;
193}
194
195//_____________________________________________________________________________
196Bool_t
197AliMUONPainterGroup::Matches(const char* pattern) const
198{
199 /// Whether our type matches "pattern"
200 TString spattern(pattern);
201
202 if ( spattern == "*" || fType.Contains(pattern) )
203 {
204 return kTRUE;
205 }
206 return kFALSE;
207}
208
209//_____________________________________________________________________________
210void
211AliMUONPainterGroup::Print(Option_t* opt) const
212{
213 /// Printout
214 cout << "Type " << fType.Data() << " Depth " << fDepth;
215 if ( IsResponder() ) cout << " is responder ";
216 if ( IsVisible() ) cout << " is visible ";
217 if ( IsPlotter() )
218 {
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());
224 }
225 if ( IsOutlined() )
226 {
227 cout << " is outlined";
228 }
229 if ( fPainters )
230 {
231 cout << " contains " << fPainters->GetLast()+1 << " painters";
232 }
233
234 cout << endl;
235
236 TString sopt(opt);
237 sopt.ToUpper();
238 if ( sopt == "FULL" )
239 {
240 TIter next(fPainters);
241 AliMUONVPainter* painter;
242 while ( ( painter = static_cast<AliMUONVPainter*>(next()) ) )
243 {
244 cout << " ";
245 painter->Print();
246 }
247 }
248}
249
250//_____________________________________________________________________________
251void
252AliMUONPainterGroup::SetData(AliMUONVTrackerData* data, Int_t dataIndex)
253{
254 /// Set the data to be plotted
255 fData = data;
256 fDataIndex = dataIndex;
257 fDataMax = -FLT_MAX;
258 fDataMin = FLT_MAX;
259}
260
261//_____________________________________________________________________________
262void
263AliMUONPainterGroup::SetLine(Int_t lineColor, Int_t lineWidth)
264{
265 /// Set our outline attributes
266 TIter next(fPainters);
267 AliMUONVPainter* painter;
268 while ( ( painter = static_cast<AliMUONVPainter*>(next()) ) )
269 {
270 painter->SetLineColor(lineColor);
271 painter->SetLineWidth(lineWidth);
272 }
273}
274