AliRoot Core  a565103 (a565103)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONManuPadPainter.cxx
Go to the documentation of this file.
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"
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 
44 
48 
49 //_____________________________________________________________________________
51 : AliMUONVPainter(),
52 fDetElemId(-1),
53 fManuId(-1),
54 fLineColorBck(-1),
55 fLineWidthBck(-1),
56 fFillColorBck(-1),
57 fFillStyleBck(-1)
58 {
60 }
61 
62 //_____________________________________________________________________________
64 : AliMUONVPainter(ioCtor),
65 fDetElemId(-1),
66 fManuId(-1),
67 fLineColorBck(-1),
68 fLineWidthBck(-1),
69 fFillColorBck(-1),
70 fFillStyleBck(-1)
71 {
73 }
74 
75 //_____________________________________________________________________________
77  Int_t detElemId,
78  Int_t manuId)
79 : AliMUONVPainter("PAD"),
80 fDetElemId(detElemId),
81 fManuId(manuId),
82 fLineColorBck(-1),
83 fLineWidthBck(-1),
84 fFillColorBck(-1),
85 fFillStyleBck(-1)
86 {
88  SetID(detElemId,manuId);
89  SetName(Form("%s/PAD",mother.GetName()));
90  SetPathName(Form("%s/PAD",mother.PathName().Data()));
91  SetContour(mother.Contour());
92 }
93 
94 //_____________________________________________________________________________
96 {
98 }
99 
100 //_____________________________________________________________________________
101 void
103 {
105 
106  fFillStyleBck = gVirtualX->GetFillStyle();
107  fFillColorBck = gVirtualX->GetFillColor();
108  fLineColorBck = gVirtualX->GetLineColor();
109  fLineWidthBck = gVirtualX->GetLineWidth();
110 }
111 
112 //_____________________________________________________________________________
113 void
115  Int_t dataIndex,
116  Double_t& dataMin, Double_t& dataMax) const
117 {
120 
121  dataMin = FLT_MAX;
122  dataMax = -FLT_MAX;
123 
124  for ( Int_t manuChannel = 0; manuChannel < AliMpConstants::ManuNofChannels();
125  ++manuChannel )
126  {
127  if ( seg->HasPadByLocation(fManuId,manuChannel) )
128  {
129  Double_t value = data.Channel(fDetElemId, fManuId, manuChannel, dataIndex);
130  dataMin = TMath::Min(value,dataMin);
131  dataMax = TMath::Max(value,dataMax);
132  }
133  }
134 }
135 
136 //_____________________________________________________________________________
137 char*
138 AliMUONManuPadPainter::GetObjectInfo(Int_t px, Int_t py) const
139 {
141  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 {
149 
150  TString name("invalid");
151 
152  AliMpPad pad = PadByPosition(x,y);
153 
154  if ( pad.IsValid() )
155  {
156  name = Form("%s%d",PathName().Data(),pad.GetManuChannel());
157  }
158 
159  return name;
160 }
161 
162 //_____________________________________________________________________________
163 Bool_t
165 {
167  return ( InteractiveReadOutConfig()->Manu(fDetElemId,fManuId) > 0 );
168 }
169 
170 //_____________________________________________________________________________
171 TString
173  Double_t x, Double_t y)
174 {
176 
177  if ( ! data.HasManu(fDetElemId,fManuId) ) return "";
178 
179  AliMpPad pad = PadByPosition(x,y);
180 
181  if ( pad.IsValid() )
182  {
183  Double_t value = data.Channel(fDetElemId,fManuId,pad.GetManuChannel(),dataIndex);
184 
185  return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
186  }
187  else
188  {
189  return "invalid";
190  }
191 }
192 
193 //_____________________________________________________________________________
194 void
196 {
198 
199  if ( !values ) return;
200 
202 
203  if ( !group ) return; // no data to histogram in this painter
204 
205  AliMpPad pad = PadByPosition(values[0],values[1]);
206 
207  AliMUONVTrackerData* data = group->Data();
208 
209  AliMUONTrackerDataHistogrammer tdh(*data,0,-1);
210 
212 
213  if (fHistogram)
214  {
215  new TCanvas();
216  fHistogram->Draw();
217  }
218 }
219 
220 //_____________________________________________________________________________
221 void
223  Int_t dataIndex,
224  Double_t min,
225  Double_t max)
226 {
228 
229  if ( !gPad ) return;
230 
231  if ( ! data.HasManu(fDetElemId,fManuId) ) return;
232 
234 
235  BackupStyle();
236 
237  gVirtualX->SetLineColor(-1);
238  gVirtualX->SetFillStyle(1001);
239 
241 
242  for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
243  {
244  AliMpPad pad = seg->PadByLocation(fManuId,i,kFALSE);
245 
246  if ( pad.IsValid() )
247  {
248  Double_t value = data.Channel(fDetElemId,fManuId,i,dataIndex);
249 
250  if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) continue;
251 
252  Int_t color = h->ColorFromValue(value,min,max);
253 
254  gVirtualX->SetFillColor(color);
255 
256  PaintPad(pad);
257 
258  }
259  }
260 
261  RestoreStyle();
262 }
263 
264 //_____________________________________________________________________________
265 void
267 {
268  Double_t blx = pad.GetPositionX()-pad.GetDimensionX();
269  Double_t bly = pad.GetPositionY()-pad.GetDimensionY();
270 
271  Double_t urx = pad.GetPositionX()+pad.GetDimensionX();
272  Double_t ury = pad.GetPositionY()+pad.GetDimensionY();
273 
274  Double_t xe1,ye1,xe2,ye2,z;
275 
278 
279  gPad->PaintBox(xe1,ye1,xe2,ye2);
280 }
281 
282 //_____________________________________________________________________________
283 void
284 AliMUONManuPadPainter::PaintOutline(Int_t color, Int_t, Double_t x, Double_t y)
285 {
287 
288  if ( !gPad ) return;
289 
290  Int_t lineColor = color >= 0 ? color : GetLineColor();
291 
292  if ( lineColor > 0 )
293  {
294  BackupStyle();
295 
296  gVirtualX->SetLineColor(lineColor);
297  gVirtualX->SetFillStyle(0);
298 
299  if ( x < FLT_MAX && y < FLT_MAX )
300  {
301  // find pad to be drawn
302  AliMpPad pad = PadByPosition(x,y);
303 
304  PaintPad(pad);
305  }
306  else
307  {
309 
310  for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
311  {
312  AliMpPad pad = seg->PadByLocation(fManuId,i,kFALSE);
313 
314  if (pad.IsValid()) PaintPad(pad);
315 
316  PaintPad(pad);
317  }
318  }
319  RestoreStyle();
320  }
321 
322 }
323 
324 //_____________________________________________________________________________
325 AliMpPad
326 AliMUONManuPadPainter::PadByPosition(Double_t x, Double_t y) const
327 {
329 
331 
332  Double_t xg,yg,zg;
333  Double_t xl,yl,zl;
334 
335  AliMUONPainterHelper::Instance()->Local2Global(fDetElemId,0.0,0.0,0.0,xg,yg,zg); // to get zg
336 
338 
339  return seg->PadByPosition(xl,yl);
340 }
341 
342 //_____________________________________________________________________________
343 void
345 {
347 
348  gVirtualX->SetFillStyle(fFillStyleBck);
349  gVirtualX->SetFillColor(fFillColorBck);
350  gVirtualX->SetLineColor(fLineColorBck);
351  gVirtualX->SetLineWidth(fLineWidthBck);
352 }
353 
354 
virtual Bool_t IsIncluded() const
Whether or not the part of the detector represented by this painter should be included in readout...
virtual TString Describe(const AliMUONVTrackerData &data, Int_t dataIndex, Double_t x=FLT_MAX, Double_t y=FLT_MAX)
Int_t ColorFromValue(Double_t value, Double_t min, Double_t max) const
static AliMUONPainterHelper * Instance()
TString NameAtPosition(Double_t x, Double_t y) const
Return specific name at a given position, if needed.
void SetID(Int_t id0, Int_t id1)
Set our IDs.
static Float_t InvalidFloatValue()
Return 1E38 as invalid float value.
void Local2Global(Int_t detElemId, Double_t xl, Double_t yl, Double_t zl, Double_t &xg, Double_t &yg, Double_t &zg) const
static AliMpSegmentation * Instance(Bool_t warn=true)
Int_t fFillStyleBck
fill style for backup
AliMUONVTrackerData * InteractiveReadOutConfig() const
Make histograms from VTrackerData and VPainter objects.
void SetContour(AliMUONContour *contour)
Set out contour.
TH1 * fHistogram
! histogram
virtual Bool_t HasManu(Int_t detElemId, Int_t manuId) const =0
Whether we have data for a given manu.
virtual Double_t Channel(Int_t detElemId, Int_t manuId, Int_t manuChannel, Int_t dim=0) const =0
Get the value for a given channel and given dimension.
const AliMpVSegmentation * GetMpSegmentationByElectronics(Int_t detElemId, Int_t elCardID, Bool_t warn=true) const
virtual const char * GetName() const
Get our name.
virtual TString PathName() const
Get our path name (aka fullname)
Int_t fFillColorBck
fill color for backup
virtual char * GetObjectInfo(Int_t px, Int_t py) const
virtual TString DimensionName(Int_t dim) const =0
Get the name of a given (internal) dimension.
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Int_t GetManuChannel() const
Definition: AliMpPad.cxx:264
AliMUONVTrackerData * Data() const
Return the data we are plotting.
static Int_t ManuNofChannels()
Max number of channels per manu.
void SetName(const char *name)
Set our name.
Base class for a graphical object representing some part of the MUON tracking system.
void PaintArea(const AliMUONVTrackerData &data, Int_t dataIndex, Double_t min, Double_t max)
Int_t fLineColorBck
line color for backup
AliMUONContour * Contour() const
Return the contour representing the outline of this object.
void SetPathName(const char *pathName)
Set our path name (aka fullname)
Int_t GetLineColor() const
Get our line color.
Double_t GetPositionY() const
Return the pad x position (in cm)
Definition: AliMpPad.h:81
AliMUONVPainter * Master() const
Int_t fDetElemId
our detection element id
void PaintOutline(Int_t color=-1, Int_t width=-1, Double_t x=FLT_MAX, Double_t y=FLT_MAX)
Utility class for the painters display.
TH1 * CreateChannelHisto(Int_t detElemId, Int_t manuId, Int_t manuChannel) const
Painter for the pads of one manu.
Bool_t IsValid() const
Return validity.
Definition: AliMpPad.h:89
virtual AliMpPad PadByPosition(Double_t x, Double_t y, Bool_t warning=true) const =0
Find pad by position.
void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg, Double_t &xl, Double_t &yl, Double_t &zl) const
virtual Bool_t HasPadByLocation(Int_t manuId, Int_t manuChannel) const
Return true if the pad with given location exists.
The abstract base class for the segmentation.
Double_t GetDimensionY() const
Return the y pad dimension - half length (in cm)
Definition: AliMpPad.h:86
Class which encapsuate all information about a pad.
Definition: AliMpPad.h:22
Double_t GetPositionX() const
Return the pad x position (in cm)
Definition: AliMpPad.h:79
TString FormatValue(const char *name, Double_t value) const
void PaintPad(const AliMpPad &pad) const
AliMpPad PadByPosition(Double_t x, Double_t y) const
A group of AliMUONVPainter.
virtual AliMpPad PadByLocation(Int_t manuId, Int_t manuChannel, Bool_t warning=true) const =0
Find pad by location.
Int_t fLineWidthBck
line width for backup
AliMUONPainterGroup * PlotterGroup() const
Return the plotter group.
virtual void DrawHistogramClone(Double_t *values=0x0) const
virtual void ComputeDataRange(const AliMUONVTrackerData &data, Int_t dataIndex, Double_t &dataMin, Double_t &dataMax) const
Base class for MUON data that can be presented at different levels in the hierarchy of the MUON syste...
Double_t GetDimensionX() const
Return the x pad dimension - half length (in cm)
Definition: AliMpPad.h:84