]>
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 "AliMUONDEPainter.h" | |
19 | ||
20 | #include "AliMUONBusPatchPainter.h" | |
21 | #include "AliMUONGeometryTransformer.h" | |
22 | #include "AliMUONPCBPainter.h" | |
23 | #include "AliMUONPainterContour.h" | |
24 | #include "AliMUONPainterHelper.h" | |
25 | #include "AliMUONVCalibParam.h" | |
26 | #include "AliMUONVTrackerData.h" | |
27 | #include "AliMUONObjectPair.h" | |
28 | #include "AliMpDDLStore.h" | |
29 | #include "AliMpDEManager.h" | |
30 | #include "AliMpDetElement.h" | |
31 | #include "AliMpPCB.h" | |
32 | #include "AliMpSector.h" | |
33 | #include "AliMpSlat.h" | |
34 | #include "AliLog.h" | |
35 | #include <TObjString.h> | |
36 | ||
37 | /// \class AliMUONDEPainter | |
38 | /// | |
39 | /// Painter for one detection element | |
40 | /// | |
41 | /// It draws a given plane (bending or non bending) of a given detection element | |
42 | /// | |
43 | /// \author Laurent Aphecetche, Subatech | |
44 | ||
45 | ///\cond CLASSIMP | |
46 | ClassImp(AliMUONDEPainter) | |
47 | ///\endcond | |
48 | ||
49 | //_____________________________________________________________________________ | |
50 | AliMUONDEPainter::AliMUONDEPainter() | |
51 | : AliMUONVPainter(), | |
52 | fDetElemId(-1) | |
53 | { | |
54 | /// default ctor | |
55 | } | |
56 | ||
1ffbeb9d | 57 | //_____________________________________________________________________________ |
58 | AliMUONDEPainter::AliMUONDEPainter(TRootIOCtor* ioCtor) | |
59 | : AliMUONVPainter(ioCtor), | |
60 | fDetElemId(-1) | |
61 | { | |
62 | /// default streaming ctor | |
63 | } | |
64 | ||
0145e89a | 65 | //_____________________________________________________________________________ |
66 | AliMUONDEPainter::AliMUONDEPainter(const AliMUONAttPainter& att, Int_t detElemId) | |
67 | : AliMUONVPainter("DE"), | |
68 | fDetElemId(detElemId) | |
69 | { | |
70 | /// normal ctor | |
71 | ||
72 | AliMUONAttPainter deAtt(att); | |
73 | ||
74 | if ( att.IsCathodeDefined() ) | |
75 | { | |
76 | AliMp::CathodType cathodType = ( att.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 ) ; | |
77 | ||
78 | Bool_t cath0 = ( cathodType == AliMp::kCath0 ) ; | |
79 | ||
80 | AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(detElemId,cathodType); | |
81 | ||
82 | Bool_t bending = ( planeType == AliMp::kBendingPlane ); | |
83 | ||
84 | deAtt.SetCathode(cath0,!cath0); | |
85 | deAtt.SetPlane(bending,!bending); | |
86 | ||
87 | } | |
88 | ||
89 | if ( att.IsPlaneDefined() ) | |
90 | { | |
91 | AliMp::PlaneType planeType = ( att.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane ); | |
92 | ||
93 | Bool_t bending = ( planeType == AliMp::kBendingPlane ); | |
94 | ||
95 | Bool_t cath0 = ( AliMpDEManager::GetCathod(detElemId,planeType) == AliMp::kCath0 ); | |
96 | ||
97 | deAtt.SetCathode(cath0,!cath0); | |
98 | deAtt.SetPlane(bending,!bending); | |
99 | ||
100 | } | |
101 | ||
102 | deAtt.SetCathodeAndPlaneMutuallyExclusive(kFALSE); | |
103 | ||
104 | SetAttributes(deAtt); | |
105 | ||
106 | AliMUONPainterHelper* h = AliMUONPainterHelper::Instance(); | |
107 | ||
108 | SetID(detElemId,-1); | |
109 | SetName(h->DEName(fDetElemId).Data()); | |
110 | SetPathName(h->DEPathName(fDetElemId).Data()); | |
111 | ||
112 | AliMp::PlaneType planeType = ( Attributes().IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane ); | |
113 | ||
114 | Double_t x,y,z; | |
115 | ||
116 | if ( AliMpDEManager::GetStationType(DetElemId()) == AliMp::kStation345 ) | |
117 | { | |
118 | const AliMpSlat* slat = h->GetSlat(DetElemId(),planeType); | |
119 | ||
120 | for ( Int_t i = 0; i < slat->GetSize(); ++i ) | |
121 | { | |
122 | Add(new AliMUONPCBPainter(Attributes(),DetElemId(),i)); | |
123 | } | |
124 | ||
125 | AliMUONPainterHelper::Instance()->Local2Global(fDetElemId,0.0,0.0,0.0,x,y,z); | |
126 | } | |
127 | else if ( AliMpDEManager::GetStationType(DetElemId()) != AliMp::kStationTrigger ) | |
128 | { | |
129 | const AliMpSector* sector = h->GetSector(DetElemId(),planeType); | |
130 | ||
131 | Double_t xl(sector->Dimensions().X()); | |
132 | Double_t yl(sector->Dimensions().Y()); | |
133 | ||
134 | h->Local2Global(fDetElemId,xl,yl,0.0,x,y,z); | |
135 | } | |
136 | else | |
137 | { | |
138 | AliFatal("Not implemented for trigger !!!"); | |
139 | } | |
140 | ||
141 | AliMUONPainterContour* contour = h->GetContour(ContourName()); | |
142 | ||
143 | TObjArray contourArray; | |
144 | ||
145 | AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(fDetElemId); | |
146 | ||
147 | AliDebug(1,Form("de %p n %d",de,de->GetNofBusPatches())); | |
148 | ||
149 | for ( Int_t i = 0; i < de->GetNofBusPatches(); ++i ) | |
150 | { | |
151 | AliMUONBusPatchPainter* painter = new AliMUONBusPatchPainter(Attributes(),de->GetBusPatchId(i)); | |
152 | ||
153 | if ( !painter->IsValid() ) | |
154 | { | |
155 | AliDebug(1,Form("Skipping BP %d which seem to have no manu in plane %s", | |
156 | de->GetBusPatchId(i), | |
157 | Attributes().IsBendingPlane() ? "bending" : "non bending")); | |
158 | delete painter; | |
159 | continue; | |
160 | } | |
161 | else | |
162 | { | |
163 | Add(painter); | |
164 | } | |
165 | ||
166 | if ( !contour ) | |
167 | { | |
168 | contourArray.Add(painter->Contour()); | |
169 | } | |
170 | } | |
171 | ||
172 | if (!contour) | |
173 | { | |
174 | contour = h->MergeContours(contourArray,ContourName()); | |
175 | if (!contour) | |
176 | { | |
177 | AliError(Form("%s : could not merge those contours",Name().Data())); | |
178 | StdoutToAliError(contourArray.Print();); | |
179 | } | |
180 | } | |
181 | ||
182 | SetContour(contour); | |
183 | } | |
184 | ||
185 | //_____________________________________________________________________________ | |
186 | AliMUONDEPainter::AliMUONDEPainter(const AliMUONDEPainter& rhs): | |
187 | AliMUONVPainter(rhs), fDetElemId(-1) | |
188 | { | |
189 | /// copy ctor | |
190 | rhs.Copy(*this); | |
191 | } | |
192 | ||
193 | //_____________________________________________________________________________ | |
194 | AliMUONDEPainter& | |
195 | AliMUONDEPainter::operator=(const AliMUONDEPainter& rhs) | |
196 | { | |
197 | /// assignment operator | |
198 | if ( this != &rhs ) | |
199 | { | |
200 | rhs.Copy(*this); | |
201 | } | |
202 | return *this; | |
203 | } | |
204 | ||
205 | //_____________________________________________________________________________ | |
206 | AliMUONDEPainter::~AliMUONDEPainter() | |
207 | { | |
208 | /// dtor = nop | |
209 | } | |
210 | ||
211 | //_____________________________________________________________________________ | |
212 | void | |
213 | AliMUONDEPainter::ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex, | |
214 | Double_t& dataMin, Double_t& dataMax) const | |
215 | { | |
216 | /// Compute the data range spanned by this detection element | |
217 | dataMin = dataMax = data.DetectionElement(fDetElemId, dataIndex); | |
218 | } | |
219 | ||
220 | //_____________________________________________________________________________ | |
221 | void | |
222 | AliMUONDEPainter::Copy(TObject& object) const | |
223 | { | |
224 | /// Copy this to object | |
225 | AliMUONVPainter::Copy((AliMUONVPainter&)(object)); | |
226 | ((AliMUONDEPainter&)(object)).fDetElemId = fDetElemId; | |
227 | } | |
228 | ||
229 | //_____________________________________________________________________________ | |
230 | TString | |
231 | AliMUONDEPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex, | |
232 | Double_t, Double_t) | |
233 | { | |
234 | /// Describe data at this detection element | |
235 | ||
236 | if (!data.HasDetectionElement(fDetElemId)) return ""; | |
237 | ||
238 | Double_t value = data.DetectionElement(fDetElemId,dataIndex); | |
239 | ||
240 | return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value); | |
241 | } | |
242 | ||
243 | //_____________________________________________________________________________ | |
10eb3d17 | 244 | void |
245 | AliMUONDEPainter::FillManuList(TObjArray& manuList) const | |
246 | { | |
247 | /// Fill (append to) manu list | |
248 | TIter next(Children()); | |
249 | AliMUONVPainter* p; | |
250 | ||
251 | while ( ( p = static_cast<AliMUONVPainter*>(next()) ) ) | |
252 | { | |
253 | if ( p->IsA() == AliMUONBusPatchPainter::Class() ) | |
254 | { | |
255 | // Only consider bus patch painters (and not PCB ones), | |
256 | // in order not to double count some manus | |
257 | p->FillManuList(manuList); | |
258 | } | |
259 | } | |
260 | } | |
1ffbeb9d | 261 | |
262 | //_____________________________________________________________________________ | |
263 | Bool_t | |
264 | AliMUONDEPainter::IsIncluded() const | |
265 | { | |
266 | /// whether this detection element is included in the readout or not | |
267 | return ( InteractiveReadOutConfig()->DetectionElement(fDetElemId) > 0 ); | |
268 | } | |
269 | ||
10eb3d17 | 270 | //_____________________________________________________________________________ |
0145e89a | 271 | void |
272 | AliMUONDEPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex, | |
273 | Double_t min, Double_t max) | |
274 | { | |
275 | /// Paint the area of this detection element | |
276 | ||
277 | if (!data.HasDetectionElement(fDetElemId)) return; | |
278 | ||
279 | Double_t value = data.DetectionElement(fDetElemId,dataIndex); | |
280 | ||
281 | if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return; | |
282 | ||
283 | Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,min,max); | |
284 | ||
285 | Contour()->PaintArea(color); | |
286 | } | |
287 | ||
288 | //_____________________________________________________________________________ | |
289 | AliMUONAttPainter | |
290 | AliMUONDEPainter::Validate(const AliMUONAttPainter& attributes) const | |
291 | { | |
292 | /// Normalize attributes | |
293 | ||
294 | AliMUONAttPainter norm(attributes); | |
295 | ||
296 | norm.SetCathodeAndPlaneMutuallyExclusive(kFALSE); | |
297 | ||
298 | if ( norm.IsCathodeDefined() && !norm.IsPlaneDefined() ) | |
299 | { | |
300 | // only cathode known : derive the plane | |
301 | ||
302 | AliMp::CathodType cathodType = ( norm.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 ); | |
303 | ||
304 | AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(fDetElemId,cathodType); | |
305 | ||
306 | Bool_t bending = ( planeType == AliMp::kBendingPlane ) ; | |
307 | ||
308 | norm.SetPlane(bending,!bending); | |
309 | } | |
310 | ||
311 | else if ( !norm.IsCathodeDefined() && norm.IsPlaneDefined() ) | |
312 | { | |
313 | // only plane is known : derive the cathode | |
314 | ||
315 | AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane ); | |
316 | ||
317 | Bool_t cath0 = ( AliMpDEManager::GetCathod(fDetElemId,planeType) == AliMp::kCath0 ); | |
318 | ||
319 | norm.SetCathode(cath0,!cath0); | |
320 | } | |
321 | else | |
322 | { | |
323 | // check that both information are compatible | |
324 | ||
325 | AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane ); | |
326 | ||
327 | AliMp::CathodType cathode = AliMpDEManager::GetCathod(fDetElemId,planeType); | |
328 | ||
94bf739c | 329 | if ( (cathode == AliMp::kCath0 && norm.IsCathode1()) || |
330 | (cathode == AliMp::kCath1 && norm.IsCathode0()) ) | |
0145e89a | 331 | { |
332 | norm.SetValid(kFALSE); | |
333 | } | |
334 | } | |
335 | ||
336 | return norm; | |
337 | } | |
338 |