]>
Commit | Line | Data |
---|---|---|
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 "AliMUONChamberPainter.h" | |
19 | ||
20 | #include "AliMUONDEPainter.h" | |
21 | #include "AliMUONPainterContour.h" | |
22 | #include "AliMUONPainterHelper.h" | |
23 | #include "AliMUONVCalibParam.h" | |
24 | #include "AliMUONVTrackerData.h" | |
25 | #include "AliMpConstants.h" | |
26 | #include "AliMpDEIterator.h" | |
27 | #include "AliMpDEManager.h" | |
28 | #include "AliMpPlaneType.h" | |
29 | #include "AliMpSegmentation.h" | |
30 | #include "AliMpStationType.h" | |
31 | #include "AliMpVSegmentation.h" | |
32 | #include "AliMUONObjectPair.h" | |
33 | #include "AliLog.h" | |
34 | #include <Riostream.h> | |
35 | #include <TObjString.h> | |
36 | #include <TArrayI.h> | |
37 | #include <cassert> | |
38 | #include <float.h> | |
39 | ||
40 | /// \class AliMUONChamberPainter | |
41 | /// | |
42 | /// Painter for one plane/cathode of one chamber | |
43 | /// | |
44 | /// \author Laurent Aphecetche, Subatech | |
45 | ||
46 | ///\cond CLASSIMP | |
47 | ClassImp(AliMUONChamberPainter) | |
48 | ///\endcond | |
49 | ||
50 | //_____________________________________________________________________________ | |
51 | AliMUONChamberPainter::AliMUONChamberPainter() | |
52 | : AliMUONVPainter(), | |
53 | fChamberId(-1) | |
54 | { | |
55 | /// ctor | |
56 | } | |
57 | ||
58 | //_____________________________________________________________________________ | |
59 | AliMUONChamberPainter::AliMUONChamberPainter(const AliMUONAttPainter& att, | |
60 | Int_t chamberId) | |
61 | : AliMUONVPainter("Chamber"), | |
62 | fChamberId(chamberId) | |
63 | { | |
64 | /// ctor | |
65 | ||
66 | AliMUONPainterHelper* h = AliMUONPainterHelper::Instance(); // to be sure mapping is loaded... | |
67 | ||
68 | AliMUONAttPainter chAtt(att); | |
69 | ||
70 | chAtt.SetCathodeAndPlaneMutuallyExclusive(kTRUE); | |
71 | ||
72 | SetAttributes(chAtt); | |
73 | ||
74 | SetID(chamberId,-1); | |
75 | SetName(h->ChamberName(fChamberId).Data()); | |
76 | SetPathName(h->ChamberPathName(fChamberId).Data()); | |
77 | ||
78 | AliMpDEIterator deIt; | |
79 | ||
80 | deIt.First(fChamberId); | |
81 | ||
82 | AliMUONPainterContour* contour = h->GetContour(ContourName()); | |
83 | TObjArray contourArray; | |
84 | ||
85 | while (!deIt.IsDone()) | |
86 | { | |
87 | Int_t detElemId = deIt.CurrentDEId(); | |
88 | ||
89 | AliMUONAttPainter deAtt(att); | |
90 | ||
91 | if ( att.IsCathodeDefined() ) | |
92 | { | |
93 | deAtt.SetCathode(kFALSE,kFALSE); | |
94 | AliMp::PlaneType planeType; | |
95 | ||
96 | if ( att.IsCathode0() ) planeType = AliMpDEManager::GetPlaneType(detElemId,AliMp::kCath0); | |
97 | else planeType = AliMpDEManager::GetPlaneType(detElemId,AliMp::kCath1); | |
98 | ||
99 | Bool_t bending = ( planeType == AliMp::kBendingPlane ); | |
100 | ||
101 | deAtt.SetPlane(bending,!bending); | |
102 | } | |
103 | ||
104 | assert(deAtt.IsPlaneDefined()); | |
105 | ||
106 | AliMUONVPainter* painter = new AliMUONDEPainter(deAtt,detElemId); | |
107 | ||
108 | Add(painter); | |
109 | ||
110 | if (!contour) | |
111 | { | |
112 | contourArray.Add(painter->Contour()); | |
113 | } | |
114 | ||
115 | deIt.Next(); | |
116 | } | |
117 | ||
118 | Double_t xmin(1E9), xmax(-1E9), ymin(1E9), ymax(-1E9); | |
119 | TIter next(Children()); | |
120 | AliMUONVPainter* painter; | |
121 | ||
122 | while ( ( painter = static_cast<AliMUONVPainter*>(next()) ) ) | |
123 | { | |
124 | const AliMpArea& area = painter->Area(); | |
125 | xmin = TMath::Min(xmin,area.LeftBorder()); | |
126 | xmax = TMath::Max(xmax,area.RightBorder()); | |
127 | ymin = TMath::Min(ymin,area.DownBorder()); | |
128 | ymax = TMath::Max(ymax,area.UpBorder()); | |
129 | } | |
130 | ||
131 | if ( contourArray.GetLast() >= 0 ) | |
132 | { | |
133 | contour = h->MergeContours(contourArray,ContourName()); | |
134 | } | |
135 | ||
136 | SetContour(contour); | |
137 | } | |
138 | ||
139 | //_____________________________________________________________________________ | |
140 | AliMUONChamberPainter::AliMUONChamberPainter(const AliMUONChamberPainter& rhs) | |
141 | : AliMUONVPainter(rhs), | |
142 | fChamberId(rhs.fChamberId) | |
143 | { | |
144 | /// copy ctor | |
145 | rhs.Copy(*this); | |
146 | } | |
147 | ||
148 | //_____________________________________________________________________________ | |
149 | AliMUONChamberPainter& | |
150 | AliMUONChamberPainter::operator=(const AliMUONChamberPainter& rhs) | |
151 | { | |
152 | /// assignment operator | |
153 | if ( this != &rhs ) | |
154 | { | |
155 | rhs.Copy(*this); | |
156 | } | |
157 | return *this; | |
158 | } | |
159 | ||
160 | //_____________________________________________________________________________ | |
161 | AliMUONChamberPainter::~AliMUONChamberPainter() | |
162 | { | |
163 | /// dtor | |
164 | } | |
165 | ||
166 | //_____________________________________________________________________________ | |
167 | void | |
168 | AliMUONChamberPainter::ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex, | |
169 | Double_t& dataMin, Double_t& dataMax) const | |
170 | { | |
171 | /// Compute data range spanned by this (plane of that) chamber | |
172 | dataMin = dataMax = data.Chamber(fChamberId, dataIndex); | |
173 | } | |
174 | ||
175 | ||
176 | //_____________________________________________________________________________ | |
177 | void | |
178 | AliMUONChamberPainter::Copy(TObject& object) const | |
179 | { | |
180 | /// Copy this to object | |
181 | AliMUONVPainter::Copy((AliMUONVPainter&)(object)); | |
182 | ((AliMUONChamberPainter&)(object)).fChamberId = fChamberId; | |
183 | } | |
184 | ||
185 | //_____________________________________________________________________________ | |
186 | TString | |
187 | AliMUONChamberPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex, | |
188 | Double_t, Double_t) | |
189 | { | |
190 | /// Describe data at this chamber | |
191 | ||
192 | if (!data.HasChamber(fChamberId)) return ""; | |
193 | ||
194 | Double_t value = data.Chamber(fChamberId,dataIndex); | |
195 | ||
196 | return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value); | |
197 | } | |
198 | ||
199 | //_____________________________________________________________________________ | |
200 | void | |
201 | AliMUONChamberPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex, | |
202 | Double_t min, Double_t max) | |
203 | { | |
204 | /// Paint area of this chamber according to data | |
205 | ||
206 | if (!data.HasChamber(fChamberId)) return; | |
207 | ||
208 | Double_t value = data.Chamber(fChamberId,dataIndex); | |
209 | ||
210 | if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return; | |
211 | ||
212 | Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,min,max); | |
213 | ||
214 | Contour()->PaintArea(color); | |
215 | } | |
216 | ||
217 | //_____________________________________________________________________________ | |
218 | AliMUONAttPainter | |
219 | AliMUONChamberPainter::Validate(const AliMUONAttPainter& attributes) const | |
220 | { | |
221 | /// Normalize attributes | |
222 | ||
223 | AliMUONAttPainter norm(attributes); | |
224 | ||
225 | // A chamber painter must be either cathode defined or plane defined | |
226 | ||
227 | if ( norm.IsCathodeDefined() && norm.IsPlaneDefined() ) | |
228 | { | |
229 | norm.SetValid(kFALSE); | |
230 | } | |
231 | ||
232 | if ( !norm.IsCathodeDefined() && !norm.IsPlaneDefined() ) | |
233 | { | |
234 | norm.SetValid(kFALSE); | |
235 | } | |
236 | ||
237 | return norm; | |
238 | } |