]>
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 "AliMUONManuPadPainter.h" | |
19 | ||
49419555 | 20 | #include "AliLog.h" |
21 | #include "AliMUONPainterGroup.h" | |
0145e89a | 22 | #include "AliMUONPainterHelper.h" |
23 | #include "AliMUONPainterPadStore.h" | |
49419555 | 24 | #include "AliMUONTrackerDataHistogrammer.h" |
0145e89a | 25 | #include "AliMUONVCalibParam.h" |
26 | #include "AliMUONVDigit.h" | |
27 | #include "AliMUONVTrackerData.h" | |
28 | #include "AliMpConnection.h" | |
29 | #include "AliMpConstants.h" | |
30 | #include "AliMpDDLStore.h" | |
31 | #include "AliMpDetElement.h" | |
32 | #include "AliMpPad.h" | |
33 | #include "AliMpSegmentation.h" | |
34 | #include "AliMpVSegmentation.h" | |
49419555 | 35 | #include <TCanvas.h> |
36 | #include <TH1.h> | |
0145e89a | 37 | #include <TVirtualPad.h> |
38 | #include <TVirtualX.h> | |
49419555 | 39 | #include <float.h> |
0145e89a | 40 | |
41 | ///\class AliMUONManuPadPainter | |
42 | /// | |
43 | /// Painter for the pads of one manu | |
44 | /// | |
45 | ///\author Laurent Aphecetche, Subatech | |
46 | ||
47 | ///\cond CLASSIMP | |
48 | ClassImp(AliMUONManuPadPainter) | |
49 | ///\endcond | |
50 | ||
51 | //_____________________________________________________________________________ | |
52 | AliMUONManuPadPainter::AliMUONManuPadPainter() | |
53 | : AliMUONVPainter(), | |
54 | fDetElemId(-1), | |
55 | fManuId(-1), | |
56 | fLineColorBck(-1), | |
57 | fLineWidthBck(-1), | |
58 | fFillColorBck(-1), | |
59 | fFillStyleBck(-1) | |
60 | { | |
61 | /// ctor | |
62 | } | |
63 | ||
1ffbeb9d | 64 | //_____________________________________________________________________________ |
65 | AliMUONManuPadPainter::AliMUONManuPadPainter(TRootIOCtor* ioCtor) | |
66 | : AliMUONVPainter(ioCtor), | |
67 | fDetElemId(-1), | |
68 | fManuId(-1), | |
69 | fLineColorBck(-1), | |
70 | fLineWidthBck(-1), | |
71 | fFillColorBck(-1), | |
72 | fFillStyleBck(-1) | |
73 | { | |
74 | /// ctor | |
75 | } | |
76 | ||
0145e89a | 77 | //_____________________________________________________________________________ |
78 | AliMUONManuPadPainter::AliMUONManuPadPainter(const AliMUONVPainter& mother, | |
79 | Int_t detElemId, | |
80 | Int_t manuId) | |
81 | : AliMUONVPainter("PAD"), | |
82 | fDetElemId(detElemId), | |
83 | fManuId(manuId), | |
84 | fLineColorBck(-1), | |
85 | fLineWidthBck(-1), | |
86 | fFillColorBck(-1), | |
87 | fFillStyleBck(-1) | |
88 | { | |
89 | /// ctor | |
90 | SetID(detElemId,manuId); | |
91 | SetName(Form("%s/PAD",mother.GetName())); | |
92 | SetPathName(Form("%s/PAD",mother.PathName().Data())); | |
93 | SetContour(mother.Contour()); | |
94 | } | |
95 | ||
96 | //_____________________________________________________________________________ | |
97 | AliMUONManuPadPainter::~AliMUONManuPadPainter() | |
98 | { | |
99 | /// dtor | |
100 | } | |
101 | ||
102 | //_____________________________________________________________________________ | |
103 | void | |
104 | AliMUONManuPadPainter::BackupStyle() | |
105 | { | |
106 | /// Remember line and fill style values | |
107 | ||
108 | fFillStyleBck = gVirtualX->GetFillStyle(); | |
109 | fFillColorBck = gVirtualX->GetFillColor(); | |
110 | fLineColorBck = gVirtualX->GetLineColor(); | |
111 | fLineWidthBck = gVirtualX->GetLineWidth(); | |
112 | } | |
113 | ||
114 | //_____________________________________________________________________________ | |
115 | void | |
116 | AliMUONManuPadPainter::ComputeDataRange(const AliMUONVTrackerData& data, | |
117 | Int_t dataIndex, | |
118 | Double_t& dataMin, Double_t& dataMax) const | |
119 | { | |
120 | /// Compute data range spanned by this manu pads | |
121 | AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(fDetElemId); | |
122 | ||
123 | dataMin = FLT_MAX; | |
124 | dataMax = -FLT_MAX; | |
125 | ||
126 | for ( Int_t manuChannel = 0; manuChannel < AliMpConstants::ManuNofChannels(); | |
127 | ++manuChannel ) | |
128 | { | |
129 | if ( de->IsConnectedChannel(fManuId,manuChannel) ) | |
130 | { | |
131 | Double_t value = data.Channel(fDetElemId, fManuId, manuChannel, dataIndex); | |
132 | dataMin = TMath::Min(value,dataMin); | |
133 | dataMax = TMath::Max(value,dataMax); | |
134 | } | |
135 | } | |
136 | } | |
137 | ||
138 | //_____________________________________________________________________________ | |
139 | char* | |
140 | AliMUONManuPadPainter::GetObjectInfo(Int_t px, Int_t py) const | |
141 | { | |
142 | /// Get object info | |
143 | return const_cast<char*>(Form("%s:%d:%d",GetName(),px,py)); | |
144 | } | |
145 | ||
146 | //_____________________________________________________________________________ | |
147 | TString | |
148 | AliMUONManuPadPainter::NameAtPosition(Double_t x, Double_t y) const | |
149 | { | |
150 | /// Specific name, dependent on the position within this painter | |
151 | ||
152 | TString name("invalid"); | |
153 | ||
154 | AliMpPad pad = PadByPosition(x,y); | |
155 | ||
156 | if ( pad.IsValid() ) | |
157 | { | |
158 | name = Form("%s%d",PathName().Data(),pad.GetLocation().GetSecond()); | |
159 | } | |
160 | ||
161 | return name; | |
162 | } | |
163 | ||
1ffbeb9d | 164 | //_____________________________________________________________________________ |
165 | Bool_t | |
166 | AliMUONManuPadPainter::IsIncluded() const | |
167 | { | |
168 | /// whether this manu is included in the readout or not | |
169 | return ( InteractiveReadOutConfig()->Manu(fDetElemId,fManuId) > 0 ); | |
170 | } | |
171 | ||
0145e89a | 172 | //_____________________________________________________________________________ |
173 | TString | |
174 | AliMUONManuPadPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex, | |
175 | Double_t x, Double_t y) | |
176 | { | |
177 | /// Describe data at given location | |
178 | ||
179 | if ( ! data.HasManu(fDetElemId,fManuId) ) return ""; | |
180 | ||
181 | AliMpPad pad = PadByPosition(x,y); | |
182 | ||
183 | if ( pad.IsValid() ) | |
184 | { | |
185 | Double_t value = data.Channel(fDetElemId,fManuId,pad.GetLocation().GetSecond(),dataIndex); | |
186 | ||
187 | return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value); | |
188 | } | |
189 | else | |
190 | { | |
191 | return "invalid"; | |
192 | } | |
193 | } | |
194 | ||
49419555 | 195 | //_____________________________________________________________________________ |
196 | void | |
197 | AliMUONManuPadPainter::DrawHistogramClone(Double_t* values) const | |
198 | { | |
199 | /// Draw histogram for pad at (values[0],values[1]) | |
200 | ||
201 | if ( !values ) return; | |
202 | ||
203 | AliMUONPainterGroup* group = Master()->PlotterGroup(); | |
204 | ||
205 | if ( !group ) return; // no data to histogram in this painter | |
206 | ||
207 | AliMpPad pad = PadByPosition(values[0],values[1]); | |
208 | ||
209 | AliMUONVTrackerData* data = group->Data(); | |
210 | ||
211 | AliMUONTrackerDataHistogrammer tdh(*data,0,-1); | |
212 | ||
213 | fHistogram = tdh.CreateChannelHisto(fDetElemId, fManuId, | |
214 | pad.GetLocation().GetSecond()); | |
215 | if (fHistogram) | |
216 | { | |
217 | new TCanvas(); | |
218 | fHistogram->Draw(); | |
219 | } | |
220 | } | |
221 | ||
0145e89a | 222 | //_____________________________________________________________________________ |
223 | void | |
224 | AliMUONManuPadPainter::PaintArea(const AliMUONVTrackerData& data, | |
225 | Int_t dataIndex, | |
226 | Double_t min, | |
227 | Double_t max) | |
228 | { | |
229 | /// Paint area of this manu pads according to the data | |
230 | ||
231 | if ( !gPad ) return; | |
232 | ||
233 | if ( ! data.HasManu(fDetElemId,fManuId) ) return; | |
234 | ||
235 | AliMUONPainterHelper* h = AliMUONPainterHelper::Instance(); | |
236 | ||
237 | BackupStyle(); | |
238 | ||
239 | Int_t cathode = h->GetCathodeType(fDetElemId,fManuId); | |
240 | ||
241 | gVirtualX->SetLineColor(-1); | |
242 | gVirtualX->SetFillStyle(1); | |
243 | ||
244 | for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i ) | |
245 | { | |
246 | Int_t id = AliMUONVDigit::BuildUniqueID(fDetElemId,fManuId,i,cathode); | |
247 | ||
248 | TVector2 position; | |
249 | TVector2 dimensions; | |
250 | ||
251 | h->PadStore().GetPadGeometry(id,position,dimensions); | |
252 | ||
253 | if ( dimensions.X() > 0 ) | |
254 | { | |
255 | Double_t value = data.Channel(fDetElemId,fManuId,i,dataIndex); | |
256 | ||
257 | if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) continue; | |
258 | ||
259 | Int_t color = h->ColorFromValue(value,min,max); | |
260 | ||
261 | if ( value > 0 ) | |
262 | { | |
263 | AliDebug(1,Form("DE %d manuId %d channel %d value %e min %e max %e color %d", | |
264 | fDetElemId,fManuId,i,value,min,max, | |
265 | color)); | |
266 | } | |
267 | ||
268 | gVirtualX->SetFillColor(color); | |
269 | ||
270 | TVector2 bl(position-dimensions); | |
271 | TVector2 ur(position+dimensions); | |
272 | ||
273 | gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y()); | |
274 | } | |
275 | } | |
276 | ||
277 | RestoreStyle(); | |
278 | } | |
279 | ||
280 | //_____________________________________________________________________________ | |
281 | void | |
282 | AliMUONManuPadPainter::PaintPad(Int_t padId) const | |
283 | { | |
284 | /// Paint a single pad | |
285 | ||
286 | TVector2 position; | |
287 | TVector2 dimensions; | |
288 | ||
289 | AliMUONPainterHelper::Instance()->PadStore().GetPadGeometry(padId,position,dimensions); | |
290 | ||
291 | if ( dimensions.X() > 0 ) | |
292 | { | |
293 | TVector2 bl(position-dimensions); | |
294 | TVector2 ur(position+dimensions); | |
295 | ||
296 | gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y()); | |
297 | } | |
298 | } | |
299 | ||
300 | //_____________________________________________________________________________ | |
301 | void | |
302 | AliMUONManuPadPainter::PaintOutline(Int_t color, Int_t, Double_t x, Double_t y) | |
303 | { | |
304 | /// Paint the outline of our pads | |
305 | ||
306 | if ( !gPad ) return; | |
307 | ||
308 | Int_t lineColor = color >= 0 ? color : GetLineColor(); | |
309 | ||
310 | AliMUONPainterHelper* h = AliMUONPainterHelper::Instance(); | |
311 | ||
312 | AliDebug(1,Form("color=%d lineColor=%d x=%7.3f y=%7.3f",color,lineColor,x,y)); | |
313 | ||
314 | if ( lineColor > 0 ) | |
315 | { | |
316 | BackupStyle(); | |
317 | ||
318 | Int_t cathode = h->GetCathodeType(fDetElemId,fManuId); | |
319 | ||
320 | gVirtualX->SetLineColor(lineColor); | |
321 | gVirtualX->SetFillStyle(0); | |
322 | ||
323 | if ( x < FLT_MAX && y < FLT_MAX ) | |
324 | { | |
325 | // find pad to be drawn | |
326 | AliMpPad pad = PadByPosition(x,y); | |
327 | ||
328 | Int_t id = AliMUONVDigit::BuildUniqueID(fDetElemId,fManuId,pad.GetLocation().GetSecond(),cathode); | |
329 | ||
330 | PaintPad(id); | |
331 | } | |
332 | else | |
333 | { | |
334 | for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i ) | |
335 | { | |
336 | Int_t id = AliMUONVDigit::BuildUniqueID(fDetElemId,fManuId,i,cathode); | |
337 | ||
338 | PaintPad(id); | |
339 | } | |
340 | } | |
341 | RestoreStyle(); | |
342 | } | |
343 | ||
344 | } | |
345 | ||
346 | //_____________________________________________________________________________ | |
347 | AliMpPad | |
348 | AliMUONManuPadPainter::PadByPosition(Double_t x, Double_t y) const | |
349 | { | |
350 | /// Find the pad at given exploded-position (x,y) | |
351 | ||
352 | const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(fDetElemId,fManuId); | |
353 | ||
354 | Double_t xg,yg,zg; | |
355 | Double_t xl,yl,zl; | |
356 | ||
357 | AliMUONPainterHelper::Instance()->Local2Global(fDetElemId,0.0,0.0,0.0,xg,yg,zg); // to get zg | |
358 | ||
359 | AliMUONPainterHelper::Instance()->Global2Local(fDetElemId,x,y,zg,xl,yl,zl); | |
360 | ||
361 | return seg->PadByPosition(TVector2(xl,yl)); | |
362 | } | |
363 | ||
364 | //_____________________________________________________________________________ | |
365 | void | |
366 | AliMUONManuPadPainter::RestoreStyle() | |
367 | { | |
368 | /// Restore line and fill style values | |
369 | ||
370 | gVirtualX->SetFillStyle(fFillStyleBck); | |
371 | gVirtualX->SetFillColor(fFillColorBck); | |
372 | gVirtualX->SetLineColor(fLineColorBck); | |
373 | gVirtualX->SetLineWidth(fLineWidthBck); | |
374 | } | |
375 | ||
376 |