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