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