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"
20 #include "AliMUONPainterHelper.h"
21 #include "AliMUONPainterPadStore.h"
22 #include "AliMUONVCalibParam.h"
23 #include "AliMUONVDigit.h"
24 #include "AliMUONVTrackerData.h"
25 #include "AliMpConnection.h"
26 #include "AliMpConstants.h"
27 #include "AliMpDDLStore.h"
28 #include "AliMpDetElement.h"
30 #include "AliMpSegmentation.h"
31 #include "AliMpVSegmentation.h"
34 #include <TVirtualPad.h>
35 #include <TVirtualX.h>
37 ///\class AliMUONManuPadPainter
39 /// Painter for the pads of one manu
41 ///\author Laurent Aphecetche, Subatech
44 ClassImp(AliMUONManuPadPainter)
47 //_____________________________________________________________________________
48 AliMUONManuPadPainter::AliMUONManuPadPainter()
60 //_____________________________________________________________________________
61 AliMUONManuPadPainter::AliMUONManuPadPainter(const AliMUONVPainter& mother,
64 : AliMUONVPainter("PAD"),
65 fDetElemId(detElemId),
73 SetID(detElemId,manuId);
74 SetName(Form("%s/PAD",mother.GetName()));
75 SetPathName(Form("%s/PAD",mother.PathName().Data()));
76 SetContour(mother.Contour());
79 //_____________________________________________________________________________
80 AliMUONManuPadPainter::~AliMUONManuPadPainter()
85 //_____________________________________________________________________________
87 AliMUONManuPadPainter::BackupStyle()
89 /// Remember line and fill style values
91 fFillStyleBck = gVirtualX->GetFillStyle();
92 fFillColorBck = gVirtualX->GetFillColor();
93 fLineColorBck = gVirtualX->GetLineColor();
94 fLineWidthBck = gVirtualX->GetLineWidth();
97 //_____________________________________________________________________________
99 AliMUONManuPadPainter::ComputeDataRange(const AliMUONVTrackerData& data,
101 Double_t& dataMin, Double_t& dataMax) const
103 /// Compute data range spanned by this manu pads
104 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(fDetElemId);
109 for ( Int_t manuChannel = 0; manuChannel < AliMpConstants::ManuNofChannels();
112 if ( de->IsConnectedChannel(fManuId,manuChannel) )
114 Double_t value = data.Channel(fDetElemId, fManuId, manuChannel, dataIndex);
115 dataMin = TMath::Min(value,dataMin);
116 dataMax = TMath::Max(value,dataMax);
121 //_____________________________________________________________________________
123 AliMUONManuPadPainter::GetObjectInfo(Int_t px, Int_t py) const
126 return const_cast<char*>(Form("%s:%d:%d",GetName(),px,py));
129 //_____________________________________________________________________________
131 AliMUONManuPadPainter::NameAtPosition(Double_t x, Double_t y) const
133 /// Specific name, dependent on the position within this painter
135 TString name("invalid");
137 AliMpPad pad = PadByPosition(x,y);
141 name = Form("%s%d",PathName().Data(),pad.GetLocation().GetSecond());
147 //_____________________________________________________________________________
149 AliMUONManuPadPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
150 Double_t x, Double_t y)
152 /// Describe data at given location
154 if ( ! data.HasManu(fDetElemId,fManuId) ) return "";
156 AliMpPad pad = PadByPosition(x,y);
160 Double_t value = data.Channel(fDetElemId,fManuId,pad.GetLocation().GetSecond(),dataIndex);
162 return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
170 //_____________________________________________________________________________
172 AliMUONManuPadPainter::PaintArea(const AliMUONVTrackerData& data,
177 /// Paint area of this manu pads according to the data
181 if ( ! data.HasManu(fDetElemId,fManuId) ) return;
183 AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
187 Int_t cathode = h->GetCathodeType(fDetElemId,fManuId);
189 gVirtualX->SetLineColor(-1);
190 gVirtualX->SetFillStyle(1);
192 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
194 Int_t id = AliMUONVDigit::BuildUniqueID(fDetElemId,fManuId,i,cathode);
199 h->PadStore().GetPadGeometry(id,position,dimensions);
201 if ( dimensions.X() > 0 )
203 Double_t value = data.Channel(fDetElemId,fManuId,i,dataIndex);
205 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) continue;
207 Int_t color = h->ColorFromValue(value,min,max);
211 AliDebug(1,Form("DE %d manuId %d channel %d value %e min %e max %e color %d",
212 fDetElemId,fManuId,i,value,min,max,
216 gVirtualX->SetFillColor(color);
218 TVector2 bl(position-dimensions);
219 TVector2 ur(position+dimensions);
221 gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
228 //_____________________________________________________________________________
230 AliMUONManuPadPainter::PaintPad(Int_t padId) const
232 /// Paint a single pad
237 AliMUONPainterHelper::Instance()->PadStore().GetPadGeometry(padId,position,dimensions);
239 if ( dimensions.X() > 0 )
241 TVector2 bl(position-dimensions);
242 TVector2 ur(position+dimensions);
244 gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
248 //_____________________________________________________________________________
250 AliMUONManuPadPainter::PaintOutline(Int_t color, Int_t, Double_t x, Double_t y)
252 /// Paint the outline of our pads
256 Int_t lineColor = color >= 0 ? color : GetLineColor();
258 AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
260 AliDebug(1,Form("color=%d lineColor=%d x=%7.3f y=%7.3f",color,lineColor,x,y));
266 Int_t cathode = h->GetCathodeType(fDetElemId,fManuId);
268 gVirtualX->SetLineColor(lineColor);
269 gVirtualX->SetFillStyle(0);
271 if ( x < FLT_MAX && y < FLT_MAX )
273 // find pad to be drawn
274 AliMpPad pad = PadByPosition(x,y);
276 Int_t id = AliMUONVDigit::BuildUniqueID(fDetElemId,fManuId,pad.GetLocation().GetSecond(),cathode);
282 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
284 Int_t id = AliMUONVDigit::BuildUniqueID(fDetElemId,fManuId,i,cathode);
294 //_____________________________________________________________________________
296 AliMUONManuPadPainter::PadByPosition(Double_t x, Double_t y) const
298 /// Find the pad at given exploded-position (x,y)
300 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(fDetElemId,fManuId);
305 AliMUONPainterHelper::Instance()->Local2Global(fDetElemId,0.0,0.0,0.0,xg,yg,zg); // to get zg
307 AliMUONPainterHelper::Instance()->Global2Local(fDetElemId,x,y,zg,xl,yl,zl);
309 return seg->PadByPosition(TVector2(xl,yl));
312 //_____________________________________________________________________________
314 AliMUONManuPadPainter::RestoreStyle()
316 /// Restore line and fill style values
318 gVirtualX->SetFillStyle(fFillStyleBck);
319 gVirtualX->SetFillColor(fFillColorBck);
320 gVirtualX->SetLineColor(fLineColorBck);
321 gVirtualX->SetLineWidth(fLineWidthBck);