]>
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 "AliMUONBusPatchPainter.h" | |
19 | ||
20 | #include "AliMUONManuPainter.h" | |
21 | #include "AliMUONPainterContour.h" | |
22 | #include "AliMUONPainterHelper.h" | |
23 | #include "AliMUONVCalibParam.h" | |
24 | #include "AliMUONVTrackerData.h" | |
25 | #include "AliMpBusPatch.h" | |
26 | #include "AliMpConstants.h" | |
27 | #include "AliMpDDLStore.h" | |
28 | #include "AliMpDEManager.h" | |
29 | #include "AliMpPlaneType.h" | |
30 | #include "AliLog.h" | |
31 | #include <TObjArray.h> | |
32 | #include <TString.h> | |
33 | #include <float.h> | |
34 | ||
35 | /// \class AliMUONBusPatchPainter | |
36 | /// | |
37 | /// Painter for one bus patch. Actually possibly for only part of one | |
38 | /// buspatch (the part that is on the plane/cathode requested when | |
39 | /// creating the painter) | |
40 | /// | |
41 | /// \author Laurent Aphecetche, Subatech | |
42 | ||
43 | ///\cond CLASSIMP | |
44 | ClassImp(AliMUONBusPatchPainter) | |
45 | ///\endcond | |
46 | ||
47 | //_____________________________________________________________________________ | |
48 | AliMUONBusPatchPainter::AliMUONBusPatchPainter() | |
49 | : AliMUONVPainter(), | |
50 | fBusPatchId(-1) | |
51 | { | |
52 | /// default ctor | |
53 | } | |
54 | ||
55 | //_____________________________________________________________________________ | |
56 | AliMUONBusPatchPainter::AliMUONBusPatchPainter(const AliMUONAttPainter& att, | |
57 | Int_t busPatchId) | |
58 | : AliMUONVPainter("BUSPATCH"), | |
59 | fBusPatchId(busPatchId) | |
60 | { | |
61 | /// normal ctor | |
62 | /// WARNING : the construction of this object can fail. | |
63 | /// You MUST check the IsValid() method afterwards (real world would | |
64 | /// be to use exception, but well, whether we should use exceptions | |
65 | /// in aliroot is still unclear to me. | |
66 | ||
67 | SetAttributes(Validate(att)); | |
68 | ||
69 | AliMp::PlaneType planeType = ( Attributes().IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane ); | |
70 | ||
71 | Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(busPatchId); | |
72 | ||
73 | AliMUONPainterHelper* h = AliMUONPainterHelper::Instance(); | |
74 | ||
75 | SetID(busPatchId,-1); | |
76 | SetName(h->BusPatchName(busPatchId)); | |
77 | SetPathName(h->BusPatchPathName(busPatchId)); | |
78 | ||
79 | AliMpBusPatch* busPatch = AliMpDDLStore::Instance()->GetBusPatch(fBusPatchId); | |
80 | ||
81 | Int_t mask = AliMpConstants::ManuMask(AliMp::kNonBendingPlane); | |
82 | ||
83 | AliMUONPainterContour* bpContour = h->GetContour(ContourName()); | |
84 | ||
85 | AliDebug(1,Form("BusPatchId %04d bending %d DE %4d bpContour(%s)=%p nofManus=%d", | |
86 | fBusPatchId,att.IsBendingPlane(),detElemId,ContourName().Data(),bpContour,busPatch->GetNofManus())); | |
87 | ||
88 | Double_t xmin(FLT_MAX), ymin(FLT_MAX), xmax(-FLT_MAX), ymax(-FLT_MAX); | |
89 | ||
90 | TObjArray contours; | |
91 | ||
92 | Int_t nmanus(0); | |
93 | ||
94 | for ( Int_t i = 0; i < busPatch->GetNofManus(); ++i ) | |
95 | { | |
96 | Int_t manuId = busPatch->GetManuId(i); | |
97 | ||
98 | Bool_t correctPlane(kTRUE); | |
99 | ||
100 | if ( planeType == AliMp::kNonBendingPlane ) | |
101 | { | |
102 | if ( ( manuId & mask ) == 0 ) correctPlane = kFALSE; | |
103 | } | |
104 | else | |
105 | { | |
106 | if ( ( manuId & mask ) == mask ) correctPlane = kFALSE; | |
107 | } | |
108 | ||
109 | AliDebug(1,Form("Adding Manu %04d to BusPatch %04d (DE %04d) " | |
110 | "manu & mask = %d correctPlane %d planeType %s", | |
111 | manuId,fBusPatchId,busPatch->GetDEId(), | |
112 | (manuId & mask),correctPlane,AliMp::PlaneTypeName(planeType).Data())); | |
113 | ||
114 | if (!correctPlane) continue; | |
115 | ||
116 | ++nmanus; | |
117 | ||
118 | AliMUONVPainter* painter = new AliMUONManuPainter(Attributes(), | |
119 | busPatch->GetDEId(), | |
120 | manuId); | |
121 | ||
122 | Add(painter); | |
123 | ||
124 | const AliMpArea& area = painter->Area(); | |
125 | ||
126 | xmin = TMath::Min(xmin,\varea.LeftBorder()); | |
127 | ymin = TMath::Min(ymin,area.DownBorder()); | |
128 | xmax = TMath::Max(xmax,area.RightBorder()); | |
129 | ymax = TMath::Max(ymax,area.UpBorder()); | |
130 | ||
131 | if (!bpContour) | |
132 | { | |
133 | contours.Add(painter->Contour()); | |
134 | } | |
135 | } | |
136 | ||
137 | if ( !nmanus ) | |
138 | { | |
139 | Invalidate(); | |
140 | return; | |
141 | } | |
142 | ||
143 | if (!bpContour) | |
144 | { | |
145 | AliDebug(1,Form("Creating contour %s",ContourName().Data())); | |
146 | bpContour = h->MergeContours(contours,ContourName()); | |
147 | if (!bpContour) | |
148 | { | |
149 | AliError("Could not merge those contours"); | |
150 | StdoutToAliError(contours.Print();); | |
151 | } | |
152 | } | |
153 | ||
154 | SetContour(bpContour); | |
155 | } | |
156 | ||
157 | //_____________________________________________________________________________ | |
158 | void | |
159 | AliMUONBusPatchPainter::ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex, | |
160 | Double_t& dataMin, Double_t& dataMax) const | |
161 | { | |
162 | /// Compute the data range spanned by this bus patch (on this cathode or plane) | |
163 | dataMin = dataMax = data.BusPatch(fBusPatchId, dataIndex); | |
164 | } | |
165 | ||
166 | //_____________________________________________________________________________ | |
167 | AliMUONBusPatchPainter::AliMUONBusPatchPainter(const AliMUONBusPatchPainter& rhs) | |
168 | : AliMUONVPainter(rhs), fBusPatchId(-1) | |
169 | { | |
170 | /// Copy ctor | |
171 | rhs.Copy(*this); | |
172 | } | |
173 | ||
174 | //_____________________________________________________________________________ | |
175 | AliMUONBusPatchPainter& | |
176 | AliMUONBusPatchPainter::operator=(const AliMUONBusPatchPainter& rhs) | |
177 | { | |
178 | /// Assignment operator | |
179 | if ( this != &rhs ) | |
180 | { | |
181 | rhs.Copy(*this); | |
182 | } | |
183 | return *this; | |
184 | } | |
185 | ||
186 | //_____________________________________________________________________________ | |
187 | AliMUONBusPatchPainter::~AliMUONBusPatchPainter() | |
188 | { | |
189 | /// dtor | |
190 | } | |
191 | ||
192 | //_____________________________________________________________________________ | |
193 | void | |
194 | AliMUONBusPatchPainter::Copy(TObject& object) const | |
195 | { | |
196 | /// Copy this to object | |
197 | AliMUONVPainter::Copy((AliMUONVPainter&)(object)); | |
198 | ((AliMUONBusPatchPainter&)(object)).fBusPatchId = fBusPatchId; | |
199 | } | |
200 | ||
201 | //_____________________________________________________________________________ | |
202 | TString | |
203 | AliMUONBusPatchPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex, | |
204 | Double_t, Double_t) | |
205 | { | |
206 | /// Text about data | |
207 | ||
208 | if (!data.HasBusPatch(fBusPatchId)) return ""; | |
209 | ||
210 | Double_t value = data.BusPatch(fBusPatchId,dataIndex); | |
211 | ||
212 | return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value); | |
213 | } | |
214 | ||
215 | //_____________________________________________________________________________ | |
216 | void | |
217 | AliMUONBusPatchPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex, | |
218 | Double_t min, Double_t max) | |
219 | { | |
220 | /// Paint area of this buspatch according to the data | |
221 | ||
222 | if (!data.HasBusPatch(fBusPatchId)) return; | |
223 | ||
224 | Double_t value = data.BusPatch(fBusPatchId,dataIndex); | |
225 | ||
226 | if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return; | |
227 | ||
228 | Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,min,max); | |
229 | ||
230 | Contour()->PaintArea(color); | |
231 | } | |
232 | ||
233 | //_____________________________________________________________________________ | |
234 | AliMUONAttPainter | |
235 | AliMUONBusPatchPainter::Validate(const AliMUONAttPainter& attributes) const | |
236 | { | |
237 | /// Normalize attributes | |
238 | ||
239 | // we invalidate the attributes, if we have no manu in the requested plane | |
240 | // and we cross-check that both cathode and plane are up-to-date | |
241 | ||
242 | AliMUONAttPainter norm(attributes); | |
243 | ||
244 | Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(fBusPatchId); | |
245 | ||
246 | if (!norm.IsValid()) return norm; | |
247 | ||
248 | if ( !norm.IsCathodeDefined() ) | |
249 | { | |
250 | AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane ); | |
251 | ||
252 | AliMp::CathodType cathodeType = AliMpDEManager::GetCathod(detElemId,planeType); | |
253 | ||
254 | Bool_t cath0 = ( cathodeType == AliMp::kCath0 ); | |
255 | ||
256 | norm.SetCathode(cath0,!cath0); | |
257 | } | |
258 | else if ( !norm.IsPlaneDefined() ) | |
259 | { | |
260 | AliMp::CathodType cathodeType = ( norm.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 ); | |
261 | ||
262 | AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(detElemId,cathodeType); | |
263 | ||
264 | Bool_t bending = ( planeType == AliMp::kBendingPlane ); | |
265 | ||
266 | norm.SetPlane(bending,!bending); | |
267 | } | |
268 | ||
269 | AliMpBusPatch* busPatch = AliMpDDLStore::Instance()->GetBusPatch(fBusPatchId); | |
270 | ||
271 | Int_t mask = AliMpConstants::ManuMask(AliMp::kNonBendingPlane); | |
272 | ||
273 | Int_t nb(0); | |
274 | Int_t b(0); | |
275 | ||
276 | for ( Int_t i = 0; i < busPatch->GetNofManus(); ++i ) | |
277 | { | |
278 | Int_t manuId = busPatch->GetManuId(i); | |
279 | ||
280 | if ( manuId & mask ) ++nb; | |
281 | else ++b; | |
282 | } | |
283 | ||
284 | if ( norm.IsBendingPlane() && !b ) norm.SetValid(kFALSE); | |
285 | if ( norm.IsNonBendingPlane() && !nb ) norm.SetValid(kFALSE); | |
286 | ||
287 | return norm; | |
288 | } | |
289 |