1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONManuPadPainter.h"
21 #include "AliMUONPainterGroup.h"
22 #include "AliMUONPainterHelper.h"
23 #include "AliMUONPainterPadStore.h"
24 #include "AliMUONTrackerDataHistogrammer.h"
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"
33 #include "AliMpSegmentation.h"
34 #include "AliMpVSegmentation.h"
37 #include <TVirtualPad.h>
38 #include <TVirtualX.h>
41 ///\class AliMUONManuPadPainter
43 /// Painter for the pads of one manu
45 ///\author Laurent Aphecetche, Subatech
48 ClassImp(AliMUONManuPadPainter)
51 //_____________________________________________________________________________
52 AliMUONManuPadPainter::AliMUONManuPadPainter()
64 //_____________________________________________________________________________
65 AliMUONManuPadPainter::AliMUONManuPadPainter(const AliMUONVPainter& mother,
68 : AliMUONVPainter("PAD"),
69 fDetElemId(detElemId),
77 SetID(detElemId,manuId);
78 SetName(Form("%s/PAD",mother.GetName()));
79 SetPathName(Form("%s/PAD",mother.PathName().Data()));
80 SetContour(mother.Contour());
83 //_____________________________________________________________________________
84 AliMUONManuPadPainter::~AliMUONManuPadPainter()
89 //_____________________________________________________________________________
91 AliMUONManuPadPainter::BackupStyle()
93 /// Remember line and fill style values
95 fFillStyleBck = gVirtualX->GetFillStyle();
96 fFillColorBck = gVirtualX->GetFillColor();
97 fLineColorBck = gVirtualX->GetLineColor();
98 fLineWidthBck = gVirtualX->GetLineWidth();
101 //_____________________________________________________________________________
103 AliMUONManuPadPainter::ComputeDataRange(const AliMUONVTrackerData& data,
105 Double_t& dataMin, Double_t& dataMax) const
107 /// Compute data range spanned by this manu pads
108 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(fDetElemId);
113 for ( Int_t manuChannel = 0; manuChannel < AliMpConstants::ManuNofChannels();
116 if ( de->IsConnectedChannel(fManuId,manuChannel) )
118 Double_t value = data.Channel(fDetElemId, fManuId, manuChannel, dataIndex);
119 dataMin = TMath::Min(value,dataMin);
120 dataMax = TMath::Max(value,dataMax);
125 //_____________________________________________________________________________
127 AliMUONManuPadPainter::GetObjectInfo(Int_t px, Int_t py) const
130 return const_cast<char*>(Form("%s:%d:%d",GetName(),px,py));
133 //_____________________________________________________________________________
135 AliMUONManuPadPainter::NameAtPosition(Double_t x, Double_t y) const
137 /// Specific name, dependent on the position within this painter
139 TString name("invalid");
141 AliMpPad pad = PadByPosition(x,y);
145 name = Form("%s%d",PathName().Data(),pad.GetLocation().GetSecond());
151 //_____________________________________________________________________________
153 AliMUONManuPadPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
154 Double_t x, Double_t y)
156 /// Describe data at given location
158 if ( ! data.HasManu(fDetElemId,fManuId) ) return "";
160 AliMpPad pad = PadByPosition(x,y);
164 Double_t value = data.Channel(fDetElemId,fManuId,pad.GetLocation().GetSecond(),dataIndex);
166 return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
174 //_____________________________________________________________________________
176 AliMUONManuPadPainter::DrawHistogramClone(Double_t* values) const
178 /// Draw histogram for pad at (values[0],values[1])
180 if ( !values ) return;
182 AliMUONPainterGroup* group = Master()->PlotterGroup();
184 if ( !group ) return; // no data to histogram in this painter
186 AliMpPad pad = PadByPosition(values[0],values[1]);
188 AliMUONVTrackerData* data = group->Data();
190 AliMUONTrackerDataHistogrammer tdh(*data,0,-1);
192 fHistogram = tdh.CreateChannelHisto(fDetElemId, fManuId,
193 pad.GetLocation().GetSecond());
201 //_____________________________________________________________________________
203 AliMUONManuPadPainter::PaintArea(const AliMUONVTrackerData& data,
208 /// Paint area of this manu pads according to the data
212 if ( ! data.HasManu(fDetElemId,fManuId) ) return;
214 AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
218 Int_t cathode = h->GetCathodeType(fDetElemId,fManuId);
220 gVirtualX->SetLineColor(-1);
221 gVirtualX->SetFillStyle(1);
223 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
225 Int_t id = AliMUONVDigit::BuildUniqueID(fDetElemId,fManuId,i,cathode);
230 h->PadStore().GetPadGeometry(id,position,dimensions);
232 if ( dimensions.X() > 0 )
234 Double_t value = data.Channel(fDetElemId,fManuId,i,dataIndex);
236 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) continue;
238 Int_t color = h->ColorFromValue(value,min,max);
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,
247 gVirtualX->SetFillColor(color);
249 TVector2 bl(position-dimensions);
250 TVector2 ur(position+dimensions);
252 gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
259 //_____________________________________________________________________________
261 AliMUONManuPadPainter::PaintPad(Int_t padId) const
263 /// Paint a single pad
268 AliMUONPainterHelper::Instance()->PadStore().GetPadGeometry(padId,position,dimensions);
270 if ( dimensions.X() > 0 )
272 TVector2 bl(position-dimensions);
273 TVector2 ur(position+dimensions);
275 gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
279 //_____________________________________________________________________________
281 AliMUONManuPadPainter::PaintOutline(Int_t color, Int_t, Double_t x, Double_t y)
283 /// Paint the outline of our pads
287 Int_t lineColor = color >= 0 ? color : GetLineColor();
289 AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
291 AliDebug(1,Form("color=%d lineColor=%d x=%7.3f y=%7.3f",color,lineColor,x,y));
297 Int_t cathode = h->GetCathodeType(fDetElemId,fManuId);
299 gVirtualX->SetLineColor(lineColor);
300 gVirtualX->SetFillStyle(0);
302 if ( x < FLT_MAX && y < FLT_MAX )
304 // find pad to be drawn
305 AliMpPad pad = PadByPosition(x,y);
307 Int_t id = AliMUONVDigit::BuildUniqueID(fDetElemId,fManuId,pad.GetLocation().GetSecond(),cathode);
313 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
315 Int_t id = AliMUONVDigit::BuildUniqueID(fDetElemId,fManuId,i,cathode);
325 //_____________________________________________________________________________
327 AliMUONManuPadPainter::PadByPosition(Double_t x, Double_t y) const
329 /// Find the pad at given exploded-position (x,y)
331 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(fDetElemId,fManuId);
336 AliMUONPainterHelper::Instance()->Local2Global(fDetElemId,0.0,0.0,0.0,xg,yg,zg); // to get zg
338 AliMUONPainterHelper::Instance()->Global2Local(fDetElemId,x,y,zg,xl,yl,zl);
340 return seg->PadByPosition(TVector2(xl,yl));
343 //_____________________________________________________________________________
345 AliMUONManuPadPainter::RestoreStyle()
347 /// Restore line and fill style values
349 gVirtualX->SetFillStyle(fFillStyleBck);
350 gVirtualX->SetFillColor(fFillColorBck);
351 gVirtualX->SetLineColor(fLineColorBck);
352 gVirtualX->SetLineWidth(fLineWidthBck);